diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-06-18 19:42:46 +0530 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-06-18 19:49:39 +0530 |
commit | 7c8df4bd70091301e8473ef144153d1b2946edd3 (patch) | |
tree | 93fd0782419dd211471f9efb1a8879b7df6dc5d9 /tests/walk_test.c | |
parent | a32b08930f1828b39d6cafd2779bdab66aebc484 (diff) | |
download | libcg-7c8df4bd70091301e8473ef144153d1b2946edd3.tar.gz libcg-7c8df4bd70091301e8473ef144153d1b2946edd3.tar.xz libcg-7c8df4bd70091301e8473ef144153d1b2946edd3.zip |
libcgroup: Introduce post order walk
With the introduction of the flags, we now actually make use of them.
This patch adds a post mode and modifies the test case to also do a post
order walk.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Diffstat (limited to 'tests/walk_test.c')
-rw-r--r-- | tests/walk_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/walk_test.c b/tests/walk_test.c index 2e16ecd..e09f705 100644 --- a/tests/walk_test.c +++ b/tests/walk_test.c @@ -41,6 +41,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } strcpy(root, info.full_path); + printf("Begin pre-order walk\n"); printf("root is %s\n", root); visit_node(&info, root); while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) != @@ -49,6 +50,32 @@ int main(int argc, char *argv[]) } cgroup_walk_tree_end(&handle); + printf("pre-order walk finished\n"); + ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl); + + if (ret != 0) { + fprintf(stderr, "Walk failed\n"); + exit(EXIT_FAILURE); + } + + ret = cgroup_walk_tree_set_flags(&handle, CGROUP_WALK_TYPE_POST_DIR); + + if (ret) { + fprintf(stderr, "Walk failed with %s\n", cgroup_strerror(ret)); + exit(EXIT_FAILURE); + } + + strcpy(root, info.full_path); + printf("Begin post-order walk\n"); + printf("root is %s\n", root); + visit_node(&info, root); + while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) != + ECGEOF) { + visit_node(&info, root); + } + cgroup_walk_tree_end(&handle); + printf("post order walk finished\n"); + ret = cgroup_walk_tree_begin(controller, "/a", 2, &handle, &info, &lvl); if (ret != 0) { |