2 # Copyright (C) 2011-2024 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 <https://www.gnu.org/licenses/>.
17 # Test for a behavior 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 behavior 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 motivated in detail by coreutils bug#8846:
25 # <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846>
26 # and the following CC:ed thread on bug-autoconf list:
27 # <https://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
74 # The following hangs with Fedora 34's ksh-20120801-255:
75 # (seq --format=z%g= 121; echo "eval ': \`(set) 2>&1\`'")|env -i ksh
76 # yet terminates if it emits one fewer variable assignment.
77 # Using that ksh here would make this test hang: the above is
78 # derived from the configure script generated for this test.
79 # Reported as https://github.com/ksh93/ksh/issues/316
80 case $sh in */ksh
) skip_
"skipping $sh to avoid hang"; continue;; esac
82 test "$sh" = : && continue
84 unindent
> Makefile.am
<<END
85 TESTS = foo.test bar.test
86 ## No trailing semicolon here, *deliberately*.
87 ${pfx}TESTS_ENVIRONMENT = 8>&1 9>&8
90 CONFIG_SHELL
="$sh" $sh .
/configure CONFIG_SHELL
="$sh"
91 run_make
-O VERBOSE
=y check
92 grep '[ /]foo\.test: foofoofoo$' stdout
93 grep '[ /]foo\.test: barbarbar$' stdout
94 grep '[ /]bar\.test: 8888$' stdout
95 grep '[ /]bar\.test: 9999$' stdout
96 $EGREP '(foofoofoo|barbarbar|8888|9999)' foo.log
&& exit 1
97 : # For shells with buggy 'set -e'.