From 9867bea0e9719d3e66b9b1504c728579a9a6b39c Mon Sep 17 00:00:00 2001 Message-Id: <9867bea0e9719d3e66b9b1504c728579a9a6b39c.1714867822.git.mdw@distorted.org.uk> From: Mark Wooding Date: Fri, 19 Feb 2016 21:49:33 +0000 Subject: [PATCH] server/tests.at (WITH_STRACE): Factor out the strace(1) machinery. Organization: Straylight/Edgeware From: Mark Wooding There's very little noticeable difference in the behaviour: the (usually empty) directory created for strace(1) to scribble its corefile has a different name. The new macro takes care of running the caller's command in the correct directory, so the (only, currently) call site doesn't need to worry about that any more. --- server/tests.at | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/server/tests.at b/server/tests.at index 5fcf0601..af94847d 100644 --- a/server/tests.at +++ b/server/tests.at @@ -42,6 +42,27 @@ 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,26 +105,11 @@ 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 echo TRIPE $2 >&2 - case "${TRIPE_TEST_STRACE-nil}" in - nil) - TRIPE -d. $2 >server-output.full 2>server-errors - ;; - *) - mkdir -p strace-hack/ - (cd strace-hack/ - ulimit -c hard >/dev/null 2>&1 - strace -f -o ../tripe.trace \ - TRIPE -d.. $2 >../server-output.full 2>../server-errors) - ;; - esac + WITH_STRACE([tripe], [TRIPE $2 >server-output.full 2>server-errors]) stat=$? echo $stat >server-status if test $stat -ne 0; then -- [mdw]