server/tests.at (TRIPE): Set command-line trace options from environment.
[tripe] / server / tests.at
index 7a64cb4..df77d71 100644 (file)
@@ -35,13 +35,35 @@ m4_define([SETUPDIR], [
 ## Running standard programs with useful options.
 m4_define([TRIPE],
   [env TRIPE_PRIVHELPER=$abs_top_builddir/priv/tripe-privhelper \
-     $abs_top_builddir/server/tripe -F -d. -aadmin -p0 -b127.0.0.1 -talice])
+     $abs_top_builddir/server/tripe -F -d. -aadmin -p0 -b127.0.0.1 -talice \
+       ${TRIPE_TEST_TRACEOPTS+-T$TRIPE_TEST_TRACEOPTS}])
 m4_define([TRIPECTL], [$abs_top_builddir/client/tripectl -d. -aadmin])
 m4_define([USLIP], [$abs_top_builddir/uslip/tripe-uslip])
 m4_define([PKSTREAM],
   [$abs_top_builddir/pkstream/pkstream -b127.0.0.1 -p127.0.0.1])
 m4_define([MITM], [$abs_top_builddir/proxy/tripe-mitm])
 
+## WITH_STRACE(tag, cmd)
+##
+## There's an awful hack here.  If a process running under strace exits with
+## a signal, then strace will kill itself with the same signal -- and
+## therefore clobber the original process's core file.  So we arrange to run
+## strace in one directory and have the child process run in another.
+m4_define([WITH_STRACE],
+[case "${TRIPE_TEST_STRACE-nil}" in
+  nil)
+    $2
+    ;;
+  *)
+    mkdir -p strace-hack.$1/
+    (ulimit -c hard >/dev/null 2>&1
+     sh -c 'cd strace-hack.$1; exec "$[]@"' - \
+       strace -f -o../$1.trace \
+       sh -c 'cd ..; exec "$[]@"' - \
+       $2)
+    ;;
+ esac])
+
 ## Sequences.  (These are used for testing the replay protection machinery.)
 m4_define([R32], [ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15   dnl
                  16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31])
@@ -84,24 +106,17 @@ mv stdout $1/port
 ## Test body...
 $3
 
-## End of the test, now run the server.  There's an awful hack here.  If a
-## process running under strace exits with a signal, then strace will kill
-## itself with the same signal -- and therefore clobber the original
-## process's core file.  So we arrange to run strace in one directory and
-## have the child process run in another.
+## End of the test, now run the server.
 ) && :; } | {
   cd $1
-  mkdir -p strace-hack/
   echo TRIPE $2 >&2
-  (cd strace-hack/
-   ulimit -c hard >/dev/null 2>&1
-   strace -f -o ../tripe.trace \
-     TRIPE -d.. $2 >../server-output.full 2>../server-errors)
+  WITH_STRACE([tripe], [TRIPE $2 >server-output.full 2>server-errors.full])
   stat=$?
   echo $stat >server-status
   if test $stat -ne 0; then
-    echo "exit status: $stat" >>server-errors
+    echo "exit status: $stat" >>server-errors.full
   fi
+  grep -v '^+ tripe: ' server-errors.full >server-errors
 
   ## We interrupt this relatively sensible macro for an especially awful
   ## hack.  The tripe server emits warnings which are often caused by lack of
@@ -214,9 +229,12 @@ m4_define([COMMS_SLIP], [
 m4_define([AWAIT_KXDONE], [
 
   ## Ignore some reports caused by races.
-  TRIPECTL -d$3 WARN test PUSH
-  TRIPECTL -d$3 WARN test IGNORE WARN KX $2 incorrect cookie
-  TRIPECTL -d$3 WARN test IGNORE WARN KX $2 unexpected pre-challenge
+  for d in $1 $3; do
+    TRIPECTL -d$d WARN test PUSH
+    TRIPECTL -d$d WARN test IGNORE WARN KX $2 incorrect cookie
+    TRIPECTL -d$d WARN test IGNORE WARN KX $2 unexpected pre-challenge
+    TRIPECTL -d$d WARN test IGNORE WARN KX $2 unexpected challenge
+  done
 
   ## Watch for the key-exchange completion announcement in the background.
   COPROCESSES([wait-$1], [
@@ -242,7 +260,7 @@ m4_define([AWAIT_KXDONE], [
   AT_CHECK([echo $waitrc],, [0[]nl])
 
   ## Be interested in key-exchange warnings again.
-  TRIPECTL -d$4 WARN test POP
+  for d in $1 $3; do TRIPECTL -d$d WARN test POP; done
 ])
 
 ## ESTABLISH(adir, aname, aopts, bdir, bname, bopts, [aport], [bport])