PageRenderTime 28ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/mk/tests.mk

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