ci: Run meson tests in strace if it's available and can be used
Keep the strace logs in job artifacts for tests which timed out. This can be useful for figuring out why a timeout occurred. strace cannot be used in jobs where ASAN is enabled, because ASAN's leak checker also uses ptrace(), which isn't possible within strace. Suggested-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9472>
This commit is contained in:
@@ -41,9 +41,19 @@ if [ -n "$CROSS" ]; then
|
||||
fi
|
||||
|
||||
# Only use GNU time if available, not any shell built-in command
|
||||
if test -f /usr/bin/time; then
|
||||
MESON_TEST_ARGS+=--wrapper=$PWD/.gitlab-ci/meson/test-wrapper.sh
|
||||
fi
|
||||
case $CI_JOB_NAME in
|
||||
# ASAN leak detection is incompatible with strace
|
||||
*-asan*)
|
||||
if test -f /usr/bin/time; then
|
||||
MESON_TEST_ARGS+=--wrapper=$PWD/.gitlab-ci/meson/time.sh
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if test -f /usr/bin/time -a -f /usr/bin/strace; then
|
||||
MESON_TEST_ARGS+=--wrapper=$PWD/.gitlab-ci/meson/time-strace.sh
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
rm -rf _build
|
||||
meson _build --native-file=native.file \
|
||||
|
27
.gitlab-ci/meson/time-strace.sh
Executable file
27
.gitlab-ci/meson/time-strace.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
STRACEDIR=meson-logs/strace/$(for i in $@; do basename -z -- $i; echo -n _; done)
|
||||
|
||||
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
|
Reference in New Issue
Block a user