
meson tests sharing a binary (and deviating in their env/args) will produce temporary logs to the same directory, which is assumed to exist only for the duration of a single test. This is problematic when running tests in parallel, as one test may remove the directory before the other(s) finish, causing a test flake. This appends the each test's pid to the output directory to enforce uniqueness and avoid the race. Signed-off-by: Ryan Neph <ryanneph@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20779>
30 lines
771 B
Bash
Executable File
30 lines
771 B
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ "x$STRACEDIR" = "x" ]; then
|
|
STRACEDIR=meson-logs/strace/$(for i in $@; do basename -z -- $i; echo -n _; done).$$
|
|
fi
|
|
|
|
mkdir -p $STRACEDIR
|
|
|
|
# If the test times out, meson sends SIGTERM 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 strace -ff -tt -T -o $STRACEDIR/log "$@" &
|
|
TIMEPID=$!
|
|
STRACEPID=$(ps --ppid $TIMEPID -o pid=)
|
|
TESTPID=$(ps --ppid $STRACEPID -o pid=)
|
|
|
|
if test "x$TESTPID" != x; then
|
|
trap 'kill -TERM $TESTPID; wait $TIMEPID; exit $?' TERM
|
|
fi
|
|
|
|
wait $TIMEPID
|
|
EXITCODE=$?
|
|
|
|
# Only keep strace logs if the test timed out
|
|
rm -rf $STRACEDIR &
|
|
|
|
exit $EXITCODE
|