1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-09-16 17:45:52 +03:00

test: make the test entrypoint scripts shellcheck-compliant

This commit is contained in:
Frantisek Sumsal
2021-04-19 13:01:59 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 4d686e6b0b
commit 3f161ba9bc
53 changed files with 311 additions and 152 deletions

View File

@@ -1,17 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Basic systemd setup" TEST_DESCRIPTION="Basic systemd setup"
IMAGE_NAME="basic" IMAGE_NAME="basic"
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes} RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
TEST_REQUIRE_INSTALL_TESTS=0 TEST_REQUIRE_INSTALL_TESTS=0
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() { test_append_files() {
# install tests manually so the test is functional even when -Dinstall-tests=false # install tests manually so the test is functional even when -Dinstall-tests=false
local dst="$1/usr/lib/systemd/tests/testdata/units/" local dst="${1:?}/usr/lib/systemd/tests/testdata/units/"
mkdir -p "$dst" mkdir -p "$dst"
cp -v $TEST_UNITS_DIR/{testsuite-01,end}.service $TEST_UNITS_DIR/testsuite.target "$dst" cp -v "$TEST_UNITS_DIR"/{testsuite-01,end}.service "$TEST_UNITS_DIR/testsuite.target" "$dst"
} }
do_test "$@" 01 do_test "$@" 01

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Run unit tests under containers" TEST_DESCRIPTION="Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER=yes RUN_IN_UNPRIVILEGED_CONTAINER=yes
@@ -11,53 +12,63 @@ frobnicate!
$KERNEL_APPEND $KERNEL_APPEND
" "
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
check_result_nspawn() { check_result_nspawn() {
local _ret=1 local workspace="${1:?}"
[[ -e $1/testok ]] && _ret=0 local ret=1
if [[ -s $1/failed ]]; then
_ret=$(($_ret+1)) [[ -e "$workspace/testok" ]] && ret=0
if [[ -s "$workspace/failed" ]]; then
ret=$((ret + 1))
echo "=== Failed test log ===" echo "=== Failed test log ==="
cat $1/failed cat "$workspace/failed"
else else
if [[ -s $1/skipped ]]; then if [[ -s "$workspace/skipped" ]]; then
echo "=== Skipped test log ==" echo "=== Skipped test log =="
cat $1/skipped cat "$workspace/skipped"
fi fi
if [[ -s $1/testok ]]; then if [[ -s "$workspace/testok" ]]; then
echo "=== Passed tests ===" echo "=== Passed tests ==="
cat $1/testok cat "$workspace/testok"
fi fi
fi fi
save_journal $1/var/log/journal
_umount_dir $initdir save_journal "$workspace/var/log/journal"
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1)) _umount_dir "${initdir:?}"
return $_ret
[[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1))
return $ret
} }
check_result_qemu() { check_result_qemu() {
local _ret=1 local ret=1
mount_initdir mount_initdir
[[ -e $initdir/testok ]] && _ret=0 [[ -e "${initdir:?}/testok" ]] && ret=0
if [[ -s $initdir/failed ]]; then
_ret=$(($_ret+1)) if [[ -s "$initdir/failed" ]]; then
ret=$((ret + 1))
echo "=== Failed test log ===" echo "=== Failed test log ==="
cat $initdir/failed cat "$initdir/failed"
else else
if [[ -s $initdir/skipped ]]; then if [[ -s "$initdir/skipped" ]]; then
echo "=== Skipped test log ==" echo "=== Skipped test log =="
cat $initdir/skipped cat "$initdir/skipped"
fi fi
if [[ -s $initdir/testok ]]; then if [[ -s "$initdir/testok" ]]; then
echo "=== Passed tests ===" echo "=== Passed tests ==="
cat $initdir/testok cat "$initdir/testok"
fi fi
fi fi
save_journal $initdir/var/log/journal
_umount_dir $initdir save_journal "$initdir/var/log/journal"
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1)) _umount_dir "$initdir"
return $_ret
[[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1))
return $ret
} }
do_test "$@" 02 do_test "$@" 02

View File

@@ -1,9 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Job-related tests" TEST_DESCRIPTION="Job-related tests"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
IMAGE_NAME="default" IMAGE_NAME="default"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 03 do_test "$@" 03

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Journal-related tests" TEST_DESCRIPTION="Journal-related tests"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 04 do_test "$@" 04

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Resource limits-related tests" TEST_DESCRIPTION="Resource limits-related tests"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 05 do_test "$@" 05

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="SELinux tests" TEST_DESCRIPTION="SELinux tests"
IMAGE_NAME="selinux" IMAGE_NAME="selinux"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
@@ -12,32 +13,39 @@ TEST_NO_NSPAWN=1
# Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing # Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing
test -f /usr/share/selinux/devel/include/system/systemd.if || exit 0 test -f /usr/share/selinux/devel/include/system/systemd.if || exit 0
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
SETUP_SELINUX=yes SETUP_SELINUX=yes
KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux" KERNEL_APPEND="${KERNEL_APPEND:=} selinux=1 security=selinux"
test_append_files() { test_append_files() {
( (
local workspace="${1:?}"
local policy_headers_dir=/usr/share/selinux/devel
local modules_dir=/var/lib/selinux
setup_selinux setup_selinux
local _modules_dir=/var/lib/selinux # Make sure we never expand this to "/..."
rm -rf $1/$_modules_dir rm -rf "${workspace:?}/$modules_dir"
if ! cp -ar $_modules_dir $1/$_modules_dir; then
dfatal "Failed to copy $_modules_dir" if ! cp -ar "$modules_dir" "$workspace/$modules_dir"; then
dfatal "Failed to copy $modules_dir"
exit 1 exit 1
fi fi
local _policy_headers_dir=/usr/share/selinux/devel rm -rf "${workspace:?}/$policy_headers_dir"
rm -rf $1/$_policy_headers_dir
inst_dir /usr/share/selinux inst_dir /usr/share/selinux
if ! cp -ar $_policy_headers_dir $1/$_policy_headers_dir; then
dfatal "Failed to copy $_policy_headers_dir" if ! cp -ar "$policy_headers_dir" "$workspace/$policy_headers_dir"; then
dfatal "Failed to copy $policy_headers_dir"
exit 1 exit 1
fi fi
mkdir $1/systemd-test-module mkdir "$workspace/systemd-test-module"
cp systemd_test.te $1/systemd-test-module cp systemd_test.te "$workspace/systemd-test-module"
cp systemd_test.if $1/systemd-test-module cp systemd_test.if "$workspace/systemd-test-module"
cp systemd_test.fc $1/systemd-test-module cp systemd_test.fc "$workspace/systemd-test-module"
dracut_install -o sesearch dracut_install -o sesearch
dracut_install runcon dracut_install runcon
dracut_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile dracut_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile

View File

@@ -1,9 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
NSPAWN_TIMEOUT=30 NSPAWN_TIMEOUT=30

View File

@@ -1,10 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
IMAGE_NAME="test08" IMAGE_NAME="test08"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=300 QEMU_TIMEOUT=300
FSTYPE=ext4 FSTYPE=ext4
TEST_FORCE_NEWIMAGE=1 TEST_FORCE_NEWIMAGE=1

View File

@@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=300 QEMU_TIMEOUT=300
do_test "$@" 09 do_test "$@" 09

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 10 do_test "$@" 10

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 11 do_test "$@" 11

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171" TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 12 do_test "$@" 12

View File

@@ -1,15 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="systemd-nspawn smoke test" TEST_DESCRIPTION="systemd-nspawn smoke test"
IMAGE_NAME="nspawn" IMAGE_NAME="nspawn"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() { test_append_files() {
( (
../create-busybox-container $1/testsuite-13.nc-container local workspace="${1:?}"
initdir="$1/testsuite-13.nc-container" dracut_install nc ip md5sum
"$TEST_BASE_DIR/create-busybox-container" "$workspace/testsuite-13.nc-container"
initdir="$workspace/testsuite-13.nc-container" dracut_install nc ip md5sum
) )
} }

View File

@@ -1,13 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="/etc/machine-id testing" TEST_DESCRIPTION="/etc/machine-id testing"
IMAGE_NAME="badid" IMAGE_NAME="badid"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() { test_append_files() {
printf "556f48e837bc4424a710fa2e2c9d3e3c\ne3d\n" >$1/etc/machine-id printf "556f48e837bc4424a710fa2e2c9d3e3c\ne3d\n" >"${1:?}/etc/machine-id"
} }
do_test "$@" 14 do_test "$@" 14

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Dropin tests" TEST_DESCRIPTION="Dropin tests"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 15 do_test "$@" 15

View File

@@ -1,9 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests" TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests"
SKIP_INITRD=yes SKIP_INITRD=yes
TEST_NO_QEMU=1 TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 16 do_test "$@" 16

View File

@@ -1,10 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="UDEV" TEST_DESCRIPTION="UDEV"
IMAGE_NAME="udev" IMAGE_NAME="udev"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=500 QEMU_TIMEOUT=500
test_append_files() { test_append_files() {

View File

@@ -1,8 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="FailureAction= operation" TEST_DESCRIPTION="FailureAction= operation"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=600 QEMU_TIMEOUT=600
do_test "$@" 18 do_test "$@" 18

View File

@@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy" TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=600 QEMU_TIMEOUT=600
UNIFIED_CGROUP_HIERARCHY=yes UNIFIED_CGROUP_HIERARCHY=yes

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test changing main PID" TEST_DESCRIPTION="test changing main PID"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 20 do_test "$@" 20

View File

@@ -1,12 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Tmpfiles related tests" TEST_DESCRIPTION="Tmpfiles related tests"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() { test_append_files() {
if [[ "$IS_BUILT_WITH_ASAN" == "yes" ]]; then if [[ "${IS_BUILT_WITH_ASAN:=}" == "yes" ]]; then
if [[ -z "$initdir" ]]; then if [[ -z "${initdir:=}" ]]; then
echo >&2 "\$initdir is not defined, can't continue" echo >&2 "\$initdir is not defined, can't continue"
exit 1 exit 1
fi fi

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test Type=exec" TEST_DESCRIPTION="test Type=exec"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 23 do_test "$@" 23

View File

@@ -1,68 +1,77 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="cryptsetup systemd setup" TEST_DESCRIPTION="cryptsetup systemd setup"
IMAGE_NAME="cryptsetup" IMAGE_NAME="cryptsetup"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
TEST_FORCE_NEWIMAGE=1 TEST_FORCE_NEWIMAGE=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
check_result_qemu() { check_result_qemu() {
ret=1 local ret=1
mount_initdir mount_initdir
[[ -e $initdir/testok ]] && ret=0 [[ -e "${initdir:?}/testok" ]] && ret=0
[[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR [[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}"
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
mount /dev/mapper/varcrypt $initdir/var cryptsetup luksOpen "${LOOPDEV:?}p2" varcrypt <"$TESTDIR/keyfile"
save_journal $initdir/var/log/journal mount /dev/mapper/varcrypt "$initdir/var"
_umount_dir $initdir/var save_journal "$initdir/var/log/journal"
_umount_dir $initdir _umount_dir "$initdir/var"
_umount_dir "$initdir"
cryptsetup luksClose /dev/mapper/varcrypt cryptsetup luksClose /dev/mapper/varcrypt
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
echo $JOURNAL_LIST [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
test -s $TESTDIR/failed && ret=$(($ret+1)) echo "${JOURNAL_LIST:-No journals were saved}"
test -s "$TESTDIR/failed" && ret=$((ret + 1))
return $ret return $ret
} }
test_create_image() { test_create_image() {
create_empty_image_rootdir create_empty_image_rootdir
echo -n test >$TESTDIR/keyfile
cryptsetup -q luksFormat --pbkdf pbkdf2 --pbkdf-force-iterations 1000 ${LOOPDEV}p2 $TESTDIR/keyfile echo -n test >"${TESTDIR:?}/keyfile"
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile cryptsetup -q luksFormat --pbkdf pbkdf2 --pbkdf-force-iterations 1000 "${LOOPDEV:?}p2" "$TESTDIR/keyfile"
cryptsetup luksOpen "${LOOPDEV}p2" varcrypt <"$TESTDIR/keyfile"
mkfs.ext4 -L var /dev/mapper/varcrypt mkfs.ext4 -L var /dev/mapper/varcrypt
mkdir -p $initdir/var mkdir -p "${initdir:?}/var"
mount /dev/mapper/varcrypt $initdir/var mount /dev/mapper/varcrypt "$initdir/var"
# Create what will eventually be our root filesystem onto an overlay # Create what will eventually be our root filesystem onto an overlay
( (
LOG_LEVEL=5 LOG_LEVEL=5
eval $(udevadm info --export --query=env --name=/dev/mapper/varcrypt) # shellcheck source=/dev/null
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) source <(udevadm info --export --query=env --name=/dev/mapper/varcrypt)
# shellcheck source=/dev/null
source <(udevadm info --export --query=env --name="${LOOPDEV}p2")
setup_basic_environment setup_basic_environment
mask_supporting_services mask_supporting_services
install_dmevent install_dmevent
generate_module_dependencies generate_module_dependencies
cat >$initdir/etc/crypttab <<EOF cat >"$initdir/etc/crypttab" <<EOF
$DM_NAME UUID=$ID_FS_UUID /etc/varkey $DM_NAME UUID=$ID_FS_UUID /etc/varkey
EOF EOF
echo -n test >$initdir/etc/varkey echo -n test >"$initdir/etc/varkey"
cat $initdir/etc/crypttab | ddebug ddebug <"$initdir/etc/crypttab"
cat >>$initdir/etc/fstab <<EOF cat >>"$initdir/etc/fstab" <<EOF
/dev/mapper/varcrypt /var ext4 defaults 0 1 /dev/mapper/varcrypt /var ext4 defaults 0 1
EOF EOF
# Forward journal messages to the console, so we have something # Forward journal messages to the console, so we have something
# to investigate even if we fail to mount the encrypted /var # to investigate even if we fail to mount the encrypted /var
echo ForwardToConsole=yes >> $initdir/etc/systemd/journald.conf echo ForwardToConsole=yes >> "$initdir/etc/systemd/journald.conf"
) )
} }
cleanup_root_var() { cleanup_root_var() {
ddebug "umount $initdir/var" ddebug "umount ${initdir:?}/var"
mountpoint $initdir/var && umount $initdir/var mountpoint "$initdir/var" && umount "$initdir/var"
[[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
} }

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test importd" TEST_DESCRIPTION="test importd"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 25 do_test "$@" 25

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test setenv" TEST_DESCRIPTION="test setenv"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 26 do_test "$@" 26

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test StandardOutput=file:" TEST_DESCRIPTION="test StandardOutput=file:"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 27 do_test "$@" 27

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Ensure %j Wants directives work" TEST_DESCRIPTION="Ensure %j Wants directives work"
RUN_IN_UNPRIVILEGED_CONTAINER=yes RUN_IN_UNPRIVILEGED_CONTAINER=yes
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 28 do_test "$@" 28

View File

@@ -2,12 +2,14 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
set -e set -e
TEST_DESCRIPTION="test systemd-portabled" TEST_DESCRIPTION="test systemd-portabled"
IMAGE_NAME="portabled" IMAGE_NAME="portabled"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
TEST_INSTALL_VERITY_MINIMAL=1 TEST_INSTALL_VERITY_MINIMAL=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
# Need loop devices for mounting images # Need loop devices for mounting images
test_append_files() { test_append_files() {

View File

@@ -1,7 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange=" TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange="
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 30 do_test "$@" 30

View File

@@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997" TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
QEMU_TIMEOUT=300 QEMU_TIMEOUT=300
do_test "$@" 31 do_test "$@" 31

View File

@@ -1,8 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test OOM killer logic" TEST_DESCRIPTION="test OOM killer logic"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
UNIFIED_CGROUP_HIERARCHY=yes UNIFIED_CGROUP_HIERARCHY=yes

View File

@@ -2,7 +2,10 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
set -e set -e
TEST_DESCRIPTION="test CleanUnit" TEST_DESCRIPTION="test CleanUnit"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 33 do_test "$@" 33

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUser=0 and back" TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUser=0 and back"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 34 do_test "$@" 34

View File

@@ -3,7 +3,10 @@ set -e
TEST_DESCRIPTION="test NUMAPolicy= and NUMAMask= options" TEST_DESCRIPTION="test NUMAPolicy= and NUMAMask= options"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
if qemu_min_version "5.2.0"; then if qemu_min_version "5.2.0"; then
QEMU_OPTIONS="-object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0" QEMU_OPTIONS="-object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0"
else else

View File

@@ -2,7 +2,10 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
set -e set -e
TEST_DESCRIPTION="test RuntimeDirectoryPreserve=yes" TEST_DESCRIPTION="test RuntimeDirectoryPreserve=yes"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 37 do_test "$@" 37

View File

@@ -1,7 +1,10 @@
#!/bin/bash #!/bin/bash
set -e set -e
TEST_DESCRIPTION="test unit freezing and thawing via DBus and systemctl" TEST_DESCRIPTION="test unit freezing and thawing via DBus and systemctl"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 38 do_test "$@" 38

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test ExecReload= (PR #13098)" TEST_DESCRIPTION="Test ExecReload= (PR #13098)"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 39 do_test "$@" 39

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test ExecXYZEx= service unit dbus hookups" TEST_DESCRIPTION="test ExecXYZEx= service unit dbus hookups"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 40 do_test "$@" 40

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test oneshot unit restart on failure" TEST_DESCRIPTION="Test oneshot unit restart on failure"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 41 do_test "$@" 41

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test that ExecStopPost= is always run" TEST_DESCRIPTION="test that ExecStopPost= is always run"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 42 do_test "$@" 42

View File

@@ -1,7 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test PrivateUsers=yes on user manager" TEST_DESCRIPTION="Test PrivateUsers=yes on user manager"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
has_user_dbus_socket || exit 0 has_user_dbus_socket || exit 0

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test log namespaces" TEST_DESCRIPTION="test log namespaces"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 44 do_test "$@" 44

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="testing homed" TEST_DESCRIPTION="testing homed"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 46 do_test "$@" 46

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test that KillMode=mixed does not leave left over processes with ExecStopPost=" TEST_DESCRIPTION="Test that KillMode=mixed does not leave left over processes with ExecStopPost="
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 47 do_test "$@" 47

View File

@@ -2,7 +2,10 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
set -e set -e
TEST_DESCRIPTION="test StartStopNoReload" TEST_DESCRIPTION="test StartStopNoReload"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 48 do_test "$@" 48

View File

@@ -2,6 +2,8 @@
set -e set -e
TEST_DESCRIPTION="test adding new BindPaths while unit is already running" TEST_DESCRIPTION="test adding new BindPaths while unit is already running"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 49 do_test "$@" 49

View File

@@ -2,12 +2,14 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
set -e set -e
TEST_DESCRIPTION="test systemd-dissect" TEST_DESCRIPTION="test systemd-dissect"
IMAGE_NAME="dissect" IMAGE_NAME="dissect"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
TEST_INSTALL_VERITY_MINIMAL=1 TEST_INSTALL_VERITY_MINIMAL=1
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
command -v mksquashfs >/dev/null 2>&1 || exit 0 command -v mksquashfs >/dev/null 2>&1 || exit 0
command -v veritysetup >/dev/null 2>&1 || exit 0 command -v veritysetup >/dev/null 2>&1 || exit 0

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test ExecCondition= does not restart on abnormal or failure" TEST_DESCRIPTION="Test ExecCondition= does not restart on abnormal or failure"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 51 do_test "$@" 51

View File

@@ -1,18 +1,20 @@
#!/bin/bash #!/bin/bash
set -e set -e
. $TEST_BASE_DIR/test-functions
TEST_REQUIRE_INSTALL_TESTS=0 TEST_REQUIRE_INSTALL_TESTS=0
TEST_DESCRIPTION="testing honor first shutdown" TEST_DESCRIPTION="testing honor first shutdown"
#INTERACTIVE_DEBUG=1
TEST_NO_QEMU=1 TEST_NO_QEMU=1
#Using timeout because if the test fails it can loop. # 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 # The reason is because the poweroff executed by end.service
# could turn into a reboot if the test fails. # could turn into a reboot if the test fails.
NSPAWN_TIMEOUT=20 NSPAWN_TIMEOUT=20
#Remove this file if it exists. this is used along with # Remove this file if it exists. This is used along with
# the make target "finish". Since concrete confirmaion is # the make target "finish". Since concrete confirmation is
# only found from the console during the poweroff. # only found from the console during the poweroff.
rm -f /tmp/honorfirstshutdown.log >/dev/null rm -f /tmp/honorfirstshutdown.log >/dev/null

View File

@@ -4,8 +4,9 @@ set -e
TEST_DESCRIPTION="test timer units when initial clock is ahead" TEST_DESCRIPTION="test timer units when initial clock is ahead"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
future_date=$(date -u +%Y-%m-%dT%H:%M:%S -d '+3 days') QEMU_OPTIONS="-rtc base=$(date -u +%Y-%m-%dT%H:%M:%S -d '+3 days')"
QEMU_OPTIONS="-rtc base=${future_date}"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 53 do_test "$@" 53

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test credentials" TEST_DESCRIPTION="test credentials"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 54 do_test "$@" 54

View File

@@ -1,47 +1,56 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="systemd-oomd Memory Pressure Test" TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"
. $TEST_BASE_DIR/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
check_result_nspawn() { check_result_nspawn() {
local workspace="${1:?}"
local ret=1 local ret=1
local journald_report="" local journald_report=""
local pids="" local pids=""
[[ -e $1/testok ]] && ret=0
if [[ -e $1/skipped ]]; then [[ -e "$workspace/testok" ]] && ret=0
if [[ -e "$workspace/skipped" ]]; then
echo "TEST-56-OOMD was skipped:" echo "TEST-56-OOMD was skipped:"
cat $1/skipped cat "$workspace/skipped"
ret=0 ret=0
fi fi
[[ -f $1/failed ]] && cp -a $1/failed $TESTDIR
save_journal $1/var/log/journal [[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}"
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed save_journal "$workspace/var/log/journal"
echo $JOURNAL_LIST [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
test -s $TESTDIR/failed && ret=$(($ret+1)) echo "${JOURNAL_LIST:-No journals were saved}"
[ -n "$TIMED_OUT" ] && ret=$(($ret+1))
check_asan_reports "$1" || ret=$(($ret+1)) test -s "$TESTDIR/failed" && ret=$((ret + 1))
_umount_dir $initdir [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1))
check_asan_reports "$workspace" || ret=$((ret + 1))
_umount_dir "${initdir:?}"
return $ret return $ret
} }
check_result_qemu() { check_result_qemu() {
local ret=1 local ret=1
mount_initdir mount_initdir
[[ -e $initdir/testok ]] && ret=0 [[ -e "${initdir:?}/testok" ]] && ret=0
if [[ -e $initdir/skipped ]]; then if [[ -e "$initdir/skipped" ]]; then
echo "TEST-56-OOMD was skipped:" echo "TEST-56-OOMD was skipped:"
cat $initdir/skipped cat "$initdir/skipped"
ret=0 ret=0
fi fi
[[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR
save_journal $initdir/var/log/journal [[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}"
check_asan_reports "$initdir" || ret=$(($ret+1)) save_journal "$initdir/var/log/journal"
_umount_dir $initdir check_asan_reports "$initdir" || ret=$((ret + 1))
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed _umount_dir "$initdir"
echo $JOURNAL_LIST [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
test -s $TESTDIR/failed && ret=$(($ret+1)) echo "${JOURNAL_LIST:-No journals were saved}"
[ -n "$TIMED_OUT" ] && ret=$(($ret+1))
test -s "$TESTDIR/failed" && ret=$((ret + 1))
[ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1))
return $ret return $ret
} }

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test ExitType=cgroup" TEST_DESCRIPTION="test ExitType=cgroup"
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 56 do_test "$@" 56