From 3c0aafb5e5db7f91ce379e43841debcd325cc50e Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Tue, 1 Jul 2008 13:54:34 +0000 Subject: [PATCH] From: Sudhir Kumar libcgroup: further testcases for create_cgroup() and delete_cgroup() This patch adds testcases for libcgroup API cgroup_create_cgroup() and cgroup_delete_cgroup() testing. The APIs are called under the same but two conditions(FS_MOUNTED=0/1) and return values are checked. The test checks if these APIs can handle a null cgroup and hence passes a nulll cgroup as parameter. Signed-off-by: Sudhir Kumar Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@91 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest01.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index 0c4d20ba..cbe4634e 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -131,6 +131,25 @@ int main(int argc, char *argv[]) else printf("Test[0:%2d]\tFAIL: cgroup_delete_cgroup() retval=%d\n", ++i, retval); + /* + * Test06: Check if cgroup_create_cgroup() handles a NULL cgroup + * Exp outcome: error ECGINVAL + */ + retval = cgroup_create_cgroup(nullcgroup, 1); + if (retval) + printf("Test[0:%2d]\tPASS: cgroup_create_cgroup() nullcgroup handled\n", ++i); + else + printf("Test[0:%2d]\tFAIL: cgroup_create_cgroup() nullcgroup not handled\n", ++i); + + /* + * Test07: delete nullcgroup + */ + retval = cgroup_delete_cgroup(nullcgroup, 1); + if (retval) + printf("Test[0:%2d]\tPASS: cgroup_delete_cgroup() nullcgroup handled\n", ++i); + else + printf("Test[0:%2d]\tFAIL: cgroup_delete_cgroup() Unable to handle nullcgroup\n", ++i); + cgroup_free(&nullcgroup); cgroup_free(&cgroup1); @@ -271,6 +290,25 @@ int main(int argc, char *argv[]) } else printf("Test[1:%2d]\tFAIL: cgroup_delete_cgroup() retval=%d\n", ++i, retval); + /* + * Test08: Check if cgroup_create_cgroup() handles a NULL cgroup + * Exp outcome: error ECGINVAL + */ + retval = cgroup_create_cgroup(nullcgroup, 1); + if (retval) + printf("Test[1:%2d]\tPASS: cgroup_create_cgroup() nullcgroup handled\n", ++i); + else + printf("Test[1:%2d]\tFAIL: cgroup_create_cgroup() nullcgroup not handled\n", ++i); + + /* + * Test09: delete nullcgroup + */ + retval = cgroup_delete_cgroup(nullcgroup, 1); + if (retval) + printf("Test[1:%2d]\tPASS: cgroup_delete_cgroup() nullcgroup handled\n", ++i); + else + printf("Test[1:%2d]\tFAIL: cgroup_delete_cgroup() Unable to handle nullcgroup\n", ++i); + cgroup_free(&nullcgroup); cgroup_free(&cgroup1); -- 2.47.2