summaryrefslogtreecommitdiff
path: root/src/test/test-cgroup-mask.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-08-09 15:42:49 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-08-09 09:42:49 -0400
commit8c759b33a435c6a9390a18ebe9259402e2fc595e (patch)
tree49cc7cac1a6f0050c16b895806d8a390646b00cc /src/test/test-cgroup-mask.c
parente85a690b9606a98a8ba8c02fa50a38d26a313f4b (diff)
downloadsystemd-8c759b33a435c6a9390a18ebe9259402e2fc595e.tar.gz
systemd-8c759b33a435c6a9390a18ebe9259402e2fc595e.tar.bz2
systemd-8c759b33a435c6a9390a18ebe9259402e2fc595e.zip
tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576)
Without this "meson test" will end up running all tests in the same cgroup root, and they all will try to manage it. Which usually isn't too bad, except when they end up clearing up each other's cgroups. This race is hard to trigger but has caused various CI runs to fail spuriously. With this change we simply move every test that runs a manager object into their own private cgroup. Note that we don't clean up the cgroup at the end, we leave that to the cgroup manager around it. This fixes races that become visible by test runs throwing out errors like this: ``` exec-systemcallfilter-failing.service: Passing 0 fds to service exec-systemcallfilter-failing.service: About to execute: /bin/echo 'This should not be seen' exec-systemcallfilter-failing.service: Forked /bin/echo as 5693 exec-systemcallfilter-failing.service: Changed dead -> start exec-systemcallfilter-failing.service: Failed to attach to cgroup /exec-systemcallfilter-failing.service: No such file or directory Received SIGCHLD from PID 5693 ((echo)). Child 5693 ((echo)) died (code=exited, status=219/CGROUP) exec-systemcallfilter-failing.service: Child 5693 belongs to exec-systemcallfilter-failing.service exec-systemcallfilter-failing.service: Main process exited, code=exited, status=219/CGROUP exec-systemcallfilter-failing.service: Changed start -> failed exec-systemcallfilter-failing.service: Unit entered failed state. exec-systemcallfilter-failing.service: Failed with result 'exit-code'. exec-systemcallfilter-failing.service: cgroup is empty Assertion 'service->main_exec_status.status == status_expected' failed at ../src/src/test/test-execute.c:71, function check(). Aborting. ``` BTW, I tracked this race down by using perf: ``` # perf record -e cgroup:cgroup_mkdir,cgroup_rmdir … # perf script ``` Thanks a lot @iaguis, @alban for helping me how to use perf for this. Fixes #5895.
Diffstat (limited to 'src/test/test-cgroup-mask.c')
-rw-r--r--src/test/test-cgroup-mask.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
index b42088c680..4a13d710dc 100644
--- a/src/test/test-cgroup-mask.c
+++ b/src/test/test-cgroup-mask.c
@@ -34,6 +34,8 @@ static int test_cgroup_mask(void) {
FDSet *fdset = NULL;
int r;
+ enter_cgroup_subroot();
+
/* Prepare the manager. */
assert_se(set_unit_path(get_testdata_dir("")) >= 0);
assert_se(runtime_dir = setup_fake_runtime_dir());