Commit graph

301 commits

Author SHA1 Message Date
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
Frantisek Sumsal a33e2692e1 test: avoid using pipes in certain cases
`command -v <bin> | grep ...` can under certain conditions cause the
`command` to exit with SIGPIPE, which in combination with `set -o
pipefail` means that the tests sometimes randomly die during setup.
Let's avoid using pipes in such cases.
2021-04-16 19:05:42 +02:00
Frantisek Sumsal 96af59aabb test: use set -o pipefail
This breaks some existing loops which previously ignored if the piped
program exited with EC >0. Rewrite them to mitigate this (and also make
them more robust in some cases).
2021-04-16 19:05:37 +02:00
Frantisek Sumsal 1b8fcd9c63 test: shell code cleanup
Just some basic stuff, like double quotes around strings, using
predictable values for possibly unset variables, formatting, etc.
2021-04-16 18:49:37 +02:00
Zbigniew Jędrzejewski-Szmek 0ee994836c TEST-*: use spacing before redirection operator, but not after
<< EOF → <<EOF
> foo < bar → >foo <bar
2021-04-08 20:21:50 +02:00
Zbigniew Jędrzejewski-Szmek 129cb6e249 shared/calendarspec: when mktime() moves us backwards, jump forward
When trying to calculate the next firing of 'Sun *-*-* 01:00:00', we'd fall
into an infinite loop, because mktime() moves us "backwards":

Before this patch:
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
...

We rely on mktime() normalizing the time. The man page does not say that it'll
move the time forward, but our algorithm relies on this. So let's catch this
case explicitly.

With this patch:
$ TZ=Europe/Dublin faketime 2021-03-21 build/systemd-analyze calendar --iterations=5 'Sun *-*-* 01:00:00'
Normalized form: Sun *-*-* 01:00:00
    Next elapse: Sun 2021-03-21 01:00:00 GMT
       (in UTC): Sun 2021-03-21 01:00:00 UTC
       From now: 59min left
       Iter. #2: Sun 2021-04-04 01:00:00 IST
       (in UTC): Sun 2021-04-04 00:00:00 UTC
       From now: 1 weeks 6 days left           <---- note the 2 week jump here
       Iter. #3: Sun 2021-04-11 01:00:00 IST
       (in UTC): Sun 2021-04-11 00:00:00 UTC
       From now: 2 weeks 6 days left
       Iter. #4: Sun 2021-04-18 01:00:00 IST
       (in UTC): Sun 2021-04-18 00:00:00 UTC
       From now: 3 weeks 6 days left
       Iter. #5: Sun 2021-04-25 01:00:00 IST
       (in UTC): Sun 2021-04-25 00:00:00 UTC
       From now: 1 months 4 days left

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1941335.
2021-03-23 00:35:02 +01:00
Frantisek Sumsal 5acfe54e98 test: fix permissions of the ASan udev workaround
otherwise udev complains about the file being world-writable:
systemd-udevd[228]: Configuration file /etc/udev/rules.d/00-set-LD_PRELOAD.rules is marked world-writable. Please remove world writability permission bits. Proceeding anyway.

Fixes: systemd/systemd-centos-ci#354
2021-03-11 00:28:13 +09:00
Frantisek Sumsal 9f6235e1b4 test: fix TEST-50-DISSECT under sanitizers
This test would normally get stuck when trying to mount the verity image
due to:

systemd-udevd[299]: dm-0: '/usr/sbin/dmsetup udevflags 6293812'(err) '==371==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.'
systemd-udevd[299]: dm-0: Process '/usr/sbin/dmsetup udevflags 6293812' failed with exit code 1
...
systemd-udevd[299]: dm-0: '/usr/sbin/dmsetup udevcomplete 6293812'(err) '==372==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.'
systemd-udevd[299]: dm-0: Process '/usr/sbin/dmsetup udevcomplete 6293812' failed with exit code 1.
systemd-udevd[299]: dm-0: Command "/usr/sbin/dmsetup udevcomplete 6293812" returned 1 (error), ignoring.

so let's add a simple udev rule which sets $LD_PRELOAD for the block
subsystem.

Also, install the ASan library along with necessary dependencies into
the verity minimal image, to get rid of the annoying (yet harmless)
errors about missing library from $LD_LIBRARY.
2021-03-06 22:44:00 +01:00
Frantisek Sumsal 648fd18924 test: tidy up the ASan-related stuff 2021-03-06 22:43:58 +01:00
Frantisek Sumsal 3b5fc147d6 test: disable at_exit LSan check for dbus.service
When running integration tests under sanitizers D-Bus fails to
shutdown cleanly, causing unnecessary noise in the logs:

```
dbus-daemon[272]: ==272==LeakSanitizer has encountered a fatal error.
dbus-daemon[272]: ==272==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
dbus-daemon[272]: ==272==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
```

Since we're not "sanitizing" D-Bus anyway let's disable LSan's at_exit
check for the dbus.service to get rid of this error.
2021-03-06 11:27:04 +09:00
Luca Boccassi 93f597013a Add ExtensionImages directive to form overlays
Add support for overlaying images for services on top of their
root fs, using a read-only overlay.
2021-02-23 15:34:46 +00:00
Luca Boccassi 0761da386a test: avoid leaking open loop devices
When a subshell is used ('make' or 'make all') the LOOPDEV environment
variable, which is used to store the opened loop device, is lost.
So the cleanup on trap/exit doesn't do anything, and the loop
device used to mount the test image is left around.

Avoid using a subshell to fix the issue.
2021-02-17 18:55:05 +01:00
Luca Boccassi 7eba0c50f5 test: install binaries from local d/control file
The source package in the apt cache might be older than the
packaging from salsa.debian.org/systemd-team/systemd so it might not
list all the current binary packages.
This is currently the case for systemd-timesyncd, so TEST-30 fails.

Simply grep the control file rather than using apt-cache when iterating
over the packages contents.
2021-02-15 10:17:39 +01:00
Zbigniew Jędrzejewski-Szmek b3c57df0f5
Merge pull request #18401 from anitazha/oomdxattr
oomd: implement avoid/omit support for cgroups
2021-02-13 10:00:31 +01:00