From: Kamalesh Babulal Date: Mon, 16 Oct 2023 08:43:56 +0000 (+0530) Subject: gunit/012: populate root_cgroup.controllers file X-Git-Tag: v3.2.0~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1c1bb5e83d0cec2a941622cad1cd471ff22b551;p=thirdparty%2Flibcgroup.git gunit/012: populate root_cgroup.controllers file 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 Signed-off-by: Tom Hromatka --- diff --git a/tests/gunit/012-cgroup_create_cgroup.cpp b/tests/gunit/012-cgroup_create_cgroup.cpp index 1d771058..c06bb3a4 100644 --- a/tests/gunit/012-cgroup_create_cgroup.cpp +++ b/tests/gunit/012-cgroup_create_cgroup.cpp @@ -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 */