aboutsummaryrefslogtreecommitdiff
path: root/.gitlab-ci/meson/time.sh
diff options
context:
space:
mode:
Diffstat (limited to '.gitlab-ci/meson/time.sh')
-rwxr-xr-x.gitlab-ci/meson/time.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/.gitlab-ci/meson/time.sh b/.gitlab-ci/meson/time.sh
new file mode 100755
index 00000000..cde6bb71
--- /dev/null
+++ b/.gitlab-ci/meson/time.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# 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 "$@" &
+TIMEPID=$!
+TESTPID=$(ps --ppid $TIMEPID -o pid=)
+
+if test "x$TESTPID" != x; then
+ trap 'kill -TERM $TESTPID; wait $TIMEPID; exit $?' TERM
+fi
+
+wait $TIMEPID
+exit $?