summaryrefslogtreecommitdiffstats
path: root/tests/pathtest.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pathtest.c')
-rw-r--r--tests/pathtest.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/pathtest.c b/tests/pathtest.c
new file mode 100644
index 0000000..076c38a
--- /dev/null
+++ b/tests/pathtest.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <libcgroup.h>
+
+int main(int argc, char *argv[])
+{
+ char *path;
+ char *expected_path, *controller;
+ int ret;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage %s: <controller name> <path>\n",
+ argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ controller = argv[1];
+ expected_path = argv[2];
+
+ cgroup_init();
+
+ ret = cgroup_get_current_controller_path(getpid(), controller, &path);
+ if (ret)
+ printf("Test FAIL, get path failed for controller %s\n",
+ controller);
+ else {
+ if (strcmp(path, expected_path))
+ printf("Test FAIL, expected_path %s, got path %s\n",
+ expected_path, path);
+ else
+ printf("Test PASS, controller %s path %s\n",
+ controller, path);
+ free(path);
+ }
+
+ return EXIT_SUCCESS;
+}