Commit Graph

589 Commits

Author SHA1 Message Date
Yu Watanabe
97bbb9cfbd test: create ESP and xbootldr partitions 2023-12-13 14:28:30 +09:00
Yu Watanabe
0f236e8cd6 test: mask mdmonitor when building image
Follow-up for 22e31655f3.
2023-12-13 14:28:03 +09:00
Yu Watanabe
4ed943e97b test: make install_mdadm() also install relevant kernel modules
Installing mdadm without kernel modules is mostly meaningless.
2023-12-13 14:19:28 +09:00
Yu Watanabe
5b4fa6f13c test: split out host_has_{btrfs,mdadm}() from TEST-64-UDEV-STORAGE 2023-12-13 14:19:28 +09:00
Frantisek Sumsal
52c1fb6885 test: set correct group for systemd-journal-upload tests
We can't use the systemd-journal-upload user here, since it's created
dynamically by DynamicUser=yes. However, we can use the group specified
in SupplementaryGroups=, so do exactly that.
2023-12-05 09:07:14 +01:00
Yu Watanabe
fa316d553c test: show saved journal files after TEST-02-UNITTESTS 2023-11-28 04:10:25 +09:00
Frantisek Sumsal
60f9c49b16 test: remove the reboot counter just before spawning container/VM
Doing that in test_run() is not enough, since it's called only once and
spawns all QEMU/nspawn jobs.
2023-11-25 20:22:24 +01:00
Frantisek Sumsal
fa6f37c043 test: don't redirect stdout/stderr to console
Turns out that redirecting a lot of output to the console can have some
funny effects, like random kernel soft lockups. I spotted this in
various CIs, but it remained almost entirely hidden thanks to
`softlockup_panic=1`, until 1a36d2672f which introduced a couple of
tests that log quite a lot in a short amount of time. This, in
combination with newer kernel version, which, for some reason, seem to
be more susceptible to such soft lockups, made the Arch Linux jobs soft
lockup quite a lot, see [0].

While debugging this I also noticed that runs which don't redirect
stdout/stderr to the console are noticeably faster, e.g.:

    # TEST-71 nspawn + QEMU (KVM), StandardOutput=journal+console
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:24.64
    # TEST-71 nspawn + QEMU (KVM), StandardOutput=journal
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:17.95

    # TEST-71 nspawn + QEMU, StandardOutput=journal+console
    Elapsed (wall clock) time (h:mm:ss or m:ss): 2:04.70
    # TEST-71 nspawn + QEMU, StandardOutput=journal
    Elapsed (wall clock) time (h:mm:ss or m:ss): 1:44.48

    # TEST-04 QEMU, StandardOutput=journal+console
    Elapsed (wall clock) time (h:mm:ss or m:ss): 4:22.70
    # TEST-04 QEMU, StandardOutput=console
    Elapsed (wall clock) time (h:mm:ss or m:ss): 5:04.67

Given all this, let's effectively revert ba7abf79a5, and dump the
testsuite-related journal messages only after the test finishes, so they
don't go through the slow console.

Resolves: systemd/systemd-centos-ci#660

[0] https://github.com/systemd/systemd-centos-ci/issues/660
2023-11-24 18:00:07 +01:00
Frantisek Sumsal
09bdb9f121 test: clean up the save_journal() stuff a bit
Let's save all journals from the test machine instead of calling export
on each journal file separately, which makes the code less complicated
(and probably faster).
2023-11-24 11:51:27 +01:00
Frantisek Sumsal
f258a76332 test: don't use ddebug() before it's defined
I'm pretty sure this is not the only case, but it's the one I recently
noticed. Even though we call ddebug() from a function, that function is
called before ddebug() is defined, resulting in the same issue as if we
called just ddebug() in its place, i.e.:

