Clean up leftover tincd and sptps_test processes.
[tinc] / test / testlib.sh
index d60b9da..39a2bf4 100644 (file)
@@ -21,10 +21,6 @@ case "$_" in
        ;;
 esac
 
-# Remove test directories
-
-rm -rf $d1 $d2 $d3
-
 # Default arguments for both tinc and tincd
 
 c1="--config=$d1 --pidfile=$d1/pid"
@@ -37,6 +33,16 @@ r1="--logfile=$d1/log -d5"
 r2="--logfile=$d2/log -d5"
 r3="--logfile=$d3/log -d5"
 
+# Check for leftover tinc daemons
+
+[ -f $d1/pid ] && $tinc $c1 stop
+[ -f $d2/pid ] && $tinc $c2 stop
+[ -f $d3/pid ] && $tinc $c3 stop
+
+# Remove test directories
+
+rm -rf $d1 $d2 $d3
+
 # Exit on errors, log all commands being executed
 
 set -ex