From 8eaae035d1762d5ab3624a7104f4154770434b00 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 17 Dec 2008 15:16:54 +0000 Subject: [PATCH] libcgroup Test: libcgroup-modify_cgroup-test3-for-multimnt This patch adds a testcase for libcgroup api cgroup_modify_cgroup() for commongroup (under two controllers) in multiple mount scenario. Again the challenge is to handle the control value as diff controllers put diff upper limit on control value and we pick the controller dynamicaly. So thoughts ??? Signed-off-by: Sudhir Kumar git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@264 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest01.c | 68 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index 7b65fe49..e1c93e80 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -930,7 +930,73 @@ int main(int argc, char *argv[]) strncpy(extra, "\n", SIZE); /* - * Test13: delete this common cgroup + * Test13: Create a valid cgroup structure to modify the + * commongroup which is under multiple controllers + * Exp outcome: no error. 0 return value + */ + strncpy(group, "commongroup", sizeof(group)); + strncpy(val_string, "7000000", sizeof(val_string)); + retval = set_controller(ctl1, controller_name, control_file); + + if (retval) { + fprintf(stderr, "Setting controller failled " + " Exiting without running further testcases\n"); + exit(1); + } + + mod_common_cgroup = new_cgroup(group, controller_name, + control_file, STRING); + + /* Add one more controller to the cgroup */ + retval = set_controller(ctl2, controller_name, control_file); + if (retval) { + fprintf(stderr, "Setting controller failled " + " Exiting without running further testcases\n"); + exit(1); + } + if (!cgroup_add_controller(mod_common_cgroup, controller_name)) + message(++i, FAIL, "add_controller()", retval, extra); + + /* + * 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 */ + if (!retval) { + build_path(path_control_file, mountpoint, + "commongroup", control_file); + if (!group_modified(path_control_file, STRING)) { + build_path(path_control_file, mountpoint2, + "commongroup", control_file); + if (!group_modified(path_control_file, STRING)) { + strncat(extra, " group modified under" + " both controllers\n", SIZE); + message(++i, PASS, "modify_cgroup()", + retval, extra); + } else { + strncat(extra, " group not modified " + "under 2nd controller\n", SIZE); + message(++i, FAIL, "modify_cgroup()", + retval, extra); + } + } else { + strncat(extra, " group not modified under any " + "controller\n", SIZE); + message(++i, FAIL, "modify_cgroup()", + retval, extra); + } + } else { + strncat(extra, "\n", sizeof("\n")); + message(++i, FAIL, "modify_cgroup()", retval, extra); + } + + strncpy(extra, "\n", SIZE); + + /* + * Test15: delete this common cgroup * Exp outcome: zero return value */ strncpy(extra, " Called with commongroup. ", SIZE); -- 2.47.2