..//test-functions: line 276: ddebug: command not found
2023-11-20 21:26:17 +01:00
Frantisek Sumsal
6162caa288 test: move a couple of binaries to the BASICTOOLS array
As they're not optional.
2023-11-20 21:26:14 +01:00
Frantisek Sumsal
8ddbd9e078 test: support NO_BUILD=yes on Fedora 2023-11-20 21:26:11 +01:00
Frantisek Sumsal
b54bc139ae test: make the LOOKS_LIKE_* variables proper booleans 2023-11-20 21:26:08 +01:00
Frantisek Sumsal
5ef964f88c test: make TEST-06-SELINUX work with the refpolicy and beef it up a bit
Currently the test works only with policy shipped by Fedora, which makes
it pretty much useless in most of our CIs. Let's drop the custom module
and make the test more generic, so it works with the refpolicy as well,
which should allow us to run it on Arch and probably even in Ubuntu CI.
2023-11-14 18:54:16 +01:00
Frantisek Sumsal
4f3d8def18 test: don't pre-process $KERNEL_APPEND
Let's just rely on the word splitting done by bash instead of messing
with that ourselves, as it's just adding extra complexity to appease one
ShellCheck check. Also, this apparently never worked for the nspawn
stuff anyway, since I forgot to set $IFS to an appropriate value, so it
always put all arguments from $KERNEL_APPEND into a single array item
with an extra newline, which then made systemd sad:

~# readarray arr <<< "foo bar baz"; for i in "${arr[@]}"; do echo "'$i'"; done
'foo bar baz
'
~# make -C test/TEST-45-TIMEDATE/ clean setup run BUILD_DIR=$PWD/build TEST_NO_QEMU=1 KERNEL_APPEND="systemd.log_level=console"
...
~# journalctl -o short-monotonic --no-hostname --file /var/tmp/systemd-tests/systemd-test.XaDX67/system.journal --grep "Failed to parse" -p info --no-pager
[551138.986882] systemd-tmpfiles[21]: Failed to parse log level 'console
[551138.987179] systemd-remount-fs[20]: Failed to parse log level 'console
[551138.993125] systemd-sysusers[23]: Failed to parse log level 'console
[551138.998685] journalctl[29]: Failed to parse log level 'console

Resolves: #29945
2023-11-09 16:31:12 +00:00
Frantisek Sumsal
4e086c389a Revert "test: don't panic on soft lockups"
Let's put this back in, as it could help with occasional machine lock ups
on overloaded systems (and it didn't help with the original issue
anyway).

This reverts commit 3a89904e45.
2023-11-03 20:38:31 +00:00
Maanya Goenka
db776f6935 portable: add support for confext
Support confexts for portable services
2023-11-03 16:59:58 +00:00
Frantisek Sumsal
af70e2021e test: add a couple more tests for systemd-pcrextend 2023-10-25 18:18:47 +02:00
Frantisek Sumsal
5ab2f737cd test: introduce $TEST_SKIP_SHUTDOWN
To get rid of some boilerplate.
2023-10-24 12:35:03 +02:00
Franck Bui
a1af99df8e test: install af_packet kernel module on openSUSE
Currently needed by test-dhcp-server unit test, af_packet is not built-in on
openSUSE distributions.
2023-10-21 11:39:10 +01:00
Frantisek Sumsal
a2dd592002 test: unify checking for user xattrs support in cgroupfs
Also, run the coredump forwarding test only if user xattrs are
supported.
2023-10-19 18:01:07 +01:00
Frantisek Sumsal
c1b129f4ad test: introduce TEST-09-REBOOT
To test stuff involving state preserved across (multiple) reboots, like
journal boot IDs.
2023-09-27 14:50:19 +02:00
Frantisek Sumsal
7f048f0ed0 test: enable debug logs for the user instances as well
To make debugging [0], hopefully, easier.

[0] https://github.com/systemd/systemd/issues/28504
2023-09-25 15:24:11 +01:00
Frantisek Sumsal
18c3ffbfcc test: wait for the swtpm socket to appear
On slower/overloaded systems it may take a bit for the swtpm socket
to show up:

