Commit graph

147 commits

Author SHA1 Message Date
Evgeny Vereshchagin 038bf640e9 tests: bump up QEMU_MEM 2019-07-16 15:01:26 +00:00
Evgeny Vereshchagin 869250e6b8
Merge pull request #12992 from mrc0mmand/test-functions-fixes
Various test/test-functions fixes/improvements
2019-07-09 02:27:39 +03:00
Frantisek Sumsal 71a0de36e5 test: be a little bit more verbose when installing service binaries 2019-07-08 21:10:21 +02:00
Frantisek Sumsal 3cdb93d07b test: correctly handle installation of newly introduced binaries
In certain cases we might attempt to install a binary which is already
present in the test image, yet it's missing from the host system.
In such cases, let's check if the binary indeed exists in the image
before doing any other chcecks. If it does, immediately return with
success.

This was discovered during installation of
/usr/lib/systemd/systemd-bless-boot, which was not present in Ubuntu CI
(as the installed systemd was from the Ubuntu repositories), and the
binary itself was already in the image thanks to `ninja install`.
However, during extraction of binaries from the systemd service files,
another attempt to install this binary was made, which failed due to
`find_binary` being unable to find it.
2019-07-08 21:05:51 +02:00
Frantisek Sumsal f5f8cc7aed test: make ASAN/UBSAN_OPTIONS overridable from the outside
This should allow us to tweak the ASAN_OPTIONS and UBSAN_OPTIONS env
variables for integration tests as well
2019-07-09 02:00:14 +09:00
Frantisek Sumsal 37ee8dc80f test: improve handling of ASan under clang
Running integration tests with ASan is somewhat tricky to begin with, as
we need to pre-load the ASan runtime DSO for certain services (like
dbus), otherwise they won't start or behave as expected. In case of gcc
this is pretty easy, as we need the runtime DSO during compilation, so
it's already present on the host system. For clang things get more
complicated, as ASan is compiled in statically by default, thus to
enable the necessary dynamic-ish behavior one needs to compile with
-shared-libasan and then correctly set LD_PRELOAD_PATH, as the runtime
libraries are not in a standard library path.
2019-05-27 17:46:07 +02:00
Zbigniew Jędrzejewski-Szmek 9e099c9fd8
Merge pull request #12431 from poettering/tmpfiles-chmod-chown-order
tmpfiles: run chown() before chmod()
2019-05-22 17:23:28 +02:00
Zbigniew Jędrzejewski-Szmek 95cff2a794 test: search $BOOT for kernel+initrd
$BOOT is the preferred location for kernel images. If $BOOT does not
exist, -x will print the path to ESP, so well fall back to previous
behaviour.
2019-05-19 12:05:21 +02:00
Evgeny Vereshchagin a5372344ea tests: override a hard-coded timeout that kicks in too early (under ASan+UBSan)
The test has failed two times today: https://travis-ci.org/systemd/systemd/jobs/530750626
and https://travis-ci.org/systemd/systemd/jobs/530759465.
2019-05-12 03:37:36 +02:00
Evgeny Vereshchagin 6141c6c99b tests: redirect the stdout/stderr of journald to a file (under ASan+UBSan)
Sometimes UBSan sends its reports to stderr regardless of what is specified in log_path
Let's try to catch them by redirecting stderr (and stdout just in case) to a file
See https://github.com/systemd/systemd/pull/12524#issuecomment-491108821
2019-05-12 03:37:36 +02:00
Evgeny Vereshchagin abf9b52ccd tests: redirect UBsan reports to a file
so that they won't end up in /dev/null
2019-05-12 03:37:36 +02:00
Frantisek Sumsal 54a3790ccb test: allow SKIP_INITRD override
Certain distributions (e.g. Arch Linux) require booting with initrd, as
they lack support for commonly used filesystems in the kernel (i.e. the
support is compiled in as modules)
2019-05-09 20:11:31 +02:00
Frantisek Sumsal aaef1ed21d test: don't preload libasan for systemd-remount-fs.service
The `mount` utility has an unexpected behavior when run with libasan,
causing false-positives during the integration testing.

