2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Test for a behaviour of 'TESTS_ENVIRONMENT' and 'AM_TESTS_ENVIRONMENT'
18 # w.r.t. file descriptor redirections which, although undocumented,
19 # is nonetheless required by Gnulib's 'tests/init.sh' and by coreutils'
21 # The checked behaviour is that we can portably do file descriptor
22 # redirections by placing them at the end of a {AM_,}TESTS_ENVIRONMENT
23 # definition without a following semicolon. The need to support this
24 # is detailedly motivated by coreutils bug#8846:
25 # <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846>
26 # and the following CC:ed thread on bug-autoconf list:
27 # <http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00002.html>
31 cat >> configure.ac << 'END'
35 # Use both a shell script and a perl script as tests,
36 # for better coverage.
41 echo " " $0: foofoofoo >&8
42 echo " " $0: barbarbar >&9
45 echo "#! $PERL -w" > bar.test
46 cat >>bar.test <<'END'
47 use warnings FATAL => 'all';
49 open(FD8, ">&=8") or die "$!";
50 open(FD9, ">&=9") or die "$!";
51 print FD8 " $0: 8888\n";
52 print FD9 " $0: 9999\n";
55 chmod a+x foo.test bar.test
60 # Korn Shells seem more vulnerable to the issue highlighted in coreutils
61 # bug#8846 than other shells are. In particular, the default Korn Shell
62 # on Debian GNU/Linux is affected by the issue. So let's try to run our
63 # test with a system Korn Shell too, if that's available.
67 *) for d in /bin /usr/bin; do
68 test -f $d/ksh && { bin_ksh=$d/ksh; break; }
72 for sh in "$SHELL" "$bin_ksh"; do
73 test "$sh" = : && continue
75 unindent > Makefile.am <<END
76 TESTS = foo.test bar.test
77 ## No trailing semicolon here, *deliberately*.
78 ${pfx}TESTS_ENVIRONMENT = 8>&1 9>&8
81 CONFIG_SHELL="$sh" $sh ./configure CONFIG_SHELL="$sh"
82 VERBOSE=y $MAKE check >stdout || { cat stdout; Exit 1; }
84 grep '[ /]foo\.test: foofoofoo$' stdout
85 grep '[ /]foo\.test: barbarbar$' stdout
86 grep '[ /]bar\.test: 8888$' stdout
87 grep '[ /]bar\.test: 9999$' stdout
88 $EGREP '(foofoofoo|barbarbar|8888|9999)' foo.log && Exit 1
89 : # For shells with buggy 'set -e'.