automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {testsuite-work} tests: fix spurious failures in self tests


From: Stefano Lattarini
Subject: [FYI] {testsuite-work} tests: fix spurious failures in self tests
Date: Wed, 1 Jun 2011 16:39:47 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Our ad-hoc usage of `tests/defs' in the testsuite's self tests
stopped working properly when we made the test scripts re-execute
themselves with the configure-time $SHELL.  Fix this.

Fixes a bug introduced by commit 'v1.11-874-g1321be7'.

* tests/defs: Only check that we can find the client test script
when we must re-execute it.
* tests/self-check-cleanup.test: Export `AM_TESTS_REEXEC' to "no"
before running the self tests.
* tests/self-check-dir.test: Likewise.
* tests/self-check-explicit-skips.test: Likewise.
* tests/self-check-me.test: Likewise.
* tests/self-check-sanity.test: Likewise.
* tests/self-check-reexec.test: New test.
* tests/Makefile.am (TESTS): Update.
---
 ChangeLog                            |   18 +++++
 tests/Makefile.am                    |    1 +
 tests/Makefile.in                    |    1 +
 tests/defs                           |   11 ++--
 tests/self-check-cleanup.test        |    2 +
 tests/self-check-dir.test            |    2 +
 tests/self-check-explicit-skips.test |    1 +
 tests/self-check-me.test             |    2 +
 tests/self-check-reexec.test         |  116 ++++++++++++++++++++++++++++++++++
 tests/self-check-sanity.test         |    2 +
 10 files changed, 150 insertions(+), 6 deletions(-)
 create mode 100755 tests/self-check-reexec.test

diff --git a/ChangeLog b/ChangeLog
index 64c8892..7100f28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2011-06-01  Stefano Lattarini  <address@hidden>
 
+       tests: fix spurious failures in self tests
+       Our ad-hoc usage of `tests/defs' in the testsuite's self tests
+       stopped working properly when we made the test scripts re-execute
+       themselves with the configure-time $SHELL.  Fix this.
+       Fixes a bug introduced by commit 'v1.11-874-g1321be7'.
+       * tests/defs: Only check that we can find the client test script
+       when we must re-execute it.
+       * tests/self-check-cleanup.test: Export `AM_TESTS_REEXEC' to "no"
+       before running the self tests.
+       * tests/self-check-dir.test: Likewise.
+       * tests/self-check-explicit-skips.test: Likewise.
+       * tests/self-check-me.test: Likewise.
+       * tests/self-check-sanity.test: Likewise.
+       * tests/self-check-reexec.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
        tests: prefer ulimit over timeout in test on a memory-hogging bug
        * tests/cond29.test: Use 'ulimit' instead of 'timeout' to ensure
        that automake does not uses up too much resources.  This is really
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a7958d7..0bb993a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -848,6 +848,7 @@ self-check-exit.test \
 self-check-explicit-skips.test \
 self-check-is_newest.test \
 self-check-me.test \
+self-check-reexec.test \
 self-check-report.test \
 self-check-sanity.test \
 self-check-unindent.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 4279eea..875b06e 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1136,6 +1136,7 @@ self-check-exit.test \
 self-check-explicit-skips.test \
 self-check-is_newest.test \
 self-check-me.test \
+self-check-reexec.test \
 self-check-report.test \
 self-check-sanity.test \
 self-check-unindent.test \
diff --git a/tests/defs b/tests/defs
index 5494625..1f3210c 100644
--- a/tests/defs
+++ b/tests/defs
@@ -76,12 +76,6 @@ test -f "$testbuilddir/defs-static" || {
    exit 99
 }
 
-# Ensure we can find ourselves.
-test -f "$0" || {
-   echo "$me: unable to find myself: $0" >&2
-   exit 1
-}
-
 
 ## ------------------------------------ ##
 ##  Ensure we run with a proper shell.  ##
@@ -93,6 +87,11 @@ case ${AM_TESTS_REEXEC-yes} in
   n|no|false|0)
     ;;
   *)
+    # Ensure we can find ourselves.
+    if test ! -f "$0"; then
+      echo "$me: unable to find myself: $0" >&2
+      exit 99
+    fi
     AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
     # Cannot simply do `opts=$-', since the content of $- is not
     # portable among different shells.  So try to propagate only
diff --git a/tests/self-check-cleanup.test b/tests/self-check-cleanup.test
index 17859e9..f9a8658 100755
--- a/tests/self-check-cleanup.test
+++ b/tests/self-check-cleanup.test
@@ -30,6 +30,8 @@ sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static 
>defs-static
 diff ../defs-static defs-static && Exit 99
 cp ../defs .
 
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
 have_symlinks=false
 ln -s defs foo && have_symlinks=:
 export have_symlinks # Is used also by spawned shells.
diff --git a/tests/self-check-dir.test b/tests/self-check-dir.test
index ba9fd29..0b4dd4e 100755
--- a/tests/self-check-dir.test
+++ b/tests/self-check-dir.test
@@ -22,6 +22,8 @@
 
 set -ex
 
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
 this=S_dir
 outcome=:
 pwd
