test: reindent

Standard Emacs shell-mode 4-space indent.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-09-18 06:38:59 +02:00
1 parent efed0db16b
commit 8904ca993e
27 files changed
+331 -331

No files matched your search

@@ -6,10 +6,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_RCSD/service.conf" run "rm -f $FINIT_RCSD/service.conf"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+3 -3
View File
@@ -6,10 +6,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+53 -53
View File
@@ -9,77 +9,77 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $TEST_CONF" run "rm -f $TEST_CONF"
} }
test_one() test_one()
{ {
cond=$1 cond=$1
stanza=$2 stanza=$2
sleep 5 sleep 5
say 'Enable finit debug, try to figure out what is going on ...' say 'Enable finit debug, try to figure out what is going on ...'
run "initctl debug" run "initctl debug"
say "Add stanza '$stanza' to $TEST_CONF ..." say "Add stanza '$stanza' to $TEST_CONF ..."
run "echo '$stanza' > $TEST_CONF" run "echo '$stanza' > $TEST_CONF"
run "ls -l /run/ /run/finit/" run "ls -l /run/ /run/finit/"
say 'Reload Finit' say 'Reload Finit'
run "initctl ls" run "initctl ls"
run "initctl reload" run "initctl reload"
run "initctl status" run "initctl status"
run "ps" run "ps"
date date
sleep 2 sleep 2
date date
run "ls -l /run/ /run/finit/" run "ls -l /run/ /run/finit/"
say 'Asserting condition' say 'Asserting condition'
run "initctl cond set $cond" run "initctl cond set $cond"
date date
sleep 2 sleep 2
date date
run "ls -l /run/ /run/finit/" run "ls -l /run/ /run/finit/"
run "initctl status" run "initctl status"
run "ps" run "ps"
run "initctl status task.sh" run "initctl status task.sh"
sleep 1 sleep 1
run "echo Hej; cat /run/task.state" run "echo Hej; cat /run/task.state"
assert_file_contains /run/task.state 1 assert_file_contains /run/task.state 1
say 'Reload Finit' say 'Reload Finit'
run "initctl reload" run "initctl reload"
sleep 1 sleep 1
say 'Ensure task has not run again ...' say 'Ensure task has not run again ...'
assert_file_contains /run/task.state 1 assert_file_contains /run/task.state 1
say 'Switch to another runlevel ...' say 'Switch to another runlevel ...'
run "initctl runlevel 3" run "initctl runlevel 3"
sleep 1 sleep 1
say 'Ensure task has run again ...' say 'Ensure task has run again ...'
assert_file_contains /run/task.state 2 assert_file_contains /run/task.state 2
say 'Touch task.sh .conf file and reload Finit ...' say 'Touch task.sh .conf file and reload Finit ...'
run "touch $TEST_CONF" run "touch $TEST_CONF"
run "initctl reload" run "initctl reload"
sleep 1 sleep 1
# run "initctl status task.sh" # run "initctl status task.sh"
assert_file_contains /run/task.state 3 assert_file_contains /run/task.state 3
say "Done, drop stanza from $TEST_CONF ..." say "Done, drop stanza from $TEST_CONF ..."
run "rm $TEST_CONF" run "rm $TEST_CONF"
run "initctl reload" run "initctl reload"
} }
+33 -33
View File
@@ -7,57 +7,57 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" "/tmp/post" run "rm -f $FINIT_CONF" "/tmp/post"
} }
crashit() crashit()
{ {
nm=$1 nm=$1
say 'Simulate service crash (kill -9 ..)' say 'Simulate service crash (kill -9 ..)'
i=0 i=0
laps=100 laps=100
while [ $i -lt $laps ]; do while [ $i -lt $laps ]; do
i=$((i + 1)) i=$((i + 1))
say "Lap $i/$laps, killing service $nm ..." # we have this, no sleep needed say "Lap $i/$laps, killing service $nm ..." # we have this, no sleep needed
if ! run "slay $nm"; then if ! run "slay $nm"; then
break; break;
fi fi
done done
} }
test_one() test_one()
{ {
type=$1 type=$1
shift shift
nm=$1 nm=$1
shift shift
args=$* args=$*
say "Add service stanza in $FINIT_CONF" say "Add service stanza in $FINIT_CONF"
run "echo service log:stderr oncrash:script post:/bin/post.sh $nm $args > $FINIT_CONF" run "echo service log:stderr oncrash:script post:/bin/post.sh $nm $args > $FINIT_CONF"
say 'Reload Finit' say 'Reload Finit'
run "initctl reload" run "initctl reload"
if [ "$type" = "sig" ]; then if [ "$type" = "sig" ]; then
retry "assert_num_children 1 $nm" retry "assert_num_children 1 $nm"
run "initctl status $nm" run "initctl status $nm"
crashit "$nm" crashit "$nm"
fi fi
retry "assert_status $nm crashed" 500 retry "assert_status $nm crashed" 500
run "cat /tmp/post" run "cat /tmp/post"
assert_file_contains "/tmp/post" "POST" assert_file_contains "/tmp/post" "POST"
run "rm -f /tmp/post" run "rm -f /tmp/post"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+30 -30
View File
@@ -16,15 +16,15 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" "/tmp/post" run "rm -f $FINIT_CONF" "/tmp/post"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
@@ -35,36 +35,36 @@ test_teardown()
test_one() test_one()
{ {
cond=$1 cond=$1
say "Verifying foo -> <$cond> bar ..." say "Verifying foo -> <$cond> bar ..."
run "echo service log:stderr name:foo serv -np -i foo -f /tmp/arrakis > $FINIT_CONF" run "echo service log:stderr name:foo serv -np -i foo -f /tmp/arrakis > $FINIT_CONF"
run "echo service log:stderr name:bar \<!$cond\> serv -np -i bar -F /tmp/arrakis >> $FINIT_CONF" run "echo service log:stderr name:bar \<!$cond\> serv -np -i bar -F /tmp/arrakis >> $FINIT_CONF"
run "cat $FINIT_CONF" run "cat $FINIT_CONF"
say 'Reload Finit' say 'Reload Finit'
run "initctl reload" run "initctl reload"
run "initctl status" run "initctl status"
assert_status "foo" "running" assert_status "foo" "running"
assert_cond "$cond" assert_cond "$cond"
assert_status "bar" "running" assert_status "bar" "running"
say "Verify bar is restarted when foo is ..." say "Verify bar is restarted when foo is ..."
pid=$(texec initctl |grep bar | awk '{print $1;}') pid=$(texec initctl |grep bar | awk '{print $1;}')
run "initctl restart foo" run "initctl restart foo"
run "initctl status" run "initctl status"
assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid" assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
# Wait for spice to be stolen by the Harkonnen # Wait for spice to be stolen by the Harkonnen
sleep 3 sleep 3
# bar should now have detected the loss of spice and be in restart # bar should now have detected the loss of spice and be in restart
run "initctl status" run "initctl status"
assert_status "bar" "restart" assert_status "bar" "restart"
# verify bar is stopped->waiting and no longer in restart after stopping foo # verify bar is stopped->waiting and no longer in restart after stopping foo
run "initctl stop foo" run "initctl stop foo"
run "initctl status" run "initctl status"
run "initctl status bar" run "initctl status bar"
assert_status "bar" "waiting" assert_status "bar" "waiting"
} }
sep sep
+22 -22
View File
@@ -9,52 +9,52 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF /tmp/post" run "rm -f $FINIT_CONF /tmp/post"
} }
# Cannot run mknod as non-root even in a chroot # Cannot run mknod as non-root even in a chroot
# touch is close enough for our needs # touch is close enough for our needs
mkdev() mkdev()
{ {
dir=$(dirname "$1") dir=$(dirname "$1")
run "mkdir -p $dir" run "mkdir -p $dir"
run "touch $1" run "touch $1"
} }
rmdev() rmdev()
{ {
run "rm $1" run "rm $1"
} }
test_one() test_one()
{ {
cond="$1" cond="$1"
node="/$cond" node="/$cond"
say "Checking cond $cond and device $node ..." say "Checking cond $cond and device $node ..."
run "echo service log:null \<$cond\> serv -np >> $FINIT_CONF" run "echo service log:null \<$cond\> serv -np >> $FINIT_CONF"
run "cat $FINIT_CONF" run "cat $FINIT_CONF"
run "initctl reload" run "initctl reload"
assert_status "serv" "waiting" assert_status "serv" "waiting"
mkdev "$node" mkdev "$node"
assert_status "serv" "running" assert_status "serv" "running"
rmdev "$node" rmdev "$node"
assert_status "serv" "waiting" assert_status "serv" "waiting"
say "Cleaning up ..." say "Cleaning up ..."
run "rm $FINIT_CONF" run "rm $FINIT_CONF"
run "initctl reload" run "initctl reload"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+5 -5
View File
@@ -8,16 +8,16 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
run "mkdir -p /etc/default" run "mkdir -p /etc/default"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+4 -4
View File
@@ -5,15 +5,15 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+8 -8
View File
@@ -9,28 +9,28 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
test_init() test_init()
{ {
run "echo '# Three foo and one bar enter Finit' > $FINIT_CONF" run "echo '# Three foo and one bar enter Finit' > $FINIT_CONF"
} }
test_add_one() test_add_one()
{ {
service=$1 service=$1
say "Add service stanza '$service' to $FINIT_CONF ..." say "Add service stanza '$service' to $FINIT_CONF ..."
run "echo '$service' >> $FINIT_CONF" run "echo '$service' >> $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+7 -7
View File
@@ -4,10 +4,10 @@ set -eu
cmd="" cmd=""
if [ "$#" -lt 1 ]; then if [ "$#" -lt 1 ]; then
cmd="/bin/sh" cmd="/bin/sh"
else else
cmd=$1 cmd=$1
shift shift
fi fi
TEST_DIR=$(dirname "$0")/.. TEST_DIR=$(dirname "$0")/..
@@ -15,11 +15,11 @@ SYSROOT="${SYSROOT:-$(pwd)/${TEST_DIR}/sysroot}"
PID_FILE="$SYSROOT/running_test.pid" PID_FILE="$SYSROOT/running_test.pid"
if [ -f "$PID_FILE" ] ; then if [ -f "$PID_FILE" ] ; then
target=$(cat "$PID_FILE") target=$(cat "$PID_FILE")
target=$(pgrep -P "$target") target=$(pgrep -P "$target")
else else
echo "No test running!" echo "No test running!"
exit 1 exit 1
fi fi
# shellcheck disable=SC1091 # shellcheck disable=SC1091
+12 -12
View File
@@ -24,9 +24,9 @@
set -eu set -eu
if [ "$#" -lt 2 ]; then if [ "$#" -lt 2 ]; then
echo "Usage:" echo "Usage:"
echo " $0 [target-pid] [command [arguments]]" echo " $0 [target-pid] [command [arguments]]"
exit 1 exit 1
fi fi
target="$1" target="$1"
shift shift
@@ -46,12 +46,12 @@ PATH="$TESTENV_PATH"
export PATH export PATH
"$nsenter" \ "$nsenter" \
--preserve-credentials \ --preserve-credentials \
--user \ --user \
--mount \ --mount \
--uts \ --uts \
--ipc \ --ipc \
--net \ --net \
--pid \ --pid \
-w -t "$target" \ -w -t "$target" \
"$chroot" "$SYSROOT" "$@" "$chroot" "$SYSROOT" "$@"
+8 -8
View File
@@ -342,17 +342,17 @@ echo "Finit running as PID $finit_pid"
i=0 i=0
set +u set +u
while [ -z "$BOOTSTRAP" ] && [ $i -lt 10 ]; do while [ -z "$BOOTSTRAP" ] && [ $i -lt 10 ]; do
lvl=$(texec sh -c "initctl runlevel | awk '{print \$2;}'") lvl=$(texec sh -c "initctl runlevel | awk '{print \$2;}'")
if [ "$lvl" = "$FINIT_RUNLEVEL" ]; then if [ "$lvl" = "$FINIT_RUNLEVEL" ]; then
say "Reached runlevel $FINIT_RUNLEVEL, releasing test." say "Reached runlevel $FINIT_RUNLEVEL, releasing test."
break; break;
fi fi
i=$((i + 1)) i=$((i + 1))
sleep 1 sleep 1
done done
set -u set -u
if type test_setup > /dev/null 2>&1 ; then if type test_setup > /dev/null 2>&1 ; then
test_setup test_setup
fi fi
wdstart $TEST_TIMEOUT wdstart $TEST_TIMEOUT
+18 -18
View File
@@ -8,16 +8,16 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
run "mkdir -p /etc/default" run "mkdir -p /etc/default"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
test_one() test_one()
@@ -37,11 +37,11 @@ test_one()
run "initctl reload" run "initctl reload"
sleep 1 sleep 1
# run "initctl status serv" # run "initctl status serv"
assert_status "serv" "running" assert_status "serv" "running"
sleep 2 sleep 2
# run "initctl cond dump" # run "initctl cond dump"
assert_cond "service/serv/ready" assert_cond "service/serv/ready"
say "Verify 'ready' is set after SIGHUP ..." say "Verify 'ready' is set after SIGHUP ..."
@@ -52,7 +52,7 @@ test_one()
# Issue #343 # Issue #343
say "Verify 'ready' is reasserted if service crashes and is restarted ..." say "Verify 'ready' is reasserted if service crashes and is restarted ..."
# run "initctl status serv" # run "initctl status serv"
run "initctl signal serv 9" run "initctl signal serv 9"
retry 'assert_status "serv" "running"' 2 1 retry 'assert_status "serv" "running"' 2 1
retry 'assert_cond "service/serv/ready"' 3 1 retry 'assert_cond "service/serv/ready"' 3 1
@@ -67,7 +67,7 @@ test_one()
say "Verify 'ready' is reasserted on 'initctl reload' ..." say "Verify 'ready' is reasserted on 'initctl reload' ..."
run "initctl reload" run "initctl reload"
sleep 1 sleep 1
# run "initctl; initctl cond dump" # run "initctl; initctl cond dump"
assert_status "serv" "running" assert_status "serv" "running"
assert_cond "service/serv/ready" assert_cond "service/serv/ready"
@@ -75,12 +75,12 @@ test_one()
# 'started' when they created their PID file. The serv test daemon # 'started' when they created their PID file. The serv test daemon
# waits 3 sec between pidfile and notify to trigger this bug. # waits 3 sec between pidfile and notify to trigger this bug.
if [ "$type" != "native" ]; then if [ "$type" != "native" ]; then
say "Verify 'ready' is *not* asserted immediately on restart + reload" say "Verify 'ready' is *not* asserted immediately on restart + reload"
run "initctl restart serv" run "initctl restart serv"
run "initctl reload" run "initctl reload"
sleep 1 sleep 1
assert_nocond "service/serv/ready" assert_nocond "service/serv/ready"
retry 'assert_cond "service/serv/ready"' 5 0.5 retry 'assert_cond "service/serv/ready"' 5 0.5
fi fi
say "Verify 'ready' is deasserted on stop ..." say "Verify 'ready' is deasserted on stop ..."
@@ -93,9 +93,9 @@ test_one()
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
run "initctl reload" run "initctl reload"
# sleep 2 # sleep 2
# num=$(run "find /proc/1/fd |wc -l") # num=$(run "find /proc/1/fd |wc -l")
# say "finit: number of open file descriptors after test: $num" # say "finit: number of open file descriptors after test: $num"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+14 -14
View File
@@ -7,32 +7,32 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" "/tmp/post" run "rm -f $FINIT_CONF" "/tmp/post"
} }
test_one() test_one()
{ {
pidfn=$1 pidfn=$1
service=$2 service=$2
sep sep
say "Add service stanza '$service' to $FINIT_CONF ..." say "Add service stanza '$service' to $FINIT_CONF ..."
run "echo '$service' > $FINIT_CONF" run "echo '$service' > $FINIT_CONF"
run "initctl reload" run "initctl reload"
assert_is_pidfile "serv" "$pidfn" assert_is_pidfile "serv" "$pidfn"
say "Done, drop service from $FINIT_CONF ..." say "Done, drop service from $FINIT_CONF ..."
run "rm $FINIT_CONF" run "rm $FINIT_CONF"
run "initctl reload" run "initctl reload"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+28 -28
View File
@@ -5,49 +5,49 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
test_one() test_one()
{ {
pre=$1 pre=$1
precont=$2 precont=$2
service=$3 service=$3
post=$4 post=$4
postcont=$5 postcont=$5
say "Add service stanza '$service' to $FINIT_CONF ..." say "Add service stanza '$service' to $FINIT_CONF ..."
run "echo '$service' > $FINIT_CONF" run "echo '$service' > $FINIT_CONF"
say 'Reload Finit' say 'Reload Finit'
run "initctl reload" run "initctl reload"
retry 'assert_num_children 1 serv' retry 'assert_num_children 1 serv'
if [ -n "$pre" ]; then if [ -n "$pre" ]; then
assert_file_contains "$pre" "$precont" assert_file_contains "$pre" "$precont"
run "rm -f $pre" run "rm -f $pre"
fi fi
say 'Stop the service' say 'Stop the service'
run "initctl stop serv" run "initctl stop serv"
retry 'assert_num_children 0 serv' retry 'assert_num_children 0 serv'
if [ -n "$post" ]; then if [ -n "$post" ]; then
assert_file_contains "$post" "$postcont" assert_file_contains "$post" "$postcont"
run "rm -f $post" run "rm -f $post"
fi fi
say "Done, drop service from $FINIT_CONF ..." say "Done, drop service from $FINIT_CONF ..."
run "rm $FINIT_CONF" run "rm $FINIT_CONF"
run "initctl reload" run "initctl reload"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+2 -2
View File
@@ -12,12 +12,12 @@ RCLOCAL="echo 'KILROY WAS HERE' > /tmp/rclocal"
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
} }
sleep 1 sleep 1
+19 -19
View File
@@ -6,39 +6,39 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
test_one() test_one()
{ {
service=$1 service=$1
file=/tmp/ready file=/tmp/ready
say "Add service stanza '$service' to $FINIT_CONF ..." say "Add service stanza '$service' to $FINIT_CONF ..."
run "echo '$service' > $FINIT_CONF" run "echo '$service' > $FINIT_CONF"
say 'Reload Finit' say 'Reload Finit'
run "initctl reload" run "initctl reload"
retry 'assert_num_children 1 serv' retry 'assert_num_children 1 serv'
assert_file_contains "$file" "READY" assert_file_contains "$file" "READY"
run "rm -f $file" run "rm -f $file"
say 'Stop the service' say 'Stop the service'
run "initctl stop serv" run "initctl stop serv"
retry 'assert_num_children 0 serv' retry 'assert_num_children 0 serv'
say "Done, drop service from $FINIT_CONF ..." say "Done, drop service from $FINIT_CONF ..."
run "rm $FINIT_CONF" run "rm $FINIT_CONF"
run "initctl reload" run "initctl reload"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+6 -6
View File
@@ -6,21 +6,21 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
run "mkdir -p /etc/default" run "mkdir -p /etc/default"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
check_restarts() check_restarts()
{ {
assert "serv restarts" "$(texec cat "$1" | awk '{print $1;}')" -ge "$2" assert "serv restarts" "$(texec cat "$1" | awk '{print $1;}')" -ge "$2"
} }
+6 -6
View File
@@ -9,17 +9,17 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
run "mkdir -p /etc/default" run "mkdir -p /etc/default"
export TEST_TIMEOUT=5 export TEST_TIMEOUT=5
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+3 -3
View File
@@ -9,12 +9,12 @@ FINIT_RUNLEVEL=9
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
@@ -23,7 +23,7 @@ test_teardown()
say 'Check runlevel' say 'Check runlevel'
lvl=$(run "initctl runlevel | awk '{print \$2;}'") lvl=$(run "initctl runlevel | awk '{print \$2;}'")
if [ "$lvl" -eq "9" ]; then if [ "$lvl" -eq "9" ]; then
return 0 return 0
fi fi
return 1 return 1
+2 -2
View File
@@ -13,11 +13,11 @@ FINITBIN="$(pwd)/$top_builddir/src/finit" DEST="$SYSROOT" make -f "$srcdir/lib/s
# Drop plugins we don't need in test, only causes confusing FAIL in logs. # Drop plugins we don't need in test, only causes confusing FAIL in logs.
for plugin in tty.so urandom.so rtc.so modprobe.so hotplug.so; do for plugin in tty.so urandom.so rtc.so modprobe.so hotplug.so; do
find "$SYSROOT" -name $plugin -delete find "$SYSROOT" -name $plugin -delete
done done
# Drop system .conf files we don't need in test, same as above # Drop system .conf files we don't need in test, same as above
for conf in hotplug.conf; do for conf in hotplug.conf; do
find "$SYSROOT" -name $conf -delete find "$SYSROOT" -name $conf -delete
done done
+3 -3
View File
@@ -7,10 +7,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+6 -6
View File
@@ -8,10 +8,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
@@ -35,9 +35,9 @@ say 'Simulate service crash (kill -9 ..)'
i=0 i=0
laps=1000 laps=1000
while [ $i -lt $laps ]; do while [ $i -lt $laps ]; do
i=$((i + 1)) i=$((i + 1))
say "Lap $i/$laps, killing service ..." # we have this, no sleep needed say "Lap $i/$laps, killing service ..." # we have this, no sleep needed
run "slay service.sh" run "slay service.sh"
done done
retry 'assert_new_pid service.sh /run/service.pid' retry 'assert_new_pid service.sh /run/service.pid'
+27 -27
View File
@@ -5,51 +5,51 @@ TEST_DIR=$(dirname "$0")
test_setup() test_setup()
{ {
say "Test start $(date)" say "Test start $(date)"
} }
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
test_one() test_one()
{ {
pidfn=$1 pidfn=$1
service=$2 service=$2
say "Add service stanza '$service' to $FINIT_CONF ..." say "Add service stanza '$service' to $FINIT_CONF ..."
run "echo '$service' > $FINIT_CONF" run "echo '$service' > $FINIT_CONF"
say 'Reload Finit' say 'Reload Finit'
#run "initctl debug" #run "initctl debug"
run "initctl reload" run "initctl reload"
#run "initctl status" #run "initctl status"
#run "ps" #run "ps"
#run "initctl status" #run "initctl status"
#run "ps" #run "ps"
#run "initctl status serv" #run "initctl status serv"
retry 'assert_num_children 1 serv' retry 'assert_num_children 1 serv'
retry "assert_has_pidfile $pidfn" 1 retry "assert_has_pidfile $pidfn" 1
say 'Stop the service' say 'Stop the service'
run "initctl stop serv" run "initctl stop serv"
retry 'assert_num_children 0 serv' retry 'assert_num_children 0 serv'
say 'Start the service again' say 'Start the service again'
run "initctl start serv" run "initctl start serv"
retry 'assert_num_children 1 serv' retry 'assert_num_children 1 serv'
say "Done, drop service from $FINIT_CONF ..." say "Done, drop service from $FINIT_CONF ..."
run "rm $FINIT_CONF" run "rm $FINIT_CONF"
run "initctl reload" run "initctl reload"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+3 -3
View File
@@ -6,10 +6,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_RCSD/service.conf" run "rm -f $FINIT_RCSD/service.conf"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+3 -3
View File
@@ -6,10 +6,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null
+3 -3
View File
@@ -6,10 +6,10 @@ TEST_DIR=$(dirname "$0")
test_teardown() test_teardown()
{ {
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
run "rm -f $FINIT_CONF" run "rm -f $FINIT_CONF"
} }
# shellcheck source=/dev/null # shellcheck source=/dev/null