From be9bc9f12e399828a1a5292fd74f90507b55f836 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 17 Dec 2008 15:15:56 +0000 Subject: libcgroup Test: libcgroup-modify_cgroup-test1-for-multimnt This patch adds a testcase for libcgroup api cgroup_modify_cgroup() for multiple mount scenario for first controller. The challenge is to handle the control value as diff controllers put diff upper limit on control value and we pick the controller dynamicaly. We are going to use a config file for that which will have the controller name, control file name and the control value. But not sure if there is any better approach. So thoughts ??? Signed-off-by: Sudhir Kumar git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@262 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest01.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index a6f2339..4104157 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -23,6 +23,7 @@ int main(int argc, char *argv[]) /* In case of multimount for readability we use the controller name * before the cgroup structure name */ struct cgroup *ctl1_cgroup1, *ctl2_cgroup1, *ctl2_cgroup2; + struct cgroup *mod_ctl1_cgroup1, *mod_ctl2_cgroup1, *mod_common_cgroup; struct cgroup *common_cgroup; char controller_name[FILENAME_MAX], control_file[FILENAME_MAX]; char path_group[FILENAME_MAX], path_control_file[FILENAME_MAX]; @@ -714,8 +715,41 @@ int main(int argc, char *argv[]) strncpy(extra, "\n", SIZE); + + /* + * Create another valid cgroup structure with same group name + * to modify the existing group ctl1_group1 + * Exp outcome: no error. 0 return value + */ + strncpy(group, "ctl1_group1", sizeof(group)); + retval = set_controller(ctl1, controller_name, control_file); + strncpy(val_string, "7000000", sizeof(val_string)); + + if (retval) { + fprintf(stderr, "Setting controller failled " + " Exiting without running further testcases\n"); + exit(1); + } + + mod_ctl1_cgroup1 = new_cgroup(group, controller_name, + control_file, STRING); + + /* + * Test09: modify existing cgroup with this new cgroup + * Exp outcome: zero return value and control value modified + */ + build_path(path_control_file, mountpoint, + "ctl1_group1", control_file); + + retval = cgroup_modify_cgroup(mod_ctl1_cgroup1); + /* Check if the values are changed */ + if (!retval && !group_modified(path_control_file, STRING)) + message(++i, PASS, "modify_cgroup()", retval, extra); + else + message(++i, FAIL, "modify_cgroup()", retval, extra); + /* - * Test09: delete cgroups + * Test10: delete cgroups * Exp outcome: zero return value */ retval = cgroup_delete_cgroup(ctl1_cgroup1, 1); -- cgit