tests: default to /tmp as the temporary directory
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Dec 2010 18:07:36 +0000 (10:07 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Dec 2010 18:08:04 +0000 (10:08 -0800)
* tests/check.mk (TESTS_ENVIRONMENT): Default TMPDIR to /tmp,
rather than to the working directory; this is more common in
practice, which makes the tests more real-worldish; and it is
often faster.  Also, it avoids some problems with NFS cleanups.
* tests/misc/sort-compress: Remove unnecessary code setting TMPDIR.
* tests/misc/sort-compress-proc: Likewise.  Do the final sleep
only if TMPDIR is relative, which should be rarely given the
change to TESTS_ENVIRONMENT.

tests/check.mk
tests/misc/sort-compress
tests/misc/sort-compress-proc

index df0c924..1391d51 100644 (file)
@@ -49,7 +49,8 @@ built_programs = \
 # variables to test scripts.
 TESTS_ENVIRONMENT =                            \
   . $(srcdir)/lang-default;                    \
-  tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.;        \
+  tmp__=$${TMPDIR-/tmp};                       \
+  test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.;   \
   . $(srcdir)/envvar-check;                    \
   TMPDIR=$$tmp__; export TMPDIR;               \
   exec 9>&2;                                   \
index a51a2df..50845c9 100755 (executable)
@@ -22,9 +22,6 @@ print_ver_ sort
 seq -w 2000 > exp || framework_failure
 tac exp > in || framework_failure
 
-# Ensure that $TMPDIR is valid.
-TMPDIR=.; export TMPDIR
-
 # This should force the use of temp files
 sort -S 1k in > out || fail=1
 compare exp out || fail=1
index 8d0094f..30f6b43 100755 (executable)
 print_ver_ sort
 expensive_
 
-# Ensure that $TMPDIR is valid.
-if test -d /tmp && test -w /tmp
-then TMPDIR=/tmp
-else TMPDIR=.
-fi
-export TMPDIR
-
 seq -w 2000 > exp || fail=1
 tac exp > in || fail=1
 insize=$(stat -c %s - <in) || fail=1
@@ -78,10 +71,13 @@ rm -f ok
 
 rm -f compress
 
-# Give compression subprocesses time to react when 'sort' exits.
+# If $TMPDIR is relative, give subprocesses time to react when 'sort' exits.
 # Otherwise, under NFS, when 'sort' unlinks the temp files and they
 # are renamed to .nfsXXXX instead of being removed, the parent cleanup
 # of this directory will fail because the files are still open.
-sleep 1
+case $TMPDIR in
+/*) ;;
+*) sleep 1;;
+esac
 
 Exit $fail