From 3cc0377a215a3cfa55c17948be72c0fa502ae6ec Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Tue, 1 Apr 2025 18:35:15 +0000 Subject: [PATCH] gunit: Promote namespaces in test 001 and 013 to heap variables On one of my ubuntu22 machines, the NAMESPACE5[] character array was outputing garbage for the last test. Looks like gtest was running it in another thread, and the pointer was garbage. Promote the NAMESPACE* variables to be heap variables so that they're safely available for all threads. Signed-off-by: Tom Hromatka Acked-by: Kamalesh Babulal --- tests/gunit/001-path.cpp | 5 +++-- tests/gunit/013-cgroup_build_tasks_procs_path.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/gunit/001-path.cpp b/tests/gunit/001-path.cpp index b48f06e6..a729e080 100644 --- a/tests/gunit/001-path.cpp +++ b/tests/gunit/001-path.cpp @@ -10,6 +10,9 @@ #include "libcgroup-internal.h" +char * const NAMESPACE1 = "ns1"; +char * const NAMESPACE5 = "ns5"; + class BuildPathV1Test : public ::testing::Test { protected: @@ -33,8 +36,6 @@ class BuildPathV1Test : public ::testing::Test { * Note that controllers 1 and 5 are also given namespaces */ void SetUp() override { - char NAMESPACE1[] = "ns1"; - char NAMESPACE5[] = "ns5"; const int ENTRY_CNT = 6; int i, ret; diff --git a/tests/gunit/013-cgroup_build_tasks_procs_path.cpp b/tests/gunit/013-cgroup_build_tasks_procs_path.cpp index 87b00e5e..7bc7261d 100644 --- a/tests/gunit/013-cgroup_build_tasks_procs_path.cpp +++ b/tests/gunit/013-cgroup_build_tasks_procs_path.cpp @@ -10,6 +10,9 @@ #include "libcgroup-internal.h" +char * const NAMESPACE1 = "ns1"; +char * const NAMESPACE4 = "ns4"; + class BuildTasksProcPathTest : public ::testing::Test { protected: @@ -33,8 +36,6 @@ class BuildTasksProcPathTest : public ::testing::Test { * Note that controllers 1 and 4 are also given namespaces */ void SetUp() override { - char NAMESPACE1[] = "ns1"; - char NAMESPACE4[] = "ns4"; const int ENTRY_CNT = 6; int i, ret; -- 2.47.3