test: check that subsecond mtime works with make.
[automake.git] / t / perf / testsuite-recheck.sh
blob3f858c6bf63bd37aefdc4930ba59707b7f0caf49
1 #! /bin/sh
2 # Copyright (C) 2012-2024 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 performance of recheck target in the face of many failed tests.
18 # FIXME: this test is not currently able to detect whether the measured
19 # FIXME: performance is too low, and FAIL accordingly; it just offers an
20 # FIXME: easy way to verify how effective a performance optimization is.
22 . test-init.sh
24 count=5000
26 cat >> configure.ac <<'END'
27 AC_OUTPUT
28 END
30 cat > Makefile.am <<END
31 count_expected = $count
32 TEST_EXTENSIONS = .t
33 ## Updated later.
34 TESTS =
35 END
37 # This should ensure that our timing won't be disturbed by the time
38 # that would be actually required to run any of:
39 # - the test cases
40 # - the test driver executing them
41 # - the recipe to create the final test-suite log.
42 cat >> Makefile.am << 'END'
43 AUTOMAKE_OPTIONS = -Wno-override
44 ## These should never be run.
45 T_LOG_COMPILER = false
46 T_LOG_DRIVER = false
48 # The recipe of this also serves as a sanity check.
49 $(TEST_SUITE_LOG):
50 ## For debugging.
51 @echo "RE-RUN:"; for i in $(TEST_LOGS); do echo " $$i"; done
52 ## All the test cases should have been re-run.
53 @count_got=`for i in $(TEST_LOGS); do echo $$i; done | wc -l` \
54 && echo "Count expected: $(count_expected)" \
55 && echo "Count obtained: $$count_got" \
56 && test $$count_got -eq $(count_expected)
57 ## Pre-existing log files of the tests to re-run should have been
58 ## removed by the 'recheck' target
59 @for i in $(TEST_LOGS); do \
60 test ! -f $$i.log || { echo "$$i.log exists!"; exit 1; }; \
61 done
62 ## Actually create the target file, for extra safety.
63 @echo dummy > $@
64 END
66 # Updated later.
67 : > all
69 # Temporarily disable shell traces, to avoid bloating the log file.
70 set +x
72 for i in $(seq_ 1 $count); do
73 echo dummy $i > $i.log
74 echo :global-test-result: PASS > $i.trs
75 echo :test-result: PASS >> $i.trs
76 echo :recheck: yes >> $i.trs
77 echo TESTS += $i.t >> Makefile.am
78 echo $i >> all
79 done
81 # Re-enable shell traces.
82 set -x
84 # So that we don't need to create a ton of dummy tests.
85 echo '$(TESTS):' >> Makefile.am
87 head -n 100 Makefile.am || : # For debugging.
88 tail -n 100 Makefile.am || : # Likewise.
89 cat $count.trs # Likewise, just the last specimen though.
91 $ACLOCAL
92 $AUTOCONF
93 $AUTOMAKE -a
95 ./configure
96 $MAKE recheck