diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/get_controller.c | 34 |
2 files changed, 36 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 41aebd3..e8401f2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/include LDADD = $(top_srcdir)/src/.libs/libcgroup.la # compile the tests, but do not install them -noinst_PROGRAMS = libcgrouptest01 libcg_ba setuid pathtest walk_test read_stats walk_task +noinst_PROGRAMS = libcgrouptest01 libcg_ba setuid pathtest walk_test read_stats walk_task get_controller libcgrouptest01_SOURCES=libcgrouptest01.c test_functions.c libcgrouptest.h libcg_ba_SOURCES=libcg_ba.cpp @@ -11,6 +11,7 @@ pathtest_SOURCES=pathtest.c walk_test_SOURCES=walk_test.c read_stats_SOURCES=read_stats.c walk_task_SOURCES=walk_task.c +get_controller_SOURCES=get_controller.c EXTRA_DIST = pathtest.sh runlibcgrouptest.sh diff --git a/tests/get_controller.c b/tests/get_controller.c new file mode 100644 index 0000000..1829f5c --- /dev/null +++ b/tests/get_controller.c @@ -0,0 +1,34 @@ +#include <libcgroup.h> +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + int error; + void *handle; + struct cgroup_mount_point info; + + error = cgroup_init(); + + if (error) { + printf("cgroup_init failed with %s\n", cgroup_strerror(error)); + exit(1); + } + + error = cgroup_get_controller_begin(&handle, &info); + + while (error != ECGEOF) { + printf("Controller %s is mounted at %s\n", info.name, + info.path); + error = cgroup_get_controller_next(&handle, &info); + if (error && error != ECGEOF) { + printf("cgroup_get_contrller_next failed with %s", + cgroup_strerror(error)); + exit(1); + } + } + + error = cgroup_get_controller_end(&handle); + + return 0; +} |