]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
gunit/012: populate root_cgroup.controllers file
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 16 Oct 2023 08:43:56 +0000 (14:13 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 25 Oct 2023 20:23:20 +0000 (14:23 -0600)
To enable a controller in a cgroup, its parent's subtree_control file is
read to check if the controller is enabled, if not enabled, parent's
cgroup.controllers is checked for the supported controllers, before
enabling it in the cgroup.subtree_control.

Populate controllers in the root_cgroup.controllers file, to help with
the check for supported controllers, without this
cgroupv2_subtree_control_recursive() will fail, when it is checked for
controller existence.

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

index 1d771058ba2ad5af8bc041f3e5119280c77c1bf8..c06bb3a4cd677e26be8eb7195a34a3b76f927551 100644 (file)
@@ -82,6 +82,16 @@ class CgroupCreateCgroupTest : public ::testing::Test {
                                f = fopen(tmp_path, "w");
                                ASSERT_NE(f, nullptr);
                                fclose(f);
+
+                               memset(tmp_path, 0, sizeof(tmp_path));
+                               snprintf(tmp_path, FILENAME_MAX - 1,
+                                        "%s/cgroup.controllers",
+                                        PARENT_DIR);
+
+                               f = fopen(tmp_path, "a");
+                               ASSERT_NE(f, nullptr);
+                               fprintf(f, "%s ",  CONTROLLERS[i]);
+                               fclose(f);
                                break;
                        default:
                                /* we shouldn't get here.  fail the test */