]> git.lizzy.rs Git - rust.git/blob - mk/tests.mk
auto merge of #14313 : kballard/rust/tuple_dotdot_match_ice, r=cmr
[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 =
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 PLEASE_BENCH
44   TEST_BENCH = --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/valgrind/valgrind.h \
231                        $(S)src/rt/valgrind/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/jemalloc' -v \
244                 | grep '^$(S)src/libuv' -v \
245                 | grep '^$(S)src/llvm' -v \
246                 | grep '^$(S)src/gyp' -v \
247                 | grep '^$(S)src/libbacktrace' -v \
248                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
249                 $(Q)find $(S)src/etc -name '*.py' \
250                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
251                 $(Q)find $(S)src/doc -name '*.js' \
252                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
253                 $(Q)find $(S)src/etc -name '*.sh' \
254                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
255                 $(Q)find $(S)src/etc -name '*.pl' \
256                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
257                 $(Q)find $(S)src/etc -name '*.c' \
258                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
259                 $(Q)find $(S)src/etc -name '*.h' \
260                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
261                 $(Q)echo $(ALL_CS) \
262                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
263                 $(Q)echo $(ALL_HS) \
264                 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
265                 $(Q)find $(S)src -type f -perm +111 \
266                     -not -name '*.rs' -and -not -name '*.py' \
267                     -and -not -name '*.sh' \
268                 | grep '^$(S)src/jemalloc' -v \
269                 | grep '^$(S)src/libuv' -v \
270                 | grep '^$(S)src/llvm' -v \
271                 | grep '^$(S)src/rt/hoedown' -v \
272                 | grep '^$(S)src/gyp' -v \
273                 | grep '^$(S)src/etc' -v \
274                 | grep '^$(S)src/doc' -v \
275                 | grep '^$(S)src/compiler-rt' -v \
276                 | grep '^$(S)src/libbacktrace' -v \
277                 | xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
278
279 endif
280
281
282 ######################################################################
283 # Sets of tests
284 ######################################################################
285
286 define DEF_TEST_SETS
287
288 check-stage$(1)-T-$(2)-H-$(3)-exec:                                     \
289         check-stage$(1)-T-$(2)-H-$(3)-rpass-exec                        \
290         check-stage$(1)-T-$(2)-H-$(3)-rfail-exec                        \
291         check-stage$(1)-T-$(2)-H-$(3)-cfail-exec                        \
292         check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec                   \
293         check-stage$(1)-T-$(2)-H-$(3)-cfail-full-exec                   \
294         check-stage$(1)-T-$(2)-H-$(3)-rmake-exec                        \
295         check-stage$(1)-T-$(2)-H-$(3)-crates-exec                       \
296         check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec                   \
297         check-stage$(1)-T-$(2)-H-$(3)-bench-exec                        \
298         check-stage$(1)-T-$(2)-H-$(3)-debuginfo-gdb-exec \
299         check-stage$(1)-T-$(2)-H-$(3)-debuginfo-lldb-exec \
300         check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
301         check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
302         check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
303
304 # Only test the compiler-dependent crates when the target is
305 # able to build a compiler (when the target triple is in the set of host triples)
306 ifneq ($$(findstring $(2),$$(CFG_HOST)),)
307
308 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
309         $$(foreach crate,$$(TEST_CRATES), \
310            check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
311
312 else
313
314 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
315         $$(foreach crate,$$(TEST_TARGET_CRATES), \
316            check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
317
318 endif
319
320 check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec: \
321         $$(foreach crate,$$(TEST_DOC_CRATES), \
322            check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$$(crate)-exec)
323
324 check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
325         $$(foreach docname,$$(DOCS), \
326            check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)
327
328 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
329         check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
330         check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec    \
331         check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
332         check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec \
333         check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
334
335 endef
336
337 $(foreach host,$(CFG_HOST), \
338  $(foreach target,$(CFG_TARGET), \
339   $(foreach stage,$(STAGES), \
340     $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
341
342
343 ######################################################################
344 # Crate testing
345 ######################################################################
346
347 define TEST_RUNNER
348
349 # If NO_REBUILD is set then break the dependencies on everything but
350 # the source files so we can test crates without rebuilding any of the
351 # parent crates.
352 ifeq ($(NO_REBUILD),)
353 TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
354                             $$(foreach crate,$$(TARGET_CRATES),\
355                                 $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
356                                 $$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))
357
358 # The regex crate depends on the regex_macros crate during testing, but it
359 # notably depend on the *host* regex_macros crate, not the target version.
360 # Additionally, this is not a dependency in stage1, only in stage2.
361 ifeq ($(4),regex)
362 ifneq ($(1),1)
363 TESTDEP_$(1)_$(2)_$(3)_$(4) += $$(TLIB$(1)_T_$(3)_H_$(3))/stamp.regex_macros
364 endif
365 endif
366
367 else
368 TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
369 endif
370
371 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): CFG_COMPILER_HOST_TRIPLE = $(2)
372 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)):                            \
373                 $$(CRATEFILE_$(4)) \
374                 $$(TESTDEP_$(1)_$(2)_$(3)_$(4))
375         @$$(call E, rustc: $$@)
376         $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test   \
377                 -L "$$(RT_OUTPUT_DIR_$(2))"             \
378                 -L "$$(LLVM_LIBDIR_$(2))"
379
380 endef
381
382 $(foreach host,$(CFG_HOST), \
383  $(eval $(foreach target,$(CFG_TARGET), \
384   $(eval $(foreach stage,$(STAGES), \
385    $(eval $(foreach crate,$(TEST_CRATES), \
386     $(eval $(call TEST_RUNNER,$(stage),$(target),$(host),$(crate))))))))))
387
388 define DEF_TEST_CRATE_RULES
389 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
390
391 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
392                 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
393         @$$(call E, run: $$<)
394         $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
395             --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
396             $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) \
397             && touch $$@
398 endef
399
400 define DEF_TEST_CRATE_RULES_arm-linux-androideabi
401 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
402
403 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
404                 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
405         @$$(call E, run: $$< via adb)
406         $$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
407         $$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
408                 ./$$(notdir $$<) \
409                 --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
410                 $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
411                 > tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
412         $$(Q)cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
413         $$(Q)touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
414         $$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
415         $$(Q)$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
416         $$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/$$(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) tmp/
417         @if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
418         then \
419                 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
420                 touch $$@; \
421         else \
422                 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
423                 exit 101; \
424         fi
425 endef
426
427 define DEF_TEST_CRATE_RULES_null
428 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
429
430 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
431                 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
432         @$$(call E, failing: no device for $$< )
433         false
434 endef
435
436 $(foreach host,$(CFG_HOST), \
437  $(foreach target,$(CFG_TARGET), \
438   $(foreach stage,$(STAGES), \
439    $(foreach crate, $(TEST_CRATES), \
440     $(if $(findstring $(target),$(CFG_BUILD)), \
441      $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
442      $(if $(findstring $(target),"arm-linux-androideabi"), \
443       $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
444        $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
445        $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
446       ), \
447       $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
448      ))))))
449
450 ######################################################################
451 # Rules for the compiletest tests (rpass, rfail, etc.)
452 ######################################################################
453
454 RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
455 RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
456 RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
457 RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
458 CFAIL_FULL_RC := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rc)
459 CFAIL_FULL_RS := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rs)
460 RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
461 RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
462 CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
463 CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
464 BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
465 PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
466 DEBUGINFO_GDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
467 DEBUGINFO_LLDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
468 CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
469 CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
470
471 # perf tests are the same as bench tests only they run under
472 # a performance monitor.
473 PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
474
475 RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
476 RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
477 CFAIL_FULL_TESTS := $(CFAIL_FULL_RC) $(CFAIL_FULL_RS)
478 RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
479 CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
480 BENCH_TESTS := $(BENCH_RS)
481 PERF_TESTS := $(PERF_RS)
482 PRETTY_TESTS := $(PRETTY_RS)
483 DEBUGINFO_GDB_TESTS := $(DEBUGINFO_GDB_RS)
484 DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
485 CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
486
487 CTEST_SRC_BASE_rpass = run-pass
488 CTEST_BUILD_BASE_rpass = run-pass
489 CTEST_MODE_rpass = run-pass
490 CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
491
492 CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
493 CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps
494 CTEST_MODE_rpass-full = run-pass
495 CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
496
497 CTEST_SRC_BASE_cfail-full = compile-fail-fulldeps
498 CTEST_BUILD_BASE_cfail-full = compile-fail-fulldeps
499 CTEST_MODE_cfail-full = compile-fail
500 CTEST_RUNTOOL_cfail-full = $(CTEST_RUNTOOL)
501
502 CTEST_SRC_BASE_rfail = run-fail
503 CTEST_BUILD_BASE_rfail = run-fail
504 CTEST_MODE_rfail = run-fail
505 CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
506
507 CTEST_SRC_BASE_cfail = compile-fail
508 CTEST_BUILD_BASE_cfail = compile-fail
509 CTEST_MODE_cfail = compile-fail
510 CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
511
512 CTEST_SRC_BASE_bench = bench
513 CTEST_BUILD_BASE_bench = bench
514 CTEST_MODE_bench = run-pass
515 CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
516
517 CTEST_SRC_BASE_perf = bench
518 CTEST_BUILD_BASE_perf = perf
519 CTEST_MODE_perf = run-pass
520 CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
521
522 CTEST_SRC_BASE_debuginfo-gdb = debuginfo
523 CTEST_BUILD_BASE_debuginfo-gdb = debuginfo-gdb
524 CTEST_MODE_debuginfo-gdb = debuginfo-gdb
525 CTEST_RUNTOOL_debuginfo-gdb = $(CTEST_RUNTOOL)
526
527 CTEST_SRC_BASE_debuginfo-lldb = debuginfo
528 CTEST_BUILD_BASE_debuginfo-lldb = debuginfo-lldb
529 CTEST_MODE_debuginfo-lldb = debuginfo-lldb
530 CTEST_RUNTOOL_debuginfo-lldb = $(CTEST_RUNTOOL)
531
532 CTEST_SRC_BASE_codegen = codegen
533 CTEST_BUILD_BASE_codegen = codegen
534 CTEST_MODE_codegen = codegen
535 CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)
536
537 # CTEST_DISABLE_$(TEST_GROUP), if set, will cause the test group to be
538 # disabled and the associated message to be printed as a warning
539 # during attempts to run those tests.
540
541 ifeq ($(CFG_GDB),)
542 CTEST_DISABLE_debuginfo-gdb = "no gdb found"
543 endif
544
545 ifeq ($(CFG_LLDB),)
546 CTEST_DISABLE_debuginfo-lldb = "no lldb found"
547 endif
548
549 # Completely disable LLDB tests for now
550 CTEST_DISABLE_debuginfo-lldb = "LLDB tests are not enabled yet"
551
552 ifeq ($(CFG_CLANG),)
553 CTEST_DISABLE_codegen = "no clang found"
554 endif
555
556 ifeq ($(CFG_OSTYPE),apple-darwin)
557 CTEST_DISABLE_debuginfo-gdb = "gdb on darwing needs root"
558 endif
559
560 # CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that
561 # test group to be disabled *unless* the target is able to build a
562 # compiler (i.e. when the target triple is in the set of of host
563 # triples).  The associated message will be printed as a warning
564 # during attempts to run those tests.
565
566 define DEF_CTEST_VARS
567
568 # All the per-stage build rules you might want to call from the
569 # command line.
570 #
571 # $(1) is the stage number
572 # $(2) is the target triple to test
573 # $(3) is the host triple to test
574
575 # Prerequisites for compiletest tests
576 TEST_SREQ$(1)_T_$(2)_H_$(3) = \
577         $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
578         $$(SREQ$(1)_T_$(2)_H_$(3))
579
580 # Rules for the cfail/rfail/rpass/bench/perf test runner
581
582 # The tests select when to use debug configuration on their own;
583 # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
584 CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
585
586 # The tests can not be optimized while the rest of the compiler is optimized, so
587 # filter out the optimization (if any) from rustc and then figure out if we need
588 # to be optimized
589 CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
590 ifndef CFG_DISABLE_OPTIMIZE_TESTS
591 CTEST_RUSTC_FLAGS += -O
592 endif
593
594 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) :=                                          \
595                 --compile-lib-path $$(HLIB$(1)_H_$(3))                          \
596         --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3))                       \
597         --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))                        \
598         --clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
599         --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
600         --aux-base $$(S)src/test/auxiliary/                 \
601         --stage-id stage$(1)-$(2)                                                       \
602         --target $(2)                                       \
603         --host $(3)                                       \
604         --android-cross-path=$(CFG_ANDROID_CROSS_PATH)    \
605         --adb-path=$(CFG_ADB)                          \
606         --adb-test-dir=$(CFG_ADB_TEST_DIR)                  \
607         --host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
608         --lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
609         --target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
610         $$(CTEST_TESTARGS)
611
612 CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
613 CTEST_DEPS_rpass-full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
614 CTEST_DEPS_cfail-full_$(1)-T-$(2)-H-$(3) = $$(CFAIL_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
615 CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
616 CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
617 CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
618 CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
619 CTEST_DEPS_debuginfo-gdb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_GDB_TESTS)
620 CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS)
621 CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
622
623 endef
624
625 $(foreach host,$(CFG_HOST), \
626  $(eval $(foreach target,$(CFG_TARGET), \
627   $(eval $(foreach stage,$(STAGES), \
628    $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
629
630 define DEF_RUN_COMPILETEST
631
632 CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
633         $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
634         --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
635         --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
636         --ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
637         --mode $$(CTEST_MODE_$(4)) \
638         $$(CTEST_RUNTOOL_$(4))
639
640 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
641
642 # CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)
643 # Goal: leave this variable as empty string if we should run the test.
644 # Otherwise, set it to the reason we are not running the test.
645 # (Encoded as a separate variable because GNU make does not have a
646 # good way to express OR on ifeq commands)
647
648 ifneq ($$(CTEST_DISABLE_$(4)),)
649 # Test suite is disabled for all configured targets.
650 CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4) := $$(CTEST_DISABLE_$(4))
651 else
652 # else, check if non-self-hosted target (i.e. target not-in hosts) ...
653 ifeq ($$(findstring $(2),$$(CFG_HOST)),)
654 # ... if so, then check if this test suite is disabled for non-selfhosts.
655 ifneq ($$(CTEST_DISABLE_NONSELFHOST_$(4)),)
656 # Test suite is disabled for this target.
657 CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4) := $$(CTEST_DISABLE_NONSELFHOST_$(4))
658 endif
659 endif
660 # Neither DISABLE nor DISABLE_NONSELFHOST is set ==> okay, run the test.
661 endif
662
663 ifeq ($$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)),)
664 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
665                 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
666                 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
667         @$$(call E, run $(4) [$(2)]: $$<)
668         $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
669                 $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
670                 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
671                 && touch $$@
672
673 else
674
675 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)):
676         @$$(call E, run $(4) [$(2)]: $$<)
677         @$$(call E, warning: tests disabled: $$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)))
678         touch $$@
679
680 endif
681
682 endef
683
684 CTEST_NAMES = rpass rpass-full cfail-full rfail cfail bench perf debuginfo-gdb debuginfo-lldb codegen
685
686 $(foreach host,$(CFG_HOST), \
687  $(eval $(foreach target,$(CFG_TARGET), \
688   $(eval $(foreach stage,$(STAGES), \
689    $(eval $(foreach name,$(CTEST_NAMES), \
690    $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
691
692 PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
693 PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
694 PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
695 PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
696 PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
697 PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
698 PRETTY_DIRNAME_pretty-rpass = run-pass
699 PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
700 PRETTY_DIRNAME_pretty-rfail = run-fail
701 PRETTY_DIRNAME_pretty-bench = bench
702 PRETTY_DIRNAME_pretty-pretty = pretty
703
704 define DEF_RUN_PRETTY_TEST
705
706 PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) :=                   \
707                 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
708         --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
709         --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
710         --mode pretty
711
712 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
713
714 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
715                 $$(TEST_SREQ$(1)_T_$(2)_H_$(3))         \
716                 $$(PRETTY_DEPS_$(4))
717         @$$(call E, run pretty-rpass [$(2)]: $$<)
718         $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
719                 $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
720                 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
721                 && touch $$@
722
723 endef
724
725 $(foreach host,$(CFG_HOST), \
726  $(foreach target,$(CFG_TARGET), \
727   $(foreach stage,$(STAGES), \
728    $(foreach pretty-name,$(PRETTY_NAMES), \
729     $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
730
731
732 ######################################################################
733 # Crate & freestanding documentation tests
734 ######################################################################
735
736 define DEF_RUSTDOC
737 RUSTDOC_EXE_$(1)_T_$(2)_H_$(3) := $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
738 RUSTDOC_$(1)_T_$(2)_H_$(3) := $$(RPATH_VAR$(1)_T_$(2)_H_$(3)) $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
739 endef
740
741 $(foreach host,$(CFG_HOST), \
742  $(foreach target,$(CFG_TARGET), \
743   $(foreach stage,$(STAGES), \
744    $(eval $(call DEF_RUSTDOC,$(stage),$(target),$(host))))))
745
746 # Freestanding
747
748 define DEF_DOC_TEST
749
750 check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
751
752 # If NO_REBUILD is set then break the dependencies on everything but
753 # the source files so we can test documentation without rebuilding
754 # rustdoc etc.
755 ifeq ($(NO_REBUILD),)
756 DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
757         $$(D)/$(4).md \
758         $$(TEST_SREQ$(1)_T_$(2)_H_$(3))                         \
759         $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
760 else
761 DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(D)/$(4).md
762 endif
763
764 ifeq ($(2),$$(CFG_BUILD))
765 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
766         @$$(call E, run doc-$(4) [$(2)])
767         $$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --cfg dox --test $$< --test-args "$$(TESTARGS)" && touch $$@
768 else
769 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)):
770         touch $$@
771 endif
772 endef
773
774 $(foreach host,$(CFG_HOST), \
775  $(foreach target,$(CFG_TARGET), \
776   $(foreach stage,$(STAGES), \
777    $(foreach docname,$(DOCS), \
778     $(eval $(call DEF_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
779
780 # Crates
781
782 define DEF_CRATE_DOC_TEST
783
784 # If NO_REBUILD is set then break the dependencies on everything but
785 # the source files so we can test crate documentation without
786 # rebuilding any of the parent crates.
787 ifeq ($(NO_REBUILD),)
788 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
789         $$(TEST_SREQ$(1)_T_$(2)_H_$(3))                         \
790         $$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))              \
791         $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
792 else
793 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
794 endif
795
796 # (Issues #13732, #13983, #14000) The doc for the regex crate includes
797 # uses of the `regex!` macro from the regex_macros crate.  There is
798 # normally a dependence injected that makes the target's regex depend
799 # upon the host's regex_macros (see #13845), but that dependency
800 # injection is currently skipped for stage1 as a special case.
801 #
802 # Therefore, as a further special case, this conditional skips
803 # attempting to run the doc tests for the regex crate atop stage1,
804 # (since there is no regex_macros crate for the stage1 rustc to load).
805 #
806 # (Another approach for solving this would be to inject the desired
807 # dependence for stage1 as well, by setting things up to generate a
808 # regex_macros crate that was compatible with the stage1 rustc and
809 # thus re-enable our ability to run this test.)
810 ifeq (stage$(1)-crate-$(4),stage1-crate-regex)
811 check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$(4)-exec:
812         @$$(call E, skipping doc-crate-$(4) as it uses macros and cannot run at stage$(1))
813 else
814 check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$(4)-exec: \
815         $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4))
816 endif
817
818 ifeq ($(2),$$(CFG_BUILD))
819 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
820         @$$(call E, run doc-crate-$(4) [$(2)])
821         $$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test \
822                 $$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@
823 else
824 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)):
825         touch $$@
826 endif
827
828 endef
829
830 $(foreach host,$(CFG_HOST), \
831  $(foreach target,$(CFG_TARGET), \
832   $(foreach stage,$(STAGES), \
833    $(foreach crate,$(TEST_DOC_CRATES), \
834     $(eval $(call DEF_CRATE_DOC_TEST,$(stage),$(target),$(host),$(crate)))))))
835
836 ######################################################################
837 # Shortcut rules
838 ######################################################################
839
840 TEST_GROUPS = \
841         crates \
842         $(foreach crate,$(TEST_CRATES),$(crate)) \
843         $(foreach crate,$(TEST_DOC_CRATES),doc-crate-$(crate)) \
844         rpass \
845         rpass-full \
846         cfail-full \
847         rfail \
848         cfail \
849         bench \
850         perf \
851         rmake \
852         debuginfo-gdb \
853         debuginfo-lldb \
854         codegen \
855         doc \
856         $(foreach docname,$(DOCS),doc-$(docname)) \
857         pretty \
858         pretty-rpass \
859         pretty-rpass-full \
860         pretty-rfail \
861         pretty-bench \
862         pretty-pretty \
863         $(NULL)
864
865 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
866 check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
867 endef
868
869 $(foreach stage,$(STAGES), \
870  $(foreach target,$(CFG_TARGET), \
871   $(foreach host,$(CFG_HOST), \
872    $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
873
874 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
875 check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
876 endef
877
878 $(foreach stage,$(STAGES), \
879  $(foreach target,$(CFG_TARGET), \
880   $(foreach host,$(CFG_HOST), \
881    $(foreach group,$(TEST_GROUPS), \
882     $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
883
884 define DEF_CHECK_FOR_STAGE
885 check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD)
886 check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET), \
887                            check-stage$(1)-H-$$(target))
888 endef
889
890 $(foreach stage,$(STAGES), \
891  $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
892
893 define DEF_CHECK_FOR_STAGE_AND_GROUP
894 check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD)-$(2)
895 check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET), \
896                                check-stage$(1)-H-$$(target)-$(2))
897 endef
898
899 $(foreach stage,$(STAGES), \
900  $(foreach group,$(TEST_GROUPS), \
901   $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
902
903
904 define DEF_CHECK_FOR_STAGE_AND_HOSTS
905 check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET), \
906                            check-stage$(1)-T-$$(target)-H-$(2))
907 endef
908
909 $(foreach stage,$(STAGES), \
910  $(foreach host,$(CFG_HOST), \
911   $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
912
913 define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
914 check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET), \
915                                 check-stage$(1)-T-$$(target)-H-$(2)-$(3))
916 endef
917
918 $(foreach stage,$(STAGES), \
919  $(foreach host,$(CFG_HOST), \
920   $(foreach group,$(TEST_GROUPS), \
921    $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
922
923 define DEF_CHECK_DOC_FOR_STAGE
924 check-stage$(1)-docs: $$(foreach docname,$$(DOCS),\
925                        check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-$$(docname)) \
926                      $$(foreach crate,$$(TEST_DOC_CRATES),\
927                        check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-crate-$$(crate))
928 endef
929
930 $(foreach stage,$(STAGES), \
931  $(eval $(call DEF_CHECK_DOC_FOR_STAGE,$(stage))))
932
933 define DEF_CHECK_CRATE
934 check-$(1): check-stage2-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-$(1)-exec
935 endef
936
937 $(foreach crate,$(TEST_CRATES), \
938  $(eval $(call DEF_CHECK_CRATE,$(crate))))
939
940 ######################################################################
941 # RMAKE rules
942 ######################################################################
943
944 RMAKE_TESTS := $(shell ls -d $(S)src/test/run-make/*/)
945 RMAKE_TESTS := $(RMAKE_TESTS:$(S)src/test/run-make/%/=%)
946
947 define DEF_RMAKE_FOR_T_H
948 # $(1) the stage
949 # $(2) target triple
950 # $(3) host triple
951
952
953 ifeq ($(2)$(3),$$(CFG_BUILD)$$(CFG_BUILD))
954 check-stage$(1)-T-$(2)-H-$(3)-rmake-exec: \
955                 $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake)
956
957 $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
958                 $$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
959         @touch $$@
960
961 $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
962                 $(S)src/test/run-make/%/Makefile \
963                 $$(CSREQ$(1)_T_$(2)_H_$(3))
964         @rm -rf $(3)/test/run-make/$$*
965         @mkdir -p $(3)/test/run-make/$$*
966         $$(Q)$$(CFG_PYTHON) $(S)src/etc/maketest.py $$(dir $$<) \
967         $$(MAKE) \
968             $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
969             $(3)/test/run-make/$$* \
970             "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
971             $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
972             "$$(TESTNAME)" \
973             $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
974             "$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
975             "$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
976             $(1)
977         @touch $$@
978 else
979 # FIXME #11094 - The above rule doesn't work right for multiple targets
980 check-stage$(1)-T-$(2)-H-$(3)-rmake-exec:
981         @true
982
983 endif
984
985
986 endef
987
988 $(foreach stage,$(STAGES), \
989  $(foreach target,$(CFG_TARGET), \
990   $(foreach host,$(CFG_HOST), \
991    $(eval $(call DEF_RMAKE_FOR_T_H,$(stage),$(target),$(host))))))