Systemd/src/test
Lennart Poettering 8c759b33a4 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.
2017-08-09 09:42:49 -04:00
..
generate-sym-test.py Mark python scripts executable 2017-05-07 20:16:47 -04:00
meson.build tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-acl-util.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-af-list.c test-af-list: drop unnecessary backslash 2017-05-07 20:01:04 -04:00
test-alloc-util.c tests: move alloc related tests to test-alloc-util.c 2016-03-03 18:46:58 +01:00
test-architecture.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-arphrd-list.c Silence two "unused function af_lookup" warnings (#5222) 2017-02-04 10:25:20 -05:00
test-ask-password-api.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-async.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-barrier.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-bitmap.c
test-boot-timestamps.c shared/acpi-fpdt: use ENODATA for missing data and skip test 2016-03-04 21:45:45 -05:00
test-btrfs.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-calendarspec.c calendarspec: parse unix timestamps (@...) (#5947) 2017-05-17 11:40:49 +02:00
test-cap-list.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-capability.c tests: test ambient capabilities. 2016-01-12 12:14:50 +02:00
test-cgroup-mask.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-cgroup-util.c test-cgroup-util: add a "test" to print out cg_is_*_wanted() values 2017-02-22 19:58:06 -05:00
test-cgroup.c tree-wide: make use of getpid_cached() wherever we can 2017-07-20 20:27:24 +02:00
test-clock.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-condition.c test-condition: fix test_condition_test_group() (#6531) 2017-08-05 19:25:19 -04:00
test-conf-files.c basic/conf-files: extend conf_files_list() to list unsuffixed files 2017-02-11 18:21:06 -05:00
test-conf-parser.c test-conf-parser: add valid and invalid utf8 test for config_parse_path 2017-05-14 13:19:11 +02:00
test-copy.c machined: when copying files from/to userns containers chown to root 2017-02-17 10:22:28 +01:00
test-cpu-set-util.c tests: move cpu-set-util related tests to test-cpu-set-util.c 2016-03-03 18:46:58 +01:00
test-daemon.c test-daemon: sleep just a little bit by default 2017-07-13 17:55:02 -04:00
test-date.c time-util: make parse_timestamp() return -EINVAL if the input is very old date (#6327) 2017-07-11 19:12:48 +02:00
test-device-nodes.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-dissect-image.c dissect: make using a generic partition as root partition optional 2016-12-21 19:09:30 +01:00
test-dlopen.c meson: add test-dlopen 2017-04-23 21:47:28 -04:00
test-dns-domain.c resolved: make sure idn2 conversions are roundtrippable 2017-07-21 08:00:23 -04:00
test-ellipsize.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-engine.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-env-util.c tests: add tests for environment serialization 2017-06-23 20:46:33 -04:00
test-escape.c tests: add tests for environment serialization 2017-06-23 20:46:33 -04:00
test-exec-util.c test-exec-util: drop duplicate const 2017-04-21 12:05:55 -04:00
test-execute.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-extract-word.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-fd-util.c core/manager: split out creation of serialization fd out to a helper 2017-02-20 18:49:09 -05:00
test-fdset.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-fileio.c basic: support default and alternate values for env expansion 2017-02-20 23:32:53 -05:00
test-firewall-util.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-fs-util.c test-fs-util: re-order test_readlink_and_make_absolute and test_get_files_in_directory (#6288) 2017-07-04 23:22:47 -04:00
test-fstab-util.c tests: move fstab-util related tests to test-fstab-util.c 2016-03-03 19:04:06 +01:00
test-glob-util.c basic: add readdir_no_dot and safe_glob functions 2017-04-27 13:20:08 -04:00
test-hash.c test: skip instead of fail if crypto kmods are not available 2017-03-03 16:45:44 +01:00
test-hashmap-ordered.awk meson: also indent scripts with 8 spaces 2017-04-25 08:49:16 -04:00
test-hashmap-plain.c test-hashmap: use $SYSTEMD_SLOW_TESTS variable 2017-07-13 17:52:49 -04:00
test-hashmap.c tree-wide: sort includes 2015-11-16 22:09:36 +01:00
test-helper.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-helper.h tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-hexdecoct.c util-lib: be stricter when decoding hex strings 2016-12-21 19:09:31 +01:00
test-hostname-util.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-hostname.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-id128.c test: skip instead of fail if crypto kmods are not available 2017-03-03 16:45:44 +01:00
test-install-root.c install: when a template unit is instantiated via a /usr symlink, consider it enabled 2017-02-07 20:16:12 +01:00
test-install.c install: introduce UnitFileFlags 2016-10-24 10:19:08 +02:00
test-io-util.c tests: move io-util related tests to test-io-util 2016-03-03 19:04:06 +01:00
test-ipcrm.c test-ipcrm: use configured nobody user name (#5350) 2017-02-15 10:22:22 +01:00
test-job-type.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-journal-importer.c test: drop TEST_DATA_DIR, fold into get_testdata_dir() 2017-02-16 21:45:57 +01:00
test-libudev.c tree-wide: standardize on $(PACKAGE_VERSION) for the version string 2017-04-04 20:36:09 -04:00
test-list.c list: LIST_INSERT_BEFORE: update head if necessary (#4261) 2016-10-04 16:15:37 +02:00
test-locale-util.c tree-wide: sort includes 2015-11-16 22:09:36 +01:00
test-log.c tree-wide: make use of getpid_cached() wherever we can 2017-07-20 20:27:24 +02:00
test-loopback.c test: show debug log output during test-loopback 2017-06-23 12:06:58 +02:00
test-mount-util.c Modify mount_propagation_flags_from_string to return a normal int code 2016-12-17 13:57:04 -05:00
test-namespace.c tree-wide: drop NULL sentinel from strjoin 2016-10-23 11:43:27 -04:00
test-netlink-manual.c tree-wide: minor formatting inconsistency cleanups 2016-02-23 14:20:34 -08:00
test-ns.c core: add RootImage= setting for using a specific image file as root directory for a service 2017-02-07 12:19:42 +01:00
test-nss.c resolved,nss-myhostname: use _gateway for the gateway 2017-07-31 14:41:56 -04:00
test-parse-util.c Merge pull request #5600 from fbuihuu/make-logind-restartable 2017-06-24 18:58:36 -04:00
test-path-lookup.c systemctl: don't confuse sysv code with generated units 2016-04-12 13:43:32 +02:00
test-path-util.c basic/path-util: allow flags for path_equal_or_files_same 2017-06-17 12:37:16 -04:00
test-path.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-prioq.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-proc-cmdline.c util-lib: various improvements to kernel command line parsing 2016-12-21 19:09:08 +01:00
test-process-util.c test-process-util: test multiple invocations of rename_process 2017-08-04 11:25:57 +02:00
test-random-util.c tests: add test-random-util 2017-06-28 10:34:45 -04:00
test-ratelimit.c tree-wide: sort includes 2015-11-16 22:09:36 +01:00
test-replace-var.c tree-wide: drop NULL sentinel from strjoin 2016-10-23 11:43:27 -04:00
test-rlimit-util.c core: make parsing of RLIMIT_NICE aware of actual nice levels 2016-04-29 16:27:49 +02:00
test-sched-prio.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-seccomp.c test-seccomp: arm64 does not have access() and poll() 2017-07-15 17:18:22 -04:00
test-selinux.c Revert "selinux: split up mac_selinux_have() from mac_selinux_use()" 2017-05-12 14:43:39 +01:00
test-set.c
test-sigbus.c test-sigbus: skip the test under valgrind 2017-05-10 11:05:57 +00:00
test-signal-util.c tree-wide: make use of getpid_cached() wherever we can 2017-07-20 20:27:24 +02:00
test-siphash24.c test-siphash24: add a test for concatenating very short buffers 2016-02-20 16:34:59 -05:00
test-sizeof.c test-sizeof: print the size of an enum 2017-04-25 21:14:59 -04:00
test-sleep.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-socket-util.c test: add support for in_addr_is_multicast tests 2017-02-24 15:42:59 +05:30
test-stat-util.c basic/path-util: allow flags for path_equal_or_files_same 2017-06-17 12:37:16 -04:00
test-strbuf.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-string-util.c string-util: add strlen_ptr() helper 2017-07-31 18:20:28 +02:00
test-strip-tab-ansi.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-strv.c strv: fix STRV_FOREACH_BACKWARDS() to be a single statement only 2016-10-07 20:14:38 +02:00
test-strxcpyx.c test-strxcpyx: add test for strpcpyf overflow 2017-07-03 20:50:14 -04:00
test-tables.c Drop busname unit type 2017-07-23 09:29:02 -04:00
test-terminal-util.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-time.c Parse "timeout=0" as infinity in various generators (#6264) 2017-07-03 14:29:32 +02:00
test-tmpfiles.c tree-wide: make use of getpid_cached() wherever we can 2017-07-20 20:27:24 +02:00
test-udev.c tree-wide: standardize on $(PACKAGE_VERSION) for the version string 2017-04-04 20:36:09 -04:00
test-uid-range.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-unaligned.c util-lib: add accessors for unaligned native endian words 2016-06-06 19:59:09 +02:00
test-unit-file.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-unit-name.c tests: when running a manager object in a test, migrate to private cgroup subroot first (#6576) 2017-08-09 09:42:49 -04:00
test-user-util.c sysusers: move various user credential validity checks to src/basic/ 2016-07-22 15:53:45 +02:00
test-utf8.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-util.c basic/util: move execute_directory() to separate file 2017-02-11 18:21:06 -05:00
test-verbs.c
test-watchdog.c test-watchdog: wait just one cycle unless $SYSTEMD_SLOW_TESTS 2017-07-13 17:54:59 -04:00
test-web-util.c tests: move web-util related tests to test-web-util.c 2016-03-03 18:46:58 +01:00
test-xattr-util.c tests: move xattr-util related tests to test-xattr-util.c 2016-03-03 19:04:07 +01:00
test-xml.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00