Commit graph

342 commits

Author SHA1 Message Date
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
Frantisek Sumsal 72f9e485ce test: create a dummy LSan suppression file in the minimal image
otherwise gcc's ASan complains (unlike clang's) when the image is used -
e.g. in TEST-29 or TEST-50.

```
[   17.328705] testsuite-29.sh[361]: + portablectl --profile=trusted attach --now --runtime /usr/share/minimal_0.raw app0
...
[   20.978649] systemd[1]: Starting app0-foo.service...
[   21.104844] kernel: loop0: detected capacity change from 0 to 24960
[   20.999559] systemd[1]: Starting app0.service...
[   21.126022] kernel: loop1: detected capacity change from 0 to 24960
...
[   21.861087] cat[422]: AddressSanitizer: failed to read suppressions file '/systemd-lsan.supp'
[   21.868634] cat[421]: AddressSanitizer: failed to read suppressions file '/systemd-lsan.supp'
[   21.877941] systemd[1]: app0.service: Control process exited, code=exited, status=1/FAILURE
[   21.878836] systemd[1]: app0.service: Failed with result 'exit-code'.
[   21.905712] systemd[1]: Failed to start app0.service.
```

Follow-up to f201f34477.
2021-11-26 18:15:51 +00:00
Lennart Poettering 9ead418413 test: test new SYSEXT_SCOPE=/PORTABLE_PREFIXES= fields in TEST-29 2021-11-23 22:55:49 +01:00
Frantisek Sumsal f201f34477 test: suppress certain leaks reported by LSan
so we can run TEST-46 under sanitizers once again.

`systemd-homed` runs fsck on home directories, which reports a memory
leak we're not interested in. Let's introduce an LSan suppression file
to get around this. Since the patterns in the suppression file are
matched using basic substring match[0], they're a bit cumbersome, but
should get the work one.

[0] https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions

Example leaks (as reported by TEST-46):
```
systemd-homed[1333]: =================================================================
systemd-homed[1333]: ==1333==ERROR: LeakSanitizer: detected memory leaks
systemd-homed[1333]: Direct leak of 24 byte(s) in 1 object(s) allocated from:
systemd-homed[1333]:     #0 0x7f0c8facccd1 in calloc (/usr/lib/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.so+0xf4cd1)
systemd-homed[1333]:     #1 0x558d9494ff67  (/usr/bin/fsck+0x3f67)
systemd-homed[1333]: Direct leak of 6 byte(s) in 1 object(s) allocated from:
systemd-homed[1333]:     #0 0x7f0c8fa906c1 in strdup (/usr/lib/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.so+0xb86c1)
systemd-homed[1333]:     #1 0x558d949518fd  (/usr/bin/fsck+0x58fd)
systemd-homed[1333]: SUMMARY: AddressSanitizer: 30 byte(s) leaked in 2 allocation(s).
systemd-homed[1337]: ==1337==WARNING: Symbolizer was blocked from starting itself!
systemd-homed[1337]: =================================================================
systemd-homed[1337]: ==1337==ERROR: LeakSanitizer: detected memory leaks
systemd-homed[1337]: Direct leak of 67584 byte(s) in 1 object(s) allocated from:
systemd-homed[1337]:     #0 0x7f01edb84b19  (/usr/lib/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.so+0xf4b19)
systemd-homed[1337]:     #1 0x7f01e8326829  (/usr/bin/../lib/libLLVM-12.so+0xb46829)
systemd-homed[1337]: SUMMARY: AddressSanitizer: 67584 byte(s) leaked in 1 allocation(s).
```

