1
0
mirror of https://github.com/systemd/systemd synced 2024-07-09 12:36:12 +00:00
Commit Graph

43 Commits

Author SHA1 Message Date
Luca Boccassi
80468db8fa test: use 'auto' instead of 'uefi' for automated fallback
mkosi will prefer UEFI if the architecture supports it, but fallback
to 'linux' if it doesn't.
2024-06-17 15:52:50 +01:00
Daan De Meyer
1e5a1bbe02 test: Run tests that don't need a vm in systemd-nspawn
If we're not running the test as root, stick to using a virtual
machine, as mkosi can't do rootless nspawn yet.
2024-05-29 14:10:50 +02:00
Daan De Meyer
31c797e03d test: Add cmdline field to configure extra kernel command line args
Configuring extra cmdline arguments as a list is much nicer than
having to pass the --kernel-command-line-extra argument manually.
2024-05-14 12:43:28 +02:00
Daan De Meyer
f6af2976aa TEST-06-SELINUX: Simplify auto-relabeling
Let's ship a .autorelabel file so we can get rid of
firstboot-autorelabel.service.
2024-05-14 12:43:28 +02:00
Daan De Meyer
c87e243fef test: Rename mkosi_args to mkosi-args 2024-05-14 12:43:28 +02:00
Daan De Meyer
7a321b5a21 test: Rename testsuite-XX units to match test name
Having these named differently than the test itself mostly creates
unecessary confusion and makes writing logic against the tests harder
so let's rename the testsuite-xx units and scripts to just use the
test name itself.
2024-05-14 12:43:28 +02:00
Daan De Meyer
5748f13e54 test: Rework integration test definitions
Let's make this behave more like all the rest of the meson stuff.
This also is the first step to making it a bit more flexible so we
can define integration tests in different ways as will be seen in
the next commits.
2024-05-14 12:43:28 +02:00
Daan De Meyer
1f2c9bda49 test: Default to linux qemu firmware
Direct kernel boot results in much faster boot times so let's use
it by default.

We disable it for tests that need to reboot because +-50% of the
time, doing a reboot when using direct kernel boot causes qemu to
hang on reboot. Until we figure that out, let's use UEFI for the
tests that need to reboot.
2024-05-06 11:57:09 +02:00
Richard Maw
ab9d60250e test: Enable TEST-06-SELINUX testing with mkosi 2024-05-03 12:57:11 +01:00
Frantisek Sumsal
5ef964f88c test: make TEST-06-SELINUX work with the refpolicy and beef it up a bit
Currently the test works only with policy shipped by Fedora, which makes
it pretty much useless in most of our CIs. Let's drop the custom module
and make the test more generic, so it works with the refpolicy as well,
which should allow us to run it on Arch and probably even in Ubuntu CI.
2023-11-14 18:54:16 +01:00
Frantisek Sumsal
bbe865b2fe test: switch SELinux to permissive in the config file
The config file has (unfortunately) precedence over the kernel command
line, so let's tweak the config file if necessary.
2023-11-14 12:54:50 +01:00
Johannes Segitz
5f22d16bb3
test: Check that SELinux policy is available before running SELinux test (#28868)
* test: Check that SELinux policy is available before running SELinux test

---------

Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
2023-08-17 18:04:53 +01:00
Frantisek Sumsal
d5ab23aa54 test: a couple of assorted cleanups
- sort binaries
- send stdout/stderr of the autorelabel service to console as well
2023-06-05 23:30:01 +02:00
Frantisek Sumsal
fa5dee77c0 test: load the SELinux module outside of the VM
Turns out we can, apart from just building the module, "shove" it into
the SELinux database in a chroot as well. This brings quite significant
time savings, as the SELinux db rebuild takes 2 - 5 minutes in a VM
without acceleration (and takes currently ~half of the runtime of the test
in the C8S job).
2023-06-05 22:52:38 +02:00
Frantisek Sumsal
038efe6df1 test: build the SELinux test module on the host
Let's save some time and build the SELinux test module on the host
instead of a possibly unaccelerated VM. This brings the runtime of
TEST-06-SELINUX from ~12 minutes down to a ~1 minute.
2023-05-19 11:45:11 +02:00
Zbigniew Jędrzejewski-Szmek
721700df3c TEST-06-SELINUX: add the usual spdx license header to policy files 2021-10-18 09:43:18 +02:00
Zbigniew Jędrzejewski-Szmek
7b3cec95db tests: add spdx headers to scripts and Makefiles 2021-10-18 09:04:45 +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
Frantisek Sumsal
31db4c20ea test: reintroduce m4 dependency for TEST-06-SELINUX
m4 is required to build the test SELinux module:

```
[   31.321789] sh[483]: /bin/sh: line 1: m4: command not found
[   31.882668] sh[488]: Compiling targeted systemd_test module
[   32.120862] sh[492]: /bin/sh: line 1: m4: command not found
[   32.159897] sh[458]: make: *** [/usr/share/selinux/devel/include/Makefile:156: tmp/systemd_test.mod] Error 127
```
2021-05-19 13:01:07 +02:00
Zbigniew Jędrzejewski-Szmek
44ff8df777 Drop dependency on m4
m4 was hugely popular in the past, because autotools, automake, flex, bison and
many other things used it. But nowadays it much less popular, and might not even
be installed in the buildroot. (m4 is small, so it doesn't make a big difference.)

(FWIW, Fedora dropped make from the buildroot now,
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot. I think it's
reasonable to assume that m4 will be dropped at some point too.)

The main reason to drop m4 is that the syntax is not very nice, and we should
minimize the number of different syntaxes that we use. We still have two
(configure_file() with @FOO@ and jinja2 templates with {{foo}} and the
pythonesque conditional expressions), but at least we don't need m4 (with
m4_dnl and `quotes').
2021-05-19 10:24:43 +09: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
3f161ba9bc test: make the test entrypoint scripts shellcheck-compliant 2021-04-20 10:26:43 +02:00
Frantisek Sumsal
01da74243d test: add a custom SELinux file context
Since the test suite overhaul, the test units are now under
/usr/lib/systemd/tests/testdata/tetsuite-06.units with
system_u:object_r:lib_t context. This causes an AVC denial, since the
systemd unit files are expected to have the
system_u:object_r:systemd_unit_file_t context. Let's fix this by using a
custom file context definition.
2021-02-05 17:08:58 +01:00
Luca Boccassi
d9e606e89f tests: build the image once and then copy/extend it
Building custom images for each test takes a lot of time.
Build the default one, and if the test needs incompatible changes
just copy it and extend it instead.
2021-01-24 13:07:39 +00:00
Zbigniew Jędrzejewski-Szmek
68a7705e35 TEST-06-*: also try the installation path for Debian
https://salsa.debian.org/systemd-team/systemd/-/blob/debian/master/debian/tests/upstream
used sed to adjust the path. I think it's better to make our script more
flexible.
2020-03-31 14:37:20 +02:00
Zbigniew Jędrzejewski-Szmek
8c3534b5db test: rework how images are created
Before, we'd create a separate image for each test, in
/var/tmp/systemd-test.XXXXX/rootdisk.img. Most of the images
where very similar, except that each one had some unit files installed
specifically for the test. The installation of those custom unit files
was removed in previous commits (all the unit files are always installed).

The new approach is to only create as few distinct images as possible.
We have:
default.img: the "normal" image suitable for almost all the tests
basic.img: the same as default image but doesn't mask any services
cryptsetup.img: p2 is used for encrypted /var
badid.img: /etc/machine-id is overwritten with stuff
selinux.img: with selinux added for fun and fun
and a few others:

ls -l build/test/*img
lrwxrwxrwx 1 root root 38 Mar 21 21:23 build/test/badid.img -> /var/tmp/systemd-test.PJFFeo/badid.img
lrwxrwxrwx 1 root root 38 Mar 21 21:17 build/test/basic.img -> /var/tmp/systemd-test.na0xOI/basic.img
lrwxrwxrwx 1 root root 43 Mar 21 21:18 build/test/cryptsetup.img -> /var/tmp/systemd-test.Tzjv06/cryptsetup.img
lrwxrwxrwx 1 root root 40 Mar 21 21:19 build/test/default.img -> /var/tmp/systemd-test.EscAsS/default.img
lrwxrwxrwx 1 root root 39 Mar 21 21:22 build/test/nspawn.img -> /var/tmp/systemd-test.HSebKo/nspawn.img
lrwxrwxrwx 1 root root 40 Mar 21 21:20 build/test/selinux.img -> /var/tmp/systemd-test.daBjbx/selinux.img
lrwxrwxrwx 1 root root 39 Mar 21 21:21 build/test/test08.img -> /var/tmp/systemd-test.OgnN8Z/test08.img

I considered trying to use the same image everywhere. It would probably be
possible, but it would be very brittle. By using separate images where it is
necessary we keep various orthogonal modifications independent.

The way that images are cached is complicated by the fact that we still
want to keep them in /var/tmp. Thus, an image is created on first use and
linked to from build/test/ so it can be found by other tests.

Tests cannot be run in parallel. I think that is an acceptable limitation.
Creation of the images was probably taking more resources then the actual
tests, so we should be better off anyway.
2020-03-28 11:51:29 +01:00
Zbigniew Jędrzejewski-Szmek
50b836518c test: drop cargo-cult line
p2 is only used in the cryptsetup test...
2020-03-28 11:51:13 +01:00
Zbigniew Jędrzejewski-Szmek
1ed5556e56 test: move most of TEST-06-* setup to static files 2020-03-28 11:46:47 +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
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
976ed3b621 test: use "ln -fs"
Without this, repeated runs of "make -C TEST/... setup" fail when trying
to create the symlink.
2019-07-30 13:27:06 +02: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
Frantisek Sumsal
cc469c3dfc test: drop || return 1 expression which is incompatible with set -e
The `set -e` option is incompatible with a subshell/compound command,
which is followed by || <EXPR>. In such case, the -e option is ignored
in all affected subshells/functions (see man bash(1) for command `set`).
2019-07-08 21:11:32 +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
Yu Watanabe
ed94652a33 test: drop 'After=multi-user.target' from most of testsuite.service 2018-11-03 18:00:47 +09:00
Lennart Poettering
cc4338e435 tests: tighten check for TEST-06-SELINUX dependencies a bit
As it turns out /usr/share/selinux/devel/ is now included in more RPMs
than just selinux-policy-devel (specifically container-selinux, which is
pulled in by various container related RPMs). Let's hence tighten the
dependency check a bit and look for systemd's .if file, which is what we
actually care about.
2018-06-06 10:17:38 +02:00
Lennart Poettering
67321fdf3e test: bypass selinux integration test if selinux policy devel package is not installed
With this "sudo ./run-integration-tests.sh" should work fully without
exception, even on systems lacking SELinux (in which case that test will
just be skipped)
2018-03-23 15:29:35 +01:00
Martin Pitt
818567fce6 test: Run qemu/nspawn tests with "set -e"
This catches errors like "ninja not found", missing programs etc. early,
instead of silently ignoring them and trying to boot a broken VM.

In install_config_files(), allow some distro specific files to be absent
(such as /etc/sysconfig/init).
2017-08-10 08:43:13 +02:00
Martin Pitt
054ee249a2 test: Factorize common integration test functions (#6540)
All test/TEST* but TEST-02-CRYPTSETUP share the same check_result_qemu()
and test_cleanup(), so move them into test_functions and only override
them in TEST-02-CRYPTSETUP.

Also provide a common test_run() which by default assumes that both QEMU
and nspawn tests are run. Particular tests which don't support either
need to explicitly opt out by setting $TEST_NO_{QEMU,NSPAWN}. Do it this
way around to avoid accidentally forgetting to opt in, and to encourage
test authors to at least always support nspawn.
2017-08-04 15:34:14 +03:00
Martin Pitt
a415d43655 tests: force booting the kernel with SELinux
selinux=1 is not sufficient when running on a kernel which also has another LSM
(such as AppArmor) enabled and defaults to that.
2016-06-24 11:28:35 +02:00
Evgeny Vereshchagin
cd4c260323 tests: use symlink to Makefile 2016-05-01 16:40:21 +00:00
Phillip Sz
e3ceb75be3 test: remove exit 0 at the end
We don't need that at the end, as it will always exit with 0 if
everything is okey.
2016-02-05 11:38:58 +01:00
Evgeny Vereshchagin
5c7290b195 tests: add test-selinux-checks 2016-01-31 09:02:51 +00:00