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