I: Started swtpm as PID 189419 with state dir /tmp/tmp.pWqUutuGUj
I: Configured emulated TPM2 device tpm-spapr
+ tee /var/tmp/systemd-test-TEST-70-TPM2_1/console.log
+ timeout --foreground 1200 /bin/qemu-system-ppc64le -smp 4 ...
qemu-system-ppc64le: -chardev socket,id=chrtpm,path=/tmp/tmp.pWqUutuGUj/sock: Failed to connect to '/tmp/tmp.pWqUutuGUj/sock': No such file or directory
E: qemu failed with exit code 1

Spotted regularly in the ppc64le cron job and in some Ubuntu CI/CentOS CI
pr runs [0].

[0] https://github.com/systemd/systemd/pull/29183#issuecomment-1721727927
2023-09-23 11:32:12 +01:00
Frantisek Sumsal
3a89904e45 test: don't panic on soft lockups
We can't do anything about them anyway, and most importantly this seems
to alleviate systemd/systemd-centos-ci#660, which should make the CIs
a bit less angry (at least until the issue is addressed properly).
2023-09-23 14:19:55 +08:00
Frantisek Sumsal
5599c84bcd test: fix debugging of nspawn tests
The pipe stuff introduced in 701e0c2660 causes nspawn to switch the
console from 'interactive' into 'read-only' which is a bit useless when
debugging. Let's set --console=interactive explicitly in such case.

Follow-up to 701e0c2660.
2023-08-29 01:08:08 +01:00
Mathieu Tortuyaux
41712cd1c0 sysext: support EXTENSION_RELOAD_MANAGER metadata
This metadata (EXTENSION_RELOAD_MANAGER) can be set to "1" to reload the manager
when merging/refreshing/unmerging a system extension image. This can be useful in case the sysext
image provides systemd units that need to be loaded.

With `--no-reload`, one can deactivate the EXTENSION_RELOAD_MANAGER metadata interpretation.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2023-08-21 11:13:54 +02:00
Maanya Goenka
b856f1dfc5 test: add test for confext service-scoped support 2023-08-15 18:34:57 +00:00
Frantisek Sumsal
cb16b72e9c test: correctly propagate return code from check_result hooks 2023-08-11 16:57:06 +02:00
Frantisek Sumsal
701e0c2660 test: save the console log to a file
So we can refer to it later if needed.
2023-08-11 16:57:06 +02:00
Franck Bui
372d40fb03 test: testsuite-35.sh needs manual/test-session-properties to be installed on SUSE 2023-08-10 19:11:07 +01:00
Frantisek Sumsal
04bce24d4e test: ignore missing libudev when creating the test image
Same scenario as with libsystemd - ldd might use unprefixed RPATH, and
we install our own stuff into the image unconditionally anyway.

Also, bail out early if we hit a missing DSO with a possibly helpful
message.
2023-08-05 13:32:17 +09:00
Franck Bui
33ce0a8992 test: install systemd-homed for openSUSE
This new sub-package has been recently introduced.
2023-08-01 19:40:38 +02:00
Franck Bui
ba0ff9fc0f test: console fonts are located in /usr/share on openSUSE 2023-08-01 19:38:13 +02:00
Luca Boccassi
b0d3095fd6 Drop split-usr and unmerged-usr support
As previously announced, execute order 66:

https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html

The meson options split-usr, rootlibdir and rootprefix become no-ops
that print a warning if they are set to anything other than the
default values. We can remove them in a future release.
2023-07-28 19:34:03 +01:00
Lennart Poettering
4a262d5677 test: add test for initrd credentials
This extends the test framework a bit, and allows adding additional
initrds to the qemu invocation, which we use here to place credentials
in the new /run/systemd/@initrd/ credentials dir which are then passed
to the host.
2023-07-04 23:05:23 +02:00
Frantisek Sumsal
2b5e786005 test: enable LSan for certain wrapped binaries
So we're able to detect memory leaks in our NSS modules.

An example after introducing a memory leak in nss-myhostname.c:

