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.
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.
12 ######################################################################
14 ######################################################################
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
)
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
24 ######################################################################
25 # Environment configuration
26 ######################################################################
28 # The arguments to all test runners
30 TESTARGS
+= $(TESTNAME
)
37 # Arguments to the cfail/rfail/rpass/bench tests
39 CTEST_RUNTOOL
= --runtool
"$(CFG_VALGRIND)"
42 # Arguments to the perf tests
44 CTEST_PERF_RUNTOOL
= --runtool
"$(CFG_PERF_TOOL)"
47 CTEST_TESTARGS
:= $(TESTARGS
)
50 CTEST_TESTARGS
+= --verbose
53 # If we're running perf then set this environment variable
54 # to put the benchmarks into 'hard mode'
55 ifeq ($(MAKECMDGOALS
),perf
)
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
63 define DEF_TARGET_COMMANDS
66 CFG_RUN_TEST_
$(1)=$$(call CFG_RUN_
$(1),,$$(CFG_VALGRIND
) $$(1))
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))
83 # Run the compiletest runner itself under valgrind
85 CFG_RUN_CTEST_
$(1)=$$(call CFG_RUN_TEST_
$$(CFG_BUILD_TRIPLE
),$$(2),$$(3))
87 CFG_RUN_CTEST_
$(1)=$$(call CFG_RUN_
$$(CFG_BUILD_TRIPLE
),$$(TLIB
$$(1)_T_
$$(3)_H_
$$(3)),$$(2))
92 $(foreach target
,$(CFG_TARGET_TRIPLES
), \
93 $(eval
$(call DEF_TARGET_COMMANDS
,$(target
))))
95 # Target platform specific variables
96 # for arm-linux-androidabi
97 define DEF_ADB_DEVICE_STATUS
98 CFG_ADB_DEVICE_STATUS
=$(1)
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
))) \
112 $(info check: $(target
) test disabled \
113 $(info check: adb not found
) \
114 $(eval
$(call DEF_ADB_DEVICE_STATUS
, false
))) \
119 ifeq ($(CFG_ADB_DEVICE_STATUS
),true
)
120 CFG_ADB_TEST_DIR
=/data
/tmp
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
)) \
141 ######################################################################
143 ######################################################################
145 check: cleantestlibs cleantmptestlogs tidy
all check-stage2
146 $(Q
)$(CFG_PYTHON
) $(S
)src
/etc
/check-summary.py tmp
/*.log
148 check-notidy
: cleantestlibs cleantmptestlogs
all check-stage2
149 $(Q
)$(CFG_PYTHON
) $(S
)src
/etc
/check-summary.py tmp
/*.log
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
155 check-test
: cleantestlibs cleantmptestlogs
all check-stage2-rfail
156 $(Q
)$(CFG_PYTHON
) $(S
)src
/etc
/check-summary.py tmp
/*.log
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
163 .PHONY
: cleantmptestlogs cleantestlibs
169 $(Q
)find
$(CFG_BUILD_TRIPLE
)/test \
170 -name
'*.[odasS]' -o \
177 -name
'*.libaux' -o \
180 -name
'*.debugger.script' \
184 ######################################################################
186 ######################################################################
192 ALL_CS
:= $(wildcard $(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 \
202 ALL_HS
:= $(wildcard $(S
)src
/rt
/*.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 \
218 # Run the tidy script in multiple parts to avoid huge 'echo' commands
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
227 | xargs
-n
10 $(CFG_PYTHON
) $(S
)src
/etc
/tidy.py
229 | xargs
-n
10 $(CFG_PYTHON
) $(S
)src
/etc
/tidy.py
234 ######################################################################
236 ######################################################################
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
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
)),)
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
)
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
)
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
)
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
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
))))))
286 ######################################################################
288 ######################################################################
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))
297 STDTESTDEP_
$(1)_
$(2)_
$(3) =
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
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
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
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
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
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
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
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
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
))))))))
357 define DEF_TEST_CRATE_RULES
358 check-stage
$(1)-T-
$(2)-H-
$(3)-$(4)-exec
: $$(call TEST_OK_FILE
,$(1),$(2),$(3),$(4))
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)) \
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))
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
; \
385 rm tmp
/check-stage
$(1)-T-
$(2)-H-
$(3)-$(4).tmp
; \
388 rm tmp
/check-stage
$(1)-T-
$(2)-H-
$(3)-$(4).tmp
; \
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))
396 $$(call TEST_OK_FILE
,$(1),$(2),$(3),$(4)): \
397 $(3)/stage
$(1)/test/$(4)test-
$(2)$$(X_
$(2))
398 @
$$(call E
, run
: skipped
$$< )
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
))) \
413 $(eval
$(call DEF_TEST_CRATE_RULES
,$(stage
),$(target
),$(host
),$(crate
))) \
417 ######################################################################
418 # Rules for the compiletest tests (rpass, rfail, etc.)
419 ######################################################################
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
)
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
)
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
)
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
)
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
)
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
)
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
)
466 CTEST_SRC_BASE_bench
= bench
467 CTEST_BUILD_BASE_bench
= bench
468 CTEST_MODE_bench
= run-pass
469 CTEST_RUNTOOL_bench
= $(CTEST_RUNTOOL
)
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
)
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
)
482 CTEST_DISABLE_debuginfo
= "no gdb found"
485 ifeq ($(CFG_OSTYPE
),apple-darwin
)
486 CTEST_DISABLE_debuginfo
= "gdb on darwing needs root"
489 define DEF_CTEST_VARS
491 # All the per-stage build rules you might want to call from the
494 # $(1) is the stage number
495 # $(2) is the target triple to test
496 # $(3) is the host triple to test
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))
503 # Rules for the cfail/rfail/rpass/bench/perf test runner
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) \
512 --adb-path
=$(CFG_ADB
) \
513 --adb-test-dir
=$(CFG_ADB_TEST_DIR
) \
514 --rustcflags
"$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
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
)
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
))))))))
532 define DEF_RUN_COMPILETEST
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))
541 check-stage
$(1)-T-
$(2)-H-
$(3)-$(4)-exec
: $$(call TEST_OK_FILE
,$(1),$(2),$(3),$(4))
543 ifeq ($$(CTEST_DISABLE_
$(4)),)
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)) \
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)))
567 CTEST_NAMES
= rpass rpass-full rfail cfail bench perf debuginfo
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
))))))))))
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
587 define DEF_RUN_PRETTY_TEST
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))/ \
595 check-stage
$(1)-T-
$(2)-H-
$(3)-$(4)-exec
: $$(call TEST_OK_FILE
,$(1),$(2),$(3),$(4))
597 $$(call TEST_OK_FILE
,$(1),$(2),$(3),$(4)): \
598 $$(TEST_SREQ
$(1)_T_
$(2)_H_
$(3)) \
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)) \
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
)))))))
614 define DEF_RUN_DOC_TEST
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)/ \
622 check-stage
$(1)-T-
$(2)-H-
$(3)-doc-
$(4)-exec
: $$(call TEST_OK_FILE
,$(1),$(2),$(3),doc-
$(4))
624 $$(call TEST_OK_FILE
,$(1),$(2),$(3),doc-
$(4)): \
625 $$(TEST_SREQ
$(1)_T_
$(2)_H_
$(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)) \
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
)))))))
642 ######################################################################
643 # Extracting tests for docs
644 ######################################################################
646 EXTRACT_TESTS
:= "$(CFG_PYTHON)" $(S
)src
/etc
/extract-tests.py
648 define DEF_DOC_TEST_HOST
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)
657 $(foreach host
,$(CFG_HOST_TRIPLES
), \
658 $(foreach docname
,$(DOC_TEST_NAMES
), \
659 $(eval
$(call DEF_DOC_TEST_HOST
,$(host
),$(docname
)))))
662 ######################################################################
664 ######################################################################
668 $(foreach crate
,$(TEST_CRATES
),$(crate
)) \
677 $(foreach docname
,$(DOC_TEST_NAMES
),doc-
$(docname
)) \
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
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
))))))
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
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
)))))))
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
))
711 $(foreach stage
,$(STAGES
), \
712 $(eval
$(call DEF_CHECK_FOR_STAGE
,$(stage
))))
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))
720 $(foreach stage
,$(STAGES
), \
721 $(foreach group
,$(TEST_GROUPS
), \
722 $(eval
$(call DEF_CHECK_FOR_STAGE_AND_GROUP
,$(stage
),$(group
)))))
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))
730 $(foreach stage
,$(STAGES
), \
731 $(foreach host
,$(CFG_HOST_TRIPLES
), \
732 $(eval
$(call DEF_CHECK_FOR_STAGE_AND_HOSTS
,$(stage
),$(host
)))))
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))
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
))))))
744 ######################################################################
746 ######################################################################
748 FT
:= run_pass_stage2
749 FT_LIB
:= $(call CFG_LIB_NAME_
$(CFG_BUILD_TRIPLE
),$(FT
))
750 FT_DRIVER
:= $(FT
)_driver
752 GENERATED
+= tmp
/$(FT
).rc tmp
/$(FT_DRIVER
).rs
754 tmp
/$(FT
).rc tmp
/$(FT_DRIVER
).rs
: \
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
760 define DEF_CHECK_FAST_FOR_T_H
765 $$(TLIB2_T_
$(2)_H_
$(3))/$$(FT_LIB
): \
767 $$(SREQ2_T_
$(2)_H_
$(3))
768 @
$$(call E
, compile_and_link
: $$@
)
769 $$(STAGE2_T_
$(2)_H_
$(3)) --lib
-o
$$@
$$<
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
$$@
$$<
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
784 check-fast-T-
$(2)-H-
$(3): \
785 $(3)/test/$$(FT_DRIVER
)-$(2).out
789 $(foreach host
,$(CFG_HOST_TRIPLES
), \
790 $(eval
$(foreach target
,$(CFG_TARGET_TRIPLES
), \
791 $(eval
$(call DEF_CHECK_FAST_FOR_T_H
,,$(target
),$(host
))))))
793 check-fast
: tidy check-fast-H-
$(CFG_BUILD_TRIPLE
)
795 define DEF_CHECK_FAST_FOR_H
797 check-fast-H-
$(1): check-fast-T-
$(1)-H-
$(1)
801 $(foreach host
,$(CFG_HOST_TRIPLES
), \
802 $(eval
$(call DEF_CHECK_FAST_FOR_H
,$(host
))))