PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/mk/tests.mk

https://github.com/Trinick/rust
Makefile | 820 lines | 593 code | 160 blank | 67 comment | 5 complexity | c48b235df9fbf136c996d2b16889e2e3 MD5 | raw file
Possible License(s): Apache-2.0, MIT, BSD-2-Clause, JSON
  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 = std extra
  15. TEST_HOST_CRATES = syntax rustc rustdoc rust rustpkg rusti
  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. # Target platform specific variables
  76. # for arm-linux-androidabi
  77. define DEF_ADB_DEVICE_STATUS
  78. CFG_ADB_DEVICE_STATUS=$(1)
  79. endef
  80. $(foreach target,$(CFG_TARGET_TRIPLES), \
  81. $(if $(findstring $(target),"arm-linux-androideabi"), \
  82. $(if $(findstring adb,$(CFG_ADB)), \
  83. $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
  84. $(info check: $(target) test enabled \
  85. $(info check: android device attached) \
  86. $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
  87. $(info check: $(target) test disabled \
  88. $(info check: android device not attached) \
  89. $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
  90. ), \
  91. $(info check: $(target) test disabled \
  92. $(info check: adb not found) \
  93. $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
  94. ), \
  95. ) \
  96. )
  97. ifeq ($(CFG_ADB_DEVICE_STATUS),true)
  98. CFG_ADB_TEST_DIR=/data/tmp
  99. $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
  100. $(shell adb remount 1>/dev/null) \
  101. $(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
  102. $(shell adb shell rm -rf $(CFG_ADB_TEST_DIR)/* 1>/dev/null) \
  103. $(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
  104. $(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
  105. $(CFG_ADB_TEST_DIR) 1>/dev/null) \
  106. $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
  107. $(CFG_ADB_TEST_DIR)) \
  108. $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
  109. $(CFG_ADB_TEST_DIR)) \
  110. $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
  111. $(CFG_ADB_TEST_DIR)) \
  112. )
  113. else
  114. CFG_ADB_TEST_DIR=
  115. endif
  116. ######################################################################
  117. # Main test targets
  118. ######################################################################
  119. check: cleantestlibs cleantmptestlogs tidy all check-stage2
  120. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  121. check-notidy: cleantestlibs cleantmptestlogs all check-stage2
  122. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  123. check-full: cleantestlibs cleantmptestlogs tidy \
  124. all check-stage1 check-stage2 check-stage3
  125. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  126. check-test: cleantestlibs cleantmptestlogs all check-stage2-rfail
  127. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  128. check-lite: cleantestlibs cleantmptestlogs \
  129. check-stage2-std check-stage2-extra check-stage2-rpass \
  130. check-stage2-rustpkg check-stage2-rusti \
  131. check-stage2-rfail check-stage2-cfail
  132. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  133. .PHONY: cleantmptestlogs cleantestlibs
  134. cleantmptestlogs:
  135. $(Q)rm -f tmp/*.log
  136. cleantestlibs:
  137. $(Q)find $(CFG_BUILD_TRIPLE)/test \
  138. -name '*.[odasS]' -o \
  139. -name '*.so' -o \
  140. -name '*.dylib' -o \
  141. -name '*.dll' -o \
  142. -name '*.def' -o \
  143. -name '*.bc' -o \
  144. -name '*.dSYM' -o \
  145. -name '*.libaux' -o \
  146. -name '*.out' -o \
  147. -name '*.err' -o \
  148. -name '*.debugger.script' \
  149. | xargs rm -rf
  150. ######################################################################
  151. # Tidy
  152. ######################################################################
  153. ifdef CFG_NOTIDY
  154. tidy:
  155. else
  156. ALL_CS := $(wildcard $(S)src/rt/*.cpp \
  157. $(S)src/rt/*/*.cpp \
  158. $(S)src/rt/*/*/*.cpp \
  159. $(S)srcrustllvm/*.cpp)
  160. ALL_CS := $(filter-out $(S)src/rt/bigint/bigint_ext.cpp \
  161. $(S)src/rt/bigint/bigint_int.cpp \
  162. $(S)src/rt/miniz.cpp \
  163. $(S)src/rt/linenoise/linenoise.c \
  164. $(S)src/rt/linenoise/utf8.c \
  165. ,$(ALL_CS))
  166. ALL_HS := $(wildcard $(S)src/rt/*.h \
  167. $(S)src/rt/*/*.h \
  168. $(S)src/rt/*/*/*.h \
  169. $(S)srcrustllvm/*.h)
  170. ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
  171. $(S)src/rt/vg/memcheck.h \
  172. $(S)src/rt/uthash/uthash.h \
  173. $(S)src/rt/uthash/utlist.h \
  174. $(S)src/rt/msvc/typeof.h \
  175. $(S)src/rt/msvc/stdint.h \
  176. $(S)src/rt/msvc/inttypes.h \
  177. $(S)src/rt/bigint/bigint.h \
  178. $(S)src/rt/linenoise/linenoise.h \
  179. $(S)src/rt/linenoise/utf8.h \
  180. ,$(ALL_HS))
  181. # Run the tidy script in multiple parts to avoid huge 'echo' commands
  182. tidy:
  183. @$(call E, check: formatting)
  184. $(Q)find $(S)src -name '*.r[sc]' \
  185. | grep '^$(S)src/test' -v \
  186. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  187. $(Q)find $(S)src/etc -name '*.py' \
  188. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  189. $(Q)echo $(ALL_CS) \
  190. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  191. $(Q)echo $(ALL_HS) \
  192. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  193. endif
  194. ######################################################################
  195. # Sets of tests
  196. ######################################################################
  197. define DEF_TEST_SETS
  198. check-stage$(1)-T-$(2)-H-$(3)-exec: \
  199. check-stage$(1)-T-$(2)-H-$(3)-rpass-exec \
  200. check-stage$(1)-T-$(2)-H-$(3)-rfail-exec \
  201. check-stage$(1)-T-$(2)-H-$(3)-cfail-exec \
  202. check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
  203. check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
  204. check-stage$(1)-T-$(2)-H-$(3)-bench-exec \
  205. check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \
  206. check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
  207. check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
  208. check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
  209. # Only test the compiler-dependent crates when the target is
  210. # able to build a compiler (when the target triple is in the set of host triples)
  211. ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
  212. check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
  213. $$(foreach crate,$$(TEST_CRATES), \
  214. check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
  215. else
  216. check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
  217. $$(foreach crate,$$(TEST_TARGET_CRATES), \
  218. check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
  219. endif
  220. check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
  221. $$(foreach docname,$$(DOC_TEST_NAMES), \
  222. check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)
  223. check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
  224. check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
  225. check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec \
  226. check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
  227. check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec \
  228. check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
  229. endef
  230. $(foreach host,$(CFG_HOST_TRIPLES), \
  231. $(foreach target,$(CFG_TARGET_TRIPLES), \
  232. $(foreach stage,$(STAGES), \
  233. $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
  234. ######################################################################
  235. # Crate testing
  236. ######################################################################
  237. define TEST_RUNNER
  238. # If NO_REBUILD is set then break the dependencies on extra so we can
  239. # test crates without rebuilding std and extra first
  240. ifeq ($(NO_REBUILD),)
  241. STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
  242. else
  243. STDTESTDEP_$(1)_$(2)_$(3) =
  244. endif
  245. $(3)/stage$(1)/test/stdtest-$(2)$$(X_$(2)): \
  246. $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
  247. $$(STDTESTDEP_$(1)_$(2)_$(3))
  248. @$$(call E, compile_and_link: $$@)
  249. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  250. $(3)/stage$(1)/test/extratest-$(2)$$(X_$(2)): \
  251. $$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
  252. $$(STDTESTDEP_$(1)_$(2)_$(3))
  253. @$$(call E, compile_and_link: $$@)
  254. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  255. $(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)): \
  256. $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
  257. $$(STDTESTDEP_$(1)_$(2)_$(3))
  258. @$$(call E, compile_and_link: $$@)
  259. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  260. $(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER_TRIPLE = $(2)
  261. $(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): \
  262. $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
  263. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
  264. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2))
  265. @$$(call E, compile_and_link: $$@)
  266. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  267. $(3)/stage$(1)/test/rustpkgtest-$(2)$$(X_$(2)): \
  268. $$(RUSTPKG_LIB) $$(RUSTPKG_INPUTS) \
  269. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  270. @$$(call E, compile_and_link: $$@)
  271. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  272. $(3)/stage$(1)/test/rustitest-$(2)$$(X_$(2)): \
  273. $$(RUSTI_LIB) $$(RUSTI_INPUTS) \
  274. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  275. @$$(call E, compile_and_link: $$@)
  276. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  277. $(3)/stage$(1)/test/rusttest-$(2)$$(X_$(2)): \
  278. $$(RUST_LIB) $$(RUST_INPUTS) \
  279. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  280. @$$(call E, compile_and_link: $$@)
  281. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  282. $(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)): \
  283. $$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
  284. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  285. @$$(call E, compile_and_link: $$@)
  286. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  287. endef
  288. $(foreach host,$(CFG_HOST_TRIPLES), \
  289. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  290. $(eval $(foreach stage,$(STAGES), \
  291. $(eval $(call TEST_RUNNER,$(stage),$(target),$(host))))))))
  292. define DEF_TEST_CRATE_RULES
  293. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  294. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  295. $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
  296. @$$(call E, run: $$<)
  297. $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
  298. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  299. && touch $$@
  300. endef
  301. define DEF_TEST_CRATE_RULES_arm-linux-androideabi
  302. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  303. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  304. $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
  305. @$$(call E, run: $$< via adb)
  306. @$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
  307. @$(CFG_ADB) shell LD_LIBRARY_PATH=$(CFG_ADB_TEST_DIR) \
  308. $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
  309. --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \
  310. tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
  311. @cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
  312. @touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
  313. @$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
  314. @$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
  315. @if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
  316. then \
  317. rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
  318. touch $$@; \
  319. else \
  320. rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
  321. exit 101; \
  322. fi
  323. endef
  324. define DEF_TEST_CRATE_RULES_null
  325. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  326. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  327. $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
  328. @$$(call E, run: skipped $$< )
  329. @touch $$@
  330. endef
  331. $(foreach host,$(CFG_HOST_TRIPLES), \
  332. $(foreach target,$(CFG_TARGET_TRIPLES), \
  333. $(foreach stage,$(STAGES), \
  334. $(foreach crate, $(TEST_CRATES), \
  335. $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
  336. $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
  337. $(if $(findstring $(target),"arm-linux-androideabi"), \
  338. $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
  339. $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
  340. $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
  341. ), \
  342. $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
  343. ))))))
  344. ######################################################################
  345. # Rules for the compiletest tests (rpass, rfail, etc.)
  346. ######################################################################
  347. RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
  348. RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
  349. RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
  350. RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
  351. RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
  352. RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
  353. CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
  354. CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
  355. BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
  356. PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
  357. DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
  358. CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
  359. CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
  360. # perf tests are the same as bench tests only they run under
  361. # a performance monitor.
  362. PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
  363. RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
  364. RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
  365. RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
  366. CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
  367. BENCH_TESTS := $(BENCH_RS)
  368. PERF_TESTS := $(PERF_RS)
  369. PRETTY_TESTS := $(PRETTY_RS)
  370. DEBUGINFO_TESTS := $(DEBUGINFO_RS)
  371. CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
  372. CTEST_SRC_BASE_rpass = run-pass
  373. CTEST_BUILD_BASE_rpass = run-pass
  374. CTEST_MODE_rpass = run-pass
  375. CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
  376. CTEST_SRC_BASE_rpass-full = run-pass-full
  377. CTEST_BUILD_BASE_rpass-full = run-pass-full
  378. CTEST_MODE_rpass-full = run-pass
  379. CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
  380. CTEST_SRC_BASE_rfail = run-fail
  381. CTEST_BUILD_BASE_rfail = run-fail
  382. CTEST_MODE_rfail = run-fail
  383. CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
  384. CTEST_SRC_BASE_cfail = compile-fail
  385. CTEST_BUILD_BASE_cfail = compile-fail
  386. CTEST_MODE_cfail = compile-fail
  387. CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
  388. CTEST_SRC_BASE_bench = bench
  389. CTEST_BUILD_BASE_bench = bench
  390. CTEST_MODE_bench = run-pass
  391. CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
  392. CTEST_SRC_BASE_perf = bench
  393. CTEST_BUILD_BASE_perf = perf
  394. CTEST_MODE_perf = run-pass
  395. CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
  396. CTEST_SRC_BASE_debuginfo = debug-info
  397. CTEST_BUILD_BASE_debuginfo = debug-info
  398. CTEST_MODE_debuginfo = debug-info
  399. CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)
  400. CTEST_SRC_BASE_codegen = codegen
  401. CTEST_BUILD_BASE_codegen = codegen
  402. CTEST_MODE_codegen = codegen
  403. CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)
  404. ifeq ($(CFG_GDB),)
  405. CTEST_DISABLE_debuginfo = "no gdb found"
  406. endif
  407. ifeq ($(CFG_CLANG),)
  408. CTEST_DISABLE_codegen = "no clang found"
  409. endif
  410. ifeq ($(CFG_OSTYPE),apple-darwin)
  411. CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
  412. endif
  413. define DEF_CTEST_VARS
  414. # All the per-stage build rules you might want to call from the
  415. # command line.
  416. #
  417. # $(1) is the stage number
  418. # $(2) is the target triple to test
  419. # $(3) is the host triple to test
  420. # Prerequisites for compiletest tests
  421. TEST_SREQ$(1)_T_$(2)_H_$(3) = \
  422. $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
  423. $$(SREQ$(1)_T_$(2)_H_$(3))
  424. # Rules for the cfail/rfail/rpass/bench/perf test runner
  425. CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
  426. --compile-lib-path $$(HLIB$(1)_H_$(3)) \
  427. --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
  428. --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
  429. --clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
  430. --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD_TRIPLE))/bin \
  431. --aux-base $$(S)src/test/auxiliary/ \
  432. --stage-id stage$(1)-$(2) \
  433. --target $(2) \
  434. --adb-path=$(CFG_ADB) \
  435. --adb-test-dir=$(CFG_ADB_TEST_DIR) \
  436. --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
  437. $$(CTEST_TESTARGS)
  438. CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
  439. CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
  440. CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
  441. CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
  442. CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
  443. CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
  444. CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
  445. CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
  446. endef
  447. $(foreach host,$(CFG_HOST_TRIPLES), \
  448. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  449. $(eval $(foreach stage,$(STAGES), \
  450. $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
  451. define DEF_RUN_COMPILETEST
  452. CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
  453. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  454. --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
  455. --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
  456. --mode $$(CTEST_MODE_$(4)) \
  457. $$(CTEST_RUNTOOL_$(4))
  458. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  459. ifeq ($$(CTEST_DISABLE_$(4)),)
  460. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  461. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  462. $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
  463. @$$(call E, run $(4) [$(2)]: $$<)
  464. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  465. $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
  466. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  467. && touch $$@
  468. else
  469. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  470. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  471. $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
  472. @$$(call E, run $(4) [$(2)]: $$<)
  473. @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
  474. touch $$@
  475. endif
  476. endef
  477. CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo codegen
  478. $(foreach host,$(CFG_HOST_TRIPLES), \
  479. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  480. $(eval $(foreach stage,$(STAGES), \
  481. $(eval $(foreach name,$(CTEST_NAMES), \
  482. $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
  483. PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
  484. PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
  485. PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
  486. PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
  487. PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
  488. PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
  489. PRETTY_DIRNAME_pretty-rpass = run-pass
  490. PRETTY_DIRNAME_pretty-rpass-full = run-pass-full
  491. PRETTY_DIRNAME_pretty-rfail = run-fail
  492. PRETTY_DIRNAME_pretty-bench = bench
  493. PRETTY_DIRNAME_pretty-pretty = pretty
  494. define DEF_RUN_PRETTY_TEST
  495. PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
  496. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  497. --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
  498. --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
  499. --mode pretty
  500. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  501. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  502. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  503. $$(PRETTY_DEPS_$(4))
  504. @$$(call E, run pretty-rpass [$(2)]: $$<)
  505. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  506. $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
  507. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  508. && touch $$@
  509. endef
  510. $(foreach host,$(CFG_HOST_TRIPLES), \
  511. $(foreach target,$(CFG_TARGET_TRIPLES), \
  512. $(foreach stage,$(STAGES), \
  513. $(foreach pretty-name,$(PRETTY_NAMES), \
  514. $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
  515. define DEF_RUN_DOC_TEST
  516. DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4) := \
  517. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  518. --src-base $(3)/test/doc-$(4)/ \
  519. --build-base $(3)/test/doc-$(4)/ \
  520. --mode run-pass
  521. check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
  522. $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
  523. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  524. doc-$(4)-extract$(3)
  525. @$$(call E, run doc-$(4) [$(2)]: $$<)
  526. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  527. $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
  528. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \
  529. && touch $$@
  530. endef
  531. $(foreach host,$(CFG_HOST_TRIPLES), \
  532. $(foreach target,$(CFG_TARGET_TRIPLES), \
  533. $(foreach stage,$(STAGES), \
  534. $(foreach docname,$(DOC_TEST_NAMES), \
  535. $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
  536. ######################################################################
  537. # Extracting tests for docs
  538. ######################################################################
  539. EXTRACT_TESTS := "$(CFG_PYTHON)" $(S)src/etc/extract-tests.py
  540. define DEF_DOC_TEST_HOST
  541. doc-$(2)-extract$(1):
  542. @$$(call E, extract: $(2) tests)
  543. $$(Q)rm -f $(1)/test/doc-$(2)/*.rs
  544. $$(Q)$$(EXTRACT_TESTS) $$(S)doc/$(2).md $(1)/test/doc-$(2)
  545. endef
  546. $(foreach host,$(CFG_HOST_TRIPLES), \
  547. $(foreach docname,$(DOC_TEST_NAMES), \
  548. $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
  549. ######################################################################
  550. # Shortcut rules
  551. ######################################################################
  552. TEST_GROUPS = \
  553. crates \
  554. $(foreach crate,$(TEST_CRATES),$(crate)) \
  555. rpass \
  556. rpass-full \
  557. rfail \
  558. cfail \
  559. bench \
  560. perf \
  561. debuginfo \
  562. codegen \
  563. doc \
  564. $(foreach docname,$(DOC_TEST_NAMES),doc-$(docname)) \
  565. pretty \
  566. pretty-rpass \
  567. pretty-rpass-full \
  568. pretty-rfail \
  569. pretty-bench \
  570. pretty-pretty \
  571. $(NULL)
  572. define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
  573. check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
  574. endef
  575. $(foreach stage,$(STAGES), \
  576. $(foreach target,$(CFG_TARGET_TRIPLES), \
  577. $(foreach host,$(CFG_HOST_TRIPLES), \
  578. $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
  579. define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
  580. check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
  581. endef
  582. $(foreach stage,$(STAGES), \
  583. $(foreach target,$(CFG_TARGET_TRIPLES), \
  584. $(foreach host,$(CFG_HOST_TRIPLES), \
  585. $(foreach group,$(TEST_GROUPS), \
  586. $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
  587. define DEF_CHECK_FOR_STAGE
  588. check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)
  589. check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  590. check-stage$(1)-H-$$(target))
  591. endef
  592. $(foreach stage,$(STAGES), \
  593. $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
  594. define DEF_CHECK_FOR_STAGE_AND_GROUP
  595. check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)-$(2)
  596. check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  597. check-stage$(1)-H-$$(target)-$(2))
  598. endef
  599. $(foreach stage,$(STAGES), \
  600. $(foreach group,$(TEST_GROUPS), \
  601. $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
  602. define DEF_CHECK_FOR_STAGE_AND_HOSTS
  603. check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  604. check-stage$(1)-T-$$(target)-H-$(2))
  605. endef
  606. $(foreach stage,$(STAGES), \
  607. $(foreach host,$(CFG_HOST_TRIPLES), \
  608. $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
  609. define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
  610. check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  611. check-stage$(1)-T-$$(target)-H-$(2)-$(3))
  612. endef
  613. $(foreach stage,$(STAGES), \
  614. $(foreach host,$(CFG_HOST_TRIPLES), \
  615. $(foreach group,$(TEST_GROUPS), \
  616. $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
  617. ######################################################################
  618. # check-fast rules
  619. ######################################################################
  620. FT := run_pass_stage2
  621. FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD_TRIPLE),$(FT))
  622. FT_DRIVER := $(FT)_driver
  623. GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
  624. tmp/$(FT).rc tmp/$(FT_DRIVER).rs: \
  625. $(RPASS_TESTS) \
  626. $(S)src/etc/combine-tests.py
  627. @$(call E, check: building combined stage2 test runner)
  628. $(Q)$(CFG_PYTHON) $(S)src/etc/combine-tests.py
  629. define DEF_CHECK_FAST_FOR_T_H
  630. # $(1) unused
  631. # $(2) target triple
  632. # $(3) host triple
  633. $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
  634. tmp/$$(FT).rc \
  635. $$(SREQ2_T_$(2)_H_$(3))
  636. @$$(call E, compile_and_link: $$@)
  637. $$(STAGE2_T_$(2)_H_$(3)) --lib -o $$@ $$<
  638. $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
  639. tmp/$$(FT_DRIVER).rs \
  640. $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
  641. $$(SREQ2_T_$(2)_H_$(3))
  642. @$$(call E, compile_and_link: $$@ $$<)
  643. $$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$<
  644. $(3)/test/$$(FT_DRIVER)-$(2).out: \
  645. $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)) \
  646. $$(SREQ2_T_$(2)_H_$(3))
  647. $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) \
  648. --logfile tmp/$$(FT_DRIVER)-$(2).log
  649. check-fast-T-$(2)-H-$(3): \
  650. $(3)/test/$$(FT_DRIVER)-$(2).out
  651. endef
  652. $(foreach host,$(CFG_HOST_TRIPLES), \
  653. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  654. $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
  655. check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
  656. define DEF_CHECK_FAST_FOR_H
  657. check-fast-H-$(1): check-fast-T-$(1)-H-$(1)
  658. endef
  659. $(foreach host,$(CFG_HOST_TRIPLES), \
  660. $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))