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 # Simple Tests support: redirection of file descriptors with
18 # AM_TESTS_FD_REDIRECT.
19 # See also related test 'parallel-tests-fd-redirect.test'.
23 cat >> configure.ac << 'END'
27 cat > Makefile.am <<'END'
29 AM_TESTS_FD_REDIRECT = 3<three 4>four 5>>five 7<&0 8>&1 9>&2
45 cat foo.test # For debugging.
46 echo 'this line will be removed' > four
47 echo 'this line will not be removed' > five
49 echo 'ok ok ok' | $MAKE check >stdout 2>stderr || st=1
53 test x"$am_parallel_tests" != x"yes" || cat foo.log
55 grep '[ /]foo\.test: foofoofoo$' stdout
56 grep '[ /]foo\.test: barbarbar$' stderr
57 grep 'this line' four && Exit 1
59 grep '^this line will not be removed$' five
60 grep '^ok ok ok$' five
61 $EGREP '(foofoofoo|barbarbar|3333|ok ok ok|this line)' foo.log && Exit 1
65 # Try using both shell script and a perl script as the test, for
68 cat > foo.test <<'END'
76 grep '^ok ok ok$' <&7 >&5
78 echo " " $0: foofoofoo >&8
79 echo " " $0: barbarbar >&9
84 echo "#! $PERL -w" > foo.test
85 cat >> foo.test <<'END'
86 use warnings FATAL => 'all';
89 open (FD3, "<&=3") or die "opening FD3: $!";
90 open (FD4, ">&=4") or die "opening FD4: $!";
91 open (FD5, ">&=5") or die "opening FD5: $!";
92 open (FD7, "<&=7") or die "opening FD7: $!";
93 open (FD8, ">&=8") or die "opening FD8: $!";
94 open (FD9, ">&=9") or die "opening FD9: $!";
96 chomp (my $FOO = <FD3>);
97 die "$FOO != 3333" if not $FOO eq "3333";
101 die "$_ != 'ok ok ok'" if not $_ eq 'ok ok ok';
104 print FD8 " $0: foofoofoo\n";
105 print FD9 " $0: barbarbar\n";