diff --git a/test/TEST-50-DISSECT/test.sh b/test/TEST-50-DISSECT/test.sh index 9d42e4891c1..86a4f079bb0 100755 --- a/test/TEST-50-DISSECT/test.sh +++ b/test/TEST-50-DISSECT/test.sh @@ -23,6 +23,7 @@ test_append_files() { install_dmevent generate_module_dependencies inst_binary losetup + inst_binary wc install_verity_minimal ) } diff --git a/test/units/testsuite-02.sh b/test/units/testsuite-02.sh index b0807c9d8aa..ea4efda70bd 100755 --- a/test/units/testsuite-02.sh +++ b/test/units/testsuite-02.sh @@ -54,9 +54,9 @@ for task in "${TEST_LIST[@]}"; do # until one of the tasks finishes, so we can replace it. while [[ ${#running[@]} -ge $MAX_QUEUE_SIZE ]]; do for key in "${!running[@]}"; do - if ! kill -0 ${running[$key]} &>/dev/null; then + if ! kill -0 "${running[$key]}" &>/dev/null; then # Task has finished, report its result and drop it from the queue - wait ${running[$key]} + wait "${running[$key]}" ec=$? report_result "$key" $ec unset running["$key"] diff --git a/test/units/testsuite-13.sh b/test/units/testsuite-13.sh index 03b1bc39712..d93cc7b1452 100755 --- a/test/units/testsuite-13.sh +++ b/test/units/testsuite-13.sh @@ -112,7 +112,7 @@ EOF sleep 0.1 done - return $(systemctl show -P ExecMainStatus nspawn_machinectl_bind.service) + return "$(systemctl show -P ExecMainStatus nspawn_machinectl_bind.service)" } function run { diff --git a/test/units/testsuite-14.sh b/test/units/testsuite-14.sh index 6eecf916a20..7a64d937361 100755 --- a/test/units/testsuite-14.sh +++ b/test/units/testsuite-14.sh @@ -21,18 +21,18 @@ r="$(pwd)/overwrite-broken-machine-id" setup_root "$r" systemd-machine-id-setup --print --root "$r" echo abc >>"$r/etc/machine-id" -id=$(systemd-machine-id-setup --print --root "$r") -echo $id >expected +id="$(systemd-machine-id-setup --print --root "$r")" +echo "$id" >expected check expected "$r/etc/machine-id" -r="$(pwd)/transient-machine-id" +r="$PWD/transient-machine-id" setup_root "$r" systemd-machine-id-setup --print --root "$r" echo abc >>"$r/etc/machine-id" mount -o remount,ro "$r" mount -t tmpfs tmpfs "$r/run" -transient_id=$(systemd-machine-id-setup --print --root "$r") +transient_id="$(systemd-machine-id-setup --print --root "$r")" mount -o remount,rw "$r" -commited_id=$(systemd-machine-id-setup --print --commit --root "$r") +commited_id="$(systemd-machine-id-setup --print --commit --root "$r")" [[ "$transient_id" = "$commited_id" ]] check "$r/etc/machine-id" "$r/run/machine-id" diff --git a/test/units/testsuite-15.sh b/test/units/testsuite-15.sh index 018ae8aab9b..23c2156501d 100755 --- a/test/units/testsuite-15.sh +++ b/test/units/testsuite-15.sh @@ -3,51 +3,53 @@ set -eux set -o pipefail _clear_service () { - systemctl stop $1.service 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/$1.service - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} - if [[ $1 == *@ ]]; then - systemctl stop $1*.service 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/$1*.service - rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.d - rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.{wants,requires} + local SERVICE_NAME="${1:?_clear_service: missing argument}" + systemctl stop "$SERVICE_NAME.service" 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.{wants,requires} + if [[ $SERVICE_NAME == *@ ]]; then + systemctl stop "$SERVICE_NAME"*.service 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.d + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.{wants,requires} fi } clear_services () { - for u in $*; do - _clear_service $u + for u in "$@"; do + _clear_service "$u" done systemctl daemon-reload } create_service () { - clear_services $1 + local SERVICE_NAME="${1:?create_service: missing argument}" + clear_services "$SERVICE_NAME" - cat >/etc/systemd/system/$1.service</etc/systemd/system/"$SERVICE_NAME".service <> "${TL}" + if [[ ! -f /${service}.${result} ]]; then + journalctl -u "${service/_/-}.service" >>"$TESTLOG" fi } @@ -45,12 +43,11 @@ wait_for fail_start startfail wait_for fail_stop stopfail wait_for fail_runtime runtimefail -if [[ -f "${TL}" ]] -then +if [[ -f "$TESTLOG" ]]; then # no mv - cp "${TL}" /test.log + cp "$TESTLOG" /test.log exit 1 -else - touch /testok - exit 0 fi + +touch /testok +exit 0 diff --git a/test/units/testsuite-17.sh b/test/units/testsuite-17.sh index 3cf57550fc3..2ec9f6a8910 100755 --- a/test/units/testsuite-17.sh +++ b/test/units/testsuite-17.sh @@ -5,8 +5,8 @@ set -o pipefail >/failed -for t in ${0%.sh}.*.sh; do - echo "Running $t"; ./$t +for t in "${0%.sh}".*.sh; do + echo "Running $t"; ./"$t" done touch /testok diff --git a/test/units/testsuite-20.sh b/test/units/testsuite-20.sh index 56f07933a91..111713dabf1 100755 --- a/test/units/testsuite-20.sh +++ b/test/units/testsuite-20.sh @@ -140,7 +140,7 @@ systemd-run --unit=test20-mainpidsh3.service \ && { echo 'unexpected success'; exit 1; } # Test that this failed due to timeout, and not some other error -test $(systemctl show -P Result test20-mainpidsh3.service) = timeout +test "$(systemctl show -P Result test20-mainpidsh3.service)" = timeout systemd-analyze log-level info diff --git a/test/units/testsuite-22.02.sh b/test/units/testsuite-22.02.sh index 5d1254db03e..94fa11ba886 100755 --- a/test/units/testsuite-22.02.sh +++ b/test/units/testsuite-22.02.sh @@ -21,10 +21,10 @@ d /tmp/d/2 0755 daemon daemon - - EOF test -d /tmp/d/1 -test $(stat -c %U:%G:%a /tmp/d/1) = "daemon:daemon:755" +test "$(stat -c %U:%G:%a /tmp/d/1)" = "daemon:daemon:755" test -d /tmp/d/2 -test $(stat -c %U:%G:%a /tmp/d/2) = "daemon:daemon:755" +test "$(stat -c %U:%G:%a /tmp/d/2)" = "daemon:daemon:755" # # 'D' @@ -39,10 +39,10 @@ D /tmp/D/2 0755 daemon daemon - - EOF test -d /tmp/D/1 -test $(stat -c %U:%G:%a /tmp/D/1) = "daemon:daemon:755" +test "$(stat -c %U:%G:%a /tmp/D/1)" = "daemon:daemon:755" test -d /tmp/D/2 -test $(stat -c %U:%G:%a /tmp/D/2) = "daemon:daemon:755" +test "$(stat -c %U:%G:%a /tmp/D/2)" = "daemon:daemon:755" systemd-tmpfiles --remove - </failed -for t in ${0%.sh}.*.sh; do - echo "Running $t"; ./$t +for t in "${0%.sh}".*.sh; do + echo "Running $t"; ./"$t" done touch /testok diff --git a/test/units/testsuite-23.sh b/test/units/testsuite-23.sh index c66ed262296..4ef7c878a83 100755 --- a/test/units/testsuite-23.sh +++ b/test/units/testsuite-23.sh @@ -21,8 +21,8 @@ systemd-run --unit=six -p Type=exec /tmp/brokenbinary && { echo 'unexpected succ systemd-run --unit=seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity # Both TERM and SIGINT happen to have the same number on all architectures -test $(systemctl show --value -p KillSignal seven.service) -eq 15 -test $(systemctl show --value -p RestartKillSignal seven.service) -eq 2 +test "$(systemctl show --value -p KillSignal seven.service)" -eq 15 +test "$(systemctl show --value -p RestartKillSignal seven.service)" -eq 2 systemctl restart seven.service systemctl stop seven.service diff --git a/test/units/testsuite-36.sh b/test/units/testsuite-36.sh index 46c08017d1b..6d3713c9623 100755 --- a/test/units/testsuite-36.sh +++ b/test/units/testsuite-36.sh @@ -55,7 +55,7 @@ stopJournalctl() { # the --sync wait until the synchronization is complete echo "Force journald to write all queued messages" journalctl --sync - journalctl -u $unit --cursor-file="$journalCursorFile" >"$journalLog" + journalctl -u "$unit" --cursor-file="$journalCursorFile" >"$journalLog" } checkNUMA() { @@ -97,32 +97,38 @@ pid1ReloadWithJournal() { pid1StartUnitWithStrace() { startStrace '-f' - systemctl start $1 + systemctl start "${1:?missing unit name}" sleep $sleepAfterStart stopStrace } pid1StartUnitWithJournal() { startJournalctl - systemctl start $1 + systemctl start "${1:?missing unit name}" sleep $sleepAfterStart stopJournalctl } pid1StopUnit() { - systemctl stop $1 + systemctl stop "${1:?missing unit name}" } systemctlCheckNUMAProperties() { - local LOGFILE="$(mktemp)" - systemctl show -p NUMAPolicy $1 >"$LOGFILE" - grep "NUMAPolicy=$2" "$LOGFILE" + local UNIT_NAME="${1:?missing unit name}" + local NUMA_POLICY="${2:?missing NUMAPolicy}" + local NUMA_MASK="${3:-""}" + local LOGFILE - >"$LOGFILE" + LOGFILE="$(mktemp)" - if [ -n "$3" ]; then - systemctl show -p NUMAMask $1 >"$LOGFILE" - grep "NUMAMask=$3" "$LOGFILE" + systemctl show -p NUMAPolicy "$UNIT_NAME" >"$LOGFILE" + grep "NUMAPolicy=$NUMA_POLICY" "$LOGFILE" + + : >"$LOGFILE" + + if [ -n "$NUMA_MASK" ]; then + systemctl show -p NUMAMask "$UNIT_NAME" >"$LOGFILE" + grep "NUMAMask=$NUMA_MASK" "$LOGFILE" fi } @@ -145,10 +151,10 @@ if ! checkNUMA; then echo "systemd-run NUMAPolicy=default && NUMAMask=0 check without NUMA support" runUnit='numa-systemd-run-test.service' startJournalctl - systemd-run -p NUMAPolicy=default -p NUMAMask=0 --unit $runUnit sleep 1000 + systemd-run -p NUMAPolicy=default -p NUMAMask=0 --unit "$runUnit" sleep 1000 sleep $sleepAfterStart - pid1StopUnit $runUnit - stopJournalctl $runUnit + pid1StopUnit "$runUnit" + stopJournalctl "$runUnit" grep "NUMA support not available, ignoring" "$journalLog" else @@ -156,43 +162,43 @@ else writePID1NUMAPolicy "default" pid1ReloadWithStrace # Kernel requires that nodemask argument is set to NULL when setting default policy - grep "set_mempolicy(MPOL_DEFAULT, NULL" $straceLog + grep "set_mempolicy(MPOL_DEFAULT, NULL" "$straceLog" echo "PID1 NUMAPolicy support - Default policy w/ mask" writePID1NUMAPolicy "default" "0" pid1ReloadWithStrace - grep "set_mempolicy(MPOL_DEFAULT, NULL" $straceLog + grep "set_mempolicy(MPOL_DEFAULT, NULL" "$straceLog" echo "PID1 NUMAPolicy support - Bind policy w/o mask" writePID1NUMAPolicy "bind" pid1ReloadWithJournal - grep "Failed to set NUMA memory policy: Invalid argument" $journalLog + grep "Failed to set NUMA memory policy: Invalid argument" "$journalLog" echo "PID1 NUMAPolicy support - Bind policy w/ mask" writePID1NUMAPolicy "bind" "0" pid1ReloadWithStrace - grep -P "set_mempolicy\(MPOL_BIND, \[0x0*1\]" $straceLog + grep -P "set_mempolicy\(MPOL_BIND, \[0x0*1\]" "$straceLog" echo "PID1 NUMAPolicy support - Interleave policy w/o mask" writePID1NUMAPolicy "interleave" pid1ReloadWithJournal - grep "Failed to set NUMA memory policy: Invalid argument" $journalLog + grep "Failed to set NUMA memory policy: Invalid argument" "$journalLog" echo "PID1 NUMAPolicy support - Interleave policy w/ mask" writePID1NUMAPolicy "interleave" "0" pid1ReloadWithStrace - grep -P "set_mempolicy\(MPOL_INTERLEAVE, \[0x0*1\]" $straceLog + grep -P "set_mempolicy\(MPOL_INTERLEAVE, \[0x0*1\]" "$straceLog" echo "PID1 NUMAPolicy support - Preferred policy w/o mask" writePID1NUMAPolicy "preferred" pid1ReloadWithJournal # Preferred policy with empty node mask is actually allowed and should reset allocation policy to default - ! grep "Failed to set NUMA memory policy: Invalid argument" $journalLog + grep "Failed to set NUMA memory policy: Invalid argument" "$journalLog" && { echo >&2 "unexpected pass"; exit 1; } echo "PID1 NUMAPolicy support - Preferred policy w/ mask" writePID1NUMAPolicy "preferred" "0" pid1ReloadWithStrace - grep -P "set_mempolicy\(MPOL_PREFERRED, \[0x0*1\]" $straceLog + grep -P "set_mempolicy\(MPOL_PREFERRED, \[0x0*1\]" "$straceLog" echo "PID1 NUMAPolicy support - Local policy w/o mask" writePID1NUMAPolicy "local" @@ -202,136 +208,133 @@ else # return a numerical constant instead (with a comment): # set_mempolicy(0x4 /* MPOL_??? */, NULL, 0) = 0 # Let's cover this scenario as well - grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" $straceLog + grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" "$straceLog" echo "PID1 NUMAPolicy support - Local policy w/ mask" writePID1NUMAPolicy "local" "0" pid1ReloadWithStrace - grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" $straceLog + grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" "$straceLog" echo "Unit file NUMAPolicy support - Default policy w/o mask" writeTestUnitNUMAPolicy "default" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "default" - pid1StopUnit $testUnit - grep "set_mempolicy(MPOL_DEFAULT, NULL" $straceLog + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "default" + pid1StopUnit "$testUnit" + grep "set_mempolicy(MPOL_DEFAULT, NULL" "$straceLog" echo "Unit file NUMAPolicy support - Default policy w/ mask" writeTestUnitNUMAPolicy "default" "0" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "default" "0" + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "default" "0" pid1StopUnit $testUnit # Mask must be ignored - grep "set_mempolicy(MPOL_DEFAULT, NULL" $straceLog + grep "set_mempolicy(MPOL_DEFAULT, NULL" "$straceLog" echo "Unit file NUMAPolicy support - Bind policy w/o mask" writeTestUnitNUMAPolicy "bind" - pid1StartUnitWithJournal $testUnit - pid1StopUnit $testUnit - grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" $journalLog + pid1StartUnitWithJournal "$testUnit" + pid1StopUnit "$testUnit" + grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" "$journalLog" echo "Unit file NUMAPolicy support - Bind policy w/ mask" writeTestUnitNUMAPolicy "bind" "0" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "bind" "0" - pid1StopUnit $testUnit - grep -P "set_mempolicy\(MPOL_BIND, \[0x0*1\]" $straceLog + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "bind" "0" + pid1StopUnit "$testUnit" + grep -P "set_mempolicy\(MPOL_BIND, \[0x0*1\]" "$straceLog" echo "Unit file NUMAPolicy support - Interleave policy w/o mask" writeTestUnitNUMAPolicy "interleave" - pid1StartUnitWithStrace $testUnit - pid1StopUnit $testUnit - grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" $journalLog + pid1StartUnitWithStrace "$testUnit" + pid1StopUnit "$testUnit" + grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" "$journalLog" echo "Unit file NUMAPolicy support - Interleave policy w/ mask" writeTestUnitNUMAPolicy "interleave" "0" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "interleave" "0" - pid1StopUnit $testUnit - grep -P "set_mempolicy\(MPOL_INTERLEAVE, \[0x0*1\]" $straceLog + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "interleave" "0" + pid1StopUnit "$testUnit" + grep -P "set_mempolicy\(MPOL_INTERLEAVE, \[0x0*1\]" "$straceLog" echo "Unit file NUMAPolicy support - Preferred policy w/o mask" writeTestUnitNUMAPolicy "preferred" - pid1StartUnitWithJournal $testUnit - systemctlCheckNUMAProperties $testUnit "preferred" - pid1StopUnit $testUnit - ! grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" $journalLog + pid1StartUnitWithJournal "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "preferred" + pid1StopUnit "$testUnit" + grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" "$journalLog" && { echo >&2 "unexpected pass"; exit 1; } echo "Unit file NUMAPolicy support - Preferred policy w/ mask" writeTestUnitNUMAPolicy "preferred" "0" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "preferred" "0" - pid1StopUnit $testUnit - grep -P "set_mempolicy\(MPOL_PREFERRED, \[0x0*1\]" $straceLog + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "preferred" "0" + pid1StopUnit "$testUnit" + grep -P "set_mempolicy\(MPOL_PREFERRED, \[0x0*1\]" "$straceLog" echo "Unit file NUMAPolicy support - Local policy w/o mask" writeTestUnitNUMAPolicy "local" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "local" - pid1StopUnit $testUnit - grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" $straceLog + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "local" + pid1StopUnit "$testUnit" + grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" "$straceLog" echo "Unit file NUMAPolicy support - Local policy w/ mask" writeTestUnitNUMAPolicy "local" "0" - pid1StartUnitWithStrace $testUnit - systemctlCheckNUMAProperties $testUnit "local" "0" - pid1StopUnit $testUnit + pid1StartUnitWithStrace "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "local" "0" + pid1StopUnit "$testUnit" # Mask must be ignored - grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" $straceLog + grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" "$straceLog" echo "Unit file CPUAffinity=NUMA support" writeTestUnitNUMAPolicy "bind" "0" - echo "CPUAffinity=numa" >>$testUnitNUMAConf + echo "CPUAffinity=numa" >>"$testUnitNUMAConf" systemctl daemon-reload - systemctl start $testUnit - systemctlCheckNUMAProperties $testUnit "bind" "0" - pid=$(systemctl show --value -p MainPID $testUnit) - cpulist=$(cat /sys/devices/system/node/node0/cpulist) - affinity_systemd=$(systemctl show --value -p CPUAffinity $testUnit) - [ $cpulist = $affinity_systemd ] - pid1StopUnit $testUnit + systemctl start "$testUnit" + systemctlCheckNUMAProperties "$testUnit" "bind" "0" + cpulist="$(cat /sys/devices/system/node/node0/cpulist)" + affinity_systemd="$(systemctl show --value -p CPUAffinity "$testUnit")" + [ "$cpulist" = "$affinity_systemd" ] + pid1StopUnit "$testUnit" echo "systemd-run NUMAPolicy support" runUnit='numa-systemd-run-test.service' - systemd-run -p NUMAPolicy=default --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "default" - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=default --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "default" + pid1StopUnit "$runUnit" - systemd-run -p NUMAPolicy=default -p NUMAMask=0 --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "default" "" - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=default -p NUMAMask=0 --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "default" "" + pid1StopUnit "$runUnit" - systemd-run -p NUMAPolicy=bind -p NUMAMask=0 --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "bind" "0" - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=bind -p NUMAMask=0 --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "bind" "0" + pid1StopUnit "$runUnit" - systemd-run -p NUMAPolicy=interleave -p NUMAMask=0 --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "interleave" "0" - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=interleave -p NUMAMask=0 --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "interleave" "0" + pid1StopUnit "$runUnit" - systemd-run -p NUMAPolicy=preferred -p NUMAMask=0 --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "preferred" "0" - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=preferred -p NUMAMask=0 --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "preferred" "0" + pid1StopUnit "$runUnit" - systemd-run -p NUMAPolicy=local --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "local" - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=local --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "local" + pid1StopUnit "$runUnit" - systemd-run -p NUMAPolicy=local -p NUMAMask=0 --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "local" "" - pid1StopUnit $runUnit - - systemd-run -p NUMAPolicy=local -p NUMAMask=0 -p CPUAffinity=numa --unit $runUnit sleep 1000 - systemctlCheckNUMAProperties $runUnit "local" "" - systemctl cat $runUnit | grep -q 'CPUAffinity=numa' - pid1StopUnit $runUnit + systemd-run -p NUMAPolicy=local -p NUMAMask=0 --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "local" "" + pid1StopUnit "$runUnit" + systemd-run -p NUMAPolicy=local -p NUMAMask=0 -p CPUAffinity=numa --unit "$runUnit" sleep 1000 + systemctlCheckNUMAProperties "$runUnit" "local" "" + systemctl cat "$runUnit" | grep -q 'CPUAffinity=numa' + pid1StopUnit "$runUnit" fi # Cleanup -rm -rf $testDir -rm -rf $confDir +rm -rf "$confDir" systemctl daemon-reload systemd-analyze log-level info diff --git a/test/units/testsuite-39.sh b/test/units/testsuite-39.sh index 90da2bf5e18..3b0d893a4c0 100755 --- a/test/units/testsuite-39.sh +++ b/test/units/testsuite-39.sh @@ -18,12 +18,12 @@ ExecReload=/bin/false EOF systemctl daemon-reload -systemctl start $SERVICE_NAME -systemctl status $SERVICE_NAME +systemctl start "$SERVICE_NAME" +systemctl status "$SERVICE_NAME" # The reload SHOULD fail but SHOULD NOT affect the service state -systemctl reload $SERVICE_NAME && { echo 'unexpected success'; exit 1; } -systemctl status $SERVICE_NAME -systemctl stop $SERVICE_NAME +systemctl reload "$SERVICE_NAME" && { echo 'unexpected success'; exit 1; } +systemctl status "$SERVICE_NAME" +systemctl stop "$SERVICE_NAME" echo "[#2] Failing ExecReload= should not kill the service (multiple ExecReload=)" @@ -36,12 +36,12 @@ ExecReload=/bin/true EOF systemctl daemon-reload -systemctl start $SERVICE_NAME -systemctl status $SERVICE_NAME +systemctl start "$SERVICE_NAME" +systemctl status "$SERVICE_NAME" # The reload SHOULD fail but SHOULD NOT affect the service state -systemctl reload $SERVICE_NAME && { echo 'unexpected success'; exit 1; } -systemctl status $SERVICE_NAME -systemctl stop $SERVICE_NAME +systemctl reload "$SERVICE_NAME" && { echo 'unexpected success'; exit 1; } +systemctl status "$SERVICE_NAME" +systemctl stop "$SERVICE_NAME" echo "[#3] Failing ExecReload=- should not affect reload's exit code" cat >"$SERVICE_PATH" </run/systemd/system/testservice-50a.service </run/systemd/system/testservice-50b.service </run/systemd/system/testservice-50c.service </run/systemd/system/testservice-50e.service <>/skipped -cgroup_type=$(stat -fc %T /sys/fs/cgroup/) +cgroup_type="$(stat -fc %T /sys/fs/cgroup/)" if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then echo "no cgroup2" >>/skipped fi if [ ! -f /usr/lib/systemd/systemd-oomd ] && [ ! -f /lib/systemd/systemd-oomd ]; then echo "no oomd" >>/skipped fi -[[ -e /skipped ]] && exit 0 || true + +if [[ -e /skipped ]]; then + exit 0 +fi rm -rf /etc/systemd/system/testsuite-55-testbloat.service.d @@ -30,7 +33,7 @@ oomctl | grep "Default Memory Pressure Duration: 5s" # systemd-oomd watches for elevated pressure for 5 seconds before acting. # It can take time to build up pressure so either wait 2 minutes or for the service to fail. -timeout=$(date -ud "2 minutes" +%s) +timeout="$(date -ud "2 minutes" +%s)" while [[ $(date -u +%s) -le $timeout ]]; do if ! systemctl status testsuite-55-testbloat.service; then break @@ -55,8 +58,8 @@ if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then systemctl start testsuite-55-testmunch.service systemctl start testsuite-55-testbloat.service - timeout=$(date -ud "2 minutes" +%s) - while [[ $(date -u +%s) -le $timeout ]]; do + timeout="$(date -ud "2 minutes" +%s)" + while [[ "$(date -u +%s)" -le "$timeout" ]]; do if ! systemctl status testsuite-55-testmunch.service; then break fi