From 14bafbba9bbef1aa4a5a9194ce53f931f33124cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 2 Feb 2021 11:38:19 +0100 Subject: [PATCH] ci: Run 'time' in the background and propagate signals to test process Simply exec'ing time didn't produce any output from it when a test timed out. Fixes: 35f59e14f833 "ci: Use GNU time as meson test wrapper" Part-of: --- .gitlab-ci.yml | 2 +- .gitlab-ci/container/x86_build.sh | 1 + .gitlab-ci/meson/test-wrapper.sh | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79bdbd031d0..f0213791163 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -277,7 +277,7 @@ x86_build: extends: - .use-x86_build-base variables: - MESA_IMAGE_TAG: &x86_build "2021-01-29-time" + MESA_IMAGE_TAG: &x86_build "2021-02-02-procps" .use-x86_build: variables: diff --git a/.gitlab-ci/container/x86_build.sh b/.gitlab-ci/container/x86_build.sh index fe923e09d85..c7e46476ef3 100644 --- a/.gitlab-ci/container/x86_build.sh +++ b/.gitlab-ci/container/x86_build.sh @@ -32,6 +32,7 @@ apt-get install -y --no-remove \ liblua5.3-dev \ libxml2-dev \ ocl-icd-opencl-dev \ + procps \ time \ wine-development \ wine32-development diff --git a/.gitlab-ci/meson/test-wrapper.sh b/.gitlab-ci/meson/test-wrapper.sh index 5e339c345ce..1bb91927090 100755 --- a/.gitlab-ci/meson/test-wrapper.sh +++ b/.gitlab-ci/meson/test-wrapper.sh @@ -1,8 +1,24 @@ #!/bin/sh # Only use GNU time if available, not any shell built-in command -if test -f /usr/bin/time; then - exec /usr/bin/time -v "$@" +if ! test -f /usr/bin/time; then + exec "$@" fi -exec "$@" + +# If the test times out, meson sends SIGINT & SIGTERM signals 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 "$@" & +TIMEPID=$! +TESTPID=$(ps --ppid $TIMEPID -o pid=) + +if test "x$TESTPID" != x; then + trap 'kill -INT $TESTPID; wait $TIMEPID; exit $?' INT + trap 'kill -TERM $TESTPID; wait $TIMEPID; exit $?' TERM +fi + +wait $TIMEPID +exit $?