ZGC: Split ZTest into a VM and not VM test fixture

This commit is contained in:
Axel Boldt-Christmas 2025-11-19 15:29:17 +00:00
parent 2c22648e7b
commit bdcdbf9428
11 changed files with 29 additions and 21 deletions

View File

@ -29,7 +29,7 @@
class CollectedHeap;
class ZArguments : public GCArguments {
friend class ZTest;
friend class ZVMTest;
private:
static void select_max_gc_threads();

View File

@ -36,7 +36,7 @@ public:
};
class ZInitialize : public AllStatic {
friend class ZTest;
friend class ZVMTest;
private:
static constexpr size_t ErrorMessageLength = 256;

View File

@ -31,7 +31,7 @@
class ZNUMA : public AllStatic {
friend class VMStructs;
friend class ZNUMATest;
friend class ZTest;
friend class ZVMTest;
private:
static bool _enabled;

View File

@ -33,9 +33,9 @@
using ZVirtualMemoryRegistry = ZRangeRegistry<ZVirtualMemory>;
class ZVirtualMemoryReserver {
friend class ZTest;
friend class ZMapperTest;
friend class ZVirtualMemoryManagerTest;
friend class ZVMTest;
private:

View File

@ -25,7 +25,7 @@
#include "gc/z/zGlobals.hpp"
#include "zunittest.hpp"
class ZAddressTest : public ZTest {
class ZAddressTest : public ZVMTest {
protected:
static zpointer color(uintptr_t value, uintptr_t color) {
return ZAddress::color(zaddress(value | ZAddressHeapBase), color);

View File

@ -41,7 +41,7 @@ using namespace testing;
#define CAPTURE(expression) CAPTURE1(expression)
class ZForwardingTest : public ZTest {
class ZForwardingTest : public ZVMTest {
public:
// Setup and tear down
ZHeap* _old_heap;

View File

@ -26,7 +26,7 @@
#include "gc/z/zLiveMap.inline.hpp"
#include "zunittest.hpp"
class ZLiveMapTest : public ZTest {
class ZLiveMapTest : public ZVMTest {
private:
// Setup and tear down
ZHeap* _old_heap;

View File

@ -32,7 +32,7 @@
using namespace testing;
class ZMapperTest : public ZTest {
class ZMapperTest : public ZVMTest {
private:
static constexpr size_t ReservationSize = 3 * ZGranuleSize;

View File

@ -52,7 +52,7 @@ public:
}
};
class ZVirtualMemoryManagerTest : public ZTest {
class ZVirtualMemoryManagerTest : public ZVMTest {
private:
static constexpr size_t ReservationSize = 32 * M;

View File

@ -41,7 +41,7 @@ inline std::ostream& operator<<(std::ostream& str, const ZVirtualMemory& vmem) {
}
class ZAddressOffsetMaxSetter {
friend class ZTest;
friend class ZVMTest;
private:
size_t _old_max;
@ -61,6 +61,21 @@ public:
};
class ZTest : public testing::Test {
private:
unsigned int _rand_seed;
protected:
ZTest()
: _rand_seed(static_cast<unsigned int>(::testing::UnitTest::GetInstance()->random_seed())) {}
int random() {
const int next_seed = os::next_random(_rand_seed);
_rand_seed = static_cast<unsigned int>(next_seed);
return next_seed;
}
};
class ZVMTest : public ZTest {
public:
class ZAddressReserver {
ZVirtualMemoryReserver* _reserver;
@ -106,7 +121,6 @@ public:
private:
ZAddressOffsetMaxSetter _zaddress_offset_max_setter;
unsigned int _rand_seed;
void skip_all_tests() {
// Skipping from the constructor currently works, but according to the
@ -117,9 +131,8 @@ private:
}
protected:
ZTest()
: _zaddress_offset_max_setter(ZAddressOffsetMax),
_rand_seed(static_cast<unsigned int>(::testing::UnitTest::GetInstance()->random_seed())) {
ZVMTest()
: _zaddress_offset_max_setter(ZAddressOffsetMax) {
if (!is_os_supported()) {
// If the OS does not support ZGC do not run initialization, as it may crash the VM.
skip_all_tests();
@ -138,12 +151,9 @@ protected:
_zaddress_offset_max_setter._old_mask = ZAddressOffsetMask;
return true;
}();
}
int random() {
const int next_seed = os::next_random(_rand_seed);
_rand_seed = static_cast<unsigned int>(next_seed);
return next_seed;
// Silence unused variable warning
(void)runs_once;
}
bool is_os_supported() {

View File

@ -57,8 +57,6 @@ public class AllNotVMGtest {
TF("LogOutputList.level_for"),
TF("os_linux.addr_to_function_valid"),
TF("Semaphore.trywait", Platform.isOSX()),
TF("ZArrayTest.slice"),
TF("ZNUMATest.calculate_share"),
};
public static Stream<String> getFilteredTests() {