From 41b49782c2cd62f284eef3d32eeacbd2d4938934 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 17 Jul 2020 10:16:45 +0200 Subject: [PATCH] Test: Check port file exists and contains the expected number (4711) Signed-off-by: DL6ER --- test/run.sh | 10 +++++++++- test/test_suite.bats | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/run.sh b/test/run.sh index bf64b9f5..32322aa1 100755 --- a/test/run.sh +++ b/test/run.sh @@ -11,8 +11,16 @@ if ! id -u pihole &> /dev/null; then useradd -m -s /usr/sbin/nologin pihole fi +# Kill possibly running pihole-FTL process +while pidof -s pihole-FTL > /dev/null; do + pid="$(pidof -s pihole-FTL)" + echo "Terminating running pihole-FTL process with PID ${pid}" + kill $pid + sleep 1 +done + # Clean up possible old files from earlier test runs -rm -f /etc/pihole/gravity.db /etc/pihole/pihole-FTL.db /var/log/pihole.log /var/log/pihole-FTL.log +rm -f /etc/pihole/gravity.db /etc/pihole/pihole-FTL.db /var/log/pihole.log /var/log/pihole-FTL.log /dev/shm/FTL-* # Create necessary directories and files mkdir -p /etc/pihole /run/pihole /var/log diff --git a/test/test_suite.bats b/test/test_suite.bats index 82e1e15d..8fe60ab6 100644 --- a/test/test_suite.bats +++ b/test/test_suite.bats @@ -456,3 +456,9 @@ printf "%s\n" "${lines[@]}" [[ ${lines[0]} == "2" ]] } + +@test "Port file exists and contains expected API port" { + run bash -c 'cat /run/pihole-FTL.port' + printf "%s\n" "${lines[@]}" + [[ ${lines[0]} == "4711" ]] +}