]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/Makefile.in
testsuite: Make check-parallel return non-zero if a test failed
[thirdparty/binutils-gdb.git] / gdb / testsuite / Makefile.in
1 # Makefile for regression testing the GNU debugger.
2 # Copyright 1992-2016 Free Software Foundation, Inc.
3
4 # This file is part of GDB.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 VPATH = @srcdir@
20 srcdir = @srcdir@
21 prefix = @prefix@
22 exec_prefix = @exec_prefix@
23 abs_builddir = @abs_builddir@
24
25 target_alias = @target_noncanonical@
26 program_transform_name = @program_transform_name@
27 build_canonical = @build@
28 host_canonical = @host@
29 target_canonical = @target@
30
31 SHELL = @SHELL@
32 EXEEXT = @EXEEXT@
33 SUBDIRS = @subdirs@
34 RPATH_ENVVAR = @RPATH_ENVVAR@
35 ALL_SUBDIRS = gdb.ada gdb.arch gdb.asm gdb.base gdb.btrace gdb.cell gdb.cp \
36 gdb.disasm gdb.dlang gdb.dwarf2 gdb.fortran gdb.gdb gdb.go \
37 gdb.java gdb.linespec gdb.mi gdb.modula2 gdb.multi \
38 gdb.objc gdb.opencl gdb.opt gdb.pascal gdb.python gdb.server \
39 gdb.stabs gdb.reverse gdb.threads gdb.trace gdb.xml \
40 $(SUBDIRS)
41
42 EXTRA_RULES = @EXTRA_RULES@
43
44 CC=@CC@
45
46 EXPECT = `if [ "$${READ1}" != "" ] ; then \
47 echo $${rootme}/expect-read1; \
48 elif [ -f $${rootme}/../../expect/expect ] ; then \
49 echo $${rootme}/../../expect/expect ; \
50 else \
51 echo expect ; \
52 fi`
53
54 RUNTEST = $(RUNTEST_FOR_TARGET)
55
56 RUNTESTFLAGS =
57
58 FORCE_PARALLEL =
59
60 RUNTEST_FOR_TARGET = `\
61 if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
62 echo $${srcdir}/../../dejagnu/runtest; \
63 else \
64 if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
65 echo runtest; \
66 else \
67 t='$(program_transform_name)'; echo runtest | sed -e $$t; \
68 fi; \
69 fi`
70
71 #### host, target, and site specific Makefile frags come in here.
72
73 # The use of $$(x_FOR_TARGET) reduces the command line length by not
74 # duplicating the lengthy definition.
75
76 TARGET_FLAGS_TO_PASS = \
77 "prefix=$(prefix)" \
78 "exec_prefix=$(exec_prefix)" \
79 "against=$(against)" \
80 'CC=$$(CC_FOR_TARGET)' \
81 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
82 "CFLAGS=$(TESTSUITE_CFLAGS)" \
83 'CXX=$$(CXX_FOR_TARGET)' \
84 "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
85 "CXXFLAGS=$(CXXFLAGS)" \
86 "MAKEINFO=$(MAKEINFO)" \
87 "INSTALL=$(INSTALL)" \
88 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
89 "INSTALL_DATA=$(INSTALL_DATA)" \
90 "LDFLAGS=$(LDFLAGS)" \
91 "LIBS=$(LIBS)" \
92 "RUNTEST=$(RUNTEST)" \
93 "RUNTESTFLAGS=$(RUNTESTFLAGS)"
94
95 all: $(EXTRA_RULES)
96 @echo "Nothing to be done for all..."
97
98 .NOEXPORT:
99 INFODIRS=doc
100 info:
101 install-info:
102 dvi:
103 pdf:
104 install-pdf:
105 html:
106 install-html:
107
108 install:
109
110 uninstall: force
111
112 # Use absolute `site.exp' path everywhere to suppress VPATH lookups for it.
113 # Bare `site.exp' is used as a target here if user requests it explicitly.
114 # $(RUNTEST) is looking up `site.exp' only in the current directory.
115
116 $(abs_builddir)/site.exp site.exp: ./config.status Makefile
117 @echo "Making a new config file..."
118 -@rm -f ./tmp?
119 @touch site.exp
120 -@mv site.exp site.bak
121 @echo "## these variables are automatically generated by make ##" > ./tmp0
122 @echo "# Do not edit here. If you wish to override these values" >> ./tmp0
123 @echo "# add them to the last section" >> ./tmp0
124 @echo "set host_triplet ${host_canonical}" >> ./tmp0
125 @echo "set target_alias $(target_alias)" >> ./tmp0
126 @echo "set target_triplet ${target_canonical}" >> ./tmp0
127 @echo "set build_triplet ${build_canonical}" >> ./tmp0
128 @echo "set srcdir ${srcdir}" >> ./tmp0
129 @echo "set tool gdb" >> ./tmp0
130 @echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0
131 @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
132 @cat ./tmp0 > site.exp
133 @cat site.bak | sed \
134 -e '1,/^## All variables above are.*##/ d' >> site.exp
135 -@rm -f ./tmp?
136
137 installcheck:
138
139 # See whether -j was given to make. Either it was given with no
140 # arguments, and appears as "j" in the first word, or it was given an
141 # argument and appears as "-j" in a separate word.
142 @GMAKE_TRUE@saw_dash_j = $(or $(findstring j,$(firstword $(MAKEFLAGS))),$(filter -j,$(MAKEFLAGS)))
143
144 # For GNU make, try to run the tests in parallel if any -j option is
145 # given. If RUNTESTFLAGS is not empty, then by default the tests will
146 # be serialized. This can be overridden by setting FORCE_PARALLEL to
147 # any non-empty value. For a non-GNU make, do not parallelize.
148 @GMAKE_TRUE@CHECK_TARGET = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
149 @GMAKE_FALSE@CHECK_TARGET = check-single
150
151 # Note that we must resort to a recursive make invocation here,
152 # because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
153 # in conditions.
154 check: all $(abs_builddir)/site.exp
155 $(MAKE) $(CHECK_TARGET)
156
157 check-read1:
158 $(MAKE) READ1="1" check
159
160 # All the hair to invoke dejagnu. A given invocation can just append
161 # $(RUNTESTFLAGS)
162 DO_RUNTEST = \
163 rootme=`pwd`; export rootme; \
164 srcdir=${srcdir} ; export srcdir ; \
165 EXPECT=${EXPECT} ; export EXPECT ; \
166 EXEEXT=${EXEEXT} ; export EXEEXT ; \
167 $(RPATH_ENVVAR)=$$rootme/../../expect:$$rootme/../../libstdc++:$$rootme/../../tk/unix:$$rootme/../../tcl/unix:$$rootme/../../bfd:$$rootme/../../opcodes:$$$(RPATH_ENVVAR); \
168 export $(RPATH_ENVVAR); \
169 if [ -f $${rootme}/../../expect/expect ] ; then \
170 TCL_LIBRARY=$${srcdir}/../../tcl/library ; \
171 export TCL_LIBRARY ; fi ; \
172 $(RUNTEST)
173
174 # TESTS exists for the user to pass on the command line to easily
175 # say "Only run these tests." With check-single it's not necessary, but
176 # with check-parallel there's no other way to (easily) specify a subset
177 # of tests. For consistency we support it for check-single as well.
178 # To specify all tests in a subdirectory, use TESTS=gdb.subdir/*.exp.
179 # E.g., make check TESTS="gdb.server/*.exp gdb.threads/*.exp".
180 @GMAKE_TRUE@TESTS :=
181 @GMAKE_FALSE@TESTS =
182
183 @GMAKE_TRUE@ifeq ($(strip $(TESTS)),)
184 @GMAKE_TRUE@expanded_tests_or_none :=
185 @GMAKE_TRUE@else
186 @GMAKE_TRUE@expanded_tests := $(patsubst $(srcdir)/%,%,$(wildcard $(addprefix $(srcdir)/,$(TESTS))))
187 @GMAKE_TRUE@expanded_tests_or_none := $(or $(expanded_tests),no-matching-tests-found)
188 @GMAKE_TRUE@endif
189 @GMAKE_FALSE@expanded_tests_or_none = $(TESTS)
190
191 # Shorthand for running all the tests in a single directory.
192 @GMAKE_TRUE@check-gdb.%:
193 @GMAKE_TRUE@ $(MAKE) check TESTS="gdb.$*/*.exp"
194
195 check-single:
196 $(DO_RUNTEST) $(RUNTESTFLAGS) $(expanded_tests_or_none)
197
198 check-parallel:
199 -rm -rf cache outputs temp
200 $(MAKE) -k do-check-parallel; \
201 result=$$?; \
202 $(SHELL) $(srcdir)/dg-extract-results.sh \
203 `find outputs -name gdb.sum -print` > gdb.sum; \
204 $(SHELL) $(srcdir)/dg-extract-results.sh -L \
205 `find outputs -name gdb.log -print` > gdb.log; \
206 sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
207 exit $$result
208
209 # Turn a list of .exp files into "check/" targets. Only examine .exp
210 # files appearing in a gdb.* directory -- we don't want to pick up
211 # lib/ by mistake. For example, gdb.linespec/linespec.exp becomes
212 # check/gdb.linespec/linespec.exp. The list is generally sorted
213 # alphabetically, but we take a few tests known to be slow and push
214 # them to the front of the list to try to lessen the overall time
215 # taken by the test suite -- if one of these tests happens to be run
216 # late, it will cause the overall time to increase.
217 @GMAKE_TRUE@ifeq ($(strip $(TESTS)),)
218 slow_tests = gdb.base/break-interp.exp gdb.base/interp.exp \
219 gdb.base/multi-forks.exp
220 @GMAKE_TRUE@all_tests := $(shell cd $(srcdir) && find gdb.* -name '*.exp' -print)
221 @GMAKE_TRUE@reordered_tests := $(slow_tests) $(filter-out $(slow_tests),$(all_tests))
222 @GMAKE_TRUE@TEST_TARGETS := $(addprefix check/,$(reordered_tests))
223 @GMAKE_TRUE@else
224 @GMAKE_TRUE@TEST_TARGETS := $(addprefix check/,$(expanded_tests_or_none))
225 @GMAKE_TRUE@endif
226
227 do-check-parallel: $(TEST_TARGETS)
228 @:
229
230 @GMAKE_TRUE@check/%.exp:
231 @GMAKE_TRUE@ -mkdir -p outputs/$*
232 @GMAKE_TRUE@ @$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS)
233
234 check/no-matching-tests-found:
235 @echo ""
236 @echo "No matching tests found."
237 @echo ""
238
239 # Utility rule invoked by step 2 of the build-perf rule.
240 @GMAKE_TRUE@workers/%.worker:
241 @GMAKE_TRUE@ mkdir -p gdb.perf/outputs/$*
242 @GMAKE_TRUE@ $(DO_RUNTEST) --status --outdir=gdb.perf/outputs/$* lib/build-piece.exp WORKER=$* GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=build-pieces
243
244 # Utility rule to build tests that support it in parallel.
245 # The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE:
246 # gen-workers, build-pieces, final.
247 #
248 # GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want
249 # anything in RUNTESTFLAGS to override it.
250 #
251 # We don't delete the outputs directory here as these programs can take
252 # awhile to build, and perftest.exp has support for deciding whether to
253 # recompile them. If you want to remove these directories, make clean.
254 #
255 # The point of step 1 is to construct the set of worker tasks for step 2.
256 # All of the information needed by build-piece.exp is contained in the name
257 # of the generated .worker file.
258 @GMAKE_TRUE@build-perf: $(abs_builddir)/site.exp
259 @GMAKE_TRUE@ rm -rf gdb.perf/workers
260 @GMAKE_TRUE@ mkdir -p gdb.perf/workers
261 @GMAKE_TRUE@ @: Step 1: Generate the build .worker files.
262 @GMAKE_TRUE@ $(DO_RUNTEST) --status --directory=gdb.perf --outdir gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers
263 @GMAKE_TRUE@ @: Step 2: Compile the pieces. Here is the build parallelism.
264 @GMAKE_TRUE@ $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker)
265 @GMAKE_TRUE@ @: Step 3: Do the final link.
266 @GMAKE_TRUE@ $(DO_RUNTEST) --status --directory=gdb.perf --outdir gdb.perf GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=final
267
268 # The default is to both compile and run the tests.
269 GDB_PERFTEST_MODE = both
270
271 check-perf: all $(abs_builddir)/site.exp
272 @if test ! -d gdb.perf; then mkdir gdb.perf; fi
273 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS)
274
275 force:;
276
277 clean mostlyclean:
278 -rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
279 -rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript
280 -rm -f *.dwo *.dwp
281 -rm -rf outputs temp cache
282 -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache
283 -rm -f read1.so expect-read1
284 if [ x"${ALL_SUBDIRS}" != x ] ; then \
285 for dir in ${ALL_SUBDIRS}; \
286 do \
287 echo "$$dir:"; \
288 if [ -d $$dir ]; then \
289 (cd $$dir; $(MAKE) clean); \
290 fi; \
291 done ; \
292 else true; fi
293
294 distclean maintainer-clean realclean: clean
295 -rm -f *~ core
296 -rm -f Makefile config.status *-init.exp
297 -rm -fr *.log summary detail *.plog *.sum *.psum site.*
298 if [ x"${ALL_SUBDIRS}" != x ] ; then \
299 for dir in ${ALL_SUBDIRS}; \
300 do \
301 echo "$$dir:"; \
302 if [ -d $$dir ]; then \
303 (cd $$dir; $(MAKE) distclean); \
304 fi; \
305 done ; \
306 else true; fi
307
308 Makefile : Makefile.in config.status $(host_makefile_frag)
309 $(SHELL) config.status
310
311 config.status: configure
312 $(SHELL) config.status --recheck
313
314 TAGS: force
315 find $(srcdir) -name '*.exp' -print | \
316 etags --regex='/proc[ \t]+\([^ \t]+\)/\1/' -
317
318 # Build the expect wrapper script that preloads the read1.so library.
319 expect-read1:
320 @echo Making expect-read1
321 @rm -f expect-read1-tmp
322 @touch expect-read1-tmp
323 @echo "# THIS FILE IS GENERATED -*- buffer-read-only: t -*- \n" >>expect-read1-tmp
324 @echo "# vi:set ro: */\n\n" >>expect-read1-tmp
325 @echo "# To regenerate this file, run:\n" >>expect-read1-tmp
326 @echo "# make clean; make/\n" >>expect-read1-tmp
327 @echo "export LD_PRELOAD=`pwd`/read1.so" >>expect-read1-tmp
328 @echo 'exec expect "$$@"' >>expect-read1-tmp
329 @chmod +x expect-read1-tmp
330 @mv expect-read1-tmp expect-read1
331
332 # Build the read1.so preload library. This overrides the `read'
333 # function, making it read one byte at a time. Running the testsuite
334 # with this catches racy tests.
335 read1.so: lib/read1.c
336 $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS)
337
338 # Build the read1 machinery.
339 .PHONY: read1
340 read1: read1.so expect-read1