]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: make the test entrypoint scripts shellcheck-compliant
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 19 Apr 2021 11:01:59 +0000 (13:01 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Apr 2021 08:26:43 +0000 (10:26 +0200)
53 files changed:
test/TEST-01-BASIC/test.sh
test/TEST-02-UNITTESTS/test.sh
test/TEST-03-JOBS/test.sh
test/TEST-04-JOURNAL/test.sh
test/TEST-05-RLIMITS/test.sh
test/TEST-06-SELINUX/test.sh
test/TEST-07-ISSUE-1981/test.sh
test/TEST-08-ISSUE-2730/test.sh
test/TEST-09-ISSUE-2691/test.sh
test/TEST-10-ISSUE-2467/test.sh
test/TEST-11-ISSUE-3166/test.sh
test/TEST-12-ISSUE-3171/test.sh
test/TEST-13-NSPAWN-SMOKE/test.sh
test/TEST-14-MACHINE-ID/test.sh
test/TEST-15-DROPIN/test.sh
test/TEST-16-EXTEND-TIMEOUT/test.sh
test/TEST-17-UDEV/test.sh
test/TEST-18-FAILUREACTION/test.sh
test/TEST-19-DELEGATE/test.sh
test/TEST-20-MAINPIDGAMES/test.sh
test/TEST-22-TMPFILES/test.sh
test/TEST-23-TYPE-EXEC/test.sh
test/TEST-24-CRYPTSETUP/test.sh
test/TEST-25-IMPORT/test.sh
test/TEST-26-SETENV/test.sh
test/TEST-27-STDOUTFILE/test.sh
test/TEST-28-PERCENTJ-WANTEDBY/test.sh
test/TEST-29-PORTABLE/test.sh
test/TEST-30-ONCLOCKCHANGE/test.sh
test/TEST-31-DEVICE-ENUMERATION/test.sh
test/TEST-32-OOMPOLICY/test.sh
test/TEST-33-CLEAN-UNIT/test.sh
test/TEST-34-DYNAMICUSERMIGRATE/test.sh
test/TEST-36-NUMAPOLICY/test.sh
test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh
test/TEST-38-FREEZER/test.sh
test/TEST-39-EXECRELOAD/test.sh
test/TEST-40-EXEC-COMMAND-EX/test.sh
test/TEST-41-ONESHOT-RESTART/test.sh
test/TEST-42-EXECSTOPPOST/test.sh
test/TEST-43-PRIVATEUSER-UNPRIV/test.sh
test/TEST-44-LOG-NAMESPACE/test.sh
test/TEST-46-HOMED/test.sh
test/TEST-47-ISSUE-14566/test.sh
test/TEST-48-START-STOP-NO-RELOAD/test.sh
test/TEST-49-RUNTIME-BIND-PATHS/test.sh
test/TEST-50-DISSECT/test.sh
test/TEST-51-ISSUE-16115/test.sh
test/TEST-52-HONORFIRSTSHUTDOWN/test.sh
test/TEST-53-ISSUE-16347/test.sh
test/TEST-54-CREDS/test.sh
test/TEST-55-OOMD/test.sh
test/TEST-56-EXIT-TYPE/test.sh

index 66c35fe2b723a176955924745cea0c186069da6e..3de0e51d5a3af73ce616f0e7dbcda5f860e102f4 100755 (executable)
@@ -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
index 6143d3352b01ba56c46574ace65145b3173e5202..2bfe41a42b30fab27970dc834eefcd6577714ba0 100755 (executable)
@@ -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
index 221a18682a9f90820db8357ee837716c7b13bdbe..d719238d1ab6076949c89bc07146884f865e2cf7 100755 (executable)
@@ -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
index f16543c2b44b7ebd7076357af9f2d6f8c7d674d9..66182435da79e17fabd2fc4c08889f26f48497d3 100755 (executable)
@@ -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
index 463fe42a7cf200f78ae5c6d8dc8c540128b682c1..f95c198f1a35b2b89fcb09d98db4d3423ac45815 100755 (executable)
@@ -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
index f05cd355938bfa1ba9ab5af05e55daa6d6d87a48..984caf4b4fa18977f2c7bc96b74f0d5c652ded9e 100755 (executable)
@@ -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
index 5da24a987ce5d5933e555dd99164983a4c492ac1..bcb7584cb167aacf616805bdecf2f1a62ac132c8 100755 (executable)
@@ -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
 
index 34d68835d8fee92283b7742ddd23db0acb6e6038..0e66aa88de937dc2e924c4e27b620bf2be5c4165 100755 (executable)
@@ -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
index a4d155be1db3443b5de823671ba57d017eb9e069..19eb3ac6b3b94a3758fd502e8ccdaf6ba2f3d022 100755 (executable)
@@ -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
index 14ded56ba15c938a4bfb84bb1d7396062b5dadb3..c0b8e27164e8d0cf6b5d3bb9b764fb9f9f258c02 100755 (executable)
@@ -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
index da003c90d512dc4d0e68468a29dbdea0f4f9fafa..e8189f5276c2fcf4931be936daf42e15e80a4d89 100755 (executable)
@@ -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
index c8abefbd866641e0df6206920c241435308d3a36..52e33cdfdbc9751deb85d08f5441dc5b5dd9f0f7 100755 (executable)
@@ -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
index 0f6bf587a65916f8d4122a5867b1e5b1fe427d25..05a33e0716af04c3e540fd049dc52d12aae39eef 100755 (executable)
@@ -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
     )
 }
 