diff --git a/tests/self-check-explicit-skips.test 
b/tests/self-check-explicit-skips.test
index 15bf2d9..d24e0ef 100755
--- a/tests/self-check-explicit-skips.test
+++ b/tests/self-check-explicit-skips.test
@@ -30,6 +30,7 @@ cp ../defs .
 set +e
 
 unset am_explicit_skips stderr_fileno_
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
 
 $SHELL -c '. ./defs; (exit 77); exit 77' dummy.test
 test $? -eq 77 || Exit 1
diff --git a/tests/self-check-me.test b/tests/self-check-me.test
index 141857f..8fd2bc0 100755
--- a/tests/self-check-me.test
+++ b/tests/self-check-me.test
@@ -21,6 +21,8 @@
 
 set -ex
 
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
 $SHELL -c '. ./defs && echo me=$me' foo-bar-.test | grep '^me=foo-bar-$'
 $SHELL -c '. ./defs && echo me=$me' _foo__bar.test | grep '^me=_foo__bar$'
 $SHELL -c '. ./defs && echo me=$me' 012.test | grep '^me=012$'
diff --git a/tests/self-check-reexec.test b/tests/self-check-reexec.test
new file mode 100755
index 0000000..a35c143
--- /dev/null
+++ b/tests/self-check-reexec.test
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check that automatic re-execution of test script with the
+# configure-time $SHELL.
+
+. ./defs || Exit 1
+
+# This is not optimal, but it's much better than writing wrapper
+# scripts acting as "fake" shells.
+sh -c ': ${.sh.version}' \
+  && skip_ "sh is a Korn Shell"
+ksh -c 'test -n "${.sh.version}"' || \
+  skip_ "ksh is not a fully-fledged Korn Shell"
+
+cwd=`pwd` || Exit 99
+
+cp ../defs .
+unset AM_TESTS_REEXEC || :
+
+#
+# Check how to default, force or prevent a re-execution.
+#
+
+cat > run-with-ksh.test <<'END'
+#!/bin/false
+. ./defs
+# Subshell required to prevent some shells (e.g., older bash) from
+# only complaining on stderr but then exiting with exit status 0.
+(test -n "${.sh.version}" && echo ${.sh.version})
+END
+
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd'|" \
+    -e 's|^SHELL=.*$|SHELL=ksh; export SHELL|' \
+    < ../defs-static >defs-static
+
+sh -x run-with-ksh.test
+
+AM_TESTS_REEXEC=''    sh run-with-ksh.test
+AM_TESTS_REEXEC=yes   sh run-with-ksh.test
+AM_TESTS_REEXEC=y     sh run-with-ksh.test
+AM_TESTS_REEXEC=true  sh run-with-ksh.test
+AM_TESTS_REEXEC=1     sh run-with-ksh.test
+AM_TESTS_REEXEC=no    sh run-with-ksh.test && Exit 1
+AM_TESTS_REEXEC=n     sh run-with-ksh.test && Exit 1
+AM_TESTS_REEXEC=false sh run-with-ksh.test && Exit 1
+AM_TESTS_REEXEC=0     sh run-with-ksh.test && Exit 1
+
+#
+# Check message about the re-execution.
+#
+
+cat > dummy.test <<'END'
+#!/bin/sh
+. ./defs
+:
+END
+chmod a+x dummy.test
+
+mkdir sub
+cp dummy.test defs sub
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd'|" \
+    < ../defs-static > defs-static
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd/sub'|" \
+    < ../defs-static > sub/defs-static
+
+./dummy.test a b | grep "^dummy: exec $SHELL \\./dummy\\.test a b$"
+
+for am_sh in sh ksh; do
+  $am_sh dummy.test a b c \
+    | grep "^dummy: exec $SHELL dummy\\.test a b c$"
+  $am_sh ./dummy.test a b c \
+    | grep "^dummy: exec $SHELL \\./dummy\\.test a b c$"
+  cd sub
+  $am_sh ../dummy.test a b \
+    | grep "dummy: exec $SHELL \\.\\./dummy\\.test a b$"
+  cd ..
+  $am_sh "$cwd/dummy.test" a -b c- \
+    | grep "^dummy: exec $SHELL $cwd/dummy\\.test a -b c-$"
+  $am_sh sub/dummy.test 1 2 3 4 \
+    | grep "^dummy: exec $SHELL sub/dummy\\.test 1 2 3 4$"
+done
+
+#
+# Check that arguments passed to a test script are preserved by a re-exec.
+#
+
+cat > checkargs.test <<'END'
+. ./defs
+test $# -eq 3 && test x"$1" = x'a' && test x"$2" = x && test x"$3" = x"-e"
+END
+
+$SHELL checkargs.test a '' -e
+$SHELL ./checkargs.test a '' -e
+$SHELL "$cwd/checkargs.test" a '' -e
+cd sub
+$SHELL ../checkargs.test a '' -e
+cd ..
+cp checkargs.test sub
+$SHELL sub/checkargs.test a '' -e
+
+:
diff --git a/tests/self-check-sanity.test b/tests/self-check-sanity.test
index d35432f..3e60a68 100755
--- a/tests/self-check-sanity.test
+++ b/tests/self-check-sanity.test
@@ -27,6 +27,8 @@ show_stderr ()
   sed 's/^/ | /' stderr >&2
 }
 
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
 if $SHELL -c '. ../defs' dummy.test 2>stderr; then
   show_stderr
   Exit 1
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]