From 5b6909ef50da07bd3a02f1dad52053f81baab649 Mon Sep 17 00:00:00 2001 From: Michael Tatarinov Date: Thu, 6 Oct 2011 15:12:22 +0400 Subject: More fixes with a unique temporary directories and files for the regression test.. Signed-off-by: Eric S. Raymond --- SConstruct | 26 ++++++++++++++++---------- gps/fake.py | 5 +++-- regress-driver | 3 ++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/SConstruct b/SConstruct index fe09d37b..4ecbf68d 100644 --- a/SConstruct +++ b/SConstruct @@ -1267,13 +1267,16 @@ rtcm_regress = Utility('rtcm-regress', [gpsdecode], [ '@echo "Testing RTCM decoding..."', 'for f in $SRCDIR/test/*.rtcm2; do ' 'echo "Testing $${f}..."; ' - '$SRCDIR/gpsdecode -j <$${f} >/tmp/test-$$$$.chk; ' - 'diff -ub $${f}.chk /tmp/test-$$$$.chk; ' + 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' + '$SRCDIR/gpsdecode -j <$${f} >$${TMPFILE}; ' + 'diff -ub $${f}.chk $${TMPFILE}; ' + 'rm -f $${TMPFILE}; ' 'done;', '@echo "Testing idempotency of JSON dump/decode for RTCM2"', - '$SRCDIR/gpsdecode -e -j /tmp/test-$$$$.chk; ' - 'grep -v "^#" test/synthetic-rtcm2.json | diff -ub - /tmp/test-$$$$.chk; ' - 'rm /tmp/test-$$$$.chk', + 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' + '$SRCDIR/gpsdecode -e -j $${TMPFILE}; ' + 'grep -v "^#" test/synthetic-rtcm2.json | diff -ub - $${TMPFILE}; ' + 'rm -f $${TMPFILE}; ', ]) # Rebuild the RTCM regression tests. @@ -1288,13 +1291,16 @@ aivdm_regress = Utility('aivdm-regress', [gpsdecode], [ '@echo "Testing AIVDM decoding..."', 'for f in $SRCDIR/test/*.aivdm; do ' 'echo "Testing $${f}..."; ' - '$SRCDIR/gpsdecode -u -c <$${f} >/tmp/test-$$$$.chk; ' - 'diff -ub $${f}.chk /tmp/test-$$$$.chk; ' + 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' + '$SRCDIR/gpsdecode -u -c <$${f} >$${TMPFILE}; ' + 'diff -ub $${f}.chk $${TMPFILE}; ' + 'rm -f $${TMPFILE}; ' 'done;', '@echo "Testing idempotency of JSON dump/decode for AIS"', - '$SRCDIR/gpsdecode -e -j <$SRCDIR/test/synthetic-ais.json >/tmp/test-$$$$.chk; ' - 'grep -v "^#" $SRCDIR/test/synthetic-ais.json | diff -ub - /tmp/test-$$$$.chk; ' - 'rm /tmp/test-$$$$.chk', + 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' + '$SRCDIR/gpsdecode -e -j <$SRCDIR/test/synthetic-ais.json >$${TMPFILE}; ' + 'grep -v "^#" $SRCDIR/test/synthetic-ais.json | diff -ub - $${TMPFILE}; ' + 'rm -f $${TMPFILE}; ', ]) # Rebuild the AIVDM regression tests. diff --git a/gps/fake.py b/gps/fake.py index 7843fed6..59bf8f84 100644 --- a/gps/fake.py +++ b/gps/fake.py @@ -300,11 +300,12 @@ class DaemonInstance: def __init__(self, control_socket=None): self.sockfile = None self.pid = None + self.tmpdir = os.environ.get('TMPDIR', '/tmp') if control_socket: self.control_socket = control_socket else: - self.control_socket = "/tmp/gpsfake-%d.sock" % os.getpid() - self.pidfile = "/tmp/gpsfake_pid-%s" % os.getpid() + self.control_socket = "%s/gpsfake-%d.sock" % (self.tmpdir, os.getpid()) + self.pidfile = "%s/gpsfake-%d.pid" % (self.tmpdir, os.getpid()) def spawn(self, options, port, background=False, prefix=""): "Spawn a daemon instance." self.spawncmd = None diff --git a/regress-driver b/regress-driver index b9015ee2..f6bcfc02 100755 --- a/regress-driver +++ b/regress-driver @@ -105,7 +105,7 @@ case $mode in then trap 'rm -f ${TMP}/test-$$.chk; exit $errors' EXIT HUP INT TERM case $testing in - daemon) ${PYTHON} ${GPSD_HOME}/gpsfake -s 38400 -f -1 -p $opts ${f} | ${GPSFILTER} ${ALTFILTER} >${TMP}/test-$$.chk ;; + daemon) TMPDIR=${TMP} ${PYTHON} ${GPSD_HOME}/gpsfake -s 38400 -f -1 -p $opts ${f} | ${GPSFILTER} ${ALTFILTER} >${TMP}/test-$$.chk ;; clientlib) ${GPSD_HOME}/test_libgps -b <${f} >${TMP}/test-$$.chk ;; esac if [ "${ALTFILTER}" ] @@ -189,4 +189,5 @@ then echo "scale=2; ${endtime} - ${starttime}" | bc fi +rm -fr ${TMP} exit $status -- cgit v1.2.1