index 87abe2e439a64e2cb093f7d5a3bd51588670ac4d..3507915bb9044cc21701a2e8e08d32b9b101ccd3 100755 (executable)
@@ -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
index 1540e2e1f115dd1803226a367d52444ba8b7939d..134ed7bba3b68215022f7b8eed613852e2f90618 100755 (executable)
@@ -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
index e1e2a68fa9e009dd651c09f0b6d93d47c0ee1f96..60c0dd1ee2ce81696292946b982689074523a1f5 100755 (executable)
@@ -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
index b13ae0aa78267ff69c644207aba541fbd8a6babd..2a4cef2fa5e4cdae4bcf9d2714d5ce7e7142c4d2 100755 (executable)
@@ -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() {
index 5c386b8ea209aae9079510d15a44bc91fd8ec89a..913c254f5d1c9bb5bc4ce01418685d133c7081af 100755 (executable)
@@ -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
index 03c7760bfd14d099ded8f87fd97383a6e68c36c2..a25c28ef4ee88da6f56291beb9bafaa8747eb29a 100755 (executable)
@@ -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
 
index 50724b3f3c0bca3aa19e185ba1167ea5c8211bf5..96c85db909fc441df9cf80f9c9b43d326257283a 100755 (executable)
@@ -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
index e4874b4d230ee328627aa5c43b4489880fdb9fb2..7038864deb91144a1d59dccdc283f4931ac0d55c 100755 (executable)
@@ -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
index 1b0d25a721ba9dbb091575f3edea4b982ff4eeef..2d1b938071c4abb81ab504219e7850714f3b246a 100755 (executable)
@@ -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
index d7b338c7f0f388cbf6e5d9169f85eb6cf2628c61..e4d99d10b9e5d36fb26d311175ed43532624e4d9 100755 (executable)
@@ -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 <<EOF
+        cat >"$initdir/etc/crypttab" <<EOF
 $DM_NAME UUID=$ID_FS_UUID /etc/varkey
 EOF
-        echo -n test >$initdir/etc/varkey
-        cat $initdir/etc/crypttab | ddebug
+        echo -n test >"$initdir/etc/varkey"
+        ddebug <"$initdir/etc/crypttab"
 
-        cat >>$initdir/etc/fstab <<EOF
+        cat >>"$initdir/etc/fstab" <<EOF
 /dev/mapper/varcrypt    /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
-        echo ForwardToConsole=yes >> $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
 }
 
