2021-01-29 10:03:19 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-08-07 15:05:38 +01:00
|
|
|
if [ "x$STRACEDIR" = "x" ]; then
|
2023-01-26 19:22:23 +00:00
|
|
|
STRACEDIR=meson-logs/strace/$(for i in $@; do basename -z -- $i; echo -n _; done).$$
|
2022-08-07 15:05:38 +01:00
|
|
|
fi
|
2021-03-04 11:58:56 +00:00
|
|
|
|
|
|
|
mkdir -p $STRACEDIR
|
|
|
|
|
2021-03-04 17:14:03 +00:00
|
|
|
# If the test times out, meson sends SIGTERM to this process.
|
2021-02-02 10:38:19 +00:00
|
|
|
# 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.
|
|
|
|
|
2021-03-04 11:58:56 +00:00
|
|
|
/usr/bin/time -v strace -ff -tt -T -o $STRACEDIR/log "$@" &
|
2021-02-02 10:38:19 +00:00
|
|
|
TIMEPID=$!
|
2021-03-04 11:58:56 +00:00
|
|
|
STRACEPID=$(ps --ppid $TIMEPID -o pid=)
|
|
|
|
TESTPID=$(ps --ppid $STRACEPID -o pid=)
|
2021-02-02 10:38:19 +00:00
|
|
|
|
|
|
|
if test "x$TESTPID" != x; then
|
|
|
|
trap 'kill -TERM $TESTPID; wait $TIMEPID; exit $?' TERM
|
|
|
|
fi
|
|
|
|
|
|
|
|
wait $TIMEPID
|
2021-03-04 11:58:56 +00:00
|
|
|
EXITCODE=$?
|
|
|
|
|
|
|
|
# Only keep strace logs if the test timed out
|
|
|
|
rm -rf $STRACEDIR &
|
|
|
|
|
|
|
|
exit $EXITCODE
|