Merge branch '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 : More complex interactions with "make recheck" are OK.
84 chmod a-r bar.log bar.trs
85 $MAKE recheck >stdout || { cat stdout; Exit 1; }
86 cat stdout
87 test -f bar.trs
88 test -r bar.trs
89 grep '^PASS: bar\.test' stdout
90 grep 'foo\.test' stdout && Exit 1
91 count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
92
93 : Recreate by remaking the global test log.
94 chmod a-r foo.trs
95 rm -f test-suite.log
96 $MAKE test-suite.log >stdout || { cat stdout; Exit 1; }
97 cat stdout
98 test -f foo.trs
99 test -r foo.trs
100 grep '^PASS: foo\.test' stdout
101 grep 'bar\.test' stdout && Exit 1
102 # Also test that have only run before should be counted in the final
103 # testsuite summary.
104 grep '^# TOTAL:  *2$' stdout
105
106 : Setup for the next check.
107 : > baz.test
108 sed 's/^TESTS =.*/& baz.test/' Makefile > t
109 diff t Makefile && Exit 99
110 mv -f t Makefile
111 $MAKE check
112 test -f foo.trs
113 test -f bar.trs
114 test -f baz.trs
115
116 : Interactions with lazy test reruns are OK.
117 chmod a-r foo.trs
118 $sleep
119 touch stamp
120 $sleep
121 touch bar.test
122 RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; Exit 1; }
123 cat stdout
124 test -r foo.trs
125 is_newest bar.trs bar.test
126 grep '^PASS: foo\.test' stdout
127 grep '^PASS: bar\.test' stdout
128 grep 'baz\.test' stdout && Exit 1
129 # Also test that have only run before should be counted in the final
130 # testsuite summary.
131 grep '^# TOTAL:  *3$' stdout
132
133 :