3434
3535#include < stdio.h>
3636
37+ // for basename
38+ #include < libgen.h>
39+
3740typedef struct {
3841 const char * mount_path;
3942 const char * root_path;
@@ -47,6 +50,7 @@ static bool file_exists(const char* filename) {
4750 return os::stat (filename, &st) == 0 ;
4851}
4952
53+ // we rely on temp_file returning modifiable memory in resource area.
5054static char * temp_file (const char * prefix) {
5155 const testing::TestInfo* test_info = ::testing::UnitTest::GetInstance ()->current_test_info ();
5256 stringStream path;
@@ -89,7 +93,7 @@ static void fill_file(const char* path, const char* content) {
8993}
9094
9195TEST (cgroupTest, read_numerical_key_value_failure_cases) {
92- const char * test_file = temp_file (" cgroups" );
96+ char * test_file = temp_file (" cgroups" );
9397 const char * b = basename (test_file);
9498 EXPECT_TRUE (b != nullptr ) << " basename was null" ;
9599 stringStream path;
@@ -135,7 +139,7 @@ TEST(cgroupTest, read_numerical_key_value_failure_cases) {
135139}
136140
137141TEST (cgroupTest, read_numerical_key_value_success_cases) {
138- const char * test_file = temp_file (" cgroups" );
142+ char * test_file = temp_file (" cgroups" );
139143 const char * b = basename (test_file);
140144 EXPECT_TRUE (b != nullptr ) << " basename was null" ;
141145 stringStream path;
@@ -235,7 +239,7 @@ TEST(cgroupTest, read_numerical_key_value_null) {
235239}
236240
237241TEST (cgroupTest, read_number_tests) {
238- const char * test_file = temp_file (" cgroups" );
242+ char * test_file = temp_file (" cgroups" );
239243 const char * b = basename (test_file);
240244 constexpr julong bad = 0xBAD ;
241245 EXPECT_TRUE (b != nullptr ) << " basename was null" ;
@@ -289,7 +293,7 @@ TEST(cgroupTest, read_number_tests) {
289293}
290294
291295TEST (cgroupTest, read_string_tests) {
292- const char * test_file = temp_file (" cgroups" );
296+ char * test_file = temp_file (" cgroups" );
293297 const char * b = basename (test_file);
294298 EXPECT_TRUE (b != nullptr ) << " basename was null" ;
295299 stringStream path;
@@ -355,7 +359,7 @@ TEST(cgroupTest, read_string_tests) {
355359}
356360
357361TEST (cgroupTest, read_number_tuple_test) {
358- const char * test_file = temp_file (" cgroups" );
362+ char * test_file = temp_file (" cgroups" );
359363 const char * b = basename (test_file);
360364 EXPECT_TRUE (b != nullptr ) << " basename was null" ;
361365 stringStream path;
0 commit comments