Merge branch 'testsuite-saner-shell' into maint
[platform/upstream/automake.git] / t / test-trs-recover2.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 harness features:
18 #  - recovery from unreadable '.trs' files, in various scenarios
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 = foo.test bar.test
29 TEST_LOG_COMPILER = true
30 END
31
32 : > foo.test
33 : > bar.test
34
35 TEST_STATUS=0; export TEST_STATUS
36
37 $ACLOCAL
38 $AUTOCONF
39 $AUTOMAKE -a
40
41 ./configure
42
43 : > t
44 chmod a-r t
45 test ! -r t || Exit 77
46 rm -f t
47
48 : Create the required log files.
49 $MAKE check
50 test -f foo.trs
51 test -f bar.trs
52
53 : Recreate with a sweeping "make check".
54 chmod a-r bar.trs
55 $MAKE check
56 test -f foo.trs
57 test -r foo.trs
58 test -f bar.trs
59 test -r bar.trs
60
61 : Again, this time with one .trs file missing and the other
62 : one unreadable.
63 rm -f foo.trs
64 chmod a-r bar.trs
65 $MAKE check
66 test -f foo.trs
67 test -r foo.trs
68 test -f bar.trs
69 test -r bar.trs
70
71 : Again, but using "make recheck" this time.
72 rm -f foo.trs
73 chmod a-r bar.trs
74 $MAKE recheck >stdout || { cat stdout; Exit 1; }
75 cat stdout
76 test -f foo.trs
77 test -r foo.trs
78 test -f bar.trs
79 test -r bar.trs
80 grep '^PASS: foo\.test' stdout
81 grep '^PASS: bar\.test' stdout
82
83 : Recreate by remaking the global test log.
84 chmod a-r foo.trs
85 rm -f test-suite.log
86 $MAKE test-suite.log >stdout || { cat stdout; Exit 1; }
87 cat stdout
88 test -f foo.trs
89 test -r foo.trs
90 grep '^PASS: foo\.test' stdout
91 grep 'bar\.test' stdout && Exit 1
92 # Also test that have only run before should be counted in the final
93 # testsuite summary.
94 grep '^# TOTAL:  *2$' stdout
95
96 : Setup for the next check.
97 : > baz.test
98 sed 's/^TESTS =.*/& baz.test/' Makefile > t
99 diff t Makefile && Exit 99
100 mv -f t Makefile
101 $MAKE check
102 test -f foo.trs
103 test -f bar.trs
104 test -f baz.trs
105
106 : Interactions with lazy test reruns are OK.
107 chmod a-r foo.trs
108 $sleep
109 touch stamp
110 $sleep
111 touch bar.test
112 RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; Exit 1; }
113 cat stdout
114 test -r foo.trs
115 is_newest bar.trs bar.test
116 grep '^PASS: foo\.test' stdout
117 grep '^PASS: bar\.test' stdout
118 grep 'baz\.test' stdout && Exit 1
119 # Also test that have only run before should be counted in the final
120 # testsuite summary.
121 grep '^# TOTAL:  *3$' stdout
122
123 :