PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/mk/tests.mk

https://github.com/osaut/rust
Makefile | 712 lines | 496 code | 151 blank | 65 comment | 4 complexity | fcfec07ae92f43f4546b5d1c82965f17 MD5 | raw file
Possible License(s): JSON, Apache-2.0, MIT
  1. # Copyright 2012 The Rust Project Developers. See the COPYRIGHT
  2. # file at the top-level directory of this distribution and at
  3. # http://rust-lang.org/COPYRIGHT.
  4. #
  5. # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. # option. This file may not be copied, modified, or distributed
  9. # except according to those terms.
  10. ######################################################################
  11. # Test variables
  12. ######################################################################
  13. # The names of crates that must be tested
  14. TEST_TARGET_CRATES = core std
  15. TEST_HOST_CRATES = syntax rustc rustdoc rusti rust rustpkg
  16. TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
  17. # Markdown files under doc/ that should have their code extracted and run
  18. DOC_TEST_NAMES = tutorial tutorial-ffi tutorial-macros tutorial-borrowed-ptr tutorial-tasks rust
  19. ######################################################################
  20. # Environment configuration
  21. ######################################################################
  22. # The arguments to all test runners
  23. ifdef TESTNAME
  24. TESTARGS += $(TESTNAME)
  25. endif
  26. ifdef CHECK_XFAILS
  27. TESTARGS += --ignored
  28. endif
  29. # Arguments to the cfail/rfail/rpass/bench tests
  30. ifdef CFG_VALGRIND
  31. CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
  32. endif
  33. # Arguments to the perf tests
  34. ifdef CFG_PERF_TOOL
  35. CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
  36. endif
  37. CTEST_TESTARGS := $(TESTARGS)
  38. ifdef VERBOSE
  39. CTEST_TESTARGS += --verbose
  40. endif
  41. # If we're running perf then set this environment variable
  42. # to put the benchmarks into 'hard mode'
  43. ifeq ($(MAKECMDGOALS),perf)
  44. RUST_BENCH=1
  45. export RUST_BENCH
  46. endif
  47. TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
  48. TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
  49. define DEF_TARGET_COMMANDS
  50. ifdef CFG_UNIXY_$(1)
  51. CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
  52. endif
  53. ifdef CFG_WINDOWSY_$(1)
  54. CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)/$$(2)/$$(strip \
  55. $$(if $$(findstring stage0,$$(1)), \
  56. stage0/$$(CFG_LIBDIR), \
  57. $$(if $$(findstring stage1,$$(1)), \
  58. stage1/$$(CFG_LIBDIR), \
  59. $$(if $$(findstring stage2,$$(1)), \
  60. stage2/$$(CFG_LIBDIR), \
  61. $$(if $$(findstring stage3,$$(1)), \
  62. stage3/$$(CFG_LIBDIR), \
  63. )))))/rustc/$$(CFG_BUILD_TRIPLE)/$$(CFG_LIBDIR)
  64. CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
  65. endif
  66. # Run the compiletest runner itself under valgrind
  67. ifdef CTEST_VALGRIND
  68. CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD_TRIPLE),$$(2),$$(3))
  69. else
  70. CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD_TRIPLE),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
  71. endif
  72. endef
  73. $(foreach target,$(CFG_TARGET_TRIPLES), \
  74. $(eval $(call DEF_TARGET_COMMANDS,$(target))))
  75. ######################################################################
  76. # Main test targets
  77. ######################################################################
  78. check: cleantestlibs cleantmptestlogs tidy all check-stage2
  79. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  80. check-notidy: cleantestlibs cleantmptestlogs all check-stage2
  81. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  82. check-full: cleantestlibs cleantmptestlogs tidy \
  83. all check-stage1 check-stage2 check-stage3
  84. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  85. check-test: cleantestlibs cleantmptestlogs all check-stage2-rfail
  86. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  87. check-lite: cleantestlibs cleantmptestlogs \
  88. check-stage2-core check-stage2-std check-stage2-rpass \
  89. check-stage2-rfail check-stage2-cfail
  90. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  91. .PHONY: cleantmptestlogs cleantestlibs
  92. cleantmptestlogs:
  93. $(Q)rm -f tmp/*.log
  94. cleantestlibs:
  95. $(Q)find $(CFG_BUILD_TRIPLE)/test \
  96. -name '*.[odasS]' -o \
  97. -name '*.so' -o \
  98. -name '*.dylib' -o \
  99. -name '*.dll' -o \
  100. -name '*.def' -o \
  101. -name '*.bc' -o \
  102. -name '*.dSYM' -o \
  103. -name '*.libaux' -o \
  104. -name '*.out' -o \
  105. -name '*.err' -o \
  106. -name '*.debugger.script' \
  107. | xargs rm -rf
  108. ######################################################################
  109. # Tidy
  110. ######################################################################
  111. ifdef CFG_NOTIDY
  112. tidy:
  113. else
  114. ALL_CS := $(wildcard $(S)src/rt/*.cpp \
  115. $(S)src/rt/*/*.cpp \
  116. $(S)src/rt/*/*/*.cpp \
  117. $(S)srcrustllvm/*.cpp)
  118. ALL_CS := $(filter-out $(S)src/rt/bigint/bigint_ext.cpp \
  119. $(S)src/rt/bigint/bigint_int.cpp \
  120. $(S)src/rt/miniz.cpp \
  121. $(S)src/rt/linenoise/linenoise.c \
  122. $(S)src/rt/linenoise/utf8.c \
  123. ,$(ALL_CS))
  124. ALL_HS := $(wildcard $(S)src/rt/*.h \
  125. $(S)src/rt/*/*.h \
  126. $(S)src/rt/*/*/*.h \
  127. $(S)srcrustllvm/*.h)
  128. ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
  129. $(S)src/rt/vg/memcheck.h \
  130. $(S)src/rt/uthash/uthash.h \
  131. $(S)src/rt/uthash/utlist.h \
  132. $(S)src/rt/msvc/typeof.h \
  133. $(S)src/rt/msvc/stdint.h \
  134. $(S)src/rt/msvc/inttypes.h \
  135. $(S)src/rt/bigint/bigint.h \
  136. $(S)src/rt/linenoise/linenoise.h \
  137. $(S)src/rt/linenoise/utf8.h \
  138. ,$(ALL_HS))
  139. # Run the tidy script in multiple parts to avoid huge 'echo' commands
  140. tidy:
  141. @$(call E, check: formatting)
  142. $(Q)find $(S)src -name '*.r[sc]' \
  143. | grep '^$(S)src/test' -v \
  144. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  145. $(Q)find $(S)src/etc -name '*.py' \
  146. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  147. $(Q)echo $(ALL_CS) \
  148. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  149. $(Q)echo $(ALL_HS) \
  150. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  151. endif
  152. ######################################################################
  153. # Sets of tests
  154. ######################################################################
  155. define DEF_TEST_SETS
  156. check-stage$(1)-T-$(2)-H-$(3)-exec: \
  157. check-stage$(1)-T-$(2)-H-$(3)-rpass-exec \
  158. check-stage$(1)-T-$(2)-H-$(3)-rfail-exec \
  159. check-stage$(1)-T-$(2)-H-$(3)-cfail-exec \
  160. check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
  161. check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
  162. check-stage$(1)-T-$(2)-H-$(3)-bench-exec \
  163. check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \
  164. check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
  165. check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
  166. # Only test the compiler-dependent crates when the target is
  167. # able to build a compiler (when the target triple is in the set of host triples)
  168. ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
  169. check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
  170. $$(foreach crate,$$(TEST_CRATES), \
  171. check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
  172. else
  173. check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
  174. $$(foreach crate,$$(TEST_TARGET_CRATES), \
  175. check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
  176. endif
  177. check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
  178. $$(foreach docname,$$(DOC_TEST_NAMES), \
  179. check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)
  180. check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
  181. check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
  182. check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec \
  183. check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
  184. check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec \
  185. check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
  186. endef
  187. $(foreach host,$(CFG_HOST_TRIPLES), \
  188. $(foreach target,$(CFG_TARGET_TRIPLES), \
  189. $(foreach stage,$(STAGES), \
  190. $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
  191. ######################################################################
  192. # Crate testing
  193. ######################################################################
  194. define TEST_RUNNER
  195. # If NO_REBUILD is set then break the dependencies on std so we can
  196. # test crates without rebuilding core and std first
  197. ifeq ($(NO_REBUILD),)
  198. STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
  199. else
  200. STDTESTDEP_$(1)_$(2)_$(3) =
  201. endif
  202. $(3)/test/coretest.stage$(1)-$(2)$$(X_$(2)): \
  203. $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
  204. $$(STDTESTDEP_$(1)_$(2)_$(3))
  205. @$$(call E, compile_and_link: $$@)
  206. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  207. $(3)/test/stdtest.stage$(1)-$(2)$$(X_$(2)): \
  208. $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
  209. $$(STDTESTDEP_$(1)_$(2)_$(3))
  210. @$$(call E, compile_and_link: $$@)
  211. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  212. $(3)/test/syntaxtest.stage$(1)-$(2)$$(X_$(2)): \
  213. $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
  214. $$(STDTESTDEP_$(1)_$(2)_$(3))
  215. @$$(call E, compile_and_link: $$@)
  216. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  217. $(3)/test/rustctest.stage$(1)-$(2)$$(X_$(2)): \
  218. $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
  219. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
  220. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2))
  221. @$$(call E, compile_and_link: $$@)
  222. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  223. $(3)/test/rustpkgtest.stage$(1)-$(2)$$(X_$(2)): \
  224. $$(RUSTPKG_LIB) $$(RUSTPKG_INPUTS) \
  225. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  226. @$$(call E, compile_and_link: $$@)
  227. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  228. $(3)/test/rustitest.stage$(1)-$(2)$$(X_$(2)): \
  229. $$(RUSTI_LIB) $$(RUSTI_INPUTS) \
  230. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  231. @$$(call E, compile_and_link: $$@)
  232. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  233. $(3)/test/rusttest.stage$(1)-$(2)$$(X_$(2)): \
  234. $$(RUST_LIB) $$(RUST_INPUTS) \
  235. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  236. @$$(call E, compile_and_link: $$@)
  237. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  238. $(3)/test/rustdoctest.stage$(1)-$(2)$$(X_$(2)): \
  239. $$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
  240. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  241. @$$(call E, compile_and_link: $$@)
  242. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  243. endef
  244. $(foreach host,$(CFG_HOST_TRIPLES), \
  245. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  246. $(eval $(foreach stage,$(STAGES), \
  247. $(eval $(call TEST_RUNNER,$(stage),$(target),$(host))))))))
  248. define DEF_TEST_CRATE_RULES
  249. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  250. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  251. $(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
  252. @$$(call E, run: $$<)
  253. $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
  254. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  255. && touch $$@
  256. endef
  257. $(foreach host,$(CFG_HOST_TRIPLES), \
  258. $(foreach target,$(CFG_TARGET_TRIPLES), \
  259. $(foreach stage,$(STAGES), \
  260. $(foreach crate, $(TEST_CRATES), \
  261. $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate)))))))
  262. ######################################################################
  263. # Rules for the compiletest tests (rpass, rfail, etc.)
  264. ######################################################################
  265. RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
  266. RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
  267. RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
  268. RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
  269. RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
  270. RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
  271. CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
  272. CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
  273. BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
  274. PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
  275. DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
  276. # perf tests are the same as bench tests only they run under
  277. # a performance monitor.
  278. PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
  279. RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
  280. RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
  281. RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
  282. CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
  283. BENCH_TESTS := $(BENCH_RS)
  284. PERF_TESTS := $(PERF_RS)
  285. PRETTY_TESTS := $(PRETTY_RS)
  286. DEBUGINFO_TESTS := $(DEBUGINFO_RS)
  287. CTEST_SRC_BASE_rpass = run-pass
  288. CTEST_BUILD_BASE_rpass = run-pass
  289. CTEST_MODE_rpass = run-pass
  290. CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
  291. CTEST_SRC_BASE_rpass-full = run-pass-full
  292. CTEST_BUILD_BASE_rpass-full = run-pass-full
  293. CTEST_MODE_rpass-full = run-pass
  294. CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
  295. CTEST_SRC_BASE_rfail = run-fail
  296. CTEST_BUILD_BASE_rfail = run-fail
  297. CTEST_MODE_rfail = run-fail
  298. CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
  299. CTEST_SRC_BASE_cfail = compile-fail
  300. CTEST_BUILD_BASE_cfail = compile-fail
  301. CTEST_MODE_cfail = compile-fail
  302. CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
  303. CTEST_SRC_BASE_bench = bench
  304. CTEST_BUILD_BASE_bench = bench
  305. CTEST_MODE_bench = run-pass
  306. CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
  307. CTEST_SRC_BASE_perf = bench
  308. CTEST_BUILD_BASE_perf = perf
  309. CTEST_MODE_perf = run-pass
  310. CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
  311. CTEST_SRC_BASE_debuginfo = debug-info
  312. CTEST_BUILD_BASE_debuginfo = debug-info
  313. CTEST_MODE_debuginfo = debug-info
  314. CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)
  315. ifeq ($(CFG_GDB),)
  316. CTEST_DISABLE_debuginfo = "no gdb found"
  317. endif
  318. ifeq ($(CFG_OSTYPE),apple-darwin)
  319. CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
  320. endif
  321. define DEF_CTEST_VARS
  322. # All the per-stage build rules you might want to call from the
  323. # command line.
  324. #
  325. # $(1) is the stage number
  326. # $(2) is the target triple to test
  327. # $(3) is the host triple to test
  328. # Prerequisites for compiletest tests
  329. TEST_SREQ$(1)_T_$(2)_H_$(3) = \
  330. $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
  331. $$(SREQ$(1)_T_$(2)_H_$(3))
  332. # Rules for the cfail/rfail/rpass/bench/perf test runner
  333. CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
  334. --compile-lib-path $$(HLIB$(1)_H_$(3)) \
  335. --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
  336. --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
  337. --aux-base $$(S)src/test/auxiliary/ \
  338. --stage-id stage$(1)-$(2) \
  339. --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
  340. $$(CTEST_TESTARGS)
  341. CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
  342. CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
  343. CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
  344. CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
  345. CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
  346. CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
  347. CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
  348. endef
  349. $(foreach host,$(CFG_HOST_TRIPLES), \
  350. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  351. $(eval $(foreach stage,$(STAGES), \
  352. $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
  353. define DEF_RUN_COMPILETEST
  354. CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
  355. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  356. --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
  357. --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
  358. --mode $$(CTEST_MODE_$(4)) \
  359. $$(CTEST_RUNTOOL_$(4))
  360. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  361. ifeq ($$(CTEST_DISABLE_$(4)),)
  362. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  363. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  364. $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
  365. @$$(call E, run $(4): $$<)
  366. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  367. $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
  368. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  369. && touch $$@
  370. else
  371. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  372. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  373. $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
  374. @$$(call E, run $(4): $$<)
  375. @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
  376. touch $$@
  377. endif
  378. endef
  379. CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo
  380. $(foreach host,$(CFG_HOST_TRIPLES), \
  381. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  382. $(eval $(foreach stage,$(STAGES), \
  383. $(eval $(foreach name,$(CTEST_NAMES), \
  384. $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
  385. PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
  386. PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
  387. PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
  388. PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
  389. PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
  390. PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
  391. PRETTY_DIRNAME_pretty-rpass = run-pass
  392. PRETTY_DIRNAME_pretty-rpass-full = run-pass-full
  393. PRETTY_DIRNAME_pretty-rfail = run-fail
  394. PRETTY_DIRNAME_pretty-bench = bench
  395. PRETTY_DIRNAME_pretty-pretty = pretty
  396. define DEF_RUN_PRETTY_TEST
  397. PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
  398. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  399. --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
  400. --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
  401. --mode pretty
  402. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  403. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  404. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  405. $$(PRETTY_DEPS_$(4))
  406. @$$(call E, run pretty-rpass: $$<)
  407. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  408. $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
  409. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  410. && touch $$@
  411. endef
  412. $(foreach host,$(CFG_HOST_TRIPLES), \
  413. $(foreach target,$(CFG_TARGET_TRIPLES), \
  414. $(foreach stage,$(STAGES), \
  415. $(foreach pretty-name,$(PRETTY_NAMES), \
  416. $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
  417. define DEF_RUN_DOC_TEST
  418. DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4) := \
  419. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  420. --src-base $(3)/test/doc-$(4)/ \
  421. --build-base $(3)/test/doc-$(4)/ \
  422. --mode run-pass
  423. check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
  424. $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
  425. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  426. doc-$(4)-extract$(3)
  427. @$$(call E, run doc-$(4): $$<)
  428. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  429. $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
  430. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \
  431. && touch $$@
  432. endef
  433. $(foreach host,$(CFG_HOST_TRIPLES), \
  434. $(foreach target,$(CFG_TARGET_TRIPLES), \
  435. $(foreach stage,$(STAGES), \
  436. $(foreach docname,$(DOC_TEST_NAMES), \
  437. $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
  438. ######################################################################
  439. # Extracting tests for docs
  440. ######################################################################
  441. EXTRACT_TESTS := "$(CFG_PYTHON)" $(S)src/etc/extract-tests.py
  442. define DEF_DOC_TEST_HOST
  443. doc-$(2)-extract$(1):
  444. @$$(call E, extract: $(2) tests)
  445. $$(Q)rm -f $(1)/test/doc-$(2)/*.rs
  446. $$(Q)$$(EXTRACT_TESTS) $$(S)doc/$(2).md $(1)/test/doc-$(2)
  447. endef
  448. $(foreach host,$(CFG_HOST_TRIPLES), \
  449. $(foreach docname,$(DOC_TEST_NAMES), \
  450. $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
  451. ######################################################################
  452. # Shortcut rules
  453. ######################################################################
  454. TEST_GROUPS = \
  455. crates \
  456. $(foreach crate,$(TEST_CRATES),$(crate)) \
  457. rpass \
  458. rpass-full \
  459. rfail \
  460. cfail \
  461. bench \
  462. perf \
  463. debuginfo \
  464. doc \
  465. $(foreach docname,$(DOC_TEST_NAMES),$(docname)) \
  466. pretty \
  467. pretty-rpass \
  468. pretty-rpass-full \
  469. pretty-rfail \
  470. pretty-bench \
  471. pretty-pretty \
  472. $(NULL)
  473. define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
  474. check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
  475. endef
  476. $(foreach stage,$(STAGES), \
  477. $(foreach target,$(CFG_TARGET_TRIPLES), \
  478. $(foreach host,$(CFG_HOST_TRIPLES), \
  479. $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
  480. define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
  481. check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
  482. endef
  483. $(foreach stage,$(STAGES), \
  484. $(foreach target,$(CFG_TARGET_TRIPLES), \
  485. $(foreach host,$(CFG_HOST_TRIPLES), \
  486. $(foreach group,$(TEST_GROUPS), \
  487. $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
  488. define DEF_CHECK_FOR_STAGE
  489. check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)
  490. check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  491. check-stage$(1)-H-$$(target))
  492. endef
  493. $(foreach stage,$(STAGES), \
  494. $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
  495. define DEF_CHECK_FOR_STAGE_AND_GROUP
  496. check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)-$(2)
  497. check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  498. check-stage$(1)-H-$$(target)-$(2))
  499. endef
  500. $(foreach stage,$(STAGES), \
  501. $(foreach group,$(TEST_GROUPS), \
  502. $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
  503. define DEF_CHECK_FOR_STAGE_AND_HOSTS
  504. check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  505. check-stage$(1)-T-$$(target)-H-$(2))
  506. endef
  507. $(foreach stage,$(STAGES), \
  508. $(foreach host,$(CFG_HOST_TRIPLES), \
  509. $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
  510. define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
  511. check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  512. check-stage$(1)-T-$$(target)-H-$(2)-$(3))
  513. endef
  514. $(foreach stage,$(STAGES), \
  515. $(foreach host,$(CFG_HOST_TRIPLES), \
  516. $(foreach group,$(TEST_GROUPS), \
  517. $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
  518. ######################################################################
  519. # check-fast rules
  520. ######################################################################
  521. FT := run_pass_stage2
  522. FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD_TRIPLE),$(FT))
  523. FT_DRIVER := $(FT)_driver
  524. GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
  525. tmp/$(FT).rc tmp/$(FT_DRIVER).rs: \
  526. $(RPASS_TESTS) \
  527. $(S)src/etc/combine-tests.py
  528. @$(call E, check: building combined stage2 test runner)
  529. $(Q)$(CFG_PYTHON) $(S)src/etc/combine-tests.py
  530. define DEF_CHECK_FAST_FOR_T_H
  531. # $(1) unused
  532. # $(2) target triple
  533. # $(3) host triple
  534. $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
  535. tmp/$$(FT).rc \
  536. $$(SREQ2_T_$(2)_H_$(3))
  537. @$$(call E, compile_and_link: $$@)
  538. $$(STAGE2_T_$(2)_H_$(3)) --lib -o $$@ $$<
  539. $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
  540. tmp/$$(FT_DRIVER).rs \
  541. $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
  542. $$(SREQ2_T_$(2)_H_$(3))
  543. @$$(call E, compile_and_link: $$@ $$<)
  544. $$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$<
  545. $(3)/test/$$(FT_DRIVER)-$(2).out: \
  546. $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)) \
  547. $$(SREQ2_T_$(2)_H_$(3))
  548. $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) \
  549. --logfile tmp/$$(FT_DRIVER)-$(2).log
  550. check-fast-T-$(2)-H-$(3): \
  551. $(3)/test/$$(FT_DRIVER)-$(2).out
  552. endef
  553. $(foreach host,$(CFG_HOST_TRIPLES), \
  554. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  555. $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
  556. check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
  557. define DEF_CHECK_FAST_FOR_H
  558. check-fast-H-$(1): check-fast-T-$(1)-H-$(1)
  559. endef
  560. $(foreach host,$(CFG_HOST_TRIPLES), \
  561. $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))