]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup Test: libcgrouptest-multimnt04
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:00:37 +0000 (15:00 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:00:37 +0000 (15:00 +0000)
This patch adds a testcase for libcgroup API cgroup_delete_cgroup() testing.
The API is called under the multimount condition(FS_MOUNTED=2) and return
values are checked. The group is checked if it is deleted from the root directory
of the corresponding controller's mountpoint.

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

tests/libcgrouptest01.c

index 71dcec4f03de0fb7383905727956266d211b56f2..0140ad11c419d5f87fbd3b3d8e847eb6c2ee1fd4 100644 (file)
@@ -387,6 +387,8 @@ int main(int argc, char *argv[])
 
                cgroup_free(&nullcgroup);
                cgroup_free(&cgroup1);
+               cgroup_free(&cgroup2);
+               cgroup_free(&cgroup3);
 
                break;
 
@@ -576,6 +578,48 @@ int main(int argc, char *argv[])
                                                 ++i, retval);
                }
 
+               /*
+                * Test09: delete cgroups
+                * Exp outcome: zero return value
+                */
+               retval = cgroup_delete_cgroup(cpu_cgroup1, 1);
+               if (!retval) {
+                       /* Check if the group is deleted from the dir tree */
+                       strncpy(path_group, mountpoint, sizeof(path_group));
+                       strncat(path_group, "/cpugroup1", sizeof(path_group));
+                       if (group_exist(path_group) == -1)
+                               printf("Test[1:%2d]\tPASS: cgroup_delete_cgroup() retval=%d\n",
+                                                                                ++i, retval);
+                       else
+                               printf("Test[1:%2d]\tFAIL: group still found in fs\n", ++i);
+               } else {
+                       printf("Test[1:%2d]\tFAIL: cgroup_delete_cgroup() retval=%d\n", ++i, retval);
+               }
+
+               /*
+                * Test09: delete other cgroups too
+                * Exp outcome: zero return value
+                */
+               retval = cgroup_delete_cgroup(mem_cgroup1, 1);
+               if (!retval) {
+                       /* Check if the group is deleted from the dir tree */
+                       strncpy(path_group, mountpoint, sizeof(path_group));
+                       strncat(path_group, "/memgroup1", sizeof(path_group));
+                       if (group_exist(path_group) == -1)
+                               printf("Test[1:%2d]\tPASS: cgroup_delete_cgroup() retval=%d\n",
+                                                                                ++i, retval);
+                       else
+                               printf("Test[1:%2d]\tFAIL: group still found in fs\n", ++i);
+               } else {
+                       printf("Test[1:%2d]\tFAIL: cgroup_delete_cgroup() retval=%d\n", ++i, retval);
+               }
+
+               /* Free the cgroup structures */
+               cgroup_free(&nullcgroup);
+               cgroup_free(&cpu_cgroup1);
+               cgroup_free(&mem_cgroup1);
+               cgroup_free(&mem_cgroup2);
+
                break;
 
        default: