From b1c1bb5e83d0cec2a941622cad1cd471ff22b551 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Mon, 16 Oct 2023 14:13:56 +0530 Subject: [PATCH] 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 --- tests/gunit/012-cgroup_create_cgroup.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 */ -- 2.47.2