]> git.lizzy.rs Git - rust.git/blob - mk/tests.mk
core: Fix size_hint for signed integer Range<T> iterators
[rust.git] / mk / tests.mk
1 # Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11
12 ######################################################################
13 # Test variables
14 ######################################################################
15
16 # The names of crates that must be tested
17
18 # libcore/librustc_unicode tests are in a separate crate
19 DEPS_coretest :=
20 $(eval $(call RUST_CRATE,coretest))
21
22 DEPS_collectionstest :=
23 $(eval $(call RUST_CRATE,collectionstest))
24
25 TEST_TARGET_CRATES = $(filter-out core rustc_unicode,$(TARGET_CRATES)) \
26                         collectionstest coretest
27 TEST_DOC_CRATES = $(DOC_CRATES)
28 TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve \
29                                 rustc_trans rustc_lint,\
30                      $(HOST_CRATES))
31 TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
32
33 ######################################################################
34 # Environment configuration
35 ######################################################################
36
37 # The arguments to all test runners
38 ifdef TESTNAME
39   TESTARGS += $(TESTNAME)
40 endif
41
42 ifdef CHECK_IGNORED
43   TESTARGS += --ignored
44 endif
45
46 # Arguments to the cfail/rfail/rpass/bench tests
47 ifdef CFG_VALGRIND
48   CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
49 endif
50
51 # Arguments to the perf tests
52 ifdef CFG_PERF_TOOL
53   CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
54 endif
55
56 CTEST_TESTARGS := $(TESTARGS)
57
58 # --bench is only relevant for crate tests, not for the compile tests
59 ifdef PLEASE_BENCH
60   TESTARGS += --bench
61 endif
62
63 ifdef VERBOSE
64   CTEST_TESTARGS += --verbose
65 endif
66
67 # Setting locale ensures that gdb's output remains consistent.
68 # This prevents tests from failing with some locales (fixes #17423).
69 export LC_ALL=C
70
71 # If we're running perf then set this environment variable
72 # to put the benchmarks into 'hard mode'
73 ifeq ($(MAKECMDGOALS),perf)
74   export RUST_BENCH=1
75 endif
76
77 TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
78 TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
79
80 define DEF_TARGET_COMMANDS
81
82 ifdef CFG_UNIXY_$(1)
83   CFG_RUN_TEST_$(1)=$$(TARGET_RPATH_VAR$$(2)_T_$$(3)_H_$$(4)) \
84           $$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
85 endif
86
87 ifdef CFG_WINDOWSY_$(1)
88   CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)$$(2)/$$(strip \
89    $$(if $$(findstring stage0,$$(1)), \
90        stage0/$$(CFG_LIBDIR_RELATIVE), \
91       $$(if $$(findstring stage1,$$(1)), \
92            stage1/$$(CFG_LIBDIR_RELATIVE), \
93           $$(if $$(findstring stage2,$$(1)), \
94                stage2/$$(CFG_LIBDIR_RELATIVE), \
95                $$(if $$(findstring stage3,$$(1)), \
96                     stage3/$$(CFG_LIBDIR_RELATIVE), \
97                )))))/rustlib/$$(CFG_BUILD)/lib
98   CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(4)),$$(1))
99 endif
100
101 # Run the compiletest runner itself under valgrind
102 ifdef CTEST_VALGRIND
103 CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \
104       $$(call CFG_RUN_TEST_$$(CFG_BUILD),$$(3),$$(4))
105 else
106 CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \
107       $$(call CFG_RUN_$$(CFG_BUILD),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
108 endif
109
110 endef
111
112 $(foreach target,$(CFG_TARGET), \
113   $(eval $(call DEF_TARGET_COMMANDS,$(target))))
114
115 # Target platform specific variables for android
116 define DEF_ADB_DEVICE_STATUS
117 CFG_ADB_DEVICE_STATUS=$(1)
118 endef
119
120 $(foreach target,$(CFG_TARGET), \
121   $(if $(findstring android, $(target)), \
122     $(if $(findstring adb,$(CFG_ADB)), \
123       $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[:_A-Za-z0-9-]+[[:blank:]]+device')), \
124         $(info check: android device attached) \
125         $(eval $(call DEF_ADB_DEVICE_STATUS, true)), \
126         $(info check: android device not attached) \
127         $(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
128       ), \
129       $(info check: adb not found) \
130       $(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
131     ), \
132   ) \
133 )
134
135 ifeq ($(CFG_ADB_DEVICE_STATUS),true)
136 CFG_ADB_TEST_DIR=/data/tmp
137
138 $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
139  $(shell $(CFG_ADB) remount 1>/dev/null) \
140  $(shell $(CFG_ADB) shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
141  $(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)) \
142  $(shell $(CFG_ADB) push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
143  $(foreach target,$(CFG_TARGET), \
144   $(if $(findstring android, $(target)), \
145    $(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/$(target)) \
146    $(foreach crate,$(TARGET_CRATES), \
147     $(shell $(CFG_ADB) push $(TLIB2_T_$(target)_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_$(target),$(crate)) \
148                     $(CFG_ADB_TEST_DIR)/$(target))), \
149  )))
150 else
151 CFG_ADB_TEST_DIR=
152 endif
153
154 # $(1) - name of doc test
155 # $(2) - file of the test
156 define DOCTEST
157 DOC_NAMES := $$(DOC_NAMES) $(1)
158 DOCFILE_$(1) := $(2)
159 endef
160
161 $(foreach doc,$(DOCS), \
162   $(eval $(call DOCTEST,md-$(doc),$(S)src/doc/$(doc).md)))
163 $(foreach file,$(wildcard $(S)src/doc/trpl/*.md), \
164   $(eval $(call DOCTEST,$(file:$(S)src/doc/trpl/%.md=trpl-%),$(file))))
165
166 ######################################################################
167 # Main test targets
168 ######################################################################
169
170 # The main testing target. Tests lots of stuff.
171 check: check-sanitycheck cleantmptestlogs cleantestlibs all check-stage2 tidy
172         $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
173
174 # As above but don't bother running tidy.
175 check-notidy: cleantmptestlogs cleantestlibs all check-stage2
176         $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
177
178 # A slightly smaller set of tests for smoke testing.
179 check-lite: cleantestlibs cleantmptestlogs \
180         $(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate)) \
181         check-stage2-rpass check-stage2-rpass-valgrind \
182         check-stage2-rfail check-stage2-cfail check-stage2-pfail check-stage2-rmake
183         $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
184
185 # Only check the 'reference' tests: rpass/cfail/rfail/rmake.
186 check-ref: cleantestlibs cleantmptestlogs check-stage2-rpass check-stage2-rpass-valgrind \
187         check-stage2-rfail check-stage2-cfail check-stage2-pfail check-stage2-rmake
188         $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
189
190 # Only check the docs.
191 check-docs: cleantestlibs cleantmptestlogs check-stage2-docs
192         $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
193
194 # Some less critical tests that are not prone to breakage.
195 # Not run as part of the normal test suite, but tested by bors on checkin.
196 check-secondary: check-build-compiletest check-build-lexer-verifier check-lexer check-pretty
197
198 .PHONY: check-sanitycheck
199
200 check-sanitycheck:
201         $(Q)$(CFG_PYTHON) $(S)src/etc/check-sanitycheck.py
202
203 # check + check-secondary.
204 #
205 # Issue #17883: build check-secondary first so hidden dependencies in
206 # e.g. building compiletest are exercised (resolve those by adding
207 # deps to rules that need them; not by putting `check` first here).
208 check-all: check-secondary check
209
210 # Pretty-printing tests.
211 check-pretty: check-stage2-T-$(CFG_BUILD)-H-$(CFG_BUILD)-pretty-exec
212
213 define DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE
214 check-stage$(1)-build-compiletest:      $$(HBIN$(1)_H_$(CFG_BUILD))/compiletest$$(X_$(CFG_BUILD))
215 endef
216
217 $(foreach stage,$(STAGES), \
218  $(eval $(call DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE,$(stage))))
219
220 check-build-compiletest: \
221         check-stage1-build-compiletest \
222         check-stage2-build-compiletest
223
224 .PHONY: cleantmptestlogs cleantestlibs
225
226 cleantmptestlogs:
227         $(Q)rm -f tmp/*.log
228
229 cleantestlibs:
230         $(Q)find $(CFG_BUILD)/test \
231          -name '*.[odasS]' -o \
232          -name '*.so' -o \
233          -name '*.dylib' -o \
234          -name '*.dll' -o \
235          -name '*.def' -o \
236          -name '*.bc' -o \
237          -name '*.dSYM' -o \
238          -name '*.libaux' -o \
239          -name '*.out' -o \
240          -name '*.err' -o \
241          -name '*.debugger.script' \
242          | xargs rm -rf
243
244
245 ######################################################################
246 # Tidy
247 ######################################################################
248
249 ifdef CFG_NOTIDY
250 .PHONY: tidy
251 tidy:
252 else
253
254 # Run the tidy script in multiple parts to avoid huge 'echo' commands
255 .PHONY: tidy
256 tidy: tidy-basic tidy-binaries tidy-errors tidy-features
257
258 endif
259
260 .PHONY: tidy-basic
261 tidy-basic:
262                 @$(call E, check: formatting)
263                 $(Q) $(CFG_PYTHON) $(S)src/etc/tidy.py $(S)src/
264
265 .PHONY: tidy-binaries
266 tidy-binaries:
267                 @$(call E, check: binaries)
268                 $(Q)find $(S)src -type f -perm +a+x \
269                     -not -name '*.rs' -and -not -name '*.py' \
270                     -and -not -name '*.sh' \
271                 | grep '^$(S)src/jemalloc' -v \
272                 | grep '^$(S)src/libuv' -v \
273                 | grep '^$(S)src/llvm' -v \
274                 | grep '^$(S)src/rt/hoedown' -v \
275                 | grep '^$(S)src/gyp' -v \
276                 | grep '^$(S)src/etc' -v \
277                 | grep '^$(S)src/doc' -v \
278                 | grep '^$(S)src/compiler-rt' -v \
279                 | grep '^$(S)src/libbacktrace' -v \
280                 | grep '^$(S)src/rust-installer' -v \
281                 | xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
282
283 .PHONY: tidy-errors
284 tidy-errors:
285                 @$(call E, check: extended errors)
286                 $(Q) $(CFG_PYTHON) $(S)src/etc/errorck.py $(S)src/
287
288 .PHONY: tidy-features
289 tidy-features:
290                 @$(call E, check: feature sanity)
291                 $(Q) $(CFG_PYTHON) $(S)src/etc/featureck.py $(S)src/
292
293
294 ######################################################################
295 # Sets of tests
296 ######################################################################
297
298 define DEF_TEST_SETS
299
300 check-stage$(1)-T-$(2)-H-$(3)-exec: \
301         check-stage$(1)-T-$(2)-H-$(3)-rpass-exec \
302         check-stage$(1)-T-$(2)-H-$(3)-rfail-exec \
303         check-stage$(1)-T-$(2)-H-$(3)-cfail-exec \
304         check-stage$(1)-T-$(2)-H-$(3)-pfail-exec \
305     check-stage$(1)-T-$(2)-H-$(3)-rpass-valgrind-exec \
306     check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
307         check-stage$(1)-T-$(2)-H-$(3)-cfail-full-exec \
308         check-stage$(1)-T-$(2)-H-$(3)-rmake-exec \
309         check-stage$(1)-T-$(2)-H-$(3)-rustdocck-exec \
310         check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
311         check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec \
312         check-stage$(1)-T-$(2)-H-$(3)-bench-exec \
313         check-stage$(1)-T-$(2)-H-$(3)-debuginfo-gdb-exec \
314         check-stage$(1)-T-$(2)-H-$(3)-debuginfo-lldb-exec \
315         check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
316         check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
317         check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
318
319 # Only test the compiler-dependent crates when the target is
320 # able to build a compiler (when the target triple is in the set of host triples)
321 ifneq ($$(findstring $(2),$$(CFG_HOST)),)
322
323 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
324         $$(foreach crate,$$(TEST_CRATES), \
325            check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
326
327 else
328
329 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
330         $$(foreach crate,$$(TEST_TARGET_CRATES), \
331            check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
332
333 endif
334
335 check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec: \
336         $$(foreach crate,$$(TEST_DOC_CRATES), \
337            check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$$(crate)-exec)
338
339 check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
340         $$(foreach docname,$$(DOC_NAMES), \
341            check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec) \
342
343 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
344         check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
345     check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-valgrind-exec \
346         check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec \
347         check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
348         check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec \
349         check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
350
351 endef
352
353 $(foreach host,$(CFG_HOST), \
354  $(foreach target,$(CFG_TARGET), \
355   $(foreach stage,$(STAGES), \
356     $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
357
358
359 ######################################################################
360 # Crate testing
361 ######################################################################
362
363 define TEST_RUNNER
364
365 # If NO_REBUILD is set then break the dependencies on everything but
366 # the source files so we can test crates without rebuilding any of the
367 # parent crates.
368 ifeq ($(NO_REBUILD),)
369 TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
370                             $$(foreach crate,$$(TARGET_CRATES), \
371                                 $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
372                                 $$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))
373
374 else
375 TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
376 endif
377
378 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): CFG_COMPILER_HOST_TRIPLE = $(2)
379 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
380                 $$(CRATEFILE_$(4)) \
381                 $$(TESTDEP_$(1)_$(2)_$(3)_$(4))
382         @$$(call E, rustc: $$@)
383         $(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
384             $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
385                 -L "$$(RT_OUTPUT_DIR_$(2))" \
386                 $$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
387                 $$(RUSTFLAGS_$(4))
388
389 endef
390
391 $(foreach host,$(CFG_HOST), \
392  $(eval $(foreach target,$(CFG_TARGET), \
393   $(eval $(foreach stage,$(STAGES), \
394    $(eval $(foreach crate,$(TEST_CRATES), \
395     $(eval $(call TEST_RUNNER,$(stage),$(target),$(host),$(crate))))))))))
396
397 define DEF_TEST_CRATE_RULES
398 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
399
400 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
401                 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
402         @$$(call E, run: $$<)
403         $$(Q)touch $$@.start_time
404         $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(1),$(2),$(3)) $$(TESTARGS) \
405             --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
406             $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) \
407             && touch -r $$@.start_time $$@ && rm $$@.start_time
408 endef
409
410 define DEF_TEST_CRATE_RULES_android
411 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
412
413 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
414                 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
415         @$$(call E, run: $$< via adb)
416         $$(Q)touch $$@.start_time
417         $$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
418         $$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=./$(2) \
419                 ./$$(notdir $$<) \
420                 --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
421                 $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
422                 > tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
423         $$(Q)cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
424         $$(Q)touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
425         $$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
426         $$(Q)$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
427         @if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
428         then \
429                 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
430                 touch -r $$@.start_time $$@ && rm $$@.start_time; \
431         else \
432                 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
433                 exit 101; \
434         fi
435 endef
436
437 define DEF_TEST_CRATE_RULES_null
438 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
439
440 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
441                 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
442         @$$(call E, failing: no device for $$< )
443         false
444 endef
445
446 $(foreach host,$(CFG_HOST), \
447  $(foreach target,$(CFG_TARGET), \
448   $(foreach stage,$(STAGES), \
449    $(foreach crate, $(TEST_CRATES), \
450     $(if $(findstring $(target),$(CFG_BUILD)), \
451      $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
452      $(if $(findstring android, $(target)), \
453       $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
454        $(eval $(call DEF_TEST_CRATE_RULES_android,$(stage),$(target),$(host),$(crate))), \
455        $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
456       ), \
457       $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
458      ))))))
459
460 ######################################################################
461 # Rules for the compiletest tests (rpass, rfail, etc.)
462 ######################################################################
463
464 RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
465 RPASS_VALGRIND_RS := $(wildcard $(S)src/test/run-pass-valgrind/*.rs)
466 RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
467 CFAIL_FULL_RS := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rs)
468 RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
469 CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
470 PFAIL_RS := $(wildcard $(S)src/test/parse-fail/*.rs)
471 BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
472 PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
473 DEBUGINFO_GDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
474 DEBUGINFO_LLDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
475 CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
476 CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
477 RUSTDOCCK_RS := $(wildcard $(S)src/test/rustdoc/*.rs)
478
479 # perf tests are the same as bench tests only they run under
480 # a performance monitor.
481 PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
482
483 RPASS_TESTS := $(RPASS_RS)
484 RPASS_VALGRIND_TESTS := $(RPASS_VALGRIND_RS)
485 RPASS_FULL_TESTS := $(RPASS_FULL_RS)
486 CFAIL_FULL_TESTS := $(CFAIL_FULL_RS)
487 RFAIL_TESTS := $(RFAIL_RS)
488 CFAIL_TESTS := $(CFAIL_RS)
489 PFAIL_TESTS := $(PFAIL_RS)
490 BENCH_TESTS := $(BENCH_RS)
491 PERF_TESTS := $(PERF_RS)
492 PRETTY_TESTS := $(PRETTY_RS)
493 DEBUGINFO_GDB_TESTS := $(DEBUGINFO_GDB_RS)
494 DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
495 CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
496 RUSTDOCCK_TESTS := $(RUSTDOCCK_RS)
497
498 CTEST_SRC_BASE_rpass = run-pass
499 CTEST_BUILD_BASE_rpass = run-pass
500 CTEST_MODE_rpass = run-pass
501 CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
502
503 CTEST_SRC_BASE_rpass-valgrind = run-pass-valgrind
504 CTEST_BUILD_BASE_rpass-valgrind = run-pass-valgrind
505 CTEST_MODE_rpass-valgrind = run-pass-valgrind
506 CTEST_RUNTOOL_rpass-valgrind = $(CTEST_RUNTOOL)
507
508 CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
509 CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps
510 CTEST_MODE_rpass-full = run-pass
511 CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
512
513 CTEST_SRC_BASE_cfail-full = compile-fail-fulldeps
514 CTEST_BUILD_BASE_cfail-full = compile-fail-fulldeps
515 CTEST_MODE_cfail-full = compile-fail
516 CTEST_RUNTOOL_cfail-full = $(CTEST_RUNTOOL)
517
518 CTEST_SRC_BASE_rfail = run-fail
519 CTEST_BUILD_BASE_rfail = run-fail
520 CTEST_MODE_rfail = run-fail
521 CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
522
523 CTEST_SRC_BASE_cfail = compile-fail
524 CTEST_BUILD_BASE_cfail = compile-fail
525 CTEST_MODE_cfail = compile-fail
526 CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
527
528 CTEST_SRC_BASE_pfail = parse-fail
529 CTEST_BUILD_BASE_pfail = parse-fail
530 CTEST_MODE_pfail = parse-fail
531 CTEST_RUNTOOL_pfail = $(CTEST_RUNTOOL)
532
533 CTEST_SRC_BASE_bench = bench
534 CTEST_BUILD_BASE_bench = bench
535 CTEST_MODE_bench = run-pass
536 CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
537
538 CTEST_SRC_BASE_perf = bench
539 CTEST_BUILD_BASE_perf = perf
540 CTEST_MODE_perf = run-pass
541 CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
542
543 CTEST_SRC_BASE_debuginfo-gdb = debuginfo
544 CTEST_BUILD_BASE_debuginfo-gdb = debuginfo-gdb
545 CTEST_MODE_debuginfo-gdb = debuginfo-gdb
546 CTEST_RUNTOOL_debuginfo-gdb = $(CTEST_RUNTOOL)
547
548 CTEST_SRC_BASE_debuginfo-lldb = debuginfo
549 CTEST_BUILD_BASE_debuginfo-lldb = debuginfo-lldb
550 CTEST_MODE_debuginfo-lldb = debuginfo-lldb
551 CTEST_RUNTOOL_debuginfo-lldb = $(CTEST_RUNTOOL)
552
553 CTEST_SRC_BASE_codegen = codegen
554 CTEST_BUILD_BASE_codegen = codegen
555 CTEST_MODE_codegen = codegen
556 CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)
557
558 CTEST_SRC_BASE_rustdocck = rustdoc
559 CTEST_BUILD_BASE_rustdocck = rustdoc
560 CTEST_MODE_rustdocck = rustdoc
561 CTEST_RUNTOOL_rustdocck = $(CTEST_RUNTOOL)
562
563 # CTEST_DISABLE_$(TEST_GROUP), if set, will cause the test group to be
564 # disabled and the associated message to be printed as a warning
565 # during attempts to run those tests.
566
567 ifeq ($(CFG_GDB),)
568 CTEST_DISABLE_debuginfo-gdb = "no gdb found"
569 endif
570
571 ifeq ($(CFG_LLDB),)
572 CTEST_DISABLE_debuginfo-lldb = "no lldb found"
573 endif
574
575 ifeq ($(CFG_CLANG),)
576 CTEST_DISABLE_codegen = "no clang found"
577 endif
578
579 ifneq ($(CFG_OSTYPE),apple-darwin)
580 CTEST_DISABLE_debuginfo-lldb = "lldb tests are only run on darwin"
581 endif
582
583 ifeq ($(CFG_OSTYPE),apple-darwin)
584 CTEST_DISABLE_debuginfo-gdb = "gdb on darwin needs root"
585 endif
586
587 ifeq ($(findstring android, $(CFG_TARGET)), android)
588 CTEST_DISABLE_debuginfo-gdb =
589 CTEST_DISABLE_debuginfo-lldb = "lldb tests are disabled on android"
590 endif
591
592 # CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that
593 # test group to be disabled *unless* the target is able to build a
594 # compiler (i.e. when the target triple is in the set of of host
595 # triples).  The associated message will be printed as a warning
596 # during attempts to run those tests.
597
598 define DEF_CTEST_VARS
599
600 # All the per-stage build rules you might want to call from the
601 # command line.
602 #
603 # $(1) is the stage number
604 # $(2) is the target triple to test
605 # $(3) is the host triple to test
606
607 # Prerequisites for compiletest tests
608 TEST_SREQ$(1)_T_$(2)_H_$(3) = \
609         $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
610         $$(SREQ$(1)_T_$(2)_H_$(3))
611
612 # Rules for the cfail/rfail/rpass/bench/perf test runner
613
614 # The tests select when to use debug configuration on their own;
615 # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
616 CTEST_RUSTC_FLAGS := $$(subst -C debug-assertions,,$$(subst -C debug-assertions=on,,$$(CFG_RUSTC_FLAGS)))
617
618 # The tests cannot be optimized while the rest of the compiler is optimized, so
619 # filter out the optimization (if any) from rustc and then figure out if we need
620 # to be optimized
621 CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
622 ifndef CFG_DISABLE_OPTIMIZE_TESTS
623 CTEST_RUSTC_FLAGS += -O
624 endif
625
626
627 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
628                 --compile-lib-path $$(HLIB$(1)_H_$(3)) \
629         --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
630         --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
631         --rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
632         --clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
633         --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
634         --aux-base $$(S)src/test/auxiliary/ \
635         --stage-id stage$(1)-$(2) \
636         --target $(2) \
637         --host $(3) \
638         --python $$(CFG_PYTHON) \
639         --gdb-version="$(CFG_GDB_VERSION)" \
640         --lldb-version="$(CFG_LLDB_VERSION)" \
641         --android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
642         --adb-path=$(CFG_ADB) \
643         --adb-test-dir=$(CFG_ADB_TEST_DIR) \
644         --host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
645         --lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
646         --target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
647         $$(CTEST_TESTARGS)
648
649 ifdef CFG_VALGRIND_RPASS
650 ifdef GOOD_VALGRIND_$(2)
651 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) += --valgrind-path "$(CFG_VALGRIND_RPASS)"
652 endif
653 endif
654
655 ifndef CFG_DISABLE_VALGRIND_RPASS
656 ifdef GOOD_VALGRIND_$(2)
657 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) += --force-valgrind
658 endif
659 endif
660
661 CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
662 CTEST_DEPS_rpass-valgrind_$(1)-T-$(2)-H-$(3) = $$(RPASS_VALGRIND_TESTS)
663 CTEST_DEPS_rpass-full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
664 CTEST_DEPS_cfail-full_$(1)-T-$(2)-H-$(3) = $$(CFAIL_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
665 CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
666 CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
667 CTEST_DEPS_pfail_$(1)-T-$(2)-H-$(3) = $$(PFAIL_TESTS)
668 CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
669 CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
670 CTEST_DEPS_debuginfo-gdb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_GDB_TESTS)
671 CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
672                                                $(S)src/etc/lldb_batchmode.py \
673                                                $(S)src/etc/lldb_rust_formatters.py
674 CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
675 CTEST_DEPS_rustdocck_$(1)-T-$(2)-H-$(3) = $$(RUSTDOCCK_TESTS) \
676         $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
677         $(S)src/etc/htmldocck.py
678
679 endef
680
681 $(foreach host,$(CFG_HOST), \
682  $(eval $(foreach target,$(CFG_TARGET), \
683   $(eval $(foreach stage,$(STAGES), \
684    $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
685
686 define DEF_RUN_COMPILETEST
687
688 CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
689         $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
690         --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
691         --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
692         --mode $$(CTEST_MODE_$(4)) \
693         $$(CTEST_RUNTOOL_$(4))
694
695 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
696
697 # CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)
698 # Goal: leave this variable as empty string if we should run the test.
699 # Otherwise, set it to the reason we are not running the test.
700 # (Encoded as a separate variable because GNU make does not have a
701 # good way to express OR on ifeq commands)
702
703 ifneq ($$(CTEST_DISABLE_$(4)),)
704 # Test suite is disabled for all configured targets.
705 CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4) := $$(CTEST_DISABLE_$(4))
706 else
707 # else, check if non-self-hosted target (i.e. target not-in hosts) ...
708 ifeq ($$(findstring $(2),$$(CFG_HOST)),)
709 # ... if so, then check if this test suite is disabled for non-selfhosts.
710 ifneq ($$(CTEST_DISABLE_NONSELFHOST_$(4)),)
711 # Test suite is disabled for this target.
712 CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4) := $$(CTEST_DISABLE_NONSELFHOST_$(4))
713 endif
714 endif
715 # Neither DISABLE nor DISABLE_NONSELFHOST is set ==> okay, run the test.
716 endif
717
718 ifeq ($$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)),)
719 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
720                 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
721                 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
722         @$$(call E, run $(4) [$(2)]: $$<)
723         $$(Q)touch $$@.start_time
724         $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
725                 $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
726                 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
727                 && touch -r $$@.start_time $$@ && rm $$@.start_time
728
729 else
730
731 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)):
732         @$$(call E, run $(4) [$(2)]: $$<)
733         @$$(call E, warning: tests disabled: $$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)))
734         touch $$@
735
736 endif
737
738 endef
739
740 CTEST_NAMES = rpass rpass-valgrind rpass-full cfail-full rfail cfail pfail \
741         bench perf debuginfo-gdb debuginfo-lldb codegen rustdocck
742
743 $(foreach host,$(CFG_HOST), \
744  $(eval $(foreach target,$(CFG_TARGET), \
745   $(eval $(foreach stage,$(STAGES), \
746    $(eval $(foreach name,$(CTEST_NAMES), \
747    $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
748
749 PRETTY_NAMES = pretty-rpass pretty-rpass-valgrind pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
750 PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
751 PRETTY_DEPS_pretty-rpass-valgrind = $(RPASS_VALGRIND_TESTS)
752 PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
753 PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
754 PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
755 PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
756 PRETTY_DIRNAME_pretty-rpass = run-pass
757 PRETTY_DIRNAME_pretty-rpass-valgrind = run-pass-valgrind
758 PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
759 PRETTY_DIRNAME_pretty-rfail = run-fail
760 PRETTY_DIRNAME_pretty-bench = bench
761 PRETTY_DIRNAME_pretty-pretty = pretty
762
763 define DEF_PRETTY_FULLDEPS
764 PRETTY_DEPS$(1)_T_$(2)_H_$(3)_pretty-rpass-full = $$(CSREQ$(1)_T_$(3)_H_$(3))
765 endef
766
767 $(foreach host,$(CFG_HOST), \
768  $(foreach target,$(CFG_TARGET), \
769   $(foreach stage,$(STAGES), \
770    $(eval $(call DEF_PRETTY_FULLDEPS,$(stage),$(target),$(host))))))
771
772 define DEF_RUN_PRETTY_TEST
773
774 PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
775                 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
776         --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
777         --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
778         --mode pretty
779
780 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
781
782 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
783                 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
784                 $$(PRETTY_DEPS_$(4)) \
785                 $$(PRETTY_DEPS$(1)_T_$(2)_H_$(3)_$(4))
786         @$$(call E, run pretty-rpass [$(2)]: $$<)
787         $$(Q)touch $$@.start_time
788         $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
789                 $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
790                 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
791                 && touch -r $$@.start_time $$@ && rm $$@.start_time
792
793 endef
794
795 $(foreach host,$(CFG_HOST), \
796  $(foreach target,$(CFG_TARGET), \
797   $(foreach stage,$(STAGES), \
798    $(foreach pretty-name,$(PRETTY_NAMES), \
799     $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
800
801
802 ######################################################################
803 # Crate & freestanding documentation tests
804 ######################################################################
805
806 define DEF_RUSTDOC
807 RUSTDOC_EXE_$(1)_T_$(2)_H_$(3) := $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
808 RUSTDOC_$(1)_T_$(2)_H_$(3) := $$(RPATH_VAR$(1)_T_$(2)_H_$(3)) $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
809 endef
810
811 $(foreach host,$(CFG_HOST), \
812  $(foreach target,$(CFG_TARGET), \
813   $(foreach stage,$(STAGES), \
814    $(eval $(call DEF_RUSTDOC,$(stage),$(target),$(host))))))
815
816 # Freestanding
817
818 define DEF_DOC_TEST
819
820 check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
821
822 # If NO_REBUILD is set then break the dependencies on everything but
823 # the source files so we can test documentation without rebuilding
824 # rustdoc etc.
825 ifeq ($(NO_REBUILD),)
826 DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
827         $$(DOCFILE_$(4)) \
828         $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
829         $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
830 else
831 DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(DOCFILE_$(4))
832 endif
833
834 ifeq ($(2),$$(CFG_BUILD))
835 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
836         @$$(call E, run doc-$(4) [$(2)])
837         $$(Q)touch $$@.start_time
838         $$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --cfg dox --test $$< \
839                 --test-args "$$(TESTARGS)" && \
840                 touch -r $$@.start_time $$@ && rm $$@.start_time
841 else
842 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)):
843         touch $$@
844 endif
845 endef
846
847 $(foreach host,$(CFG_HOST), \
848  $(foreach target,$(CFG_TARGET), \
849   $(foreach stage,$(STAGES), \
850    $(foreach docname,$(DOC_NAMES), \
851     $(eval $(call DEF_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
852
853 # Crates
854
855 define DEF_CRATE_DOC_TEST
856
857 # If NO_REBUILD is set then break the dependencies on everything but
858 # the source files so we can test crate documentation without
859 # rebuilding any of the parent crates.
860 ifeq ($(NO_REBUILD),)
861 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
862         $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
863         $$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
864         $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
865 else
866 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
867 endif
868
869 check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$(4)-exec: \
870         $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4))
871
872 ifeq ($(2),$$(CFG_BUILD))
873 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
874         @$$(call E, run doc-crate-$(4) [$(2)])
875         $$(Q)touch $$@.start_time
876         $$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
877             $$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
878                 $$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && \
879                 touch -r $$@.start_time $$@ && rm $$@.start_time
880 else
881 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)):
882         touch $$@
883 endif
884
885 endef
886
887 $(foreach host,$(CFG_HOST), \
888  $(foreach target,$(CFG_TARGET), \
889   $(foreach stage,$(STAGES), \
890    $(foreach crate,$(TEST_DOC_CRATES), \
891     $(eval $(call DEF_CRATE_DOC_TEST,$(stage),$(target),$(host),$(crate)))))))
892
893 ######################################################################
894 # Shortcut rules
895 ######################################################################
896
897 TEST_GROUPS = \
898         crates \
899         $(foreach crate,$(TEST_CRATES),$(crate)) \
900         $(foreach crate,$(TEST_DOC_CRATES),doc-crate-$(crate)) \
901         rpass \
902     rpass-valgrind \
903         rpass-full \
904         cfail-full \
905         rfail \
906         cfail \
907         pfail \
908         bench \
909         perf \
910         rmake \
911         rustdocck \
912         debuginfo-gdb \
913         debuginfo-lldb \
914         codegen \
915         doc \
916         $(foreach docname,$(DOC_NAMES),doc-$(docname)) \
917         pretty \
918         pretty-rpass \
919     pretty-rpass-valgrind \
920         pretty-rpass-full \
921         pretty-rfail \
922         pretty-bench \
923         pretty-pretty \
924         $(NULL)
925
926 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
927 check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
928 endef
929
930 $(foreach stage,$(STAGES), \
931  $(foreach target,$(CFG_TARGET), \
932   $(foreach host,$(CFG_HOST), \
933    $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
934
935 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
936 check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
937 endef
938
939 $(foreach stage,$(STAGES), \
940  $(foreach target,$(CFG_TARGET), \
941   $(foreach host,$(CFG_HOST), \
942    $(foreach group,$(TEST_GROUPS), \
943     $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
944
945 define DEF_CHECK_FOR_STAGE
946 check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD)
947 check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET), \
948                            check-stage$(1)-H-$$(target))
949 endef
950
951 $(foreach stage,$(STAGES), \
952  $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
953
954 define DEF_CHECK_FOR_STAGE_AND_GROUP
955 check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD)-$(2)
956 check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET), \
957                                check-stage$(1)-H-$$(target)-$(2))
958 endef
959
960 $(foreach stage,$(STAGES), \
961  $(foreach group,$(TEST_GROUPS), \
962   $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
963
964
965 define DEF_CHECK_FOR_STAGE_AND_HOSTS
966 check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET), \
967                            check-stage$(1)-T-$$(target)-H-$(2))
968 endef
969
970 $(foreach stage,$(STAGES), \
971  $(foreach host,$(CFG_HOST), \
972   $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
973
974 define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
975 check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET), \
976                                 check-stage$(1)-T-$$(target)-H-$(2)-$(3))
977 endef
978
979 $(foreach stage,$(STAGES), \
980  $(foreach host,$(CFG_HOST), \
981   $(foreach group,$(TEST_GROUPS), \
982    $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
983
984 define DEF_CHECK_DOC_FOR_STAGE
985 check-stage$(1)-docs: $$(foreach docname,$$(DOC_NAMES), \
986                        check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-$$(docname)) \
987                      $$(foreach crate,$$(TEST_DOC_CRATES), \
988                        check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-crate-$$(crate))
989 endef
990
991 $(foreach stage,$(STAGES), \
992  $(eval $(call DEF_CHECK_DOC_FOR_STAGE,$(stage))))
993
994 define DEF_CHECK_CRATE
995 check-$(1): check-stage2-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-$(1)-exec
996 endef
997
998 $(foreach crate,$(TEST_CRATES), \
999  $(eval $(call DEF_CHECK_CRATE,$(crate))))
1000
1001 ######################################################################
1002 # RMAKE rules
1003 ######################################################################
1004
1005 RMAKE_TESTS := $(shell ls -d $(S)src/test/run-make/*/)
1006 RMAKE_TESTS := $(RMAKE_TESTS:$(S)src/test/run-make/%/=%)
1007
1008 define DEF_RMAKE_FOR_T_H
1009 # $(1) the stage
1010 # $(2) target triple
1011 # $(3) host triple
1012
1013
1014 ifeq ($(2)$(3),$$(CFG_BUILD)$$(CFG_BUILD))
1015 check-stage$(1)-T-$(2)-H-$(3)-rmake-exec: \
1016                 $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake)
1017
1018 $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
1019                 $$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
1020         @touch $$@
1021
1022 $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1023                 $(S)src/test/run-make/%/Makefile \
1024                 $$(CSREQ$(1)_T_$(2)_H_$(3))
1025         @rm -rf $(3)/test/run-make/$$*
1026         @mkdir -p $(3)/test/run-make/$$*
1027         $$(Q)touch $$@.start_time
1028         $$(Q)$$(CFG_PYTHON) $(S)src/etc/maketest.py $$(dir $$<) \
1029         $$(MAKE) \
1030             $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
1031             $(3)/test/run-make/$$* \
1032             "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
1033             $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
1034             "$$(TESTNAME)" \
1035             $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
1036             "$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
1037             "$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
1038             $(1) \
1039             $$(S)
1040         @touch -r $$@.start_time $$@ && rm $$@.start_time
1041 else
1042 # FIXME #11094 - The above rule doesn't work right for multiple targets
1043 check-stage$(1)-T-$(2)-H-$(3)-rmake-exec:
1044         @true
1045
1046 endif
1047
1048
1049 endef
1050
1051 $(foreach stage,$(STAGES), \
1052  $(foreach target,$(CFG_TARGET), \
1053   $(foreach host,$(CFG_HOST), \
1054    $(eval $(call DEF_RMAKE_FOR_T_H,$(stage),$(target),$(host))))))