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