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