summaryrefslogtreecommitdiffstats
path: root/tests/libcgrouptest01.c
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-12-22 18:49:15 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2008-12-22 18:49:15 +0000
commit2517466058ffb183ed83cd1b05f6f51b7a511a56 (patch)
tree0d49c351f0c10dda989e3e748980f443d6103bcd /tests/libcgrouptest01.c
parent7f0f54d78fe04ee16a82a1cc40687395ce684dd7 (diff)
downloadlibcg-2517466058ffb183ed83cd1b05f6f51b7a511a56.tar.gz
libcg-2517466058ffb183ed83cd1b05f6f51b7a511a56.tar.xz
libcg-2517466058ffb183ed83cd1b05f6f51b7a511a56.zip
libcgroup: libcgroup testcases for compare_cgroup
From: Sudhir Kumar <skumar@linux.vnet.ibm.com> This patch adds a testcase for cgroup_compare_cgroup() wrapper. 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@281 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'tests/libcgrouptest01.c')
-rw-r--r--tests/libcgrouptest01.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c
index 16c00ac..5ec0b68 100644
--- a/tests/libcgrouptest01.c
+++ b/tests/libcgrouptest01.c
@@ -431,6 +431,11 @@ int main(int argc, char *argv[])
strncpy(extra, "\n", SIZE);
+ /* Test17: Test the wrapper to compare cgroup
+ * Create 2 cgroups and test it
+ */
+ test_cgroup_compare_cgroup(ctl1, ctl2, 19);
+
cgroup_free(&nullcgroup);
cgroup_free(&cgroup1);
cgroup_free(&cgroup2);
@@ -1382,3 +1387,66 @@ void free_info_msgs()
if (info)
free(info);
}
+
+void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i)
+{
+ int retval;
+ struct cgroup *cgroup1, *cgroup2;
+ struct cgroup_controller *controller;
+ char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
+ char wr[SIZE], extra[] = "in cgroup_compare_cgroup";
+
+ retval = cgroup_compare_cgroup(NULL, NULL);
+ if (retval)
+ message(i++, PASS, "compare_cgroup()", retval, info[0]);
+ else
+ message(i++, FAIL, "compare_cgroup()", retval, info[0]);
+
+ cgroup1 = cgroup_new_cgroup("testgroup");
+ cgroup2 = cgroup_new_cgroup("testgroup");
+ cgroup_set_uid_gid(cgroup1, 0, 0, 0, 0);
+ cgroup_set_uid_gid(cgroup2, 0, 0, 0, 0);
+
+ retval = set_controller(ctl1, controller_name, control_file);
+
+ controller = cgroup_add_controller(cgroup1, controller_name);
+ if (controller) {
+ retval = add_control_value(controller,
+ control_file, wr, STRING);
+ if (retval)
+ message(i++, FAIL, wr, retval, extra);
+ }
+
+ controller = cgroup_add_controller(cgroup2, controller_name);
+ if (controller) {
+ retval = add_control_value(controller,
+ control_file, wr, STRING);
+ if (retval)
+ message(i++, FAIL, wr, retval, extra);
+ }
+
+ retval = cgroup_compare_cgroup(cgroup1, cgroup2);
+ if (retval)
+ message(i++, FAIL, "compare_cgroup()", retval, info[19]);
+ else
+ message(i++, PASS, "compare_cgroup()", retval, info[19]);
+
+ /* Test the api by putting diff number of controllers in cgroups */
+ retval = set_controller(ctl2, controller_name, control_file);
+ controller = cgroup_add_controller(cgroup2, controller_name);
+ if (controller) {
+ retval = add_control_value(controller,
+ control_file, wr, STRING);
+ if (retval)
+ message(i++, FAIL, wr, retval, extra);
+ }
+
+ retval = cgroup_compare_cgroup(cgroup1, cgroup2);
+ if (retval == ECGROUPNOTEQUAL)
+ message(i++, PASS, "compare_cgroup()", retval, info[19]);
+ else
+ message(i++, FAIL, "compare_cgroup()", retval, info[19]);
+
+ cgroup_free(&cgroup1);
+ cgroup_free(&cgroup2);
+}