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
This commit is contained in:
Yucong Sun 2021-10-06 11:56:09 -07:00 committed by Andrii Nakryiko
parent 6587ff58ce
commit e87c3434f8
2 changed files with 4 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <ftw.h> #include <ftw.h>
#include <unistd.h>
#include "cgroup_helpers.h" #include "cgroup_helpers.h"
@ -33,10 +34,9 @@
#define CGROUP_MOUNT_DFLT "/sys/fs/cgroup" #define CGROUP_MOUNT_DFLT "/sys/fs/cgroup"
#define NETCLS_MOUNT_PATH CGROUP_MOUNT_DFLT "/net_cls" #define NETCLS_MOUNT_PATH CGROUP_MOUNT_DFLT "/net_cls"
#define CGROUP_WORK_DIR "/cgroup-test-work-dir" #define CGROUP_WORK_DIR "/cgroup-test-work-dir"
#define format_cgroup_path(buf, path) \ #define format_cgroup_path(buf, path) \
snprintf(buf, sizeof(buf), "%s%s%s", CGROUP_MOUNT_PATH, \ snprintf(buf, sizeof(buf), "%s%s%d%s", CGROUP_MOUNT_PATH, \
CGROUP_WORK_DIR, path) CGROUP_WORK_DIR, getpid(), path)
#define format_classid_path(buf) \ #define format_classid_path(buf) \
snprintf(buf, sizeof(buf), "%s%s", NETCLS_MOUNT_PATH, \ snprintf(buf, sizeof(buf), "%s%s", NETCLS_MOUNT_PATH, \