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" ]] +}