]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
gunit: Promote namespaces in test 001 and 013 to heap variables
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 1 Apr 2025 18:35:15 +0000 (18:35 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 2 Apr 2025 18:45:23 +0000 (12:45 -0600)
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 <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
tests/gunit/001-path.cpp
tests/gunit/013-cgroup_build_tasks_procs_path.cpp

index b48f06e6a728272888378c1f6f01cd740241edaa..a729e0803208b66b534168df257004dc3a2470a7 100644 (file)
@@ -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;
 
index 87b00e5e41b150bb0262bc94742f788993c5a219..7bc7261db6b3558b01a176a2b001917877ea1e45 100644 (file)
@@ -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;