diff options
author | Sargun Dhillon <sargun@sargun.me> | 2016-12-02 13:42:18 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-04 00:07:11 +0300 |
commit | 1a922fee66c8a691bfec738b6a5694b2dbb2177d (patch) | |
tree | a2196acc64ef60499075d0711c4a0eecb0abef09 /samples/bpf/cgroup_helpers.h | |
parent | 69a9d09b2251aeb968e76f39f2b89774312daa3d (diff) | |
download | linux-1a922fee66c8a691bfec738b6a5694b2dbb2177d.tar.xz |
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.h | 16 |
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 |