With the suppression file:
```
systemd-homed[1339]: -----------------------------------------------------
systemd-homed[1339]: Suppressions used:
systemd-homed[1339]:   count      bytes template
systemd-homed[1339]:       2         30 /bin/fsck$
systemd-homed[1339]: -----------------------------------------------------
systemd-homed[1343]: ==1343==WARNING: Symbolizer was blocked from starting itself!
systemd-homed[1343]: -----------------------------------------------------
systemd-homed[1343]: Suppressions used:
systemd-homed[1343]:   count      bytes template
systemd-homed[1343]:       1      67584 /lib/libLLVM
systemd-homed[1343]: -----------------------------------------------------
```
2021-11-22 20:52:56 +01:00
Frantisek Sumsal c049acb22e test: fix a couple of "new" shellcheck-related issues
related to https://github.com/koalaman/shellcheck/wiki/SC2295
2021-11-22 20:52:56 +01:00
Frantisek Sumsal e50d743f99 test: support the new lvm udev autoactivation
Introduced in lvm 2.03.14.
See: https://sourceware.org/git/?p=lvm2.git;a=commit;h=67722b312390cdab29c076c912e14bd739c5c0f6
2021-11-01 20:55:38 +01:00
Frantisek Sumsal 35382a9da3 test: merge coverage reports from previous test runs
Relevant mainly for tests which utilize both QEMU and nspawn.
2021-10-25 11:35:47 +02:00
Frantisek Sumsal d2a39812fd test: rename the global service override file for coverage runs
Otherwise we break TEST-15-DROPIN, since it uses
/usr/lib/systemd/system/service.d/override.conf in some of its
sub-tests.
2021-10-23 22:10:24 +02:00
Frantisek Sumsal 035af7adfe test: disable ProtectHome= when collecting coverage as well
Depending on the location of the original build dir, either ProtectHome=
or ProtectSystem= may get in the way when creating the gcov metadata
files.

Follow-up to:
    * 02d7e73013
    * 6c9efba677
2021-10-23 21:27:20 +02:00
Frantisek Sumsal 7a6c5b6ab5 test: make the coverage check safer for non-compiled builds 2021-10-21 18:34:21 +02:00
Frantisek Sumsal 02d7e73013 test: loosen sandbox restrictions for integration tests as well
Otherwise we miss quite a lot of coverage (mainly from logind,
hostnamed, networkd, and possibly others), since they can't write their
reports with `ProtectSystem=strict`.
2021-10-21 18:06:36 +02:00
Frantisek Sumsal 0b5fe54ff5 test: collect coverage in a couple more codepaths
Otherwise we'd miss coverage from TEST-{02,24,61}, since they don't go
through the "standard" `check_result_common` hook.

Follow-up to 7bf20e48bd.
2021-10-20 16:46:58 +01:00
Luca Boccassi c82dc15b9f test: create and merge code coverage reports in integration tests
If -Db_coverage=true is used at build time, then ARTIFACT_DIRECTORY/TEST-XX-FOO.coverage-info
files are created with code coverage data, and run-integration-test.sh also
merges them into ARTIFACT_DIRECTORY/merged.coverage-info since the coveralls.io
helpers accept only a single file.
2021-10-04 16:40:49 +01:00
Zbigniew Jędrzejewski-Szmek 8f5bcd615b licensing: add forgotten spdx headers
Those are all "our" files, but we forgot to add the headers,
most likely because of non-standard file extensions.
2021-10-01 14:45:00 +02:00
Frantisek Sumsal 1c3f490f23 test: shellcheck-ify test scripts 2021-09-30 12:12:00 +02:00
Frantisek Sumsal 7074c047c1 test: explicitly report if we fail to install a file into the image 2021-09-29 10:05:21 +02:00
Frantisek Sumsal f4e64b6e34 test: add an iSCSI helper 2021-09-29 10:05:21 +02:00
Luca Boccassi 3a18c0e5f2
Merge pull request #20806 from fbuihuu/test-make-debug-tools-optional
test: make the installation of the debug tools optional in the image
2021-09-22 12:01:59 +01:00
Franck Bui 9fbb13acbc test: wc is needed by test/units/testsuite-50.sh 2021-09-22 09:04:52 +02:00
Franck Bui f7d47cc862 test: make the installation of the debug tools optional in the image 2021-09-22 08:37:34 +02:00
Luca Boccassi 71a80dcc0b
Merge pull request #20690 from DaanDeMeyer/oomd-user-services
oom: Support for user services
2021-09-21 15:39:48 +01:00
Daan De Meyer 064a5c1438 oom: Add support for user unit ManagedOOM property updates
Compared to PID1 where systemd-oomd has to be the client to PID1
because PID1 is a more privileged process than systemd-oomd, systemd-oomd
is the more privileged process compared to a user manager so we have
user managers be the client whereas systemd-oomd is now the server.

The same varlink protocol is used between user managers and systemd-oomd
to deliver ManagedOOM property updates. systemd-oomd now sets up a varlink
server that user managers connect to to send ManagedOOM property updates.

