2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-04-09 20:39:41 +03:00
set -eux
set -o pipefail
2017-12-14 14:17:43 +03:00
rm -f /test.log
2021-04-09 20:49:32 +03:00
TESTLOG = /test.log.XXXXXXXX
2017-12-14 14:17:43 +03:00
function wait_for( )
{
2021-04-09 20:49:32 +03:00
local service = " ${ 1 :- wait_for : missing service argument } "
local result = " ${ 2 :- success } "
local time = " ${ 3 :- 45 } "
2017-12-14 14:17:43 +03:00
2021-04-09 20:49:32 +03:00
while [ [ ! -f /${ service } .terminated && ! -f /${ service } .success && $time -gt 0 ] ] ; do
2017-12-14 14:17:43 +03:00
sleep 1
2021-04-09 20:49:32 +03:00
time = $(( time - 1 ))
2017-12-14 14:17:43 +03:00
done
2021-04-09 20:49:32 +03:00
if [ [ ! -f /${ service } .${ result } ] ] ; then
journalctl -u " ${ service /_/- } .service " >>" $TESTLOG "
2017-12-14 14:17:43 +03:00
fi
}
# This checks all stages, start, runtime and stop, can be extended by
# EXTEND_TIMEOUT_USEC
wait_for success_all
# These check that EXTEND_TIMEOUT_USEC that occurs at greater than the
# extend timeout interval but less then the stage limit (TimeoutStartSec,
# RuntimeMaxSec, TimeoutStopSec) still succeed.
wait_for success_start
wait_for success_runtime
wait_for success_stop
# These ensure that EXTEND_TIMEOUT_USEC will still timeout in the
2020-12-02 11:53:32 +03:00
# appropriate stage, after the stage limit, when the EXTEND_TIMEOUT_USEC
2017-12-14 14:17:43 +03:00
# message isn't sent within the extend timeout interval.
wait_for fail_start startfail
wait_for fail_stop stopfail
wait_for fail_runtime runtimefail
2021-04-09 20:49:32 +03:00
if [ [ -f " $TESTLOG " ] ] ; then
2017-12-14 14:17:43 +03:00
# no mv
2021-04-09 20:49:32 +03:00
cp " $TESTLOG " /test.log
2017-12-14 14:17:43 +03:00
exit 1
fi
2021-04-09 20:49:32 +03:00
touch /testok
exit 0