Commit graph

410 commits

Author SHA1 Message Date
Frantisek Sumsal cd15f7f6d1 test: set the default QEMU and nspawn timeouts to 30 minutes
Set both timeouts to some reasonable values instead of just `infinity`
to provide some form of a safe-net in case the test goes haywire and the
environment didn't set the timeouts itself (like our CIs do).
2022-08-26 19:16:45 +02:00
Frantisek Sumsal 10d7ed12c9 test: use a unique machine name for each nspawn test
to avoid scope clashing in case some previous test crashed and/or didn't
clean up properly. Currently all test machines are called `root`, since
the name is automagically derived from the container path (in this case
`/var/tmp/systemd-test.XXXXXX/root`).

E.g. (from Ubuntu CI):
```
[23:10:12] --x-- Running TEST-71-HOSTNAME --x--
make: Entering directory '/tmp/autopkgtest.5LjnBV/build.0mE/systemd/test/TEST-71-HOSTNAME'
+ make -C TEST-71-HOSTNAME setup run
TEST-71-HOSTNAME SETUP: test hostnamed
Reusing existing cached image /tmp/autopkgtest.5LjnBV/build.0mE/systemd/test/TEST-71-HOSTNAME/../default.img → /tmp/autopkgtest.5LjnBV/build.0mE/systemd/test/default.img
'/var/tmp/systemd-test.1yy2SS/default.img' -> '/tmp/autopkgtest.5LjnBV/build.0mE/systemd/test/default.img'
I: Masking supporting services
'/var/tmp/systemd-test.1yy2SS/root/etc/systemd/system/systemd-hwdb-update.service' -> '/dev/null'
'/var/tmp/systemd-test.1yy2SS/root/etc/systemd/system/systemd-journal-catalog-update.service' -> '/dev/null'
'/var/tmp/systemd-test.1yy2SS/root/etc/systemd/system/systemd-networkd.service' -> '/dev/null'
'/var/tmp/systemd-test.1yy2SS/root/etc/systemd/system/systemd-networkd.socket' -> '/dev/null'
'/var/tmp/systemd-test.1yy2SS/root/etc/systemd/system/systemd-resolved.service' -> '/dev/null'
TEST-71-HOSTNAME RUN: test hostnamed
+ env --unset=UNIFIED_CGROUP_HIERARCHY --unset=SYSTEMD_NSPAWN_UNIFIED_HIERARCHY timeout --foreground 1200 /bin/systemd-nspawn --register=no --kill-signal=SIGKILL --directory=/var/tmp/systemd-test.1yy2SS/root --setenv=SYSTEMD_UNIT_PATH=/usr/lib/systemd/tests/testdata/testsuite-71.units:/usr/lib/systemd/tests/testdata/units: /lib/systemd/systemd systemd.unit=testsuite.target systemd.wants=testsuite-71.service systemd.wants=end.service
Spawning container root on /var/tmp/systemd-test.1yy2SS/root.
Press ^] three times within 1s to kill container.
Failed to allocate scope: Unit root.scope already exists.
E: nspawn failed with exit code 1
```
2022-08-26 19:16:45 +02:00
Frantisek Sumsal 6a9c497768 test: bump the base VM memory to 768M
as with 512M some tests occasionally trip off OOM-killer (e.g.
TEST-64 + multipath).
2022-08-26 15:40:34 +02:00
Frantisek Sumsal cde09b07df test: check for other hypervisors as well
EC2 machines run on Xen, so account for that as well when checking KVM
availability.
2022-08-26 15:40:34 +02:00
Frantisek Sumsal bea9d62bdb test: correctly process multiline strings in $KERNEL_APPEND
Some tests (like TEST-02) set a multiline string to $KERNEL_APPEND
(which is a valid thing to do), unfortunately we'd use only the first
line of it and throw the rest away, e.g:

```
$ printf "%s" "$x"
hello

this is a multiline

kernel command line
$ read -ra out <<< "$x"
$ printf "%s" "${out[@]}"
hello
```

Let's use readarray/mapfile instead to avoid this:

```
$ readarray out <<< "$x"
$ printf "%s" "${out[@]}"
hello

this is a multiline

kernel command line

```
2022-08-19 22:31:32 +01:00
Kai Lueke 16c1ca0db4 sysext: introduce ARCHITECTURE field to match host architecture
When an extension image has binaries they should match the host
architecture. Currently there is no way to specify this requirement.
Introduce an ARCHITECTURE field in the extension's release file that
may be set to prevent loading on the wrong host architecture.
Since this new field is introduced late, we don't want to make
specifying it mandatory as it would break existing sysext images.

See https://github.com/systemd/systemd/issues/24061
2022-08-15 10:54:32 +02:00
Kai Lueke ab4d43c54e sysext: support distribution-independent extensions using ID=_any
A sysext image that merely contains static binaries has no dependency
on the host distribution and should be able to be used anywhere.
Support the special '_any' value for the ID field in the extension to
opt-out of ID and VERSION_ID/SYSEXT_LEVEL matching.

