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