Files
mongo/bazel/test_wrapper.sh
Zack Winter 2b0a34a66e SERVER-110647 Set up coredump collection logic on unit test timeout (#42592)
GitOrigin-RevId: 9f613d547669fd4e0708fb082a7838ea283947be
2025-10-14 16:58:27 +00:00

30 lines
695 B
Bash
Executable File

#!/bin/bash
ulimit -c unlimited
eval ${@:1} &
main_pid=$!
echo "Process-under-test started with PID: ${main_pid}"
(
sleep 600
# 'kill -0' checks for process existence without sending a signal
if kill -0 "$main_pid" 2>/dev/null; then
echo "10 minute Timer finished. Process-under-test ${main_pid} is still running. Sending a SIGABRT to trigger a coredump now."
kill -ABRT "${main_pid}"
fi
) &
wait "${main_pid}"
RET=$?
CORE_FILE=$(find -L ./ -name "*.core")
if [ -f "$CORE_FILE" ]; then
CORE_FILENAME="dump_$(date +%s%N).core"
mv $CORE_FILE "$TEST_UNDECLARED_OUTPUTS_DIR/$CORE_FILENAME"
echo "Writing coredump to $CORE_FILENAME..."
fi
exit $RET