Files
third_party_mesa3d/.gitlab-ci/meson/test-wrapper.sh
Michel Dänzer 14bafbba9b ci: Run 'time' in the background and propagate signals to test process
Simply exec'ing time didn't produce any output from it when a test
timed out.

Fixes: 35f59e14f8 "ci: Use GNU time as meson test wrapper"
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8830>
2021-02-04 09:36:49 +00:00

25 lines
651 B
Bash
Executable File

#!/bin/sh
# Only use GNU time if available, not any shell built-in command
if ! test -f /usr/bin/time; then
exec "$@"
fi
# If the test times out, meson sends SIGINT & SIGTERM signals to this process.
# Simply exec'ing "time" would result in no output from that in this case.
# Instead, we need to run "time" in the background, catch the signals and
# propagate them to the actual test process.
/usr/bin/time -v "$@" &
TIMEPID=$!
TESTPID=$(ps --ppid $TIMEPID -o pid=)
if test "x$TESTPID" != x; then
trap 'kill -INT $TESTPID; wait $TIMEPID; exit $?' INT
trap 'kill -TERM $TESTPID; wait $TIMEPID; exit $?' TERM
fi
wait $TIMEPID
exit $?