]> git.proxmox.com Git - rustc.git/blob - mk/tests.mk
Merge tag 'upstream-tar/0.7'
[rustc.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 = std extra
18 TEST_HOST_CRATES = syntax rustc rustdoc rusti rust rustpkg
19 TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
20
21 # Markdown files under doc/ that should have their code extracted and run
22 DOC_TEST_NAMES = tutorial tutorial-ffi tutorial-macros tutorial-borrowed-ptr tutorial-tasks rust
23
24 ######################################################################
25 # Environment configuration
26 ######################################################################
27
28 # The arguments to all test runners
29 ifdef TESTNAME
30 TESTARGS += $(TESTNAME)
31 endif
32
33 ifdef CHECK_XFAILS
34 TESTARGS += --ignored
35 endif
36
37 # Arguments to the cfail/rfail/rpass/bench tests
38 ifdef CFG_VALGRIND
39 CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
40 endif
41
42 # Arguments to the perf tests
43 ifdef CFG_PERF_TOOL
44 CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
45 endif
46
47 CTEST_TESTARGS := $(TESTARGS)
48
49 ifdef VERBOSE
50 CTEST_TESTARGS += --verbose
51 endif
52
53 # If we're running perf then set this environment variable
54 # to put the benchmarks into 'hard mode'
55 ifeq ($(MAKECMDGOALS),perf)
56 RUST_BENCH=1
57 export RUST_BENCH
58 endif
59
60 TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
61 TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
62
63 define DEF_TARGET_COMMANDS
64
65 ifdef CFG_UNIXY_$(1)
66 CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
67 endif
68
69 ifdef CFG_WINDOWSY_$(1)
70 CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)/$$(2)/$$(strip \
71 $$(if $$(findstring stage0,$$(1)), \
72 stage0/$$(CFG_LIBDIR), \
73 $$(if $$(findstring stage1,$$(1)), \
74 stage1/$$(CFG_LIBDIR), \
75 $$(if $$(findstring stage2,$$(1)), \
76 stage2/$$(CFG_LIBDIR), \
77 $$(if $$(findstring stage3,$$(1)), \
78 stage3/$$(CFG_LIBDIR), \
79 )))))/rustc/$$(CFG_BUILD_TRIPLE)/$$(CFG_LIBDIR)
80 CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
81 endif
82
83 # Run the compiletest runner itself under valgrind
84 ifdef CTEST_VALGRIND
85 CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD_TRIPLE),$$(2),$$(3))
86 else
87 CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD_TRIPLE),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
88 endif
89
90 endef
91
92 $(foreach target,$(CFG_TARGET_TRIPLES), \
93 $(eval $(call DEF_TARGET_COMMANDS,$(target))))
94
95 # Target platform specific variables
96 # for arm-linux-androidabi
97 define DEF_ADB_DEVICE_STATUS
98 CFG_ADB_DEVICE_STATUS=$(1)
99 endef
100
101 $(foreach target,$(CFG_TARGET_TRIPLES), \
102 $(if $(findstring $(target),"arm-linux-androideabi"), \
103 $(if $(findstring adb,$(CFG_ADB)), \
104 $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
105 $(info check: $(target) test enabled \
106 $(info check: android device attached) \
107 $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
108 $(info check: $(target) test disabled \
109 $(info check: android device not attached) \
110 $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
111 ), \
112 $(info check: $(target) test disabled \
113 $(info check: adb not found) \
114 $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
115 ), \
116 ) \
117 )
118
119 ifeq ($(CFG_ADB_DEVICE_STATUS),true)
120 CFG_ADB_TEST_DIR=/data/tmp
121
122 $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
123 $(shell adb remount 1>/dev/null) \
124 $(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125 $(shell adb shell rm -rf $(CFG_ADB_TEST_DIR)/* 1>/dev/null) \
126 $(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
127 $(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
128 $(CFG_ADB_TEST_DIR) 1>/dev/null) \
129 $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
130 $(CFG_ADB_TEST_DIR)) \
131 $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
132 $(CFG_ADB_TEST_DIR)) \
133 $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
134 $(CFG_ADB_TEST_DIR)) \
135 )
136 else
137 CFG_ADB_TEST_DIR=
138 endif
139
140
141 ######################################################################
142 # Main test targets
143 ######################################################################
144
145 check: cleantestlibs cleantmptestlogs tidy all check-stage2
146 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
147
148 check-notidy: cleantestlibs cleantmptestlogs all check-stage2
149 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
150
151 check-full: cleantestlibs cleantmptestlogs tidy \
152 all check-stage1 check-stage2 check-stage3
153 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
154
155 check-test: cleantestlibs cleantmptestlogs all check-stage2-rfail
156 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
157
158 check-lite: cleantestlibs cleantmptestlogs \
159 check-stage2-std check-stage2-extra check-stage2-rpass \
160 check-stage2-rfail check-stage2-cfail
161 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
162
163 .PHONY: cleantmptestlogs cleantestlibs
164
165 cleantmptestlogs:
166 $(Q)rm -f tmp/*.log
167
168 cleantestlibs:
169 $(Q)find $(CFG_BUILD_TRIPLE)/test \
170 -name '*.[odasS]' -o \
171 -name '*.so' -o \
172 -name '*.dylib' -o \
173 -name '*.dll' -o \
174 -name '*.def' -o \
175 -name '*.bc' -o \
176 -name '*.dSYM' -o \
177 -name '*.libaux' -o \
178 -name '*.out' -o \
179 -name '*.err' -o \
180 -name '*.debugger.script' \
181 | xargs rm -rf
182
183
184 ######################################################################
185 # Tidy
186 ######################################################################
187
188 ifdef CFG_NOTIDY
189 tidy:
190 else
191
192 ALL_CS := $(wildcard $(S)src/rt/*.cpp \
193 $(S)src/rt/*/*.cpp \
194 $(S)src/rt/*/*/*.cpp \
195 $(S)srcrustllvm/*.cpp)
196 ALL_CS := $(filter-out $(S)src/rt/bigint/bigint_ext.cpp \
197 $(S)src/rt/bigint/bigint_int.cpp \
198 $(S)src/rt/miniz.cpp \
199 $(S)src/rt/linenoise/linenoise.c \
200 $(S)src/rt/linenoise/utf8.c \
201 ,$(ALL_CS))
202 ALL_HS := $(wildcard $(S)src/rt/*.h \
203 $(S)src/rt/*/*.h \
204 $(S)src/rt/*/*/*.h \
205 $(S)srcrustllvm/*.h)
206 ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
207 $(S)src/rt/vg/memcheck.h \
208 $(S)src/rt/uthash/uthash.h \
209 $(S)src/rt/uthash/utlist.h \
210 $(S)src/rt/msvc/typeof.h \
211 $(S)src/rt/msvc/stdint.h \
212 $(S)src/rt/msvc/inttypes.h \
213 $(S)src/rt/bigint/bigint.h \
214 $(S)src/rt/linenoise/linenoise.h \
215 $(S)src/rt/linenoise/utf8.h \
216 ,$(ALL_HS))
217
218 # Run the tidy script in multiple parts to avoid huge 'echo' commands
219 tidy:
220 @$(call E, check: formatting)
221 $(Q)find $(S)src -name '*.r[sc]' \
222 | grep '^$(S)src/test' -v \
223 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
224 $(Q)find $(S)src/etc -name '*.py' \
225 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
226 $(Q)echo $(ALL_CS) \
227 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
228 $(Q)echo $(ALL_HS) \
229 | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
230
231 endif
232
233
234 ######################################################################
235 # Sets of tests
236 ######################################################################
237
238 define DEF_TEST_SETS
239
240 check-stage$(1)-T-$(2)-H-$(3)-exec: \
241 check-stage$(1)-T-$(2)-H-$(3)-rpass-exec \
242 check-stage$(1)-T-$(2)-H-$(3)-rfail-exec \
243 check-stage$(1)-T-$(2)-H-$(3)-cfail-exec \
244 check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
245 check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
246 check-stage$(1)-T-$(2)-H-$(3)-bench-exec \
247 check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \
248 check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
249 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
250
251 # Only test the compiler-dependent crates when the target is
252 # able to build a compiler (when the target triple is in the set of host triples)
253 ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
254
255 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
256 $$(foreach crate,$$(TEST_CRATES), \
257 check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
258
259 else
260
261 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
262 $$(foreach crate,$$(TEST_TARGET_CRATES), \
263 check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
264
265 endif
266
267 check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
268 $$(foreach docname,$$(DOC_TEST_NAMES), \
269 check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)
270
271 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
272 check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
273 check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec \
274 check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
275 check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec \
276 check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
277
278 endef
279
280 $(foreach host,$(CFG_HOST_TRIPLES), \
281 $(foreach target,$(CFG_TARGET_TRIPLES), \
282 $(foreach stage,$(STAGES), \
283 $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
284
285
286 ######################################################################
287 # Crate testing
288 ######################################################################
289
290 define TEST_RUNNER
291
292 # If NO_REBUILD is set then break the dependencies on extra so we can
293 # test crates without rebuilding std and extra first
294 ifeq ($(NO_REBUILD),)
295 STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
296 else
297 STDTESTDEP_$(1)_$(2)_$(3) =
298 endif
299
300 $(3)/stage$(1)/test/stdtest-$(2)$$(X_$(2)): \
301 $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
302 $$(STDTESTDEP_$(1)_$(2)_$(3))
303 @$$(call E, compile_and_link: $$@)
304 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
305
306 $(3)/stage$(1)/test/extratest-$(2)$$(X_$(2)): \
307 $$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
308 $$(STDTESTDEP_$(1)_$(2)_$(3))
309 @$$(call E, compile_and_link: $$@)
310 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
311
312 $(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)): \
313 $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
314 $$(STDTESTDEP_$(1)_$(2)_$(3))
315 @$$(call E, compile_and_link: $$@)
316 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
317
318 $(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER_TRIPLE = $(2)
319 $(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): \
320 $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
321 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
322 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2))
323 @$$(call E, compile_and_link: $$@)
324 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
325
326 $(3)/stage$(1)/test/rustpkgtest-$(2)$$(X_$(2)): \
327 $$(RUSTPKG_LIB) $$(RUSTPKG_INPUTS) \
328 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
329 @$$(call E, compile_and_link: $$@)
330 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
331
332 $(3)/stage$(1)/test/rustitest-$(2)$$(X_$(2)): \
333 $$(RUSTI_LIB) $$(RUSTI_INPUTS) \
334 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
335 @$$(call E, compile_and_link: $$@)
336 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
337
338 $(3)/stage$(1)/test/rusttest-$(2)$$(X_$(2)): \
339 $$(RUST_LIB) $$(RUST_INPUTS) \
340 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
341 @$$(call E, compile_and_link: $$@)
342 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
343
344 $(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)): \
345 $$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
346 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
347 @$$(call E, compile_and_link: $$@)
348 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
349
350 endef
351
352 $(foreach host,$(CFG_HOST_TRIPLES), \
353 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
354 $(eval $(foreach stage,$(STAGES), \
355 $(eval $(call TEST_RUNNER,$(stage),$(target),$(host))))))))
356
357 define DEF_TEST_CRATE_RULES
358 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
359
360 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
361 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
362 @$$(call E, run: $$<)
363 $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
364 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
365 && touch $$@
366 endef
367
368 define DEF_TEST_CRATE_RULES_arm-linux-androideabi
369 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
370
371 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
372 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
373 @$$(call E, run: $$< via adb)
374 @$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
375 @$(CFG_ADB) shell LD_LIBRARY_PATH=$(CFG_ADB_TEST_DIR) \
376 $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
377 --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \
378 tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
379 @cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
380 @touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
381 @$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
382 @$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
383 @if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
384 then \
385 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
386 touch $$@; \
387 else \
388 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
389 exit 101; \
390 fi
391 endef
392
393 define DEF_TEST_CRATE_RULES_null
394 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
395
396 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
397 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
398 @$$(call E, run: skipped $$< )
399 @touch $$@
400 endef
401
402 $(foreach host,$(CFG_HOST_TRIPLES), \
403 $(foreach target,$(CFG_TARGET_TRIPLES), \
404 $(foreach stage,$(STAGES), \
405 $(foreach crate, $(TEST_CRATES), \
406 $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
407 $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
408 $(if $(findstring $(target),"arm-linux-androideabi"), \
409 $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
410 $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
411 $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
412 ), \
413 $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
414 ))))))
415
416
417 ######################################################################
418 # Rules for the compiletest tests (rpass, rfail, etc.)
419 ######################################################################
420
421 RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
422 RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
423 RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
424 RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
425 RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
426 RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
427 CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
428 CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
429 BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
430 PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
431 DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
432
433 # perf tests are the same as bench tests only they run under
434 # a performance monitor.
435 PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
436
437 RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
438 RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
439 RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
440 CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
441 BENCH_TESTS := $(BENCH_RS)
442 PERF_TESTS := $(PERF_RS)
443 PRETTY_TESTS := $(PRETTY_RS)
444 DEBUGINFO_TESTS := $(DEBUGINFO_RS)
445
446 CTEST_SRC_BASE_rpass = run-pass
447 CTEST_BUILD_BASE_rpass = run-pass
448 CTEST_MODE_rpass = run-pass
449 CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
450
451 CTEST_SRC_BASE_rpass-full = run-pass-full
452 CTEST_BUILD_BASE_rpass-full = run-pass-full
453 CTEST_MODE_rpass-full = run-pass
454 CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
455
456 CTEST_SRC_BASE_rfail = run-fail
457 CTEST_BUILD_BASE_rfail = run-fail
458 CTEST_MODE_rfail = run-fail
459 CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
460
461 CTEST_SRC_BASE_cfail = compile-fail
462 CTEST_BUILD_BASE_cfail = compile-fail
463 CTEST_MODE_cfail = compile-fail
464 CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
465
466 CTEST_SRC_BASE_bench = bench
467 CTEST_BUILD_BASE_bench = bench
468 CTEST_MODE_bench = run-pass
469 CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
470
471 CTEST_SRC_BASE_perf = bench
472 CTEST_BUILD_BASE_perf = perf
473 CTEST_MODE_perf = run-pass
474 CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
475
476 CTEST_SRC_BASE_debuginfo = debug-info
477 CTEST_BUILD_BASE_debuginfo = debug-info
478 CTEST_MODE_debuginfo = debug-info
479 CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)
480
481 ifeq ($(CFG_GDB),)
482 CTEST_DISABLE_debuginfo = "no gdb found"
483 endif
484
485 ifeq ($(CFG_OSTYPE),apple-darwin)
486 CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
487 endif
488
489 define DEF_CTEST_VARS
490
491 # All the per-stage build rules you might want to call from the
492 # command line.
493 #
494 # $(1) is the stage number
495 # $(2) is the target triple to test
496 # $(3) is the host triple to test
497
498 # Prerequisites for compiletest tests
499 TEST_SREQ$(1)_T_$(2)_H_$(3) = \
500 $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
501 $$(SREQ$(1)_T_$(2)_H_$(3))
502
503 # Rules for the cfail/rfail/rpass/bench/perf test runner
504
505 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
506 --compile-lib-path $$(HLIB$(1)_H_$(3)) \
507 --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
508 --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
509 --aux-base $$(S)src/test/auxiliary/ \
510 --stage-id stage$(1)-$(2) \
511 --target $(2) \
512 --adb-path=$(CFG_ADB) \
513 --adb-test-dir=$(CFG_ADB_TEST_DIR) \
514 --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
515 $$(CTEST_TESTARGS)
516
517 CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
518 CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
519 CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
520 CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
521 CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
522 CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
523 CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
524
525 endef
526
527 $(foreach host,$(CFG_HOST_TRIPLES), \
528 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
529 $(eval $(foreach stage,$(STAGES), \
530 $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
531
532 define DEF_RUN_COMPILETEST
533
534 CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
535 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
536 --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
537 --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
538 --mode $$(CTEST_MODE_$(4)) \
539 $$(CTEST_RUNTOOL_$(4))
540
541 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
542
543 ifeq ($$(CTEST_DISABLE_$(4)),)
544
545 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
546 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
547 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
548 @$$(call E, run $(4) [$(2)]: $$<)
549 $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
550 $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
551 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
552 && touch $$@
553
554 else
555
556 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
557 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
558 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
559 @$$(call E, run $(4) [$(2)]: $$<)
560 @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
561 touch $$@
562
563 endif
564
565 endef
566
567 CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo
568
569 $(foreach host,$(CFG_HOST_TRIPLES), \
570 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
571 $(eval $(foreach stage,$(STAGES), \
572 $(eval $(foreach name,$(CTEST_NAMES), \
573 $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
574
575 PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
576 PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
577 PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
578 PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
579 PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
580 PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
581 PRETTY_DIRNAME_pretty-rpass = run-pass
582 PRETTY_DIRNAME_pretty-rpass-full = run-pass-full
583 PRETTY_DIRNAME_pretty-rfail = run-fail
584 PRETTY_DIRNAME_pretty-bench = bench
585 PRETTY_DIRNAME_pretty-pretty = pretty
586
587 define DEF_RUN_PRETTY_TEST
588
589 PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
590 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
591 --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
592 --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
593 --mode pretty
594
595 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
596
597 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
598 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
599 $$(PRETTY_DEPS_$(4))
600 @$$(call E, run pretty-rpass [$(2)]: $$<)
601 $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
602 $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
603 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
604 && touch $$@
605
606 endef
607
608 $(foreach host,$(CFG_HOST_TRIPLES), \
609 $(foreach target,$(CFG_TARGET_TRIPLES), \
610 $(foreach stage,$(STAGES), \
611 $(foreach pretty-name,$(PRETTY_NAMES), \
612 $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
613
614 define DEF_RUN_DOC_TEST
615
616 DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4) := \
617 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
618 --src-base $(3)/test/doc-$(4)/ \
619 --build-base $(3)/test/doc-$(4)/ \
620 --mode run-pass
621
622 check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
623
624 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
625 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
626 doc-$(4)-extract$(3)
627 @$$(call E, run doc-$(4) [$(2)]: $$<)
628 $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
629 $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
630 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \
631 && touch $$@
632
633 endef
634
635 $(foreach host,$(CFG_HOST_TRIPLES), \
636 $(foreach target,$(CFG_TARGET_TRIPLES), \
637 $(foreach stage,$(STAGES), \
638 $(foreach docname,$(DOC_TEST_NAMES), \
639 $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
640
641
642 ######################################################################
643 # Extracting tests for docs
644 ######################################################################
645
646 EXTRACT_TESTS := "$(CFG_PYTHON)" $(S)src/etc/extract-tests.py
647
648 define DEF_DOC_TEST_HOST
649
650 doc-$(2)-extract$(1):
651 @$$(call E, extract: $(2) tests)
652 $$(Q)rm -f $(1)/test/doc-$(2)/*.rs
653 $$(Q)$$(EXTRACT_TESTS) $$(S)doc/$(2).md $(1)/test/doc-$(2)
654
655 endef
656
657 $(foreach host,$(CFG_HOST_TRIPLES), \
658 $(foreach docname,$(DOC_TEST_NAMES), \
659 $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
660
661
662 ######################################################################
663 # Shortcut rules
664 ######################################################################
665
666 TEST_GROUPS = \
667 crates \
668 $(foreach crate,$(TEST_CRATES),$(crate)) \
669 rpass \
670 rpass-full \
671 rfail \
672 cfail \
673 bench \
674 perf \
675 debuginfo \
676 doc \
677 $(foreach docname,$(DOC_TEST_NAMES),doc-$(docname)) \
678 pretty \
679 pretty-rpass \
680 pretty-rpass-full \
681 pretty-rfail \
682 pretty-bench \
683 pretty-pretty \
684 $(NULL)
685
686 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
687 check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
688 endef
689
690 $(foreach stage,$(STAGES), \
691 $(foreach target,$(CFG_TARGET_TRIPLES), \
692 $(foreach host,$(CFG_HOST_TRIPLES), \
693 $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
694
695 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
696 check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
697 endef
698
699 $(foreach stage,$(STAGES), \
700 $(foreach target,$(CFG_TARGET_TRIPLES), \
701 $(foreach host,$(CFG_HOST_TRIPLES), \
702 $(foreach group,$(TEST_GROUPS), \
703 $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
704
705 define DEF_CHECK_FOR_STAGE
706 check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)
707 check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET_TRIPLES), \
708 check-stage$(1)-H-$$(target))
709 endef
710
711 $(foreach stage,$(STAGES), \
712 $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
713
714 define DEF_CHECK_FOR_STAGE_AND_GROUP
715 check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)-$(2)
716 check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
717 check-stage$(1)-H-$$(target)-$(2))
718 endef
719
720 $(foreach stage,$(STAGES), \
721 $(foreach group,$(TEST_GROUPS), \
722 $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
723
724
725 define DEF_CHECK_FOR_STAGE_AND_HOSTS
726 check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
727 check-stage$(1)-T-$$(target)-H-$(2))
728 endef
729
730 $(foreach stage,$(STAGES), \
731 $(foreach host,$(CFG_HOST_TRIPLES), \
732 $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
733
734 define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
735 check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
736 check-stage$(1)-T-$$(target)-H-$(2)-$(3))
737 endef
738
739 $(foreach stage,$(STAGES), \
740 $(foreach host,$(CFG_HOST_TRIPLES), \
741 $(foreach group,$(TEST_GROUPS), \
742 $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
743
744 ######################################################################
745 # check-fast rules
746 ######################################################################
747
748 FT := run_pass_stage2
749 FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD_TRIPLE),$(FT))
750 FT_DRIVER := $(FT)_driver
751
752 GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
753
754 tmp/$(FT).rc tmp/$(FT_DRIVER).rs: \
755 $(RPASS_TESTS) \
756 $(S)src/etc/combine-tests.py
757 @$(call E, check: building combined stage2 test runner)
758 $(Q)$(CFG_PYTHON) $(S)src/etc/combine-tests.py
759
760 define DEF_CHECK_FAST_FOR_T_H
761 # $(1) unused
762 # $(2) target triple
763 # $(3) host triple
764
765 $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
766 tmp/$$(FT).rc \
767 $$(SREQ2_T_$(2)_H_$(3))
768 @$$(call E, compile_and_link: $$@)
769 $$(STAGE2_T_$(2)_H_$(3)) --lib -o $$@ $$<
770
771 $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
772 tmp/$$(FT_DRIVER).rs \
773 $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
774 $$(SREQ2_T_$(2)_H_$(3))
775 @$$(call E, compile_and_link: $$@ $$<)
776 $$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$<
777
778 $(3)/test/$$(FT_DRIVER)-$(2).out: \
779 $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)) \
780 $$(SREQ2_T_$(2)_H_$(3))
781 $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) \
782 --logfile tmp/$$(FT_DRIVER)-$(2).log
783
784 check-fast-T-$(2)-H-$(3): \
785 $(3)/test/$$(FT_DRIVER)-$(2).out
786
787 endef
788
789 $(foreach host,$(CFG_HOST_TRIPLES), \
790 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
791 $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
792
793 check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
794
795 define DEF_CHECK_FAST_FOR_H
796
797 check-fast-H-$(1): check-fast-T-$(1)-H-$(1)
798
799 endef
800
801 $(foreach host,$(CFG_HOST_TRIPLES), \
802 $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))