test: New test: test_start_stop_service

Add a new test that verifies that Finit will:
- Start a service that's been added to the config
- Stop the service once it's removed from the config

The second step is currently failing.

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
This commit is contained in:
Jacques de Laval committed 2021-02-18 13:55:47 +01:00
1 parent 4f82cb8261
commit 4224c2e8fe
7 files changed
+98 -6

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
#!/bin/sh
set -eu
texec() {
./testenv_exec.sh $(pgrep -P $finit_ppid) "$@"
}
fg_red='31'
fg_green='32'
fg_yellow='33'
log() {
printf "< TEST > \e[1;%dm%s\e[0m %s\n" "$1" "$2" "$3"
}
assert() {
msg=$1
shift
if [ ! "$@" ]; then
log "$fg_red" ✘ "$msg"
exit 1
fi
log "$fg_green" ✔ "$msg"
}
say() {
log "$fg_yellow" ● "$@"
}
teardown() {
texec kill 1
wait
}
trap teardown EXIT
# Setup
./testenv_start.sh finit &
finit_ppid=$!
for i in $(seq 1 50); do
sleep 0.1
finit_pid=$(pgrep -P "$finit_ppid") || continue
break
done
texec cat /dev/tty0 &
sleep 1
TEST_DIR=$(dirname $1)
source "$1"