Commit graph

314 commits

Author SHA1 Message Date
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
Frantisek Sumsal 23f8e01912 test: unify handling of boolean values
Let's unify handling of the boolean values throughout the test-functions
code, since we use 0/1, true/false, and yes/no almost randomly in many
places, so picking the right values during CI configuration can be a real
pain.
2021-07-04 21:12:39 +01:00
Dan Streetman d3b8e38409 test: optionally, only save test journal for failing tests
Saving the journal for passing tests creates a huge amount of unneeded
data stored for each full test run. Add a env var to allow saving the
journal only for failed tests.
2021-07-03 10:48:31 +01:00
Frantisek Sumsal eb70d9450c test: correctly mask supporting services in tests, take #2
Due to a little misunderstanding the last patch doesn't work as
expected, since test_create_image() is called only for the first image
(usually TEST-01-BASIC), and all subsequent images are then (possibly)
modified with test_append_files().

Follow-up to 179ca4d2b1.
2021-06-24 16:26:19 +01:00
Yu Watanabe b905f3bbba
Merge pull request #19990 from mrc0mmand/test-tweaks
A couple of stability-related test tweaks
2021-06-23 01:45:04 +09:00
Frantisek Sumsal 179ca4d2b1 test: correctly mask supporting services in tests
It turns out the "supporting services" were run in _all_ tests if
TEST-01-BASIC was run as the first test (which is usually the case),
since with the original condition in test_create_image() we would skip
the masking and then propagate the change to the default image used by
other tests. This has been causing multiple bogus test timeouts
(especially when the hwdb was being rebuilt in tests with short
timeouts, like TEST-52-HONORFIRSTSHUTDOWN).

Let's "fix" this by making the call to mask_supporting_services()
uncoditional and override the test_create_image() function in
TEST-01-BASIC to avoid the masking in this single case.
2021-06-22 12:34:31 +02:00
Luca Boccassi fa1fdd3099 test: move custom result checks from TEST-02-UNITTESTS to test-functions 2021-06-21 20:45:56 +01:00
Luca Boccassi 35cde9e935 test: install nls modules, required by vfat
kernel: FAT-fs (loop0p2): codepage cp437 not found
kernel: FAT-fs (loop0p2): IO charset ascii not found
2021-06-21 19:47:38 +01:00
Frantisek Sumsal 29bff80b5c test: drop the mawk-incompatible expression
The three-argument match() is a GNU AWK extension, thus breaking the
compatibility with mawk (used on Ubuntu/Debian, for example). Let's
replace it with a (hopefully) more portable sed expression to drop the
inadvertently introduced gawk dependency.

Fixes: #19957
2021-06-17 21:44:32 +01:00
Luca Boccassi 63878c52be test: do not run 'meson configure' if NO_BUILD is set
There is no build tree and packages are used, so it cannot work. Unlikely
that static linking has been set for those builds anyway.

Fixes https://github.com/systemd/systemd/issues/19955
2021-06-17 17:21:17 +09:00
Frantisek Sumsal e7848266da test: add a testcase for issue #19895 2021-06-15 23:18:06 +01:00
Zbigniew Jędrzejewski-Szmek dce95d0b15 test/TEST-17-UDEV: use default image
No need to build a separate 700MB image to save 3080 bytes in the default image.
2021-06-12 11:19:04 +02:00
Luca Boccassi c5fd89adcd core: make libbpf a dlopen() dependency 2021-05-25 12:59:26 +01:00
Yu Watanabe a83a7d1e9e test: drop default ACL from $TESTDIR
This fixes an issue introduced by the commit 954c77c251.

For some reasons, setting default ACL on $TESTDIR makes TEST-29-PORTABLE
fail. Let's drop the default ACL, and set ACL on saved results instead.

