2 # Copyright (C) 2011 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>
32 cat >> configure.in << 'END'
36 # Use both a shell script and a perl script as tests,
37 # for better coverage.
42 echo " " $0: foofoofoo >&8
43 echo " " $0: barbarbar >&9
46 echo "#! $PERL -w" > bar.test
47 cat >>bar.test <<'END'
48 use warnings FATAL => 'all';
50 open(FD8, ">&=8") or die "$!";
51 open(FD9, ">&=9") or die "$!";
52 print FD8 " $0: 8888\n";
53 print FD9 " $0: 9999\n";
56 chmod a+x foo.test bar.test
61 # Korn Shells seem more vulnerable to the issue highlighted in coreutils
62 # bug#8846 than other shells are. In particular, the default Korn Shell
63 # on Debian GNU/Linux is affected by the issue. So let's try to run our
64 # test with a system Korn Shell too, if that's available.
68 *) for d in /bin /usr/bin; do
69 test -f $d/ksh && { bin_ksh=$d/ksh; break; }
73 for sh in "$SHELL" "$bin_ksh"; do
74 test "$sh" = : && continue
76 unindent > Makefile.am <<END
77 TESTS = foo.test bar.test
78 ## No trailing semicolon here, *deliberately*.
79 ${pfx}TESTS_ENVIRONMENT = 8>&1 9>&8
82 CONFIG_SHELL="$sh" $sh ./configure CONFIG_SHELL="$sh"
83 VERBOSE=y $MAKE check >stdout || { cat stdout; Exit 1; }
85 grep '[ /]foo\.test: foofoofoo$' stdout
86 grep '[ /]foo\.test: barbarbar$' stdout
87 grep '[ /]bar\.test: 8888$' stdout
88 grep '[ /]bar\.test: 9999$' stdout
89 $EGREP '(foofoofoo|barbarbar|8888|9999)' foo.log && Exit 1
90 : # For shells with buggy 'set -e'.