From e0289d87dfdab4c66c2dda8fc956a0965d0d7880 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 17 Dec 2008 15:00:37 +0000 Subject: [PATCH] libcgroup Test: libcgrouptest-multimnt04 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 git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@244 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest01.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index 71dcec4f..0140ad11 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -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: -- 2.47.2