Merge branch 'rmch'
[platform/upstream/automake.git] / t / parallel-tests-fd-redirect.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
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)
7 # any later version.
8 #
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.
13 #
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/>.
16
17 # parallel-tests support: redirection of file descriptors with
18 # AM_TESTS_FD_REDIRECT, even when using tests without suffix.
19 # The sister 'parallel-tests-fd-redirect-exeext.test' do a similar
20 # check for tests that are binary executables.
21 # See also the more generic test 'check-fd-redirect.test'.
22
23 am_parallel_tests=yes
24 . ./defs || Exit 1
25
26 cat >> configure.ac << 'END'
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 AM_TESTS_FD_REDIRECT = 9>&1
32 TEST_EXTENSIONS = .test .sh
33 TESTS = foo.sh bar
34 END
35
36 $ACLOCAL
37 $AUTOCONF
38 $AUTOMAKE -a
39
40 cat > foo.sh <<'END'
41 #!/bin/sh
42 echo " foofoofoo" >&9
43 END
44 chmod a+x foo.sh
45
46 cat > bar <<'END'
47 #!/bin/sh
48 echo " barbarbar" >&9
49 END
50
51 chmod a+x foo.sh bar
52
53 ./configure
54
55 # Sanity checks.
56 st=0
57 grep '^bar\.log:.*bar' Makefile || st=1
58 grep '^foo\.log:' Makefile && st=1
59 test $st -eq 0 || fatal_ "doesn't cover expected code paths"
60
61 st=0; $MAKE check >stdout || st=1
62 cat stdout
63 cat foo.log
64 cat bar.log
65 test $st -eq 0
66 grep "^ foofoofoo$" stdout
67 grep "^ barbarbar$" stdout
68 $EGREP '(foofoofoo|barbarbar)' *.log && Exit 1
69
70 :