summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog26
-rw-r--r--modules/acl-tests1
-rw-r--r--modules/copy-file-tests1
-rw-r--r--modules/file-has-acl-tests1
-rw-r--r--tests/init.sh17
-rwxr-xr-xtests/test-copy-acl-1.sh6
-rwxr-xr-xtests/test-copy-acl-2.sh6
-rwxr-xr-xtests/test-copy-acl.sh7
-rwxr-xr-xtests/test-copy-file-1.sh10
-rwxr-xr-xtests/test-copy-file-2.sh10
-rwxr-xr-xtests/test-copy-file.sh7
-rwxr-xr-xtests/test-file-has-acl-1.sh6
-rwxr-xr-xtests/test-file-has-acl-2.sh6
-rwxr-xr-xtests/test-file-has-acl.sh7
-rwxr-xr-xtests/test-set-mode-acl-1.sh6
-rwxr-xr-xtests/test-set-mode-acl-2.sh6
-rwxr-xr-xtests/test-set-mode-acl.sh7
-rwxr-xr-xtests/test-vc-list-files-cvs.sh4
-rwxr-xr-xtests/test-vc-list-files-git.sh4
19 files changed, 116 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index d7d1f81d55..3e60f82bb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
2019-01-27 Bruno Haible <bruno@clisp.org>
+ tests: Accommodate a shell that is not in /bin/sh.
+ * tests/init.sh (setup_): Set srcdir and builddir.
+ (BOURNE_SHELL): New variable.
+ * modules/acl-tests (Depends-on): Add 'test-framework-sh'.
+ * modules/file-has-acl-tests (Depends-on): Likewise.
+ * modules/copy-file-tests (Depends-on): Likewise.
+ * tests/test-set-mode-acl-1.sh: Use the test framework. Invoke shell
+ scripts through $BOURNE_SHELL.
+ * tests/test-set-mode-acl-2.sh: Likewise.
+ * tests/test-copy-acl-1.sh: Likewise.
+ * tests/test-copy-acl-2.sh: Likewise.
+ * tests/test-file-has-acl-1.sh: Likewise.
+ * tests/test-file-has-acl-2.sh: Likewise.
+ * tests/test-copy-file-1.sh: Likewise.
+ * tests/test-copy-file-2.sh: Likewise.
+ * tests/test-set-mode-acl.sh (builddir): Consider value set by the
+ invoker.
+ * tests/test-copy-acl.sh (builddir): Likewise.
+ * tests/test-file-has-acl.sh (builddir): Likewise.
+ * tests/test-copy-file.sh (builddir): Likewise.
+ * tests/test-vc-list-files-cvs.sh: Don't create shims for executables in
+ build-aux/. Instead, invoke shell scripts through $BOURNE_SHELL.
+ * tests/test-vc-list-files-git.sh: Likewise.
+
+2019-01-27 Bruno Haible <bruno@clisp.org>
+
tests: Fix some "unused variable" warnings.
* tests/test-fts.c (fts_dealloc): Remove unused variable.
* tests/unigbrk/test-uc-grapheme-breaks.c (main): Likewise.
diff --git a/modules/acl-tests b/modules/acl-tests
index 3438f146f3..76e2a36173 100644
--- a/modules/acl-tests
+++ b/modules/acl-tests
@@ -15,6 +15,7 @@ file-has-acl-tests
read-file
unistd
xalloc
+test-framework-sh
configure.ac:
diff --git a/modules/copy-file-tests b/modules/copy-file-tests
index 299d49fc53..6b468afbfc 100644
--- a/modules/copy-file-tests
+++ b/modules/copy-file-tests
@@ -10,6 +10,7 @@ acl
acl-tests
read-file
xalloc
+test-framework-sh
configure.ac:
diff --git a/modules/file-has-acl-tests b/modules/file-has-acl-tests
index 5a26020bde..ff069ec52d 100644
--- a/modules/file-has-acl-tests
+++ b/modules/file-has-acl-tests
@@ -7,6 +7,7 @@ tests/macros.h
Depends-on:
unistd
+test-framework-sh
configure.ac:
AC_CHECK_DECLS_ONCE([alarm])
diff --git a/tests/init.sh b/tests/init.sh
index 0d6ddee3a1..9498d837ec 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -475,10 +475,18 @@ setup_ ()
initial_cwd_=$PWD
+ # Create and enter the temporary directory.
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"
+ # Set variables srcdir, builddir, for the convenience of the test.
+ case $srcdir in
+ /* | ?:*) ;;
+ *) srcdir="../$srcdir" ;;
+ esac
+ builddir=".."
+ export srcdir builddir
# As autoconf-generated configure scripts do, ensure that IFS
# is defined initially, so that saving and restoring $IFS works.
@@ -607,6 +615,15 @@ mktempd_ ()
fail_ "$err_"
}
+# The interpreter for Bourne-shell scripts.
+# No special standards compatibility requirements.
+# Some environments, such as Android, don't have /bin/sh.
+if test -f /bin/sh$EXEEXT; then
+ BOURNE_SHELL=/bin/sh
+else
+ BOURNE_SHELL=sh
+fi
+
# If you want to override the testdir_prefix_ function,
# or to add more utility functions, use this file.
test -f "$srcdir/init.cfg" \
diff --git a/tests/test-copy-acl-1.sh b/tests/test-copy-acl-1.sh
index 2f9880e04f..bb60091729 100755
--- a/tests/test-copy-acl-1.sh
+++ b/tests/test-copy-acl-1.sh
@@ -3,6 +3,8 @@
# Test copy-acl on the file system of /var/tmp, which usually is a local
# file system.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
if test -d /var/tmp; then
TMPDIR=/var/tmp
else
@@ -10,4 +12,6 @@ else
fi
export TMPDIR
-exec "${srcdir}/test-copy-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-acl.sh"
+
+Exit $?
diff --git a/tests/test-copy-acl-2.sh b/tests/test-copy-acl-2.sh
index 984602d9c9..a35c12eba1 100755
--- a/tests/test-copy-acl-2.sh
+++ b/tests/test-copy-acl-2.sh
@@ -3,7 +3,11 @@
# Test copy-acl on the file system of the build directory, which may be
# a local file system or NFS mounted.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
TMPDIR=`pwd`
export TMPDIR
-exec "${srcdir}/test-copy-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-acl.sh"
+
+Exit $?
diff --git a/tests/test-copy-acl.sh b/tests/test-copy-acl.sh
index 147bf564fd..a0a105dac6 100755
--- a/tests/test-copy-acl.sh
+++ b/tests/test-copy-acl.sh
@@ -41,7 +41,12 @@ func_tmpdir ()
}
func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+ '') builddir=`pwd` ;;
+ /* | ?:*) ;;
+ *) builddir=`pwd`/$builddir ;;
+esac
cd "$builddir" ||
{
echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
diff --git a/tests/test-copy-file-1.sh b/tests/test-copy-file-1.sh
index 8998ba5e40..c18f5e90d9 100755
--- a/tests/test-copy-file-1.sh
+++ b/tests/test-copy-file-1.sh
@@ -3,6 +3,8 @@
# Test copy-file on the file system of /var/tmp, which usually is a local
# file system.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
if test -d /var/tmp; then
TMPDIR=/var/tmp
else
@@ -10,11 +12,11 @@ else
fi
export TMPDIR
-"${srcdir}/test-copy-file.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-file.sh"
ret1=$?
-NO_STDERR_OUTPUT=1 "${srcdir}/test-copy-file.sh"
+NO_STDERR_OUTPUT=1 $BOURNE_SHELL "${srcdir}/test-copy-file.sh"
ret2=$?
case $ret1 in
- 77 ) exit $ret2 ;;
- * ) exit $ret1 ;;
+ 77 ) Exit $ret2 ;;
+ * ) Exit $ret1 ;;
esac
diff --git a/tests/test-copy-file-2.sh b/tests/test-copy-file-2.sh
index 1756f7eb47..d3b7f0e736 100755
--- a/tests/test-copy-file-2.sh
+++ b/tests/test-copy-file-2.sh
@@ -3,14 +3,16 @@
# Test copy-file on the file system of the build directory, which may be
# a local file system or NFS mounted.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
TMPDIR=`pwd`
export TMPDIR
-"${srcdir}/test-copy-file.sh"
+$BOURNE_SHELL "${srcdir}/test-copy-file.sh"
ret1=$?
-NO_STDERR_OUTPUT=1 "${srcdir}/test-copy-file.sh"
+NO_STDERR_OUTPUT=1 $BOURNE_SHELL "${srcdir}/test-copy-file.sh"
ret2=$?
case $ret1 in
- 77 ) exit $ret2 ;;
- * ) exit $ret1 ;;
+ 77 ) Exit $ret2 ;;
+ * ) Exit $ret1 ;;
esac
diff --git a/tests/test-copy-file.sh b/tests/test-copy-file.sh
index 98da280efb..cd2868d243 100755
--- a/tests/test-copy-file.sh
+++ b/tests/test-copy-file.sh
@@ -35,7 +35,12 @@ func_tmpdir ()
}
func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+ '') builddir=`pwd` ;;
+ /* | ?:*) ;;
+ *) builddir=`pwd`/$builddir ;;
+esac
cd "$builddir" ||
{
echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
diff --git a/tests/test-file-has-acl-1.sh b/tests/test-file-has-acl-1.sh
index e3ad9c0e8c..ab13a88c3b 100755
--- a/tests/test-file-has-acl-1.sh
+++ b/tests/test-file-has-acl-1.sh
@@ -3,6 +3,8 @@
# Test file-has-acl on the file system of /var/tmp, which usually is a local
# file system.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
if test -d /var/tmp; then
TMPDIR=/var/tmp
else
@@ -10,4 +12,6 @@ else
fi
export TMPDIR
-exec "${srcdir}/test-file-has-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh"
+
+Exit $?
diff --git a/tests/test-file-has-acl-2.sh b/tests/test-file-has-acl-2.sh
index 6b92b1d928..41561d6cf3 100755
--- a/tests/test-file-has-acl-2.sh
+++ b/tests/test-file-has-acl-2.sh
@@ -3,7 +3,11 @@
# Test file-has-acl on the file system of the build directory, which may be
# a local file system or NFS mounted.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
TMPDIR=`pwd`
export TMPDIR
-exec "${srcdir}/test-file-has-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh"
+
+Exit $?
diff --git a/tests/test-file-has-acl.sh b/tests/test-file-has-acl.sh
index 26610c1e27..a2fa9c3a00 100755
--- a/tests/test-file-has-acl.sh
+++ b/tests/test-file-has-acl.sh
@@ -41,7 +41,12 @@ func_tmpdir ()
}
func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+ '') builddir=`pwd` ;;
+ /* | ?:*) ;;
+ *) builddir=`pwd`/$builddir ;;
+esac
cd "$builddir" ||
{
echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
diff --git a/tests/test-set-mode-acl-1.sh b/tests/test-set-mode-acl-1.sh
index 68c247cd15..7b16b3739b 100755
--- a/tests/test-set-mode-acl-1.sh
+++ b/tests/test-set-mode-acl-1.sh
@@ -3,6 +3,8 @@
# Test set-mode-acl on the file system of /var/tmp, which usually is a local
# file system.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
if test -d /var/tmp; then
TMPDIR=/var/tmp
else
@@ -10,4 +12,6 @@ else
fi
export TMPDIR
-exec "${srcdir}/test-set-mode-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh"
+
+Exit $?
diff --git a/tests/test-set-mode-acl-2.sh b/tests/test-set-mode-acl-2.sh
index d1377dfc8f..2f7c8c02d5 100755
--- a/tests/test-set-mode-acl-2.sh
+++ b/tests/test-set-mode-acl-2.sh
@@ -3,7 +3,11 @@
# Test set-mode-acl on the file system of the build directory, which may be
# a local file system or NFS mounted.
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
TMPDIR=`pwd`
export TMPDIR
-exec "${srcdir}/test-set-mode-acl.sh"
+$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh"
+
+Exit $?
diff --git a/tests/test-set-mode-acl.sh b/tests/test-set-mode-acl.sh
index f0b1641a43..b2f12cf220 100755
--- a/tests/test-set-mode-acl.sh
+++ b/tests/test-set-mode-acl.sh
@@ -41,7 +41,12 @@ func_tmpdir ()
}
func_tmpdir
-builddir=`pwd`
+# builddir may already be set by the script that invokes this one.
+case "$builddir" in
+ '') builddir=`pwd` ;;
+ /* | ?:*) ;;
+ *) builddir=`pwd`/$builddir ;;
+esac
cd "$builddir" ||
{
echo "$0: cannot determine build directory (unreadable parent dir?)" >&2
diff --git a/tests/test-vc-list-files-cvs.sh b/tests/test-vc-list-files-cvs.sh
index b4c389c963..9b2efef652 100755
--- a/tests/test-vc-list-files-cvs.sh
+++ b/tests/test-vc-list-files-cvs.sh
@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. */
: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" .
+. "$srcdir/init.sh"; path_prepend_ .
tmpdir=vc-cvs
repo=`pwd`/$tmpdir/repo
@@ -44,7 +44,7 @@ for i in with-cvsu without; do
cvs -Q -d "$repo" import -m imp m M M0 &&
cvs -Q -d "$repo" co m && cd m &&
printf '%s\n' b c d/a > expected &&
- vc-list-files | sort > actual &&
+ $BOURNE_SHELL "$abs_aux_dir/vc-list-files" | sort > actual &&
compare expected actual &&
ok=1
test $ok = 0 && fail=1
diff --git a/tests/test-vc-list-files-git.sh b/tests/test-vc-list-files-git.sh
index b47105032b..15db4d0eef 100755
--- a/tests/test-vc-list-files-git.sh
+++ b/tests/test-vc-list-files-git.sh
@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. */
: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" .
+. "$srcdir/init.sh"; path_prepend_ .
tmpdir=vc-git-$$
GIT_DIR= GIT_WORK_TREE=; unset GIT_DIR GIT_WORK_TREE
@@ -35,7 +35,7 @@ mkdir $tmpdir && cd $tmpdir &&
git add . > /dev/null &&
git commit -q -a -m log &&
printf '%s\n' b c d/a > expected &&
- vc-list-files > actual &&
+ $BOURNE_SHELL "$abs_aux_dir/vc-list-files" > actual &&
compare expected actual &&
fail=0