]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
gunit/test-015: Populate subtree_control for leaf cgroup
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 20 Dec 2022 16:09:19 +0000 (21:39 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 6 Jan 2023 15:28:47 +0000 (08:28 -0700)
We no more rely on the cgroup's parent subtree_control file to verify
if a controller is enabled for a cgroup. So, populate the leaf/child
cgroups with subtree_control file similar to the parent cgroup.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/gunit/015-cgroupv2_controller_enabled.cpp

index f5ad47c2fde66dd34c3c71fdee246d13a1a2c8c4..25d2e7c1f76a5252d9262d1cfdbd92a0a9404a15 100644 (file)
@@ -54,6 +54,7 @@ class CgroupV2ControllerEnabled : public ::testing::Test {
        void InitChildDir(const char dirname[])
        {
                char tmp_path[FILENAME_MAX] = {0};
+               FILE *f;
                int ret;
 
                /* create the directory */
@@ -61,6 +62,14 @@ class CgroupV2ControllerEnabled : public ::testing::Test {
                         PARENT_DIR, dirname);
                ret = mkdir(tmp_path, MODE);
                ASSERT_EQ(ret, 0);
+
+               snprintf(tmp_path, FILENAME_MAX - 1,
+                        "%s/%s/cgroup.subtree_control", PARENT_DIR, dirname);
+
+               f = fopen(tmp_path, "w");
+               ASSERT_NE(f, nullptr);
+               fprintf(f, "cpu io memory pids\n");
+               fclose(f);
        }
 
        void InitMountTable(void)