]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup Test: libcgroup-attach_task-singlemount-testcase
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:11:00 +0000 (15:11 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:11:00 +0000 (15:11 +0000)
Hi,
This patch adds a testcase for cgroup_attach_task() api for single mount.

Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@255 4f4bb910-9a46-0410-90c8-c897d4f1cd53

tests/libcgrouptest01.c

index 2aa881e192450b58cf650dab81222503f4b795a9..67c5232e1be9d82acdd843b2c308c6c90bc471c6 100644 (file)
@@ -286,7 +286,34 @@ int main(int argc, char *argv[])
                strncpy(extra, "\n", SIZE);
 
                /*
-                * Test07: modify cgroup with the same cgroup
+                * Test07: Call cgroup_attach_task() with valid cgroup and check
+                * if return values are correct. If yes check if task exists in
+                * that group's tasks file
+                * Exp outcome: current task should be attached to that group
+                */
+               retval = cgroup_attach_task(cgroup1);
+               if (retval == 0) {
+                       strncpy(tasksfile, mountpoint, sizeof(mountpoint));
+                       strncat(tasksfile, "/group1", sizeof("/group1"));
+                       strncat(tasksfile, "/tasks", sizeof("/tasks"));
+                       if (check_task(tasksfile)) {
+                               strncpy(extra, " Task found in grp\n", SIZE);
+                               message(++i, PASS, "attach_task()", retval,
+                                                                        extra);
+                       } else {
+                               strncpy(extra, " Task not found in grp\n",
+                                                                        SIZE);
+                               message(++i, FAIL, "attach_task()", retval,
+                                                                        extra);
+                       }
+               } else {
+                       message(++i, FAIL, "attach_task()", retval, extra);
+               }
+
+               strncpy(extra, "\n", SIZE);
+
+               /*
+                * Test08: modify cgroup with the same cgroup
                 * Exp outcome: zero return value. No change.
                 */
                strncpy(extra, " Called with same cgroup argument\n", SIZE);
@@ -320,7 +347,7 @@ int main(int argc, char *argv[])
                                                 control_file, STRING);
 
                /*
-                * Test08: modify cgroup with this new cgroup
+                * Test10: modify cgroup with this new cgroup
                 * Exp outcome: zero return value
                 */
                strncpy(path_control_file, mountpoint, sizeof(mountpoint));
@@ -336,7 +363,7 @@ int main(int argc, char *argv[])
                        message(++i, FAIL, "modify_cgroup()", retval, extra);
 
                /*
-                * Test09: modify cgroup with the null cgroup
+                * Test11: modify cgroup with the null cgroup
                 * Exp outcome: zero return value.
                 */
 
@@ -366,7 +393,7 @@ int main(int argc, char *argv[])
                                                 control_file, INT64);
 
                /*
-                * Test10: modify existing group with this cgroup
+                * Test13: modify existing group with this cgroup
                 * Exp outcome: zero return value
                 */
                strncpy(extra, " Called with a cgroup argument with "
@@ -389,7 +416,7 @@ int main(int argc, char *argv[])
                strncpy(extra, "\n", SIZE);
 
                /*
-                * Test11: delete cgroup
+                * Test14: delete cgroup
                 * Exp outcome: zero return value
                 */
                retval = cgroup_delete_cgroup(cgroup1, 1);
@@ -416,7 +443,7 @@ int main(int argc, char *argv[])
                strncpy(extra, "\n", SIZE);
 
                /*
-                * Test12: Check if cgroup_create_cgroup() handles a NULL cgroup
+                * Test15: Check if cgroup_create_cgroup() handles a NULL cgroup
                 * Exp outcome: error ECGINVAL
                 */
                strncpy(extra, " Called with NULL cgroup argument\n", SIZE);
@@ -429,7 +456,7 @@ int main(int argc, char *argv[])
                strncpy(extra, "\n", SIZE);
 
                /*
-                * Test13: delete nullcgroup
+                * Test16: delete nullcgroup
                 */
                strncpy(extra, " Called with NULL cgroup argument\n", SIZE);
                retval = cgroup_delete_cgroup(nullcgroup, 1);