testsuite-71.sh[2881]: =================================================================
testsuite-71.sh[2881]: ==2880==ERROR: LeakSanitizer: detected memory leaks
testsuite-71.sh[2881]: Direct leak of 2 byte(s) in 1 object(s) allocated from:
testsuite-71.sh[2881]:     #0 0x7fa28907243b in strdup (/usr/lib64/libasan.so.8.0.0+0x7243b)
testsuite-71.sh[2881]:     #1 0x7fa286a7bc10 in gethostname_full ../src/basic/hostname-util.c:67
testsuite-71.sh[2881]:     #2 0x7fa286a74af9 in gethostname_malloc ../src/basic/hostname-util.h:24
testsuite-71.sh[2881]:     #3 0x7fa286a756f4 in _nss_myhostname_gethostbyname4_r ../src/nss-myhostname/nss-myhostname.c:79
testsuite-71.sh[2881]:     #4 0x7fa288f17588 in getaddrinfo (/lib64/libc.so.6+0xf4588)
testsuite-71.sh[2881]:     #5 0x7fa2890a4d93 in __interceptor_getaddrinfo.part.0 (/usr/lib64/libasan.so.8.0.0+0xa4d93)
testsuite-71.sh[2881]:     #6 0x55a54b2b7159 in ahosts_keys_int.part.0 (/usr/bin/getent.orig+0x4159)
testsuite-71.sh[2881]: SUMMARY: AddressSanitizer: 2 byte(s) leaked in 1 allocation(s).
2023-06-28 17:04:31 +02:00
Frantisek Sumsal
88c98cb261 test: make sure we get PID1's stack trace on ASan/UBSan errors
As hitting an ASan/UBSan error in PID1 results in a crash (and a kernel
panic when running under qemu), we usually lose the stack trace which
makes debugging quite painful. Let's mitigate this by forwarding the
stack trace to multiple places - namely to a file and the syslog.
2023-06-23 14:37:07 +02:00
Daan De Meyer
d110169b65 test: Add touch into minimal verity test image 2023-06-21 12:48:48 +02:00
Frantisek Sumsal
033601b79a test: wrap curl when running with ASan
Necessary (unfortunately) for curl on C8S.
2023-06-19 10:19:44 +02:00
Frantisek Sumsal
52db3601bd test: extend the DynamicUser=yes coverage workaround to a couple more services 2023-06-18 23:08:24 +02:00
Frantisek Sumsal
3bba91ef44 test: set $PATH to something predictable in the ASan wrapper
This is still necessary when running with clang's ASan, as it uses an
external binary to symbolize the stack traces.

Follow-up to ba79e8c2cc.
2023-06-15 14:53:32 +01:00
Frantisek Sumsal
a6695a431f test: copy file xattrs (if any) as well 2023-06-13 10:15:27 +02:00
Frantisek Sumsal
8e81885531 test: wrap agetty & getfacl when running with sanitizers
The list is getting slightly ridiculous.
2023-06-07 16:26:21 +02:00
Frantisek Sumsal
93b896e90e test: drop $SKIP_INITRD
It's pointless nowadays, since we always need an initrd for the test VMs
as we require modules that are usually not compiled in the kernel.
2023-06-07 15:23:36 +02:00
Frantisek Sumsal
25bc469727 test: rebuild the ldconfig cache after changing its configuration
Follow-up to ba79e8c2cc.
2023-06-07 15:19:44 +02:00
Frantisek Sumsal
6f814d4f5d
Merge pull request #27933 from mrc0mmand/selinux
test: a couple of TEST-06-SELINUX tweaks
2023-06-06 11:18:50 +02:00
Frantisek Sumsal
d5ab23aa54 test: a couple of assorted cleanups
- sort binaries
- send stdout/stderr of the autorelabel service to console as well
2023-06-05 23:30:01 +02:00
Frantisek Sumsal
8c0ace5739 test: add a reasoning why we don't use the SELinux-provided units 2023-06-05 22:52:38 +02:00
Yu Watanabe
3db7f3c58c
Merge pull request #27912 from mrc0mmand/cryptsetup-tests
test: add a couple more tests for systemd-cryptsetup
2023-06-06 03:34:59 +09:00
Frantisek Sumsal
71d7f02cc7 test: make check_result_*() set -e friendly 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
00c2676972 test: minor cleanup
No functional change.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
0334afe4d0 test: make the root/data partition size configurable per test 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
70bdf6e661 test: introduce test_require_bin() and use it
No functional change.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
18fa5c8283 test: move TPM2-related setup stuff into test-functions
And hide it all behind $TEST_SETUP_SWTPM.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
0efa27bd4b test: allow running only specified subtests/testcases
Useful when debugging, e.g.:

make -C test/TEST-74-AUX-UTILS clean setup run TEST_MATCH_SUBTEST=run

Resolves: #27914
2023-06-05 15:58:37 +02:00
Frantisek Sumsal
dee4a9923b test: add a couple of tests for systemd-run 2023-06-01 23:12:47 +02:00
Frantisek Sumsal
ba79e8c2cc test: split the ASan wrapper into smaller blocks and tidy it up a bit
No functional change (hopefully), just making it easier on the eyes.
2023-05-26 13:43:07 +09:00
Yu Watanabe
23ff8a776c test: install test specific modules in test_append_files() 2023-05-22 12:40:05 +09:00
Frantisek Sumsal
daeb95a1d8 test: drop generated stuff from the final coverage report
Let's drop stuff from the current $BUILD_DIR from the final coverage
report, as it's all generated files (mostly gperf) which we don't
really care about and it makes the Coveralls report confusing, since it
reports "source not available" for all such files.
2023-05-19 11:07:07 +02:00
Yu Watanabe
ec0bd9611a
Merge pull request #27684 from mrc0mmand/more-nspawn-tests
test: further extend systemd-nspawn coverage
2023-05-19 03:00:54 +09:00
Luca Boccassi
8fb26ccd36 integration test: pass 'noresume' to qemu
When running on Debian/Ubuntu, I get a minute delay or so on every boot
because the local initramfs tries to resume from hibernation. This is
not really useful here, so always skip it
2023-05-18 16:45:55 +01:00
Frantisek Sumsal
2de77dbfc7 test: wrap setfacl when running with ASan 2023-05-18 17:30:36 +02:00
Frantisek Sumsal
0d4519dd84 test: don't mount /sys & /proc if already mounted 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
cbd20ab41b test: add a couple of tests for nspawn config files 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
d5a6ff8c18 test: cover --bind-user= 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
786f6d81f7 test: pass $BUILD_DIR as $COVERAGE_BUILD_DIR to the system manager
To make additional coverage-related tweaks slightly easier.
2023-05-15 10:06:54 +02:00
Frantisek Sumsal
807626d1ce test: install the overlayfs/loop modules unconditionally 2023-05-14 19:32:07 +02:00
Frantisek Sumsal
3b2823a749 test: bind mount the $BUILD_DIR into nspawn containers
when collecting coverage. This applies only to containers started
via machinectl (or directly via the systemd-nspawn@.service unit).
2023-05-14 19:32:07 +02:00
Frantisek Sumsal
ceea144ed8 test: use dropins to override system configuration
Instead of touching the configuration files directly.
2023-05-14 19:32:07 +02:00
Frantisek Sumsal
990b629e12 test: always install the script utility 2023-05-13 00:26:38 +02:00
Frantisek Sumsal
378db9e2b9 test: add a couple of tests for machinectl 2023-05-13 00:26:38 +02:00
Frantisek Sumsal
c2df08b5b8 test: clean up the nspawn tests a bit 2023-05-12 18:05:29 +02:00
Zbigniew Jędrzejewski-Szmek
711169905e test: use sed and grep instead of perl
This gets rid of the all-but-one remaining uses of perl. I tested the new code
on my machine, so I'm fairly confident that it works as expected.

