From 44f5dae655206be2040c2f927c6accb5e897555f Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 17 Dec 2008 15:20:36 +0000 Subject: [PATCH] libcgroup Test: fix-modify_cgroup-bug-in-multimnt this patch fixes the testcase for cgroup_modify_cgroup() multi mount. The second controller was not initialised to a value, so doing that. /me learns the bad effects of using global data structure :) Signed-off-by: Sudhir Kumar git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@272 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest01.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index 24813956..333957b8 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -20,6 +20,7 @@ int main(int argc, char *argv[]) { int fs_mounted, retval; struct cgroup *cgroup1, *cgroup2, *cgroup3, *nullcgroup = NULL; + struct cgroup_controller *sec_controller; /* In case of multimount for readability we use the controller name * before the cgroup structure name */ struct cgroup *ctl1_cgroup1, *ctl2_cgroup1, *ctl2_cgroup2; @@ -825,14 +826,24 @@ int main(int argc, char *argv[]) " Exiting without running further testcases\n"); exit(1); } - if (!cgroup_add_controller(mod_common_cgroup, controller_name)) + + sec_controller = cgroup_add_controller(mod_common_cgroup, + controller_name); + if (!sec_controller) { message(++i, FAIL, "add_controller()", retval, extra); + printf("The cgroup_modify_cgroup() test will fail\n"); + } + + strncpy(val_string, "7000000", sizeof(val_string)); + retval = cgroup_add_value_string(sec_controller, + control_file, val_string); + if (retval) + printf("The cgroup_modify_cgroup() test will fail\n"); /* * Test14: modify existing cgroup with this new cgroup * Exp outcome: zero return value and control value modified */ - strncpy(extra, " Called with commongroup. ", SIZE); retval = cgroup_modify_cgroup(mod_common_cgroup); /* Check if the values are changed */ @@ -840,11 +851,14 @@ int main(int argc, char *argv[]) set_controller(ctl1, controller_name, control_file); build_path(path_control_file, mountpoint, "commongroup", control_file); + strncpy(val_string, "260000", sizeof(val_string)); if (!group_modified(path_control_file, STRING)) { set_controller(ctl2, controller_name, control_file); build_path(path_control_file, mountpoint2, "commongroup", control_file); + strncpy(val_string, "7000000", + sizeof(val_string)); if (!group_modified(path_control_file, STRING)) { strncat(extra, " group modified under" " both controllers\n", SIZE); -- 2.47.2