PageRenderTime 2470ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 1ms

/mk/tests.mk

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