]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup Test: libcgroup-split-new-cgroup-function
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:21:32 +0000 (15:21 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:21:32 +0000 (15:21 +0000)
This patch splits the earlier created function new_cgroup() into two
to make it more useful for other testcases.

Signed-off-by:  Sudhir Kumar  <skumar@linux.vnet.ibm.com>

git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@274 4f4bb910-9a46-0410-90c8-c897d4f1cd53

tests/libcgrouptest.h
tests/libcgrouptest01.c

index c04eaa665344bff26e3969bfaa95c84b2cfd4491..983d9be901a2c0b167d5308ae2ee566822ce4eb7 100644 (file)
@@ -87,6 +87,8 @@ static int group_exist(char *path_group);
 static int set_controller(int controller, char *controller_name,
                                                 char *control_file);
 static int group_modified(char *path_control_file, int value_type);
+static int add_control_value(struct cgroup_controller *newcontroller,
+                                char * control_file, char *wr, int value_type);
 struct cgroup *new_cgroup(char *group, char *controller_name,
                                 char *control_file, int value_type);
 int check_fsmounted(int multimnt);
index 333957b8a5b9adc5d1744561c3a8494fe8faa972..5bd9dd5db0ceb66b3e5d82ba3ddb5ebf5de22e79 100644 (file)
@@ -1109,12 +1109,46 @@ static int group_modified(char *path_control_file, int value_type)
        }
        return 1;
 }
+static int add_control_value(struct cgroup_controller *newcontroller,
+                                char * control_file, char *wr, int value_type)
+{
+       int retval;
+
+       switch (value_type) {
+
+       case BOOL:
+               retval = cgroup_add_value_bool(newcontroller,
+                                        control_file, val_bool);
+               snprintf(wr, SIZE, "add_value_bool()");
+               break;
+       case INT64:
+               retval = cgroup_add_value_int64(newcontroller,
+                                        control_file, val_int64);
+               snprintf(wr, SIZE, "add_value_int64()");
+               break;
+       case UINT64:
+               retval = cgroup_add_value_uint64(newcontroller,
+                                        control_file, val_uint64);
+               snprintf(wr, SIZE, "add_value_uint64()");
+               break;
+       case STRING:
+               retval = cgroup_add_value_string(newcontroller,
+                                        control_file, val_string);
+               snprintf(wr, SIZE, "add_value_string()");
+               break;
+       default:
+               printf("ERROR: wrong value in add_control_value()\n");
+               return 1;
+               break;
+       }
+       return retval;
+}
 
 struct cgroup *new_cgroup(char *group, char *controller_name,
                                 char *control_file, int value_type)
 {
        int retval;
-       char wr[SIZE]; /* Na,es of wrapper apis */
+       char wr[SIZE]; /* Names of wrapper apis */
        struct cgroup *newcgroup;
        struct cgroup_controller *newcontroller;
        newcgroup = cgroup_new_cgroup(group);
@@ -1130,33 +1164,8 @@ struct cgroup *new_cgroup(char *group, char *controller_name,
 
                newcontroller = cgroup_add_controller(newcgroup, controller_name);
                if (newcontroller) {
-                       switch (value_type) {
-
-                       case BOOL:
-                               retval = cgroup_add_value_bool(newcontroller,
-                                                control_file, val_bool);
-                               snprintf(wr, sizeof(wr), "add_value_bool()");
-                               break;
-                       case INT64:
-                               retval = cgroup_add_value_int64(newcontroller,
-                                                control_file, val_int64);
-                               snprintf(wr, sizeof(wr), "add_value_int64()");
-                               break;
-                       case UINT64:
-                               retval = cgroup_add_value_uint64(newcontroller,
-                                                control_file, val_uint64);
-                               snprintf(wr, sizeof(wr), "add_value_uint64()");
-                               break;
-                       case STRING:
-                               retval = cgroup_add_value_string(newcontroller,
-                                                control_file, val_string);
-                               snprintf(wr, sizeof(wr), "add_value_string()");
-                               break;
-                       default:
-                               printf("ERROR: wrong value in new_cgroup()\n");
-                               return NULL;
-                               break;
-                       }
+                       retval =  add_control_value(newcontroller,
+                                                control_file, wr, value_type);
 
                        if (!retval) {
                                message(++i, PASS, "new_cgroup()",