diff --git a/src/hotspot/share/gc/z/zArguments.hpp b/src/hotspot/share/gc/z/zArguments.hpp index 8bbd88f357c..83165b8ec9b 100644 --- a/src/hotspot/share/gc/z/zArguments.hpp +++ b/src/hotspot/share/gc/z/zArguments.hpp @@ -29,7 +29,7 @@ class CollectedHeap; class ZArguments : public GCArguments { - friend class ZTest; + friend class ZVMTest; private: static void select_max_gc_threads(); diff --git a/src/hotspot/share/gc/z/zInitialize.hpp b/src/hotspot/share/gc/z/zInitialize.hpp index 6d297655352..6c6becc08e8 100644 --- a/src/hotspot/share/gc/z/zInitialize.hpp +++ b/src/hotspot/share/gc/z/zInitialize.hpp @@ -36,7 +36,7 @@ public: }; class ZInitialize : public AllStatic { - friend class ZTest; + friend class ZVMTest; private: static constexpr size_t ErrorMessageLength = 256; diff --git a/src/hotspot/share/gc/z/zNUMA.hpp b/src/hotspot/share/gc/z/zNUMA.hpp index 838a114c210..1e668a70a74 100644 --- a/src/hotspot/share/gc/z/zNUMA.hpp +++ b/src/hotspot/share/gc/z/zNUMA.hpp @@ -31,7 +31,7 @@ class ZNUMA : public AllStatic { friend class VMStructs; friend class ZNUMATest; - friend class ZTest; + friend class ZVMTest; private: static bool _enabled; diff --git a/src/hotspot/share/gc/z/zVirtualMemoryManager.hpp b/src/hotspot/share/gc/z/zVirtualMemoryManager.hpp index 0fd6045d633..3ddfa69504c 100644 --- a/src/hotspot/share/gc/z/zVirtualMemoryManager.hpp +++ b/src/hotspot/share/gc/z/zVirtualMemoryManager.hpp @@ -33,9 +33,9 @@ using ZVirtualMemoryRegistry = ZRangeRegistry; class ZVirtualMemoryReserver { - friend class ZTest; friend class ZMapperTest; friend class ZVirtualMemoryManagerTest; + friend class ZVMTest; private: diff --git a/test/hotspot/gtest/gc/z/test_zAddress.cpp b/test/hotspot/gtest/gc/z/test_zAddress.cpp index 0df77b01ad2..b6b9910104d 100644 --- a/test/hotspot/gtest/gc/z/test_zAddress.cpp +++ b/test/hotspot/gtest/gc/z/test_zAddress.cpp @@ -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); diff --git a/test/hotspot/gtest/gc/z/test_zForwarding.cpp b/test/hotspot/gtest/gc/z/test_zForwarding.cpp index 5275b78fb82..7366a081e31 100644 --- a/test/hotspot/gtest/gc/z/test_zForwarding.cpp +++ b/test/hotspot/gtest/gc/z/test_zForwarding.cpp @@ -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; diff --git a/test/hotspot/gtest/gc/z/test_zLiveMap.cpp b/test/hotspot/gtest/gc/z/test_zLiveMap.cpp index da956b70b2a..abde16090ec 100644 --- a/test/hotspot/gtest/gc/z/test_zLiveMap.cpp +++ b/test/hotspot/gtest/gc/z/test_zLiveMap.cpp @@ -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; diff --git a/test/hotspot/gtest/gc/z/test_zMapper_windows.cpp b/test/hotspot/gtest/gc/z/test_zMapper_windows.cpp index 95e6317dfd8..6e1961e3f3a 100644 --- a/test/hotspot/gtest/gc/z/test_zMapper_windows.cpp +++ b/test/hotspot/gtest/gc/z/test_zMapper_windows.cpp @@ -32,7 +32,7 @@ using namespace testing; -class ZMapperTest : public ZTest { +class ZMapperTest : public ZVMTest { private: static constexpr size_t ReservationSize = 3 * ZGranuleSize; diff --git a/test/hotspot/gtest/gc/z/test_zVirtualMemoryManager.cpp b/test/hotspot/gtest/gc/z/test_zVirtualMemoryManager.cpp index 7c41dde04cb..076d6ce4494 100644 --- a/test/hotspot/gtest/gc/z/test_zVirtualMemoryManager.cpp +++ b/test/hotspot/gtest/gc/z/test_zVirtualMemoryManager.cpp @@ -52,7 +52,7 @@ public: } }; -class ZVirtualMemoryManagerTest : public ZTest { +class ZVirtualMemoryManagerTest : public ZVMTest { private: static constexpr size_t ReservationSize = 32 * M; diff --git a/test/hotspot/gtest/gc/z/zunittest.hpp b/test/hotspot/gtest/gc/z/zunittest.hpp index 2464f821380..09d7b9e1460 100644 --- a/test/hotspot/gtest/gc/z/zunittest.hpp +++ b/test/hotspot/gtest/gc/z/zunittest.hpp @@ -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(::testing::UnitTest::GetInstance()->random_seed())) {} + + int random() { + const int next_seed = os::next_random(_rand_seed); + _rand_seed = static_cast(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(::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(next_seed); - return next_seed; + // Silence unused variable warning + (void)runs_once; } bool is_os_supported() { diff --git a/test/hotspot/jtreg/gtest/AllNotVMGtest.java b/test/hotspot/jtreg/gtest/AllNotVMGtest.java index 817b9848778..0cc0b76a5a9 100644 --- a/test/hotspot/jtreg/gtest/AllNotVMGtest.java +++ b/test/hotspot/jtreg/gtest/AllNotVMGtest.java @@ -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 getFilteredTests() {