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'.
21 # For gen-testsuite-part: ==> try-with-serial-tests <==
24 cat >> configure.ac << 'END'
28 cat > Makefile.am <<'END'
30 AM_TESTS_FD_REDIRECT = 3<three 4>four 5>>five 7<&0 8>&1 9>&2
46 cat foo.test # For debugging.
47 echo 'this line will be removed' > four
48 echo 'this line will not be removed' > five
50 echo 'ok ok ok' | $MAKE check >stdout 2>stderr || st=1
54 test x"$am_serial_tests" = x"yes" || cat foo.log
56 grep '[ /]foo\.test: foofoofoo$' stdout
57 grep '[ /]foo\.test: barbarbar$' stderr
58 grep 'this line' four && Exit 1
60 grep '^this line will not be removed$' five
61 grep '^ok ok ok$' five
62 $EGREP '(foofoofoo|barbarbar|3333|ok ok ok|this line)' foo.log && Exit 1
66 # Try using both shell script and a perl script as the test, for
69 cat > foo.test <<'END'
77 grep '^ok ok ok$' <&7 >&5
79 echo " " $0: foofoofoo >&8
80 echo " " $0: barbarbar >&9
85 echo "#! $PERL -w" > foo.test
86 cat >> foo.test <<'END'
87 use warnings FATAL => 'all';
90 open (FD3, "<&=3") or die "opening FD3: $!";
91 open (FD4, ">&=4") or die "opening FD4: $!";
92 open (FD5, ">&=5") or die "opening FD5: $!";
93 open (FD7, "<&=7") or die "opening FD7: $!";
94 open (FD8, ">&=8") or die "opening FD8: $!";
95 open (FD9, ">&=9") or die "opening FD9: $!";
97 chomp (my $FOO = <FD3>);
98 die "$FOO != 3333" if not $FOO eq "3333";
102 die "$_ != 'ok ok ok'" if not $_ eq 'ok ok ok';
105 print FD8 " $0: foofoofoo\n";
106 print FD9 " $0: barbarbar\n";