diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2008-12-22 19:06:14 +0000 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2008-12-22 19:06:14 +0000 |
commit | e397822e299a297d22f49216f2bcbdf41db6781f (patch) | |
tree | 395421156cd9f8bacbd47c7cfe40622a137afe9f /tests | |
parent | 298234f29860180126ea8be222519714b5a25dcb (diff) | |
download | libcg-e397822e299a297d22f49216f2bcbdf41db6781f.tar.gz libcg-e397822e299a297d22f49216f2bcbdf41db6781f.tar.xz libcg-e397822e299a297d22f49216f2bcbdf41db6781f.zip |
libcgroup: test for cgroup_add/free_controller
From: Sudhir Kumar <skumar@linux.vnet.ibm.com>
This patch adds testcases for cgroup_add_controller() wrapper api.
Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@292 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libcgrouptest.h | 1 | ||||
-rw-r--r-- | tests/libcgrouptest01.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/libcgrouptest.h b/tests/libcgrouptest.h index acc530a..f9d51cc 100644 --- a/tests/libcgrouptest.h +++ b/tests/libcgrouptest.h @@ -117,6 +117,7 @@ void test_cgroup_get_cgroup(int ctl1, int ctl2, int i); /* API test functions end here */ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i); +void test_cgroup_add_free_controller(int i); void get_controllers(const char *name, int *exist); static int group_exist(char *path_group); static int set_controller(int controller, char *controller_name, 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); + +} |