diff --git a/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp b/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp index 154ba09095b..695c586b1d8 100644 --- a/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2022 SAP SE. All rights reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023 SAP SE. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ static void check_failing_realloc(size_t failing_request_size) { EXPECT_NULL(p2); // original allocation should still be intact - GtestUtils::check_range(p, first_size); + EXPECT_RANGE_IS_MARKED(p, first_size); if (nmt_enabled) { check_expected_malloc_header(p, mtTest, first_size); } @@ -102,14 +102,14 @@ static void* do_realloc(void* p, size_t old_size, size_t new_size, uint8_t old_c // Check old content, and possibly zapped area (if block grew) if (old_size < new_size) { - GtestUtils::check_range((char*)p2, old_size, old_content); + EXPECT_RANGE_IS_MARKED_WITH(p2, old_size, old_content); #ifdef ASSERT if (MemTracker::enabled()) { - GtestUtils::check_range((char*)p2 + old_size, new_size - old_size, uninitBlockPad); + EXPECT_RANGE_IS_MARKED_WITH((char*)p2 + old_size, new_size - old_size, uninitBlockPad); } #endif } else { - GtestUtils::check_range((char*)p2, new_size, old_content); + EXPECT_RANGE_IS_MARKED_WITH(p2, new_size, old_content); } return p2; diff --git a/test/hotspot/gtest/testutils.cpp b/test/hotspot/gtest/testutils.cpp index eb2898a526d..cefa33b08dd 100644 --- a/test/hotspot/gtest/testutils.cpp +++ b/test/hotspot/gtest/testutils.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 SAP SE. All rights reserved. + * Copyright (c) 2021, 2023 SAP SE. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ void GtestUtils::mark_range_with(void* p, size_t s, uint8_t mark) { } } -bool GtestUtils::check_range(const void* p, size_t s, uint8_t expected) { +bool GtestUtils::is_range_marked(const void* p, size_t s, uint8_t expected) { if (p == NULL || s == 0) { return true; } diff --git a/test/hotspot/gtest/testutils.hpp b/test/hotspot/gtest/testutils.hpp index 0a4e8a9a5dd..23428a6526b 100644 --- a/test/hotspot/gtest/testutils.hpp +++ b/test/hotspot/gtest/testutils.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 SAP SE. All rights reserved. + * Copyright (c) 2021, 2023 SAP SE. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,16 +39,18 @@ public: // Given a memory range, check that the whole range is filled with the expected byte. // If not, hex dump around first non-matching address and return false. // If p == NULL or size == 0, returns true. - static bool check_range(const void* p, size_t s, uint8_t expected); + static bool is_range_marked(const void* p, size_t s, uint8_t expected); // Convenience method with a predefined byte mark. - static void mark_range(void* p, size_t s) { mark_range_with(p, s, 32); } - static bool check_range(const void* p, size_t s) { return check_range(p, s, 32); } + static void mark_range(void* p, size_t s) { mark_range_with(p, s, 32); } + static bool is_range_marked(const void* p, size_t s) { return is_range_marked(p, s, 32); } }; -#define ASSERT_RANGE_IS_MARKED_WITH(p, size, mark) ASSERT_TRUE(GtestUtils::check_range(p, size, mark)) -#define ASSERT_RANGE_IS_MARKED(p, size) ASSERT_TRUE(GtestUtils::check_range(p, size)) +#define ASSERT_RANGE_IS_MARKED_WITH(p, size, mark) ASSERT_TRUE(GtestUtils::is_range_marked(p, size, mark)) +#define ASSERT_RANGE_IS_MARKED(p, size) ASSERT_TRUE(GtestUtils::is_range_marked(p, size)) +#define EXPECT_RANGE_IS_MARKED_WITH(p, size, mark) EXPECT_TRUE(GtestUtils::is_range_marked(p, size, mark)) +#define EXPECT_RANGE_IS_MARKED(p, size) EXPECT_TRUE(GtestUtils::is_range_marked(p, size)) // Mimicking the official ASSERT_xx and EXPECT_xx counterparts of the googletest suite. // (ASSERT|EXPECT)_NOT_NULL: check that the given pointer is not NULL