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