1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

machine: resolve race condition in TEST-13-NSPAWN.machinectl.sh

I encountered this race condition while working on TEST-13-NSPAWN.varlinkctl.sh.
The long-running machine's init script sometimes does not have time to start and
register signals. As result, occasiounally failed tests.

(cherry picked from commit e826a8bed4)
This commit is contained in:
Ivan Kruglov 2024-09-20 12:20:53 +02:00 committed by Luca Boccassi
parent bc0ba0030b
commit 0cd10d410b

View File

@ -47,12 +47,21 @@ trap 'kill $PID' EXIT
# We need to wait for the sleep process asynchronously in order to allow
# bash to process signals
sleep infinity &
# notify that the process is ready
touch /ready
PID=$!
while :; do
wait || :
done
EOF
rm -f /var/lib/machines/long-running/ready
machinectl start long-running
# !!!! DO NOT REMOVE THIS TEST
# The test makes sure that the long-running's init script has enough time to start and registered signal traps
timeout 10 bash -c "until test -e /var/lib/machines/long-running/ready; do sleep .5; done"
machinectl
machinectl --no-pager --help