From 60e8f117bc5175ffbafb002a9156e6a18d499901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Date: Fri, 2 Aug 2024 13:25:22 +0200 Subject: [PATCH] testing/test_runner: Support interactive test debugging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/testing/test_runner.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/testing/test_runner.sh b/lib/testing/test_runner.sh index 700d45e5..f6be7939 100755 --- a/lib/testing/test_runner.sh +++ b/lib/testing/test_runner.sh @@ -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 @@ -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 "$@"