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