Follow-up to Support style in 'frame|thread apply'
[deliverable/binutils-gdb.git] / gdb / testsuite / Makefile.in
CommitLineData
c906108c 1# Makefile for regression testing the GNU debugger.
42a4f53d 2# Copyright 1992-2019 Free Software Foundation, Inc.
c906108c
SS
3
4# This file is part of GDB.
5
d53a7b30 6# This program is free software; you can redistribute it and/or modify
c906108c 7# it under the terms of the GNU General Public License as published by
d53a7b30
JB
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,
c906108c
SS
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.
d53a7b30 15#
c906108c 16# You should have received a copy of the GNU General Public License
d53a7b30 17# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
18
19VPATH = @srcdir@
20srcdir = @srcdir@
21prefix = @prefix@
22exec_prefix = @exec_prefix@
b8b4e42b 23abs_builddir = @abs_builddir@
437277d4 24abs_srcdir = @abs_srcdir@
c906108c 25
be2a5f71 26target_alias = @target_noncanonical@
c906108c
SS
27program_transform_name = @program_transform_name@
28build_canonical = @build@
29host_canonical = @host@
30target_canonical = @target@
c906108c
SS
31
32SHELL = @SHELL@
93076499 33EXEEXT = @EXEEXT@
c906108c
SS
34SUBDIRS = @subdirs@
35RPATH_ENVVAR = @RPATH_ENVVAR@
36
2a31c623
PA
37EXTRA_RULES = @EXTRA_RULES@
38
39CC=@CC@
40
41EXPECT = `if [ "$${READ1}" != "" ] ; then \
42 echo $${rootme}/expect-read1; \
43 elif [ -f $${rootme}/../../expect/expect ] ; then \
44 echo $${rootme}/../../expect/expect ; \
45 else \
46 echo expect ; \
47 fi`
c906108c
SS
48
49RUNTEST = $(RUNTEST_FOR_TARGET)
50
51RUNTESTFLAGS =
52
6bc80edc
TT
53FORCE_PARALLEL =
54
dd06d4d6
AH
55GDBSERVER_DEBUG =
56
fb6a751f
SDJ
57# Default number of iterations that we will use to run the testsuite
58# if the user does not specify the RACY_ITER environment variable
59# (e.g., when the user calls the make rule directly from the command
60# line).
61DEFAULT_RACY_ITER = 3
62
c906108c
SS
63RUNTEST_FOR_TARGET = `\
64 if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
65 echo $${srcdir}/../../dejagnu/runtest; \
66 else \
67 if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
68 echo runtest; \
69 else \
dcfff61f 70 t='$(program_transform_name)'; echo runtest | sed -e $$t; \
c906108c
SS
71 fi; \
72 fi`
73
74#### host, target, and site specific Makefile frags come in here.
75
76# The use of $$(x_FOR_TARGET) reduces the command line length by not
77# duplicating the lengthy definition.
78
79TARGET_FLAGS_TO_PASS = \
80 "prefix=$(prefix)" \
81 "exec_prefix=$(exec_prefix)" \
82 "against=$(against)" \
83 'CC=$$(CC_FOR_TARGET)' \
84 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
85 "CFLAGS=$(TESTSUITE_CFLAGS)" \
c906108c
SS
86 'CXX=$$(CXX_FOR_TARGET)' \
87 "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
88 "CXXFLAGS=$(CXXFLAGS)" \
89 "MAKEINFO=$(MAKEINFO)" \
90 "INSTALL=$(INSTALL)" \
91 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
92 "INSTALL_DATA=$(INSTALL_DATA)" \
93 "LDFLAGS=$(LDFLAGS)" \
94 "LIBS=$(LIBS)" \
95 "RUNTEST=$(RUNTEST)" \
96 "RUNTESTFLAGS=$(RUNTESTFLAGS)"
97
2a31c623 98all: $(EXTRA_RULES)
c906108c
SS
99 @echo "Nothing to be done for all..."
100
101.NOEXPORT:
102INFODIRS=doc
103info:
104install-info:
105dvi:
9453113a
DJ
106pdf:
107install-pdf:
085dd6e6
JM
108html:
109install-html:
c906108c
SS
110
111install:
112
113uninstall: force
114
b8b4e42b
JK
115# Use absolute `site.exp' path everywhere to suppress VPATH lookups for it.
116# Bare `site.exp' is used as a target here if user requests it explicitly.
117# $(RUNTEST) is looking up `site.exp' only in the current directory.
118
119$(abs_builddir)/site.exp site.exp: ./config.status Makefile
c906108c
SS
120 @echo "Making a new config file..."
121 -@rm -f ./tmp?
122 @touch site.exp
123 -@mv site.exp site.bak
124 @echo "## these variables are automatically generated by make ##" > ./tmp0
125 @echo "# Do not edit here. If you wish to override these values" >> ./tmp0
126 @echo "# add them to the last section" >> ./tmp0
c906108c
SS
127 @echo "set host_triplet ${host_canonical}" >> ./tmp0
128 @echo "set target_alias $(target_alias)" >> ./tmp0
129 @echo "set target_triplet ${target_canonical}" >> ./tmp0
130 @echo "set build_triplet ${build_canonical}" >> ./tmp0
437277d4 131 @echo "set srcdir ${abs_srcdir}" >> ./tmp0
c906108c 132 @echo "set tool gdb" >> ./tmp0
f3525b70 133 @echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0
c906108c
SS
134 @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
135 @cat ./tmp0 > site.exp
136 @cat site.bak | sed \
137 -e '1,/^## All variables above are.*##/ d' >> site.exp
138 -@rm -f ./tmp?
139
140installcheck:
141
96d68bd4
RO
142# See whether -j was given to make. Before GNU make 4.2, either it was
143# given with no arguments, and appears as "j" in the first word, or it was
144# given an argument and appears as "-j" in a separate word. Starting with
145# GNU make 4.2, it always appears as "-j"/"-jN" in a separate word.
146saw_dash_j = $(or $(findstring j,$(firstword $(MAKEFLAGS))),$(filter -j%,$(MAKEFLAGS)))
81208388 147
3b165252
SM
148# Try to run the tests in parallel if any -j option is given. If RUNTESTFLAGS
149# is not empty, then by default the tests will be serialized. This can be
150# overridden by setting FORCE_PARALLEL to any non-empty value.
151CHECK_TARGET_TMP = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
152CHECK_TARGET = $(if $(RACY_ITER),$(addsuffix -racy,$(CHECK_TARGET_TMP)),$(CHECK_TARGET_TMP))
6bc80edc 153
81208388
TT
154# Note that we must resort to a recursive make invocation here,
155# because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
156# in conditions.
157check: all $(abs_builddir)/site.exp
158 $(MAKE) $(CHECK_TARGET)
6bc80edc 159
2a31c623
PA
160check-read1:
161 $(MAKE) READ1="1" check
162
f63c03b4
SDJ
163# Check whether we need to print the timestamp for each line of
164# status.
165TIMESTAMP = $(if $(TS),| $(srcdir)/print-ts.py $(if $(TS_FORMAT),$(TS_FORMAT),),)
166
dd06d4d6
AH
167gdbserver_debug = $(if $(GDBSERVER_DEBUG),GDBSERVER_DEBUG=$(GDBSERVER_DEBUG) ; export GDBSERVER_DEBUG ;,)
168
6bc80edc
TT
169# All the hair to invoke dejagnu. A given invocation can just append
170# $(RUNTESTFLAGS)
171DO_RUNTEST = \
c906108c
SS
172 rootme=`pwd`; export rootme; \
173 srcdir=${srcdir} ; export srcdir ; \
174 EXPECT=${EXPECT} ; export EXPECT ; \
dd06d4d6 175 EXEEXT=${EXEEXT} ; export EXEEXT ; $(gdbserver_debug) \
c906108c
SS
176 $(RPATH_ENVVAR)=$$rootme/../../expect:$$rootme/../../libstdc++:$$rootme/../../tk/unix:$$rootme/../../tcl/unix:$$rootme/../../bfd:$$rootme/../../opcodes:$$$(RPATH_ENVVAR); \
177 export $(RPATH_ENVVAR); \
178 if [ -f $${rootme}/../../expect/expect ] ; then \
179 TCL_LIBRARY=$${srcdir}/../../tcl/library ; \
180 export TCL_LIBRARY ; fi ; \
41d1845e 181 $(RUNTEST) --status
6bc80edc 182
c17ef0d5
DE
183# TESTS exists for the user to pass on the command line to easily
184# say "Only run these tests." With check-single it's not necessary, but
185# with check-parallel there's no other way to (easily) specify a subset
186# of tests. For consistency we support it for check-single as well.
187# To specify all tests in a subdirectory, use TESTS=gdb.subdir/*.exp.
188# E.g., make check TESTS="gdb.server/*.exp gdb.threads/*.exp".
3b165252 189TESTS :=
c17ef0d5 190
3b165252
SM
191ifeq ($(strip $(TESTS)),)
192expanded_tests_or_none :=
193else
194expanded_tests := $(patsubst $(srcdir)/%,%,$(wildcard $(addprefix $(srcdir)/,$(TESTS))))
195expanded_tests_or_none := $(or $(expanded_tests),no-matching-tests-found)
196endif
c17ef0d5 197
4992aa20 198# Shorthand for running all the tests in a single directory.
3b165252
SM
199check-gdb.%:
200 $(MAKE) check TESTS="gdb.$*/*.exp"
4992aa20 201
81208388 202check-single:
f63c03b4 203 $(DO_RUNTEST) $(RUNTESTFLAGS) $(expanded_tests_or_none) $(TIMESTAMP)
6bc80edc 204
fb6a751f
SDJ
205check-single-racy:
206 -rm -rf cache racy_outputs temp
207 mkdir -p racy_outputs; \
208 racyiter="$(RACY_ITER)"; \
209 test "x$$racyiter" == "x" && \
210 racyiter=$(DEFAULT_RACY_ITER); \
211 if test $$racyiter -lt 2 ; then \
212 echo "RACY_ITER must be at least 2."; \
213 exit 1; \
214 fi; \
215 trap "exit" INT; \
216 for n in `seq $$racyiter` ; do \
217 mkdir -p racy_outputs/$$n; \
218 $(DO_RUNTEST) --outdir=racy_outputs/$$n $(RUNTESTFLAGS) \
f63c03b4 219 $(expanded_tests_or_none) $(TIMESTAMP); \
fb6a751f
SDJ
220 done; \
221 $(srcdir)/analyze-racy-logs.py \
222 `ls racy_outputs/*/gdb.sum` > racy.sum; \
223 sed -n '/=== gdb Summary ===/,$$ p' racy.sum
224
6bc80edc 225check-parallel:
5dd3176f 226 -rm -rf cache outputs temp
81208388 227 $(MAKE) -k do-check-parallel; \
bef95aac 228 result=$$?; \
5a699617 229 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
81208388 230 `find outputs -name gdb.sum -print` > gdb.sum; \
5a699617 231 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
bef95aac
SM
232 `find outputs -name gdb.log -print` > gdb.log; \
233 sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
234 exit $$result
81208388 235
fb6a751f
SDJ
236check-parallel-racy:
237 -rm -rf cache racy_outputs temp
238 racyiter="$(RACY_ITER)"; \
239 test "x$$racyiter" == "x" && \
240 racyiter=$(DEFAULT_RACY_ITER); \
241 if test $$racyiter -lt 2 ; then \
242 echo "RACY_ITER must be at least 2."; \
243 exit 1; \
244 fi; \
245 trap "exit" INT; \
246 for n in `seq $$racyiter` ; do \
247 $(MAKE) -k do-check-parallel-racy \
248 RACY_OUTPUT_N=$$n; \
5a699617 249 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
fb6a751f
SDJ
250 `find racy_outputs/$$n -name gdb.sum -print` > \
251 racy_outputs/$$n/gdb.sum; \
6f1107b5 252 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
fb6a751f
SDJ
253 `find racy_outputs/$$n -name gdb.log -print` > \
254 racy_outputs/$$n/gdb.log; \
255 sed -n '/=== gdb Summary ===/,$$ p' racy_outputs/$$n/gdb.sum; \
256 done; \
257 $(srcdir)/analyze-racy-logs.py \
258 `ls racy_outputs/*/gdb.sum` > racy.sum; \
259 sed -n '/=== gdb Summary ===/,$$ p' racy.sum
260
81208388
TT
261# Turn a list of .exp files into "check/" targets. Only examine .exp
262# files appearing in a gdb.* directory -- we don't want to pick up
263# lib/ by mistake. For example, gdb.linespec/linespec.exp becomes
264# check/gdb.linespec/linespec.exp. The list is generally sorted
265# alphabetically, but we take a few tests known to be slow and push
266# them to the front of the list to try to lessen the overall time
267# taken by the test suite -- if one of these tests happens to be run
268# late, it will cause the overall time to increase.
3b165252 269ifeq ($(strip $(TESTS)),)
81208388
TT
270slow_tests = gdb.base/break-interp.exp gdb.base/interp.exp \
271 gdb.base/multi-forks.exp
3b165252
SM
272all_tests := $(shell cd $(srcdir) && find gdb.* -name '*.exp' -print)
273reordered_tests := $(slow_tests) $(filter-out $(slow_tests),$(all_tests))
274TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(reordered_tests))
275else
276TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(expanded_tests_or_none))
277endif
81208388
TT
278
279do-check-parallel: $(TEST_TARGETS)
280 @:
281
3b165252
SM
282check/%.exp:
283 -mkdir -p outputs/$*
f63c03b4 284 @$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS) $(TIMESTAMP)
c906108c 285
fb6a751f
SDJ
286do-check-parallel-racy: $(TEST_TARGETS)
287 @:
288
3b165252
SM
289check-racy/%.exp:
290 -mkdir -p racy_outputs/$(RACY_OUTPUT_N)/$*
291 $(DO_RUNTEST) GDB_PARALLEL=yes \
292 --outdir=racy_outputs/$(RACY_OUTPUT_N)/$* $*.exp \
f63c03b4 293 $(RUNTESTFLAGS) $(TIMESTAMP)
fb6a751f 294
c17ef0d5
DE
295check/no-matching-tests-found:
296 @echo ""
297 @echo "No matching tests found."
298 @echo ""
299
3d338901 300# Utility rule invoked by step 2 of the build-perf rule.
3b165252
SM
301workers/%.worker:
302 mkdir -p gdb.perf/outputs/$*
f63c03b4 303 $(DO_RUNTEST) --outdir=gdb.perf/outputs/$* lib/build-piece.exp WORKER=$* GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=build-pieces $(TIMESTAMP)
3d338901
DE
304
305# Utility rule to build tests that support it in parallel.
306# The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE:
307# gen-workers, build-pieces, final.
308#
309# GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want
310# anything in RUNTESTFLAGS to override it.
311#
312# We don't delete the outputs directory here as these programs can take
313# awhile to build, and perftest.exp has support for deciding whether to
314# recompile them. If you want to remove these directories, make clean.
315#
316# The point of step 1 is to construct the set of worker tasks for step 2.
317# All of the information needed by build-piece.exp is contained in the name
318# of the generated .worker file.
3b165252
SM
319build-perf: $(abs_builddir)/site.exp
320 rm -rf gdb.perf/workers
321 mkdir -p gdb.perf/workers
322 @: Step 1: Generate the build .worker files.
f63c03b4 323 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers $(TIMESTAMP)
3b165252
SM
324 @: Step 2: Compile the pieces. Here is the build parallelism.
325 $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker)
326 @: Step 3: Do the final link.
f63c03b4 327 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=final $(TIMESTAMP)
3d338901
DE
328
329# The default is to both compile and run the tests.
330GDB_PERFTEST_MODE = both
331
7636ccf9
YQ
332check-perf: all $(abs_builddir)/site.exp
333 @if test ! -d gdb.perf; then mkdir gdb.perf; fi
f63c03b4 334 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS) $(TIMESTAMP)
7636ccf9 335
c906108c
SS
336force:;
337
c906108c 338clean mostlyclean:
1d41d745 339 -rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
576fd14c 340 -rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript
957df313 341 -rm -f *.dwo *.dwp
81208388 342 -rm -rf outputs temp cache
3d338901 343 -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache
2a31c623 344 -rm -f read1.so expect-read1
c906108c
SS
345
346distclean maintainer-clean realclean: clean
347 -rm -f *~ core
348 -rm -f Makefile config.status *-init.exp
349 -rm -fr *.log summary detail *.plog *.sum *.psum site.*
c906108c 350
a4ce5b0d 351Makefile : Makefile.in config.status $(host_makefile_frag)
c906108c
SS
352 $(SHELL) config.status
353
354config.status: configure
355 $(SHELL) config.status --recheck
6bf58e63
TT
356
357TAGS: force
967d1f9b 358 find $(srcdir) -name '*.exp' -print | \
2361b0fb
TT
359 etags \
360 --regex='/\(proc\|proc_with_prefix\|gdb_caching_proc\)[ \t]+\([^ \t]+\)/\2/' \
361 -
2a31c623
PA
362
363# Build the expect wrapper script that preloads the read1.so library.
364expect-read1:
365 @echo Making expect-read1
366 @rm -f expect-read1-tmp
367 @touch expect-read1-tmp
368 @echo "# THIS FILE IS GENERATED -*- buffer-read-only: t -*- \n" >>expect-read1-tmp
369 @echo "# vi:set ro: */\n\n" >>expect-read1-tmp
370 @echo "# To regenerate this file, run:\n" >>expect-read1-tmp
371 @echo "# make clean; make/\n" >>expect-read1-tmp
372 @echo "export LD_PRELOAD=`pwd`/read1.so" >>expect-read1-tmp
373 @echo 'exec expect "$$@"' >>expect-read1-tmp
374 @chmod +x expect-read1-tmp
375 @mv expect-read1-tmp expect-read1
376
377# Build the read1.so preload library. This overrides the `read'
378# function, making it read one byte at a time. Running the testsuite
379# with this catches racy tests.
380read1.so: lib/read1.c
381 $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS)
382
383# Build the read1 machinery.
384.PHONY: read1
385read1: read1.so expect-read1
ad02e4fe
SM
386
387# Disable implicit make rules.
388include $(srcdir)/../disable-implicit-rules.mk
This page took 1.905084 seconds and 4 git commands to generate.