summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-12-17 15:01:48 +0000
committerBalbir Singh <balbir@linux.vnet.ibm.com>2008-12-17 15:01:48 +0000
commit764a147fae9ab82b15c2ed94b5b510c3879f2530 (patch)
tree75d47abf44554d9bf88149b2b19ada4834313e97 /tests
parente0289d87dfdab4c66c2dda8fc956a0965d0d7880 (diff)
downloadlibcg-764a147fae9ab82b15c2ed94b5b510c3879f2530.tar.gz
libcg-764a147fae9ab82b15c2ed94b5b510c3879f2530.tar.xz
libcg-764a147fae9ab82b15c2ed94b5b510c3879f2530.zip
libcgroup Test: libcgrouptest-multimnt05
Hi The following patch adds three testcases for libcg apis create and delete _cgroup() and wrapper apis for multiple mount case. The patch creates a valid cgroup structure with two controllers and after calling to apis performs a check under both controllers. Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@245 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'tests')
-rw-r--r--tests/libcgrouptest01.c76
1 files changed, 73 insertions, 3 deletions
diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c
index 0140ad1..2139ffa 100644
--- a/tests/libcgrouptest01.c
+++ b/tests/libcgrouptest01.c
@@ -22,9 +22,13 @@ int main(int argc, char *argv[])
struct cgroup *cgroup1, *cgroup2, *cgroup3, *nullcgroup = NULL;
/* In case of multimount for readability we use the controller name
* before the cgroup structure name */
- struct cgroup *cpu_cgroup1, *mem_cgroup1, *mem_cgroup2;
- char controller_name[FILENAME_MAX], control_file[FILENAME_MAX],
- path_group[FILENAME_MAX], path_control_file[FILENAME_MAX];
+ struct cgroup *cpu_cgroup1, *mem_cgroup1, *mem_cgroup2, *common_cgroup;
+ struct cgroup_controller *newcontroller;
+ char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
+ char path_group[FILENAME_MAX], path_control_file[FILENAME_MAX];
+
+ /* The path to the common group under different controllers */
+ char path1_common_group[FILENAME_MAX], path2_common_group[FILENAME_MAX];
char mountpoint[FILENAME_MAX], tasksfile[FILENAME_MAX], group[FILENAME_MAX];
/* Hardcode second mountpoint for now. Will update soon */
@@ -614,6 +618,72 @@ int main(int argc, char *argv[])
printf("Test[1:%2d]\tFAIL: cgroup_delete_cgroup() retval=%d\n", ++i, retval);
}
+ /*
+ * Test10: Create a valid cgroup structure which has multiple controllers
+ * Exp outcome: no error. 0 return value
+ */
+ strncpy(group, "commongroup", sizeof(group));
+ strncpy(val_string, "4096", sizeof(val_string));
+ retval = set_controller(CPU, controller_name, control_file);
+
+ if (retval)
+ fprintf(stderr, "Setting controller failled\n");
+
+ common_cgroup = new_cgroup(group, controller_name,
+ control_file, STRING);
+
+ /* Add one more controller to the cgroup */
+ strncpy(controller_name, "memory", sizeof(controller_name));
+ if (!cgroup_add_controller(common_cgroup, controller_name))
+ printf("Test[2:%2d]\tFAIL: cgroup_add_controller()\n", ++i);
+
+ /*
+ * Test11: Then Call cgroup_create_cgroup() with this valid group
+ * Exp outcome: zero return value
+ */
+ retval = cgroup_create_cgroup(common_cgroup, 1);
+ if (!retval) {
+ /* Check if the group exists under both controllers */
+ strncpy(path1_common_group, mountpoint, sizeof(path1_common_group));
+ strncat(path1_common_group, "/commongroup", sizeof(path1_common_group));
+ if (group_exist(path1_common_group) == 0) {
+
+ strncpy(path2_common_group, mountpoint, sizeof(path2_common_group));
+ strncat(path2_common_group, "/commongroup", sizeof(path2_common_group));
+
+ if (group_exist(path2_common_group) == 0)
+ printf("Test[2:%2d]\tPASS: group found under both controllers\n", ++i);
+ else
+ printf("Test[2:%2d]\tFAIL: group not found under 2nd controller\n", ++i);
+
+ } else {
+ printf("Test[2:%2d]\tFAIL: group not found in fs\n", ++i);
+ }
+ } else {
+ printf("Test[2:%2d]\tFAIL: cgroup_create_cgroup() retval=%d\n", ++i, retval);
+ }
+
+ /*
+ * Test12: delete this common cgroup
+ * Exp outcome: zero return value
+ */
+ retval = cgroup_delete_cgroup(common_cgroup, 1);
+ if (!retval) {
+ /* Check if the group is deleted from both dir tree */
+ if (group_exist(path1_common_group) == -1) {
+
+ if (group_exist(path2_common_group) == -1)
+ printf("Test[1:%2d]\tPASS: group deleted globally\n", ++i);
+ else
+ printf("Test[1:%2d]\tPASS: group not deleted globally\n", ++i);
+
+ } 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);