From 1a922fee66c8a691bfec738b6a5694b2dbb2177d Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Fri, 2 Dec 2016 02:42:18 -0800 Subject: 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 Acked-by: Alexei Starovoitov Signed-off-by: David S. Miller --- samples/bpf/cgroup_helpers.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 samples/bpf/cgroup_helpers.h (limited to 'samples/bpf/cgroup_helpers.h') 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 +#include + +#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 -- cgit 1.4.1