test: Add testenv_enter.sh to ease debugging testenv

The script testenv_enter.sh, by default, runs /bin/sh in the environment
currently setup.

A bit easier than copy pasting the old hint text printed before test run.

Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
This commit is contained in:
Magnus Malm
2021-02-23 11:19:57 +01:00
parent 4480010d4a
commit 3d01728d2e
3 changed files with 26 additions and 1 deletions
+2
View File
@@ -83,6 +83,7 @@ teardown() {
texec kill -SIGUSR2 1
wait
rm "$TEST_DIR"/running_test.pid
}
trap teardown EXIT
@@ -98,6 +99,7 @@ log "$color_reset" '--' ''
# Setup
"$TEST_DIR/testenv_start.sh" finit &
finit_ppid=$!
echo "$finit_ppid" > "$TEST_DIR"/running_test.pid
finit_pid=$(retry "pgrep -P $finit_ppid")
tty=/dev/$(texec cat /sys/class/tty/console/active)
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
set -eu
cmd=""
if [ "$#" -lt 1 ]; then
cmd="/bin/sh"
else
cmd=$1
shift
fi
PID_FILE=$(dirname "$0")/running_test.pid
if [ -f "$PID_FILE" ] ; then
target=$(cat "$PID_FILE")
target=$(pgrep -P "$target")
else
echo "No test running!"
exit 1
fi
"$(dirname "$0")"/testenv_exec.sh "$target" "$cmd" "$@"
+1 -1
View File
@@ -5,7 +5,7 @@ set -eu
TEST_DIR=$(dirname "$0")
TESTS_ROOT="$(pwd)/${TEST_DIR}/test_root"
>&2 echo "Hint: Execute '${TEST_DIR}/testenv_exec.sh \$(pgrep -P $$) /bin/sh; reset' to enter the test namespace"
>&2 echo "Hint: Execute 'test/testenv_enter.sh' to enter the test namespace"
unshare=$(command -v unshare)
chroot=$(command -v chroot)