tests.mk 29.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

11

G
Graydon Hoare 已提交
12
######################################################################
13
# Test variables
G
Graydon Hoare 已提交
14 15
######################################################################

16
# The names of crates that must be tested
17
TEST_TARGET_CRATES = std extra
18
TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc syntax
19
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
G
Graydon Hoare 已提交
20

21
# Markdown files under doc/ that should have their code extracted and run
G
Graydon Hoare 已提交
22
DOC_TEST_NAMES = tutorial tutorial-ffi tutorial-macros tutorial-borrowed-ptr \
23
                 tutorial-tasks tutorial-conditions tutorial-container rust
24

25 26 27
######################################################################
# Environment configuration
######################################################################
28

B
Brian Anderson 已提交
29 30 31 32 33 34 35 36 37
# The arguments to all test runners
ifdef TESTNAME
  TESTARGS += $(TESTNAME)
endif

ifdef CHECK_XFAILS
  TESTARGS += --ignored
endif

38
TEST_BENCH = --bench
39

B
Brian Anderson 已提交
40 41 42
# Arguments to the cfail/rfail/rpass/bench tests
ifdef CFG_VALGRIND
  CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
43
  TEST_BENCH =
B
Brian Anderson 已提交
44
endif
45

46 47
ifdef NO_BENCH
  TEST_BENCH =
B
Brian Anderson 已提交
48
endif
49

50 51 52 53 54
# Arguments to the perf tests
ifdef CFG_PERF_TOOL
  CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
endif

B
Brian Anderson 已提交
55
CTEST_TESTARGS := $(TESTARGS)
G
Graydon Hoare 已提交
56

B
Brian Anderson 已提交
57 58 59
ifdef VERBOSE
  CTEST_TESTARGS += --verbose
endif
60

61 62 63 64 65 66 67
# If we're running perf then set this environment variable
# to put the benchmarks into 'hard mode'
ifeq ($(MAKECMDGOALS),perf)
  RUST_BENCH=1
  export RUST_BENCH
endif

68 69
TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
70

71 72 73 74 75
TEST_RATCHET_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4)-metrics.json
TEST_RATCHET_NOISE_PERCENT=10.0

# Whether to ratchet or merely save benchmarks
ifdef CFG_RATCHET_BENCH
76
CRATE_TEST_EXTRA_ARGS=\
77
  --test $(TEST_BENCH) \
78 79 80
  --ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
  --ratchet-noise-percent $(TEST_RATCHET_NOISE_PERCENT)
else
81
CRATE_TEST_EXTRA_ARGS=\
82
  --test $(TEST_BENCH) \
83 84 85
  --save-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4))
endif

86 87 88 89 90 91 92 93
# If we're sharding the testsuite between parallel testers,
# pass this argument along to the compiletest and crate test
# invocations.
ifdef TEST_SHARD
  CTEST_TESTARGS += --test-shard=$(TEST_SHARD)
  CRATE_TEST_EXTRA_ARGS += --test-shard=$(TEST_SHARD)
endif

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
define DEF_TARGET_COMMANDS

ifdef CFG_UNIXY_$(1)
  CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
endif

ifdef CFG_WINDOWSY_$(1)
  CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)/$$(2)/$$(strip \
   $$(if $$(findstring stage0,$$(1)), \
       stage0/$$(CFG_LIBDIR), \
      $$(if $$(findstring stage1,$$(1)), \
           stage1/$$(CFG_LIBDIR), \
          $$(if $$(findstring stage2,$$(1)), \
               stage2/$$(CFG_LIBDIR), \
               $$(if $$(findstring stage3,$$(1)), \
                    stage3/$$(CFG_LIBDIR), \
               )))))/rustc/$$(CFG_BUILD_TRIPLE)/$$(CFG_LIBDIR)
  CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
endif

# Run the compiletest runner itself under valgrind
ifdef CTEST_VALGRIND
CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD_TRIPLE),$$(2),$$(3))
else
CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD_TRIPLE),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
endif

endef

$(foreach target,$(CFG_TARGET_TRIPLES), \
  $(eval $(call DEF_TARGET_COMMANDS,$(target))))

D
Daniel Micay 已提交
126
# Target platform specific variables
127
# for arm-linux-androidabi
128 129
define DEF_ADB_DEVICE_STATUS
CFG_ADB_DEVICE_STATUS=$(1)
130 131 132
endef

