Skip to content

Commit

Permalink
testing/test_runner: Support interactive test debugging
Browse files Browse the repository at this point in the history
Add support for entering interactive test debugging when DEBUG_TESTENV=1 is set
in the environment. This will execute $SHELL inside the namespace that is setup
for the test run, after setting up the test interfaces, making it easy to
manually run tests in the same environment to debug things.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Aug 5, 2024
1 parent 451bfbf commit 60e8f11
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/testing/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ usage()

if [ "$EUID" -ne "0" ]; then
if command -v sudo >/dev/null 2>&1; then
exec sudo env V=${VERBOSE_TESTS} "$0" "$@"
exec sudo env V=${VERBOSE_TESTS} DEBUG_TESTENV=${DEBUG_TESTENV:-0} "$0" "$@"
else
die "Tests should be run as root"
fi
Expand All @@ -480,4 +480,10 @@ TOOL_TESTS_DIR="$(dirname "$TEST_DEFINITIONS")"
shift
trap teardown EXIT
setup

if [ "${DEBUG_TESTENV:-0}" -eq "1" ] && [ -n "$SHELL" ]; then
echo "Entering interactive testenv debug - Ctrl-D to exit and resume test execution"
$SHELL
fi

run_tests "$@"

0 comments on commit 60e8f11

Please sign in to comment.