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