selftests: new test for cgroup namespaces
From: Alban Crequy <alban@kinvolk.io>
This adds the selftest "cgroupns_test" in order to test the CGroup
Namespace patchset.
cgroupns_test creates two child processes. They perform a list of
actions defined by the array cgroupns_test. This array can easily be
extended to more scenarios without adding much code. They are
synchronized with eventfds to ensure only one action is performed at a
time.
The memory is shared between the processes (CLONE_VM) so each child
process can know the pid of their siblings without extra IPC.
The output explains the scenario being played. Example:
> current cgroup: /user.slice/user-0.slice/session-1.scope
> child process #0: check that process #self (pid=482) has cgroup /user.slice/user-0.slice/session-1.scope
> child process #0: unshare cgroupns
> child process #0: move process #self (pid=482) to cgroup cgroup-a/subcgroup-a
> child process #0: join parent cgroupns
The test does not change the mount namespace and does not mount any
new cgroup2 filesystem. Therefore this does not test that the cgroup2
mount is correctly rooted to the cgroupns root at mount time.
Signed-off-by: Alban Crequy <alban@kinvolk.io>
3 files changed