For example, on Arch Linux with LD_PRELOAD pointing to libasan:
```
bash-5.0# mount -o remount,rw -v /
mount: /dev/sda1 mounted on /.
bash-5.0# echo $?
1
```
However:
```
bash-5.0# LD_PRELOAD= mount -o remount,rw -v /
mount: /dev/sda1 mounted on /.
bash-5.0# echo $?
0
```
Further investigation with strace shows a LeakSanitizer error:
```
bash-5.0# strace -s 512 mount -o remount,rw -v /
...
write(2, "==355==LeakSanitizer has encountered a fatal error.\n", 52) = -1 EBADF (Bad file descriptor)
write(2, "ReportFile::Write() can't output requested buffer!\n", 51) = -1 EBADF (Bad file descriptor)
exit_group(1)                           = ?
+++ exited with 1 +++
```

Let's workaround this by clearing the LD_PRELOAD variable for
systemd-remount-fs.service
2019-05-09 20:11:20 +02:00
Lennart Poettering 908665f4e9 test-functions: follow fedora dbus-daemon/dbus-broker rearrangements
Apparently dbus.service is now a symlink to either dbus-broker.service
or dbus-daemon.service. Copy in the right target service in each case.
2019-04-30 09:18:23 +02:00
Zbigniew Jędrzejewski-Szmek cc5549ca12 scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)

Also remove the few vim config lines that were left. We should either have them
on all files, or none.

Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-12 08:30:31 +02:00
Zbigniew Jędrzejewski-Szmek 408c9a07e5 test: filter out messages when stripping binaries
We would get an error for every script, which is just noise.
2019-04-12 08:23:41 +02:00
Frantisek Sumsal b43c2c01e9 test: allow overriding of the KVM detection using TEST_NO_KVM
By default the run_qemu() function enables KVM automatically
if it detects the /dev/kvm char device and if the machine is not
already a KVM one. Let's add a TEST_NO_KVM env variable to suppress
this detection.
2019-03-16 18:59:07 +01:00
Frantisek Sumsal c81a46b904 test: introduce INTERACTIVE_DEBUG
Make the interactive debugging of (particularly QEMU) machines less
painful, by replacing the default vt220 TERM with linux one, and
by not shutting down the machine after running the test itself.
2019-03-16 18:59:01 +01:00
Frantisek Sumsal 6d67286fc3 test: unify indentation 2019-03-16 15:49:43 +01:00
Lennart Poettering 9bbd37845c
Merge pull request #11988 from keszybz/test-binaries-installation
Install more requires binaries for tests
2019-03-15 13:06:11 +01:00
Frantisek Sumsal 32983312ed test: bump the second partition size to 50MB
10MB is not enough for a LUKS2 partition.
2019-03-15 06:12:23 +01:00
Zbigniew Jędrzejewski-Szmek 98b0439f08 tests: install /usr/bin/dbus-broker when using dbus-broker
We'd install the service file, and then dbus-broker-launcher because it is
mentioned in ExecStart=, but not the main executable, so nothing would work.
Let's just install dbus-broker executables if found. They are small, so this
doesn't matter much, and is much easier than figuring the exact conditions
under which dbus-broker will be used instead of dbus-daemon.
2019-03-14 15:52:38 +01:00
Frantisek Sumsal 0ae4456c93 test: avoid double-fsck'ing of the rootfs on Arch
Since systemd 206 the combination of systemd and mkinitcpio
causes, under certain conditions, the rootfs to be double fsck'd.

Symptoms:
```
:: performing fsck on '/dev/sda1'
systemd: clean, 3523/125488 files, 141738/501760 blocks
********************** WARNING **********************
*                                                   *
*  The root device is not configured to be mounted  *
*  read-write! It may be fsck'd again later.        *
*                                                   *
*****************************************************
<snip>
[  OK  ] Started File System Check on Root Device
```

