8371698: ZGC: Call GTEST_SKIP when OS is unsupported

Reviewed-by: aboldtch, jsikstro, mdoerr
This commit is contained in:
Stefan Karlsson 2025-11-18 11:57:58 +00:00
parent 28d94d6ab4
commit df5b105bbb
4 changed files with 9 additions and 31 deletions

View File

@ -51,11 +51,6 @@ public:
zoffset _page_offset;
virtual void SetUp() {
// Only run test on supported Windows versions
if (!is_os_supported()) {
GTEST_SKIP() << "OS not supported";
}
_old_heap = ZHeap::_heap;
ZHeap::_heap = (ZHeap*)os::malloc(sizeof(ZHeap), mtTest);
@ -83,11 +78,6 @@ public:
}
virtual void TearDown() {
if (!is_os_supported()) {
// Test skipped, nothing to cleanup
return;
}
os::free(ZHeap::_heap);
ZHeap::_heap = _old_heap;
ZGeneration::_old = _old_old;

View File

@ -42,11 +42,6 @@ private:
public:
virtual void SetUp() {
// Only run test on supported Windows versions
if (!is_os_supported()) {
GTEST_SKIP() << "OS not supported";
}
_zaddress_reserver.SetUp(ReservationSize);
_reserver = _zaddress_reserver.reserver();
_registry = _zaddress_reserver.registry();
@ -58,11 +53,6 @@ public:
}
virtual void TearDown() {
if (!is_os_supported()) {
// Test skipped, nothing to cleanup
return;
}
// Best-effort cleanup
_registry = nullptr;
_reserver = nullptr;

View File

@ -62,11 +62,6 @@ private:
public:
virtual void SetUp() {
// Only run test on supported Windows versions
if (!is_os_supported()) {
GTEST_SKIP() << "OS not supported";
}
_zaddress_reserver.SetUp(ReservationSize);
_reserver = _zaddress_reserver.reserver();
_registry = _zaddress_reserver.registry();
@ -78,11 +73,6 @@ public:
}
virtual void TearDown() {
if (!is_os_supported()) {
// Test skipped, nothing to cleanup
return;
}
_registry = nullptr;
_reserver = nullptr;
_zaddress_reserver.TearDown();

View File

@ -76,7 +76,6 @@ public:
}
void SetUp(size_t reservation_size) {
GTEST_EXPECT_TRUE(ZArguments::is_os_supported()) << "Should not use SetUp on unsupported systems";
GTEST_EXPECT_FALSE(_active) << "SetUp called twice without a TearDown";
_active = true;
@ -109,12 +108,21 @@ private:
ZAddressOffsetMaxSetter _zaddress_offset_max_setter;
unsigned int _rand_seed;
void skip_all_tests() {
// Skipping from the constructor currently works, but according to the
// documentation the GTEST_SKIP macro should be used from the test or
// from the SetUp function. If this start to fail down the road, then
// we'll have to explicitly call this for each inheriting gtest.
GTEST_SKIP() << "OS not supported";
}
protected:
ZTest()
: _zaddress_offset_max_setter(ZAddressOffsetMax),
_rand_seed(static_cast<unsigned int>(::testing::UnitTest::GetInstance()->random_seed())) {
if (!is_os_supported()) {
// If the OS does not support ZGC do not run initialization, as it may crash the VM.
skip_all_tests();
return;
}