]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: libcgroup testcases for cgroup_get_cgroup
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Mon, 22 Dec 2008 18:50:46 +0000 (18:50 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Mon, 22 Dec 2008 18:50:46 +0000 (18:50 +0000)
From: Sudhir Kumar <skumar@linux.vnet.ibm.com>

This atch adds a new testcase for api cgroup_get_cgroup()
for single mount case.

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@282 4f4bb910-9a46-0410-90c8-c897d4f1cd53

tests/libcgrouptest.h
tests/libcgrouptest01.c

index de2f67be964e226d246ddf6f2f5d2fffe3bdda32..73b25e3350a83d233d1f412f4953d595e073a243 100644 (file)
@@ -84,6 +84,7 @@ void test_cgroup_attach_task(int retcode, struct cgroup *cgroup1,
 /* API test functions end here */
 
 void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i);
+void test_cgroup_get_cgroup(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,
index 5ec0b6881dd97dcb00b356a2ab6b8d2d91a5176d..2f71f2f159c9ed2c085d63a2206c191b1601ba9c 100644 (file)
@@ -381,8 +381,17 @@ int main(int argc, char *argv[])
 
                strncpy(extra, "\n", SIZE);
 
+               /* Test14: Test cgroup_get_cgroup() api
+                * The group group1 has been created and modified in the
+                * filesystem. Read it using the api and check if the values
+                * are correct as we know all the control values now.
+                * WARN: If any of the previous api fails and control reaches
+                * here, this api also will fail
+                */
+               test_cgroup_get_cgroup(14);
+
                /*
-                * Test14: delete cgroup
+                * Test15: delete cgroup
                 * Exp outcome: zero return value
                 */
                retval = cgroup_delete_cgroup(cgroup1, 1);
@@ -1366,6 +1375,7 @@ void set_info_msgs()
                case 15:
                        strncpy(info[k], " Group not deleted globaly\n", SIZE);
                        break;
+               /* In case there is no extra info messages to be printed */
                case 19:
                        strncpy(info[k], " \n", SIZE);
                        break;
@@ -1450,3 +1460,29 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i)
        cgroup_free(&cgroup1);
        cgroup_free(&cgroup2);
 }
+
+void test_cgroup_get_cgroup(int i)
+{
+       struct cgroup *cgroup_filled;
+       int ret;
+
+       /* Test with nullcgroup first */
+       ret = cgroup_get_cgroup(NULL);
+       if (ret == ECGROUPNOTALLOWED)
+               message(i++, PASS, "get_cgroup()", ret, info[0]);
+       else
+               message(i++, FAIL, "get_cgroup()", ret, info[0]);
+
+       /* Test with name filled cgroup */
+       cgroup_filled = cgroup_new_cgroup("group1");
+       if (!cgroup_filled)
+               message(i++, FAIL, "new_cgroup()", 0, info[19]);
+
+       ret = cgroup_get_cgroup(cgroup_filled);
+       if (!ret)
+               message(i++, PASS, "get_cgroup()", ret, info[19]);
+       else
+               message(i++, FAIL, "get_cgroup()", ret, info[19]);
+
+       cgroup_free(&cgroup_filled);
+}