See https://github.com/systemd/systemd/issues/24061
2022-08-15 10:51:01 +02:00
Frantisek Sumsal 134d4f1b9d test: be a bit more verbose about shared library symlinks
For example:
```
D: Installing /usr/lib64/libz.so.1.2.11
D: Creating symlink /usr/lib64/libz.so.1.2.11 -> /usr/lib64/libz.so.1
D: Creating extra symlink: /lib64/libz.so
D: Installing /usr/lib64/libgcc_s-12-20220507.so.1
D: Creating symlink /usr/lib64/libgcc_s-12-20220507.so.1 -> /usr/lib64/libgcc_s.so.1
```
2022-08-02 18:28:43 +02:00
Frantisek Sumsal 5f347d3160 test: install libgcc_s.so.1 explicitly if available
Since the library is dlopen()ed by libpthread and required during
pthread_exit()/pthread_cancel(), let's install it explicitly if available to
avoid unexpected fails in tests. This also consolidates all related
workarounds for this library across the test scripts.
2022-08-02 18:28:35 +02:00
Yu Watanabe 0d6217efc1
Merge pull request #23937 from mrc0mmand/test-tweaks
Several ASan-related test suite tweaks
2022-07-08 06:25:57 +09:00
Frantisek Sumsal b92c3df242 test: allow multiple handlers for the EXIT signal
Bash allows only one handler per signal, so let's overcome this
limitation by having one dedicated EXIT signal which runs all registered
handlers from all over the place.
2022-07-07 20:17:34 +02:00
Frantisek Sumsal 98b27937cb test: bump the data partition size if we don't strip binaries
so we can run TEST-24 under sanitizers as well.

Also, when at it, use the 'named-fields' sfdisk format to make the code
a bit more descriptive without needing a manual.
2022-07-07 19:17:05 +02:00
Frantisek Sumsal fdb70dd922 test: create an ASan wrapper for getent and su
since they "suffer" from the same issue as `login` and other binaries
that load PAM stuff
2022-07-07 19:17:05 +02:00
Yu Watanabe 63663a0f0f test: several cleanups for TEST-35-LOGIN
- use test_append_files() to install additional commands
- drop use of expect
- include assert.sh and use assertions at several places
- use timeout command at several places
- always use logind-test-user
- etc
2022-07-07 13:15:00 +00:00
Michal Sekletar bf40417c7c tests: add test for handling of background sessions 2022-07-07 10:11:43 +09:00
Yu Watanabe 99080ed3f0
Merge pull request #23396 from msekletar/fix-idle-action-lock
logind: remember our idle state and use it to detect idle level transitions
2022-07-07 07:42:51 +09:00
Michal Sekletar 181656fc0f tests: verify that Lock D-Bus signal is sent when IdleAction=lock 2022-07-04 14:22:15 +02:00
Frantisek Sumsal 17082e8ac1 test: resize the terminal automagically with INTERACTIVE_DEBUG=yes 2022-07-04 09:41:06 +02:00
Frantisek Sumsal 8afe2f53b2 test: install /usr/libexec/vi as well
since `/bin/vi` (at least on Fedora) is a shell wrapper which runs
either `/bin/vim` or `/usr/libexec/vi` based on availability.
2022-07-04 09:41:06 +02:00
Michael Biebl 41d6f3bf4d Use https for freedesktop.org
grep -l -r http:// | xargs sed -E -i s'#http://(.*).freedesktop.org#https://\1.freedesktop.org#'
2022-06-28 13:10:05 +02:00
Frantisek Sumsal dc350e78fe test: allow overriding $QEMU_MEM when running w/ ASan 2022-06-21 14:03:57 +02:00
Frantisek Sumsal 354b3364aa test: fuzz our dbus interfaces with dfuzzer 2022-06-19 16:22:35 +02:00
Frantisek Sumsal 508a7f04b3 test: make masking of supplementary services configurable 2022-06-19 11:27:41 +02:00
Frantisek Sumsal 35d2d2e61c test: run the custom check hooks before common checks
since we delete the guest journals as part of the save_journal() step in
check_result_common(), making journal inaccessible from the custom check
hooks.
2022-06-17 17:28:13 +02:00
Frantisek Sumsal 4b9a0c3aeb test: pass the initdir to check_result_{qemu,nspawn} hooks 2022-06-17 17:14:45 +02:00
Frantisek Sumsal 94850fb956 test: always wrap useradd/userdel when running w/ ASan
since they dlopen() PAM modules, including systemd ones.
2022-06-17 14:51:52 +02:00
Frantisek Sumsal ba7abf79a5 test: send stdout/stderr of testsuite units to journal & console
to make debugging in CIs slightly easier.
2022-06-17 12:54:50 +09:00
Yu Watanabe 75176c7914
Merge pull request #23741 from mrc0mmand/more-asan-tweaks
test: wrap certain uninstrumented binaries to make them work w/ ASan
2022-06-16 12:10:56 +09:00
Frantisek Sumsal b727d7e02d test: don't wrap binaries built with ASan
since they should handle loading other instrumented libraries without
issues.
2022-06-16 00:02:35 +02:00
Frantisek Sumsal fa65ba6baa test: drop all LD_PRELOAD-related ASan workarounds
since they shouldn't be necessary anymore, as we tweak the "problematic"
binaries on per-binary basis.
2022-06-16 00:02:35 +02:00
Frantisek Sumsal 3917534d62 test: wrap binaries using systemd DSOs when running w/ ASan
Let's detect & wrap binaries which are linked against systemd DSOs and
we're running under ASan, since otherwise running such binaries ends
with:

