chiark / gitweb /
server/tests.at: Add a retry loop in `COMMS_EPING'.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 1 Feb 2012 22:55:57 +0000 (22:55 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 21 Mar 2012 16:11:49 +0000 (16:11 +0000)
We will want to test this in the context of an unreliable network later.

server/tests.at

index 649ff82..b3e01a0 100644 (file)
@@ -172,10 +172,24 @@ m4_define([WITH_TRIPE], [WITH_TRIPEX([.], [$1], [$2])])
 m4_define([WITH_2TRIPES],
          [WITH_TRIPEX([$1], [$3 $4], [WITH_TRIPEX([$2], [$3 $5], [$6])])])
 
-## COMMS_EPING(adir, aname, bdir, bname)
+## RETRY(n, body)
+m4_define([RETRY], [
+  n=0 rc=1
+  while test $n -lt $1; do
+    if $2
+    then rc=0; break
+    fi
+    n=$(( $n + 1 ))
+  done
+  exit $rc
+])
+
+## COMMS_EPING(adir, aname, bdir, bname, [n])
 m4_define([COMMS_EPING], [
-  AT_CHECK([TRIPECTL -d$1 EPING $4],, [ignore])
-  AT_CHECK([TRIPECTL -d$3 EPING $2],, [ignore])
+  AT_CHECK([RETRY([m4_default([$5], [1])],
+    [TRIPECTL -d$1 EPING $4])],, [ignore])
+  AT_CHECK([RETRY([m4_default([$5], [1])],
+    [TRIPECTL -d$3 EPING $2])],, [ignore])
 ])
 
 ## COMMS_SLIP(adir, aname, bdir, bname)