1#!/bin/sh 2 3STRACEDIR=meson-logs/strace/$(for i in $@; do basename -z -- $i; echo -n _; done) 4 5mkdir -p $STRACEDIR 6 7# If the test times out, meson sends SIGTERM to this process. 8# Simply exec'ing "time" would result in no output from that in this case. 9# Instead, we need to run "time" in the background, catch the signals and 10# propagate them to the actual test process. 11 12/usr/bin/time -v strace -ff -tt -T -o $STRACEDIR/log "$@" & 13TIMEPID=$! 14STRACEPID=$(ps --ppid $TIMEPID -o pid=) 15TESTPID=$(ps --ppid $STRACEPID -o pid=) 16 17if test "x$TESTPID" != x; then 18 trap 'kill -TERM $TESTPID; wait $TIMEPID; exit $?' TERM 19fi 20 21wait $TIMEPID 22EXITCODE=$? 23 24# Only keep strace logs if the test timed out 25rm -rf $STRACEDIR & 26 27exit $EXITCODE 28