Commit graph

389 commits

Author SHA1 Message Date
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
Grigori Goronzy fd8b924820 cryptenroll: add tests for TPM2 unlocking
Add tests for enrolling and unlocking. Various cases are tested:

- Default PCR 7 policy w/o PIN, good and bad cases (wrong PCR)
- PCR 7 + PIN policy, good and bad cases (wrong PCR, wrong PIN)
- Non-default PCR 0+7 policy w/o PIN, good and bad cases (wrong PCR 0)

v2: rename test, fix tss2 library installation, fix CI failures
v3: fix ppc64, load module
2022-03-15 21:17:00 +01:00
Luca Boccassi 4f2dba98ad TEST-29: do not pass -q to mk/unsquashfs, not supported on CentOS 8 2022-03-08 18:02:09 +09:00
Zbigniew Jędrzejewski-Szmek 13391986b5 TEST-29: trim output a bit
IIUC, pipefail doesn't matter for a sequence of commands joined with &&, and we
don't have any pipes. And such a failing expression also does not trigger an
exit, so the set +e/set -e were noops.
2022-03-07 14:31:36 +01:00
Frantisek Sumsal 93c3b6989b test: set ReadWritePaths= only for units from TEST-20
as setting it system-wide has some undesirable side-effects.

Follow-up to b6fc524.
2022-02-17 14:45:21 +00:00
Evgeny Vereshchagin bf6ef6b6a9 tests: allow running all the services with SYSTEMD_LOG_LEVEL
It should make it easier to figure out what exactly services do there.
For example, with SYSTEMD_LOG_LEVEL=debug userdbd (v249) prints
```
varlink-5: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{}}
```
before it crashes and systemd-resolved prints
```
varlink-21: New incoming message: {"method":"io.systemd.Resolve.ResolveAddress","parameters":{"address":[127,0,0,1],"flags":0,"ifindex":1000000,"family":0}}
```
and those messages are helpful (especially when scripts causing them
aren't clever enough to keep track of random stuff they send to systemd
:-))
2022-02-16 07:50:51 +03:00
Frantisek Sumsal b6fc52408a test: set ReadWritePaths=$BUILD_DIR when running w/ coverage
otherwise units using `DynamicUser=yes` won't be able to write the
coverage stats (currently affecting TEST-20-MAINPIDGAMES).

`DynamicUser=yes` implies `ProtectSystem=strict` and
`ProtectHome=read-only` and can't be overridden hence we need to
utilize `ReadWritePaths=` to work around that.
2022-02-14 21:59:33 +00:00
Frantisek Sumsal d282e57e2a test: check for (possibly) missing test coverage
If the test logs contain lines like:

```
...systemd-resolved[735885]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-250.a.p/base-filesystem.c.gcda:Cannot open
```

it means we're possibly missing some coverage since gcov can't write the stats,
usually due to the sandbox being too restrictive (e.g. ProtectSystem=yes,
ProtectHome=yes) or the $BUILD_DIR being inaccessible to non-root users.
2022-02-14 12:20:02 +01:00
Frantisek Sumsal e4c822e9ac test: set ACLs for the build dir when built with coverage
Otherwise unprivileged processes (like systemd-resolved) can't write
coverage data.
2022-02-14 11:58:54 +01:00
Frantisek Sumsal d10d562bd4 test: lvm 2.03.15 dropped the static autoactivation
so install the respective generator only if we're running with older
lvm versions.

See: https://sourceware.org/git/?p=lvm2.git;a=commit;h=ee8fb0310c53ed003a43b324c99cdfd891dd1a7c
2022-02-09 22:36:25 +01:00
Frantisek Sumsal f723740871 test: introduce `get_cgroup_hierarchy() helper
which returns the host's cgroup hierarchy (unified, hybrid, or legacy).
2022-02-01 22:13:45 +01:00
Frantisek Sumsal 6f73ef8b30 test: copy portable profiles into the image if they don't exist there
If we're built with `-Dportable=false`, the portable profiles won't get
installed into the image. Since we need only the profile files and
nothing else, let's copy them into the image explicitly in such case.
2022-01-31 17:09:30 +00:00
Yu Watanabe 256ce2e889
Merge pull request #21838 from lnussel/logind-refactor
Logind shutdown refactor
2022-01-31 19:45:33 +09:00
Luca Boccassi 3fa80e5e75 core: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used
A bind mount is added directly from private on the host to the actual
destination directory, no need for the symlinks (which cannot be created
as the bind mount happens first and creates the target as an actual directory)

Fixes https://github.com/systemd/systemd/issues/22264
2022-01-28 00:54:10 +00:00
Luca Boccassi 392d46d7a8 test: use mksquashfs -noappend
Makes the setup idempotent, as mksquashfs by default attempts to
append to an existing image
2022-01-27 14:21:29 +00:00
Luca Boccassi d76f0de746 test: rename service used in TEST-29-PORTABLE to avoid conflict
There's an app0.service in the extension app0.raw, so don't use the same
name for a unit in minimal.raw
2022-01-27 14:21:29 +00:00
Ludwig Nussel 48f3bc5cc4 test: add shutdown test
Wraps nspawn to be able to use pexpect. The test logs in on the console
and runs screen. In one screen window it types in shutdown commands and
checks whether a wall message was sent to the other.
2022-01-25 17:43:13 +01:00
Ludwig Nussel b13a8b5b37 test: mark partition bootable
Make test suite partition bootable so nspawn can use the image directly.
Useful for local testing.

https://systemd.io/DISCOVERABLE_PARTITIONS/
2021-12-29 19:23:26 +00:00
Zbigniew Jędrzejewski-Szmek ff254eea8f test: ignore the error about our own libraries missing during image creation
19:50:59 F: Missing a shared library required by /var/tmp/systemd-test.NIPT2q/root/lib/systemd/libsystemd-core-250.so.
19:50:59 F: Run "ldd /var/tmp/systemd-test.NIPT2q/root/lib/systemd/libsystemd-core-250.so" to find out what it is.
19:50:59 F: libsystemd-shared-250.so => not found
19:50:59 F: Cannot create a test image.
2021-12-25 15:18:50 +09:00
Yu Watanabe 92ecc87512 test: install losetup by default
Preparation for the next commit.
2021-12-20 23:34:27 +09:00
Franck Bui 051ea718f2 TEST-10: don't attempt to write a byte to the socket
Writing a byte to test10.socket is actually the root cause of issue #19154:
depending on the timing, it's possible that PID1 closes the socket before socat
(or nc, it doesn't matter which tool is actually used) tries to write that one
byte to the socket. In this case writing to the socket returns EPIPE, which
causes socat to exit(1) and subsequently make the test fail.

Since we're only interested in connecting to the socket and triggering the rate
limit of the socket, this patch removes the parts that write the single byte to
the socket, which should remove the race for good.

Since it shouldn't matter whether the test uses socat or nc, let's switch back
to nc and hence remove the sole user of socat. The exit status of nc is however
ignored because some versions might choke when the socket is closed
unexpectedly.
2021-12-07 08:29:09 +09:00
Luca Boccassi 56f2a72919 elf-util: switch libelf/libdw to dlopen()
In order to avoid inflating the dependency list for the core
library, use dlopen when inspecting elfs, since it's only
used in two non-core executables.
2021-11-30 16:49:59 +00:00