]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: replace sleep with timeout
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 May 2023 06:15:30 +0000 (15:15 +0900)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 2 May 2023 09:09:18 +0000 (11:09 +0200)
If the test environment is too slow, then sleeping 2 seconds may not be
sufficient.

test/units/testsuite-63.sh

index 591e6d31045ed53a8997dfefdea42d89dbb045c8..59a7b3208fc7aa84f813184068916ec2a6716448 100755 (executable)
@@ -15,10 +15,10 @@ systemctl start test63.path
 touch /tmp/test63
 
 # Make sure systemd has sufficient time to hit the trigger limit for test63.path.
-sleep 2
+# shellcheck disable=SC2016
+timeout 30 bash -c 'while ! test "$(systemctl show test63.path -P ActiveState)" = failed; do sleep .2; done'
 test "$(systemctl show test63.service -P ActiveState)" = inactive
 test "$(systemctl show test63.service -P Result)" = success
-test "$(systemctl show test63.path -P ActiveState)" = failed
 test "$(systemctl show test63.path -P Result)" = trigger-limit-hit
 
 # Test that starting the service manually doesn't affect the path unit.