xo-gc: scaffold utest for GCObjectStore
This commit is contained in:
parent
268e474cfd
commit
a67d8b962a
6 changed files with 129 additions and 9 deletions
|
|
@ -8,7 +8,6 @@
|
|||
#include "GCObjectStoreConfig.hpp"
|
||||
#include "MutationLogConfig.hpp"
|
||||
#include "object_age.hpp"
|
||||
//#include "Generation.hpp"
|
||||
#include <xo/arena/ArenaConfig.hpp>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ set(UTEST_SRCS
|
|||
Collector.test.cpp
|
||||
X1Collector.test.cpp
|
||||
DX1CollectorIterator.test.cpp
|
||||
GCObjectStore.test.cpp
|
||||
Object2.test.cpp
|
||||
random_allocs.cpp
|
||||
)
|
||||
|
|
|
|||
94
utest/GCObjectStore.test.cpp
Normal file
94
utest/GCObjectStore.test.cpp
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/** @file GCObjectStore.test.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Apr 2026
|
||||
**/
|
||||
|
||||
#include <xo/object2/List.hpp>
|
||||
#include <xo/object2/Integer.hpp>
|
||||
#include <xo/gc/GCObjectStore.hpp>
|
||||
#include <xo/alloc2/GCObject.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace ut {
|
||||
using xo::scm::DList;
|
||||
using xo::scm::DInteger;
|
||||
using xo::mm::GCObjectStoreConfig;
|
||||
using xo::mm::GCObjectStore;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::mm::ArenaConfig;
|
||||
using xo::facet::typeseq;
|
||||
using xo::facet::impl_for;
|
||||
using xo::scope;
|
||||
using std::size_t;
|
||||
using std::uint32_t;
|
||||
|
||||
namespace {
|
||||
struct Testcase {
|
||||
explicit Testcase(uint32_t n_gen, uint32_t n_survive,
|
||||
size_t gc_z, uint32_t type_z)
|
||||
: n_gen_{n_gen},
|
||||
n_survive_{n_survive},
|
||||
gc_size_{gc_z},
|
||||
object_type_z_{type_z}
|
||||
{}
|
||||
|
||||
/** number of generations in gco store **/
|
||||
uint32_t n_gen_ = 0;
|
||||
/** object promotes on surviving this many gc cycles **/
|
||||
uint32_t n_survive_ = 0;
|
||||
/** size of each generation's half-space, in bytes **/
|
||||
size_t gc_size_ = 0;
|
||||
/** Storage for object type array, in bytes.
|
||||
* (need to allow 1 pointer per type)
|
||||
**/
|
||||
uint32_t object_type_z_ = 0;
|
||||
|
||||
};
|
||||
|
||||
static std::vector<Testcase> s_testcase_v = {
|
||||
/** n_gen, n_survive, gc_size, object_type_z **/
|
||||
Testcase(2, 4, 16 * 1024, 8 * 128),
|
||||
};
|
||||
}
|
||||
|
||||
TEST_CASE("GCObjectStore-1", "[GCObjectStore]")
|
||||
{
|
||||
constexpr bool c_debug_flag = false;
|
||||
scope log(XO_DEBUG(c_debug_flag));
|
||||
|
||||
for (size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) {
|
||||
const Testcase & tc = s_testcase_v[i_tc];
|
||||
|
||||
/** config for each half-space **/
|
||||
ArenaConfig arena_config
|
||||
= (ArenaConfig()
|
||||
.with_name("arena-name-not-used")
|
||||
.with_size(tc.gc_size_)
|
||||
.with_store_header_flag(true));
|
||||
|
||||
GCObjectStoreConfig gcos_config(arena_config,
|
||||
tc.n_gen_,
|
||||
tc.n_survive_,
|
||||
tc.object_type_z_,
|
||||
c_debug_flag);
|
||||
|
||||
// object type storage will be empty unless we install a type.
|
||||
GCObjectStore gcos(gcos_config);
|
||||
|
||||
REQUIRE(gcos.is_type_installed(typeseq::id<DList>()) == false);
|
||||
|
||||
//REQUIRE(nullptr == gcos.lookup_type(typeseq::id<DList>()));
|
||||
|
||||
#ifdef NOT_YET
|
||||
|
||||
|
||||
// // Usual path would be via ACollector interface; that's inconvenient here
|
||||
//
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} /*namespace ut*/
|
||||
|
||||
/* end GCObjectStore.test.cpp */
|
||||
|
|
@ -63,7 +63,7 @@ namespace ut {
|
|||
|
||||
TEST_CASE("printable1", "[pp][x1][list]")
|
||||
{
|
||||
constexpr bool c_debug_flag = true;
|
||||
constexpr bool c_debug_flag = false;
|
||||
scope log(XO_DEBUG(c_debug_flag));
|
||||
|
||||
bool ok = SetupObject2::register_facets();
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
#include "DArray.hpp"
|
||||
|
||||
#include <xo/object2/Float.hpp>
|
||||
//#include "number/IGCObject_DFloat.hpp"
|
||||
#include "number/IGCObject_DInteger.hpp"
|
||||
#include "list/IGCObject_DList.hpp"
|
||||
#include <xo/object2/Integer.hpp>
|
||||
#include <xo/object2/List.hpp>
|
||||
//#include "list/IGCObject_DList.hpp"
|
||||
|
||||
#include <xo/alloc2/CollectorTypeRegistry.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/gc/X1Collector.hpp>
|
||||
//#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/CollectorTypeRegistry.hpp>
|
||||
|
||||
#include <xo/arena/AllocInfo.hpp>
|
||||
#include <xo/arena/padding.hpp>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,32 @@
|
|||
/* file gc_utest_main.cpp */
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch2/catch.hpp"
|
||||
#include <xo/gc/init_gc.hpp>
|
||||
#include <xo/subsys/Subsystem.hpp>
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
using xo::S_gc_tag;
|
||||
using xo::InitSubsys;
|
||||
using xo::InitEvidence;
|
||||
|
||||
// ensure xo-gc properly initialized when Subsystem::initialize_all() runs
|
||||
static InitEvidence s_init = (InitSubsys<S_gc_tag>::require());
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
using xo::Subsystem;
|
||||
|
||||
// Your custom initialization code here
|
||||
Subsystem::initialize_all();
|
||||
|
||||
// Run Catch2's test session
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
|
||||
// cleanup here, if any
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* end gc_utest_main.cpp */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue