mirror of
https://github.com/troglobit/finit.git
synced 2026-11-28 20:58:24 +00: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:
1 parent
4480010d4a
commit
3d01728d2e
3 files changed
+26
-1
No files matched your search
@@ -83,6 +83,7 @@ teardown() {
|
|||||||
texec kill -SIGUSR2 1
|
texec kill -SIGUSR2 1
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
rm "$TEST_DIR"/running_test.pid
|
||||||
}
|
}
|
||||||
|
|
||||||
trap teardown EXIT
|
trap teardown EXIT
|
||||||
@@ -98,6 +99,7 @@ log "$color_reset" '--' ''
|
|||||||
# Setup
|
# Setup
|
||||||
"$TEST_DIR/testenv_start.sh" finit &
|
"$TEST_DIR/testenv_start.sh" finit &
|
||||||
finit_ppid=$!
|
finit_ppid=$!
|
||||||
|
echo "$finit_ppid" > "$TEST_DIR"/running_test.pid
|
||||||
finit_pid=$(retry "pgrep -P $finit_ppid")
|
finit_pid=$(retry "pgrep -P $finit_ppid")
|
||||||
|
|
||||||
tty=/dev/$(texec cat /sys/class/tty/console/active)
|
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")
|
TEST_DIR=$(dirname "$0")
|
||||||
TESTS_ROOT="$(pwd)/${TEST_DIR}/test_root"
|
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)
|
unshare=$(command -v unshare)
|
||||||
chroot=$(command -v chroot)
|
chroot=$(command -v chroot)
|
||||||
|
|||||||
Reference in new issue
Block a user