install_iscsi() has one majestic perl invocation, but we can't get rid of it
easily: it extends the code of tgt-admin to print some list of files. Obviously
this only works because tgt-admin is written in perl, and perl will be installed
if tgt-admin is installed. install_iscsi() is used in TEST-64-UDEV-STORAGE
conditionally if tgtadm is installed, so this can stay as is.
2023-05-09 08:11:10 +02:00
Frantisek Sumsal
94d82b5980 tree-wide: code spelling fixes
As reported by Fossies.
2023-04-20 21:54:59 +02:00
Frantisek Sumsal
e6c281c1cb test: add a couple of tests for getty-generator 2023-04-14 13:54:27 +02:00
Frantisek Sumsal
82929336c7 test: drop binary stripping stuff
Stripping the binaries in the test images makes potential stack straces
quite useless, so let's drop the stripping stuff to make test fails a bit
more developer friendly.

Related: https://github.com/systemd/systemd-centos-ci/pull/616
2023-04-12 10:33:32 +09:00
Yu Watanabe
18a6cd4ba3 test-64: add tests for compat devlinks for NVMe drive 2023-04-08 06:12:29 +09:00
Frantisek Sumsal
61961e693d test: check if we skip the full setup on daemon-reexec
A simple test case for issue #27106.

Resolves: #27139
2023-04-07 07:53:14 +09:00
Thomas Blume
d6d0661631 test/test-functions: fix typo in install_suse_systemd() 2023-04-04 20:39:11 +01:00
Frantisek Sumsal
2e4f69946c
Merge pull request #27087 from mrc0mmand/missing-coverage
test: set ReadWritePaths= for test-.services when built w/ coverage
2023-04-01 18:59:42 +02:00
Frantisek Sumsal
e660c590a5 test: set ReadWritePaths= for test-.services when built w/ coverage
Let's make the dropin, to make the build dir writable for gcov, a bit
more generic, so it can be used by all units starting with prefix test-.
This should help with a bunch of recent reports about missing coverage I
got, as well as with existing test units using DynamicUser=true.

This might feel a bit like a magic trick from behind the curtains, but I
want to touch the actual tests as little as possible, since it makes them
unnecessarily messy (see the various workarounds for sanitizers), and
the coverage reports are generated only in a specific CI job anyway.
2023-03-31 19:23:31 +02:00
Thomas Blume
c7bf1959d7 test: use setpriv instead of su for user switch from root
systemd-repart needs to find mkfs.ext4 for the test.
This is located in the directory /usr/sbin on openSUSE Tumbleweed.
But since the variable ALWAYS_SET_PATH in /etc/login.defs is set to yes,
su re-initializes the $PATH variable and removes /usr/sbin.
Hence, mkfs.ext4 is not found and the test fails.
Using setpriv instead of su fixes this issue and is more appropriate to
do the switch user task from root.

[zjs: move setpriv to $BASICTOOLS and force-push to retrigger CI]
2023-03-31 22:26:44 +08:00
Luca Boccassi
49e8342965 test: do not remove state directory on failure
The test log is in the state directory, and we want to keep it around
when a test fails.

Follow-up for: 256a835f1c
2023-03-29 12:59:02 +09:00
Luca Boccassi
e8114a4f86 portable: add PORTABLE_NAME_AND_VERSION= and other metadata to LogsExtraFields=
This is useful to identify log messages with metadata from the images
they run on. Look for ID/VERSION_ID/IMAGE_ID/IMAGE_VERSION/BUILD_ID,
with a SYSEXT_ prefix if we are looking at an extension, and append via
LogExtraFields= as respectively PORTABLE_NAME_AND_VERSION= in case of a
single image. In case of extensions, append as PORTABLE_ROOT_NAME_AND_VERSION=
for the base and one PORTABLE_EXTENSION_AND_VERSION= for each extension.

Example with a base and two extensions, with the unit coming from the
first extension:

[Service]
RootImage=/home/bluca/git/systemd/base.raw
Environment=PORTABLE=app0.raw
BindReadOnlyPaths=/etc/os-release:/run/host/os-release
LogExtraFields=PORTABLE=app0.raw
Environment=PORTABLE_ROOT=base.raw
LogExtraFields=PORTABLE_ROOT=base.raw
LogExtraFields=PORTABLE_ROOT_NAME_AND_VERSION=debian_10

ExtensionImages=/home/bluca/git/systemd/app0.raw
LogExtraFields=PORTABLE_EXTENSION=app0.raw
LogExtraFields=PORTABLE_EXTENSION_NAME_AND_VERSION=app_0

ExtensionImages=/home/bluca/git/systemd/app1.raw
LogExtraFields=PORTABLE_EXTENSION=app1.raw
LogExtraFields=PORTABLE_EXTENSION_NAME_AND_VERSION=app_1
2023-03-28 12:14:21 +01:00
Franck Bui
04ef5d1bd7 test: don't export $TOOLS_DIR
It's not (and shouldn't be) used by any test scripts.
2023-03-27 17:20:18 +02:00
Franck Bui
256a835f1c test: clean up $STATEDIR too 2023-03-27 17:20:18 +02:00
Franck Bui
0c566150c8 test: $STATEDIR should not point to /usr/lib/systemd/tests when NO_BUILD=1
When testing the binaries from the host, make sure to not store the state data
below /usr but use a dedicated directory in /var/tmp/ instead.

The working directories of the tests, initially located in /var/tmp, are also
moved in a dedicated directory /var/tmp/systemd-tests.
2023-03-27 17:20:15 +02:00
Luca Boccassi
8e1a129136
Merge pull request #26870 from fbuihuu/move-unit-tests-in-a-dedicated-subdir
Move unit tests in a dedicated subdir
2023-03-27 09:38:15 +01:00
Franck Bui
f8d527aa9a test: install symlinks with valid targets on SUSE and Debian 2023-03-26 10:44:09 +02:00
Frantisek Sumsal
237d81fdb3 test: filter the merged coverage report instead
So we don't have to do this twice - once for the base report and then
for each "real" one.

Follow-up to 7fdd6e157a.
2023-03-25 17:55:41 +01:00
Frantisek Sumsal
7fdd6e157a test: do an initial coverage capture
I noticed that our coverage reports miss some files completely - this
happens when the test doesn't touch the code in them at all, so the
generated coverage data (and resulting reports) have no information
about them. Let's fix this by doing an initial zero coverage capture
that contains a zeroed counter for every instrumented line in every
file, so when we later merge it with a capture from the test, it shows up
with a missing coverage instead of not showing at all.
2023-03-25 12:29:40 +00:00
Franck Bui
fa2745a3e1 test: on openSUSE install the collection of unit test binaries in the target only for TEST-02-UNITTESTS 2023-03-24 14:10:04 +01:00
Franck Bui
26c2b30277 test: install unit tests in a dedicated subdirectory below '$testsdir'
/usr/lib/systemd/tests may contain more than the unit tests. For example on
SUSE we also install the integration tests there.

Putting the unit tests in a dedicated directory named 'unit-tests' makes the
layout cleaner.

Note that `run-unit-tests.py` has not been moved so we don't need to adjust
(Fedora) packaging and users also don't need to descend into the subdirectory.
2023-03-24 14:08:57 +01:00
Frantisek Sumsal
e912bef85d test: wrap mkfs.*/mksquashfs/mkswap binaries when running w/ ASan 2023-03-16 12:56:40 +00:00
Frantisek Sumsal
72f6d0e556 test: bump the D-Bus related timeouts to 120s
Let's attempt to reduce the amount of flakes further when the AWS region
we run in is under heavy load and the hypervisor stars stealing our CPU
time.

Follow-up to e0cbb73911 and c78d18215b.
2023-03-09 13:27:57 +01:00
Zbigniew Jędrzejewski-Szmek
7a17e41dcf test: drop whitespace after shell redirection operators
(The one case that is left unchanged is '< <(subcommand)'.)

