1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00

test: Remove old bash test runner

We put a timeline of 257 to remove the old bash test runner so since
we're about to release 257, let's remove the old bash test runner in
favor of the meson + mkosi test runner.
This commit is contained in:
Daan De Meyer 2024-09-05 20:37:37 +02:00 committed by Luca Boccassi
parent 560412148f
commit ead814a0b0
132 changed files with 0 additions and 5892 deletions

View File

@ -118,8 +118,6 @@ For testing and debugging, fuzzers can be executed as any other program, includi
## Integration Tests
Sources in `test/TEST-*` implement system-level testing for executables, libraries and daemons that are shipped by the project.
They require privileges to run, and are not safe to execute directly on a host.
By default they will build an image and run the test under it via `qemu` or `systemd-nspawn`.
Most of those tests should be able to run via `systemd-nspawn`, which is orders-of-magnitude faster than `qemu`, but some tests require privileged operations like using `dm-crypt` or `loopdev`.
They are clearly marked if that is the case.

View File

@ -125,99 +125,15 @@ If you're debugging a failing integration test (running `meson test --interactiv
there's no need to run `systemctl start ...`, running `systemctl soft-reboot` on its own is sufficient to
rerun the test.
## Running the integration tests the old fashioned way
The extended testsuite only works with UID=0. It consists of the subdirectories
named `test/TEST-??-*`, each of which contains a description of an OS image and
a test which consists of systemd units and scripts to execute in this image.
The same image is used for execution under `systemd-nspawn` and `qemu`.
To run the extended testsuite do the following:
```shell
$ ninja -C build # Avoid building anything as root later
$ sudo test/run-integration-tests.sh
ninja: Entering directory `/home/zbyszek/src/systemd/build'
ninja: no work to do.
--x-- Running TEST-01-BASIC --x--
+ make -C TEST-01-BASIC clean setup run
make: Entering directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC'
TEST-01-BASIC CLEANUP: Basic systemd setup
TEST-01-BASIC SETUP: Basic systemd setup
...
TEST-01-BASIC RUN: Basic systemd setup [OK]
make: Leaving directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC'
--x-- Result of TEST-01-BASIC: 0 --x--
--x-- Running TEST-02-CRYPTSETUP --x--
+ make -C TEST-02-CRYPTSETUP clean setup run
```
If one of the tests fails, then $subdir/test.log contains the log file of
the test.
To run just one of the cases:
```shell
$ sudo make -C test/TEST-01-BASIC clean setup run
```
### Specifying the build directory
If the build directory is not detected automatically, it can be specified
with BUILD_DIR=:
```shell
$ sudo BUILD_DIR=some-other-build/ test/run-integration-tests
```
or
```shell
$ sudo make -C test/TEST-01-BASIC BUILD_DIR=../../some-other-build/ ...
```
Note that in the second case, the path is relative to the test case directory.
An absolute path may also be used in both cases.
### Testing installed binaries instead of built
To run the extended testsuite using the systemd installed on the system instead
of the systemd from a build, use the NO_BUILD=1:
```shell
$ sudo NO_BUILD=1 test/run-integration-tests
```
### Configuration variables
`TEST_NO_QEMU=1`: Don't run tests under qemu.
`TEST_QEMU_ONLY=1`: Run only tests that require qemu.
`TEST_NO_NSPAWN=1`: Don't run tests under systemd-nspawn.
`TEST_PREFER_NSPAWN=1`: Run all tests that do not require qemu under
systemd-nspawn.
`TEST_PREFER_QEMU=1`: Run all tests under qemu.
`TEST_NO_KVM=1`: Disable qemu KVM auto-detection (may be necessary when you're
trying to run the *vanilla* qemu and have both qemu and qemu-kvm installed)
`QEMU_MEM=512M`: Configure amount of memory for qemu VMs (defaults to 512M).
`QEMU_SMP=1`: Configure number of CPUs for qemu VMs (defaults to 1).
`KERNEL_APPEND='...'`: Append additional parameters to the kernel command line.
`NSPAWN_ARGUMENTS='...'`: Specify additional arguments for systemd-nspawn.
`QEMU_TIMEOUT=infinity`: Set a timeout for tests under qemu (defaults to 1800
sec).
`NSPAWN_TIMEOUT=infinity`: Set a timeout for tests under systemd-nspawn
(defaults to 1800 sec).
`TEST_SHELL=1`: Configure the machine to be more *user-friendly* for
interactive debugging (e.g. by setting a usable default terminal, suppressing
the shutdown after the test, etc.).
@ -229,25 +145,8 @@ expression.
`TEST_MATCH_TESTCASE=testcase`: Same as $TEST_MATCH_SUBTEST but for subtests
that make use of `run_testcases`.
The kernel and initrd can be specified with $KERNEL_BIN and $INITRD. (Fedora's
or Debian's default kernel path and initrd are used by default.)
A script will try to find your qemu binary. If you want to specify a different
one with `$QEMU_BIN`.
`TEST_SKIP`: takes a space separated list of tests to skip.
### Debugging the qemu image
If you want to log in the testsuite virtual machine, use `TEST_SHELL=1`
and log in as root:
```shell
$ sudo make -C test/TEST-01-BASIC TEST_SHELL=1 run
```
The root password is empty.
## Ubuntu CI
New PRs submitted to the project are run through regression tests, and one set

View File

@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
all setup run clean clean-again:
@TEST_BASE_DIR=../ ./test.sh --$@
.PHONY: all setup run clean clean-again

View File

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Basic systemd setup"
IMAGE_NAME="basic"
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
TEST_REQUIRE_INSTALL_TESTS=0
TEST_SUPPORTING_SERVICES_SHOULD_BE_MASKED=0
# Check if we can correctly deserialize if the kernel cmdline contains "weird" stuff
# like an invalid argument, "end of arguments" separator, or a sysvinit argument (-z)
# See: https://github.com/systemd/systemd/issues/28184
KERNEL_APPEND="foo -- -z bar --- baz $KERNEL_APPEND"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
TEST_DESCRIPTION="Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER=yes
# Some tests make collecting coverage impossible (like test-mount-util, which
# remounts the whole / as read-only), so let's ignore the gcov errors in such
# case
IGNORE_MISSING_COVERAGE=yes
# Embed some newlines in the kernel command line to stress our test suite
# Also, pass $TEST_PREFER_NSPAWN to the VM/container if set
#
# shellcheck disable=SC2015
KERNEL_APPEND="
$(get_bool "${TEST_PREFER_NSPAWN:-0}" && echo "systemd.setenv=TEST_PREFER_NSPAWN=1" || :)
frobnicate!
systemd.setenv=TEST_CMDLINE_NEWLINE=foo
systemd.setenv=TEST_CMDLINE_NEWLINE=bar
$KERNEL_APPEND
"
# Override $TEST_PREFER_NSPAWN if it was set to always run both the QEMU and
# the nspawn part of the test
TEST_PREFER_NSPAWN=no
test_append_files() {
if get_bool "$LOOKS_LIKE_SUSE"; then
dinfo "Install the unit test binaries needed by the TEST-02-UNITTESTS at runtime"
inst_recursive "${SOURCE_DIR}/unit-tests"
fi
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Job-related tests"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Journal-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
local dropin_dir
image_install curl setterm unzstd
image_install -o openssl
# Necessary for RH-based systems, otherwise MHD fails with:
# microhttpd: Failed to initialise TLS session.
image_install -o /etc/crypto-policies/back-ends/gnutls.config
# Since we nuke the journal repeatedly during this test, let's redirect
# stdout/stderr to the console as well to make the test a bit more debug-able.
if ! get_bool "${TEST_SHELL:-}"; then
dropin_dir="${workspace:?}/etc/systemd/system/TEST-04-JOURNAL.service.d/"
mkdir -p "$dropin_dir"
printf '[Service]\nStandardOutput=journal+console\nStandardError=journal+console' >"$dropin_dir/99-stdout.conf"
fi
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Resource limits-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,43 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="SELinux tests"
IMAGE_NAME="selinux"
TEST_NO_NSPAWN=1
if [[ -e /etc/selinux/config ]]; then
SEPOLICY="$(awk -F= '/^SELINUXTYPE=/ {print $2; exit}' /etc/selinux/config)"
# C8S doesn't set SELINUXTYPE in /etc/selinux/config, so default to 'targeted'
if [[ -z "$SEPOLICY" ]]; then
echo "Failed to parse SELinux policy from /etc/selinux/config, falling back to 'targeted'"
SEPOLICY="targeted"
fi
if [[ ! -d "/etc/selinux/$SEPOLICY" ]]; then
echo "Missing policy directory /etc/selinux/$SEPOLICY, skipping the test"
exit 0
fi
echo "Using SELinux policy '$SEPOLICY'"
else
echo "/etc/selinux/config is missing, skipping the test"
exit 0
fi
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
SETUP_SELINUX=yes
KERNEL_APPEND="${KERNEL_APPEND:-} selinux=1 enforcing=0 lsm=selinux"
test_append_files() {
local workspace="${1:?}"
setup_selinux
# Config file has (unfortunately) always precedence, so let's switch it there as well
sed -i '/^SELINUX=disabled$/s/disabled/permissive/' "$workspace/etc/selinux/config"
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Tests for core PID1 functionality"
# for testing PrivateNetwork=yes
NSPAWN_ARGUMENTS="--capability=CAP_NET_ADMIN"
# for testing PrivatePIDs=yes
TEST_INSTALL_VERITY_MINIMAL=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
image_install logger socat
inst_binary mksquashfs
inst_binary unsquashfs
install_verity_minimal
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,110 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test various scenarios involving transition from/to initrd"
# Note: for debugging systemd.journald.max_level_console=debug might come in handy
# as well, but it's not used here since it's _very_ noisy and slows the test
# down a lot
KERNEL_APPEND="${KERNEL_APPEND:-} systemd.journald.forward_to_console=1"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
local exitrd file dir
# Create an exitrd
#
# This should provide coverage for exitrd related issues, see:
# - https://github.com/systemd/systemd/issues/28645
# - https://github.com/systemd/systemd/pull/28648
# - https://github.com/systemd/systemd/pull/28793
#
# This is a bit messier than I originally anticipated, as installing our own libraries
# is handled implicitly by install_systemd() which I don't want to use here, since
# I need only the systemd-shutdown binary
exitrd="$workspace/exitrd"
mkdir -p "$exitrd/etc" "$exitrd/usr"
initdir="$exitrd" image_install bash /usr/lib/os-release
ln -srf "$exitrd/usr/lib/os-release" "$exitrd/etc/initrd-release"
initdir="$exitrd" inst_binary "$workspace/usr/lib/systemd/systemd-shutdown" "/usr/lib/systemd/systemd-shutdown"
initdir="$exitrd" inst_libs "$exitrd/usr/lib/systemd/systemd-shutdown"
# We need to deal with libsystemd stuff explicitly, as we don't call install_systemd() here
while read -r file; do
initdir="$exitrd" inst_library "$file" "${file##"$workspace"}"
initdir="$exitrd" inst_libs "$file"
done < <(find "$workspace/usr/" -name "libsystemd*.so*")
# Call systemd-shutdown indirectly, so we can show a message that we can check for
# later to make sure the exitrd was actually executed
cat >"$exitrd/shutdown" <<\EOF
#!/usr/bin/bash -eu
echo "Hello from exitrd"
exec /usr/lib/systemd/systemd-shutdown "$@"
EOF
chmod +x "$exitrd/shutdown"
}
check_result_qemu_hook() {
local workspace="${1:?}"
local console_log="${TESTDIR:?}/console.log"
if [[ -e "$workspace/skipped" ]]; then
return 0
fi
if [[ ! -e "$console_log" ]]; then
dfatal "Missing console log - this shouldn't happen"
return 1
fi
# The console log should not contain messages like:
# [ 6.245000] systemd-shutdown[1]: Failed to move /run/initramfs to /: Invalid argument
# [ 6.245955] systemd-shutdown[1]: Failed to switch root to "/run/initramfs": Invalid argument
if grep -qE "systemd-shutdown.+: Failed to move /run/initramfs" "$console_log" ||
grep -qE "systemd-shutdown.+: Failed to switch root" "$console_log"; then
derror "sd-shutdown failed to switch root in exitrd"
return 1
fi
# Check if the exitrd was executed at all
if ! grep -q "Hello from exitrd" "$console_log"; then
derror "Missing 'hello' message from exitrd"
return 1
fi
return 0
}
# Setup a one shot service in initrd that creates a dummy bind mount under /run
# to check if the mount persists though the initrd transition. The "check" part
# is in the respective TEST-08-INITRD.sh script.
#
# See: https://github.com/systemd/systemd/issues/28452
run_qemu_hook() {
local extra="${TESTDIR:?}/initrd.extra"
mkdir -m 755 "$extra"
mkdir -m 755 "$extra/etc" "$extra/etc/systemd" "$extra/etc/systemd/system" "$extra/etc/systemd/system/initrd.target.wants"
cat >"$extra/etc/systemd/system/initrd-run-mount.service" <<EOF
[Unit]
Description=Create a mount in /run that should survive the transition from initrd
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=mkdir /run/initrd-mount-source /run/initrd-mount-target
ExecStart=mount -v --bind /run/initrd-mount-source /run/initrd-mount-target
ExecStart=cp -v /etc/initrd-release /run/initrd-mount-target/hello-world
EOF
ln -svrf "$extra/etc/systemd/system/initrd-run-mount.service" "$extra/etc/systemd/system/initrd.target.wants/initrd-run-mount.service"
(cd "$extra" && find . | cpio -o -H newc -R root:root > "$extra.cpio")
INITRD_EXTRA="$extra.cpio"
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test various scenarios involving (multiple) machine reboots"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,60 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="systemd-nspawn tests"
IMAGE_NAME="nspawn"
TEST_NO_NSPAWN=1
IMAGE_ADDITIONAL_ROOT_SIZE=500
TEST_FORCE_NEWIMAGE=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
local container="$workspace/usr/share/TEST-13-NSPAWN-container-template"
# For virtual wlan interface.
instmods mac80211_hwsim
# for IPMasquerade=
instmods "=net/netfilter"
# For /dev/net/tun
instmods tun
generate_module_dependencies
# For unprivileged mountfsd.
if command -v openssl >/dev/null 2>&1; then
inst_binary openssl
fi
# Create a dummy container "template" with a minimal toolset, which we can
# then use as a base for our nspawn/machinectl tests
initdir="$container" setup_basic_dirs
initdir="$container" image_install \
bash \
env \
cat \
hostname \
grep \
ip \
ls \
md5sum \
mountpoint \
ncat \
ps \
seq \
sleep \
stat \
touch \
true
cp /etc/os-release "$container/usr/lib/os-release"
cat >"$container/sbin/init" <<EOF
#!/bin/bash
echo "Hello from dummy init, beautiful day, innit?"
ip link
EOF
chmod +x "$container/sbin/init"
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Dropin tests"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="UDEV"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
instmods snd_seq snd_timer tun
generate_module_dependencies
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="FailureAction= operation"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Various cgroup-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
UNIFIED_CGROUP_HIERARCHY=yes
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,37 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Fuzz our D-Bus interfaces with dfuzzer"
TEST_SUPPORTING_SERVICES_SHOULD_BE_MASKED=0
QEMU_TIMEOUT="${QEMU_TIMEOUT:-1800}"
IMAGE_NAME=dfuzzer
TEST_FORCE_NEWIMAGE=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
# Run the test either only under nspawn (if $TEST_PREFER_NSPAWN is set to true)
# or only uder qemu otherwise, to avoid running the test twice on machines where
# we can do both.
if ! get_bool "${TEST_PREFER_NSPAWN:=}"; then
TEST_NO_NSPAWN=1
fi
test_require_bin dfuzzer
if ! get_bool "$IS_BUILT_WITH_ASAN"; then
echo "systemd is built without ASan, skipping..."
exit 0
fi
test_append_files() {
local workspace="${1:?}"
image_install dfuzzer /etc/dfuzzer.conf
# Enable all systemd-related services, including the D-Bus ones
"$SYSTEMCTL" --root="${workspace:?}" preset-all
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Tmpfiles related tests"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
if get_bool "${IS_BUILT_WITH_ASAN:=}"; then
if [[ -z "${initdir:=}" ]]; then
echo >&2 "\$initdir is not defined, can't continue"
exit 1
fi
sed -i "s/systemd//g" "$initdir/etc/nsswitch.conf"
fi
image_install setfacl
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Tests for various unit file settings"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,246 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="cryptsetup systemd setup"
IMAGE_NAME="cryptsetup"
IMAGE_ADDITIONAL_DATA_SIZE=100
TEST_NO_NSPAWN=1
TEST_FORCE_NEWIMAGE=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
PART_UUID="deadbeef-dead-dead-beef-000000000000"
DM_NAME="test24_varcrypt"
KERNEL_OPTIONS=(
"rd.luks=1"
"luks.name=$PART_UUID=$DM_NAME"
"luks.key=$PART_UUID=/keyfile:LABEL=varcrypt_keydev"
"luks.options=$PART_UUID=x-initrd.attach"
# Forward journal to console to make debugging easier (or possible at all) if we fail to bring the
# encrypted /var up during boot
"systemd.journald.forward_to_console=1"
)
KERNEL_APPEND+=" ${KERNEL_OPTIONS[*]}"
QEMU_OPTIONS+=" -drive format=raw,cache=unsafe,file=${STATEDIR:?}/keydev.img"
check_result_qemu() {
local ret
mount_initdir
cryptsetup luksOpen "${LOOPDEV:?}p4" "${DM_NAME:?}" <"$TESTDIR/keyfile"
mount "/dev/mapper/$DM_NAME" "$initdir/var"
check_result_common "${initdir:?}" && ret=0 || ret=$?
_umount_dir "$initdir/var"
_umount_dir "$initdir"
cryptsetup luksClose "/dev/mapper/$DM_NAME"
return $ret
}
can_test_pkcs11() {
if ! command -v "softhsm2-util" >/dev/null; then
ddebug "softhsm2-util not available, skipping the PKCS#11 test"
return 1
fi
if ! command -v "pkcs11-tool" >/dev/null; then
ddebug "pkcs11-tool not available, skipping the PKCS#11 test"
return 1
fi
if ! command -v "certtool" >/dev/null; then
ddebug "certtool not available, skipping the PKCS#11 test"
return 1
fi
if ! "${SYSTEMCTL:?}" --version | grep -q "+P11KIT"; then
ddebug "Support for p11-kit is disabled, skipping the PKCS#11 test"
return 1
fi
if ! "${SYSTEMCTL:?}" --version | grep -q "+OPENSSL"; then
ddebug "Support for openssl is disabled, skipping the PKCS#11 test"
return 1
fi
if ! "${SYSTEMCTL:?}" --version | grep -q "+LIBCRYPTSETUP\b"; then
ddebug "Support for libcryptsetup is disabled, skipping the PKCS#11 test"
return 1
fi
if ! "${SYSTEMCTL:?}" --version | grep -q "+LIBCRYPTSETUP_PLUGINS"; then
ddebug "Support for libcryptsetup plugins is disabled, skipping the PKCS#11 test"
return 1
fi
return 0
}
setup_pkcs11_token() {
dinfo "Setup PKCS#11 token"
local P11_MODULE_CONFIGS_DIR P11_MODULE_DIR SOFTHSM_MODULE
export SOFTHSM2_CONF="/tmp/softhsm2.conf"
mkdir -p "$initdir/usr/lib/softhsm/tokens/"
cat >${SOFTHSM2_CONF} <<EOF
directories.tokendir = $initdir/usr/lib/softhsm/tokens/
objectstore.backend = file
slots.removable = false
slots.mechanisms = ALL
EOF
export GNUTLS_PIN="1234"
export GNUTLS_SO_PIN="12345678"
softhsm2-util --init-token --free --label "TestToken" --pin ${GNUTLS_PIN} --so-pin ${GNUTLS_SO_PIN}
if ! P11_MODULE_CONFIGS_DIR=$(pkg-config --variable=p11_module_configs p11-kit-1); then
echo "WARNING! Cannot get p11_module_configs from p11-kit-1.pc, assuming /usr/share/p11-kit/modules" >&2
P11_MODULE_CONFIGS_DIR="/usr/share/p11-kit/modules"
fi
if ! P11_MODULE_DIR=$(pkg-config --variable=p11_module_path p11-kit-1); then
echo "WARNING! Cannot get p11_module_path from p11-kit-1.pc, assuming /usr/lib/pkcs11" >&2
P11_MODULE_DIR="/usr/lib/pkcs11"
fi
SOFTHSM_MODULE=$(grep -F 'module:' "$P11_MODULE_CONFIGS_DIR/softhsm2.module"| cut -d ':' -f 2| xargs)
if [[ "$SOFTHSM_MODULE" =~ ^[^/] ]]; then
SOFTHSM_MODULE="$P11_MODULE_DIR/$SOFTHSM_MODULE"
fi
# RSA #####################################################
pkcs11-tool --module "$SOFTHSM_MODULE" --token-label "TestToken" --pin "env:GNUTLS_PIN" --so-pin "env:GNUTLS_SO_PIN" --keypairgen --key-type "RSA:2048" --label "RSATestKey" --usage-decrypt
certtool --generate-self-signed \
--load-privkey="pkcs11:token=TestToken;object=RSATestKey;type=private" \
--load-pubkey="pkcs11:token=TestToken;object=RSATestKey;type=public" \
--template "$TEST_BASE_DIR/$TESTNAME/template.cfg" \
--outder --outfile "/tmp/rsa_test.crt"
pkcs11-tool --module "$SOFTHSM_MODULE" --token-label "TestToken" --pin "env:GNUTLS_PIN" --so-pin "env:GNUTLS_SO_PIN" --write-object "/tmp/rsa_test.crt" --type cert --label "RSATestKey"
rm "/tmp/rsa_test.crt"
# prime256v1 ##############################################
pkcs11-tool --module "$SOFTHSM_MODULE" --token-label "TestToken" --pin "env:GNUTLS_PIN" --so-pin "env:GNUTLS_SO_PIN" --keypairgen --key-type "EC:prime256v1" --label "ECTestKey" --usage-derive
certtool --generate-self-signed \
--load-privkey="pkcs11:token=TestToken;object=ECTestKey;type=private" \
--load-pubkey="pkcs11:token=TestToken;object=ECTestKey;type=public" \
--template "$TEST_BASE_DIR/$TESTNAME/template.cfg" \
--outder --outfile "/tmp/ec_test.crt"
pkcs11-tool --module "$SOFTHSM_MODULE" --token-label "TestToken" --pin "env:GNUTLS_PIN" --so-pin "env:GNUTLS_SO_PIN" --write-object "/tmp/ec_test.crt" --type cert --label "ECTestKey"
rm "/tmp/ec_test.crt"
###########################################################
rm ${SOFTHSM2_CONF}
unset SOFTHSM2_CONF
inst_libs "$SOFTHSM_MODULE"
inst_library "$SOFTHSM_MODULE"
inst_simple "$P11_MODULE_CONFIGS_DIR/softhsm2.module"
cat >"$initdir/etc/softhsm2.conf" <<EOF
directories.tokendir = /usr/lib/softhsm/tokens/
objectstore.backend = file
slots.removable = false
slots.mechanisms = ALL
log.level = INFO
EOF
mkdir -p "$initdir/etc/systemd/system/systemd-cryptsetup@.service.d"
cat >"$initdir/etc/systemd/system/systemd-cryptsetup@.service.d/PKCS11.conf" <<EOF
[Unit]
# Make sure we can start systemd-cryptsetup@empty_pkcs11_auto.service many times
StartLimitBurst=10
[Service]
Environment="SOFTHSM2_CONF=/etc/softhsm2.conf"
Environment="PIN=$GNUTLS_PIN"
EOF
unset GNUTLS_PIN
unset GNUTLS_SO_PIN
}
test_create_image() {
create_empty_image_rootdir
echo -n test >"${TESTDIR:?}/keyfile"
cryptsetup -q luksFormat --uuid="$PART_UUID" --pbkdf pbkdf2 --pbkdf-force-iterations 1000 "${LOOPDEV:?}p4" "$TESTDIR/keyfile"
cryptsetup luksOpen "${LOOPDEV}p4" "${DM_NAME:?}" <"$TESTDIR/keyfile"
mkfs.ext4 -L var "/dev/mapper/$DM_NAME"
mkdir -p "${initdir:?}/var"
mount "/dev/mapper/$DM_NAME" "$initdir/var"
LOG_LEVEL=5
setup_basic_environment
mask_supporting_services
install_dmevent
generate_module_dependencies
if can_test_pkcs11; then
setup_pkcs11_token
fi
# Create a keydev
dd if=/dev/zero of="${STATEDIR:?}/keydev.img" bs=1M count=16
mkfs.ext4 -L varcrypt_keydev "$STATEDIR/keydev.img"
mkdir -p "$STATEDIR/keydev"
mount "$STATEDIR/keydev.img" "$STATEDIR/keydev"
echo -n test >"$STATEDIR/keydev/keyfile"
sync "$STATEDIR/keydev"
umount "$STATEDIR/keydev"
cat >>"$initdir/etc/fstab" <<EOF
/dev/mapper/$DM_NAME /var ext4 defaults 0 1
EOF
# Forward journal messages to the console, so we have something to investigate even if we fail to mount
# the encrypted /var
mkdir -p "$initdir/etc/systemd/journald.conf.d/"
echo -ne "[Journal]\nForwardToConsole=yes\n" >"$initdir/etc/systemd/journald.conf.d/99-forward.conf"
# If $INITRD wasn't provided explicitly, generate a custom one with dm-crypt
# support
if [[ -z "$INITRD" ]]; then
INITRD="${TESTDIR:?}/initrd.img"
dinfo "Generating a custom initrd with dm-crypt support in '${INITRD:?}'"
if command -v dracut >/dev/null; then
dracut --force --verbose --add crypt "$INITRD"
elif command -v mkinitcpio >/dev/null; then
mkinitcpio -S autodetect --addhooks sd-encrypt --generate "$INITRD"
elif command -v mkinitramfs >/dev/null; then
# The cryptroot hook is provided by the cryptsetup-initramfs package
if ! dpkg-query -s cryptsetup-initramfs; then
derror "Missing 'cryptsetup-initramfs' package for dm-crypt support in initrd"
return 1
fi
mkinitramfs -o "$INITRD"
else
dfatal "Unrecognized initrd generator, can't continue"
return 1
fi
fi
}
cleanup_root_var() {
mountpoint -q "$initdir/var" && umount "$initdir/var"
[[ -b "/dev/mapper/${DM_NAME:?}" ]] && cryptsetup luksClose "/dev/mapper/$DM_NAME"
mountpoint -q "${STATEDIR:?}/keydev" && umount "$STATEDIR/keydev"
}
test_cleanup() {
# ignore errors, so cleanup can continue
cleanup_root_var || :
_test_cleanup
}
test_setup_cleanup() {
cleanup_root_var || :
cleanup_initdir
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test importd"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="systemctl-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="test systemd-portabled"
IMAGE_NAME="portabled"
TEST_NO_NSPAWN=1
TEST_INSTALL_VERITY_MINIMAL=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
instmods squashfs =squashfs
instmods dm_verity =md
install_dmevent
generate_module_dependencies
inst_binary mksquashfs
inst_binary unsquashfs
install_verity_minimal
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange="
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test OOM killer logic"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
UNIFIED_CGROUP_HIERARCHY=yes
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUser=0 and back"
# Certain subtests run with DynamicUser=true which makes writing the gcov
# artifacts impossible. As $GCOV_PREFIX and friends seem to be ineffective
# in this situation, let's simply ignore all gcov complaints for the whole
# test to make it happy.
IGNORE_MISSING_COVERAGE=yes
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Tests for systemd-logind"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
image_install -o evemu-device evemu-event
instmods uinput
generate_module_dependencies
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test NUMAPolicy= and NUMAMask= options"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
if qemu_min_version "5.2.0"; then
QEMU_OPTIONS+=" -object memory-backend-ram,id=mem0,size=${QEMU_MEM:-768M} -numa node,memdev=mem0,nodeid=0"
else
QEMU_OPTIONS+=" -numa node,nodeid=0"
fi
if [[ "$(uname -m)" =~ ^(s390x|ppc)$ ]]; then
echo "QEMU doesn't support NUMA nodes on $(uname -m), skipping the test"
exit 0
fi
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test unit freezing and thawing via DBus and systemctl"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test PrivateUsers=yes on user manager"
IMAGE_NAME="private-users"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
has_user_dbus_socket || exit 0
test_require_bin mksquashfs
test_append_files() {
inst_binary mksquashfs
inst_binary unsquashfs
install_verity_minimal
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test log namespaces"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test timedated"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,30 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="testing homed"
# Skip the qemu version of the test, unless we have btrfs
(modprobe -nv btrfs && command -v mkfs.btrfs >/dev/null) || TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
get_bool "${NO_BUILD:-}" && HOMECTL_BIN="homectl" || HOMECTL_BIN="${BUILD_DIR:?}/homectl"
test_require_bin "$HOMECTL_BIN"
# Need loop devices for mounting images
test_append_files() {
if ! get_bool "$TEST_NO_QEMU" ; then
instmods loop =block
install_dmevent
install_btrfs
generate_module_dependencies
fi
inst_binary ssh
inst_binary sshd
inst_binary ssh-keygen
image_install -o /usr/lib/ssh/sshd-session /usr/libexec/openssh/sshd-session
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,44 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="test systemd-dissect"
IMAGE_NAME="dissect"
TEST_NO_NSPAWN=1
TEST_INSTALL_VERITY_MINIMAL=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
# On Ubuntu the BPF LSM is not enabled by default, so we need to do it via the
# kernel command line on boot
if [ "$LOOKS_LIKE_UBUNTU" = "yes" ]; then
KERNEL_OPTIONS=(
"lsm=lockdown,capability,landlock,yama,apparmor,bpf"
)
KERNEL_APPEND+=" ${KERNEL_OPTIONS[*]}"
fi
test_require_bin mksquashfs veritysetup sfdisk
test_append_files() {
instmods squashfs =squashfs
instmods dm_verity =md
install_dmevent
generate_module_dependencies
inst_binary wc
inst_binary sha256sum
inst_binary tar
if command -v openssl >/dev/null 2>&1; then
inst_binary openssl
fi
inst_binary mksquashfs
inst_binary unsquashfs
inst_binary pkcheck
inst_binary veritysetup
install_verity_minimal
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,23 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_REQUIRE_INSTALL_TESTS=0
TEST_DESCRIPTION="testing honor first shutdown"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
# Using timeout because if the test fails it can loop.
# The reason is because the poweroff executed by end.service
# could turn into a reboot if the test fails.
NSPAWN_TIMEOUT=60
check_result_nspawn_hook() {
local workspace="${1:?}"
"${JOURNALCTL:?}" -D "${workspace:?}/var/log/journal" --grep "Shutdown is already active. Skipping emergency action request" --no-pager
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test timer units when initial clock is ahead"
TEST_NO_NSPAWN=1
QEMU_OPTIONS+=" -rtc base=$(date -u +%Y-%m-%dT%H:%M:%S -d '+3 days')"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,87 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test credentials"
NSPAWN_CREDS=(
"--set-credential=mynspawncredential:strangevalue"
)
NSPAWN_ARGUMENTS="${NSPAWN_ARGUMENTS:-} ${NSPAWN_CREDS[*]}"
UNIT_CRED=$(base64 -w 0 <<EOF
[Service]
Type=oneshot
ExecStart=touch /tmp/unit-cred
EOF
)
DROPIN_CRED=$(base64 -w 0 <<EOF
[Service]
ExecStart=touch /tmp/unit-dropin
EOF
)
NAMED_DROPIN_CRED=$(base64 -w 0 <<EOF
[Service]
ExecStart=touch /tmp/unit-named-dropin
EOF
)
QEMU_CREDS=(
"-fw_cfg name=opt/io.systemd.credentials/myqemucredential,string=othervalue"
"-smbios type=11,value=io.systemd.credential:smbioscredential=magicdata"
"-smbios type=11,value=io.systemd.credential.binary:binarysmbioscredential=bWFnaWNiaW5hcnlkYXRh"
"-smbios type=11,value=io.systemd.credential.binary:sysusers.extra=dSBjcmVkdGVzdHVzZXIK"
"-smbios type=11,value=io.systemd.credential.binary:tmpfiles.extra=ZiAvdG1wL3NvdXJjZWRmcm9tY3JlZGVudGlhbCAtIC0gLSAtIHRtcGZpbGVzc2VjcmV0Cg=="
"-smbios type=11,value=io.systemd.credential.binary:fstab.extra=aW5qZWN0ZWQgL2luamVjdGVkIHRtcGZzIFgtbW91bnQubWtkaXIgMCAwCg=="
"-smbios type=11,value=io.systemd.credential:getty.ttys.container=idontexist"
"-smbios type=11,value=io.systemd.credential.binary:systemd.extra-unit.my-service.service=$UNIT_CRED"
"-smbios type=11,value=io.systemd.credential.binary:systemd.unit-dropin.my-service.service=$DROPIN_CRED"
"-smbios type=11,value=io.systemd.credential.binary:systemd.unit-dropin.my-service.service~30-named=$NAMED_DROPIN_CRED"
)
QEMU_OPTIONS="${QEMU_OPTIONS:-} ${QEMU_CREDS[*]}"
KERNEL_CREDS=(
"systemd.set_credential=kernelcmdlinecred:uff"
"systemd.set_credential=sysctl.extra:kernel.domainname=sysctltest"
"systemd.set_credential=login.motd:hello"
"systemd.set_credential=login.issue:welcome"
"systemd.set_credential_binary=waldi:d29vb29mZmZ3dWZmZnd1ZmYK"
"rd.systemd.import_credentials=no"
)
KERNEL_APPEND="${KERNEL_APPEND:-} ${KERNEL_CREDS[*]}"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
instmods qemu_fw_cfg
if get_bool "$LOOKS_LIKE_SUSE"; then
instmods dmi-sysfs
fi
generate_module_dependencies
}
run_qemu_hook() {
local td="$WORKDIR"/initrd.extra."$RANDOM"
mkdir -m 755 "$td"
add_at_exit_handler "rm -rf $td"
mkdir -m 755 "$td/etc" "$td"/etc/systemd "$td"/etc/systemd/system "$td"/etc/systemd/system/initrd.target.wants
cat > "$td"/etc/systemd/system/initrdcred.service <<EOF
[Unit]
Description=populate initrd credential dir
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=sh -c "mkdir -m 0755 -p /run/credentials && mkdir -m 0700 /run/credentials/@initrd && umask 0077 && echo guatemala > /run/credentials/@initrd/myinitrdcred"
EOF
ln -s ../initrdcred.service "$td"/etc/systemd/system/initrd.target.wants/initrdcred.service
( cd "$td" && find . | cpio -o -H newc -R root:root > "$td".cpio )
add_at_exit_handler "rm $td.cpio"
INITRD_EXTRA="$td.cpio"
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,28 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"
IMAGE_NAME="oomd"
# Need to set up swap
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
image_install mkswap swapon swapoff stress-ng
image_install -o btrfs
mkdir -p "${workspace:?}/etc/systemd/system/init.scope.d/"
cat >"${workspace:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF
[Scope]
MemoryHigh=infinity
StartupMemoryHigh=10G
EOF
}
do_test "$@" 55

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test systemd-repart"
IMAGE_NAME="repart"
IMAGE_ADDITIONAL_ROOT_SIZE=1000
TEST_FORCE_NEWIMAGE=1
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
test_append_files() {
if ! get_bool "${TEST_NO_QEMU:=}"; then
install_dmevent
instmods dm_verity =md
instmods erofs
generate_module_dependencies
image_install veritysetup
image_install -o mksquashfs
image_install -o mkfs.erofs
fi
inst_binary mcopy
image_install mkswap
if command -v openssl >/dev/null 2>&1; then
inst_binary openssl
fi
}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test auto restart of exited services which are stuck in reloading state"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test that mount/unmount storms can enter/exit rate limit state and will not leak units"
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test RestrictNetworkInterfaces="
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/17433"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,537 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# vi: ts=4 sw=4 tw=0 et:
#
# TODO:
# * SW raid (mdadm)
# * MD (mdadm) -> dm-crypt -> LVM
# * iSCSI -> dm-crypt -> LVM
set -e
TEST_DESCRIPTION="systemd-udev storage tests"
TEST_NO_NSPAWN=1
# Save only journals of failing test cases by default (to conserve space)
TEST_SAVE_JOURNAL="${TEST_SAVE_JOURNAL:-fail}"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
USER_QEMU_OPTIONS="${QEMU_OPTIONS:-}"
USER_KERNEL_APPEND="${KERNEL_APPEND:-}"
_host_has_feature() {(
set -e
case "${1:?}" in
btrfs)
host_has_btrfs
;;
iscsi)
# Client/initiator (Open-iSCSI)
command -v iscsiadm && command -v iscsid || return $?
# Server/target (TGT)
command -v tgtadm && command -v tgtd || return $?
;;
lvm)
command -v lvm || return $?
;;
mdadm)
host_has_mdadm
;;
multipath)
command -v multipath && command -v multipathd || return $?
;;
*)
echo >&2 "ERROR: Unknown feature '$1'"
# Make this a hard error to distinguish an invalid feature from
# a missing feature
exit 1
esac
)}
test_append_files() {(
local feature
# An associative array of requested (but optional) features and their
# respective "handlers" from test/test-functions
#
# Note: we install cryptsetup unconditionally, hence it's not explicitly
# checked for here
local -A features=(
[btrfs]=install_btrfs
[iscsi]=install_iscsi
[lvm]=install_lvm
[mdadm]=install_mdadm
[multipath]=install_multipath
)
instmods "=block" "=md" "=nvme" "=scsi"
install_dmevent
image_install lsblk swapoff swapon wc wipefs
# Install the optional features if the host has the respective tooling
for feature in "${!features[@]}"; do
if _host_has_feature "$feature"; then
"${features[$feature]}"
fi
done
generate_module_dependencies
for i in {0..127}; do
dd if=/dev/zero of="${TESTDIR:?}/disk$i.img" bs=1M count=1
echo "device$i" >"${TESTDIR:?}/disk$i.img"
done
)}
_image_cleanup() {
mount_initdir
# Clean up certain "problematic" files which may be left over by failing tests
: >"${initdir:?}/etc/fstab"
: >"${initdir:?}/etc/crypttab"
# Clear previous assignment
QEMU_OPTIONS_ARRAY=()
}
test_run_one() {
local test_id="${1:?}"
if run_qemu "$test_id"; then
check_result_qemu || { echo "qemu test failed"; return 1; }
fi
return 0
}
test_run() {
local test_id="${1:?}"
local passed=()
local failed=()
local skipped=()
local ec state
mount_initdir
if get_bool "${TEST_NO_QEMU:=}" || ! find_qemu_bin; then
dwarn "can't run qemu, skipping"
return 0
fi
# Execute each currently defined function starting with "testcase_"
for testcase in "${TESTCASES[@]}"; do
_image_cleanup
echo "------ $testcase: BEGIN ------"
# Note for my future frustrated self: `fun && xxx` (as well as ||, if, while,
# until, etc.) _DISABLES_ the `set -e` behavior in _ALL_ nested function
# calls made from `fun()`, i.e. the function _CONTINUES_ even when a called
# command returned non-zero EC. That may unexpectedly hide failing commands
# if not handled properly. See: bash(1) man page, `set -e` section.
#
# So, be careful when adding clean up snippets in the testcase_*() functions -
# if the `test_run_one()` function isn't the last command, you have propagate
# the exit code correctly (e.g. `test_run_one() || return $?`, see below).
ec=0
"$testcase" "$test_id" || ec=$?
case $ec in
0)
passed+=("$testcase")
state="PASS"
;;
77)
skipped+=("$testcase")
state="SKIP"
;;
*)
failed+=("$testcase")
state="FAIL"
esac
echo "------ $testcase: END ($state) ------"
done
echo "Passed tests: ${#passed[@]}"
printf " * %s\n" "${passed[@]}"
echo "Skipped tests: ${#skipped[@]}"
printf " * %s\n" "${skipped[@]}"
echo "Failed tests: ${#failed[@]}"
printf " * %s\n" "${failed[@]}"
[[ ${#failed[@]} -eq 0 ]] || return 1
return 0
}
testcase_virtio_scsi_basic() {
if ! "${QEMU_BIN:?}" -device help | grep 'name "virtio-scsi-pci"'; then
echo "virtio-scsi-pci device driver is not available, skipping test..."
return 77
fi
local i
local qemu_opts=(
"-device virtio-scsi-pci,id=scsi0"
"-device virtio-scsi-pci,id=scsi1"
"-device virtio-scsi-pci,id=scsi2"
"-device virtio-scsi-pci,id=scsi3"
)
for i in {0..127}; do
# Add 128 drives, 32 per bus
qemu_opts+=(
"-device scsi-hd,drive=drive$i,bus=scsi$((i / 32)).0,channel=0,scsi-id=$((i % 32)),lun=0"
"-drive format=raw,cache=unsafe,file=${TESTDIR:?}/disk$i.img,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}"
}
testcase_nvme_basic() {
if ! "${QEMU_BIN:?}" -device help | grep 'name "nvme"'; then
echo "nvme device driver is not available, skipping test..."
return 77
fi
local i
local qemu_opts=()
for (( i = 0; i < 5; i++ )); do
qemu_opts+=(
"-device" "nvme,drive=nvme$i,serial=deadbeef$i,num_queues=8"
"-drive" "format=raw,cache=unsafe,file=${TESTDIR:?}/disk$i.img,if=none,id=nvme$i"
)
done
for (( i = 5; i < 10; i++ )); do
qemu_opts+=(
"-device" "nvme,drive=nvme$i,serial= deadbeef $i ,num_queues=8"
"-drive" "format=raw,cache=unsafe,file=${TESTDIR:?}/disk$i.img,if=none,id=nvme$i"
)
done
for (( i = 10; i < 15; i++ )); do
qemu_opts+=(
"-device" "nvme,drive=nvme$i,serial= dead/beef/$i ,num_queues=8"
"-drive" "format=raw,cache=unsafe,file=${TESTDIR:?}/disk$i.img,if=none,id=nvme$i"
)
done
for (( i = 15; i < 20; i++ )); do
qemu_opts+=(
"-device" "nvme,drive=nvme$i,serial=dead/../../beef/$i,num_queues=8"
"-drive" "format=raw,cache=unsafe,file=${TESTDIR:?}/disk$i.img,if=none,id=nvme$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${USER_QEMU_OPTIONS}"
QEMU_OPTIONS_ARRAY=("${qemu_opts[@]}")
test_run_one "${1:?}"
}
# Testcase for:
# * https://github.com/systemd/systemd/pull/24748
# * https://github.com/systemd/systemd/pull/24766
# * https://github.com/systemd/systemd/pull/24946
# Docs: https://qemu.readthedocs.io/en/latest/system/devices/nvme.html#nvm-subsystems
testcase_nvme_subsystem() {
if ! "${QEMU_BIN:?}" -device help | grep 'name "nvme-subsys"'; then
echo "nvme-subsystem device driver is not available, skipping test..."
return 77
fi
local i
local qemu_opts=(
# Create an NVM Subsystem Device
"-device nvme-subsys,id=nvme-subsys-64,nqn=subsys64"
# Attach two NVM controllers to it
"-device nvme,subsys=nvme-subsys-64,serial=deadbeef"
"-device nvme,subsys=nvme-subsys-64,serial=deadbeef"
# And create two shared namespaces attached to both controllers
"-device nvme-ns,drive=nvme0,nsid=16,shared=on"
"-drive format=raw,cache=unsafe,file=${TESTDIR:?}/disk0.img,if=none,id=nvme0"
"-device nvme-ns,drive=nvme1,nsid=17,shared=on"
"-drive format=raw,cache=unsafe,file=${TESTDIR:?}/disk1.img,if=none,id=nvme1"
)
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}"
}
# Test for issue https://github.com/systemd/systemd/issues/20212
testcase_virtio_scsi_identically_named_partitions() {
if ! "${QEMU_BIN:?}" -device help | grep 'name "virtio-scsi-pci"'; then
echo "virtio-scsi-pci device driver is not available, skipping test..."
return 77
fi
# Create 16 disks, with 8 partitions per disk (all identically named)
# and attach them to a virtio-scsi controller
local qemu_opts=("-device virtio-scsi-pci,id=scsi0,num_queues=4")
local diskpath="${TESTDIR:?}/namedpart0.img"
local i num_disk qemu_timeout
if get_bool "${IS_BUILT_WITH_ASAN:=}" || ! get_bool "$QEMU_KVM"; then
num_disk=4
else
num_disk=16
fi
dd if=/dev/zero of="$diskpath" bs=1M count=18
for ((i = 0; i < num_disk; i++)); do
diskpath="${TESTDIR:?}/namedpart$i.img"
if [[ $i -gt 0 ]]; then
cp -uv "${TESTDIR:?}/namedpart0.img" "$diskpath"
fi
qemu_opts+=(
"-device scsi-hd,drive=drive$i,bus=scsi0.0,channel=0,scsi-id=0,lun=$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
# Bump the timeout when collecting test coverage, since the test is a bit
# slower in that case
if get_bool "${IS_BUILT_WITH_ASAN:=}" || ! get_bool "$QEMU_KVM"; then
qemu_timeout=240
elif is_built_with_coverage; then
qemu_timeout=120
else
qemu_timeout=60
fi
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
# Limit the number of VCPUs and set a timeout to make sure we trigger the issue
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
QEMU_SMP=1 QEMU_TIMEOUT=$qemu_timeout test_run_one "${1:?}" || return $?
rm -f "${TESTDIR:?}"/namedpart*.img
}
testcase_multipath_basic_failover() {
if ! _host_has_feature "multipath"; then
echo "Missing multipath tools, skipping the test..."
return 77
fi
local qemu_opts=("-device virtio-scsi-pci,id=scsi")
local partdisk="${TESTDIR:?}/multipathpartitioned.img"
local image nback ndisk wwn
dd if=/dev/zero of="$partdisk" bs=1M count=16
# Add 16 multipath devices, each backed by 4 paths
for ndisk in {0..15}; do
wwn="0xDEADDEADBEEF$(printf "%.4d" "$ndisk")"
# Use a partitioned disk for the first device to test failover
[[ $ndisk -eq 0 ]] && image="$partdisk" || image="${TESTDIR:?}/disk$ndisk.img"
for nback in {0..3}; do
qemu_opts+=(
"-device scsi-hd,drive=drive${ndisk}x${nback},serial=MPIO$ndisk,wwn=$wwn"
"-drive format=raw,cache=unsafe,file=$image,file.locking=off,if=none,id=drive${ndisk}x${nback}"
)
done
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "$partdisk"
}
# Test case for issue https://github.com/systemd/systemd/issues/19946
testcase_simultaneous_events() {
local qemu_opts=("-device virtio-scsi-pci,id=scsi")
local diskpath i
for i in {0..9}; do
diskpath="${TESTDIR:?}/simultaneousevents${i}.img"
dd if=/dev/zero of="$diskpath" bs=1M count=128
qemu_opts+=(
"-device scsi-hd,drive=drive$i,serial=deadbeeftest$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "$diskpath"
}
testcase_lvm_basic() {
if ! _host_has_feature "lvm"; then
echo "Missing lvm tools, skipping the test..."
return 77
fi
local qemu_opts=("-device virtio-scsi-pci,id=scsi0")
local diskpath i
# Attach 4 SATA disks to the VM (and set their model and serial fields
# to something predictable, so we can refer to them later)
for i in {0..3}; do
diskpath="${TESTDIR:?}/lvmbasic${i}.img"
dd if=/dev/zero of="$diskpath" bs=1M count=32
qemu_opts+=(
"-device scsi-hd,drive=drive$i,vendor=systemd,product=foobar,serial=deadbeeflvm$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "${TESTDIR:?}"/lvmbasic*.img
}
testcase_btrfs_basic() {
if ! _host_has_feature "btrfs"; then
echo "Missing btrfs tools/modules, skipping the test..."
return 77
fi
local qemu_opts=("-device virtio-scsi-pci,id=scsi0")
local diskpath i size
for i in {0..3}; do
diskpath="${TESTDIR:?}/btrfsbasic${i}.img"
# Make the first disk larger for multi-partition tests
[[ $i -eq 0 ]] && size=350 || size=128
dd if=/dev/zero of="$diskpath" bs=1M count="$size"
qemu_opts+=(
"-device scsi-hd,drive=drive$i,vendor=systemd,product=foobar,serial=deadbeefbtrfs$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "${TESTDIR:?}"/btrfsbasic*.img
}
testcase_iscsi_lvm() {
if ! _host_has_feature "iscsi" || ! _host_has_feature "lvm"; then
echo "Missing iSCSI client/server tools (Open-iSCSI/TGT) or LVM utilities, skipping the test..."
return 77
fi
local qemu_opts=("-device virtio-scsi-pci,id=scsi0")
local diskpath i size
for i in {0..3}; do
diskpath="${TESTDIR:?}/iscsibasic${i}.img"
# Make the first disk larger for multi-partition tests
[[ $i -eq 0 ]] && size=150 || size=64
# Make the first disk larger for multi-partition tests
dd if=/dev/zero of="$diskpath" bs=1M count="$size"
qemu_opts+=(
"-device scsi-hd,drive=drive$i,vendor=systemd,product=foobar,serial=deadbeefiscsi$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "${TESTDIR:?}"/iscsibasic*.img
}
testcase_long_sysfs_path() {
local brid
local testdisk="${TESTDIR:?}/longsysfspath.img"
local qemu_opts=(
"-drive if=none,id=drive0,format=raw,cache=unsafe,file=$testdisk"
"-device pci-bridge,id=pci_bridge0,chassis_nr=64"
)
dd if=/dev/zero of="$testdisk" bs=1M count=64
# Create 25 additional PCI bridges, each one connected to the previous one
# (basically a really long extension cable), and attach a virtio drive to
# the last one. This should force udev into attempting to create a device
# unit with a _really_ long name.
for brid in {1..25}; do
qemu_opts+=("-device pci-bridge,id=pci_bridge$brid,bus=pci_bridge$((brid-1)),chassis_nr=$((64+brid))")
done
qemu_opts+=("-device virtio-blk-pci,drive=drive0,bus=pci_bridge$brid,serial=long-sysfs-path")
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "${testdisk:?}"
}
testcase_mdadm_basic() {
if ! _host_has_feature "mdadm"; then
echo "Missing mdadm tools/modules, skipping the test..."
return 77
fi
local qemu_opts=("-device virtio-scsi-pci,id=scsi0")
local diskpath i size
for i in {0..4}; do
diskpath="${TESTDIR:?}/mdadmbasic${i}.img"
dd if=/dev/zero of="$diskpath" bs=1M count=64
qemu_opts+=(
"-device scsi-hd,drive=drive$i,vendor=systemd,product=foobar,serial=deadbeefmdadm$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "${TESTDIR:?}"/mdadmbasic*.img
}
testcase_mdadm_lvm() {
if ! _host_has_feature "mdadm" || ! _host_has_feature "lvm"; then
echo "Missing mdadm tools/modules or LVM tools, skipping the test..."
return 77
fi
local qemu_opts=("-device virtio-scsi-pci,id=scsi0")
local diskpath i size
for i in {0..4}; do
diskpath="${TESTDIR:?}/mdadmlvm${i}.img"
dd if=/dev/zero of="$diskpath" bs=1M count=64
qemu_opts+=(
"-device scsi-hd,drive=drive$i,vendor=systemd,product=foobar,serial=deadbeefmdadmlvm$i"
"-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i"
)
done
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}" || return $?
rm -f "${TESTDIR:?}"/mdadmlvm*.img
}
# Allow overriding which tests should be run from the "outside", useful for manual
# testing (make -C test/... TESTCASES="testcase1 testcase2")
if [[ -v "TESTCASES" && -n "$TESTCASES" ]]; then
read -ra TESTCASES <<< "$TESTCASES"
else
# This must run after all functions were defined, otherwise `declare -F` won't
# see them
mapfile -t TESTCASES < <(declare -F | awk '$3 ~ /^testcase_/ {print $3;}')
fi
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test analyze"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test device isolation"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="dm-integrity test"
TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {(
instmods loop =block
instmods dm_integrity =md
inst_binary integritysetup
inst_binary blkid
install_dmevent
generate_module_dependencies
)}
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test propagation of exit status to On{Failure,Success}= dependencies"
TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@"

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1,46 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="shutdown testing"
IMAGE_NAME="shutdown"
TEST_NO_QEMU=yes
# Prevent shutdown in test suite, the expect script does that manually.
TEST_SKIP_SHUTDOWN=yes
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
_ORIG_NSPAWN="${SYSTEMD_NSPAWN:?}"
SYSTEMD_NSPAWN="${STATEDIR:?}/run-nspawn"
setup_nspawn_root_hook() {
cat >"${STATEDIR:?}/run-nspawn" <<EOF
#!/bin/bash
exec "${TEST_BASE_DIR:?}/test-shutdown.py" -v -- "$_ORIG_NSPAWN" --background= "\$@"
exit 1
EOF
chmod 755 "${STATEDIR:?}"/run-nspawn
}
test_append_files() {
local workspace="${1:?}"
# Shorten the service stop/abort timeouts to let systemd SIGKILL stubborn
# processes as soon as possible, as we don't really care about them in this
# particular test
mkdir -p "$workspace/etc/systemd/system.conf.d"
cat >"$workspace/etc/systemd/system.conf.d/99-timeout.conf" <<EOF
[Manager]
DefaultTimeoutStopSec=30s
DefaultTimeoutAbortSec=30s
EOF
inst /usr/bin/screen
echo "PS1='screen\$WINDOW # '" >>"$workspace/root/.bashrc"
echo "TERM=linux" >>"$workspace/root/.bash_profile"
echo 'startup_message off' >"$workspace/etc/screenrc"
echo 'bell_msg ""' >>"$workspace/etc/screenrc"
}
do_test "$@"

Some files were not shown because too many files have changed in this diff Show More