From e397822e299a297d22f49216f2bcbdf41db6781f Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Mon, 22 Dec 2008 19:06:14 +0000 Subject: libcgroup: test for cgroup_add/free_controller From: Sudhir Kumar This patch adds testcases for cgroup_add_controller() wrapper api. Signed-off-by: Sudhir Kumar Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@292 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest01.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/libcgrouptest01.c') diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index ece14bf..3fb9ecf 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -133,6 +133,8 @@ int main(int argc, char *argv[]) */ test_cgroup_delete_cgroup(ECGROUPNOTINITIALIZED, nullcgroup, "group1", 0, 1, 1, 7); + /* Test08: test the wrapper */ + test_cgroup_add_free_controller(8); cgroup_free(&nullcgroup); cgroup_free(&cgroup1); @@ -1491,3 +1493,33 @@ void test_cgroup_get_cgroup(int ctl1, int ctl2, int i) cgroup_free(&cgroup_b); cgroup_free(&cgroup_filled); } + +void test_cgroup_add_free_controller(int i) +{ + struct cgroup *cgroup1 = NULL, *cgroup2 = NULL; + struct cgroup_controller *cgctl1, *cgctl2; + + /* Test with a Null cgroup */ + cgctl1 = cgroup_add_controller(cgroup1, "cpu"); + if (!cgctl1) + message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]); + else + message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]); + + cgroup1 = cgroup_new_cgroup("testgroup"); + cgctl1 = cgroup_add_controller(cgroup1, "cpuset"); + if (cgctl1) + message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]); + else + message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]); + + cgctl2 = cgroup_add_controller(cgroup1, "cpu"); + if (cgctl2) + message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]); + else + message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]); + + cgroup_free(&cgroup1); + cgroup_free_controllers(cgroup2); + +} -- cgit