Fixes #19519.
2021-05-06 11:28:00 +02:00
Yu Watanabe 853401a6bc test: increase image size when static library or standalone binaries are installed 2021-05-06 11:28:00 +02:00
Zbigniew Jędrzejewski-Szmek b086a89695
Merge pull request #19453 from keszybz/consider-instance-aliases
Consider instance aliases
2021-05-05 11:23:42 +02:00
Zbigniew Jędrzejewski-Szmek ea0d33e2af tests: use "H" as the hostname
"systemd-testsuite" gets in the way when grepping for "testsuite-*.sh".
Also, the name doesn't matter for anything, so let's just use something
very short to save space.
2021-05-05 11:04:59 +02:00
Zbigniew Jędrzejewski-Szmek c0d4409219 test: properly catch tests error with no /testok or empty /failed
When editing this function in 7bf20e48bd, I couldn't
decide whether to initialize ret at the top and only reset it on success, or
whether to assign a value in each branch. In the end I did neither ;( So if the
test finished without creating any of the result files, we would echo a
message, but return "success".

But there was bigger confusion with /failed: some tests create it empty, some
don't. I think we may want to do away pre-creation of /failed completely, and
assume the test failed unless /testok is found. But I'm leaving that for later
rework. For now let's just make sure we report return success only if /testok
or /skipped is found.
2021-05-04 13:36:05 +02:00
Yu Watanabe 7afc8abdf3
Merge pull request #19487 from mrc0mmand/test-all-services-in-TEST-01
test: don't mask "supporting" services in TEST-01-BASIC
2021-05-03 12:15:29 +09:00
Frantisek Sumsal d49b881eaf test: fix a yet another pipefail + pipe race
Basically the same scenario as in
a33e2692e1, where `awk` exits as soon
as it finds a match, thus sending SIGPIPE to `ldd` if it's not fast
enough. That, in combination with `set -o pipefail` causes random &
unexpected fails, like:

```
No journal files were found.
-rw-r----- 1 root root 16777216 Apr 30 10:31
/var/tmp/TEST-01-BASIC_sanitizers-nspawn/system.journal
TEST-01-BASIC RUN: Basic systemd setup [OK]
systemd is not linked against the ASan DSO
gcc does this by default, for clang compile with -shared-libasan
make: *** [Makefile:2: clean-again] Error 1
make: Leaving directory '/build/test/TEST-01-BASIC'
```
2021-05-01 15:05:16 +09:00
Frantisek Sumsal 7776b22521 test: don't mask "supporting" services in TEST-01-BASIC
This got lost during one of the code de-duplication attempts.
2021-04-30 21:02:41 +02:00
Frantisek Sumsal 6695c41c31 test: add a couple of hooks for the check_result_*() functions
So we don't have to duplicate the whole functions if we need to inject
some test-specific checks.
2021-04-26 19:24:41 +02:00
Frantisek Sumsal c4cd6205e0 test: "detect" the test number automagically
Specifying the test number manually is tedious and prone to errors (as
recently proven). Since we have all the necessary data to work out the
test number, let's do it automagically.
2021-04-26 19:20:18 +02:00
Frantisek Sumsal 732a487fad
Merge pull request #19383 from keszybz/test58-fixes
Fixes for TEST-58-REPART and ExecStart deserialization logic
2021-04-26 19:16:44 +02:00
Zbigniew Jędrzejewski-Szmek 954c77c251 tests: use setfacl to give $SUDO_USER read permissions on artifacts
We have to invoke the tests as superuser, and not being able to read
the journal as the invoking user is annoying. I don't think there are
any security considerations here, since the invoking user can already
put arbitrary code in the Makefile and test scripts which get executed
with root privileges.
2021-04-23 20:19:09 +02:00
Zbigniew Jędrzejewski-Szmek 7bf20e48bd test: move the logic to support /skipped into shared logic
The logic to query test state was rather complex. I don't quite grok the point
of ret=$((ret+1))… But afaics, the precise result was always ignored by the
caller anyway.
2021-04-23 15:12:35 +02:00
Zbigniew Jędrzejewski-Szmek 0dd77c159a tests: install mkfs.ext4, mkfs.vfat and modules into the test image
This allows TEST-58-REPART to at least start. It fails later with with loopback
device errors.
2021-04-23 15:11:38 +02:00
Frantisek Sumsal 94009c27f4 test: rewrite kernel module handling
This code was partially broken, since the firmware directory was
undefined. Also, some of the parts were a dead code, since they relied
on code from the original dracut test suite.
2021-04-16 19:05:59 +02:00
Frantisek Sumsal 0f1947059b test: use arrays when applicable 2021-04-16 19:05:55 +02:00