Commit Graph

189 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 70ce817ccb test: de-duplicate test_setup() functions
Now we will run setup_nspawn_root() in some case where do don't need to.
2020-03-28 11:51:11 +01:00
Zbigniew Jędrzejewski-Szmek e29e4d5742 test: convert TEST-45 to a normal meson test
On my laptop, it now takes 0.23 s. We don't need the overhead of creating
an image and spawning a machine to mangle a file in /tmp.
2020-03-28 11:50:38 +01:00
Zbigniew Jędrzejewski-Szmek d0ac89a1e8 test: move TEST-43-* setup to static files
Setup of lingering is dropped. I don't think it's necessary for anything,
because the unit is still pulled in from the testsuite service.
2020-03-28 11:46:48 +01:00
Zbigniew Jędrzejewski-Szmek bdfd515ad1 test: move TEST-42-EXECSTOPPOST setup to static files 2020-03-28 11:46:48 +01:00
Zbigniew Jędrzejewski-Szmek 7eeeab205d test: move TEST-30-ONCLOCKCHANGE setup to static files
The two timezone files are now installed in the global setup. I am not too
happy about this, but it still seems better than to create a completely
separate image just for this.
2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 6e796683df test: move TEST-25-IMPORT setup to static files
Also run mask_supporting_services() here.
2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek f4c40fd754 test: move TEST-24-UNIT-TESTS setup to static files
I picked the list of zone files to install by grepping through the code. This
is is a bit brittle, but installing all of them takes a while, and more
importantly, writes a lot of lines to the log.
2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek c0b97b0fc8 test: move TEST-22-TMPFILES setup to static files 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek e5badaf335 test: move most of TEST-13-NSPAWN-SMOKE setup to static files 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek d10029bba4 test: move TEST-12-ISSUE-3171 setup to static files 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 3ac189d8aa test: move TEST-11-ISSUE-3166 setup to static files 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 8c6d58f65d test: move TEST-10-ISSUE-2467 setup to static files 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 4110a6deb9 test: use shell arrays and remove duplicates
The tool lists are obviously not empty, so let's remove the test if they are.
2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 4caa1ac794 test/TEST-06: make autorelabel.service a static file too 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 9901a6ad2e test: convert TEST-04-JOURNAL to generic image 2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek fe85f2bb9c test: move TEST-01-BASIC setup to static files
After this commit, only tests that were converted will work, because the
interface to test_run() changed.
2020-03-28 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 5f28f3ddaf test: allow overriding EFI_MOUNT like other variables 2020-03-22 10:22:42 +01:00
Jörg Thalheim ff12a7954c treewide: more portable bash shebangs
As in 2a5fcfae02
and in 3e67e5c992
using /usr/bin/env allows bash to be looked up in PATH
rather than being hard-coded.

As with the previous changes the same arguments apply
- distributions have scripts to rewrite shebangs on installation and
  they know what locations to rely on.
- For tests/compilation we should rather rely on the user to have setup
  there PATH correctly.

In particular this makes testing from git easier on NixOS where do not provide
/bin/bash to improve compose-ability.
2020-03-05 17:27:07 +01:00
Zbigniew Jędrzejewski-Szmek 33eb1f2497 tree-wide: drop printk.devkmsg=on setting in various places
Since 6123dfaa72 this should not be necessary anymore.
2020-03-03 15:02:53 +01:00
Frantisek Sumsal 2273ecfeda test: don't install /etc/securetty
Having /etc/securetty in test containers prevents root from logging into
them:

```
Jan 31 10:15:11 systemd-testsuite login[69]: pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !
Jan 31 10:15:11 systemd-testsuite login[69]: FAILED LOGIN 1 FROM pts/0 FOR root, Authentication failure
```
2020-02-01 11:55:17 +01:00
Evgeny Vereshchagin 9a1862bfa6 tests: unset LD_PRELOAD in testsuite.service when it's run under ASan
This should help to address the "grep" issue we ran into in
https://github.com/systemd/systemd-centos-ci/pull/217.
2020-01-31 13:13:04 +01:00
Filipe Brandenburger a49ad4c482 core: add test case for PrivateUsers=true in user manager
The test exercises that PrivateTmp=yes and ProtectHome={read-only,tmpfs}
directives work as expected when PrivateUsers=yes in a user manager.

Some code is also added to test-functions to help set up test cases that
exercise the user manager.
2019-12-18 11:09:30 -08:00
Lennart Poettering 5bb4503d3a test-functions: make sure we use the right library path for binaries without RPATH
Meson appears to set the rpath only for some binaries it builds, but not
all. (The rules are not clear to me, but that's besides the point of
this commit).

Let's make sure if our test script operates on a binary that has no
rpath set we fall back preferably to the BUILD_DIR rather than directly
to the host.

This matters if a test uses a libsystemd symbol introduced in a version
newer than the one on the host. In that case "ldd" will not work on the
test binary if rpath is not set. With this fix that behaviour is
corrected, and "ldd" works correctly even in this case.

(Or in other words: before this fix on binaries lacking rpath we'd base
dependency info on the libraries of the host, not the buidl tree, if
they exist in both.)
2019-11-28 09:20:40 +01:00
Filipe Brandenburger 14e0259b49 test: Disable LUKS devices from initramfs in QEMU tests
We currently use the host's kernel and initramfs in our QEMU tests.

If the host is running on an encrypted LUKS partition, then the initramfs
will have a crypttab setup looking for the particular root disk it needs to
encrypt before booting into the system.

However, this disk obviously doesn't exist in our QEMU VM, so it turns out
our tests end up waiting for this device to become available, which will
never actually happen, and boot hangs for 90s until that service times out.

[***   ] A start job is running for /dev/disk/by-uuid/01234567-abcd-1234-abcd-0123456789ab (20s / 1min 30s)

In order to prevent this issue, let's pass "rd.luks=0" to disable LUKS in
the initramfs only as part of our default kernel command-line in our QEMU
tests.

This is enough to disable this behavior and prevent the timeout, while at
the same time doesn't conflict with our tests that actually check for LUKS
behavior in the systemd running under test (such as TEST-02-CRYPTSETUP).

Tested: `sudo make -C TEST-02-CRYPTSETUP/ clean setup run`
2019-11-13 19:55:18 -08:00
Zbigniew Jędrzejewski-Szmek 51fa85913c test: add function to reduce copied setup boilerplate
Many tests were also masking systemd-machined.service. But machined
should only start when activated, so having it not masked shouldn't be
noticable. TEST-25-IMPORT needs it.
2019-10-08 09:10:12 +02:00
Zbigniew Jędrzejewski-Szmek c78c095b1e nspawn: rename UNIFIED_CGROUP_HIERARCHY to SYSTEMD_NSPAWN_UNIFIED_HIERARCHY
We should never have used an unprefixed environment variable name.
All other systemd-nspawn variables have the "SYSTEMD_NSPAWN_" prefix,
and all other systemd variables have the "SYSTEMD_" prefix.

The new variable name takes precedence, but we fall back to checking the
old one. If only the old one is found, a warning is emitted.

In addition, SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="" is accepted as an override
to avoid looking for the old variable name.

We have a variable with the same name ($UNIFIED_CGROUP_HIERARCHY) in tests,
which governs both systemd-nspawn and qemu behaviour. It is not renamed.
2019-10-01 10:21:13 -07:00
Frantisek Sumsal 501deda1ce test: allow use of nested KVM
Introduce TEST_NESTED_KVM variable, which allows use of nested KVM for
QEMU VMs (which is disabled by default by KVM autodetection).
2019-09-27 15:42:38 -07:00
Dan Streetman adcc450f46 test/test-functions: use truncate instead of dd to create testbed image
This avoids unnecessary noise in the stderr logs which dd always produces,
such as:

0+0 records in
0+0 records out
0 bytes copied, 0.000155284 s, 0.0 kB/s

Using truncate should not result in any functional change; the image will
still be created as a sparse file of the size specified.
2019-08-25 15:37:51 +09:00
Dan Streetman 84c49ad197 test/test-functions: use binaries from $BUILD_DIR or installed system
In Ubuntu CI, we test binaries from the installed system, not from
$BUILD_DIR, so use the appropriate binary.  Most of the calls to the
binaries are part of checking/processing asan-built binaries, and so
did not apply to Ubuntu CI, except for generating noise in the stderr
log like:

objdump: '/tmp/autopkgtest.83yGoI/build.fHB/src/test/TEST-01-BASIC/systemd-journald': No such file

However this also applies to the call to systemd-nspawn, which the debian
upstream test wrapper was sed-adjusting to use the installed binary
instead of the binary in $BUILD_DIR.  This commit allows removing that
sed processing of the test-functions file during Ubuntu CI test.
2019-08-25 15:36:47 +09:00
Dan Streetman 8c03df36fe test/test-functions: add mkdir to import_initdir
This dir is created by create_empty_image_rootdir, as well as indirectly
by some other functions, but it should be created by import_initdir so
the newly-exported $initdir exists and can be used immediately without
relying on other functions to create it.
2019-08-17 12:29:15 -04:00
Dan Streetman 0036ce06cb test: replace $TESTDIR/root with $initdir
The $initdir var is already set to $TESTDIR/root, it should be used
instead of direct use of $TESTDIR/root.
2019-08-17 12:29:08 -04:00
Dan Streetman 9e19a8b028 test/test-functions: avoid stderr noise, only umount on cleanup if mountpoint
Only umount it during cleanup if the $TESTDIR/root dir is a mountpoint.
This avoids adding noise to the stderr log such as:

mountpoint: /var/tmp/systemd-test.waLOFT/root: No such file or directory
2019-08-17 12:28:41 -04:00
Daniel Black f364a17dd1 test: ppc64* qemu is qemu-system-ppc64 2019-08-14 07:43:29 +00:00
Frantisek Sumsal 215bffe1b8 test: store coredumps in journal
To make debugging much easier, especially for crashes in tests under
QEMU, let's store the entire coredump bundle in the systemd journal,
which is usually kept around by various CIs. Right now, we usually end
up with a journal, but without the coredump itself, which is pretty
useless.
2019-08-13 07:09:57 +00:00
Frantisek Sumsal 761ce2a4ba test: allow overriding QEMU_OPTIONS from the outside 2019-08-05 13:48:29 +02:00
Dan Streetman 65dd488fe1 test: convert all uses of '|| true' into '|| :'
No change in functionality; just use the shorter || :
2019-07-19 13:47:21 +09:00
Zbigniew Jędrzejewski-Szmek 4a747647b3
Merge pull request #13082 from ddstreet/minor
Minor fixes in test framework
2019-07-17 08:44:01 +02:00
Dan Streetman 59279e9618 test/test-functions: fix install_dmeventd to correctly install bin/libs 2019-07-17 08:34:48 +02:00
Dan Streetman e96386521c test/test-functions: instmods call to find should use -type f
without using -type f, the logs print an error such as:

E:  E: modprobe: FATAL: Module asymmetric_keys not found in directory /lib/modules/4.15.0-54-generic

while this doesn't appear to cause problems, it can be extremely
distracting when trying to debug real failures.
2019-07-16 18:05:15 -04:00
Dan Streetman d391ee10a0 test: when stripping binaries, ignore case in suppressing "File format not recognized"
The grep -v matches all lowercase, but "file" is captialized; just ignore case so
it's suppressed for either all lowercase or capital File.
2019-07-16 18:05:15 -04:00
Dan Streetman f85bc044e5 test: ignore errors during test cleanup, so cleanup can finish
Also move TESTDIR and STATEFILE removal into test_cleanup
2019-07-16 18:05:15 -04:00
Dan Streetman ec4cab49c9 test: add create_empty_image_rootdir() to simplify testcase setup
Almost all tests were manually mounting/unmounting $TESTDIR/root
from the loopback image; this moves all that into test-functions
so the test setup functions are simplier.

Also add test_setup_cleanup() function, to cleanup what is mounted
by create_empty_image_rootdir()
2019-07-16 18:05:15 -04:00
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