test: new, verify runparts order

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-09-10 14:04:26 +02:00
parent 3d74e93fa2
commit b41b4ce989
7 changed files with 62 additions and 0 deletions
+2
View File
@@ -38,6 +38,7 @@ EXTRA_DIST += restart-self.sh
EXTRA_DIST += runlevel.sh
EXTRA_DIST += run-restart-forever.sh
EXTRA_DIST += run-task-tricks.sh
EXTRA_DIST += runparts.sh
EXTRA_DIST += start-stop-service.sh
EXTRA_DIST += start-stop-service-sub-config.sh
EXTRA_DIST += start-kill-service.sh
@@ -79,6 +80,7 @@ TESTS += restart-self.sh
TESTS += runlevel.sh
TESTS += run-restart-forever.sh
TESTS += run-task-tricks.sh
TESTS += runparts.sh
TESTS += start-stop-service.sh
TESTS += start-stop-service-sub-config.sh
TESTS += start-kill-service.sh
+9
View File
@@ -305,6 +305,15 @@ if [ -n "$BOOTSTRAP" ]; then
say "Setting up bootstrap tasks ..."
echo "$BOOTSTRAP" >> "$SYSROOT$FINIT_CONF"
fi
if [ -n "$RUNPARTS" ]; then
say "Setting up runparts task ..."
echo "runparts /etc/rc.d" >> "$SYSROOT$FINIT_CONF"
mkdir "$SYSROOT/etc/rc.d"
echo "$RUNPARTS" > "$SYSROOT/etc/rc.d/start.sh"
chmod +x "$SYSROOT/etc/rc.d/start.sh"
fi
if [ -n "$RCLOCAL" ]; then
while [ -f "$SYSROOT/etc/rc.local" ]; do
echo "$SYSROOT/etc/rc.local busy ... waiting ..."
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
#
# Verifies basic runparts behavior: to run all scripts in a directory at
# the end of system bootstrap, right before calling /etc/rc.local:
#
# - only executable scripts should be called
# - always in alphabetical order
# - SNNfoo should be called with a 'start' argument
# - KNNfoo should be called with a 'stop' argument
#
TEST_DIR=$(dirname "$0")
#DEBUG=1
# shellcheck disable=SC2034
BOOTSTRAP="runparts /etc/rc.d"
# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"
test_setup()
{
say "Test start $(date)"
}
test_teardown()
{
say "Test done $(date)"
}
while true; do
lvl=$(texec initctl runlevel)
say "Current runlevel $lvl"
if [ "$lvl" = "N 2" ]; then
break;
fi
sleep 1
done
texec diff -u /usr/share/runlevel/ref.log /tmp/runparts.log
texec cmp /usr/share/runlevel/ref.log /tmp/runparts.log || fail "runparts in wrong order"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "$0 $*" >> /tmp/runparts.log
+1
View File
@@ -0,0 +1 @@
S01abc.sh
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "$0" >> /tmp/runparts.log
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "$0" >> /tmp/runparts.log