Merge branch 'maint'
[platform/upstream/automake.git] / t / parallel-tests-log-override-recheck.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 # Check parallel-tests features: runtime redefinition of $(TEST_SUITE_LOG)
18 # for the recheck target.
19
20 . test-init.sh
21
22 cat >> configure.ac <<'END'
23 AC_OUTPUT
24 END
25
26 cat > Makefile.am <<'END'
27 TESTS = foofoo.test barbar.test bazbaz.test
28 END
29
30 cat > foofoo.test <<'END'
31 #! /bin/sh
32 echo "this is $0"
33 exit 0
34 END
35
36 cat > barbar.test <<'END'
37 #! /bin/sh
38 echo "this is $0"
39 exit 99
40 END
41
42 cat > bazbaz.test <<'END'
43 #! /bin/sh
44 echo "this is $0"
45 exit ${BAZ_EXIT_STATUS-1}
46 END
47
48 chmod a+x *.test
49
50 unset BAZ_EXIT_STATUS || :
51
52 $ACLOCAL
53 $AUTOCONF
54 $AUTOMAKE -a
55
56 # Filter make output before grepping it, for make implementations that,
57 # like Solaris' one, print the whole of the failed recipe on failure.
58 filter_stdout ()
59 {
60   grep -v 'bases=.*;' stdout > t && mv -f t stdout
61 }
62
63 ./configure
64 $MAKE check >stdout && { cat stdout; exit 1; }
65 cat stdout
66
67 using_gmake || $sleep # Required by BSD make.
68
69 chmod a-rw test-suite.log
70 TEST_SUITE_LOG=my.log $MAKE -e recheck >stdout \
71   && { cat stdout; exit 1; }
72 cat stdout
73 ls -l
74 filter_stdout
75 count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1
76 for x in stdout my.log; do
77   $FGREP foofoo $x && exit 1
78   $FGREP barbar $x
79   $FGREP bazbaz $x
80 done
81
82 using_gmake || $sleep # Required by BSD make.
83
84 chmod a-rw my.log
85 BAZ_EXIT_STATUS=0 TEST_SUITE_LOG=my2.log $MAKE -e recheck >stdout \
86   && { cat stdout; exit 1; }
87 cat stdout
88 ls -l
89 count_test_results total=2 pass=1 fail=0 skip=0 xfail=0 xpass=0 error=1
90 filter_stdout
91 $FGREP foofoo stdout && exit 1
92 $FGREP barbar stdout
93 $FGREP bazbaz stdout
94 $FGREP foofoo my2.log && exit 1
95 $FGREP barbar my2.log
96 $FGREP bazbaz my2.log && exit 1
97
98 chmod u+r test-suite.log my.log
99 $FGREP bazbaz test-suite.log
100 $FGREP bazbaz my.log
101
102 :