From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 061CF1F453 for ; Sun, 27 Jan 2019 15:07:59 +0000 (UTC) Received: from localhost ([127.0.0.1]:46804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnm2P-0001yg-1A for normalperson@yhbt.net; Sun, 27 Jan 2019 10:07:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnm2I-0001yL-HU for bug-gnulib@gnu.org; Sun, 27 Jan 2019 10:07:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnm2F-0003xa-8w for bug-gnulib@gnu.org; Sun, 27 Jan 2019 10:07:50 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::11]:31473) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gnm2E-0003vJ-FN for bug-gnulib@gnu.org; Sun, 27 Jan 2019 10:07:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1548601661; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=VQ9/JbfmyaiktgZCRBDgG9yxFFG6TokbKrgywXm2wwA=; b=RIW3A+cSN/NNTl2IVrz2VE+0j5MfbMXMjsw2bsZ0QfYflXlVxytNSgiGneZrMhGadO jY5/Pi80f4vdLgnRArh+pisKYWkzP1GGlZJR0o8tO37fiTknxgNfno4Cc7uaiGZOJHuV 5xOe+JO4ZI5Nkcpx2+RCBfSi2wn0ptulcpOMOgggvNMHi0f7Qpm1m4Tkhe5HVozmIDZW B3xst+sBgN9imlm0MzbMyuD8isehiR7W1O7Z/7LGyoHmOHvr4MOilImXy5U2QvMVoGtI HzRXw0LVLZRWd9gP0v8AxuP5PCJsGz7pnsQa42dO0V5AjtBF280erywi24AUipA6Z7nh H9sw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id v0a34ev0RF7fpSN (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sun, 27 Jan 2019 16:07:41 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: tests: Accommodate a shell that is not in /bin/sh Date: Sun, 27 Jan 2019 16:07:40 +0100 Message-ID: <2006700.NLihKnAHSQ@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::11 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On Android 4.3, I'm seeing these test failures: FAIL: test-set-mode-acl-1.sh ============================ ../../gltests/test-set-mode-acl-1.sh[13]: ../../gltests/test-set-mode-acl.sh: No such file or directory FAIL test-set-mode-acl-1.sh (exit status: 1) FAIL: test-set-mode-acl-2.sh ============================ ../../gltests/test-set-mode-acl-2.sh[9]: ../../gltests/test-set-mode-acl.sh: No such file or directory FAIL test-set-mode-acl-2.sh (exit status: 1) FAIL: test-copy-acl-1.sh ======================== ../../gltests/test-copy-acl-1.sh[13]: ../../gltests/test-copy-acl.sh: No such file or directory FAIL test-copy-acl-1.sh (exit status: 1) FAIL: test-copy-acl-2.sh ======================== ../../gltests/test-copy-acl-2.sh[9]: ../../gltests/test-copy-acl.sh: No such file or directory FAIL test-copy-acl-2.sh (exit status: 1) FAIL: test-copy-file-1.sh ========================= ../../gltests/test-copy-file-1.sh[13]: ../../gltests/test-copy-file.sh: No such file or directory ../../gltests/test-copy-file-1.sh[15]: ../../gltests/test-copy-file.sh: No such file or directory FAIL test-copy-file-1.sh (exit status: 1) FAIL: test-copy-file-2.sh ========================= ../../gltests/test-copy-file-2.sh[9]: ../../gltests/test-copy-file.sh: No such file or directory ../../gltests/test-copy-file-2.sh[11]: ../../gltests/test-copy-file.sh: No such file or directory FAIL test-copy-file-2.sh (exit status: 1) FAIL: test-file-has-acl-1.sh ============================ ../../gltests/test-file-has-acl-1.sh[13]: ../../gltests/test-file-has-acl.sh: No such file or directory FAIL test-file-has-acl-1.sh (exit status: 1) FAIL: test-file-has-acl-2.sh ============================ ../../gltests/test-file-has-acl-2.sh[9]: ../../gltests/test-file-has-acl.sh: No such file or directory FAIL test-file-has-acl-2.sh (exit status: 1) FAIL: test-vc-list-files-git.sh =============================== ../../gltests/test-vc-list-files-git.sh[40]: vc-list-files: No such file or directory FAIL test-vc-list-files-git.sh (exit status: 1) The cause is the use of the hardcode file name /bin/sh as interpreter for shell scripts. On Android, it is in /system/bin/sh, and you can assume it is found in $PATH. This patch fixes it, by defining a variable BOURNE_SHELL in init.sh, and using the test framework in all places that need it. It is similar to m4/sh-filename.m4, except that this variable BOURNE_SHELL can be set to /bin/sh in 64-bit Cygwin environments (because the shell in Cygwin can access /bin/sh, only 32-bit executables cannot). 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. diff --git a/modules/acl-tests b/modules/acl-tests index 3438f14..76e2a36 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 299d49f..6b468af 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 5a26020..ff069ec 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 0d6ddee..9498d83 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 2f9880e..bb60091 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 984602d..a35c12e 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 147bf56..a0a105d 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 8998ba5..c18f5e9 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 1756f7e..d3b7f0e 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 98da280..cd2868d 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 e3ad9c0..ab13a88 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 6b92b1d..41561d6 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 26610c1..a2fa9c3 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 68c247c..7b16b37 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 d1377df..2f7c8c0 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 f0b1641..b2f12cf 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 b4c389c..9b2efef 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 . */ : ${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 b471050..15db4d0 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 . */ : ${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