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