Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / Makefile.in
blob3235c70883235b09067eeaf5ca3895c1eb4cb8e2
1 # Makefile for regression testing the GNU debugger.
2 # Copyright 1992-2024 Free Software Foundation, Inc.
4 # This file is part of GDB.
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.
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.
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/>.
19 VPATH = @srcdir@
20 srcdir = @srcdir@
21 prefix = @prefix@
22 exec_prefix = @exec_prefix@
23 abs_builddir = @abs_builddir@
24 abs_srcdir = @abs_srcdir@
26 target_alias = @target_noncanonical@
27 program_transform_name = @program_transform_name@
28 build_canonical = @build@
29 host_canonical = @host@
30 target_canonical = @target@
31 enable_libctf = @enable_libctf@
33 SHELL = @SHELL@
34 EXEEXT = @EXEEXT@
35 SUBDIRS = @subdirs@
36 RPATH_ENVVAR = @RPATH_ENVVAR@
38 CC=@CC@
40 EXPECT = `if [ "$${READ1}" != "" ] ; then \
41 echo $${rootme}/expect-read1; \
42 elif [ "$${READMORE}" != "" ] ; then \
43 echo $${rootme}/expect-readmore; \
44 elif [ -f $${rootme}/../../expect/expect ] ; then \
45 echo $${rootme}/../../expect/expect ; \
46 else \
47 echo expect ; \
48 fi`
50 RUNTEST = $(RUNTEST_FOR_TARGET)
52 RUNTESTFLAGS =
54 FORCE_PARALLEL =
56 GDB_DEBUG =
57 GDBSERVER_DEBUG =
59 # Default number of iterations that we will use to run the testsuite
60 # if the user does not specify the RACY_ITER environment variable
61 # (e.g., when the user calls the make rule directly from the command
62 # line).
63 DEFAULT_RACY_ITER = 3
65 RUNTEST_FOR_TARGET = `\
66 if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
67 echo $${srcdir}/../../dejagnu/runtest; \
68 else \
69 if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
70 echo runtest; \
71 else \
72 t='$(program_transform_name)'; echo runtest | sed -e $$t; \
73 fi; \
74 fi`
76 #### host, target, and site specific Makefile frags come in here.
78 # The use of $$(x_FOR_TARGET) reduces the command line length by not
79 # duplicating the lengthy definition.
81 TARGET_FLAGS_TO_PASS = \
82 "prefix=$(prefix)" \
83 "exec_prefix=$(exec_prefix)" \
84 "against=$(against)" \
85 'CC=$$(CC_FOR_TARGET)' \
86 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
87 "CFLAGS=$(TESTSUITE_CFLAGS)" \
88 'CXX=$$(CXX_FOR_TARGET)' \
89 "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
90 "CXXFLAGS=$(CXXFLAGS)" \
91 "MAKEINFO=$(MAKEINFO)" \
92 "INSTALL=$(INSTALL)" \
93 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
94 "INSTALL_DATA=$(INSTALL_DATA)" \
95 "LDFLAGS=$(LDFLAGS)" \
96 "LIBS=$(LIBS)" \
97 "RUNTEST=$(RUNTEST)" \
98 "RUNTESTFLAGS=$(RUNTESTFLAGS)"
100 all:
103 .NOEXPORT:
104 INFODIRS=doc
105 info:
106 install-info:
107 dvi:
108 install-dvi:
109 pdf:
110 install-pdf:
111 html:
112 install-html:
114 install:
116 uninstall: force
118 # Use absolute `site.exp' path everywhere to suppress VPATH lookups for it.
119 # Bare `site.exp' is used as a target here if user requests it explicitly.
120 # $(RUNTEST) is looking up `site.exp' only in the current directory.
122 $(abs_builddir)/site.exp site.exp: Makefile
123 $(ECHO_GEN) \
124 rm -f ./tmp?; \
125 touch site.exp; \
126 mv site.exp site.bak; \
127 echo "## these variables are automatically generated by make ##" > ./tmp0; \
128 echo "# Do not edit here. If you wish to override these values" >> ./tmp0; \
129 echo "# add them to the last section" >> ./tmp0; \
130 echo "set host_triplet ${host_canonical}" >> ./tmp0; \
131 echo "set target_alias $(target_alias)" >> ./tmp0; \
132 echo "set target_triplet ${target_canonical}" >> ./tmp0; \
133 echo "set build_triplet ${build_canonical}" >> ./tmp0; \
134 echo "set srcdir ${abs_srcdir}" >> ./tmp0; \
135 echo "set tool gdb" >> ./tmp0; \
136 echo "set enable_libctf ${enable_libctf}" >> ./tmp0; \
137 echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0; \
138 echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0; \
139 cat ./tmp0 > site.exp; \
140 cat site.bak | sed \
141 -e '1,/^## All variables above are.*##/ d' >> site.exp; \
142 rm -f ./tmp?
144 installcheck:
146 # See whether -j was given to make. Before GNU make 4.2, either it was
147 # given with no arguments, and appears as "j" in the first word, or it was
148 # given an argument and appears as "-j" in a separate word. Starting with
149 # GNU make 4.2, it always appears as "-j"/"-jN" in a separate word.
150 saw_dash_j = $(or $(findstring j,$(firstword $(MAKEFLAGS))),$(filter -j%,$(MAKEFLAGS)))
152 # Try to run the tests in parallel if any -j option is given. If RUNTESTFLAGS
153 # is not empty, then by default the tests will be serialized. This can be
154 # overridden by setting FORCE_PARALLEL to any non-empty value.
155 CHECK_TARGET_TMP = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
156 CHECK_TARGET = $(if $(RACY_ITER),$(addsuffix -racy,$(CHECK_TARGET_TMP)),$(CHECK_TARGET_TMP))
158 # Note that we must resort to a recursive make invocation here,
159 # because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
160 # in conditions.
161 check: all $(abs_builddir)/site.exp
162 $(MAKE) $(CHECK_TARGET)
164 check-read1: read1.so expect-read1
165 $(MAKE) READ1="1" check
167 check-readmore: readmore.so expect-readmore
168 $(MAKE) READMORE="1" check
170 # Check whether we need to print the timestamp for each line of
171 # status.
172 TIMESTAMP = $(if $(TS),| $(srcdir)/print-ts.py $(if $(TS_FORMAT),$(TS_FORMAT),),)
174 gdb_debug = $(if $(GDB_DEBUG),GDB_DEBUG=$(GDB_DEBUG) ; export GDB_DEBUG ;,)
175 gdbserver_debug = $(if $(GDBSERVER_DEBUG),GDBSERVER_DEBUG=$(GDBSERVER_DEBUG) ; export GDBSERVER_DEBUG ;,)
178 # All the hair to invoke dejagnu. A given invocation can just append
179 # $(RUNTESTFLAGS)
180 DO_RUNTEST = \
181 rootme=`pwd`; export rootme; \
182 srcdir=${srcdir} ; export srcdir ; \
183 EXPECT=${EXPECT} ; export EXPECT ; \
184 EXEEXT=${EXEEXT} ; export EXEEXT ; $(gdb_debug) $(gdbserver_debug) \
185 $(RPATH_ENVVAR)=$$rootme/../../expect:$$rootme/../../libstdc++:$$rootme/../../tk/unix:$$rootme/../../tcl/unix:$$rootme/../../bfd:$$rootme/../../opcodes:$$$(RPATH_ENVVAR); \
186 export $(RPATH_ENVVAR); \
187 if [ -f $${rootme}/../../expect/expect ] ; then \
188 TCL_LIBRARY=$${srcdir}/../../tcl/library ; \
189 export TCL_LIBRARY ; fi ; \
190 $(RUNTEST) --status
192 # TESTS exists for the user to pass on the command line to easily
193 # say "Only run these tests." With check-single it's not necessary, but
194 # with check-parallel there's no other way to (easily) specify a subset
195 # of tests. For consistency we support it for check-single as well.
196 # To specify all tests in a subdirectory, use TESTS=gdb.subdir/*.exp.
197 # E.g., make check TESTS="gdb.server/*.exp gdb.threads/*.exp".
198 TESTS :=
200 ifeq ($(strip $(TESTS)),)
201 expanded_tests_or_none :=
202 else
203 expanded_tests := $(patsubst $(srcdir)/%,%,$(wildcard $(addprefix $(srcdir)/,$(TESTS))))
204 expanded_tests_or_none := $(or $(expanded_tests),no-matching-tests-found)
205 endif
207 # With check-single, if TESTS was expanded to "no-matching-tests-found" then
208 # this will be passed to DejaGnu, resuling in an error. With check-parallel
209 # in the same situation, we avoid invoking DejaGnu, and instead just call
210 # the check/no-matching-tests-found rule (which prints a helpful message).
212 # To get the same behavior for check-single we decide here, based on how
213 # TESTS expanded, whether check-single should redirect to do-check-single or
214 # to check/no-matching-tests-found.
215 ifeq ($(expanded_tests_or_none),no-matching-tests-found)
216 CHECK_SINGLE_DEP=check/no-matching-tests-found
217 else
218 CHECK_SINGLE_DEP=do-check-single
219 endif
221 # Shorthand for running all the tests in a single directory.
222 check-gdb.%:
223 $(MAKE) check TESTS="gdb.$*/*.exp"
225 do-check-single:
226 -rm -f *core* gdb.sum gdb.log
227 $(DO_RUNTEST) $(RUNTESTFLAGS) $(expanded_tests_or_none) $(TIMESTAMP); \
228 result=$$?; \
229 if test -e gdb.sum; then \
230 $(SHELL) $(srcdir)/lib/dg-add-core-file-count.sh; \
231 sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
232 fi; \
233 exit $$result
235 check-single: $(CHECK_SINGLE_DEP)
237 check-single-racy:
238 -rm -rf cache racy_outputs temp
239 mkdir -p racy_outputs; \
240 racyiter="$(RACY_ITER)"; \
241 test "x$$racyiter" = "x" && \
242 racyiter=$(DEFAULT_RACY_ITER); \
243 if test $$racyiter -lt 2 ; then \
244 echo "RACY_ITER must be at least 2."; \
245 exit 1; \
246 fi; \
247 trap "exit" INT; \
248 for n in `seq $$racyiter` ; do \
249 mkdir -p racy_outputs/$$n; \
250 $(DO_RUNTEST) --outdir=racy_outputs/$$n $(RUNTESTFLAGS) \
251 $(expanded_tests_or_none) $(TIMESTAMP); \
252 done; \
253 $(srcdir)/analyze-racy-logs.py \
254 `ls racy_outputs/*/gdb.sum` > racy.sum; \
255 sed -n '/=== gdb Summary ===/,$$ p' racy.sum
257 check-parallel:
258 -rm -f *core*
259 -rm -rf cache outputs temp
260 $(MAKE) -k do-check-parallel; \
261 result=$$?; \
262 if test -d outputs; then \
263 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
264 `find outputs -name gdb.sum -print` > gdb.sum; \
265 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
266 `find outputs -name gdb.log -print` > gdb.log; \
267 $(SHELL) $(srcdir)/lib/dg-add-core-file-count.sh; \
268 sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
269 fi; \
270 exit $$result
272 check-parallel-racy:
273 -rm -rf cache racy_outputs temp
274 racyiter="$(RACY_ITER)"; \
275 test "x$$racyiter" = "x" && \
276 racyiter=$(DEFAULT_RACY_ITER); \
277 if test $$racyiter -lt 2 ; then \
278 echo "RACY_ITER must be at least 2."; \
279 exit 1; \
280 fi; \
281 trap "exit" INT; \
282 for n in `seq $$racyiter` ; do \
283 $(MAKE) -k do-check-parallel-racy \
284 RACY_OUTPUT_N=$$n; \
285 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
286 `find racy_outputs/$$n -name gdb.sum -print` > \
287 racy_outputs/$$n/gdb.sum; \
288 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
289 `find racy_outputs/$$n -name gdb.log -print` > \
290 racy_outputs/$$n/gdb.log; \
291 sed -n '/=== gdb Summary ===/,$$ p' racy_outputs/$$n/gdb.sum; \
292 done; \
293 $(srcdir)/analyze-racy-logs.py \
294 `ls racy_outputs/*/gdb.sum` > racy.sum; \
295 sed -n '/=== gdb Summary ===/,$$ p' racy.sum
297 # Turn a list of .exp files into "check/" targets. Only examine .exp
298 # files appearing in a gdb.* directory -- we don't want to pick up
299 # lib/ by mistake. For example, gdb.linespec/linespec.exp becomes
300 # check/gdb.linespec/linespec.exp. The list is generally sorted
301 # alphabetically, but we take a few tests known to be slow and push
302 # them to the front of the list to try to lessen the overall time
303 # taken by the test suite -- if one of these tests happens to be run
304 # late, it will cause the overall time to increase.
305 ifeq ($(strip $(TESTS)),)
306 slow_tests = gdb.base/break-interp.exp gdb.base/interp.exp \
307 gdb.base/multi-forks.exp
308 all_tests := $(shell cd $(srcdir) && find gdb.* -name '*.exp' -print)
309 reordered_tests := $(slow_tests) $(filter-out $(slow_tests),$(all_tests))
310 TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(reordered_tests))
311 else
312 TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(expanded_tests_or_none))
313 endif
315 do-check-parallel: $(TEST_TARGETS)
318 check/%.exp:
319 -mkdir -p outputs/$*
320 @$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS) $(TIMESTAMP)
322 do-check-parallel-racy: $(TEST_TARGETS)
325 check-racy/%.exp:
326 -mkdir -p racy_outputs/$(RACY_OUTPUT_N)/$*
327 $(DO_RUNTEST) GDB_PARALLEL=yes \
328 --outdir=racy_outputs/$(RACY_OUTPUT_N)/$* $*.exp \
329 $(RUNTESTFLAGS) $(TIMESTAMP)
331 check/no-matching-tests-found:
332 @echo ""
333 @echo "No matching tests found."
334 @echo ""
336 # Utility rule invoked by step 2 of the build-perf rule.
337 workers/%.worker:
338 mkdir -p gdb.perf/outputs/$*
339 $(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)
341 # Utility rule to build tests that support it in parallel.
342 # The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE:
343 # gen-workers, build-pieces, final.
345 # GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want
346 # anything in RUNTESTFLAGS to override it.
348 # We don't delete the outputs directory here as these programs can take
349 # awhile to build, and perftest.exp has support for deciding whether to
350 # recompile them. If you want to remove these directories, make clean.
352 # The point of step 1 is to construct the set of worker tasks for step 2.
353 # All of the information needed by build-piece.exp is contained in the name
354 # of the generated .worker file.
355 build-perf: $(abs_builddir)/site.exp
356 rm -rf gdb.perf/workers
357 mkdir -p gdb.perf/workers
358 @: Step 1: Generate the build .worker files.
359 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers $(TIMESTAMP)
360 @: Step 2: Compile the pieces. Here is the build parallelism.
361 $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker)
362 @: Step 3: Do the final link.
363 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=final $(TIMESTAMP)
365 # The default is to both compile and run the tests.
366 GDB_PERFTEST_MODE = both
368 check-perf: all $(abs_builddir)/site.exp
369 @if test ! -d gdb.perf; then mkdir gdb.perf; fi
370 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS) $(TIMESTAMP)
373 check-all-boards: all $(abs_builddir)/site.exp
374 @if [ -z "$(GDB_TARGET_USERNAME)" ]; then \
375 echo "Must define GDB_TARGET_USERNAME"; \
376 false; \
378 @if [ -z "$(GDB_HOST_USERNAME)" ]; then \
379 echo "Must define GDB_HOST_USERNAME"; \
380 false; \
382 @if [ -z "$(TESTS)" ]; then \
383 echo "Must define TESTS"; \
384 false; \
386 ${abs_srcdir}/make-check-all.sh --keep-results \
387 --host-user "$(GDB_HOST_USERNAME)" \
388 --target-user "$(GDB_TARGET_USERNAME)" \
389 "$(TESTS)"
391 force:;
393 clean mostlyclean:
394 -rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
395 -rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript
396 -rm -f *.dwo *.dwp
397 -rm -rf outputs temp cache
398 -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache
399 -rm -f read1.so expect-read1 readmore.so expect-readmore
401 distclean maintainer-clean realclean: clean
402 -rm -f *~ core
403 -rm -f Makefile config.status *-init.exp lib/pdtrace
404 -rm -fr *.log summary detail *.plog *.sum *.psum site.*
406 Makefile : Makefile.in config.status $(host_makefile_frag)
407 $(SHELL) config.status Makefile
409 lib/pdtrace: pdtrace.in config.status
410 $(SHELL) config.status lib/pdtrace
412 config.status: configure
413 $(SHELL) config.status --recheck
415 TAGS: force
416 find $(srcdir) -name '*.exp' -print | \
417 etags \
418 --regex='/\(proc\|proc_with_prefix\|gdb_caching_proc\)[ \t]+\([^ \t]+\)/\2/' \
421 # Build the expect wrapper script that preloads the read1.so library.
422 expect-read1 expect-readmore:
423 $(ECHO_GEN) \
424 rm -f $@-tmp; \
425 touch $@-tmp; \
426 echo "# THIS FILE IS GENERATED -*- buffer-read-only: t -*- \n" >>$@-tmp; \
427 echo "# vi:set ro: */\n\n" >>$@-tmp; \
428 echo "# To regenerate this file, run:\n" >>$@-tmp; \
429 echo "# make clean; make/\n" >>$@-tmp; \
430 if [ $@ = expect-read1 ]; then \
431 echo "export LD_PRELOAD=`pwd`/read1.so" >>$@-tmp; \
432 else \
433 echo "export LD_PRELOAD=`pwd`/readmore.so" >>$@-tmp; \
434 fi; \
435 echo 'exec expect "$$@"' >>$@-tmp; \
436 chmod +x $@-tmp; \
437 mv $@-tmp $@
439 # Build the read1.so preload library. This overrides the `read'
440 # function, making it read one byte at a time. Running the testsuite
441 # with this catches racy tests.
442 read1.so: lib/read1.c
443 $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS)
445 # Build the readmore.so preload library. This overrides the `read'
446 # function, making it try harder to read more at a time. Running the
447 # testsuite with this catches racy tests.
448 readmore.so: lib/read1.c
449 $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC \
450 $(CFLAGS) -DREADMORE
452 # Build the read1 machinery.
453 .PHONY: read1 readmore
454 read1: read1.so expect-read1
455 readmore: readmore.so expect-readmore
457 # Disable implicit make rules.
458 include $(srcdir)/../disable-implicit-rules.mk
459 include $(srcdir)/../silent-rules.mk