]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup Test: set-another-controller-if-first-fails
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:13:13 +0000 (15:13 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:13:13 +0000 (15:13 +0000)
This patch adds a warning in case setting a controller fails and
tries to set values for another controller.

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

tests/libcgrouptest01.c

index 8c5126aef51881878a6ae4c831b2497203aed9eb..14513eb62e9007923795638dc3f8c548367223bc 100644 (file)
@@ -334,8 +334,17 @@ int main(int argc, char *argv[])
                retval = set_controller(MEMORY, controller_name, control_file);
                strncpy(val_string, "81920000", sizeof(val_string));
 
-               if (retval)
-                       fprintf(stderr, "Setting controller failled\n");
+               if (retval) {
+                       fprintf(stderr, "Failed to set first controller. "
+                                       "Trying with second controller\n");
+                       retval = set_controller(CPU, controller_name,
+                                                               control_file);
+                       strncpy(val_string, "4096", sizeof(val_string));
+                       if (retval)
+                               fprintf(stderr, "Failed to set any controllers "
+                                       "Tests dependent on this structure will"
+                                       " fail\n");
+               }
 
                cgroup2 = new_cgroup(group, controller_name,
                                                 control_file, STRING);
@@ -379,7 +388,8 @@ int main(int argc, char *argv[])
                strncpy(group, "group1", sizeof(group));
                retval = set_controller(CPU, controller_name, control_file);
                if (retval)
-                       fprintf(stderr, "Setting controller failled\n");
+                       fprintf(stderr, "Setting controller failled. "
+                               "Tests dependent on this struct may fail\n");
 
                cgroup3 = new_cgroup(group, controller_name,
                                                 control_file, INT64);
@@ -392,7 +402,6 @@ int main(int argc, char *argv[])
                                                "different controller\n", SIZE);
                build_path(path_control_file, mountpoint,
                                                 "group1", control_file);
-               strncpy(val_string, "2048", sizeof(val_string));
 
                retval = cgroup_modify_cgroup(cgroup3);
                /* Check if the values are changed */