summaryrefslogtreecommitdiffstats
path: root/tests/libcgrouptest01.c
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-12-17 15:21:32 +0000
committerBalbir Singh <balbir@linux.vnet.ibm.com>2008-12-17 15:21:32 +0000
commit5d16282a5f418bb7030ba33363bf570bec056a0b (patch)
tree02e9ff692544e629352e7fc7486008561685e09f /tests/libcgrouptest01.c
parent605aab868944e847b679093a7fbd542053b76d31 (diff)
downloadlibcg-5d16282a5f418bb7030ba33363bf570bec056a0b.tar.gz
libcg-5d16282a5f418bb7030ba33363bf570bec056a0b.tar.xz
libcg-5d16282a5f418bb7030ba33363bf570bec056a0b.zip
libcgroup Test: libcgroup-split-new-cgroup-function
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
Diffstat (limited to 'tests/libcgrouptest01.c')
-rw-r--r--tests/libcgrouptest01.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c
index 333957b..5bd9dd5 100644
--- a/tests/libcgrouptest01.c
+++ b/tests/libcgrouptest01.c
@@ -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()",