summaryrefslogtreecommitdiffstats
path: root/samples/bpf/cgroup_helpers.h
diff options
context:
space:
mode:
authorSargun Dhillon2016-12-02 11:42:18 +0100
committerDavid S. Miller2016-12-03 22:07:11 +0100
commit1a922fee66c8a691bfec738b6a5694b2dbb2177d (patch)
treea2196acc64ef60499075d0711c4a0eecb0abef09 /samples/bpf/cgroup_helpers.h
parentsamples/bpf: silence compiler warnings (diff)
downloadkernel-qcow2-linux-1a922fee66c8a691bfec738b6a5694b2dbb2177d.tar.gz
kernel-qcow2-linux-1a922fee66c8a691bfec738b6a5694b2dbb2177d.tar.xz
kernel-qcow2-linux-1a922fee66c8a691bfec738b6a5694b2dbb2177d.zip
samples, bpf: Refactor test_current_task_under_cgroup - separate out helpers
This patch modifies test_current_task_under_cgroup_user. The test has several helpers around creating a temporary environment for cgroup testing, and moving the current task around cgroups. This set of helpers can then be used in other tests. Signed-off-by: Sargun Dhillon <sargun@sargun.me> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/cgroup_helpers.h')
-rw-r--r--samples/bpf/cgroup_helpers.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/samples/bpf/cgroup_helpers.h b/samples/bpf/cgroup_helpers.h
new file mode 100644
index 000000000000..78c55207b6bd
--- /dev/null
+++ b/samples/bpf/cgroup_helpers.h
@@ -0,0 +1,16 @@
+#ifndef __CGROUP_HELPERS_H
+#define __CGROUP_HELPERS_H
+#include <errno.h>
+#include <string.h>
+
+#define clean_errno() (errno == 0 ? "None" : strerror(errno))
+#define log_err(MSG, ...) fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \
+ __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
+
+
+int create_and_get_cgroup(char *path);
+int join_cgroup(char *path);
+int setup_cgroup_environment(void);
+void cleanup_cgroup_environment(void);
+
+#endif