I've rearranged things so most of the tests are run from their subdirectory, and fixed a few infelecities along the way.
>From 3c3bdf71f031660dc00d668d2cdae1761756146b Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 6 Apr 2010 09:08:03 +0200 Subject: [PATCH 1/6] tests: arrange for skip and failure notices to go to stderr, not .log * tests/init.cfg: New file. Make init.sh's stderr_fileno_ match what the "exec 9>&2" we use in TESTS_ENVIRONMENT. * Makefile.am (EXTRA_DIST): Add it. --- Makefile.am | 1 + tests/init.cfg | 5 +++++ 2 files changed, 6 insertions(+), 0 deletions(-) create mode 100644 tests/init.cfg diff --git a/Makefile.am b/Makefile.am index c7ab7f2..d331e03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,6 +120,7 @@ TESTS = \ tests/znew-k EXTRA_DIST += $(TESTS) +EXTRA_DIST += tests/init.cfg install-exec-hook: remove-installed-links install-exec-hook remove-installed-links: diff --git a/tests/init.cfg b/tests/init.cfg new file mode 100644 index 0000000..901209c --- /dev/null +++ b/tests/init.cfg @@ -0,0 +1,5 @@ +# This file is sourced by init.sh, *before* its initialization. + +# This goes hand in hand with the "exec 9>&2;" in Makefile.am's +# TESTS_ENVIRONMENT definition. +stderr_fileno_=9 -- 1.7.0.4.552.gc303 >From 2056840005242d3ea78deaff53e8492fb7a7f61f Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 6 Apr 2010 09:22:54 +0200 Subject: [PATCH 2/6] tests: skip tests that use grep's -f and -E options, if they don't work * tests/init.cfg (require_grep_minus_f): New function. * tests/zgrep-f: Use require_grep_minus_f. Use path_prepend_. --- tests/init.cfg | 15 +++++++++++++++ tests/zgrep-f | 10 +++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/init.cfg b/tests/init.cfg index 901209c..5adfc9b 100644 --- a/tests/init.cfg +++ b/tests/init.cfg @@ -3,3 +3,18 @@ # This goes hand in hand with the "exec 9>&2;" in Makefile.am's # TESTS_ENVIRONMENT definition. stderr_fileno_=9 + +require_POSIX_grep_() +{ + # Ensure that grep's -f and -E options works. + # On Solaris 5.11, "grep -f" prints this: + # grep: illegal option -- f + # Usage: grep -hblcnsviw pattern file . . . + # Similar for grep -E. + + : | grep -f /dev/null + test $? = 1 || skip_ 'your grep lacks support for -f -' + + grep -E foo /dev/null + test $? = 1 || skip_ 'your grep lacks support for -E' +} diff --git a/tests/zgrep-f b/tests/zgrep-f index 0801e8d..f64b03e 100644 --- a/tests/zgrep-f +++ b/tests/zgrep-f @@ -18,19 +18,15 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - zgrep --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/tests/init.sh"; path_prepend_ . + +require_POSIX_grep_ echo needle > n || framework_failure echo needle > haystack || framework_failure gzip haystack || framework_failure - fail=0 zgrep -f - haystack.gz < n > out 2>&1 || fail=1 -- 1.7.0.4.552.gc303 >From e8cf22cc69ebc5bf1db06f7fc0234a63cb7f1e94 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 6 Apr 2010 10:56:16 +0200 Subject: [PATCH 3/6] tests: run most tests via tests/Makefile.am * Makefile.am (SUBDIRS): List tests after ".". Move most test-related things from here to ... * tests/Makefile.am: ... here. * configure.ac (AC_CONFIG_FILES): Add tests/Makefile. * tests/helin-segv: Adjust. * tests/help-version: Likewise. * tests/hufts: Likewise. * tests/memcpy-abuse: Likewise. * tests/mixed: Likewise. * tests/null-suffix-clobber: Likewise. * tests/stdin: Likewise. * tests/trailing-nul: Likewise. * tests/zdiff: Likewise. * tests/zgrep-f: Likewise. * tests/zgrep-signal: Likewise. * tests/znew-k: Likewise. --- Makefile.am | 65 +-------------------------------- configure.ac | 2 +- tests/Makefile.am | 89 +++++++++++++++++++++++++++++++++++++++++++++ tests/helin-segv | 7 +--- tests/help-version | 2 +- tests/hufts | 9 +---- tests/memcpy-abuse | 7 +--- tests/mixed | 7 +--- tests/null-suffix-clobber | 7 +--- tests/stdin | 7 +--- tests/trailing-nul | 7 +--- tests/zdiff | 7 +--- tests/zgrep-f | 2 +- tests/zgrep-signal | 7 +--- tests/znew-k | 7 +--- 15 files changed, 105 insertions(+), 127 deletions(-) create mode 100644 tests/Makefile.am diff --git a/Makefile.am b/Makefile.am index d331e03..129c453 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ ALL_RECURSIVE_TARGETS = -SUBDIRS = lib doc +SUBDIRS = lib doc . tests ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -I$(top_srcdir)/lib AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) @@ -33,7 +33,6 @@ man_MANS = gunzip.1 gzexe.1 gzip.1 \ EXTRA_DIST = $(ACINCLUDE_INPUTS) $(man_MANS) \ ChangeLog-2007 \ dist-check.mk \ - tests/hufts-segv.gz \ algorithm.doc amiga/match.a amiga/Makefile.gcc amiga/Makefile.sasc \ amiga/tailor.c amiga/utime.h atari/Makefile.st crypt.h \ gunzip.in gzexe.in gzip.doc gzip.h lzw.h msdos/match.asm msdos/tailor.c \ @@ -46,8 +45,7 @@ EXTRA_DIST = $(ACINCLUDE_INPUTS) $(man_MANS) \ sample/ztouch sample/add.c sample/sub.c sample/zread.c sample/zfile \ tailor.h vms/Makefile.mms vms/gzip.hlp vms/vms.c vms/Readme.vms \ vms/Makefile.vms vms/Makefile.gcc vms/makegzip.com zcat.in zcmp.in zdiff.in \ - zegrep.in zfgrep.in zforce.in zgrep.in zless.in zmore.in znew.in \ - tests/init.sh + zegrep.in zfgrep.in zforce.in zgrep.in zless.in zmore.in znew.in bin_PROGRAMS = gzip bin_SCRIPTS = gunzip gzexe zcat zcmp zdiff \ @@ -105,23 +103,6 @@ check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz done @echo 'Test succeeded.' -TESTS = \ - tests/helin-segv \ - tests/help-version \ - tests/hufts \ - tests/memcpy-abuse \ - tests/mixed \ - tests/null-suffix-clobber \ - tests/stdin \ - tests/trailing-nul \ - tests/zdiff \ - tests/zgrep-f \ - tests/zgrep-signal \ - tests/znew-k - -EXTRA_DIST += $(TESTS) -EXTRA_DIST += tests/init.cfg - install-exec-hook: remove-installed-links install-exec-hook remove-installed-links: @for prog_ext in $(bin_PROGRAMS) $(bin_SCRIPTS); do \ @@ -158,45 +139,3 @@ MAINTAINERCLEANFILES = gzip.doc MOSTLYCLEANFILES = _match.i match_.s _match.S gzip.doc.gz \ gunzip gzexe zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew - -# Note that the first lines are statements. They ensure that environment -# variables that can perturb tests are unset or set to expected values. -# The rest are envvar settings that propagate build-related Makefile -# variables to test scripts. -TESTS_ENVIRONMENT = \ - tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \ - TMPDIR=$$tmp__; export TMPDIR; \ - exec 9>&2; \ - shell_or_perl_() { \ - if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then \ - if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \ - grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \ - $(PERL) -w$$T_ -I$(srcdir) -MCoreutils \ - -M"CuTmpdir qw($$f)" -- "$$1"; \ - else \ - echo 1>&2 "$$tst: configure did not find a usable version of Perl," \ - "so skipping this test"; \ - (exit 77); \ - fi; \ - else \ - $(SHELL) "$$1"; \ - fi; \ - }; \ - export \ - abs_top_builddir='$(abs_top_builddir)' \ - abs_top_srcdir='$(abs_top_srcdir)' \ - abs_srcdir='$(abs_srcdir)' \ - built_programs='$(PROGRAMS) $(SCRIPTS)' \ - srcdir='$(srcdir)' \ - top_srcdir='$(top_srcdir)' \ - CC='$(CC)' \ - MAKE=$(MAKE) \ - PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)' \ - PACKAGE_VERSION=$(PACKAGE_VERSION) \ - PERL='$(PERL)' \ - PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \ - REPLACE_GETCWD=$(REPLACE_GETCWD) \ - PATH='$(abs_top_builddir)$(PATH_SEPARATOR)'"$$PATH" \ - ; shell_or_perl_ - -VERBOSE = yes diff --git a/configure.ac b/configure.ac index 9e3d7c9..871b1ca 100644 --- a/configure.ac +++ b/configure.ac @@ -195,5 +195,5 @@ AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_OFF_T -AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile]) +AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile tests/Makefile]) AC_OUTPUT diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..59ea2f2 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,89 @@ +## Process this file with automake to create Makefile.in +# Copyright 2010 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 3, 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/>. + +TESTS = \ + helin-segv \ + help-version \ + hufts \ + memcpy-abuse \ + mixed \ + null-suffix-clobber \ + stdin \ + trailing-nul \ + zdiff \ + zgrep-f \ + zgrep-signal \ + znew-k + +EXTRA_DIST = \ + $(TESTS) \ + init.cfg \ + init.sh \ + hufts-segv.gz + +built_programs = \ + gzip \ + gunzip \ + gzexe \ + zcat \ + zcmp \ + zdiff \ + zegrep \ + zfgrep \ + zforce \ + zgrep \ + zless \ + zmore \ + znew + +TESTS_ENVIRONMENT = \ + tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \ + TMPDIR=$$tmp__; export TMPDIR; \ + exec 9>&2; \ + shell_or_perl_() { \ + if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then \ + if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \ + grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \ + $(PERL) -w$$T_ -I$(srcdir) -MCoreutils \ + -M"CuTmpdir qw($$f)" -- "$$1"; \ + else \ + echo 1>&2 "$$tst: configure did not find a usable version of Perl," \ + "so skipping this test"; \ + (exit 77); \ + fi; \ + else \ + $(SHELL) "$$1"; \ + fi; \ + }; \ + export \ + LC_ALL=C \ + abs_top_builddir='$(abs_top_builddir)' \ + abs_top_srcdir='$(abs_top_srcdir)' \ + abs_srcdir='$(abs_srcdir)' \ + built_programs='$(built_programs)' \ + srcdir='$(srcdir)' \ + top_srcdir='$(top_srcdir)' \ + CC='$(CC)' \ + GZIP_TEST_NAME=`echo $$tst|sed 's,^\./,,;s,/,-,g'` \ + MAKE=$(MAKE) \ + PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)' \ + PACKAGE_VERSION=$(PACKAGE_VERSION) \ + PERL='$(PERL)' \ + SHELL='$(SHELL)' \ + PATH='$(abs_top_builddir)$(PATH_SEPARATOR)'"$$PATH" \ + ; shell_or_perl_ + +VERBOSE = yes diff --git a/tests/helin-segv b/tests/helin-segv index 4e448a5..fa54fa0 100755 --- a/tests/helin-segv +++ b/tests/helin-segv @@ -17,13 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - gzip --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. # This test case was provided by Aki Helin. printf '\037\235\220\0\0\0\304' > helin.gz || framework_failure diff --git a/tests/help-version b/tests/help-version index ebdc69a..79f4b57 100755 --- a/tests/help-version +++ b/tests/help-version @@ -26,7 +26,7 @@ test "x$SHELL" = x && SHELL=/bin/sh export SHELL : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. expected_failure_status_chroot=125 expected_failure_status_env=125 diff --git a/tests/hufts b/tests/hufts index 73e74de..5a70a2a 100755 --- a/tests/hufts +++ b/tests/hufts @@ -17,19 +17,14 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - zgrep --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. printf '\n...: invalid compressed data--format violated\n' > exp \ || framework_failure fail=0 -gzip -dc "$abs_srcdir/tests/hufts-segv.gz" > out 2> err +gzip -dc "$abs_srcdir/hufts-segv.gz" > out 2> err test $? = 1 || fail=1 compare /dev/null out || fail=1 diff --git a/tests/memcpy-abuse b/tests/memcpy-abuse index 95bc8ca..912c3bb 100755 --- a/tests/memcpy-abuse +++ b/tests/memcpy-abuse @@ -18,13 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - gzip --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. # The input must be larger than 32KiB and slightly # less uniform than e.g., all zeros. diff --git a/tests/mixed b/tests/mixed index 65898a1..7595ca3 100644 --- a/tests/mixed +++ b/tests/mixed @@ -18,13 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - zgrep --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. printf 'xxx\nyyy\n' > exp2 || framework_failure printf 'aaa\nbbb\nccc\n' > exp3 || framework_failure diff --git a/tests/null-suffix-clobber b/tests/null-suffix-clobber index e5b52a1..da4fc0f 100755 --- a/tests/null-suffix-clobber +++ b/tests/null-suffix-clobber @@ -17,13 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - gzip --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. printf anything | gzip > F.gz || framework_failure echo y > yes || framework_failure diff --git a/tests/stdin b/tests/stdin index 8dcfa68..ee52a33 100755 --- a/tests/stdin +++ b/tests/stdin @@ -17,13 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - zgrep --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. printf a | gzip > in || framework_failure printf aaa > exp || framework_failure diff --git a/tests/trailing-nul b/tests/trailing-nul index 8106c29..8a5ab07 100755 --- a/tests/trailing-nul +++ b/tests/trailing-nul @@ -18,13 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - gzip --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. (echo 0 | gzip; printf '\0') > 0.gz || framework_failure (echo 00 | gzip; printf '\0\0') > 00.gz || framework_failure diff --git a/tests/zdiff b/tests/zdiff index 151d00d..5a8b15a 100755 --- a/tests/zdiff +++ b/tests/zdiff @@ -18,13 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - zdiff --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. echo a > a || framework_failure echo b > b || framework_failure diff --git a/tests/zgrep-f b/tests/zgrep-f index f64b03e..87b9577 100644 --- a/tests/zgrep-f +++ b/tests/zgrep-f @@ -19,7 +19,7 @@ # limit so don't run it by default. : ${srcdir=.} -. "$srcdir/tests/init.sh"; path_prepend_ . +. "$srcdir/init.sh"; path_prepend_ .. require_POSIX_grep_ diff --git a/tests/zgrep-signal b/tests/zgrep-signal index 4acd737..2454423 100644 --- a/tests/zgrep-signal +++ b/tests/zgrep-signal @@ -18,13 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - gzip --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/init.sh"; path_prepend_ .. echo a | gzip -c > f.gz || framework_failure diff --git a/tests/znew-k b/tests/znew-k index d63ec26..d49b971 100644 --- a/tests/znew-k +++ b/tests/znew-k @@ -17,13 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - gzip --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh"; path_prepend_ "`pwd`" +. "$srcdir/init.sh"; path_prepend_ .. cat <<'EOF' >compress || framework_failure #!/bin/sh -- 1.7.0.4.552.gc303 >From 9e0267c54de6c488a3e7685c3cfef52a49989366 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 6 Apr 2010 11:36:52 +0200 Subject: [PATCH 4/6] tests: update init.sh from gnulib * tests/init.sh: Update from gnulib. --- tests/init.sh | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 104 insertions(+), 4 deletions(-) diff --git a/tests/init.sh b/tests/init.sh index 979eb3c..9b65129 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -52,6 +52,43 @@ # 4. Finally # $ exit +# We require $(...) support unconditionally. +# We require a few additional shell features only when $EXEEXT is nonempty, +# in order to support automatic $EXEEXT emulation: +# - hyphen-containing alias names +# - we prefer to use ${var#...} substitution, rather than having +# to work around lack of support for that feature. +# The following code attempts to find a shell with support for these features +# and re-exec's it. If not, it skips the current test. + +gl_shell_test_script_=' +test $(echo y) = y || exit 1 +test -z "$EXEEXT" && exit 0 +shopt -s expand_aliases +alias a-b="echo zoo" +v=abx + test ${v%x} = ab \ + && test ${v#a} = bx \ + && test $(a-b) = zoo +' + +if test "x$1" = "x--no-reexec"; then + shift +else + for re_shell_ in "${CONFIG_SHELL:-no_shell}" /bin/sh bash dash zsh pdksh fail + do + test "$re_shell_" = no_shell && continue + test "$re_shell_" = fail && skip_ failed to find an adequate shell + if "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null; then + exec "$re_shell_" "$0" --no-reexec "$@" + echo "$ME_: exec failed" 1>&2 + exit 127 + fi + done +fi + +test -n "$EXEEXT" && shopt -s expand_aliases + # We use a trap below for cleanup. This requires us to go through # hoops to get the right exit status transported through the handler. # So use `Exit STATUS' instead of `exit STATUS' inside of the tests. @@ -59,8 +96,18 @@ # sh inside this function. Exit () { set +e; (exit $1); exit $1; } -fail_() { echo "$ME_: failed test: $@" 1>&2; Exit 1; } -skip_() { echo "$ME_: skipped test: $@" 1>&2; Exit 77; } +# Print warnings (e.g., about skipped and failed tests) to this file number. +# Override by defining to say, 9, in init.cfg, and putting say, +# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition +# of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# This is useful when using automake's parallel tests mode, to print +# the reason for skip/failure to console, rather than to the .log files. +: ${stderr_fileno_=2} + +warn_() { echo "$@" 1>&$stderr_fileno_; } +fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } +skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } +framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 1; } # This is a stub function that is run upon trap (upon regular exit and # interrupt). Override it with a per-test function, e.g., to unmount @@ -92,8 +139,57 @@ remove_tmp_() exit $__st } +# Given a directory name, DIR, if every entry in it that matches *.exe +# contains only the specified bytes (see the case stmt below), then print +# a space-separated list of those names and return 0. Otherwise, don't +# print anything and return 1. Naming constraints apply also to DIR. +find_exe_basenames_() +{ + feb_dir_=$1 + feb_fail_=0 + feb_result_= + feb_sp_= + for feb_file_ in $feb_dir_/*.exe; do + case $feb_file_ in + *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;; + *) # Remove leading file name components as well as the .exe suffix. + feb_file_=${feb_file_##*/} + feb_file_=${feb_file_%.exe} + feb_result_="$feb_result_$feb_sp_$feb_file_";; + esac + feb_sp_=' ' + done + test $feb_fail_ = 0 && printf %s "$feb_result_" + return $feb_fail_ +} + +# Consider the files in directory, $1. +# For each file name of the form PROG.exe, create an alias named +# PROG that simply invokes PROG.exe, then return 0. If any selected +# file name or the directory name, $1, contains an unexpected character, +# define no function and return 1. +create_exe_shims_() +{ + case $EXEEXT in + '') return 0 ;; + .exe) ;; + *) echo "$0: unexpected \$EXEEXT value: $EXEEXT" 1>&2; return 1 ;; + esac + + base_names_=`find_exe_basenames_ $1` \ + || { echo "$0 (exe_shim): skipping directory: $1" 1>&2; return 1; } + + if test -n "$base_names_"; then + for base_ in $base_names_; do + alias "$base_"="$base_$EXEEXT" + done + fi + + return 0 +} + # Use this function to prepend to PATH an absolute name for each -# specified, possibly-$initial_cwd_relative, directory. +# specified, possibly-$initial_cwd_-relative, directory. path_prepend_() { while test $# != 0; do @@ -108,6 +204,10 @@ path_prepend_() *:*) fail_ "invalid path dir: '$abs_path_dir_'";; esac PATH="$abs_path_dir_:$PATH" + + # Create an alias, FOO, for each FOO.exe in this directory. + create_exe_shims_ "$abs_path_dir_" \ + || fail_ "something failed (above): $abs_path_dir_" shift done export PATH @@ -206,7 +306,7 @@ mktempd_() fail=0 # First, try to use mktemp. - d=`env -u TMPDIR mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \ + d=`env -i PATH="$PATH" mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \ || fail=1 # The resulting name must be in the specified directory. -- 1.7.0.4.552.gc303 >From a4d1e8b8b20507501b38fc8f624932067fbb15c3 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 6 Apr 2010 11:38:29 +0200 Subject: [PATCH 5/6] tests: s/framework_failure/framework_failure_/ --- tests/helin-segv | 4 ++-- tests/hufts | 2 +- tests/memcpy-abuse | 2 +- tests/mixed | 4 ++-- tests/null-suffix-clobber | 6 +++--- tests/stdin | 4 ++-- tests/trailing-nul | 6 +++--- tests/zdiff | 6 +++--- tests/zgrep-f | 6 +++--- tests/zgrep-signal | 4 ++-- tests/znew-k | 6 +++--- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/helin-segv b/tests/helin-segv index fa54fa0..d0f8567 100755 --- a/tests/helin-segv +++ b/tests/helin-segv @@ -21,8 +21,8 @@ . "$srcdir/init.sh"; path_prepend_ .. # This test case was provided by Aki Helin. -printf '\037\235\220\0\0\0\304' > helin.gz || framework_failure -printf '\0\0' > exp || framework_failure +printf '\037\235\220\0\0\0\304' > helin.gz || framework_failure_ +printf '\0\0' > exp || framework_failure_ fail=0 diff --git a/tests/hufts b/tests/hufts index 5a70a2a..dc895af 100755 --- a/tests/hufts +++ b/tests/hufts @@ -21,7 +21,7 @@ . "$srcdir/init.sh"; path_prepend_ .. printf '\n...: invalid compressed data--format violated\n' > exp \ - || framework_failure + || framework_failure_ fail=0 gzip -dc "$abs_srcdir/hufts-segv.gz" > out 2> err diff --git a/tests/memcpy-abuse b/tests/memcpy-abuse index 912c3bb..5d2256a 100755 --- a/tests/memcpy-abuse +++ b/tests/memcpy-abuse @@ -23,7 +23,7 @@ # The input must be larger than 32KiB and slightly # less uniform than e.g., all zeros. -printf wxy%032767d 0 | tee in | gzip > in.gz || framework_failure +printf wxy%032767d 0 | tee in | gzip > in.gz || framework_failure_ fail=0 diff --git a/tests/mixed b/tests/mixed index 7595ca3..c3775c8 100644 --- a/tests/mixed +++ b/tests/mixed @@ -21,8 +21,8 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -printf 'xxx\nyyy\n' > exp2 || framework_failure -printf 'aaa\nbbb\nccc\n' > exp3 || framework_failure +printf 'xxx\nyyy\n' > exp2 || framework_failure_ +printf 'aaa\nbbb\nccc\n' > exp3 || framework_failure_ fail=0 diff --git a/tests/null-suffix-clobber b/tests/null-suffix-clobber index da4fc0f..36cd9b4 100755 --- a/tests/null-suffix-clobber +++ b/tests/null-suffix-clobber @@ -20,9 +20,9 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -printf anything | gzip > F.gz || framework_failure -echo y > yes || framework_failure -echo "gzip: invalid suffix ''" > expected-err || framework_failure +printf anything | gzip > F.gz || framework_failure_ +echo y > yes || framework_failure_ +echo "gzip: invalid suffix ''" > expected-err || framework_failure_ fail=0 diff --git a/tests/stdin b/tests/stdin index ee52a33..c7459c6 100755 --- a/tests/stdin +++ b/tests/stdin @@ -20,8 +20,8 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -printf a | gzip > in || framework_failure -printf aaa > exp || framework_failure +printf a | gzip > in || framework_failure_ +printf aaa > exp || framework_failure_ fail=0 gzip -dc in - in < in > out 2>err || fail=1 diff --git a/tests/trailing-nul b/tests/trailing-nul index 8a5ab07..63bae48 100755 --- a/tests/trailing-nul +++ b/tests/trailing-nul @@ -21,9 +21,9 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -(echo 0 | gzip; printf '\0') > 0.gz || framework_failure -(echo 00 | gzip; printf '\0\0') > 00.gz || framework_failure -(echo 1 | gzip; printf '\1') > 1.gz || framework_failure +(echo 0 | gzip; printf '\0') > 0.gz || framework_failure_ +(echo 00 | gzip; printf '\0\0') > 00.gz || framework_failure_ +(echo 1 | gzip; printf '\1') > 1.gz || framework_failure_ fail=0 diff --git a/tests/zdiff b/tests/zdiff index 5a8b15a..505b93f 100755 --- a/tests/zdiff +++ b/tests/zdiff @@ -21,9 +21,9 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -echo a > a || framework_failure -echo b > b || framework_failure -gzip a b || framework_failure +echo a > a || framework_failure_ +echo b > b || framework_failure_ +gzip a b || framework_failure_ cat <<EOF > exp 1c1 diff --git a/tests/zgrep-f b/tests/zgrep-f index 87b9577..cf4b602 100644 --- a/tests/zgrep-f +++ b/tests/zgrep-f @@ -23,9 +23,9 @@ require_POSIX_grep_ -echo needle > n || framework_failure -echo needle > haystack || framework_failure -gzip haystack || framework_failure +echo needle > n || framework_failure_ +echo needle > haystack || framework_failure_ +gzip haystack || framework_failure_ fail=0 zgrep -f - haystack.gz < n > out 2>&1 || fail=1 diff --git a/tests/zgrep-signal b/tests/zgrep-signal index 2454423..1b96237 100644 --- a/tests/zgrep-signal +++ b/tests/zgrep-signal @@ -21,12 +21,12 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -echo a | gzip -c > f.gz || framework_failure +echo a | gzip -c > f.gz || framework_failure_ fail=0 status=$(exec 3>&1; (zgrep a f.gz f.gz; echo $? >&3) | :) || - framework_failure + framework_failure_ test "$status" = 141 || fail=1 diff --git a/tests/znew-k b/tests/znew-k index d49b971..e7ca443 100644 --- a/tests/znew-k +++ b/tests/znew-k @@ -20,18 +20,18 @@ : ${srcdir=.} . "$srcdir/init.sh"; path_prepend_ .. -cat <<'EOF' >compress || framework_failure +cat <<'EOF' >compress || framework_failure_ #!/bin/sh echo >&2 'compress has been invoked' exit 1 EOF -chmod +x compress || framework_failure +chmod +x compress || framework_failure_ # Note that the basename must have a length of 6 or greater. # Otherwise, "test -f $name" below would fail. name=123456.Z -printf '%1012977s' ' ' | gzip -c > $name || framework_failure +printf '%1012977s' ' ' | gzip -c > $name || framework_failure_ fail=0 -- 1.7.0.4.552.gc303 >From 6e50a6d29c84b11ce65294b7fd8b96b9ee1764b7 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 6 Apr 2010 18:19:42 +0200 Subject: [PATCH 6/6] tests: (portability) use st, not "status" as variable name * tests/zgrep-signal: Do not use status as a variable name, per autoconf's documentation that it is not portable to some shells. --- tests/zgrep-signal | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/zgrep-signal b/tests/zgrep-signal index 1b96237..d861a01 100644 --- a/tests/zgrep-signal +++ b/tests/zgrep-signal @@ -25,9 +25,8 @@ echo a | gzip -c > f.gz || framework_failure_ fail=0 -status=$(exec 3>&1; (zgrep a f.gz f.gz; echo $? >&3) | :) || - framework_failure_ +st=$(exec 3>&1; (zgrep a f.gz f.gz; echo $? >&3) | :) || framework_failure_ -test "$status" = 141 || fail=1 +test "$st" = 141 || fail=1 Exit $fail -- 1.7.0.4.552.gc303