mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
test: Minor adjustments to improve consistency between test code structure
Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
This commit is contained in:
@@ -4,6 +4,12 @@ assert_num_children() {
|
||||
assert "$1 services are running" "$(texec pgrep -P 1 "$2" | wc -l)" -eq "$1"
|
||||
}
|
||||
|
||||
remove_thing() {
|
||||
THING="$(realpath "$1")"
|
||||
say "Remove ${THING#*/test/*}"
|
||||
rm -f "$THING"
|
||||
}
|
||||
|
||||
texec() {
|
||||
# shellcheck disable=SC2154
|
||||
"$TEST_DIR/testenv_exec.sh" "$finit_pid" "$@"
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")/..
|
||||
TESTENV_ROOT="$TEST_DIR"/test_root
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/lib.sh"
|
||||
|
||||
test_teardown() {
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown..."
|
||||
say "Running test teardown."
|
||||
|
||||
# Teardown
|
||||
rm -f test_root/bin/service.sh
|
||||
remove_thing "$TESTENV_ROOT/$FINIT_CONF"
|
||||
remove_thing "$TESTENV_ROOT"/test_assets/service.sh
|
||||
}
|
||||
|
||||
# Test
|
||||
say "Test start $(date)"
|
||||
say 'Add a dynamic service in /etc/finit.conf'
|
||||
|
||||
cp "$TEST_DIR"/common/service.sh "$TEST_DIR"/test_root/test_assets/
|
||||
|
||||
say "Add a dynamic service in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] kill:20 log /test_assets/service.sh' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
|
||||
@@ -3,28 +3,30 @@
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")/..
|
||||
TESTENV_ROOT="$TEST_DIR"/test_root
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/lib.sh"
|
||||
|
||||
test_teardown() {
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown..."
|
||||
say "Running test teardown."
|
||||
|
||||
# Teardown
|
||||
rm -f test_root/bin/service.sh
|
||||
remove_thing "$TESTENV_ROOT/$FINIT_CONF_DIR/service.conf"
|
||||
remove_thing "$TESTENV_ROOT"/test_assets/service.sh
|
||||
}
|
||||
|
||||
# Test
|
||||
say "Test start $(date)"
|
||||
|
||||
say "Add a dynamic service in $FINIT_CONF_DIR/service.conf"
|
||||
cp "$TEST_DIR"/common/service.sh "$TEST_DIR"/test_root/test_assets/
|
||||
|
||||
say "Add a dynamic service in $FINIT_CONF_DIR/service.conf"
|
||||
texec sh -c "echo 'service [2345] kill:20 log /test_assets/service.sh' > $FINIT_CONF_DIR/service.conf"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec kill -SIGHUP 1
|
||||
|
||||
retry 'assert_num_children 1 service.sh' 5
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Remove the dynamic service from /etc/finit.d/service.conf'
|
||||
texec sh -c "echo > $FINIT_CONF_DIR/service.conf"
|
||||
@@ -32,4 +34,4 @@ texec sh -c "echo > $FINIT_CONF_DIR/service.conf"
|
||||
say 'Reload Finit'
|
||||
texec kill -SIGHUP 1
|
||||
|
||||
retry 'assert_num_children 0 service.sh' 5
|
||||
retry 'assert_num_children 0 service.sh'
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")/..
|
||||
TESTENV_ROOT="$TEST_DIR"/test_root
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/lib.sh"
|
||||
|
||||
test_teardown() {
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown..."
|
||||
say "Running test teardown."
|
||||
|
||||
# Teardown
|
||||
rm -f test_root/bin/service.sh
|
||||
remove_thing "$TESTENV_ROOT/$FINIT_CONF"
|
||||
remove_thing "$TESTENV_ROOT"/test_assets/service.sh
|
||||
}
|
||||
|
||||
# Test
|
||||
say "Test start $(date)"
|
||||
say 'Add service stanza in /etc/finit.conf'
|
||||
|
||||
cp "$TEST_DIR"/common/service.sh "$TEST_DIR"/test_root/test_assets/
|
||||
|
||||
say "Add service stanza in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] kill:20 log /test_assets/service.sh' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
|
||||
@@ -3,22 +3,24 @@
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")/..
|
||||
TESTENV_ROOT="$TEST_DIR"/test_root
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/lib.sh"
|
||||
|
||||
test_teardown() {
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown..."
|
||||
say "Running test teardown."
|
||||
|
||||
# Teardown
|
||||
rm -f test_root/bin/service.sh
|
||||
remove_thing "$TESTENV_ROOT/$FINIT_CONF_DIR/service.conf"
|
||||
remove_thing "$TESTENV_ROOT"/test_assets/service.sh
|
||||
}
|
||||
|
||||
# Test
|
||||
say "Test start $(date)"
|
||||
say 'Add service stanza in /etc/finit.d/service.conf'
|
||||
|
||||
cp "$TEST_DIR"/common/service.sh "$TEST_DIR"/test_root/test_assets/
|
||||
# texec sh -c "echo 'service [2345] kill:20 log /test_assets/service.sh' > $FINIT_CONF"
|
||||
|
||||
say "Add service stanza in $FINIT_CONF_DIR/service.conf"
|
||||
texec sh -c "echo 'service [2345] kill:20 log /test_assets/service.sh' > $FINIT_CONF_DIR/service.conf"
|
||||
|
||||
say 'Reload Finit'
|
||||
|
||||
Reference in New Issue
Block a user