We also add extra validation to make sure that non-root senders don't
send updates for cgroups they don't own.

The integration test was extended to repeat the chill/bloat test using
a user manager instead of PID1.
2021-09-20 13:53:11 +01:00
Frantisek Sumsal babe935563 test: add a btrfs helper 2021-09-18 20:44:34 +02:00
Frantisek Sumsal 4999f3688f test: add an LVM helper 2021-09-14 19:15:13 +02:00
Frantisek Sumsal e3d9a2e74f test: install dmevent service and socket 2021-09-14 19:15:13 +02:00
Frantisek Sumsal bac05644a7 test: specify the rootfs by label
otherwise the boot might fail when attaching multiple SATA devices to
the VM.
2021-09-14 19:15:13 +02:00
Frantisek Sumsal 9e7c3bd48c test: add a multipath helper 2021-09-12 18:38:42 +02:00
Frantisek Sumsal 39e1753673 test: rename dracut_install to image_install
The `dracut_install` is a misnomer, since the systemd integration test
suite is based on the original dracut's test suite, and not all the
references to dracut has been edited out. Let's fix that.
2021-09-08 22:41:20 +09:00
Franck Bui ce380c2f09 test: make sure to include all haveged unit files
Recent versions of haveged relies on haveged-switch-root.service too.
2021-09-01 20:40:55 +01:00
Yu Watanabe 42867dfeef test-execute: add a testcase for MountAPIVFS=no 2021-08-26 02:54:37 +09:00
Frantisek Sumsal faca95e115 test: make sure test timeout has a higher priority than a pass
otherwise we might mark tests where something crashes during shutdown as
successful, as happened in one of the recent TEST-01-BASIC runs:

```
testsuite-01.service: About to execute rm -f /failed /testok
testsuite-01.service: Forked rm as 606
testsuite-01.service: Executing: rm -f /failed /testoktestsuite-01.service: Changed dead -> start-pre
         Starting TEST-01-BASIC...
...
Child 606 (rm) died (code=exited, status=0/SUCCESS)
testsuite-01.service: Child 606 belongs to testsuite-01.service.
testsuite-01.service: Control process exited, code=exited, status=0/SUCCESS (success)
testsuite-01.service: Got final SIGCHLD for state start-pre.
testsuite-01.service: Passing 0 fds to service
testsuite-01.service: About to execute sh -e -x -c "systemctl --state=failed --no-legend --no-pager >/failed ; systemctl daemon-reload ; echo OK >/testok"
testsuite-01.service: Forked sh as 607
testsuite-01.service: Changed start-pre -> start
testsuite-01.service: Executing: sh -e -x -c "systemctl --state=failed --no-legend --no-pager >/failed ; systemctl daemon-reload ; echo OK >/testok"systemd-journald.service: Got notification message from PID 560 (FDSTORE=1)S
...
testsuite-01.service: Child 607 belongs to testsuite-01.service.
testsuite-01.service: Main process exited, code=exited, status=0/SUCCESS (success)
testsuite-01.service: Deactivated successfully.
testsuite-01.service: Service will not restart (restart setting)
testsuite-01.service: Changed start -> dead
testsuite-01.service: Job 207 testsuite-01.service/start finished, result=done
[  OK  ] Finished TEST-01-BASIC.
...
end.service: About to execute /bin/sh -x -c "systemctl poweroff --no-block"
end.service: Forked /bin/sh as 623end.service: Executing: /bin/sh -x -c "systemctl poweroff --no-block"
...
end.service: Job 213 end.service/start finished, result=canceled
Caught <SEGV>, dumped core as pid 624.
Freezing execution.

CentOS Linux 8
Kernel 4.18.0-305.12.1.el8_4.x86_64 on an x86_64 (ttyS0)

H login: qemu-kvm: terminating on signal 15 from pid 80134 (timeout)
E: Test timed out after 600s
Spawning getter /root/systemd/build/journalctl -o export -D /var/tmp/systemd-test.0UYjAS/root/var/log/journal/ca6031c2491543fe8286c748258df8d1...
Finishing after writing 15125 entries
Spawning getter /root/systemd/build/journalctl -o export -D /var/tmp/systemd-test.0UYjAS/root/var/log/journal/remote...
Finishing after writing 0 entries
-rw-r-----. 1 root root 25165824 Aug 20 12:26 /var/tmp/systemd-test.0UYjAS/system.journal
TEST-01-BASIC RUN: Basic systemd setup [OK]
...
2021-08-21 06:40:25 +09:00
Lennart Poettering dc131951b5
Merge pull request #18385 from kinvolk/mauricio/restrict-network-interfaces
Add RestrictNetworkInterfaces=
2021-08-20 03:41:11 +02:00
Luca Boccassi 468d9bc901
Merge pull request #20436 from fbuihuu/add-no-build-support-on-opensuse
Add no build support on opensuse
2021-08-19 21:11:31 +01:00
Mauricio Vásquez 00d6fceeb3 tests: add integration test for RestrictNetworkInterfaces=
Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
2021-08-19 07:25:01 -05:00
Franck Bui d93857ae09 test: if haveged is part of initrd it needs to be installed in the image too
Otherwise haveged won't survive when switching root from initrd to host making
haveged service in host fail.
2021-08-18 17:37:55 +02:00
Franck Bui 138f761904 test: adapt install_pam() for openSUSE
On openSUSE the default pam config files are shipped in /usr/etc/pam.d.

Also empty password is not allowed by default.
2021-08-18 17:37:55 +02:00
Franck Bui dfd73ccb14 test: don't try to find BUILD_DIR when NO_BUILD is set
NO_BUILD=1 indicates that we want to test systemd from the local system and not
the one from the local build. Hence there should be no need to call
find-build-dir.sh when NO_BUID=1 especially since it's likely that the script
will fail to find a local build in this case.

This avoids find-build-dir.sh to emit 'Specify build directory with $BUILD_DIR'
message when NO_BUILD=1 and no local build can be found.

This introduces a behavior change though: systemd from the local system will
always be preferred when NO_BUILD=1 even if a local build can be found.
2021-08-18 17:37:55 +02:00
Franck Bui abf062674e test: add support for NO_BUILD=1 on openSUSE 2021-08-18 17:37:24 +02:00
Luca Boccassi 9a4b883be2 extension-release: search for other files if expected name not found
In some cases image names are unpredictable - some orchestrators/deployment
tools like to mangle names to suit their internal formats. In these cases,
the requirement that the extension-release file matches exactly the image
name where it's contained cannot work.

Allow falling back to loading the first regular file which name starts with
'extension-release' located in /usr/lib/extension-release.d/ and tagged with
a user.extension-release.strict extended attribute with a true value, if the
one with the expected name cannot be found.
2021-08-17 13:04:44 +01:00
Frantisek Sumsal 46db176f8c test: use a correct kernel binary on ppc64le machines
Ubuntu calls the kernel binary as `vmlinux-*`, but RHEL/CentOS uses
the "standard" `vmlinuz-` prefix.

Follow-up to eaa602cb14.
2021-08-09 22:12:18 +01:00
Zbigniew Jędrzejewski-Szmek 4f11590f9b
Merge pull request #20399 from mrc0mmand/test-tweaks
test: yet another fix for ASan detection
2021-08-09 10:06:23 +02:00
Frantisek Sumsal 6476676b84 test: skip a harmless ldd error when installing test libs
Skip a harmless error when running the tests on a system with a significantly
older systemd version (ldd tries to resolve the unprefixed RPATH for libsystemd.so.0,
which is in this case older than the already installed libsystemd.so.0 in $initdir).
The issue is triggered by installing test dependencies in install_missing_libraries().

Spotted on CentOS 8.

```
$ ldd /var/tmp/systemd-test.nZO11F/root/lib/systemd/tests/test-sd-device-thread
/var/tmp/systemd-test.nZO11F/root/lib/systemd/tests/test-sd-device-thread: /lib64/libsystemd.so.0: version `LIBSYSTEMD_240' not found (required by /var/tmp/systemd-test.nZO11F/root/lib/systemd/tests/test-sd-device-thread)
        linux-vdso64.so.1 (0x00007fffb79d0000)
        libclang_rt.asan-powerpc64le.so => /usr/lib64/clang/11.0.0/lib/linux/libclang_rt.asan-powerpc64le.so (0x00007fffb6ef0000)
        libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007fffb6d20000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fffb6cd0000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fffb6ab0000)

$ LD_LIBRARY_PATH=/var/tmp/systemd-test.nZO11F/root/lib64/ ldd /var/tmp/systemd-test.nZO11F/root/lib/systemd/tests/test-sd-device-thread
        linux-vdso64.so.1 (0x00007fffaba80000)
        libclang_rt.asan-powerpc64le.so => /usr/lib64/clang/11.0.0/lib/linux/libclang_rt.asan-powerpc64le.so (0x00007fffaafa0000)
        libsystemd.so.0 => /var/tmp/systemd-test.nZO11F/root/lib64/libsystemd.so.0 (0x00007fffaa5f0000)
        libpthread.so.0 => /var/tmp/systemd-test.nZO11F/root/lib64/libpthread.so.0 (0x00007fffaa5a0000)
        libc.so.6 => /var/tmp/systemd-test.nZO11F/root/lib64/libc.so.6 (0x00007fffaa380000)

```
2021-08-09 10:04:40 +02:00
Frantisek Sumsal 25e399948b test: make busybox TEST-13-only dependency
to make running other tests a bit easier on distributions which don't have
busybox in repositories (CentOS).
2021-08-08 19:43:23 +02:00
Frantisek Sumsal 2d50e3c7bc test: yet another fix for ASan detection
This time for ppc64le:

```
100737c4:	5d 55 f9 4b 	bl      10008d20 <00000024.plt_call.__asan_report_load8>
100737f4:	4d 55 f9 4b 	bl      10008d40 <00000024.plt_call.__asan_handle_no_return>
10073884:	5d 50 f9 4b 	bl      100088e0 <00000024.plt_call.__asan_init>
1007388c:	75 54 f9 4b 	bl      10008d00 <00000024.plt_call.__asan_version_mismatch_check_v8>
100738a0:	41 36 f9 4b 	bl      10006ee0 <00000024.plt_call.__asan_register_globals>
100738f0:	71 4c f9 4b 	bl      10008560 <00000024.plt_call.__asan_unregister_globals>
```
2021-08-08 19:33:10 +02:00
Frantisek Sumsal 84817bfdb3 test: attempt to install only kernel modules for each subsystem
When `linux-headers` is installed on Arch Linux, it stores the module
source tree in the kernel module directory, which is then picked up by
`find` and we get a lot of harmless but annoying errors:

```
...
modprobe: FATAL: Module Kconfig.iosched not found in directory /lib/modules/5.13.7-arch1-1
modprobe: FATAL: Module Kconfig not found in directory /lib/modules/5.13.7-arch1-1
modprobe: FATAL: Module Kconfig not found in directory /lib/modules/5.13.7-arch1-1
modprobe: FATAL: Module dm-mpath.h not found in directory /lib/modules/5.13.7-arch1-1
modprobe: FATAL: Module dm-bio-prison-v2.h not found in directory /lib/modules/5.13.7-arch1-1
modprobe: FATAL: Module raid0.h not found in directory /lib/modules/5.13.7-arch1-1
...
```

Let's fix this by trying to install only kernel modules (*.ko files with
an optional compression).
2021-08-08 16:06:41 +01:00
Frantisek Sumsal 8bf79f0553 test: correctly detect ASan on s390x
s390x uses BRAS(L) instead of CALL(Q), e.g.:

```
 1009528:	c0 e5 ff ff f8 a0 	brasl	%r14,1008668 <__asan_report_load1@plt>
 10095f0:	c0 e5 ff ff ea ec 	brasl	%r14,1006bc8 <__asan_stack_malloc_4@plt>
 10097f8:	c0 e5 ff ff f8 f8 	brasl	%r14,10089e8 <__asan_report_load8@plt>
```

x86_64 for reference:

```
  4011f3:	e8 48 fe ff ff       	callq  401040 <__asan_report_load1@plt>
  401227:	e8 24 fe ff ff       	callq  401050 <__asan_report_load8@plt>
  401251:	e8 da fd ff ff       	callq  401030 <__asan_init@plt>
```
2021-07-29 23:59:08 +01:00
Frantisek Sumsal eca81d0792 test: don't explicitly disable SELinux
We don't install any policies by default, so it shouldn't interfere with
anything (and it would save me some headache).
2021-07-14 20:27:23 +02:00
Frantisek Sumsal e68e473ba2 test: strip binaries by default
Since 23f8e01 we always kept binaries unstripped, since $STRIP_BINARIES
is unset by default.
2021-07-09 14:59:11 +02:00