mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
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:
@@ -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)
|
||||
|
||||
Executable
+23
@@ -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" "$@"
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user