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