diff --git a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp index cc326dbb502..aa1d2a19b28 100644 --- a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp +++ b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp @@ -34,6 +34,9 @@ #include +// for basename +#include + typedef struct { const char* mount_path; const char* root_path; @@ -47,6 +50,7 @@ static bool file_exists(const char* filename) { return os::stat(filename, &st) == 0; } +// we rely on temp_file returning modifiable memory in resource area. static char* temp_file(const char* prefix) { const testing::TestInfo* test_info = ::testing::UnitTest::GetInstance()->current_test_info(); stringStream path; @@ -89,7 +93,7 @@ static void fill_file(const char* path, const char* content) { } TEST(cgroupTest, read_numerical_key_value_failure_cases) { - const char* test_file = temp_file("cgroups"); + char* test_file = temp_file("cgroups"); const char* b = basename(test_file); EXPECT_TRUE(b != nullptr) << "basename was null"; stringStream path; @@ -135,7 +139,7 @@ TEST(cgroupTest, read_numerical_key_value_failure_cases) { } TEST(cgroupTest, read_numerical_key_value_success_cases) { - const char* test_file = temp_file("cgroups"); + char* test_file = temp_file("cgroups"); const char* b = basename(test_file); EXPECT_TRUE(b != nullptr) << "basename was null"; stringStream path; @@ -235,7 +239,7 @@ TEST(cgroupTest, read_numerical_key_value_null) { } TEST(cgroupTest, read_number_tests) { - const char* test_file = temp_file("cgroups"); + char* test_file = temp_file("cgroups"); const char* b = basename(test_file); constexpr julong bad = 0xBAD; EXPECT_TRUE(b != nullptr) << "basename was null"; @@ -289,7 +293,7 @@ TEST(cgroupTest, read_number_tests) { } TEST(cgroupTest, read_string_tests) { - const char* test_file = temp_file("cgroups"); + char* test_file = temp_file("cgroups"); const char* b = basename(test_file); EXPECT_TRUE(b != nullptr) << "basename was null"; stringStream path; @@ -355,7 +359,7 @@ TEST(cgroupTest, read_string_tests) { } TEST(cgroupTest, read_number_tuple_test) { - const char* test_file = temp_file("cgroups"); + char* test_file = temp_file("cgroups"); const char* b = basename(test_file); EXPECT_TRUE(b != nullptr) << "basename was null"; stringStream path;