index 034b94ca7992515df260a9c62331a94943a7b0a9..51dae2d887ee604e1a56c76ef66adee44e5b786b 100755 (executable)
@@ -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
index 158fa6fdc04ac05330256ce1a5358818c0397650..2523e20929b07113b3e8c091802f93b6e25f6fd4 100755 (executable)
@@ -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
index 23aadf314e11554327833d95a4823acbdb81e413..f19ac4ac8c63c1c48257a65e10364860e191ea2f 100755 (executable)
@@ -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
index 09baf2277683a02e67ef67340e5a14339de2e89f..5525538463603f58983fd4e4c399dcc72d3dafe3 100755 (executable)
@@ -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
index cd421efdaead35c059c3025228120ee01792d6a8..9eff1d797e1040a84f8e5ee63707c86c6a0522db 100755 (executable)
@@ -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() {
index 4723e7b0be81921cb3b9edfcefb59d40f8844a4e..6a201514dced79ac8a88cc3104889fc1d0e2bad6 100755 (executable)
@@ -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
index 4fbd38d2d0dadf520dfcd5315952c86e547dfb6b..a474ec84edba2b681a73638e860a4acf444e4907 100755 (executable)
@@ -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
index 6f2955cf62c303552d5c3b47fe33a518034a9b88..11290fd8e419f3b1f5aa7bf72797b62d24046881 100755 (executable)
@@ -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
 
index 64cb6aee5938b4e9b548185cfba711dbaa2dc18c..0fcaae69e32a64c2915b857666938f083e3f157f 100755 (executable)
@@ -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
index 0b2174a894b0b15a0c0dd6d889420f042e5afb0a..d30113c75741408773448099e0c2c841cced3045 100755 (executable)
@@ -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
index cec8b699202bf58ea373285042224a7107815a63..9422a16083351e0fb103a8402166f421f0beafbf 100755 (executable)
@@ -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
index b5806c429f91aae4b18b820370fb72e477559283..72e312fca0c22adcb9dbe689eb2be8560f421137 100755 (executable)
@@ -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
index 3821db9f0023c13c5e5854a511f7f8b98cfcfe50..524180b1ad1a4c1f27e843e6606e6a187888baa1 100755 (executable)
@@ -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
index e38a9902ce072b8d4d186ecb452fd1a17d7dbbae..8f09ff1ac833f520fb2dc99942df63728e07b781 100755 (executable)
@@ -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
index 4ee84d4d35ddf7d0c9c167a6545fab482b3f0833..4e998d31f83813a4be2c7d17e2bfbda0807e43e9 100755 (executable)
@@ -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
index d3f96ae1071a9ffe5020ed72fe6d0e0c7df67d70..43ed4648c05b9daea2709bc8f1d05da8c0e7f3fc 100755 (executable)
@@ -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
index 53e6fa3dd01da5ea040bb28816c1c211f0e83e03..8e25dd8f18743b22118c0e9fa5a3fde6973389c6 100755 (executable)
@@ -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
index 4749150ff125a448f38050741e7526d0ca21b3a3..bdd18290e80fb9d9726b6caf39fc4975a1b5df16 100755 (executable)
@@ -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
 
index 26d863708e85833115b666f9898139f8c7d8dbea..2562b325cb2facf11f315e456c85b4643155e9c9 100755 (executable)
@@ -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
index 877cbfefd035d02bce12f5037d93588bc32f6dd0..dedc660b4489e35e8879bb027ec16a2c52c449ff 100755 (executable)
@@ -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
index 4e80ec76ff58a4ce593075b348960070c709464b..f9ce14986509f42b8072e49eace87484b15cf13c 100755 (executable)
@@ -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
index f6638b3241c3c7f56033647632bdcdcd6ce5bb0f..68d584fe7760799a3fead763dad09fae433e45bb 100755 (executable)
@@ -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
index ff24a4f254efc7afc2a043225ccfcbb9b632f814..d20dd9ca1b3f87b229d59cae3fdcc3794285e16d 100755 (executable)
@@ -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
index 86a4f079bb047784cdaff924c0ee99e80ece133b..8765b11cb86a8ed15e782fc535389e7d409f0e10 100755 (executable)
@@ -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
index eca235c0a647467888d4e3ccbc8cfef0a6385ddd..11dd85e460cbd3d9138831c0cd99abdbedf457b3 100755 (executable)
@@ -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
index 28b97fadb08767de6aa85dcaffce2d4977e3ca30..3bcf1b8c9ea3a4aa3e62ecef824d4f82907c2a22 100755 (executable)
@@ -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
 
index 089768e8ddb391b34cd5b94c0aebbe78cdae59cd..492d5179323d268f2fca9d4a4206602ad9ddea5c 100755 (executable)
@@ -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
index 5feb15e7f131ccb678b567b3827f90834aa2730a..4562c6095e12b09e20347f881e60158baa83590b 100755 (executable)
@@ -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
index 121aa8d56e9393d1cb615354f6239f76375c353f..afc6706e32f748b6770f926c57f975d305818fbc 100755 (executable)
@@ -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
 }
 
index fc321e4141d5391e6e380d311b102d5f88f5c16b..e654accb0e393c55d52b13da6b5ce3a23a077f96 100755 (executable)
@@ -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