From d0052c032cc1927e7e92f04cfedab20e0c4e0293 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 5 Jun 2024 07:11:27 +0000 Subject: [PATCH] 8333326: Linux Alpine build fails after 8302744 Reviewed-by: sgehwolf, clanger, stuefe --- .../gtest/runtime/test_cgroupSubsystem_linux.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp index cc326dbb502ac..aa1d2a19b28ec 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;