```
==633==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
```
2022-06-16 00:02:35 +02:00
Yu Watanabe 4627fb80bf test: move "do" at the end of line 2022-06-14 21:06:06 +09:00
Yu Watanabe 4ce68ea9b3 test: install C.UTF-8 and English locales 2022-06-14 20:59:36 +09:00
Yu Watanabe 1136175c7f test: install libxkbcommon and x11 keymaps 2022-06-14 20:59:36 +09:00
Yu Watanabe da0465dc95 test: introduce inst_recursive() helper function 2022-06-14 20:59:32 +09:00
Yu Watanabe 569c6fd1b7 test: add one more path to search keymaps
Now it also supports split-usr.
2022-06-14 20:56:23 +09:00
Yu Watanabe 9c94ab0f6f test: import logind test from debian/ubuntu test suite 2022-06-10 15:44:10 +09:00
Frantisek Sumsal 3ea18a2e36 test: set $ASAN_RT_PATH along with $LD_PRELOAD to the ASan runtime DSO
Since we unset $LD_PRELOAD in the testsuite-* units (due to another
issue), let's store the path to the ASan DSO in another env variable, so
we can easily access it in the testsuite scripts when needed.
2022-06-06 14:45:11 +02:00
Franck Bui 4d5d28e9a6 test: enable virtio-rng device for QEMU guests
If rngd is included in the host initrd, QEMU guests need at least one source of
entropy otherwise rngd will refuse to start. Hence this patch enables the
virtio RNG device in QEMU guests (exposed as a HW RNG device available at
/dev/hwrng).

As a safety measure, the patch limits the data sent to the guest to 1KB per
second in order to not let the guest starve the host entropy.
2022-06-03 01:52:28 +09:00
Frantisek Sumsal b22d90e594 test: generate a custom initrd for TEST-24 if $INITRD is unset
Co-Authored-By: Yu Watanabe <watanabe.yu+github@gmail.com>
2022-05-26 15:04:56 +02:00
Evgeny Vereshchagin d0880faa5d tests: ignore dbus-broker-launcher
There are memory leaks there https://github.com/bus1/dbus-broker/issues/289
and it crashes from time to time
https://github.com/matusmarhefka/dfuzzer/issues/20#issuecomment-1114097840
so let's just skip it by analogy with dbus-daemon to avoid
reports that have nothing to do with systemd itself.

It's kind of a part of https://github.com/systemd/systemd/pull/22547
2022-05-12 14:44:01 +09:00
Zbigniew Jędrzejewski-Szmek 3e8caa34d6 docs: use lowercase "qemu" and other minor tweaks to test docs
We used both "qemu" and "QEMU", let's use the lower-case version everywhere
since it's also the name of the binary and the version that people are
most familiar with.

The stuff under test/ is not only for the integeration tests, but also
for various other test-related stuff, so adjust the docs a bit.
2022-05-04 12:58:43 +02:00
Evgeny Vereshchagin 8e78dca982 tests: make valgrind_wrapper track file descriptors 2022-05-03 20:51:56 +00:00
Evgeny Vereshchagin c66e2f6c2c tests: make it possible to install valgrind 2022-05-03 20:50:39 +00:00
wangyuhang cca3050b9e test: use cp for journal copying when systemd-journal-remote non-existent 2022-04-25 08:27:17 +00:00
Yu Watanabe 7be87278a3
Merge pull request #23021 from fbuihuu/tmpfiles-fix-precedence-with-plus-sign
Tmpfiles fix precedence with plus sign
2022-04-16 01:36:51 +09:00
Frantisek Sumsal 3c9af05cae test: add MD-related tests to TEST-64 2022-04-14 00:12:02 +09:00
Franck Bui eef72224a8 test: adapt install_pam() for openSUSE
limits.conf is installed in /usr/etc/security for openSUSE.
2022-04-11 11:22:39 +02:00
Frantisek Sumsal 1b2e3b8bff test: ignore missing coverage in TEST-02
Since c6552ad we now try to collect coverage even in situations where
it's basically impossible (like in test-mount-util where the whole / is
mounted as read-only). As dealing with this is not worth the trouble,
let's ignore the missing coverage errors thrown by gcov in such cases.
2022-04-07 12:45:13 +02:00
Frantisek Sumsal 41d1aaea64 test: use flock when calling mkfs.btrfs
As stated in https://github.com/systemd/systemd/issues/21819#issuecomment-1064377645
`mkfs.btrfs` doesn't hold the lock for the whole duration of
`mkfs.btrfs`, thus causing unexpected races & test fails. Let's
wrap the `mkfs.btrfs` calls in an flock wrapper to mitigate this.

Hopefully fixes: #21819
2022-03-25 10:28:07 +09:00