# HG changeset patch # User Bruno Haible # Date 1548601283 -3600 # Node ID 066c585853e5e7db0c4d4f470ce654887797f170 # Parent 84fd38f4932c2dcb349e23d1c4fb47bae4139db6 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. diff -r 84fd38f4932c -r 066c585853e5 ChangeLog --- a/ChangeLog Sun Jan 27 12:24:47 2019 +0100 +++ b/ChangeLog Sun Jan 27 16:01:23 2019 +0100 @@ -1,3 +1,29 @@ +2019-01-27 Bruno Haible + + 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 tests: Fix some "unused variable" warnings. diff -r 84fd38f4932c -r 066c585853e5 modules/acl-tests --- a/modules/acl-tests Sun Jan 27 12:24:47 2019 +0100 +++ b/modules/acl-tests Sun Jan 27 16:01:23 2019 +0100 @@ -15,6 +15,7 @@ read-file unistd xalloc +test-framework-sh configure.ac: diff -r 84fd38f4932c -r 066c585853e5 modules/copy-file-tests --- a/modules/copy-file-tests Sun Jan 27 12:24:47 2019 +0100 +++ b/modules/copy-file-tests Sun Jan 27 16:01:23 2019 +0100 @@ -10,6 +10,7 @@ acl-tests read-file xalloc +test-framework-sh configure.ac: diff -r 84fd38f4932c -r 066c585853e5 modules/file-has-acl-tests --- a/modules/file-has-acl-tests Sun Jan 27 12:24:47 2019 +0100 +++ b/modules/file-has-acl-tests Sun Jan 27 16:01:23 2019 +0100 @@ -7,6 +7,7 @@ Depends-on: unistd +test-framework-sh configure.ac: AC_CHECK_DECLS_ONCE([alarm]) diff -r 84fd38f4932c -r 066c585853e5 tests/init.sh --- a/tests/init.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/init.sh Sun Jan 27 16:01:23 2019 +0100 @@ -475,10 +475,18 @@ 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 @@ 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 -r 84fd38f4932c -r 066c585853e5 tests/test-copy-acl-1.sh --- a/tests/test-copy-acl-1.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-copy-acl-1.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 @@ fi export TMPDIR -exec "${srcdir}/test-copy-acl.sh" +$BOURNE_SHELL "${srcdir}/test-copy-acl.sh" + +Exit $? diff -r 84fd38f4932c -r 066c585853e5 tests/test-copy-acl-2.sh --- a/tests/test-copy-acl-2.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-copy-acl-2.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 -r 84fd38f4932c -r 066c585853e5 tests/test-copy-acl.sh --- a/tests/test-copy-acl.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-copy-acl.sh Sun Jan 27 16:01:23 2019 +0100 @@ -41,7 +41,12 @@ } 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 -r 84fd38f4932c -r 066c585853e5 tests/test-copy-file-1.sh --- a/tests/test-copy-file-1.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-copy-file-1.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 @@ 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 -r 84fd38f4932c -r 066c585853e5 tests/test-copy-file-2.sh --- a/tests/test-copy-file-2.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-copy-file-2.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 -r 84fd38f4932c -r 066c585853e5 tests/test-copy-file.sh --- a/tests/test-copy-file.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-copy-file.sh Sun Jan 27 16:01:23 2019 +0100 @@ -35,7 +35,12 @@ } 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 -r 84fd38f4932c -r 066c585853e5 tests/test-file-has-acl-1.sh --- a/tests/test-file-has-acl-1.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-file-has-acl-1.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 @@ fi export TMPDIR -exec "${srcdir}/test-file-has-acl.sh" +$BOURNE_SHELL "${srcdir}/test-file-has-acl.sh" + +Exit $? diff -r 84fd38f4932c -r 066c585853e5 tests/test-file-has-acl-2.sh --- a/tests/test-file-has-acl-2.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-file-has-acl-2.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 -r 84fd38f4932c -r 066c585853e5 tests/test-file-has-acl.sh --- a/tests/test-file-has-acl.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-file-has-acl.sh Sun Jan 27 16:01:23 2019 +0100 @@ -41,7 +41,12 @@ } 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 -r 84fd38f4932c -r 066c585853e5 tests/test-set-mode-acl-1.sh --- a/tests/test-set-mode-acl-1.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-set-mode-acl-1.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 @@ fi export TMPDIR -exec "${srcdir}/test-set-mode-acl.sh" +$BOURNE_SHELL "${srcdir}/test-set-mode-acl.sh" + +Exit $? diff -r 84fd38f4932c -r 066c585853e5 tests/test-set-mode-acl-2.sh --- a/tests/test-set-mode-acl-2.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-set-mode-acl-2.sh Sun Jan 27 16:01:23 2019 +0100 @@ -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 -r 84fd38f4932c -r 066c585853e5 tests/test-set-mode-acl.sh --- a/tests/test-set-mode-acl.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-set-mode-acl.sh Sun Jan 27 16:01:23 2019 +0100 @@ -41,7 +41,12 @@ } 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 -r 84fd38f4932c -r 066c585853e5 tests/test-vc-list-files-cvs.sh --- a/tests/test-vc-list-files-cvs.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-vc-list-files-cvs.sh Sun Jan 27 16:01:23 2019 +0100 @@ -17,7 +17,7 @@ # along with this program. If not, see . */ : ${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 @@ 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 -r 84fd38f4932c -r 066c585853e5 tests/test-vc-list-files-git.sh --- a/tests/test-vc-list-files-git.sh Sun Jan 27 12:24:47 2019 +0100 +++ b/tests/test-vc-list-files-git.sh Sun Jan 27 16:01:23 2019 +0100 @@ -17,7 +17,7 @@ # along with this program. If not, see . */ : ${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 @@ 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