mirror of
https://github.com/troglobit/finit.git
synced 2026-11-15 19:13:11 +00:00
test: new regression test for bug #313
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
61dab8bd75
commit
726f7ba229
5 files changed
+80
-2
No files matched your search
@@ -27,7 +27,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install pkg-config tree
|
||||
sudo apt-get -y install pkg-config tree jq
|
||||
wget https://github.com/troglobit/libuev/releases/download/v2.3.2/libuev-2.3.2.tar.xz
|
||||
wget https://github.com/troglobit/libite/releases/download/v2.5.2/libite-2.5.2.tar.gz
|
||||
tar xf libuev-2.3.2.tar.xz
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Installing dependencies
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install pkg-config
|
||||
sudo apt-get -y install pkg-config jq
|
||||
wget https://github.com/troglobit/libuev/releases/download/v2.3.2/libuev-2.3.2.tar.xz
|
||||
wget https://github.com/troglobit/libite/releases/download/v2.5.2/libite-2.5.2.tar.gz
|
||||
tar xf libuev-2.3.2.tar.xz
|
||||
|
||||
@@ -33,6 +33,7 @@ EXTRA_DIST += runlevel.sh
|
||||
EXTRA_DIST += start-stop-service.sh
|
||||
EXTRA_DIST += start-stop-service-sub-config.sh
|
||||
EXTRA_DIST += start-kill-service.sh
|
||||
EXTRA_DIST += start-kill-stop.sh
|
||||
EXTRA_DIST += start-stop-sysv.sh
|
||||
EXTRA_DIST += start-stop-serv.sh
|
||||
EXTRA_DIST += signal-service.sh
|
||||
@@ -65,6 +66,7 @@ TESTS += runlevel.sh
|
||||
TESTS += start-stop-service.sh
|
||||
TESTS += start-stop-service-sub-config.sh
|
||||
TESTS += start-kill-service.sh
|
||||
TESTS += start-kill-stop.sh
|
||||
TESTS += start-stop-sysv.sh
|
||||
TESTS += start-stop-serv.sh
|
||||
TESTS += signal-service.sh
|
||||
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
# Regression test for Finit bug #313:
|
||||
# - services get the 'forking' flag on initctl reload
|
||||
# - stopping a crashing task while its restart callback is pending
|
||||
# causes state 'running' with pid:0 (i.e., not running at all.)
|
||||
#
|
||||
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
# texec sh -c "initctl status -j serv"
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Check deps ..."
|
||||
check_dep jq
|
||||
check_dep fozza
|
||||
|
||||
|
||||
say "Test start $(date)"
|
||||
rm -f "$TENV_ROOT"/oldpid
|
||||
|
||||
say "Add service stanza in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] log:stderr serv -np -- Test service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
|
||||
say 'Verify serv is running ...'
|
||||
retry 'assert_num_children 1 serv'
|
||||
|
||||
say 'Verify reload does not change forking type of service'
|
||||
#texec sh -c "initctl status -j serv"
|
||||
texec sh -c "initctl reload"
|
||||
#texec sh -c "initctl status -j serv"
|
||||
assert_forking serv false
|
||||
|
||||
say 'Simulate service crash (kill -9 ..)'
|
||||
texec sh -c "initctl debug"
|
||||
i=0
|
||||
laps=7
|
||||
while [ $i -lt $laps ]; do
|
||||
i=$((i + 1))
|
||||
say "Lap $i/$laps, killing service ..." # we have this, no sleep needed
|
||||
texec sh -c "slay serv"
|
||||
done
|
||||
|
||||
say 'Verify stopping service actually stops it'
|
||||
sleep 1
|
||||
texec sh -c "initctl stop serv"
|
||||
sleep 5
|
||||
#texec sh -c "initctl status serv"
|
||||
assert_status serv stopped
|
||||
|
||||
say 'Verify restarting service actually starts it'
|
||||
texec sh -c "initctl start serv"
|
||||
retry 'assert_num_children 1 serv'
|
||||
@@ -36,6 +36,16 @@ assert_num_services()
|
||||
assert "$1 services are loaded" "$(texec initctl -t status "$2" | wc -l)" -eq "$1"
|
||||
}
|
||||
|
||||
assert_forking()
|
||||
{
|
||||
assert "service $1 forking:$2" "$(texec initctl -j status "$1" | jq -M .forking)" = "$2"
|
||||
}
|
||||
|
||||
assert_nopid()
|
||||
{
|
||||
assert "service $1 pid:0" "$(texec initctl -j status "$1" | jq -M .pid)" -eq 0
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
assert_new_pid()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user