This way, the style with no gap was already dominant. This way, the reader
immediately knows that ' < ' is a comparison operator and ' << ' is a shift.

In a few cases, replace custom EOF replacement by just EOF. There is no point
in using someting like "_EOL" unless "EOF" appears in the text.
2023-02-06 09:19:04 +01:00
Frantisek Sumsal
42262f3e1b test: wrap delv & dig when running with sanitizers
On Arch both delv and dig pull in libnss_resolve:

```
$ grep resolve /etc/nsswitch.conf
hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
```
2023-01-27 16:40:52 +01:00
Frantisek Sumsal
e0cbb73911 test: bump the client-side timeout in sd-bus as well
Since c78d18215b D-Bus services now have 60s to start, but the client
side (sd-bus) still waits only for 25s before giving up:

```
[  226.196380] testsuite-71.sh[556]: + assert_in 'Static hostname: H' ''
[  226.332965] testsuite-71.sh[576]: + set +ex
[  226.332965] testsuite-71.sh[576]: FAIL: 'Static hostname: H' not found in:
[  228.910782] sh[577]: + systemctl poweroff --no-block
[  232.255584] hostnamectl[565]: Failed to query system properties: Connection timed out
[  236.827514] systemd[1]: end.service: Consumed 2.131s CPU time.
[  237.476969] dbus-daemon[566]: [system] Successfully activated service 'org.freedesktop.hostname1'
[  237.516308] systemd[1]: system-modprobe.slice: Consumed 1.533s CPU time.
[  237.794635] systemd[1]: testsuite-71.service: Main process exited, code=exited, status=1/FAILURE
[  237.818469] systemd[1]: testsuite-71.service: Failed with result 'exit-code'.
[  237.931415] systemd[1]: Failed to start testsuite-71.service.
[  238.000833] systemd[1]: testsuite-71.service: Consumed 5.651s CPU time.
[  238.181030] systemd[1]: Reached target testsuite.target.
```

Let's override the timeout in sd-bus as well to mitigate this.

Follow-up to c78d18215b.
2023-01-23 18:44:55 +01:00
Frantisek Sumsal
c78d18215b test: bump D-Bus service start timeout if we run without accel
The default (25s) doesn't seem to be enough in some cases (especially
in VMs without acceleration), causing spurious timeouts:

[  174.297658] dbus-daemon[647]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.0' (uid=0 pid=645 comm="hostnamectl " label="kernel")
[  184.202313] systemd[1]: systemd-update-utmp-runlevel.service: Consumed 1.253s CPU time.
[  197.335422] systemd[1]: Started dbus.service.
[  199.211468] testsuite-71.sh[639]: + assert_in 'Static hostname: H' ''
[  199.347192] dbus-daemon[647]: [system] Failed to activate service 'org.freedesktop.hostname1': timed out (service_start_timeout=25000ms)
[  199.394879] testsuite-71.sh[657]: + set +ex
[  199.438918] testsuite-71.sh[657]: FAIL: 'Static hostname: H' not found in:
[  200.966006] systemd-logind[631]: Watching system buttons on /dev/input/event0 (Power Button)
[  201.008178] systemd-logind[631]: Watching system buttons on /dev/input/event1 (AT Translated Set 2 keyboard)
[  201.034106] systemd-logind[631]: New seat seat0.
[  201.238267] sh[658]: + systemctl poweroff --no-block
[  201.329890] systemd[1]: Starting systemd-hostnamed.service...
[  202.156622] systemd[1]: systemd-update-utmp-runlevel.service: Deactivated successfully.
[  204.818913] hostnamectl[645]: Failed to query system properties: Connection timed out
[  205.195583] systemd[1]: testsuite-71.service: Main process exited, code=exited, status=1/FAILURE
[  205.227237] systemd[1]: testsuite-71.service: Failed with result 'exit-code'.
[  205.712780] systemd[1]: Failed to start testsuite-71.service.
2023-01-17 23:09:34 +00:00