| File: | jdk/test/hotspot/gtest/runtime/test_os.cpp |
| Warning: | line 206, column 17 Value stored to 'out' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | * or visit www.oracle.com if you need additional information or have any |
| 21 | * questions. |
| 22 | */ |
| 23 | |
| 24 | #include "precompiled.hpp" |
| 25 | #include "memory/allocation.hpp" |
| 26 | #include "memory/resourceArea.hpp" |
| 27 | #include "runtime/os.hpp" |
| 28 | #include "runtime/thread.hpp" |
| 29 | #include "services/memTracker.hpp" |
| 30 | #include "utilities/globalDefinitions.hpp" |
| 31 | #include "utilities/macros.hpp" |
| 32 | #include "utilities/ostream.hpp" |
| 33 | #include "utilities/align.hpp" |
| 34 | #include "unittest.hpp" |
| 35 | |
| 36 | static size_t small_page_size() { |
| 37 | return os::vm_page_size(); |
| 38 | } |
| 39 | |
| 40 | static size_t large_page_size() { |
| 41 | const size_t large_page_size_example = 4 * M; |
| 42 | return os::page_size_for_region_aligned(large_page_size_example, 1); |
| 43 | } |
| 44 | |
| 45 | TEST_VM(os, page_size_for_region)class os_page_size_for_region_vm_Test : public ::testing::Test { public: os_page_size_for_region_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_page_size_for_region_vm_Test(os_page_size_for_region_vm_Test const &) = delete; void operator=(os_page_size_for_region_vm_Test const &) = delete;};::testing::TestInfo* const os_page_size_for_region_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "page_size_for_region_vm", __null, __null, ::testing:: internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 45), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_page_size_for_region_vm_Test >);void os_page_size_for_region_vm_Test::TestBody() { |
| 46 | size_t large_page_example = 4 * M; |
| 47 | size_t large_page = os::page_size_for_region_aligned(large_page_example, 1); |
| 48 | |
| 49 | size_t small_page = os::vm_page_size(); |
| 50 | if (large_page > small_page) { |
| 51 | size_t num_small_in_large = large_page / small_page; |
| 52 | size_t page = os::page_size_for_region_aligned(large_page, num_small_in_large); |
| 53 | ASSERT_EQ(page, small_page)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(page)) == 1)>::Compare("page" , "small_page", page, small_page))) ; else return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 53, gtest_ar.failure_message()) = ::testing::Message() << "Did not get a small page"; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | TEST_VM(os, page_size_for_region_aligned)class os_page_size_for_region_aligned_vm_Test : public ::testing ::Test { public: os_page_size_for_region_aligned_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_page_size_for_region_aligned_vm_Test (os_page_size_for_region_aligned_vm_Test const &) = delete ; void operator=(os_page_size_for_region_aligned_vm_Test const &) = delete;};::testing::TestInfo* const os_page_size_for_region_aligned_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "page_size_for_region_aligned_vm", __null, __null, ::testing ::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 57), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_page_size_for_region_aligned_vm_Test >);void os_page_size_for_region_aligned_vm_Test::TestBody( ) { |
| 58 | if (UseLargePages) { |
| 59 | const size_t small_page = small_page_size(); |
| 60 | const size_t large_page = large_page_size(); |
| 61 | |
| 62 | if (large_page > small_page) { |
| 63 | size_t num_small_pages_in_large = large_page / small_page; |
| 64 | size_t page = os::page_size_for_region_aligned(large_page, num_small_pages_in_large); |
| 65 | |
| 66 | ASSERT_EQ(page, small_page)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(page)) == 1)>::Compare("page" , "small_page", page, small_page))) ; else return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 66, gtest_ar.failure_message()) = ::testing::Message(); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | TEST_VM(os, page_size_for_region_alignment)class os_page_size_for_region_alignment_vm_Test : public ::testing ::Test { public: os_page_size_for_region_alignment_vm_Test() { } private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_page_size_for_region_alignment_vm_Test (os_page_size_for_region_alignment_vm_Test const &) = delete ; void operator=(os_page_size_for_region_alignment_vm_Test const &) = delete;};::testing::TestInfo* const os_page_size_for_region_alignment_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "page_size_for_region_alignment_vm", __null, __null, :: testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 71), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_page_size_for_region_alignment_vm_Test >);void os_page_size_for_region_alignment_vm_Test::TestBody () { |
| 72 | if (UseLargePages) { |
| 73 | const size_t small_page = small_page_size(); |
| 74 | const size_t large_page = large_page_size(); |
| 75 | if (large_page > small_page) { |
| 76 | const size_t unaligned_region = large_page + 17; |
| 77 | size_t page = os::page_size_for_region_aligned(unaligned_region, 1); |
| 78 | ASSERT_EQ(page, small_page)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(page)) == 1)>::Compare("page" , "small_page", page, small_page))) ; else return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 78, gtest_ar.failure_message()) = ::testing::Message(); |
| 79 | |
| 80 | const size_t num_pages = 5; |
| 81 | const size_t aligned_region = large_page * num_pages; |
| 82 | page = os::page_size_for_region_aligned(aligned_region, num_pages); |
| 83 | ASSERT_EQ(page, large_page)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(page)) == 1)>::Compare("page" , "large_page", page, large_page))) ; else return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 83, gtest_ar.failure_message()) = ::testing::Message(); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | TEST_VM(os, page_size_for_region_unaligned)class os_page_size_for_region_unaligned_vm_Test : public ::testing ::Test { public: os_page_size_for_region_unaligned_vm_Test() { } private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_page_size_for_region_unaligned_vm_Test (os_page_size_for_region_unaligned_vm_Test const &) = delete ; void operator=(os_page_size_for_region_unaligned_vm_Test const &) = delete;};::testing::TestInfo* const os_page_size_for_region_unaligned_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "page_size_for_region_unaligned_vm", __null, __null, :: testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 88), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_page_size_for_region_unaligned_vm_Test >);void os_page_size_for_region_unaligned_vm_Test::TestBody () { |
| 89 | if (UseLargePages) { |
| 90 | // Given exact page size, should return that page size. |
| 91 | for (size_t s = os::page_sizes().largest(); s != 0; s = os::page_sizes().next_smaller(s)) { |
| 92 | size_t actual = os::page_size_for_region_unaligned(s, 1); |
| 93 | ASSERT_EQ(s, actual)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s)) == 1)>::Compare("s", "actual" , s, actual))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 93, gtest_ar.failure_message()) = ::testing::Message(); |
| 94 | } |
| 95 | |
| 96 | // Given slightly larger size than a page size, return the page size. |
| 97 | for (size_t s = os::page_sizes().largest(); s != 0; s = os::page_sizes().next_smaller(s)) { |
| 98 | size_t actual = os::page_size_for_region_unaligned(s + 17, 1); |
| 99 | ASSERT_EQ(s, actual)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s)) == 1)>::Compare("s", "actual" , s, actual))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 99, gtest_ar.failure_message()) = ::testing::Message(); |
| 100 | } |
| 101 | |
| 102 | // Given a slightly smaller size than a page size, |
| 103 | // return the next smaller page size. |
| 104 | for (size_t s = os::page_sizes().largest(); s != 0; s = os::page_sizes().next_smaller(s)) { |
| 105 | const size_t expected = os::page_sizes().next_smaller(s); |
| 106 | if (expected != 0) { |
| 107 | size_t actual = os::page_size_for_region_unaligned(s - 17, 1); |
| 108 | ASSERT_EQ(actual, expected)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(actual)) == 1)>::Compare("actual" , "expected", actual, expected))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 108, gtest_ar.failure_message()) = ::testing::Message(); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | // Return small page size for values less than a small page. |
| 113 | size_t small_page = os::page_sizes().smallest(); |
| 114 | size_t actual = os::page_size_for_region_unaligned(small_page - 17, 1); |
| 115 | ASSERT_EQ(small_page, actual)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(small_page)) == 1)>::Compare ("small_page", "actual", small_page, actual))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 115, gtest_ar.failure_message()) = ::testing::Message(); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | TEST(os, test_random)class os_test_random_Test : public ::testing::Test { public: os_test_random_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_test_random_Test (os_test_random_Test const &) = delete; void operator=(os_test_random_Test const &) = delete;};::testing::TestInfo* const os_test_random_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "test_random", __null, __null, ::testing::internal::CodeLocation ("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 119), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_test_random_Test>);void os_test_random_Test::TestBody() { |
| 120 | const double m = 2147483647; |
| 121 | double mean = 0.0, variance = 0.0, t; |
| 122 | const int reps = 10000; |
| 123 | unsigned int seed = 1; |
| 124 | |
| 125 | // tty->print_cr("seed %ld for %ld repeats...", seed, reps); |
| 126 | int num; |
| 127 | for (int k = 0; k < reps; k++) { |
| 128 | // Use next_random so the calculation is stateless. |
| 129 | num = seed = os::next_random(seed); |
| 130 | double u = (double)num / m; |
| 131 | ASSERT_TRUE(u >= 0.0 && u <= 1.0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(u >= 0.0 && u <= 1.0)) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 131, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "u >= 0.0 && u <= 1.0", "false", "true").c_str ()) = ::testing::Message() << "bad random number!"; |
| 132 | |
| 133 | // calculate mean and variance of the random sequence |
| 134 | mean += u; |
| 135 | variance += (u*u); |
| 136 | } |
| 137 | mean /= reps; |
| 138 | variance /= (reps - 1); |
| 139 | |
| 140 | ASSERT_EQ(num, 1043618065)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(num)) == 1)>::Compare("num" , "1043618065", num, 1043618065))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 140, gtest_ar.failure_message()) = ::testing::Message() << "bad seed"; |
| 141 | // tty->print_cr("mean of the 1st 10000 numbers: %f", mean); |
| 142 | int intmean = mean*100; |
| 143 | ASSERT_EQ(intmean, 50)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(intmean)) == 1)>::Compare( "intmean", "50", intmean, 50))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 143, gtest_ar.failure_message()) = ::testing::Message(); |
| 144 | // tty->print_cr("variance of the 1st 10000 numbers: %f", variance); |
| 145 | int intvariance = variance*100; |
| 146 | ASSERT_EQ(intvariance, 33)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(intvariance)) == 1)>::Compare ("intvariance", "33", intvariance, 33))) ; else return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 146, gtest_ar.failure_message()) = ::testing::Message(); |
| 147 | const double eps = 0.0001; |
| 148 | t = fabsd(mean - 0.5018); |
| 149 | ASSERT_LT(t, eps)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperLT("t", "eps", t, eps ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 149, gtest_ar.failure_message()) = ::testing::Message() << "bad mean"; |
| 150 | t = (variance - 0.3355) < 0.0 ? -(variance - 0.3355) : variance - 0.3355; |
| 151 | ASSERT_LT(t, eps)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperLT("t", "eps", t, eps ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 151, gtest_ar.failure_message()) = ::testing::Message() << "bad variance"; |
| 152 | } |
| 153 | |
| 154 | #ifdef ASSERT1 |
| 155 | TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages,static void test_os_page_size_for_region_with_zero_min_pages_ (); static void child_os_page_size_for_region_with_zero_min_pages_ () { ::testing::FLAGS_gtest_throw_on_failure = true; test_os_page_size_for_region_with_zero_min_pages_ (); exit(0); } class os_page_size_for_region_with_zero_min_pages_vm_assert_Test : public ::testing::Test { public: os_page_size_for_region_with_zero_min_pages_vm_assert_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_page_size_for_region_with_zero_min_pages_vm_assert_Test (os_page_size_for_region_with_zero_min_pages_vm_assert_Test const &) = delete; void operator=(os_page_size_for_region_with_zero_min_pages_vm_assert_Test const &) = delete;};::testing::TestInfo* const os_page_size_for_region_with_zero_min_pages_vm_assert_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "page_size_for_region_with_zero_min_pages_vm_assert", __null , __null, ::testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 156), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_page_size_for_region_with_zero_min_pages_vm_assert_Test >);void os_page_size_for_region_with_zero_min_pages_vm_assert_Test ::TestBody() { switch (0) case 0: default: if (::testing::internal ::AlwaysTrue()) { const ::testing::internal::RE& gtest_regex = ("assert failed: " "assert.min_pages > 0. failed: sanity" ); ::testing::internal::DeathTest* gtest_dt; if (!::testing:: internal::DeathTest::Create("child_os_page_size_for_region_with_zero_min_pages_()" , >est_regex, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 156, >est_dt)) { goto gtest_label_156; } if (gtest_dt != __null) { ::testing::internal::scoped_ptr< ::testing:: internal::DeathTest> gtest_dt_ptr(gtest_dt); switch (gtest_dt ->AssumeRole()) { case ::testing::internal::DeathTest::OVERSEE_TEST : if (!gtest_dt->Passed(::testing::ExitedWithCode(1)(gtest_dt ->Wait()))) { goto gtest_label_156; } break; case ::testing ::internal::DeathTest::EXECUTE_TEST: { ::testing::internal::DeathTest ::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing::internal ::AlwaysTrue()) { child_os_page_size_for_region_with_zero_min_pages_ (); }; gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE ); break; } default: break; } } } else gtest_label_156: return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 156, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message(); } void test_os_page_size_for_region_with_zero_min_pages_ () |
| 156 | "assert.min_pages > 0. failed: sanity")static void test_os_page_size_for_region_with_zero_min_pages_ (); static void child_os_page_size_for_region_with_zero_min_pages_ () { ::testing::FLAGS_gtest_throw_on_failure = true; test_os_page_size_for_region_with_zero_min_pages_ (); exit(0); } class os_page_size_for_region_with_zero_min_pages_vm_assert_Test : public ::testing::Test { public: os_page_size_for_region_with_zero_min_pages_vm_assert_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_page_size_for_region_with_zero_min_pages_vm_assert_Test (os_page_size_for_region_with_zero_min_pages_vm_assert_Test const &) = delete; void operator=(os_page_size_for_region_with_zero_min_pages_vm_assert_Test const &) = delete;};::testing::TestInfo* const os_page_size_for_region_with_zero_min_pages_vm_assert_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "page_size_for_region_with_zero_min_pages_vm_assert", __null , __null, ::testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 156), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_page_size_for_region_with_zero_min_pages_vm_assert_Test >);void os_page_size_for_region_with_zero_min_pages_vm_assert_Test ::TestBody() { switch (0) case 0: default: if (::testing::internal ::AlwaysTrue()) { const ::testing::internal::RE& gtest_regex = ("assert failed: " "assert.min_pages > 0. failed: sanity" ); ::testing::internal::DeathTest* gtest_dt; if (!::testing:: internal::DeathTest::Create("child_os_page_size_for_region_with_zero_min_pages_()" , >est_regex, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 156, >est_dt)) { goto gtest_label_156; } if (gtest_dt != __null) { ::testing::internal::scoped_ptr< ::testing:: internal::DeathTest> gtest_dt_ptr(gtest_dt); switch (gtest_dt ->AssumeRole()) { case ::testing::internal::DeathTest::OVERSEE_TEST : if (!gtest_dt->Passed(::testing::ExitedWithCode(1)(gtest_dt ->Wait()))) { goto gtest_label_156; } break; case ::testing ::internal::DeathTest::EXECUTE_TEST: { ::testing::internal::DeathTest ::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing::internal ::AlwaysTrue()) { child_os_page_size_for_region_with_zero_min_pages_ (); }; gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE ); break; } default: break; } } } else gtest_label_156: return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 156, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message(); } void test_os_page_size_for_region_with_zero_min_pages_ () { |
| 157 | size_t region_size = 16 * os::vm_page_size(); |
| 158 | os::page_size_for_region_aligned(region_size, 0); // should assert |
| 159 | } |
| 160 | #endif |
| 161 | |
| 162 | static void do_test_print_hex_dump(address addr, size_t len, int unitsize, const char* expected) { |
| 163 | char buf[256]; |
| 164 | buf[0] = '\0'; |
| 165 | stringStream ss(buf, sizeof(buf)); |
| 166 | os::print_hex_dump(&ss, addr, addr + len, unitsize); |
| 167 | // tty->print_cr("expected: %s", expected); |
| 168 | // tty->print_cr("result: %s", buf); |
| 169 | ASSERT_NE(strstr(buf, expected), (char*)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("strstr(buf, expected)" , "(char*)__null", strstr(buf, expected), (char*)__null))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 169, gtest_ar.failure_message()) = ::testing::Message(); |
| 170 | } |
| 171 | |
| 172 | TEST_VM(os, test_print_hex_dump)class os_test_print_hex_dump_vm_Test : public ::testing::Test { public: os_test_print_hex_dump_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_test_print_hex_dump_vm_Test(os_test_print_hex_dump_vm_Test const &) = delete; void operator=(os_test_print_hex_dump_vm_Test const &) = delete;};::testing::TestInfo* const os_test_print_hex_dump_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "test_print_hex_dump_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 172), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_test_print_hex_dump_vm_Test >);void os_test_print_hex_dump_vm_Test::TestBody() { |
| 173 | const char* pattern [4] = { |
| 174 | #ifdef VM_LITTLE_ENDIAN1 |
| 175 | "00 01 02 03 04 05 06 07", |
| 176 | "0100 0302 0504 0706", |
| 177 | "03020100 07060504", |
| 178 | "0706050403020100" |
| 179 | #else |
| 180 | "00 01 02 03 04 05 06 07", |
| 181 | "0001 0203 0405 0607", |
| 182 | "00010203 04050607", |
| 183 | "0001020304050607" |
| 184 | #endif |
| 185 | }; |
| 186 | |
| 187 | const char* pattern_not_readable [4] = { |
| 188 | "?? ?? ?? ?? ?? ?? ?? ??", |
| 189 | "???? ???? ???? ????", |
| 190 | "???????? ????????", |
| 191 | "????????????????" |
| 192 | }; |
| 193 | |
| 194 | // On AIX, zero page is readable. |
| 195 | address unreadable = |
| 196 | #ifdef AIX |
| 197 | (address) 0xFFFFFFFFFFFF0000ULL; |
| 198 | #else |
| 199 | (address) 0 |
| 200 | #endif |
| 201 | ; |
| 202 | |
| 203 | ResourceMark rm; |
| 204 | char buf[64]; |
| 205 | stringStream ss(buf, sizeof(buf)); |
| 206 | outputStream* out = &ss; |
Value stored to 'out' during its initialization is never read | |
| 207 | // outputStream* out = tty; // enable for printout |
| 208 | |
| 209 | // Test dumping unreadable memory |
| 210 | // Exclude test for Windows for now, since it needs SEH handling to work which cannot be |
| 211 | // guaranteed when we call directly into VM code. (see JDK-8220220) |
| 212 | #ifndef _WIN32 |
| 213 | do_test_print_hex_dump(unreadable, 100, 1, pattern_not_readable[0]); |
| 214 | do_test_print_hex_dump(unreadable, 100, 2, pattern_not_readable[1]); |
| 215 | do_test_print_hex_dump(unreadable, 100, 4, pattern_not_readable[2]); |
| 216 | do_test_print_hex_dump(unreadable, 100, 8, pattern_not_readable[3]); |
| 217 | #endif |
| 218 | |
| 219 | // Test dumping readable memory |
| 220 | address arr = (address)os::malloc(100, mtInternal); |
| 221 | for (int c = 0; c < 100; c++) { |
| 222 | arr[c] = c; |
| 223 | } |
| 224 | |
| 225 | // properly aligned |
| 226 | do_test_print_hex_dump(arr, 100, 1, pattern[0]); |
| 227 | do_test_print_hex_dump(arr, 100, 2, pattern[1]); |
| 228 | do_test_print_hex_dump(arr, 100, 4, pattern[2]); |
| 229 | do_test_print_hex_dump(arr, 100, 8, pattern[3]); |
| 230 | |
| 231 | // Not properly aligned. Should automatically down-align by unitsize |
| 232 | do_test_print_hex_dump(arr + 1, 100, 2, pattern[1]); |
| 233 | do_test_print_hex_dump(arr + 1, 100, 4, pattern[2]); |
| 234 | do_test_print_hex_dump(arr + 1, 100, 8, pattern[3]); |
| 235 | |
| 236 | os::free(arr); |
| 237 | } |
| 238 | |
| 239 | ////////////////////////////////////////////////////////////////////////////// |
| 240 | // Test os::vsnprintf and friends. |
| 241 | |
| 242 | static void check_snprintf_result(int expected, size_t limit, int actual, bool expect_count) { |
| 243 | if (expect_count || ((size_t)expected < limit)) { |
| 244 | ASSERT_EQ(expected, actual)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(expected)) == 1)>::Compare ("expected", "actual", expected, actual))) ; else return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 244, gtest_ar.failure_message()) = ::testing::Message(); |
| 245 | } else { |
| 246 | ASSERT_GT(0, actual)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperGT("0", "actual", 0 , actual))) ; else return ::testing::internal::AssertHelper(:: testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 246, gtest_ar.failure_message()) = ::testing::Message(); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // PrintFn is expected to be int (*)(char*, size_t, const char*, ...). |
| 251 | // But jio_snprintf is a C-linkage function with that signature, which |
| 252 | // has a different type on some platforms (like Solaris). |
| 253 | template<typename PrintFn> |
| 254 | static void test_snprintf(PrintFn pf, bool expect_count) { |
| 255 | const char expected[] = "abcdefghijklmnopqrstuvwxyz"; |
| 256 | const int expected_len = sizeof(expected) - 1; |
| 257 | const size_t padding_size = 10; |
| 258 | char buffer[2 * (sizeof(expected) + padding_size)]; |
| 259 | char check_buffer[sizeof(buffer)]; |
| 260 | const char check_char = '1'; // Something not in expected. |
| 261 | memset(check_buffer, check_char, sizeof(check_buffer)); |
| 262 | const size_t sizes_to_test[] = { |
| 263 | sizeof(buffer) - padding_size, // Fits, with plenty of space to spare. |
| 264 | sizeof(buffer)/2, // Fits, with space to spare. |
| 265 | sizeof(buffer)/4, // Doesn't fit. |
| 266 | sizeof(expected) + padding_size + 1, // Fits, with a little room to spare |
| 267 | sizeof(expected) + padding_size, // Fits exactly. |
| 268 | sizeof(expected) + padding_size - 1, // Doesn't quite fit. |
| 269 | 2, // One char + terminating NUL. |
| 270 | 1, // Only space for terminating NUL. |
| 271 | 0 }; // No space at all. |
| 272 | for (unsigned i = 0; i < ARRAY_SIZE(sizes_to_test)sizeof(array_size_impl(sizes_to_test)); ++i) { |
| 273 | memset(buffer, check_char, sizeof(buffer)); // To catch stray writes. |
| 274 | size_t test_size = sizes_to_test[i]; |
| 275 | ResourceMark rm; |
| 276 | stringStream s; |
| 277 | s.print("test_size: " SIZE_FORMAT"%" "l" "u", test_size); |
| 278 | SCOPED_TRACE(s.as_string())::testing::ScopedTrace gtest_trace_278( "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 278, (s.as_string())); |
| 279 | size_t prefix_size = padding_size; |
| 280 | guarantee(test_size <= (sizeof(buffer) - prefix_size), "invariant")do { if (!(test_size <= (sizeof(buffer) - prefix_size))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 280, "guarantee(" "test_size <= (sizeof(buffer) - prefix_size)" ") failed", "invariant"); ::breakpoint(); } } while (0); |
| 281 | size_t write_size = MIN2(sizeof(expected), test_size); |
| 282 | size_t suffix_size = sizeof(buffer) - prefix_size - write_size; |
| 283 | char* write_start = buffer + prefix_size; |
| 284 | char* write_end = write_start + write_size; |
| 285 | |
| 286 | int result = pf(write_start, test_size, "%s", expected); |
| 287 | |
| 288 | check_snprintf_result(expected_len, test_size, result, expect_count); |
| 289 | |
| 290 | // Verify expected output. |
| 291 | if (test_size > 0) { |
| 292 | ASSERT_EQ(0, strncmp(write_start, expected, write_size - 1))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "strncmp(write_start, expected, write_size - 1)" , 0, strncmp(write_start, expected, write_size - 1)))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 292, gtest_ar.failure_message()) = ::testing::Message(); |
| 293 | // Verify terminating NUL of output. |
| 294 | ASSERT_EQ('\0', write_start[write_size - 1])switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper('\0')) == 1)>::Compare("'\\0'" , "write_start[write_size - 1]", '\0', write_start[write_size - 1]))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 294, gtest_ar.failure_message()) = ::testing::Message(); |
| 295 | } else { |
| 296 | guarantee(test_size == 0, "invariant")do { if (!(test_size == 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 296, "guarantee(" "test_size == 0" ") failed", "invariant") ; ::breakpoint(); } } while (0); |
| 297 | guarantee(write_size == 0, "invariant")do { if (!(write_size == 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 297, "guarantee(" "write_size == 0" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
| 298 | guarantee(prefix_size + suffix_size == sizeof(buffer), "invariant")do { if (!(prefix_size + suffix_size == sizeof(buffer))) { (* g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 298, "guarantee(" "prefix_size + suffix_size == sizeof(buffer)" ") failed", "invariant"); ::breakpoint(); } } while (0); |
| 299 | guarantee(write_start == write_end, "invariant")do { if (!(write_start == write_end)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 299, "guarantee(" "write_start == write_end" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
| 300 | } |
| 301 | |
| 302 | // Verify no scribbling on prefix or suffix. |
| 303 | ASSERT_EQ(0, strncmp(buffer, check_buffer, prefix_size))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "strncmp(buffer, check_buffer, prefix_size)" , 0, strncmp(buffer, check_buffer, prefix_size)))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 303, gtest_ar.failure_message()) = ::testing::Message(); |
| 304 | ASSERT_EQ(0, strncmp(write_end, check_buffer, suffix_size))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "strncmp(write_end, check_buffer, suffix_size)" , 0, strncmp(write_end, check_buffer, suffix_size)))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 304, gtest_ar.failure_message()) = ::testing::Message(); |
| 305 | } |
| 306 | |
| 307 | // Special case of 0-length buffer with empty (except for terminator) output. |
| 308 | check_snprintf_result(0, 0, pf(NULL__null, 0, "%s", ""), expect_count); |
| 309 | check_snprintf_result(0, 0, pf(NULL__null, 0, ""), expect_count); |
| 310 | } |
| 311 | |
| 312 | // This is probably equivalent to os::snprintf, but we're being |
| 313 | // explicit about what we're testing here. |
| 314 | static int vsnprintf_wrapper(char* buf, size_t len, const char* fmt, ...) { |
| 315 | va_list args; |
| 316 | va_start(args, fmt)__builtin_va_start(args, fmt); |
| 317 | int result = os::vsnprintf(buf, len, fmt, args); |
| 318 | va_end(args)__builtin_va_end(args); |
| 319 | return result; |
| 320 | } |
| 321 | |
| 322 | TEST_VM(os, vsnprintf)class os_vsnprintf_vm_Test : public ::testing::Test { public: os_vsnprintf_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused )); os_vsnprintf_vm_Test(os_vsnprintf_vm_Test const &) = delete ; void operator=(os_vsnprintf_vm_Test const &) = delete;} ;::testing::TestInfo* const os_vsnprintf_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "vsnprintf_vm" , __null, __null, ::testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 322), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_vsnprintf_vm_Test>);void os_vsnprintf_vm_Test::TestBody() { |
| 323 | test_snprintf(vsnprintf_wrapper, true); |
| 324 | } |
| 325 | |
| 326 | TEST_VM(os, snprintf)class os_snprintf_vm_Test : public ::testing::Test { public: os_snprintf_vm_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_snprintf_vm_Test (os_snprintf_vm_Test const &) = delete; void operator=(os_snprintf_vm_Test const &) = delete;};::testing::TestInfo* const os_snprintf_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "snprintf_vm", __null, __null, ::testing::internal::CodeLocation ("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 326), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_snprintf_vm_Test>);void os_snprintf_vm_Test::TestBody() { |
| 327 | test_snprintf(os::snprintf, true); |
| 328 | } |
| 329 | |
| 330 | // These are declared in jvm.h; test here, with related functions. |
| 331 | extern "C" { |
| 332 | int jio_vsnprintf(char*, size_t, const char*, va_list); |
| 333 | int jio_snprintf(char*, size_t, const char*, ...); |
| 334 | } |
| 335 | |
| 336 | // This is probably equivalent to jio_snprintf, but we're being |
| 337 | // explicit about what we're testing here. |
| 338 | static int jio_vsnprintf_wrapper(char* buf, size_t len, const char* fmt, ...) { |
| 339 | va_list args; |
| 340 | va_start(args, fmt)__builtin_va_start(args, fmt); |
| 341 | int result = jio_vsnprintf(buf, len, fmt, args); |
| 342 | va_end(args)__builtin_va_end(args); |
| 343 | return result; |
| 344 | } |
| 345 | |
| 346 | TEST_VM(os, jio_vsnprintf)class os_jio_vsnprintf_vm_Test : public ::testing::Test { public : os_jio_vsnprintf_vm_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_jio_vsnprintf_vm_Test(os_jio_vsnprintf_vm_Test const &) = delete; void operator=(os_jio_vsnprintf_vm_Test const &) = delete;};::testing::TestInfo* const os_jio_vsnprintf_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "jio_vsnprintf_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 346), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_jio_vsnprintf_vm_Test>) ;void os_jio_vsnprintf_vm_Test::TestBody() { |
| 347 | test_snprintf(jio_vsnprintf_wrapper, false); |
| 348 | } |
| 349 | |
| 350 | TEST_VM(os, jio_snprintf)class os_jio_snprintf_vm_Test : public ::testing::Test { public : os_jio_snprintf_vm_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_jio_snprintf_vm_Test(os_jio_snprintf_vm_Test const &) = delete; void operator=(os_jio_snprintf_vm_Test const &) = delete;};::testing::TestInfo* const os_jio_snprintf_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "jio_snprintf_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 350), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_jio_snprintf_vm_Test>); void os_jio_snprintf_vm_Test::TestBody() { |
| 351 | test_snprintf(jio_snprintf, false); |
| 352 | } |
| 353 | |
| 354 | // Test that os::release_memory() can deal with areas containing multiple mappings. |
| 355 | #define PRINT_MAPPINGS(s){ tty->print_cr("%s", s); os::print_memory_mappings((char* )p, total_range_len, tty); } { tty->print_cr("%s", s); os::print_memory_mappings((char*)p, total_range_len, tty); } |
| 356 | //#define PRINT_MAPPINGS |
| 357 | |
| 358 | #ifndef _AIX // JDK-8257041 |
| 359 | // Reserve an area consisting of multiple mappings |
| 360 | // (from multiple calls to os::reserve_memory) |
| 361 | static address reserve_multiple(int num_stripes, size_t stripe_len) { |
| 362 | assert(is_aligned(stripe_len, os::vm_allocation_granularity()), "Sanity")do { if (!(is_aligned(stripe_len, os::vm_allocation_granularity ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 362, "assert(" "is_aligned(stripe_len, os::vm_allocation_granularity())" ") failed", "Sanity"); ::breakpoint(); } } while (0); |
| 363 | size_t total_range_len = num_stripes * stripe_len; |
| 364 | // Reserve a large contiguous area to get the address space... |
| 365 | address p = (address)os::reserve_memory(total_range_len); |
| 366 | EXPECT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 366, gtest_ar.failure_message()) = ::testing::Message(); |
| 367 | // .. release it... |
| 368 | EXPECT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 368, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 369 | // ... re-reserve in the same spot multiple areas... |
| 370 | for (int stripe = 0; stripe < num_stripes; stripe++) { |
| 371 | address q = p + (stripe * stripe_len); |
| 372 | // Commit, alternatingly with or without exec permission, |
| 373 | // to prevent kernel from folding these mappings. |
| 374 | const bool executable = stripe % 2 == 0; |
| 375 | q = (address)os::attempt_reserve_memory_at((char*)q, stripe_len, executable); |
| 376 | EXPECT_NE(q, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("q", "(address)__null" , q, (address)__null))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 376, gtest_ar.failure_message()) = ::testing::Message(); |
| 377 | EXPECT_TRUE(os::commit_memory((char*)q, stripe_len, executable))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::commit_memory((char *)q, stripe_len, executable))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 377, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::commit_memory((char*)q, stripe_len, executable)", "false" , "true").c_str()) = ::testing::Message(); |
| 378 | } |
| 379 | return p; |
| 380 | } |
| 381 | #endif // !AIX |
| 382 | |
| 383 | // Reserve an area with a single call to os::reserve_memory, |
| 384 | // with multiple committed and uncommitted regions |
| 385 | static address reserve_one_commit_multiple(int num_stripes, size_t stripe_len) { |
| 386 | assert(is_aligned(stripe_len, os::vm_allocation_granularity()), "Sanity")do { if (!(is_aligned(stripe_len, os::vm_allocation_granularity ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 386, "assert(" "is_aligned(stripe_len, os::vm_allocation_granularity())" ") failed", "Sanity"); ::breakpoint(); } } while (0); |
| 387 | size_t total_range_len = num_stripes * stripe_len; |
| 388 | address p = (address)os::reserve_memory(total_range_len); |
| 389 | EXPECT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 389, gtest_ar.failure_message()) = ::testing::Message(); |
| 390 | for (int stripe = 0; stripe < num_stripes; stripe++) { |
| 391 | address q = p + (stripe * stripe_len); |
| 392 | if (stripe % 2 == 0) { |
| 393 | EXPECT_TRUE(os::commit_memory((char*)q, stripe_len, false))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::commit_memory((char *)q, stripe_len, false))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 393, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::commit_memory((char*)q, stripe_len, false)", "false", "true" ).c_str()) = ::testing::Message(); |
| 394 | } |
| 395 | } |
| 396 | return p; |
| 397 | } |
| 398 | |
| 399 | #ifdef _WIN32 |
| 400 | // Release a range allocated with reserve_multiple carefully, to not trip mapping |
| 401 | // asserts on Windows in os::release_memory() |
| 402 | static void carefully_release_multiple(address start, int num_stripes, size_t stripe_len) { |
| 403 | for (int stripe = 0; stripe < num_stripes; stripe++) { |
| 404 | address q = start + (stripe * stripe_len); |
| 405 | EXPECT_TRUE(os::release_memory((char*)q, stripe_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)q, stripe_len))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 405, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)q, stripe_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 406 | } |
| 407 | } |
| 408 | struct NUMASwitcher { |
| 409 | const bool _b; |
| 410 | NUMASwitcher(bool v): _b(UseNUMAInterleaving) { UseNUMAInterleaving = v; } |
| 411 | ~NUMASwitcher() { UseNUMAInterleaving = _b; } |
| 412 | }; |
| 413 | #endif |
| 414 | |
| 415 | #ifndef _AIX // JDK-8257041 |
| 416 | #if defined(__APPLE__) && !defined(AARCH64) // See JDK-8267341. |
| 417 | TEST_VM(os, DISABLED_release_multi_mappings)class os_DISABLED_release_multi_mappings_vm_Test : public ::testing ::Test { public: os_DISABLED_release_multi_mappings_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_DISABLED_release_multi_mappings_vm_Test (os_DISABLED_release_multi_mappings_vm_Test const &) = delete ; void operator=(os_DISABLED_release_multi_mappings_vm_Test const &) = delete;};::testing::TestInfo* const os_DISABLED_release_multi_mappings_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "DISABLED_release_multi_mappings_vm", __null, __null, :: testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 417), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_DISABLED_release_multi_mappings_vm_Test >);void os_DISABLED_release_multi_mappings_vm_Test::TestBody () { |
| 418 | #else |
| 419 | TEST_VM(os, release_multi_mappings)class os_release_multi_mappings_vm_Test : public ::testing::Test { public: os_release_multi_mappings_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_release_multi_mappings_vm_Test( os_release_multi_mappings_vm_Test const &) = delete; void operator=(os_release_multi_mappings_vm_Test const &) = delete ;};::testing::TestInfo* const os_release_multi_mappings_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "release_multi_mappings_vm", __null, __null, ::testing ::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 419), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_release_multi_mappings_vm_Test >);void os_release_multi_mappings_vm_Test::TestBody() { |
| 420 | #endif |
| 421 | |
| 422 | // With NMT enabled, this will trigger JDK-8263464. For now disable the test if NMT=on. |
| 423 | if (MemTracker::tracking_level() > NMT_off) { |
| 424 | return; |
| 425 | } |
| 426 | |
| 427 | // Test that we can release an area created with multiple reservation calls |
| 428 | const size_t stripe_len = 4 * M; |
| 429 | const int num_stripes = 4; |
| 430 | const size_t total_range_len = stripe_len * num_stripes; |
| 431 | |
| 432 | // reserve address space... |
| 433 | address p = reserve_multiple(num_stripes, stripe_len); |
| 434 | ASSERT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 434, gtest_ar.failure_message()) = ::testing::Message(); |
| 435 | PRINT_MAPPINGS("A"){ tty->print_cr("%s", "A"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 436 | |
| 437 | // .. release it... |
| 438 | { |
| 439 | // On Windows, use UseNUMAInterleaving=1 which makes |
| 440 | // os::release_memory accept multi-map-ranges. |
| 441 | // Otherwise we would assert (see below for death test). |
| 442 | WINDOWS_ONLY(NUMASwitcher b(true);) |
| 443 | ASSERT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 443, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 444 | } |
| 445 | PRINT_MAPPINGS("B"){ tty->print_cr("%s", "B"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 446 | |
| 447 | // re-reserve it. This should work unless release failed. |
| 448 | address p2 = (address)os::attempt_reserve_memory_at((char*)p, total_range_len); |
| 449 | ASSERT_EQ(p2, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(p2)) == 1)>::Compare("p2", "p", p2, p))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 449, gtest_ar.failure_message()) = ::testing::Message(); |
| 450 | PRINT_MAPPINGS("C"){ tty->print_cr("%s", "C"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 451 | |
| 452 | ASSERT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 452, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 453 | } |
| 454 | #endif // !AIX |
| 455 | |
| 456 | #ifdef _WIN32 |
| 457 | // On Windows, test that we recognize bad ranges. |
| 458 | // On debug this would assert. Test that too. |
| 459 | // On other platforms, we are unable to recognize bad ranges. |
| 460 | #ifdef ASSERT1 |
| 461 | TEST_VM_ASSERT_MSG(os, release_bad_ranges, ".*bad release")static void test_os_release_bad_ranges_(); static void child_os_release_bad_ranges_ () { ::testing::FLAGS_gtest_throw_on_failure = true; test_os_release_bad_ranges_ (); exit(0); } class os_release_bad_ranges_vm_assert_Test : public ::testing::Test { public: os_release_bad_ranges_vm_assert_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_release_bad_ranges_vm_assert_Test (os_release_bad_ranges_vm_assert_Test const &) = delete; void operator=(os_release_bad_ranges_vm_assert_Test const &) = delete;};::testing::TestInfo* const os_release_bad_ranges_vm_assert_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "release_bad_ranges_vm_assert", __null, __null, ::testing ::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 461), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_release_bad_ranges_vm_assert_Test >);void os_release_bad_ranges_vm_assert_Test::TestBody() { switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { const ::testing::internal::RE& gtest_regex = ("assert failed: " ".*bad release"); ::testing::internal::DeathTest* gtest_dt; if (!::testing::internal::DeathTest::Create("child_os_release_bad_ranges_()" , >est_regex, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 461, >est_dt)) { goto gtest_label_461; } if (gtest_dt != __null) { ::testing::internal::scoped_ptr< ::testing:: internal::DeathTest> gtest_dt_ptr(gtest_dt); switch (gtest_dt ->AssumeRole()) { case ::testing::internal::DeathTest::OVERSEE_TEST : if (!gtest_dt->Passed(::testing::ExitedWithCode(1)(gtest_dt ->Wait()))) { goto gtest_label_461; } break; case ::testing ::internal::DeathTest::EXECUTE_TEST: { ::testing::internal::DeathTest ::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing::internal ::AlwaysTrue()) { child_os_release_bad_ranges_(); }; gtest_dt ->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); break; } default: break; } } } else gtest_label_461: return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 461, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message(); } void test_os_release_bad_ranges_() { |
| 462 | #else |
| 463 | TEST_VM(os, release_bad_ranges)class os_release_bad_ranges_vm_Test : public ::testing::Test { public: os_release_bad_ranges_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_release_bad_ranges_vm_Test(os_release_bad_ranges_vm_Test const &) = delete; void operator=(os_release_bad_ranges_vm_Test const &) = delete;};::testing::TestInfo* const os_release_bad_ranges_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "release_bad_ranges_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 463), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_release_bad_ranges_vm_Test >);void os_release_bad_ranges_vm_Test::TestBody() { |
| 464 | #endif |
| 465 | char* p = os::reserve_memory(4 * M); |
| 466 | ASSERT_NE(p, (char*)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(char*)__null" , p, (char*)__null))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 466, gtest_ar.failure_message()) = ::testing::Message(); |
| 467 | // Release part of range |
| 468 | ASSERT_FALSE(os::release_memory(p, M))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::release_memory( p, M)))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 468, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p, M)", "true", "false").c_str()) = ::testing ::Message(); |
| 469 | // Release part of range |
| 470 | ASSERT_FALSE(os::release_memory(p + M, M))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::release_memory( p + M, M)))) ; else return ::testing::internal::AssertHelper( ::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 470, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p + M, M)", "true", "false").c_str()) = ::testing::Message(); |
| 471 | // Release more than the range (explicitly switch off NUMA here |
| 472 | // to make os::release_memory() test more strictly and to not |
| 473 | // accidentally release neighbors) |
| 474 | { |
| 475 | NUMASwitcher b(false); |
| 476 | ASSERT_FALSE(os::release_memory(p, M * 5))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::release_memory( p, M * 5)))) ; else return ::testing::internal::AssertHelper( ::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 476, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p, M * 5)", "true", "false").c_str()) = ::testing::Message(); |
| 477 | ASSERT_FALSE(os::release_memory(p - M, M * 5))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::release_memory( p - M, M * 5)))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 477, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p - M, M * 5)", "true", "false").c_str( )) = ::testing::Message(); |
| 478 | ASSERT_FALSE(os::release_memory(p - M, M * 6))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::release_memory( p - M, M * 6)))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 478, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p - M, M * 6)", "true", "false").c_str( )) = ::testing::Message(); |
| 479 | } |
| 480 | |
| 481 | ASSERT_TRUE(os::release_memory(p, 4 * M))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory(p, 4 * M))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 481, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p, 4 * M)", "false", "true").c_str()) = ::testing::Message(); // Release for real |
| 482 | ASSERT_FALSE(os::release_memory(p, 4 * M))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::release_memory( p, 4 * M)))) ; else return ::testing::internal::AssertHelper( ::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 482, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory(p, 4 * M)", "true", "false").c_str()) = ::testing::Message(); // Again, should fail |
| 483 | } |
| 484 | #endif // _WIN32 |
| 485 | |
| 486 | TEST_VM(os, release_one_mapping_multi_commits)class os_release_one_mapping_multi_commits_vm_Test : public :: testing::Test { public: os_release_one_mapping_multi_commits_vm_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_release_one_mapping_multi_commits_vm_Test (os_release_one_mapping_multi_commits_vm_Test const &) = delete ; void operator=(os_release_one_mapping_multi_commits_vm_Test const &) = delete;};::testing::TestInfo* const os_release_one_mapping_multi_commits_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "release_one_mapping_multi_commits_vm", __null, __null , ::testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 486), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_release_one_mapping_multi_commits_vm_Test >);void os_release_one_mapping_multi_commits_vm_Test::TestBody () { |
| 487 | // Test that we can release an area consisting of interleaved |
| 488 | // committed and uncommitted regions: |
| 489 | const size_t stripe_len = 4 * M; |
| 490 | const int num_stripes = 4; |
| 491 | const size_t total_range_len = stripe_len * num_stripes; |
| 492 | |
| 493 | // reserve address space... |
| 494 | address p = reserve_one_commit_multiple(num_stripes, stripe_len); |
| 495 | ASSERT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 495, gtest_ar.failure_message()) = ::testing::Message(); |
| 496 | PRINT_MAPPINGS("A"){ tty->print_cr("%s", "A"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 497 | |
| 498 | // .. release it... |
| 499 | ASSERT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 499, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 500 | PRINT_MAPPINGS("B"){ tty->print_cr("%s", "B"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 501 | |
| 502 | // re-reserve it. This should work unless release failed. |
| 503 | address p2 = (address)os::attempt_reserve_memory_at((char*)p, total_range_len); |
| 504 | ASSERT_EQ(p2, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(p2)) == 1)>::Compare("p2", "p", p2, p))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 504, gtest_ar.failure_message()) = ::testing::Message(); |
| 505 | PRINT_MAPPINGS("C"){ tty->print_cr("%s", "C"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 506 | |
| 507 | ASSERT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 507, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 508 | PRINT_MAPPINGS("D"){ tty->print_cr("%s", "D"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 509 | } |
| 510 | |
| 511 | static void test_show_mappings(address start, size_t size) { |
| 512 | // Note: should this overflow, thats okay. stream will silently truncate. Does not matter for the test. |
| 513 | const size_t buflen = 4 * M; |
| 514 | char* buf = NEW_C_HEAP_ARRAY(char, buflen, mtInternal)(char*) (AllocateHeap((buflen) * sizeof(char), mtInternal)); |
| 515 | buf[0] = '\0'; |
| 516 | stringStream ss(buf, buflen); |
| 517 | if (start != nullptr) { |
| 518 | os::print_memory_mappings((char*)start, size, &ss); |
| 519 | } else { |
| 520 | os::print_memory_mappings(&ss); // prints full address space |
| 521 | } |
| 522 | // Still an empty implementation on MacOS and AIX |
| 523 | #if defined(LINUX1) || defined(_WIN32) |
| 524 | EXPECT_NE(buf[0], '\0')switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("buf[0]", "'\\0'" , buf[0], '\0'))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 524, gtest_ar.failure_message()) = ::testing::Message(); |
| 525 | #endif |
| 526 | // buf[buflen - 1] = '\0'; |
| 527 | // tty->print_raw(buf); |
| 528 | FREE_C_HEAP_ARRAY(char, buf)FreeHeap((char*)(buf)); |
| 529 | } |
| 530 | |
| 531 | TEST_VM(os, show_mappings_small_range)class os_show_mappings_small_range_vm_Test : public ::testing ::Test { public: os_show_mappings_small_range_vm_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_show_mappings_small_range_vm_Test (os_show_mappings_small_range_vm_Test const &) = delete; void operator=(os_show_mappings_small_range_vm_Test const &) = delete;};::testing::TestInfo* const os_show_mappings_small_range_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "show_mappings_small_range_vm", __null, __null, ::testing ::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 531), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_show_mappings_small_range_vm_Test >);void os_show_mappings_small_range_vm_Test::TestBody() { |
| 532 | test_show_mappings((address)0x100000, 2 * G); |
| 533 | } |
| 534 | |
| 535 | TEST_VM(os, show_mappings_full_range)class os_show_mappings_full_range_vm_Test : public ::testing:: Test { public: os_show_mappings_full_range_vm_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_show_mappings_full_range_vm_Test (os_show_mappings_full_range_vm_Test const &) = delete; void operator=(os_show_mappings_full_range_vm_Test const &) = delete;};::testing::TestInfo* const os_show_mappings_full_range_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "show_mappings_full_range_vm", __null, __null, ::testing ::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 535), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_show_mappings_full_range_vm_Test >);void os_show_mappings_full_range_vm_Test::TestBody() { |
| 536 | // Reserve a small range and fill it with a marker string, should show up |
| 537 | // on implementations displaying range snippets |
| 538 | char* p = os::reserve_memory(1 * M, false, mtInternal); |
| 539 | if (p != nullptr) { |
| 540 | if (os::commit_memory(p, 1 * M, false)) { |
| 541 | strcpy(p, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
| 542 | } |
| 543 | } |
| 544 | test_show_mappings(nullptr, 0); |
| 545 | if (p != nullptr) { |
| 546 | os::release_memory(p, 1 * M); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | #ifdef _WIN32 |
| 551 | // Test os::win32::find_mapping |
| 552 | TEST_VM(os, find_mapping_simple)class os_find_mapping_simple_vm_Test : public ::testing::Test { public: os_find_mapping_simple_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_find_mapping_simple_vm_Test(os_find_mapping_simple_vm_Test const &) = delete; void operator=(os_find_mapping_simple_vm_Test const &) = delete;};::testing::TestInfo* const os_find_mapping_simple_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "find_mapping_simple_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 552), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_find_mapping_simple_vm_Test >);void os_find_mapping_simple_vm_Test::TestBody() { |
| 553 | const size_t total_range_len = 4 * M; |
| 554 | os::win32::mapping_info_t mapping_info; |
| 555 | |
| 556 | // Some obvious negatives |
| 557 | ASSERT_FALSE(os::win32::find_mapping((address)NULL, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::win32::find_mapping ((address)__null, &mapping_info)))) ; else return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 557, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping((address)NULL, &mapping_info)" , "true", "false").c_str()) = ::testing::Message(); |
| 558 | ASSERT_FALSE(os::win32::find_mapping((address)4711, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::win32::find_mapping ((address)4711, &mapping_info)))) ; else return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 558, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping((address)4711, &mapping_info)" , "true", "false").c_str()) = ::testing::Message(); |
| 559 | |
| 560 | // A simple allocation |
| 561 | { |
| 562 | address p = (address)os::reserve_memory(total_range_len); |
| 563 | ASSERT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 563, gtest_ar.failure_message()) = ::testing::Message(); |
| 564 | PRINT_MAPPINGS("A"){ tty->print_cr("%s", "A"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 565 | for (size_t offset = 0; offset < total_range_len; offset += 4711) { |
| 566 | ASSERT_TRUE(os::win32::find_mapping(p + offset, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::win32::find_mapping (p + offset, &mapping_info))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 566, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping(p + offset, &mapping_info)", "false" , "true").c_str()) = ::testing::Message(); |
| 567 | ASSERT_EQ(mapping_info.base, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.base)) == 1)> ::Compare("mapping_info.base", "p", mapping_info.base, p))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 567, gtest_ar.failure_message()) = ::testing::Message(); |
| 568 | ASSERT_EQ(mapping_info.regions, 1)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.regions)) == 1)> ::Compare("mapping_info.regions", "1", mapping_info.regions, 1 ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 568, gtest_ar.failure_message()) = ::testing::Message(); |
| 569 | ASSERT_EQ(mapping_info.size, total_range_len)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.size)) == 1)> ::Compare("mapping_info.size", "total_range_len", mapping_info .size, total_range_len))) ; else return ::testing::internal:: AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 569, gtest_ar.failure_message()) = ::testing::Message(); |
| 570 | ASSERT_EQ(mapping_info.committed_size, 0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.committed_size)) == 1)>::Compare("mapping_info.committed_size", "0", mapping_info .committed_size, 0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 570, gtest_ar.failure_message()) = ::testing::Message(); |
| 571 | } |
| 572 | // Test just outside the allocation |
| 573 | if (os::win32::find_mapping(p - 1, &mapping_info)) { |
| 574 | ASSERT_NE(mapping_info.base, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("mapping_info.base" , "p", mapping_info.base, p))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 574, gtest_ar.failure_message()) = ::testing::Message(); |
| 575 | } |
| 576 | if (os::win32::find_mapping(p + total_range_len, &mapping_info)) { |
| 577 | ASSERT_NE(mapping_info.base, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("mapping_info.base" , "p", mapping_info.base, p))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 577, gtest_ar.failure_message()) = ::testing::Message(); |
| 578 | } |
| 579 | ASSERT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 579, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 580 | PRINT_MAPPINGS("B"){ tty->print_cr("%s", "B"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 581 | ASSERT_FALSE(os::win32::find_mapping(p, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::win32::find_mapping (p, &mapping_info)))) ; else return ::testing::internal:: AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 581, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping(p, &mapping_info)", "true", "false" ).c_str()) = ::testing::Message(); |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | TEST_VM(os, find_mapping_2)class os_find_mapping_2_vm_Test : public ::testing::Test { public : os_find_mapping_2_vm_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_find_mapping_2_vm_Test(os_find_mapping_2_vm_Test const &) = delete; void operator=(os_find_mapping_2_vm_Test const &) = delete;};::testing::TestInfo* const os_find_mapping_2_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "find_mapping_2_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 585), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_find_mapping_2_vm_Test> );void os_find_mapping_2_vm_Test::TestBody() { |
| 586 | // A more complex allocation, consisting of multiple regions. |
| 587 | const size_t total_range_len = 4 * M; |
| 588 | os::win32::mapping_info_t mapping_info; |
| 589 | |
| 590 | const size_t stripe_len = total_range_len / 4; |
| 591 | address p = reserve_one_commit_multiple(4, stripe_len); |
| 592 | ASSERT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 592, gtest_ar.failure_message()) = ::testing::Message(); |
| 593 | PRINT_MAPPINGS("A"){ tty->print_cr("%s", "A"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 594 | for (size_t offset = 0; offset < total_range_len; offset += 4711) { |
| 595 | ASSERT_TRUE(os::win32::find_mapping(p + offset, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::win32::find_mapping (p + offset, &mapping_info))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 595, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping(p + offset, &mapping_info)", "false" , "true").c_str()) = ::testing::Message(); |
| 596 | ASSERT_EQ(mapping_info.base, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.base)) == 1)> ::Compare("mapping_info.base", "p", mapping_info.base, p))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 596, gtest_ar.failure_message()) = ::testing::Message(); |
| 597 | ASSERT_EQ(mapping_info.regions, 4)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.regions)) == 1)> ::Compare("mapping_info.regions", "4", mapping_info.regions, 4 ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 597, gtest_ar.failure_message()) = ::testing::Message(); |
| 598 | ASSERT_EQ(mapping_info.size, total_range_len)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.size)) == 1)> ::Compare("mapping_info.size", "total_range_len", mapping_info .size, total_range_len))) ; else return ::testing::internal:: AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 598, gtest_ar.failure_message()) = ::testing::Message(); |
| 599 | ASSERT_EQ(mapping_info.committed_size, total_range_len / 2)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.committed_size)) == 1)>::Compare("mapping_info.committed_size", "total_range_len / 2" , mapping_info.committed_size, total_range_len / 2))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 599, gtest_ar.failure_message()) = ::testing::Message(); |
| 600 | } |
| 601 | // Test just outside the allocation |
| 602 | if (os::win32::find_mapping(p - 1, &mapping_info)) { |
| 603 | ASSERT_NE(mapping_info.base, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("mapping_info.base" , "p", mapping_info.base, p))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 603, gtest_ar.failure_message()) = ::testing::Message(); |
| 604 | } |
| 605 | if (os::win32::find_mapping(p + total_range_len, &mapping_info)) { |
| 606 | ASSERT_NE(mapping_info.base, p)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("mapping_info.base" , "p", mapping_info.base, p))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 606, gtest_ar.failure_message()) = ::testing::Message(); |
| 607 | } |
| 608 | ASSERT_TRUE(os::release_memory((char*)p, total_range_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::release_memory((char *)p, total_range_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 608, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::release_memory((char*)p, total_range_len)", "false", "true" ).c_str()) = ::testing::Message(); |
| 609 | PRINT_MAPPINGS("B"){ tty->print_cr("%s", "B"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 610 | ASSERT_FALSE(os::win32::find_mapping(p, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::win32::find_mapping (p, &mapping_info)))) ; else return ::testing::internal:: AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 610, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping(p, &mapping_info)", "true", "false" ).c_str()) = ::testing::Message(); |
| 611 | } |
| 612 | |
| 613 | TEST_VM(os, find_mapping_3)class os_find_mapping_3_vm_Test : public ::testing::Test { public : os_find_mapping_3_vm_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_find_mapping_3_vm_Test(os_find_mapping_3_vm_Test const &) = delete; void operator=(os_find_mapping_3_vm_Test const &) = delete;};::testing::TestInfo* const os_find_mapping_3_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "find_mapping_3_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 613), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_find_mapping_3_vm_Test> );void os_find_mapping_3_vm_Test::TestBody() { |
| 614 | const size_t total_range_len = 4 * M; |
| 615 | os::win32::mapping_info_t mapping_info; |
| 616 | |
| 617 | // A more complex case, consisting of multiple allocations. |
| 618 | { |
| 619 | const size_t stripe_len = total_range_len / 4; |
| 620 | address p = reserve_multiple(4, stripe_len); |
| 621 | ASSERT_NE(p, (address)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("p", "(address)__null" , p, (address)__null))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 621, gtest_ar.failure_message()) = ::testing::Message(); |
| 622 | PRINT_MAPPINGS("E"){ tty->print_cr("%s", "E"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 623 | for (int stripe = 0; stripe < 4; stripe++) { |
| 624 | ASSERT_TRUE(os::win32::find_mapping(p + (stripe * stripe_len), &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::win32::find_mapping (p + (stripe * stripe_len), &mapping_info))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 624, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping(p + (stripe * stripe_len), &mapping_info)" , "false", "true").c_str()) = ::testing::Message(); |
| 625 | ASSERT_EQ(mapping_info.base, p + (stripe * stripe_len))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.base)) == 1)> ::Compare("mapping_info.base", "p + (stripe * stripe_len)", mapping_info .base, p + (stripe * stripe_len)))) ; else return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 625, gtest_ar.failure_message()) = ::testing::Message(); |
| 626 | ASSERT_EQ(mapping_info.regions, 1)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.regions)) == 1)> ::Compare("mapping_info.regions", "1", mapping_info.regions, 1 ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 626, gtest_ar.failure_message()) = ::testing::Message(); |
| 627 | ASSERT_EQ(mapping_info.size, stripe_len)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.size)) == 1)> ::Compare("mapping_info.size", "stripe_len", mapping_info.size , stripe_len))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 627, gtest_ar.failure_message()) = ::testing::Message(); |
| 628 | ASSERT_EQ(mapping_info.committed_size, stripe_len)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(mapping_info.committed_size)) == 1)>::Compare("mapping_info.committed_size", "stripe_len" , mapping_info.committed_size, stripe_len))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 628, gtest_ar.failure_message()) = ::testing::Message(); |
| 629 | } |
| 630 | carefully_release_multiple(p, 4, stripe_len); |
| 631 | PRINT_MAPPINGS("F"){ tty->print_cr("%s", "F"); os::print_memory_mappings((char *)p, total_range_len, tty); }; |
| 632 | ASSERT_FALSE(os::win32::find_mapping(p, &mapping_info))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::win32::find_mapping (p, &mapping_info)))) ; else return ::testing::internal:: AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 632, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::win32::find_mapping(p, &mapping_info)", "true", "false" ).c_str()) = ::testing::Message(); |
| 633 | } |
| 634 | } |
| 635 | #endif // _WIN32 |
| 636 | |
| 637 | TEST_VM(os, os_pagesizes)class os_os_pagesizes_vm_Test : public ::testing::Test { public : os_os_pagesizes_vm_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_os_pagesizes_vm_Test(os_os_pagesizes_vm_Test const &) = delete; void operator=(os_os_pagesizes_vm_Test const &) = delete;};::testing::TestInfo* const os_os_pagesizes_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "os_pagesizes_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 637), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_os_pagesizes_vm_Test>); void os_os_pagesizes_vm_Test::TestBody() { |
| 638 | ASSERT_EQ(os::min_page_size(), 4 * K)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(os::min_page_size())) == 1)> ::Compare("os::min_page_size()", "4 * K", os::min_page_size() , 4 * K))) ; else return ::testing::internal::AssertHelper(:: testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 638, gtest_ar.failure_message()) = ::testing::Message(); |
| 639 | ASSERT_LE(os::min_page_size(), (size_t)os::vm_page_size())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperLE("os::min_page_size()" , "(size_t)os::vm_page_size()", os::min_page_size(), (size_t) os::vm_page_size()))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 639, gtest_ar.failure_message()) = ::testing::Message(); |
| 640 | // The vm_page_size should be the smallest in the set of allowed page sizes |
| 641 | // (contract says "default" page size but a lot of code actually assumes |
| 642 | // this to be the smallest page size; notable, deliberate exception is |
| 643 | // AIX which can have smaller page sizes but those are not part of the |
| 644 | // page_sizes() set). |
| 645 | ASSERT_EQ(os::page_sizes().smallest(), (size_t)os::vm_page_size())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(os::page_sizes().smallest())) == 1)>::Compare("os::page_sizes().smallest()", "(size_t)os::vm_page_size()" , os::page_sizes().smallest(), (size_t)os::vm_page_size()))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 645, gtest_ar.failure_message()) = ::testing::Message(); |
| 646 | // The large page size, if it exists, shall be part of the set |
| 647 | if (UseLargePages) { |
| 648 | ASSERT_GT(os::large_page_size(), (size_t)os::vm_page_size())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperGT("os::large_page_size()" , "(size_t)os::vm_page_size()", os::large_page_size(), (size_t )os::vm_page_size()))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 648, gtest_ar.failure_message()) = ::testing::Message(); |
| 649 | ASSERT_TRUE(os::page_sizes().contains(os::large_page_size()))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::page_sizes().contains (os::large_page_size()))) ; else return ::testing::internal:: AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 649, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::page_sizes().contains(os::large_page_size())", "false" , "true").c_str()) = ::testing::Message(); |
| 650 | } |
| 651 | os::page_sizes().print_on(tty); |
| 652 | tty->cr(); |
| 653 | } |
| 654 | |
| 655 | static const int min_page_size_log2 = exact_log2(os::min_page_size()); |
| 656 | static const int max_page_size_log2 = (int)BitsPerWord; |
| 657 | |
| 658 | TEST_VM(os, pagesizes_test_range)class os_pagesizes_test_range_vm_Test : public ::testing::Test { public: os_pagesizes_test_range_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_pagesizes_test_range_vm_Test(os_pagesizes_test_range_vm_Test const &) = delete; void operator=(os_pagesizes_test_range_vm_Test const &) = delete;};::testing::TestInfo* const os_pagesizes_test_range_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "pagesizes_test_range_vm", __null, __null, ::testing:: internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 658), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_pagesizes_test_range_vm_Test >);void os_pagesizes_test_range_vm_Test::TestBody() { |
| 659 | for (int bit = min_page_size_log2; bit < max_page_size_log2; bit++) { |
| 660 | for (int bit2 = min_page_size_log2; bit2 < max_page_size_log2; bit2++) { |
| 661 | const size_t s = (size_t)1 << bit; |
| 662 | const size_t s2 = (size_t)1 << bit2; |
| 663 | os::PageSizes pss; |
| 664 | ASSERT_EQ((size_t)0, pss.smallest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper((size_t)0)) == 1)>::Compare ("(size_t)0", "pss.smallest()", (size_t)0, pss.smallest()))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 664, gtest_ar.failure_message()) = ::testing::Message(); |
| 665 | ASSERT_EQ((size_t)0, pss.largest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper((size_t)0)) == 1)>::Compare ("(size_t)0", "pss.largest()", (size_t)0, pss.largest()))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 665, gtest_ar.failure_message()) = ::testing::Message(); |
| 666 | // one size set |
| 667 | pss.add(s); |
| 668 | ASSERT_TRUE(pss.contains(s))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(pss.contains(s))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 668, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "pss.contains(s)", "false", "true").c_str()) = ::testing::Message (); |
| 669 | ASSERT_EQ(s, pss.smallest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s)) == 1)>::Compare("s", "pss.smallest()" , s, pss.smallest()))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 669, gtest_ar.failure_message()) = ::testing::Message(); |
| 670 | ASSERT_EQ(s, pss.largest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s)) == 1)>::Compare("s", "pss.largest()" , s, pss.largest()))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 670, gtest_ar.failure_message()) = ::testing::Message(); |
| 671 | ASSERT_EQ(pss.next_larger(s), (size_t)0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_larger(s))) == 1)> ::Compare("pss.next_larger(s)", "(size_t)0", pss.next_larger( s), (size_t)0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 671, gtest_ar.failure_message()) = ::testing::Message(); |
| 672 | ASSERT_EQ(pss.next_smaller(s), (size_t)0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_smaller(s))) == 1)> ::Compare("pss.next_smaller(s)", "(size_t)0", pss.next_smaller (s), (size_t)0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 672, gtest_ar.failure_message()) = ::testing::Message(); |
| 673 | // two set |
| 674 | pss.add(s2); |
| 675 | ASSERT_TRUE(pss.contains(s2))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(pss.contains(s2))) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 675, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "pss.contains(s2)", "false", "true").c_str()) = ::testing:: Message(); |
| 676 | if (s2 < s) { |
| 677 | ASSERT_EQ(s2, pss.smallest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s2)) == 1)>::Compare("s2", "pss.smallest()", s2, pss.smallest()))) ; else return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 677, gtest_ar.failure_message()) = ::testing::Message(); |
| 678 | ASSERT_EQ(s, pss.largest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s)) == 1)>::Compare("s", "pss.largest()" , s, pss.largest()))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 678, gtest_ar.failure_message()) = ::testing::Message(); |
| 679 | ASSERT_EQ(pss.next_larger(s2), (size_t)s)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_larger(s2))) == 1)> ::Compare("pss.next_larger(s2)", "(size_t)s", pss.next_larger (s2), (size_t)s))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 679, gtest_ar.failure_message()) = ::testing::Message(); |
| 680 | ASSERT_EQ(pss.next_smaller(s2), (size_t)0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_smaller(s2))) == 1)> ::Compare("pss.next_smaller(s2)", "(size_t)0", pss.next_smaller (s2), (size_t)0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 680, gtest_ar.failure_message()) = ::testing::Message(); |
| 681 | ASSERT_EQ(pss.next_larger(s), (size_t)0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_larger(s))) == 1)> ::Compare("pss.next_larger(s)", "(size_t)0", pss.next_larger( s), (size_t)0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 681, gtest_ar.failure_message()) = ::testing::Message(); |
| 682 | ASSERT_EQ(pss.next_smaller(s), (size_t)s2)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_smaller(s))) == 1)> ::Compare("pss.next_smaller(s)", "(size_t)s2", pss.next_smaller (s), (size_t)s2))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 682, gtest_ar.failure_message()) = ::testing::Message(); |
| 683 | } else if (s2 > s) { |
| 684 | ASSERT_EQ(s, pss.smallest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s)) == 1)>::Compare("s", "pss.smallest()" , s, pss.smallest()))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 684, gtest_ar.failure_message()) = ::testing::Message(); |
| 685 | ASSERT_EQ(s2, pss.largest())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s2)) == 1)>::Compare("s2", "pss.largest()", s2, pss.largest()))) ; else return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 685, gtest_ar.failure_message()) = ::testing::Message(); |
| 686 | ASSERT_EQ(pss.next_larger(s), (size_t)s2)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_larger(s))) == 1)> ::Compare("pss.next_larger(s)", "(size_t)s2", pss.next_larger (s), (size_t)s2))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 686, gtest_ar.failure_message()) = ::testing::Message(); |
| 687 | ASSERT_EQ(pss.next_smaller(s), (size_t)0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_smaller(s))) == 1)> ::Compare("pss.next_smaller(s)", "(size_t)0", pss.next_smaller (s), (size_t)0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 687, gtest_ar.failure_message()) = ::testing::Message(); |
| 688 | ASSERT_EQ(pss.next_larger(s2), (size_t)0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_larger(s2))) == 1)> ::Compare("pss.next_larger(s2)", "(size_t)0", pss.next_larger (s2), (size_t)0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 688, gtest_ar.failure_message()) = ::testing::Message(); |
| 689 | ASSERT_EQ(pss.next_smaller(s2), (size_t)s)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(pss.next_smaller(s2))) == 1)> ::Compare("pss.next_smaller(s2)", "(size_t)s", pss.next_smaller (s2), (size_t)s))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 689, gtest_ar.failure_message()) = ::testing::Message(); |
| 690 | } |
| 691 | for (int bit3 = min_page_size_log2; bit3 < max_page_size_log2; bit3++) { |
| 692 | const size_t s3 = (size_t)1 << bit3; |
| 693 | ASSERT_EQ(s3 == s || s3 == s2, pss.contains(s3))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(s3 == s || s3 == s2)) == 1)> ::Compare("s3 == s || s3 == s2", "pss.contains(s3)", s3 == s || s3 == s2, pss.contains(s3)))) ; else return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 693, gtest_ar.failure_message()) = ::testing::Message(); |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | TEST_VM(os, pagesizes_test_print)class os_pagesizes_test_print_vm_Test : public ::testing::Test { public: os_pagesizes_test_print_vm_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_pagesizes_test_print_vm_Test(os_pagesizes_test_print_vm_Test const &) = delete; void operator=(os_pagesizes_test_print_vm_Test const &) = delete;};::testing::TestInfo* const os_pagesizes_test_print_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "pagesizes_test_print_vm", __null, __null, ::testing:: internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 699), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_pagesizes_test_print_vm_Test >);void os_pagesizes_test_print_vm_Test::TestBody() { |
| 700 | os::PageSizes pss; |
| 701 | const size_t sizes[] = { 16 * K, 64 * K, 128 * K, 1 * M, 4 * M, 1 * G, 2 * G, 0 }; |
| 702 | static const char* const expected = "16k, 64k, 128k, 1M, 4M, 1G, 2G"; |
| 703 | for (int i = 0; sizes[i] != 0; i++) { |
| 704 | pss.add(sizes[i]); |
| 705 | } |
| 706 | char buffer[256]; |
| 707 | stringStream ss(buffer, sizeof(buffer)); |
| 708 | pss.print_on(&ss); |
| 709 | ASSERT_EQ(strcmp(expected, buffer), 0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(strcmp(expected, buffer))) == 1)>::Compare("strcmp(expected, buffer)", "0", strcmp(expected , buffer), 0))) ; else return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 709, gtest_ar.failure_message()) = ::testing::Message(); |
| 710 | } |
| 711 | |
| 712 | TEST_VM(os, dll_address_to_function_and_library_name)class os_dll_address_to_function_and_library_name_vm_Test : public ::testing::Test { public: os_dll_address_to_function_and_library_name_vm_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); os_dll_address_to_function_and_library_name_vm_Test (os_dll_address_to_function_and_library_name_vm_Test const & ) = delete; void operator=(os_dll_address_to_function_and_library_name_vm_Test const &) = delete;};::testing::TestInfo* const os_dll_address_to_function_and_library_name_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "dll_address_to_function_and_library_name_vm", __null, __null, ::testing::internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 712), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_dll_address_to_function_and_library_name_vm_Test >);void os_dll_address_to_function_and_library_name_vm_Test ::TestBody() { |
| 713 | char tmp[1024]; |
| 714 | char output[1024]; |
| 715 | stringStream st(output, sizeof(output)); |
| 716 | |
| 717 | #define EXPECT_CONTAINS(haystack, needle)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("::strstr(haystack, needle)" , "(char*)__null", ::strstr(haystack, needle), (char*)__null) )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 717, gtest_ar.failure_message()) = ::testing::Message() \ |
| 718 | EXPECT_NE(::strstr(haystack, needle), (char*)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("::strstr(haystack, needle)" , "(char*)__null", ::strstr(haystack, needle), (char*)__null) )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 718, gtest_ar.failure_message()) = ::testing::Message() |
| 719 | #define EXPECT_DOES_NOT_CONTAIN(haystack, needle)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(::strstr(haystack, needle))) == 1)>::Compare("::strstr(haystack, needle)", "(char*)__null" , ::strstr(haystack, needle), (char*)__null))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 719, gtest_ar.failure_message()) = ::testing::Message() \ |
| 720 | EXPECT_EQ(::strstr(haystack, needle), (char*)NULL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(::strstr(haystack, needle))) == 1)>::Compare("::strstr(haystack, needle)", "(char*)__null" , ::strstr(haystack, needle), (char*)__null))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 720, gtest_ar.failure_message()) = ::testing::Message() |
| 721 | // #define LOG(...) tty->print_cr(__VA_ARGS__); // enable if needed |
| 722 | #define LOG(...) |
| 723 | |
| 724 | // Invalid addresses |
| 725 | LOG("os::print_function_and_library_name(st, -1) expects FALSE."); |
| 726 | address addr = (address)(intptr_t)-1; |
| 727 | EXPECT_FALSE(os::print_function_and_library_name(&st, addr))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::print_function_and_library_name (&st, addr)))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 727, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr)", "true" , "false").c_str()) = ::testing::Message(); |
| 728 | LOG("os::print_function_and_library_name(st, NULL) expects FALSE."); |
| 729 | addr = NULL__null; |
| 730 | EXPECT_FALSE(os::print_function_and_library_name(&st, addr))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(os::print_function_and_library_name (&st, addr)))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 730, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr)", "true" , "false").c_str()) = ::testing::Message(); |
| 731 | |
| 732 | // Valid addresses |
| 733 | // Test with or without shorten-paths, demangle, and scratch buffer |
| 734 | for (int i = 0; i < 16; i++) { |
| 735 | const bool shorten_paths = (i & 1) != 0; |
| 736 | const bool demangle = (i & 2) != 0; |
| 737 | const bool strip_arguments = (i & 4) != 0; |
| 738 | const bool provide_scratch_buffer = (i & 8) != 0; |
| 739 | LOG("shorten_paths=%d, demangle=%d, strip_arguments=%d, provide_scratch_buffer=%d", |
| 740 | shorten_paths, demangle, strip_arguments, provide_scratch_buffer); |
| 741 | |
| 742 | // Should show os::min_page_size in libjvm |
| 743 | addr = CAST_FROM_FN_PTR(address, Threads::create_vm)((address)((address_word)(Threads::create_vm))); |
| 744 | st.reset(); |
| 745 | EXPECT_TRUE(os::print_function_and_library_name(&st, addr,switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, provide_scratch_buffer ? tmp : __null, sizeof (tmp), shorten_paths, demangle, strip_arguments))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 749, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, provide_scratch_buffer ? tmp : NULL, sizeof(tmp), shorten_paths, demangle, strip_arguments)" , "false", "true").c_str()) = ::testing::Message() |
| 746 | provide_scratch_buffer ? tmp : NULL,switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, provide_scratch_buffer ? tmp : __null, sizeof (tmp), shorten_paths, demangle, strip_arguments))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 749, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, provide_scratch_buffer ? tmp : NULL, sizeof(tmp), shorten_paths, demangle, strip_arguments)" , "false", "true").c_str()) = ::testing::Message() |
| 747 | sizeof(tmp),switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, provide_scratch_buffer ? tmp : __null, sizeof (tmp), shorten_paths, demangle, strip_arguments))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 749, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, provide_scratch_buffer ? tmp : NULL, sizeof(tmp), shorten_paths, demangle, strip_arguments)" , "false", "true").c_str()) = ::testing::Message() |
| 748 | shorten_paths, demangle,switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, provide_scratch_buffer ? tmp : __null, sizeof (tmp), shorten_paths, demangle, strip_arguments))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 749, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, provide_scratch_buffer ? tmp : NULL, sizeof(tmp), shorten_paths, demangle, strip_arguments)" , "false", "true").c_str()) = ::testing::Message() |
| 749 | strip_arguments))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, provide_scratch_buffer ? tmp : __null, sizeof (tmp), shorten_paths, demangle, strip_arguments))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 749, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, provide_scratch_buffer ? tmp : NULL, sizeof(tmp), shorten_paths, demangle, strip_arguments)" , "false", "true").c_str()) = ::testing::Message(); |
| 750 | EXPECT_CONTAINS(output, "Threads")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("::strstr(output, \"Threads\")" , "(char*)__null", ::strstr(output, "Threads"), (char*)__null ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 750, gtest_ar.failure_message()) = ::testing::Message(); |
| 751 | EXPECT_CONTAINS(output, "create_vm")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("::strstr(output, \"create_vm\")" , "(char*)__null", ::strstr(output, "create_vm"), (char*)__null ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 751, gtest_ar.failure_message()) = ::testing::Message(); |
| 752 | EXPECT_CONTAINS(output, "jvm")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("::strstr(output, \"jvm\")" , "(char*)__null", ::strstr(output, "jvm"), (char*)__null))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 752, gtest_ar.failure_message()) = ::testing::Message(); // "jvm.dll" or "libjvm.so" or similar |
| 753 | LOG("%s", output); |
| 754 | |
| 755 | // Test truncation on scratch buffer |
| 756 | if (provide_scratch_buffer) { |
| 757 | st.reset(); |
| 758 | tmp[10] = 'X'; |
| 759 | EXPECT_TRUE(os::print_function_and_library_name(&st, addr, tmp, 10,switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, tmp, 10, shorten_paths, demangle))) ; else :: testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 760, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, tmp, 10, shorten_paths, demangle)" , "false", "true").c_str()) = ::testing::Message() |
| 760 | shorten_paths, demangle))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(os::print_function_and_library_name (&st, addr, tmp, 10, shorten_paths, demangle))) ; else :: testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 760, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "os::print_function_and_library_name(&st, addr, tmp, 10, shorten_paths, demangle)" , "false", "true").c_str()) = ::testing::Message(); |
| 761 | EXPECT_EQ(tmp[10], 'X')switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(tmp[10])) == 1)>::Compare( "tmp[10]", "'X'", tmp[10], 'X'))) ; else ::testing::internal:: AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 761, gtest_ar.failure_message()) = ::testing::Message(); |
| 762 | LOG("%s", output); |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | // Not a regex! Very primitive, just match: |
| 768 | // "d" - digit |
| 769 | // "a" - ascii |
| 770 | // "." - everything |
| 771 | // rest must match |
| 772 | static bool very_simple_string_matcher(const char* pattern, const char* s) { |
| 773 | const size_t lp = strlen(pattern); |
| 774 | const size_t ls = strlen(s); |
| 775 | if (ls < lp) { |
| 776 | return false; |
| 777 | } |
| 778 | for (size_t i = 0; i < lp; i ++) { |
| 779 | switch (pattern[i]) { |
| 780 | case '.': continue; |
| 781 | case 'd': if (!isdigit(s[i])) return false; break; |
| 782 | case 'a': if (!isascii(s[i])(((s[i]) & ~0x7f) == 0)) return false; break; |
| 783 | default: if (s[i] != pattern[i]) return false; break; |
| 784 | } |
| 785 | } |
| 786 | return true; |
| 787 | } |
| 788 | |
| 789 | TEST_VM(os, iso8601_time)class os_iso8601_time_vm_Test : public ::testing::Test { public : os_iso8601_time_vm_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); os_iso8601_time_vm_Test(os_iso8601_time_vm_Test const &) = delete; void operator=(os_iso8601_time_vm_Test const &) = delete;};::testing::TestInfo* const os_iso8601_time_vm_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "os", "iso8601_time_vm", __null, __null, ::testing::internal ::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 789), (::testing::internal::GetTestTypeId()), ::testing::Test ::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< os_iso8601_time_vm_Test>); void os_iso8601_time_vm_Test::TestBody() { |
| 790 | char buffer[os::iso8601_timestamp_size + 1]; // + space for canary |
| 791 | buffer[os::iso8601_timestamp_size] = 'X'; // canary |
| 792 | const char* result = NULL__null; |
| 793 | // YYYY-MM-DDThh:mm:ss.mmm+zzzz |
| 794 | const char* const pattern_utc = "dddd-dd-dd.dd:dd:dd.ddd.0000"; |
| 795 | const char* const pattern_local = "dddd-dd-dd.dd:dd:dd.ddd.dddd"; |
| 796 | |
| 797 | result = os::iso8601_time(buffer, sizeof(buffer), true); |
| 798 | tty->print_cr("%s", result); |
| 799 | EXPECT_EQ(result, buffer)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(result)) == 1)>::Compare("result" , "buffer", result, buffer))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 799, gtest_ar.failure_message()) = ::testing::Message(); |
| 800 | EXPECT_TRUE(very_simple_string_matcher(pattern_utc, result))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(very_simple_string_matcher (pattern_utc, result))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 800, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "very_simple_string_matcher(pattern_utc, result)", "false", "true").c_str()) = ::testing::Message(); |
| 801 | |
| 802 | result = os::iso8601_time(buffer, sizeof(buffer), false); |
| 803 | tty->print_cr("%s", result); |
| 804 | EXPECT_EQ(result, buffer)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(result)) == 1)>::Compare("result" , "buffer", result, buffer))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 804, gtest_ar.failure_message()) = ::testing::Message(); |
| 805 | EXPECT_TRUE(very_simple_string_matcher(pattern_local, result))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(very_simple_string_matcher (pattern_local, result))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 805, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "very_simple_string_matcher(pattern_local, result)", "false" , "true").c_str()) = ::testing::Message(); |
| 806 | |
| 807 | // Test with explicit timestamps |
| 808 | result = os::iso8601_time(0, buffer, sizeof(buffer), true); |
| 809 | tty->print_cr("%s", result); |
| 810 | EXPECT_EQ(result, buffer)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(result)) == 1)>::Compare("result" , "buffer", result, buffer))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 810, gtest_ar.failure_message()) = ::testing::Message(); |
| 811 | EXPECT_TRUE(very_simple_string_matcher("1970-01-01.00:00:00.000+0000", result))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(very_simple_string_matcher ("1970-01-01.00:00:00.000+0000", result))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 811, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "very_simple_string_matcher(\"1970-01-01.00:00:00.000+0000\", result)" , "false", "true").c_str()) = ::testing::Message(); |
| 812 | |
| 813 | result = os::iso8601_time(17, buffer, sizeof(buffer), true); |
| 814 | tty->print_cr("%s", result); |
| 815 | EXPECT_EQ(result, buffer)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(result)) == 1)>::Compare("result" , "buffer", result, buffer))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 815, gtest_ar.failure_message()) = ::testing::Message(); |
| 816 | EXPECT_TRUE(very_simple_string_matcher("1970-01-01.00:00:00.017+0000", result))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(very_simple_string_matcher ("1970-01-01.00:00:00.017+0000", result))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 816, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "very_simple_string_matcher(\"1970-01-01.00:00:00.017+0000\", result)" , "false", "true").c_str()) = ::testing::Message(); |
| 817 | |
| 818 | // Canary should still be intact |
| 819 | EXPECT_EQ(buffer[os::iso8601_timestamp_size], 'X')switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(buffer[os::iso8601_timestamp_size ])) == 1)>::Compare("buffer[os::iso8601_timestamp_size]", "'X'" , buffer[os::iso8601_timestamp_size], 'X'))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/home/daniel/Projects/java/jdk/test/hotspot/gtest/runtime/test_os.cpp" , 819, gtest_ar.failure_message()) = ::testing::Message(); |
| 820 | } |