]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-23-UNIT-FILE: do not wait indefinitely but set a reasonable timeout
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 13:57:07 +0000 (22:57 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 15:41:52 +0000 (16:41 +0100)
Otherwise, the test does not finish until the global timeout is reached.

This is for making the test fail earlier when something spurious happens:
```
[FAILED] Failed to start TEST-23-UNIT-FILE-short-lived.service - Shortlived Unit.
TEST-23-UNIT-FILE.sh[776]: + '[' 0 -eq 0 ']'
TEST-23-UNIT-FILE.sh[776]: + sleep .5
(snip)
58/98 systemd:integration-tests / TEST-23-UNIT-FILE  TIMEOUT  1800.52s  killed by signal 9 SIGKILL
```

(cherry picked from commit e43efecc8f43d4c0b4007630a55e75ab28032beb)

test/units/TEST-23-UNIT-FILE.Upholds.sh

index 20d2d2b173302dee3992178925c9185a73711556..b1fe897a43ca14f24a5c2dc863b42399576e1879 100755 (executable)
@@ -24,9 +24,13 @@ trap -p SIGUSR1
 
 systemctl start TEST-23-UNIT-FILE-success.service
 
-while [ "$sigusr1" -eq 0 ] ; do
+for _ in {1..120}; do
     sleep .5
+    if [[ "$sigusr1" == 1 ]]; then
+       break
+    fi
 done
+[[ "$sigusr1" == 1 ]]
 
 systemctl stop TEST-23-UNIT-FILE-uphold.service
 
@@ -46,17 +50,13 @@ rm -f /tmp/TEST-23-UNIT-FILE-retry-fail
 systemctl start TEST-23-UNIT-FILE-retry-uphold.service
 systemctl is-active TEST-23-UNIT-FILE-upheldby-install.service
 
-until systemctl is-failed TEST-23-UNIT-FILE-retry-fail.service ; do
-    sleep .5
-done
+timeout 60 bash -c 'until systemctl is-failed TEST-23-UNIT-FILE-retry-fail.service; do sleep .5; done'
 
 (! systemctl is-active TEST-23-UNIT-FILE-retry-upheld.service)
 
 touch /tmp/TEST-23-UNIT-FILE-retry-fail
 
-until systemctl is-active TEST-23-UNIT-FILE-retry-upheld.service ; do
-    sleep .5
-done
+timeout 60 bash -c 'until systemctl is-active TEST-23-UNIT-FILE-retry-upheld.service; do sleep .5; done'
 
 systemctl stop TEST-23-UNIT-FILE-retry-uphold.service TEST-23-UNIT-FILE-retry-fail.service TEST-23-UNIT-FILE-retry-upheld.service
 
@@ -74,10 +74,13 @@ trap sigusr2=1 SIGUSR2
 
 systemctl start TEST-23-UNIT-FILE-prop-stop-one.service
 
-while [ "$sigusr2" -eq 0 ] ; do
+for _ in {1..120}; do
     sleep .5
+    if [[ "$sigusr2" == 1 ]]; then
+       break
+    fi
 done
-
+[[ "$sigusr2" == 1 ]]
 
 # Idea is this:
 #    1. we start TEST-23-UNIT-FILE-binds-to.service
@@ -92,8 +95,12 @@ trap sigrtmin1=1 SIGRTMIN+1
 
 systemctl start TEST-23-UNIT-FILE-binds-to.service
 
-while [ "$sigrtmin1" -eq 0 ] ; do
+for _ in {1..120}; do
     sleep .5
+    if [[ "$sigrtmin1" == 1 ]]; then
+       break
+    fi
 done
+[[ "$sigrtmin1" == 1 ]]
 
 systemd-analyze log-level info