On Fri, Jan 02, 2009 at 05:02:03PM +0530, Sudhir Kumar wrote:
> The function test_attach_task_pid() was attaching the process calling the
> function to a group and did not have support to take any pid for attaching
> it to a group. This patch does that.
>
> Signed-off-by: Sudhir Kumar <[email protected]>
>
> ---
> tests/functions.c | 14 +++++++++++---
> tests/libcgrouptest.h | 2 +-
> tests/libcgrouptest01.c | 19 ++++++++++---------
> 3 files changed, 22 insertions(+), 13 deletions(-)
>
> Index: trunk/tests/functions.c
> ===================================================================
> --- trunk.orig/tests/functions.c
> +++ trunk/tests/functions.c
> @@ -54,13 +54,17 @@ void test_cgroup_init(int retcode, int i
>
> void test_cgroup_attach_task(int retcode, struct cgroup *cgrp,
> const char *group1, const char *group2,
> - int k, int i)
> + pid_t pid, int k, int i)
Sorry for being pedantic, but this really looks ugly. Can you indent it
better so that it comes easier on the eye? (This holds good in the
previous patches as well and in future patches)
> {
> int retval;
> char tasksfile[FILENAME_MAX], tasksfile2[FILENAME_MAX];
> /* Check, In case some error is expected due to a negative scenario */
> if (retcode) {
> - retval = cgroup_attach_task(cgrp);
> + if (pid)
> + retval = cgroup_attach_task_pid(cgrp, pid);
> + else
> + retval = cgroup_attach_task(cgrp);
> +
> if (retval == retcode)
> message(i, PASS, "attach_task()", retval, info[k]);
> else
> @@ -70,7 +74,11 @@ void test_cgroup_attach_task(int retcode
> }
>
> /* Now there is no error and it is a genuine call */
> - retval = cgroup_attach_task(cgrp);
> + if (pid)
> + retval = cgroup_attach_task_pid(cgrp, pid);
> + else
> + retval = cgroup_attach_task(cgrp);
> +
> if (retval == 0) { /* API returned success, so perform check */
> build_path(tasksfile, mountpoint,
> group1, "tasks");
> Index: trunk/tests/libcgrouptest.h
> ===================================================================
> --- trunk.orig/tests/libcgrouptest.h
> +++ trunk/tests/libcgrouptest.h
> @@ -111,7 +111,7 @@ extern char extra[SIZE];
> void test_cgroup_init(int retcode, int i);
> void test_cgroup_attach_task(int retcode, struct cgroup *cgroup1,
> const char *group1, const char *group2,
> - int k, int i);
> + pid_t pid, int k, int i);
> struct cgroup *create_new_cgroup_ds(int ctl, const char *grpname,
> int value_type, struct cntl_val_t cval, struct uid_gid_t ids, int i);
> void test_cgroup_create_cgroup(int retcode, struct cgroup *cgrp,
> Index: trunk/tests/libcgrouptest01.c
> ===================================================================
> --- trunk.orig/tests/libcgrouptest01.c
> +++ trunk/tests/libcgrouptest01.c
> @@ -97,7 +97,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(ECGROUPNOTINITIALIZED, nullcgroup,
> - NULL, NULL, NULLGRP, 2);
> + NULL, NULL, 0, NULLGRP, 2);
>
> /*
> * Test03: Create a valid cgroup ds and check all return values
> @@ -157,7 +157,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(ECGROUPNOTINITIALIZED, nullcgroup,
> - NULL, NULL, NULLGRP, 1);
> + NULL, NULL, 0, NULLGRP, 1);
>
> /*
> * Test02: call cgroup_init() and check return values
> @@ -175,7 +175,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(0, nullcgroup,
> - NULL, NULL, NULLGRP, 3);
> + NULL, NULL, 0, NULLGRP, 3);
> /*
> * Test04: Call cgroup_attach_task_pid() with null group
> * and invalid pid
> @@ -219,7 +219,7 @@ int main(int argc, char *argv[])
> * Exp outcome: current task should be attached to that group
> */
>
> - test_cgroup_attach_task(0, cgroup1, "group1", NULL,
> + test_cgroup_attach_task(0, cgroup1, "group1", NULL, 0,
> NOMESSAGE, 7);
>
> /*
> @@ -366,7 +366,8 @@ int main(int argc, char *argv[])
> * Exp outcome: current task should be attached to root groups
> */
>
> - test_cgroup_attach_task(0, nullcgroup, NULL, NULL, NULLGRP, 2);
> + test_cgroup_attach_task(0, nullcgroup, NULL, NULL,
> + 0, NULLGRP, 2);
>
> /*
> * Test03: Create a valid cgroup structure
> @@ -424,7 +425,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(0, ctl1_cgroup1, "ctl1_group1",
> - NULL, NOMESSAGE, 8);
> + NULL, 0, NOMESSAGE, 8);
>
> /*
> * Test07: Call cgroup_attach_task() with a group with ctl2
> @@ -434,7 +435,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(0, ctl2_cgroup1, "ctl1_group1",
> - "ctl2_group1", NOMESSAGE, 9);
> + "ctl2_group1", 0, NOMESSAGE, 9);
>
> /*
> * Test: Create a valid cgroup structure
> @@ -455,7 +456,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(ECGROUPNOTEXIST, ctl2_cgroup2,
> - NULL, NULL, NOTCRTDGRP, 11);
> + NULL, NULL, 0, NOTCRTDGRP, 11);
>
> /*
> * Create another valid cgroup structure with same group name
> @@ -556,7 +557,7 @@ int main(int argc, char *argv[])
> */
>
> test_cgroup_attach_task(0, common_cgroup, "commongroup",
> - "commongroup", COMMONGRP, 20);
> + "commongroup", 0, COMMONGRP, 20);
>
> /*
> * Test18: Create a valid cgroup structure to modify the
>
--
regards,
Dhaval
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel