From 3f161ba9bc43e68e5ac3dd9ef18309e6e88bee89 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 19 Apr 2021 13:01:59 +0200 Subject: [PATCH] test: make the test entrypoint scripts shellcheck-compliant --- test/TEST-01-BASIC/test.sh | 8 ++- test/TEST-02-UNITTESTS/test.sh | 65 +++++++++++-------- test/TEST-03-JOBS/test.sh | 4 +- test/TEST-04-JOURNAL/test.sh | 4 +- test/TEST-05-RLIMITS/test.sh | 4 +- test/TEST-06-SELINUX/test.sh | 36 ++++++---- test/TEST-07-ISSUE-1981/test.sh | 4 +- test/TEST-08-ISSUE-2730/test.sh | 5 +- test/TEST-09-ISSUE-2691/test.sh | 5 +- test/TEST-10-ISSUE-2467/test.sh | 4 +- test/TEST-11-ISSUE-3166/test.sh | 4 +- test/TEST-12-ISSUE-3171/test.sh | 4 +- test/TEST-13-NSPAWN-SMOKE/test.sh | 10 ++- test/TEST-14-MACHINE-ID/test.sh | 6 +- test/TEST-15-DROPIN/test.sh | 4 +- test/TEST-16-EXTEND-TIMEOUT/test.sh | 4 +- test/TEST-17-UDEV/test.sh | 5 +- test/TEST-18-FAILUREACTION/test.sh | 5 +- test/TEST-19-DELEGATE/test.sh | 5 +- test/TEST-20-MAINPIDGAMES/test.sh | 4 +- test/TEST-22-TMPFILES/test.sh | 9 ++- test/TEST-23-TYPE-EXEC/test.sh | 5 +- test/TEST-24-CRYPTSETUP/test.sh | 61 +++++++++-------- test/TEST-25-IMPORT/test.sh | 4 +- test/TEST-26-SETENV/test.sh | 4 +- test/TEST-27-STDOUTFILE/test.sh | 4 +- test/TEST-28-PERCENTJ-WANTEDBY/test.sh | 4 +- test/TEST-29-PORTABLE/test.sh | 4 +- test/TEST-30-ONCLOCKCHANGE/test.sh | 5 +- test/TEST-31-DEVICE-ENUMERATION/test.sh | 5 +- test/TEST-32-OOMPOLICY/test.sh | 5 +- test/TEST-33-CLEAN-UNIT/test.sh | 5 +- test/TEST-34-DYNAMICUSERMIGRATE/test.sh | 5 +- test/TEST-36-NUMAPOLICY/test.sh | 5 +- test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh | 5 +- test/TEST-38-FREEZER/test.sh | 5 +- test/TEST-39-EXECRELOAD/test.sh | 5 +- test/TEST-40-EXEC-COMMAND-EX/test.sh | 5 +- test/TEST-41-ONESHOT-RESTART/test.sh | 5 +- test/TEST-42-EXECSTOPPOST/test.sh | 4 +- test/TEST-43-PRIVATEUSER-UNPRIV/test.sh | 5 +- test/TEST-44-LOG-NAMESPACE/test.sh | 4 +- test/TEST-46-HOMED/test.sh | 4 +- test/TEST-47-ISSUE-14566/test.sh | 5 +- test/TEST-48-START-STOP-NO-RELOAD/test.sh | 5 +- test/TEST-49-RUNTIME-BIND-PATHS/test.sh | 4 +- test/TEST-50-DISSECT/test.sh | 4 +- test/TEST-51-ISSUE-16115/test.sh | 5 +- test/TEST-52-HONORFIRSTSHUTDOWN/test.sh | 12 ++-- test/TEST-53-ISSUE-16347/test.sh | 7 +- test/TEST-54-CREDS/test.sh | 4 +- test/TEST-55-OOMD/test.sh | 55 +++++++++------- test/TEST-56-EXIT-TYPE/test.sh | 5 +- 53 files changed, 311 insertions(+), 152 deletions(-) diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index 66c35fe2b7..3de0e51d5a 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -1,17 +1,19 @@ #!/usr/bin/env bash 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_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" test_append_files() { # 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" - 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 diff --git a/test/TEST-02-UNITTESTS/test.sh b/test/TEST-02-UNITTESTS/test.sh index 6143d3352b..2bfe41a42b 100755 --- a/test/TEST-02-UNITTESTS/test.sh +++ b/test/TEST-02-UNITTESTS/test.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Run unit tests under containers" RUN_IN_UNPRIVILEGED_CONTAINER=yes @@ -11,53 +12,63 @@ frobnicate! $KERNEL_APPEND " -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" check_result_nspawn() { - local _ret=1 - [[ -e $1/testok ]] && _ret=0 - if [[ -s $1/failed ]]; then - _ret=$(($_ret+1)) + local workspace="${1:?}" + local ret=1 + + [[ -e "$workspace/testok" ]] && ret=0 + + if [[ -s "$workspace/failed" ]]; then + ret=$((ret + 1)) echo "=== Failed test log ===" - cat $1/failed + cat "$workspace/failed" else - if [[ -s $1/skipped ]]; then + if [[ -s "$workspace/skipped" ]]; then echo "=== Skipped test log ==" - cat $1/skipped + cat "$workspace/skipped" fi - if [[ -s $1/testok ]]; then + if [[ -s "$workspace/testok" ]]; then echo "=== Passed tests ===" - cat $1/testok + cat "$workspace/testok" fi fi - save_journal $1/var/log/journal - _umount_dir $initdir - [[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1)) - return $_ret + + save_journal "$workspace/var/log/journal" + _umount_dir "${initdir:?}" + + [[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1)) + return $ret } check_result_qemu() { - local _ret=1 + local ret=1 + mount_initdir - [[ -e $initdir/testok ]] && _ret=0 - if [[ -s $initdir/failed ]]; then - _ret=$(($_ret+1)) + [[ -e "${initdir:?}/testok" ]] && ret=0 + + if [[ -s "$initdir/failed" ]]; then + ret=$((ret + 1)) echo "=== Failed test log ===" - cat $initdir/failed + cat "$initdir/failed" else - if [[ -s $initdir/skipped ]]; then + if [[ -s "$initdir/skipped" ]]; then echo "=== Skipped test log ==" - cat $initdir/skipped + cat "$initdir/skipped" fi - if [[ -s $initdir/testok ]]; then + if [[ -s "$initdir/testok" ]]; then echo "=== Passed tests ===" - cat $initdir/testok + cat "$initdir/testok" fi fi - save_journal $initdir/var/log/journal - _umount_dir $initdir - [[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1)) - return $_ret + + save_journal "$initdir/var/log/journal" + _umount_dir "$initdir" + + [[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1)) + return $ret } do_test "$@" 02 diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh index 221a18682a..d719238d1a 100755 --- a/test/TEST-03-JOBS/test.sh +++ b/test/TEST-03-JOBS/test.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Job-related tests" TEST_NO_QEMU=1 IMAGE_NAME="default" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 03 diff --git a/test/TEST-04-JOURNAL/test.sh b/test/TEST-04-JOURNAL/test.sh index f16543c2b4..66182435da 100755 --- a/test/TEST-04-JOURNAL/test.sh +++ b/test/TEST-04-JOURNAL/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Journal-related tests" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 04 diff --git a/test/TEST-05-RLIMITS/test.sh b/test/TEST-05-RLIMITS/test.sh index 463fe42a7c..f95c198f1a 100755 --- a/test/TEST-05-RLIMITS/test.sh +++ b/test/TEST-05-RLIMITS/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Resource limits-related tests" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 05 diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh index f05cd35593..984caf4b4f 100755 --- a/test/TEST-06-SELINUX/test.sh +++ b/test/TEST-06-SELINUX/test.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="SELinux tests" IMAGE_NAME="selinux" 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 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 -KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux" +KERNEL_APPEND="${KERNEL_APPEND:=} selinux=1 security=selinux" test_append_files() { ( + local workspace="${1:?}" + local policy_headers_dir=/usr/share/selinux/devel + local modules_dir=/var/lib/selinux + setup_selinux - local _modules_dir=/var/lib/selinux - rm -rf $1/$_modules_dir - if ! cp -ar $_modules_dir $1/$_modules_dir; then - dfatal "Failed to copy $_modules_dir" + # Make sure we never expand this to "/..." + rm -rf "${workspace:?}/$modules_dir" + + if ! cp -ar "$modules_dir" "$workspace/$modules_dir"; then + dfatal "Failed to copy $modules_dir" exit 1 fi - local _policy_headers_dir=/usr/share/selinux/devel - rm -rf $1/$_policy_headers_dir + rm -rf "${workspace:?}/$policy_headers_dir" 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 fi - mkdir $1/systemd-test-module - cp systemd_test.te $1/systemd-test-module - cp systemd_test.if $1/systemd-test-module - cp systemd_test.fc $1/systemd-test-module + mkdir "$workspace/systemd-test-module" + cp systemd_test.te "$workspace/systemd-test-module" + cp systemd_test.if "$workspace/systemd-test-module" + cp systemd_test.fc "$workspace/systemd-test-module" dracut_install -o sesearch dracut_install runcon dracut_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-ISSUE-1981/test.sh index 5da24a987c..bcb7584cb1 100755 --- a/test/TEST-07-ISSUE-1981/test.sh +++ b/test/TEST-07-ISSUE-1981/test.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981" TEST_NO_QEMU=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" NSPAWN_TIMEOUT=30 diff --git a/test/TEST-08-ISSUE-2730/test.sh b/test/TEST-08-ISSUE-2730/test.sh index 34d68835d8..0e66aa88de 100755 --- a/test/TEST-08-ISSUE-2730/test.sh +++ b/test/TEST-08-ISSUE-2730/test.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730" IMAGE_NAME="test08" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + QEMU_TIMEOUT=300 FSTYPE=ext4 TEST_FORCE_NEWIMAGE=1 diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh index a4d155be1d..19eb3ac6b3 100755 --- a/test/TEST-09-ISSUE-2691/test.sh +++ b/test/TEST-09-ISSUE-2691/test.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + QEMU_TIMEOUT=300 do_test "$@" 09 diff --git a/test/TEST-10-ISSUE-2467/test.sh b/test/TEST-10-ISSUE-2467/test.sh index 14ded56ba1..c0b8e27164 100755 --- a/test/TEST-10-ISSUE-2467/test.sh +++ b/test/TEST-10-ISSUE-2467/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh index da003c90d5..e8189f5276 100755 --- a/test/TEST-11-ISSUE-3166/test.sh +++ b/test/TEST-11-ISSUE-3166/test.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 11 diff --git a/test/TEST-12-ISSUE-3171/test.sh b/test/TEST-12-ISSUE-3171/test.sh index c8abefbd86..52e33cdfdb 100755 --- a/test/TEST-12-ISSUE-3171/test.sh +++ b/test/TEST-12-ISSUE-3171/test.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171" TEST_NO_QEMU=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 12 diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh index 0f6bf587a6..05a33e0716 100755 --- a/test/TEST-13-NSPAWN-SMOKE/test.sh +++ b/test/TEST-13-NSPAWN-SMOKE/test.sh @@ -1,15 +1,19 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="systemd-nspawn smoke test" IMAGE_NAME="nspawn" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" test_append_files() { ( - ../create-busybox-container $1/testsuite-13.nc-container - initdir="$1/testsuite-13.nc-container" dracut_install nc ip md5sum + local workspace="${1:?}" + + "$TEST_BASE_DIR/create-busybox-container" "$workspace/testsuite-13.nc-container" + initdir="$workspace/testsuite-13.nc-container" dracut_install nc ip md5sum ) } diff --git a/test/TEST-14-MACHINE-ID/test.sh b/test/TEST-14-MACHINE-ID/test.sh index 87abe2e439..3507915bb9 100755 --- a/test/TEST-14-MACHINE-ID/test.sh +++ b/test/TEST-14-MACHINE-ID/test.sh @@ -1,13 +1,15 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="/etc/machine-id testing" IMAGE_NAME="badid" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" test_append_files() { - printf "556f48e837bc4424a710fa2e2c9d3e3c\ne3d\n" >$1/etc/machine-id + printf "556f48e837bc4424a710fa2e2c9d3e3c\ne3d\n" >"${1:?}/etc/machine-id" } do_test "$@" 14 diff --git a/test/TEST-15-DROPIN/test.sh b/test/TEST-15-DROPIN/test.sh index 1540e2e1f1..134ed7bba3 100755 --- a/test/TEST-15-DROPIN/test.sh +++ b/test/TEST-15-DROPIN/test.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Dropin tests" TEST_NO_QEMU=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 15 diff --git a/test/TEST-16-EXTEND-TIMEOUT/test.sh b/test/TEST-16-EXTEND-TIMEOUT/test.sh index e1e2a68fa9..60c0dd1ee2 100755 --- a/test/TEST-16-EXTEND-TIMEOUT/test.sh +++ b/test/TEST-16-EXTEND-TIMEOUT/test.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests" SKIP_INITRD=yes TEST_NO_QEMU=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 16 diff --git a/test/TEST-17-UDEV/test.sh b/test/TEST-17-UDEV/test.sh index b13ae0aa78..2a4cef2fa5 100755 --- a/test/TEST-17-UDEV/test.sh +++ b/test/TEST-17-UDEV/test.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="UDEV" IMAGE_NAME="udev" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + QEMU_TIMEOUT=500 test_append_files() { diff --git a/test/TEST-18-FAILUREACTION/test.sh b/test/TEST-18-FAILUREACTION/test.sh index 5c386b8ea2..913c254f5d 100755 --- a/test/TEST-18-FAILUREACTION/test.sh +++ b/test/TEST-18-FAILUREACTION/test.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="FailureAction= operation" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + QEMU_TIMEOUT=600 do_test "$@" 18 diff --git a/test/TEST-19-DELEGATE/test.sh b/test/TEST-19-DELEGATE/test.sh index 03c7760bfd..a25c28ef4e 100755 --- a/test/TEST-19-DELEGATE/test.sh +++ b/test/TEST-19-DELEGATE/test.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + QEMU_TIMEOUT=600 UNIFIED_CGROUP_HIERARCHY=yes diff --git a/test/TEST-20-MAINPIDGAMES/test.sh b/test/TEST-20-MAINPIDGAMES/test.sh index 50724b3f3c..96c85db909 100755 --- a/test/TEST-20-MAINPIDGAMES/test.sh +++ b/test/TEST-20-MAINPIDGAMES/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test changing main PID" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 20 diff --git a/test/TEST-22-TMPFILES/test.sh b/test/TEST-22-TMPFILES/test.sh index e4874b4d23..7038864deb 100755 --- a/test/TEST-22-TMPFILES/test.sh +++ b/test/TEST-22-TMPFILES/test.sh @@ -1,12 +1,15 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Tmpfiles related tests" TEST_NO_QEMU=1 -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" test_append_files() { - if [[ "$IS_BUILT_WITH_ASAN" == "yes" ]]; then - if [[ -z "$initdir" ]]; then + if [[ "${IS_BUILT_WITH_ASAN:=}" == "yes" ]]; then + if [[ -z "${initdir:=}" ]]; then echo >&2 "\$initdir is not defined, can't continue" exit 1 fi diff --git a/test/TEST-23-TYPE-EXEC/test.sh b/test/TEST-23-TYPE-EXEC/test.sh index 1b0d25a721..2d1b938071 100755 --- a/test/TEST-23-TYPE-EXEC/test.sh +++ b/test/TEST-23-TYPE-EXEC/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test Type=exec" -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 23 diff --git a/test/TEST-24-CRYPTSETUP/test.sh b/test/TEST-24-CRYPTSETUP/test.sh index d7b338c7f0..e4d99d10b9 100755 --- a/test/TEST-24-CRYPTSETUP/test.sh +++ b/test/TEST-24-CRYPTSETUP/test.sh @@ -1,68 +1,77 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="cryptsetup systemd setup" IMAGE_NAME="cryptsetup" TEST_NO_NSPAWN=1 TEST_FORCE_NEWIMAGE=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" check_result_qemu() { - ret=1 + local ret=1 + mount_initdir - [[ -e $initdir/testok ]] && ret=0 - [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR - cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile - mount /dev/mapper/varcrypt $initdir/var - save_journal $initdir/var/log/journal - _umount_dir $initdir/var - _umount_dir $initdir + [[ -e "${initdir:?}/testok" ]] && ret=0 + [[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}" + + cryptsetup luksOpen "${LOOPDEV:?}p2" varcrypt <"$TESTDIR/keyfile" + mount /dev/mapper/varcrypt "$initdir/var" + save_journal "$initdir/var/log/journal" + _umount_dir "$initdir/var" + _umount_dir "$initdir" cryptsetup luksClose /dev/mapper/varcrypt - [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - echo $JOURNAL_LIST - test -s $TESTDIR/failed && ret=$(($ret+1)) + + [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed" + echo "${JOURNAL_LIST:-No journals were saved}" + + test -s "$TESTDIR/failed" && ret=$((ret + 1)) return $ret } test_create_image() { create_empty_image_rootdir - echo -n test >$TESTDIR/keyfile - cryptsetup -q luksFormat --pbkdf pbkdf2 --pbkdf-force-iterations 1000 ${LOOPDEV}p2 $TESTDIR/keyfile - cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile + + echo -n test >"${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 - mkdir -p $initdir/var - mount /dev/mapper/varcrypt $initdir/var + mkdir -p "${initdir:?}/var" + mount /dev/mapper/varcrypt "$initdir/var" # Create what will eventually be our root filesystem onto an overlay ( LOG_LEVEL=5 - eval $(udevadm info --export --query=env --name=/dev/mapper/varcrypt) - eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) + # shellcheck source=/dev/null + 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 mask_supporting_services install_dmevent generate_module_dependencies - cat >$initdir/etc/crypttab <"$initdir/etc/crypttab" <$initdir/etc/varkey - cat $initdir/etc/crypttab | ddebug + echo -n test >"$initdir/etc/varkey" + ddebug <"$initdir/etc/crypttab" - cat >>$initdir/etc/fstab <>"$initdir/etc/fstab" <> $initdir/etc/systemd/journald.conf + echo ForwardToConsole=yes >> "$initdir/etc/systemd/journald.conf" ) } cleanup_root_var() { - ddebug "umount $initdir/var" - mountpoint $initdir/var && umount $initdir/var + ddebug "umount ${initdir:?}/var" + mountpoint "$initdir/var" && umount "$initdir/var" [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt } diff --git a/test/TEST-25-IMPORT/test.sh b/test/TEST-25-IMPORT/test.sh index 034b94ca79..51dae2d887 100755 --- a/test/TEST-25-IMPORT/test.sh +++ b/test/TEST-25-IMPORT/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test importd" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 25 diff --git a/test/TEST-26-SETENV/test.sh b/test/TEST-26-SETENV/test.sh index 158fa6fdc0..2523e20929 100755 --- a/test/TEST-26-SETENV/test.sh +++ b/test/TEST-26-SETENV/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test setenv" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 26 diff --git a/test/TEST-27-STDOUTFILE/test.sh b/test/TEST-27-STDOUTFILE/test.sh index 23aadf314e..f19ac4ac8c 100755 --- a/test/TEST-27-STDOUTFILE/test.sh +++ b/test/TEST-27-STDOUTFILE/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test StandardOutput=file:" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 27 diff --git a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh index 09baf22776..5525538463 100755 --- a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh +++ b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Ensure %j Wants directives work" RUN_IN_UNPRIVILEGED_CONTAINER=yes -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 28 diff --git a/test/TEST-29-PORTABLE/test.sh b/test/TEST-29-PORTABLE/test.sh index cd421efdae..9eff1d797e 100755 --- a/test/TEST-29-PORTABLE/test.sh +++ b/test/TEST-29-PORTABLE/test.sh @@ -2,12 +2,14 @@ # -*- 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 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" # Need loop devices for mounting images test_append_files() { diff --git a/test/TEST-30-ONCLOCKCHANGE/test.sh b/test/TEST-30-ONCLOCKCHANGE/test.sh index 4723e7b0be..6a201514dc 100755 --- a/test/TEST-30-ONCLOCKCHANGE/test.sh +++ b/test/TEST-30-ONCLOCKCHANGE/test.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange=" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 30 diff --git a/test/TEST-31-DEVICE-ENUMERATION/test.sh b/test/TEST-31-DEVICE-ENUMERATION/test.sh index 4fbd38d2d0..a474ec84ed 100755 --- a/test/TEST-31-DEVICE-ENUMERATION/test.sh +++ b/test/TEST-31-DEVICE-ENUMERATION/test.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + QEMU_TIMEOUT=300 do_test "$@" 31 diff --git a/test/TEST-32-OOMPOLICY/test.sh b/test/TEST-32-OOMPOLICY/test.sh index 6f2955cf62..11290fd8e4 100755 --- a/test/TEST-32-OOMPOLICY/test.sh +++ b/test/TEST-32-OOMPOLICY/test.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test OOM killer logic" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" UNIFIED_CGROUP_HIERARCHY=yes diff --git a/test/TEST-33-CLEAN-UNIT/test.sh b/test/TEST-33-CLEAN-UNIT/test.sh index 64cb6aee59..0fcaae69e3 100755 --- a/test/TEST-33-CLEAN-UNIT/test.sh +++ b/test/TEST-33-CLEAN-UNIT/test.sh @@ -2,7 +2,10 @@ # -*- 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 CleanUnit" -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 33 diff --git a/test/TEST-34-DYNAMICUSERMIGRATE/test.sh b/test/TEST-34-DYNAMICUSERMIGRATE/test.sh index 0b2174a894..d30113c757 100755 --- a/test/TEST-34-DYNAMICUSERMIGRATE/test.sh +++ b/test/TEST-34-DYNAMICUSERMIGRATE/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-36-NUMAPOLICY/test.sh b/test/TEST-36-NUMAPOLICY/test.sh index cec8b69920..9422a16083 100755 --- a/test/TEST-36-NUMAPOLICY/test.sh +++ b/test/TEST-36-NUMAPOLICY/test.sh @@ -3,7 +3,10 @@ set -e TEST_DESCRIPTION="test NUMAPolicy= and NUMAMask= options" 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 QEMU_OPTIONS="-object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0" else diff --git a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh index b5806c429f..72e312fca0 100755 --- a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh +++ b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh @@ -2,7 +2,10 @@ # -*- 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 RuntimeDirectoryPreserve=yes" -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 37 diff --git a/test/TEST-38-FREEZER/test.sh b/test/TEST-38-FREEZER/test.sh index 3821db9f00..524180b1ad 100755 --- a/test/TEST-38-FREEZER/test.sh +++ b/test/TEST-38-FREEZER/test.sh @@ -1,7 +1,10 @@ #!/bin/bash set -e + TEST_DESCRIPTION="test unit freezing and thawing via DBus and systemctl" TEST_NO_NSPAWN=1 -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 38 diff --git a/test/TEST-39-EXECRELOAD/test.sh b/test/TEST-39-EXECRELOAD/test.sh index e38a9902ce..8f09ff1ac8 100755 --- a/test/TEST-39-EXECRELOAD/test.sh +++ b/test/TEST-39-EXECRELOAD/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="Test ExecReload= (PR #13098)" -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 39 diff --git a/test/TEST-40-EXEC-COMMAND-EX/test.sh b/test/TEST-40-EXEC-COMMAND-EX/test.sh index 4ee84d4d35..4e998d31f8 100755 --- a/test/TEST-40-EXEC-COMMAND-EX/test.sh +++ b/test/TEST-40-EXEC-COMMAND-EX/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-41-ONESHOT-RESTART/test.sh b/test/TEST-41-ONESHOT-RESTART/test.sh index d3f96ae107..43ed4648c0 100755 --- a/test/TEST-41-ONESHOT-RESTART/test.sh +++ b/test/TEST-41-ONESHOT-RESTART/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-42-EXECSTOPPOST/test.sh b/test/TEST-42-EXECSTOPPOST/test.sh index 53e6fa3dd0..8e25dd8f18 100755 --- a/test/TEST-42-EXECSTOPPOST/test.sh +++ b/test/TEST-42-EXECSTOPPOST/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh index 4749150ff1..bdd18290e8 100755 --- a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh +++ b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-44-LOG-NAMESPACE/test.sh b/test/TEST-44-LOG-NAMESPACE/test.sh index 26d863708e..2562b325cb 100755 --- a/test/TEST-44-LOG-NAMESPACE/test.sh +++ b/test/TEST-44-LOG-NAMESPACE/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test log namespaces" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 44 diff --git a/test/TEST-46-HOMED/test.sh b/test/TEST-46-HOMED/test.sh index 877cbfefd0..dedc660b44 100755 --- a/test/TEST-46-HOMED/test.sh +++ b/test/TEST-46-HOMED/test.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="testing homed" TEST_NO_QEMU=1 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 46 diff --git a/test/TEST-47-ISSUE-14566/test.sh b/test/TEST-47-ISSUE-14566/test.sh index 4e80ec76ff..f9ce149865 100755 --- a/test/TEST-47-ISSUE-14566/test.sh +++ b/test/TEST-47-ISSUE-14566/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-48-START-STOP-NO-RELOAD/test.sh b/test/TEST-48-START-STOP-NO-RELOAD/test.sh index f6638b3241..68d584fe77 100755 --- a/test/TEST-48-START-STOP-NO-RELOAD/test.sh +++ b/test/TEST-48-START-STOP-NO-RELOAD/test.sh @@ -2,7 +2,10 @@ # -*- 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 StartStopNoReload" -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 48 diff --git a/test/TEST-49-RUNTIME-BIND-PATHS/test.sh b/test/TEST-49-RUNTIME-BIND-PATHS/test.sh index ff24a4f254..d20dd9ca1b 100755 --- a/test/TEST-49-RUNTIME-BIND-PATHS/test.sh +++ b/test/TEST-49-RUNTIME-BIND-PATHS/test.sh @@ -2,6 +2,8 @@ set -e 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 diff --git a/test/TEST-50-DISSECT/test.sh b/test/TEST-50-DISSECT/test.sh index 86a4f079bb..8765b11cb8 100755 --- a/test/TEST-50-DISSECT/test.sh +++ b/test/TEST-50-DISSECT/test.sh @@ -2,12 +2,14 @@ # -*- 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 -. $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 veritysetup >/dev/null 2>&1 || exit 0 diff --git a/test/TEST-51-ISSUE-16115/test.sh b/test/TEST-51-ISSUE-16115/test.sh index eca235c0a6..11dd85e460 100755 --- a/test/TEST-51-ISSUE-16115/test.sh +++ b/test/TEST-51-ISSUE-16115/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + 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 diff --git a/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh b/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh index 28b97fadb0..3bcf1b8c9e 100755 --- a/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh +++ b/test/TEST-52-HONORFIRSTSHUTDOWN/test.sh @@ -1,18 +1,20 @@ #!/bin/bash set -e -. $TEST_BASE_DIR/test-functions + TEST_REQUIRE_INSTALL_TESTS=0 TEST_DESCRIPTION="testing honor first shutdown" -#INTERACTIVE_DEBUG=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 # could turn into a reboot if the test fails. NSPAWN_TIMEOUT=20 -#Remove this file if it exists. this is used along with -# the make target "finish". Since concrete confirmaion is +# Remove this file if it exists. This is used along with +# the make target "finish". Since concrete confirmation is # only found from the console during the poweroff. rm -f /tmp/honorfirstshutdown.log >/dev/null diff --git a/test/TEST-53-ISSUE-16347/test.sh b/test/TEST-53-ISSUE-16347/test.sh index 089768e8dd..492d517932 100755 --- a/test/TEST-53-ISSUE-16347/test.sh +++ b/test/TEST-53-ISSUE-16347/test.sh @@ -4,8 +4,9 @@ set -e TEST_DESCRIPTION="test timer units when initial clock is ahead" TEST_NO_NSPAWN=1 -future_date=$(date -u +%Y-%m-%dT%H:%M:%S -d '+3 days') -QEMU_OPTIONS="-rtc base=${future_date}" -. $TEST_BASE_DIR/test-functions +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 "$@" 53 diff --git a/test/TEST-54-CREDS/test.sh b/test/TEST-54-CREDS/test.sh index 5feb15e7f1..4562c6095e 100755 --- a/test/TEST-54-CREDS/test.sh +++ b/test/TEST-54-CREDS/test.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test credentials" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 54 diff --git a/test/TEST-55-OOMD/test.sh b/test/TEST-55-OOMD/test.sh index 121aa8d56e..afc6706e32 100755 --- a/test/TEST-55-OOMD/test.sh +++ b/test/TEST-55-OOMD/test.sh @@ -1,47 +1,56 @@ #!/usr/bin/env bash set -e + 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() { + local workspace="${1:?}" local ret=1 local journald_report="" 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:" - cat $1/skipped + cat "$workspace/skipped" ret=0 fi - [[ -f $1/failed ]] && cp -a $1/failed $TESTDIR - save_journal $1/var/log/journal - [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - echo $JOURNAL_LIST - test -s $TESTDIR/failed && ret=$(($ret+1)) - [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) - check_asan_reports "$1" || ret=$(($ret+1)) - _umount_dir $initdir + + [[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}" + save_journal "$workspace/var/log/journal" + [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed" + echo "${JOURNAL_LIST:-No journals were saved}" + + test -s "$TESTDIR/failed" && ret=$((ret + 1)) + [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1)) + check_asan_reports "$workspace" || ret=$((ret + 1)) + _umount_dir "${initdir:?}" return $ret } check_result_qemu() { local ret=1 + mount_initdir - [[ -e $initdir/testok ]] && ret=0 - if [[ -e $initdir/skipped ]]; then + [[ -e "${initdir:?}/testok" ]] && ret=0 + if [[ -e "$initdir/skipped" ]]; then echo "TEST-56-OOMD was skipped:" - cat $initdir/skipped + cat "$initdir/skipped" ret=0 fi - [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR - save_journal $initdir/var/log/journal - check_asan_reports "$initdir" || ret=$(($ret+1)) - _umount_dir $initdir - [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - echo $JOURNAL_LIST - test -s $TESTDIR/failed && ret=$(($ret+1)) - [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) + + [[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}" + save_journal "$initdir/var/log/journal" + check_asan_reports "$initdir" || ret=$((ret + 1)) + _umount_dir "$initdir" + [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed" + echo "${JOURNAL_LIST:-No journals were saved}" + + test -s "$TESTDIR/failed" && ret=$((ret + 1)) + [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1)) return $ret } diff --git a/test/TEST-56-EXIT-TYPE/test.sh b/test/TEST-56-EXIT-TYPE/test.sh index fc321e4141..e654accb0e 100755 --- a/test/TEST-56-EXIT-TYPE/test.sh +++ b/test/TEST-56-EXIT-TYPE/test.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="test ExitType=cgroup" -. $TEST_BASE_DIR/test-functions + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" do_test "$@" 56