From: Frantisek Sumsal Date: Fri, 9 Apr 2021 17:50:52 +0000 (+0200) Subject: test: tidy up arithmetic expressions X-Git-Tag: v249-rc1~417^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f79409835665a8ae600249d97671f05706b6dc78;p=thirdparty%2Fsystemd.git test: tidy up arithmetic expressions --- diff --git a/test/units/testsuite-03.sh b/test/units/testsuite-03.sh index 82858f0c8e7..8a8ba870e8c 100755 --- a/test/units/testsuite-03.sh +++ b/test/units/testsuite-03.sh @@ -18,7 +18,7 @@ grep 'hello\.service.*waiting' /root/list-jobs.txt START_SEC=$(date -u '+%s') systemctl start --job-mode=ignore-dependencies hello END_SEC=$(date -u '+%s') -ELAPSED=$(($END_SEC-$START_SEC)) +ELAPSED=$((END_SEC-START_SEC)) test "$ELAPSED" -lt 3 @@ -76,14 +76,14 @@ EOF START_SEC=$(date -u '+%s') systemctl start --wait wait2.service END_SEC=$(date -u '+%s') -ELAPSED=$(($END_SEC-$START_SEC)) +ELAPSED=$((END_SEC-START_SEC)) [[ "$ELAPSED" -ge 2 ]] && [[ "$ELAPSED" -le 4 ]] || exit 1 # wait5fail fails, so systemctl should fail START_SEC=$(date -u '+%s') systemctl start --wait wait2.service wait5fail.service && { echo 'unexpected success'; exit 1; } END_SEC=$(date -u '+%s') -ELAPSED=$(($END_SEC-$START_SEC)) +ELAPSED=$((END_SEC-START_SEC)) [[ "$ELAPSED" -ge 5 ]] && [[ "$ELAPSED" -le 7 ]] || exit 1 # Test time-limited scopes @@ -92,7 +92,7 @@ set +e systemd-run --scope --property=RuntimeMaxSec=3s sleep 10 RESULT=$? END_SEC=$(date -u '+%s') -ELAPSED=$(($END_SEC-$START_SEC)) +ELAPSED=$((END_SEC-START_SEC)) [[ "$ELAPSED" -ge 3 ]] && [[ "$ELAPSED" -le 5 ]] || exit 1 [[ "$RESULT" -ne 0 ]] || exit 1 diff --git a/test/units/testsuite-41.sh b/test/units/testsuite-41.sh index 527213fcf8c..e7993e8df78 100755 --- a/test/units/testsuite-41.sh +++ b/test/units/testsuite-41.sh @@ -12,7 +12,7 @@ systemd-analyze log-target console systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1" \ && { echo 'unexpected success'; exit 1; } -for ((secs=0; secs<$MAX_SECS; secs++)); do +for ((secs = 0; secs < MAX_SECS; secs++)); do [[ "$(systemctl show one.service -P NRestarts)" -le 0 ]] || break sleep 1 done @@ -35,7 +35,7 @@ systemd-run --unit=two \ && { echo 'unexpected success'; exit 1; } # wait for at least 3 restarts -for ((secs=0; secs<$MAX_SECS; secs++)); do +for ((secs = 0; secs < MAX_SECS; secs++)); do [[ $(cat $TMP_FILE) != "aaa" ]] || break sleep 1 done