]> Savannah Git Hosting - gnulib.git/commitdiff
test-framework-sh: revert port to NetBSD 7.0
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Mar 2016 19:00:35 +0000 (12:00 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Mar 2016 19:26:03 +0000 (12:26 -0700)
It was a false alarm; I misinterpreted Assaf Gordon's report.
* tests/init.sh (testdir_prefix_, pfx_, template_length_):
Restore.
(test_dir_): Adjust to mktempd_ change.
(mktempd_): Restore 2nd arg.  Use -t again.
(base_template_, template_, nx_): Resurrect old code.

ChangeLog
tests/init.sh

index d01a62d015be87875727407c981f8b17079b6a54..545e7a9834a01a29c580de9fb2e9ee4bae4d0c98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2016-03-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+       test-framework-sh: revert port to NetBSD 7.0
+       It was a false alarm; I misinterpreted Assaf Gordon's report.
+       * tests/init.sh (testdir_prefix_, pfx_, template_length_):
+       Restore.
+       (test_dir_): Adjust to mktempd_ change.
+       (mktempd_): Restore 2nd arg.  Use -t again.
+       (base_template_, template_, nx_): Resurrect old code.
+
        Port better to Alpine Linux
        Its diff implementation does not support -c, but does support -U3.
        Problem reported by Assaf Gordon in: http://bugs.gnu.org/23107#13
index 99d4d0b6513a46308a913f1f7400a598272ef912..71c452650c21a9d49c99ecdee25db829e44723fc 100644 (file)
@@ -358,6 +358,9 @@ compare ()
   fi
 }
 
+# An arbitrary prefix to help distinguish test directories.
+testdir_prefix_ () { printf gt; }
+
 # Run the user-overridable cleanup_ function, remove the temporary
 # directory and exit with the incoming value of $?.
 remove_tmp_ ()
@@ -471,7 +474,8 @@ setup_ ()
   initial_cwd_=$PWD
   fail=0
 
-  test_dir_=`mktempd_ "$initial_cwd_"` \
+  pfx_=`testdir_prefix_`
+  test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
     || fail_ "failed to create temporary directory in $initial_cwd_"
   cd "$test_dir_" || fail_ "failed to cd to temporary directory"
 
@@ -492,7 +496,7 @@ setup_ ()
 # Create a temporary directory, much like mktemp -d does.
 # Written by Jim Meyering.
 #
-# Usage: mktempd_ /tmp
+# Usage: mktempd_ /tmp phoey.XXXXXXXXXX
 #
 # First, try to use the mktemp program.
 # Failing that, we'll roll our own mktemp-like function:
@@ -540,16 +544,12 @@ rand_bytes_ ()
 mktempd_ ()
 {
   case $# in
-  1);;
-  *) fail_ "Usage: mktempd_ DIR";;
+  2);;
+  *) fail_ "Usage: mktempd_ DIR TEMPLATE";;
   esac
 
   destdir_=$1
-  base_template_=tmp.
-  template_=$base_template_.XXXXXXXXXX
-
-  # How many X's are at the end of the template.
-  nx_=10
+  template_=$2
 
   MAX_TRIES_=4
 
@@ -560,8 +560,14 @@ mktempd_ ()
   */) fail_ "invalid destination dir: remove trailing slash(es)";;
   esac
 
+  case $template_ in
+  *XXXX) ;;
+  *) fail_ \
+       "invalid template: $template_ (must have a suffix of at least 4 X's)";;
+  esac
+
   # First, try to use mktemp.
-  d=`unset TMPDIR; { mktemp -d -p "$destdir_"; } 2>/dev/null` \
+  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` \
     || fail=1
 
   # The resulting name must be in the specified directory.
@@ -581,6 +587,14 @@ mktempd_ ()
 
   # If we reach this point, we'll have to create a directory manually.
 
+  # Get a copy of the template without its suffix of X's.
+  base_template_=`echo "$template_"|sed 's/XX*$//'`
+
+  # Calculate how many X's we've just removed.
+  template_length_=`echo "$template_" | wc -c`
+  nx_=`echo "$base_template_" | wc -c`
+  nx_=`expr $template_length_ - $nx_`
+
   err_=
   i_=1
   while :; do
@@ -594,7 +608,8 @@ mktempd_ ()
   fail_ "$err_"
 }
 
-# To add more utility functions, use this file.
+# If you want to override the testdir_prefix_ function,
+# or to add more utility functions, use this file.
 test -f "$srcdir/init.cfg" \
   && . "$srcdir/init.cfg"