This occurs when neither 'ro' or 'rw', or only 'ro' is present
on the kernel command line. The solution is to mount the roofs
as read-write on the kernel command line, so systemd knows to not fsck
it again.
2019-03-13 17:05:31 +01:00
Zbigniew Jędrzejewski-Szmek 1e46047066 tests: install "head" in the image
For #11915.
2019-03-13 16:35:23 +01:00
Frantisek Sumsal 3f50fff536 test: don't overwrite TESTDIR if already set 2019-03-13 10:30:25 +01:00
Frantisek Sumsal 5bfb2a93a4 test: try to determine QEMU_SMP dynamically
If the QEMU_SMP value has not been explicitly set, try to determine it
from the number of online CPUs using the nproc utility. If this approach
fails, fall back to the default value QEMU_SMP=1.

This change should significantly help when running integration tests
under QEMU on multicore systems.
2019-03-08 21:28:26 +01:00
Taro Yamada 19632f6dbb test: (ArchLinux) Replace initramfs-linux.img with initramfs-linux-fallback.img.
Currently /boot/initramfs-linux.img is used as the default initrd for ArchLinux.
Although, since the kernel modules that are not necessary for the host  environment are removed from
initramfs-linux.img by mkinitcpio 's autodetect hook, the kernel modules necessary for qemu may be missing.
(ata_piix, ext4, and so on in my case.)
As a result, the test environment may not be built properly and the test will be failed.

initramfs-linux-fallback.img will skip this autodetect hook, so the test will run successfully in more
environments.

Both initramfs-linux.img and initramfs-linux-fallback.img are generated by default.
2019-02-02 12:45:51 +01:00
Evgeny Vereshchagin a19f909b5b tests: crash PID1 if UBSan is unhappy
Now that https://github.com/systemd/systemd/issues/10332 is unlikely to happen
it should be totally fine to try to crash PID1 :-)
2019-01-30 03:16:14 +01:00
Evgeny Vereshchagin d56db495de tests: ignore memory leaks in dbus-daemon
Otherwise, the test fails on Fedora 28 with
```
Jan 30 01:42:35 systemd-testsuite dbus-daemon[61]: [system] Successfully activated service 'org.freedesktop.systemd1'
Jan 30 01:42:35 systemd-testsuite systemd[61]: dbus.service: Kernel keyring access prohibited, ignoring.
Jan 30 01:42:35 systemd-testsuite systemd[61]: dbus.service: Executing: /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]: =================================================================
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]: ==61==ERROR: LeakSanitizer: detected memory leaks
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]: Direct leak of 72 byte(s) in 1 object(s) allocated from:
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]:     #0 0x7f21f9e29088 in __interceptor_realloc (/usr/lib64/libasan.so.5+0xef088)
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]:     #1 0x7f21f9b1b23c  (/lib64/libdbus-1.so.3+0x3323c)
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]:     #2 0x240000001b  (<unknown module>)
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]: Direct leak of 16 byte(s) in 1 object(s) allocated from:
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]:     #0 0x7f21f9e29088 in __interceptor_realloc (/usr/lib64/libasan.so.5+0xef088)
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]:     #1 0x7f21f9b1b23c  (/lib64/libdbus-1.so.3+0x3323c)
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]:     #2 0x7ffffffff  (<unknown module>)
Jan 30 01:42:50 systemd-testsuite dbus-daemon[61]: SUMMARY: AddressSanitizer: 88 byte(s) leaked in 2 allocation(s).
```

The leaks were reported and fixed in https://bugs.freedesktop.org/show_bug.cgi?id=107320.
2019-01-30 02:28:40 +01:00
Dimitri John Ledkov 9a2e265bb0
test/test-functions: on PPC64 use hvc0 console 2019-01-26 00:21:08 +00:00
Dimitri John Ledkov eaa602cb14
test/test-functions: on PP64 use vmlinux
At least on Ubuntu, ppc64el uses vmlinux-, not vmlinuz. With this, it should be
possible to run qemu tests on ppc64el as part of Ubuntu autopkgtests.
2019-01-26 00:21:07 +00:00
Frantisek Sumsal e4e039bce4 test: mark plymouth as optional dependency
rescue.service pulls in /bin/plymouth, which doesn't exist on some
distributions (e.g. Arch Linux). Let's mark it as optional, as it's not
even required by the referencing unit and causes unwanted fails in the
integration testsuite.
2019-01-21 11:35:24 +01:00
Frantisek Sumsal d7283fc157 test: limit environments for systemd-hwdb-update under ASan 2019-01-12 11:44:39 +01:00
Frantisek Sumsal 5b2172ee50 test: bump QEMU_SMP to 4 when running under ASan/UBSan 2019-01-12 11:38:21 +01:00
Frantisek Sumsal 670bec2b07 test: bump QEMU memory to 1536M when running under ASan/UBSan 2019-01-12 11:38:21 +01:00
Frantisek Sumsal 3071b3ff6e test: introduce QEMU_MEM
Some tests (mainly under ASan/UBSan) require more than 512M of memory,
so let's make it configurable (but still default to 512M).
2019-01-11 16:23:53 +01:00
Evgeny Vereshchagin 0d6e61d6a1 tests: introduce check_asan_reports and use it in check_result_{qemu|nspawn} 2018-12-29 19:14:35 +01:00
Evgeny Vereshchagin ed4f303f39 tests: look for ASan+UBSan reports in the journal 2018-12-29 19:14:35 +01:00
Evgeny Vereshchagin 9688fccc27 tests: double DefaultTimeoutStartSec when systemd is run under ASan+UBSan 2018-12-29 19:14:35 +01:00
Evgeny Vereshchagin 082bcdca2c tests: overwrite a hard-coded timeout in systemd-hwdb-update.service 2018-12-29 19:14:35 +01:00
Evgeny Vereshchagin 998445fd8a tests: fail if asan has found issues in journald 2018-12-29 19:14:35 +01:00
Evgeny Vereshchagin 7e11a95e41 tests: reproduce https://github.com/systemd/systemd/issues/11251 2018-12-29 19:14:28 +01:00
Evgeny Vereshchagin b4a450d85f tests: use systemd-journald to check whether everything has been built with ASan 2018-12-24 08:52:33 +01:00
Frantisek Sumsal a978c9f292 tests: dbus.service was renamed to dbus-daemon.service in Rawhide
Fedora Rawhide renamed dbus.service to dbus-daemon.service - that
breaks tests which require working DBus (e.g. TEST-03-JOBS)

Excerpt from the dbus.spec:
The 'dbus' package is only retained for compatibility purposes. It will
eventually be removed and then replaced by 'Provides: dbus' in the
dbus-daemon package. It will then exclusively be used for other packages to
describe their dependency on a system and user bus. It does not pull in any
particular dbus *implementation*, nor any libraries. These should be pulled
in, if required, via explicit dependencies.
2018-11-12 19:16:55 +01:00
Evgeny Vereshchagin 20fc56c02d tests: allow passing log_level via an environment variable (#10490) 2018-10-23 16:09:23 +09:00
Evgeny Vereshchagin 2614d83aa0 tests: pass halt_on_error=1 to UBSan
By default, UBSan neither crashes nor exits with a non-zero exit code
when undefined behavior has been detected. This is problematic because
it makes it much harder to catch issues like https://github.com/systemd/systemd/issues/10346,
 https://github.com/systemd/systemd/issues/10347, and https://github.com/systemd/systemd/issues/10333.
In fact, those issue were found just because I decided to grep
the test log, which isn't something that I normally do :-)

As it turns out, the only way to make UBSan signal that something is wrong that works more or less
reliably everywhere is to pass halt_on_error=1 (though, it's probably worth noting that it's currently
not set for PID1 in order not to trigger kernel panics).

See https://reviews.llvm.org/D35085#804183 and https://chromium.googlesource.com/chromium/src/testing/libfuzzer/+/HEAD/reference.md
2018-10-11 08:55:04 +02:00
Yu Watanabe 0013fac248 test: do not use global variable to pass error 2018-10-09 19:11:21 +09:00
Yu Watanabe ad931fee50 test: make install_keymaps() optionally install more keymaps 2018-10-09 19:11:21 +09:00
Yu Watanabe 83a7051ee1 test: add paths of keymaps in install_keymaps()
It seems that the paths of directories storing keymaps are changed.
2018-10-09 19:11:21 +09:00
Yu Watanabe 7d10ec1cda test: introduce install_zoneinfo()
But it is not called by default.
2018-10-09 19:11:21 +09:00