tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / test-trs-recover.sh
blobdfed379fcd3f0ed83909d5e9d16ac45ec817493b
1 #! /bin/sh
2 # Copyright (C) 2011-2018 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check parallel harness features:
18 # - recovery from deleted '.trs' files, in various scenarios
19 # This test is complex and tricky, but that's acceptable since we are
20 # testing semantics that are potentially complex and tricky.
22 . test-init.sh
24 cat >> configure.ac <<END
25 AC_OUTPUT
26 END
28 cat > Makefile.am << 'END'
29 TESTS = foo.test bar.test baz.test
30 TEST_LOG_COMPILER = $(SHELL)
31 END
33 echo 'exit $TEST_STATUS' > foo.test
34 echo 'exit $TEST_STATUS' > bar.test
35 : > baz.test
37 TEST_STATUS=0; export TEST_STATUS
39 # Slower and possible overkill in some situations, but also clearer
40 # and safer.
41 update_stamp () { $sleep && touch stamp && $sleep; }
43 $ACLOCAL
44 $AUTOCONF
45 $AUTOMAKE -a
47 ./configure
49 : Create the required log files.
50 $MAKE check
52 : Recreate by hand.
53 rm -f foo.trs bar.trs baz.trs
54 $MAKE foo.trs
55 test -f foo.trs
56 test ! -e bar.trs
57 test ! -e baz.trs
59 : Recreate by hand, several at the same time.
60 rm -f foo.trs bar.trs baz.trs
61 $MAKE foo.trs bar.trs
62 test -f foo.trs
63 test -f bar.trs
64 test ! -e baz.trs
66 : Recreate by hand, with a failing test.
67 rm -f foo.trs bar.trs
68 run_make -O TEST_STATUS=1 bar.trs baz.trs
69 test ! -e foo.trs
70 test -f bar.trs
71 test -f baz.trs
72 grep '^FAIL: bar\.test' stdout
73 $EGREP '^(baz|foo)\.test' stdout && exit 1
75 : Recreate with a sweeping "make check", and ensure that also up-to-date
76 : '.trs' files are remade.
77 update_stamp
78 rm -f foo.trs bar.trs
79 $MAKE check
80 test -f foo.trs
81 test -f bar.trs
82 is_newest baz.trs stamp
84 : Recreate with a sweeping "make check" with failing tests. Again,
85 : ensure that also up-to-date '.trs' files are remade -- this time we
86 : grep the "make check" output verify that.
87 rm -f foo.trs bar.trs
88 run_make -O -e FAIL TEST_STATUS=1 check
89 test -f foo.trs
90 test -f bar.trs
91 grep '^FAIL: foo\.test' stdout
92 grep '^FAIL: bar\.test' stdout
93 grep '^PASS: baz\.test' stdout
95 : Recreate with a "make check" with redefined TESTS.
96 rm -f foo.trs bar.trs baz.trs
97 run_make TESTS=foo.test check
98 test -f foo.trs
99 test ! -e bar.trs
100 test ! -e baz.trs
102 : Recreate with a "make check" with redefined TEST_LOGS.
103 rm -f foo.trs bar.trs baz.trs
104 run_make TEST_LOGS=bar.log check
105 test ! -e foo.trs
106 test -f bar.trs
107 test ! -e baz.trs
109 : Interactions with "make recheck" are OK.
110 rm -f foo.trs bar.trs baz.log baz.trs
111 run_make -O recheck
112 test -f foo.trs
113 test -f bar.trs
114 test ! -e baz.trs
115 test ! -e baz.log
116 grep '^PASS: foo\.test' stdout
117 grep '^PASS: bar\.test' stdout
118 grep 'baz\.test' stdout && exit 1
119 count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
121 : Setup for the next check.
122 $MAKE check
123 test -f foo.trs
124 test -f bar.trs
125 test -f baz.trs
127 : Recreate by remaking the global test log, and ensure that up-to-date
128 : '.trs' files are *not* remade.
129 update_stamp
130 rm -f foo.trs bar.trs test-suite.log
131 run_make -O test-suite.log
132 grep '^PASS: foo\.test' stdout
133 grep '^PASS: bar\.test' stdout
134 grep 'baz\.test' stdout && exit 1
135 stat *.trs *.log stamp || : # For debugging.
136 # Check that make has updated what it needed to, but no more.
137 test -f foo.trs
138 test -f bar.trs
139 is_newest stamp baz.trs
140 is_newest test-suite.log foo.trs bar.trs
142 : Setup for the next check.
143 $MAKE check
144 test -f foo.trs
145 test -f bar.trs
146 test -f baz.trs
148 : Interactions with lazy test reruns are OK.
149 rm -f foo.trs
150 update_stamp
151 touch bar.test
152 run_make -O RECHECK_LOGS= check
153 # Check that make has updated what it needed to, but no more.
154 test -f foo.trs
155 is_newest bar.trs bar.test
156 is_newest stamp baz.trs
157 grep '^PASS: foo\.test' stdout
158 grep '^PASS: bar\.test' stdout
159 grep 'baz\.test' stdout && exit 1