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