Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Add per worker cgroup suffix

This patch make each worker use a unique cgroup base directory, thus
allowing tests that uses cgroups to run concurrently.

Signed-off-by: Yucong Sun <sunyucong@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211006185619.364369-5-fallentree@fb.com

authored by

Yucong Sun and committed by
Andrii Nakryiko
e87c3434 6587ff58

+3 -3
+3 -3
tools/testing/selftests/bpf/cgroup_helpers.c
··· 11 11 #include <fcntl.h> 12 12 #include <unistd.h> 13 13 #include <ftw.h> 14 + #include <unistd.h> 14 15 15 16 #include "cgroup_helpers.h" 16 17 ··· 34 33 #define CGROUP_MOUNT_DFLT "/sys/fs/cgroup" 35 34 #define NETCLS_MOUNT_PATH CGROUP_MOUNT_DFLT "/net_cls" 36 35 #define CGROUP_WORK_DIR "/cgroup-test-work-dir" 37 - 38 36 #define format_cgroup_path(buf, path) \ 39 - snprintf(buf, sizeof(buf), "%s%s%s", CGROUP_MOUNT_PATH, \ 40 - CGROUP_WORK_DIR, path) 37 + snprintf(buf, sizeof(buf), "%s%s%d%s", CGROUP_MOUNT_PATH, \ 38 + CGROUP_WORK_DIR, getpid(), path) 41 39 42 40 #define format_classid_path(buf) \ 43 41 snprintf(buf, sizeof(buf), "%s%s", NETCLS_MOUNT_PATH, \
tools/testing/selftests/bpf/cgroup_helpers.h