From: Tom Hromatka Date: Tue, 1 Apr 2025 18:35:15 +0000 (+0000) Subject: gunit: Promote namespaces in test 001 and 013 to heap variables X-Git-Tag: v3.2.0~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3cc0377a215a3cfa55c17948be72c0fa502ae6ec;p=thirdparty%2Flibcgroup.git 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 --- 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;