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