$(foreach target,$(CFG_TARGET_TRIPLES), \
133 134
  $(if $(findstring $(target),"arm-linux-androideabi"), \
    $(if $(findstring adb,$(CFG_ADB)), \
135
      $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
136 137 138 139 140 141
        $(info check: $(target) test enabled \
          $(info check: android device attached) \
          $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
        $(info check: $(target) test disabled \
          $(info check: android device not attached) \
          $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
142
      ), \
143 144 145 146
      $(info check: $(target) test disabled \
        $(info check: adb not found) \
        $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
    ), \
147 148 149
  ) \
)

150 151
ifeq ($(CFG_ADB_DEVICE_STATUS),true)
CFG_ADB_TEST_DIR=/data/tmp
152

153 154
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
 $(shell adb remount 1>/dev/null) \
155 156 157
 $(shell adb shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
 $(shell adb shell mkdir $(CFG_ADB_TEST_DIR)) \
 $(shell adb shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
158
 $(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
159 160
 $(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
                  $(CFG_ADB_TEST_DIR) 1>/dev/null) \
161 162 163 164 165 166
 $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
                  $(CFG_ADB_TEST_DIR)) \
 $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
                  $(CFG_ADB_TEST_DIR)) \
 $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
                  $(CFG_ADB_TEST_DIR)) \
167
 )
168 169
else
CFG_ADB_TEST_DIR=
170
endif
171 172


B
Brian Anderson 已提交
173 174 175 176
######################################################################
# Main test targets
######################################################################

177 178 179 180 181 182 183 184 185 186 187 188 189 190
check: cleantestlibs cleantmptestlogs tidy all check-stage2
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-notidy: cleantestlibs cleantmptestlogs all check-stage2
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-full: cleantestlibs cleantmptestlogs tidy \
            all check-stage1 check-stage2 check-stage3
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-test: cleantestlibs cleantmptestlogs all check-stage2-rfail
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-lite: cleantestlibs cleantmptestlogs \
191
	check-stage2-std check-stage2-extra check-stage2-rpass \
A
Alex Crichton 已提交
192
	check-stage2-rustpkg check-stage2-rusti \
193 194 195
	check-stage2-rfail check-stage2-cfail
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

196 197
.PHONY: cleantmptestlogs cleantestlibs

198 199
cleantmptestlogs:
	$(Q)rm -f tmp/*.log
200

201
cleantestlibs:
202
	$(Q)find $(CFG_BUILD_TRIPLE)/test \
203 204 205 206 207 208 209
         -name '*.[odasS]' -o \
         -name '*.so' -o      \
         -name '*.dylib' -o   \
         -name '*.dll' -o     \
         -name '*.def' -o     \
         -name '*.bc' -o      \
         -name '*.dSYM' -o    \
210
         -name '*.libaux' -o      \
211
         -name '*.out' -o     \
B
Brian Leibig 已提交
212 213
         -name '*.err' -o     \
	 -name '*.debugger.script' \
214
         | xargs rm -rf
215

216

217 218 219
######################################################################
# Tidy
######################################################################
B
Brian Anderson 已提交
220

221
ifdef CFG_NOTIDY
B
Brian Anderson 已提交
222
tidy:
223
else
224 225 226 227

ALL_CS := $(wildcard $(S)src/rt/*.cpp \
                     $(S)src/rt/*/*.cpp \
                     $(S)src/rt/*/*/*.cpp \
228
                     $(S)src/rustllvm/*.cpp)
229
ALL_CS := $(filter-out $(S)src/rt/miniz.cpp \
230
                       $(S)src/rt/linenoise/linenoise.c \
B
Brian Anderson 已提交
231
                       $(S)src/rt/linenoise/utf8.c \
232 233 234 235
	,$(ALL_CS))
ALL_HS := $(wildcard $(S)src/rt/*.h \
                     $(S)src/rt/*/*.h \
                     $(S)src/rt/*/*/*.h \
236
                     $(S)src/rustllvm/*.h)
237 238 239 240 241
ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
                       $(S)src/rt/vg/memcheck.h \
                       $(S)src/rt/msvc/typeof.h \
                       $(S)src/rt/msvc/stdint.h \
                       $(S)src/rt/msvc/inttypes.h \
242
                       $(S)src/rt/linenoise/linenoise.h \
B
Brian Anderson 已提交
243
                       $(S)src/rt/linenoise/utf8.h \
244 245
	,$(ALL_HS))

246
# Run the tidy script in multiple parts to avoid huge 'echo' commands
247 248
tidy:
		@$(call E, check: formatting)
249
		$(Q)find $(S)src -name '*.r[sc]' \
250
		| grep '^$(S)src/test' -v \
251 252
		| grep '^$(S)src/libuv' -v \
		| grep '^$(S)src/llvm' -v \
253
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
254
		$(Q)find $(S)src/etc -name '*.py' \
255
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
256
		$(Q)echo $(ALL_CS) \
257
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
258
		$(Q)echo $(ALL_HS) \
259
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
260

261
endif
262

263

B
Brian Anderson 已提交
264
######################################################################
265
# Sets of tests
B
Brian Anderson 已提交
266 267
######################################################################

268 269 270 271 272 273 274 275 276
define DEF_TEST_SETS

check-stage$(1)-T-$(2)-H-$(3)-exec:     				\
	check-stage$(1)-T-$(2)-H-$(3)-rpass-exec			\
	check-stage$(1)-T-$(2)-H-$(3)-rfail-exec			\
	check-stage$(1)-T-$(2)-H-$(3)-cfail-exec			\
	check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec			\
        check-stage$(1)-T-$(2)-H-$(3)-crates-exec                      \
	check-stage$(1)-T-$(2)-H-$(3)-bench-exec			\
277
	check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \
278
	check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
279 280 281
	check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
	check-stage$(1)-T-$(2)-H-$(3)-pretty-exec

282 283 284 285
# Only test the compiler-dependent crates when the target is
# able to build a compiler (when the target triple is in the set of host triples)
ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)

286 287 288 289
check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
	$$(foreach crate,$$(TEST_CRATES), \
           check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)

290 291 292 293 294 295 296 297
else

check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
	$$(foreach crate,$$(TEST_TARGET_CRATES), \
           check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)

endif

298 299 300 301 302 303 304 305 306 307
check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
        $$(foreach docname,$$(DOC_TEST_NAMES), \
           check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)

check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
	check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
308

B
Brian Anderson 已提交
309 310
endef

311
$(foreach host,$(CFG_HOST_TRIPLES), \
312 313 314 315
 $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(foreach stage,$(STAGES), \
    $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))

B
Brian Anderson 已提交
316

317
######################################################################
318
# Crate testing
319 320
######################################################################

321
define TEST_RUNNER
322

323 324
# If NO_REBUILD is set then break the dependencies on extra so we can
# test crates without rebuilding std and extra first
325
ifeq ($(NO_REBUILD),)
326 327
STDTESTDEP_$(1)_$(2)_$(3) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
                            $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
328 329 330 331
else
STDTESTDEP_$(1)_$(2)_$(3) =
endif

332 333
$(3)/stage$(1)/test/stdtest-$(2)$$(X_$(2)):			\
		$$(STDLIB_CRATE) $$(STDLIB_INPUTS)	\
334
		$$(STDTESTDEP_$(1)_$(2)_$(3))
335
	@$$(call E, compile_and_link: $$@)
336
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
337

338 339
$(3)/stage$(1)/test/extratest-$(2)$$(X_$(2)):			\
		$$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS)	\
340
		$$(STDTESTDEP_$(1)_$(2)_$(3))
B
Brian Anderson 已提交
341
	@$$(call E, compile_and_link: $$@)
N
Niko Matsakis 已提交
342
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
343

A
Alex Crichton 已提交
344
$(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)):			\
345
		$$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS)	\
346
		$$(STDTESTDEP_$(1)_$(2)_$(3))
347 348 349
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test

350
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER_TRIPLE = $(2)
A
Alex Crichton 已提交
351
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)):					\
352
		$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
353
		$$(SREQ$(1)_T_$(2)_H_$(3)) \
B
Brian Anderson 已提交
354 355
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
                $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2))
B
Brian Anderson 已提交
356
	@$$(call E, compile_and_link: $$@)
N
Niko Matsakis 已提交
357
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
358

A
Alex Crichton 已提交
359
$(3)/stage$(1)/test/rustpkgtest-$(2)$$(X_$(2)):					\
360
		$$(RUSTPKG_LIB) $$(RUSTPKG_INPUTS)		\
361
		$$(SREQ$(1)_T_$(2)_H_$(3)) \
362
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
363
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2)) \
364 365
		$$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$$(X_$(2)) \
		$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(2))
366 367
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
368

A
Alex Crichton 已提交
369
$(3)/stage$(1)/test/rustitest-$(2)$$(X_$(2)):					\
370
		$$(RUSTI_LIB) $$(RUSTI_INPUTS)		\
371
		$$(SREQ$(1)_T_$(2)_H_$(3)) \
372
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
B
Brian Anderson 已提交
373
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
374 375
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
376

A
Alex Crichton 已提交
377
$(3)/stage$(1)/test/rusttest-$(2)$$(X_$(2)):					\
378
		$$(RUST_LIB) $$(RUST_INPUTS)		\
379
		$$(SREQ$(1)_T_$(2)_H_$(3)) \
380 381 382
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTPKG_$(2)) \
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTDOC_$(2)) \
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTI_$(2)) \
B
Brian Anderson 已提交
383
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
384 385 386
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test

A
Alex Crichton 已提交
387
$(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)):					\
388
		$$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS)		\
389
		$$(SREQ$(1)_T_$(2)_H_$(3)) \
390
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
B
Brian Anderson 已提交
391
		$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
392 393 394
	@$$(call E, compile_and_link: $$@)
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test

395 396
endef

397
$(foreach host,$(CFG_HOST_TRIPLES), \
398 399 400 401 402
 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(eval $(foreach stage,$(STAGES), \
   $(eval $(call TEST_RUNNER,$(stage),$(target),$(host))))))))

define DEF_TEST_CRATE_RULES
403 404
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

405 406
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

407
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
A
Alex Crichton 已提交
408
		$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
409
	@$$(call E, run: $$<)
410
	$$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS)	\
411
	--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
412
	$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) \
413
	&& touch $$@
414
endef
415

416 417 418 419
define DEF_TEST_CRATE_RULES_arm-linux-androideabi
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
A
Alex Crichton 已提交
420
		$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
421
	@$$(call E, run: $$< via adb)
422
	@$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
423 424
	@$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
		./$$(notdir $$<) \
425
		--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
426
		$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)))' \
427
		> tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
428 429
	@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
	@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
430 431
	@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
	@$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
432
	@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/$$(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) tmp/
433 434 435 436 437 438 439 440 441 442 443 444 445 446
	@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
	then \
		rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
		touch $$@; \
	else \
		rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
		exit 101; \
	fi
endef

define DEF_TEST_CRATE_RULES_null
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
A
Alex Crichton 已提交
447
		$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
448 449 450 451
	@$$(call E, run: skipped $$< )
	@touch $$@
endef

452
$(foreach host,$(CFG_HOST_TRIPLES), \
453 454 455
 $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(foreach stage,$(STAGES), \
   $(foreach crate, $(TEST_CRATES), \
456 457 458
    $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
     $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
     $(if $(findstring $(target),"arm-linux-androideabi"), \
459
      $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
460 461 462
       $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
       $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
      ), \
463
      $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
D
Daniel Micay 已提交
464
     ))))))
465 466


467 468 469 470 471 472 473 474 475 476 477 478
######################################################################
# Rules for the compiletest tests (rpass, rfail, etc.)
######################################################################

RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
C
Corey Richardson 已提交
479
BENCH_RS := $(wildcard $(S)src/test/bench/rt/*.rs $(S)src/test/bench/shootout/*.rs $(S)src/test/bench/std/*.rs $(S)src/test/bench/*.rs)
480
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
B
Brian Anderson 已提交
481
DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
482 483
CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
484

485 486
# perf tests are the same as bench tests only they run under
# a performance monitor.
C
Corey Richardson 已提交
487
PERF_RS := $(BENCH_RS)
488

489 490 491 492 493 494 495
RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
BENCH_TESTS := $(BENCH_RS)
PERF_TESTS := $(PERF_RS)
PRETTY_TESTS := $(PRETTY_RS)
B
Brian Leibig 已提交
496
DEBUGINFO_TESTS := $(DEBUGINFO_RS)
497
CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
B
Brian Anderson 已提交
498

499 500 501 502
CTEST_SRC_BASE_rpass = run-pass
CTEST_BUILD_BASE_rpass = run-pass
CTEST_MODE_rpass = run-pass
CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
B
Brian Anderson 已提交
503

504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
CTEST_SRC_BASE_rpass-full = run-pass-full
CTEST_BUILD_BASE_rpass-full = run-pass-full
CTEST_MODE_rpass-full = run-pass
CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)

CTEST_SRC_BASE_rfail = run-fail
CTEST_BUILD_BASE_rfail = run-fail
CTEST_MODE_rfail = run-fail
CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)

CTEST_SRC_BASE_cfail = compile-fail
CTEST_BUILD_BASE_cfail = compile-fail
CTEST_MODE_cfail = compile-fail
CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)

519
CTEST_SRC_BASE_bench = bench bench/rt bench/shootout bench/std
520 521 522 523 524 525 526 527 528
CTEST_BUILD_BASE_bench = bench
CTEST_MODE_bench = run-pass
CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)

CTEST_SRC_BASE_perf = bench
CTEST_BUILD_BASE_perf = perf
CTEST_MODE_perf = run-pass
CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)

B
Brian Leibig 已提交
529 530 531 532 533
CTEST_SRC_BASE_debuginfo = debug-info
CTEST_BUILD_BASE_debuginfo = debug-info
CTEST_MODE_debuginfo = debug-info
CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)

534 535 536 537 538
CTEST_SRC_BASE_codegen = codegen
CTEST_BUILD_BASE_codegen = codegen
CTEST_MODE_codegen = codegen
CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)

539 540 541 542
ifeq ($(CFG_GDB),)
CTEST_DISABLE_debuginfo = "no gdb found"
endif

543 544 545 546
ifeq ($(CFG_CLANG),)
CTEST_DISABLE_codegen = "no clang found"
endif

547 548 549 550
ifeq ($(CFG_OSTYPE),apple-darwin)
CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
endif

551 552 553 554 555 556 557 558 559 560 561
define DEF_CTEST_VARS

# All the per-stage build rules you might want to call from the
# command line.
#
# $(1) is the stage number
# $(2) is the target triple to test
# $(3) is the host triple to test

# Prerequisites for compiletest tests
TEST_SREQ$(1)_T_$(2)_H_$(3) = \
562
	$$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
563
	$$(SREQ$(1)_T_$(2)_H_$(3))
B
Brian Anderson 已提交
564

B
Brian Anderson 已提交
565
# Rules for the cfail/rfail/rpass/bench/perf test runner
566

567 568
# The tests select when to use debug configuration on their own;
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
569 570 571 572 573 574 575 576 577
CTEST_RUSTC_FLAGS := $$(subst --cfg debug,,$$(CFG_RUSTC_FLAGS))

# The tests can not be optimized while the rest of the compiler is optimized, so
# filter out the optimization (if any) from rustc and then figure out if we need
# to be optimized
CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
ifndef CFG_DISABLE_OPTIMIZE_TESTS
CTEST_RUSTC_FLAGS += -O
endif
578

N
Niko Matsakis 已提交
579
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) :=						\
N
Niko Matsakis 已提交
580 581
		--compile-lib-path $$(HLIB$(1)_H_$(3))				\
        --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3))			\
582
        --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))			\
583 584
        --clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
        --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD_TRIPLE))/bin \
585
        --aux-base $$(S)src/test/auxiliary/                 \
N
Niko Matsakis 已提交
586
        --stage-id stage$(1)-$(2)							\
587
        --target $(2)                                       \
588
        --adb-path=$(CFG_ADB)                          \
589
        --adb-test-dir=$(CFG_ADB_TEST_DIR)                  \
590
        --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) --target=$(2)" \
N
Niko Matsakis 已提交
591 592
        $$(CTEST_TESTARGS)

593 594 595 596 597 598
CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
B
Brian Leibig 已提交
599
CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
600
CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
N
Niko Matsakis 已提交
601

602
endef
N
Niko Matsakis 已提交
603

604
$(foreach host,$(CFG_HOST_TRIPLES), \
605 606 607
 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(eval $(foreach stage,$(STAGES), \
   $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
N
Niko Matsakis 已提交
608

609
define DEF_RUN_COMPILETEST
610

611 612
CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
        $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3))	\
613 614
        $(foreach base,$$(CTEST_SRC_BASE_$(4)), \
        --src-base $$(S)src/test/$$(base))/ \
615
        --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
616
        --ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
617 618
        --mode $$(CTEST_MODE_$(4)) \
	$$(CTEST_RUNTOOL_$(4))
N
Niko Matsakis 已提交
619

620 621
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

622 623
ifeq ($$(CTEST_DISABLE_$(4)),)

624
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
625 626
		$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
                $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
627
	@$$(call E, run $(4) [$(2)]: $$<)
628
	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
629
		$$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
630 631
		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
                && touch $$@
N
Niko Matsakis 已提交
632

633 634 635 636 637
else

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
		$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
                $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
638
	@$$(call E, run $(4) [$(2)]: $$<)
639 640 641 642 643
	@$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
	touch $$@

endif

644
endef
N
Niko Matsakis 已提交
645

646
CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo codegen
647

648
$(foreach host,$(CFG_HOST_TRIPLES), \
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(eval $(foreach stage,$(STAGES), \
   $(eval $(foreach name,$(CTEST_NAMES), \
   $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))

PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
PRETTY_DIRNAME_pretty-rpass = run-pass
PRETTY_DIRNAME_pretty-rpass-full = run-pass-full
PRETTY_DIRNAME_pretty-rfail = run-fail
PRETTY_DIRNAME_pretty-bench = bench
PRETTY_DIRNAME_pretty-pretty = pretty

define DEF_RUN_PRETTY_TEST

PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) :=			\
N
Niko Matsakis 已提交
669
		$$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3))	\
670 671
        --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
        --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
N
Niko Matsakis 已提交
672 673
        --mode pretty

674 675 676
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
677 678
	        $$(TEST_SREQ$(1)_T_$(2)_H_$(3))		\
	        $$(PRETTY_DEPS_$(4))
679
	@$$(call E, run pretty-rpass [$(2)]: $$<)
680
	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
681
		$$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
682 683
		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
                && touch $$@
N
Niko Matsakis 已提交
684

685
endef
N
Niko Matsakis 已提交
686

687
$(foreach host,$(CFG_HOST_TRIPLES), \
688 689 690 691
 $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(foreach stage,$(STAGES), \
   $(foreach pretty-name,$(PRETTY_NAMES), \
    $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
B
Brian Anderson 已提交
692

693
define DEF_RUN_DOC_TEST
694

695
DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4) := \
696 697 698
        $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3))	\
        --src-base $(3)/test/doc-$(4)/	\
        --build-base $(3)/test/doc-$(4)/	\
699 700
        --mode run-pass

701
check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
702

703
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
704 705
	        $$(TEST_SREQ$(1)_T_$(2)_H_$(3))		\
                doc-$(4)-extract$(3)
706
	@$$(call E, run doc-$(4) [$(2)]: $$<)
707
	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
708
                $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
709 710
		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \
                && touch $$@
711

712
endef
713

714
$(foreach host,$(CFG_HOST_TRIPLES), \
715 716 717 718
 $(foreach target,$(CFG_TARGET_TRIPLES), \
  $(foreach stage,$(STAGES), \
   $(foreach docname,$(DOC_TEST_NAMES), \
    $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
719

720

721 722 723
######################################################################
# Extracting tests for docs
######################################################################
B
Brian Anderson 已提交
724

725
EXTRACT_TESTS := "$(CFG_PYTHON)" $(S)src/etc/extract-tests.py
B
Brian Anderson 已提交
726

727
define DEF_DOC_TEST_HOST
728

729 730 731 732
doc-$(2)-extract$(1):
	@$$(call E, extract: $(2) tests)
	$$(Q)rm -f $(1)/test/doc-$(2)/*.rs
	$$(Q)$$(EXTRACT_TESTS) $$(S)doc/$(2).md $(1)/test/doc-$(2)
733

734
endef
735

736
$(foreach host,$(CFG_HOST_TRIPLES), \
737 738
 $(foreach docname,$(DOC_TEST_NAMES), \
  $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
739

740

741 742 743
######################################################################
# Shortcut rules
######################################################################
744

745 746 747 748 749 750 751 752 753
TEST_GROUPS = \
	crates \
	$(foreach crate,$(TEST_CRATES),$(crate)) \
	rpass \
	rpass-full \
	rfail \
	cfail \
	bench \
	perf \
B
Brian Leibig 已提交
754
	debuginfo \
755
	codegen \
756
	doc \
757
	$(foreach docname,$(DOC_TEST_NAMES),doc-$(docname)) \
758 759 760 761 762 763 764 765 766 767 768
	pretty \
	pretty-rpass \
	pretty-rpass-full \
	pretty-rfail \
	pretty-bench \
	pretty-pretty \
	$(NULL)

define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
endef
769

770 771
$(foreach stage,$(STAGES), \
 $(foreach target,$(CFG_TARGET_TRIPLES), \
772
  $(foreach host,$(CFG_HOST_TRIPLES), \
773
   $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
774

775 776 777
define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
endef
B
Brian Anderson 已提交
778

779 780
$(foreach stage,$(STAGES), \
 $(foreach target,$(CFG_TARGET_TRIPLES), \
781
  $(foreach host,$(CFG_HOST_TRIPLES), \
782 783
   $(foreach group,$(TEST_GROUPS), \
    $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
784

785
define DEF_CHECK_FOR_STAGE
786
check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)
787
check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET_TRIPLES), \
788 789
                           check-stage$(1)-H-$$(target))
endef
790

791 792
$(foreach stage,$(STAGES), \
 $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
793

794
define DEF_CHECK_FOR_STAGE_AND_GROUP
795
check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)-$(2)
796
check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
797 798
                               check-stage$(1)-H-$$(target)-$(2))
endef
799

800 801 802
$(foreach stage,$(STAGES), \
 $(foreach group,$(TEST_GROUPS), \
  $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
803

804 805

define DEF_CHECK_FOR_STAGE_AND_HOSTS
806
check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
807
                           check-stage$(1)-T-$$(target)-H-$(2))
B
Brian Anderson 已提交
808
endef
809

810
$(foreach stage,$(STAGES), \
811
 $(foreach host,$(CFG_HOST_TRIPLES), \
812 813 814
  $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))

define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
815
check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
816 817 818 819
                                check-stage$(1)-T-$$(target)-H-$(2)-$(3))
endef

$(foreach stage,$(STAGES), \
820
 $(foreach host,$(CFG_HOST_TRIPLES), \
821 822
  $(foreach group,$(TEST_GROUPS), \
   $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
823

N
Niko Matsakis 已提交
824
######################################################################
825
# check-fast rules
N
Niko Matsakis 已提交
826
######################################################################
827

828
FT := run_pass_stage2
829
FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD_TRIPLE),$(FT))
830 831
FT_DRIVER := $(FT)_driver

832
GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
N
Niko Matsakis 已提交
833

N
Niko Matsakis 已提交
834
tmp/$(FT).rc tmp/$(FT_DRIVER).rs: \
835
		$(RPASS_TESTS) \
N
Niko Matsakis 已提交
836 837
		$(S)src/etc/combine-tests.py
	@$(call E, check: building combined stage2 test runner)
838
	$(Q)$(CFG_PYTHON) $(S)src/etc/combine-tests.py
N
Niko Matsakis 已提交
839 840 841 842 843 844 845 846 847 848

define DEF_CHECK_FAST_FOR_T_H
# $(1) unused
# $(2) target triple
# $(3) host triple

$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
		tmp/$$(FT).rc \
		$$(SREQ2_T_$(2)_H_$(3))
	@$$(call E, compile_and_link: $$@)
N
Niko Matsakis 已提交
849
	$$(STAGE2_T_$(2)_H_$(3)) --lib -o $$@ $$<
N
Niko Matsakis 已提交
850

851
$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
N
Niko Matsakis 已提交
852 853 854 855
		tmp/$$(FT_DRIVER).rs \
		$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
		$$(SREQ2_T_$(2)_H_$(3))
	@$$(call E, compile_and_link: $$@ $$<)
856
	$$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$<
N
Niko Matsakis 已提交
857

N
Niko Matsakis 已提交
858
$(3)/test/$$(FT_DRIVER)-$(2).out: \
859
		$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)) \
N
Niko Matsakis 已提交
860
		$$(SREQ2_T_$(2)_H_$(3))
861
	$$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) \
862
	--logfile tmp/$$(FT_DRIVER)-$(2).log
N
Niko Matsakis 已提交
863

864
check-fast-T-$(2)-H-$(3):     			\
N
Niko Matsakis 已提交
865
	$(3)/test/$$(FT_DRIVER)-$(2).out
N
Niko Matsakis 已提交
866 867 868

endef

869
$(foreach host,$(CFG_HOST_TRIPLES), \
N
Niko Matsakis 已提交
870 871 872
 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
   $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))

873
check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
N
Niko Matsakis 已提交
874 875 876 877 878 879

define DEF_CHECK_FAST_FOR_H

check-fast-H-$(1): 		check-fast-T-$(1)-H-$(1)

endef
N
Niko Matsakis 已提交
880

881 882
$(foreach host,$(CFG_HOST_TRIPLES),			\
 $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))