Skip to content

Commit 84bdd05

Browse files
committed
compiletest: fix decision rule to run and cleanup
1 parent 9ecb97a commit 84bdd05

File tree

3 files changed

+72
-73
lines changed

3 files changed

+72
-73
lines changed

mk/tests.mk

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -92,48 +92,44 @@ endef
9292
$(foreach target,$(CFG_TARGET_TRIPLES), \
9393
$(eval $(call DEF_TARGET_COMMANDS,$(target))))
9494

95-
# Target specific variables
95+
# Target platform specific variables
9696
# for arm-linux-androidabi
97-
define DEF_RUNNABLE_STATUS
98-
CFG_RUNNABLE_$(1)=$(2)
97+
define DEF_ADB_DEVICE_STATUS
98+
CFG_ADB_DEVICE_STATUS=$(1)
9999
endef
100100

101101
$(foreach target,$(CFG_TARGET_TRIPLES), \
102-
$(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
103-
$(info check: $(target) test set is runnable \
104-
$(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \
105-
$(if $(findstring $(target),"arm-linux-androideabi"), \
106-
$(if $(findstring adb,$(shell which adb)), \
107-
$(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9-]+[[:blank:]]+device')), \
108-
$(info check: $(target) test set is runnable \
109-
$(info check: adb device attached) \
110-
$(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \
111-
$(info check: $(target) test set is not runnable \
112-
$(info check: adb device not attached) \
113-
$(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \
114-
), \
115-
$(info check: $(target) test set is not runnable \
116-
$(info check: adb not found) \
117-
$(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \
102+
$(if $(findstring $(target),"arm-linux-androideabi"), \
103+
$(if $(findstring adb,$(CFG_ADB)), \
104+
$(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
105+
$(info check: $(target) test enabled \
106+
$(info check: android device attached) \
107+
$(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
108+
$(info check: $(target) test disabled \
109+
$(info check: android device not attached) \
110+
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
118111
), \
119-
$(info check: $(target) test set is not runnable \
120-
$(eval $(call DEF_RUNNABLE_STATUS,$(target),false)) \
121-
) \
122-
) \
112+
$(info check: $(target) test disabled \
113+
$(info check: adb not found) \
114+
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
115+
), \
123116
) \
124117
)
125118

126-
ifeq ($(CFG_RUNNABLE_arm-linux-androideabi),true)
127-
CFG_ADB_DEVICE=true
128-
CFG_ADB_PATH := $(shell which adb)
129-
CFG_ADB_TEST_DIR=/system/tmp
119+
ifeq ($(CFG_ADB_DEVICE_STATUS),true)
120+
CFG_ADB_TEST_DIR=/data/tmp
130121

131-
$(info check: device $(CFG_ADB_TEST_DIR) \
132-
$(shell $(CFG_ADB_PATH) remount 1>/dev/null) \
133-
$(shell $(CFG_ADB_PATH) shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
122+
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
123+
$(shell adb remount 1>/dev/null) \
124+
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125+
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
126+
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
134127
)
128+
else
129+
CFG_ADB_TEST_DIR=
135130
endif
136131

132+
137133
######################################################################
138134
# Main test targets
139135
######################################################################
@@ -366,14 +362,15 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4
366362
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
367363
$(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
368364
@$$(call E, run: $$< via adb)
369-
@$(CFG_ADB_PATH) push $$< $(CFG_ADB_TEST_DIR)
370-
@$(CFG_ADB_PATH) shell $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
365+
@$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
366+
@$(CFG_ADB) shell LD_LIBRARY_PATH=$(CFG_ADB_TEST_DIR) \
367+
$(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
371368
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \
372369
tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
373370
@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
374371
@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
375-
@$(CFG_ADB_PATH) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
376-
@$(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
372+
@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
373+
@$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
377374
@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
378375
then \
379376
rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
@@ -400,11 +397,11 @@ $(foreach host,$(CFG_HOST_TRIPLES), \
400397
$(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
401398
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
402399
$(if $(findstring $(target),"arm-linux-androideabi"), \
403-
$(if $(findstring $(CFG_RUNNABLE_arm-linux-androideabi),"true"), \
400+
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
404401
$(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
405402
$(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
406403
), \
407-
$(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
404+
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
408405
))))))
409406

410407

@@ -496,36 +493,19 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
496493

497494
# Rules for the cfail/rfail/rpass/bench/perf test runner
498495

499-
ifeq ($(CFG_ADB_DEVICE),true)
500-
501496
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
502497
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
503498
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
504-
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
499+
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
505500
--aux-base $$(S)src/test/auxiliary/ \
506501
--stage-id stage$(1)-$(2) \
507502
--host $(CFG_BUILD_TRIPLE) \
508503
--target $(2) \
509-
--adb-path=$(CFG_ADB_PATH) \
504+
--adb-path=$(CFG_ADB) \
510505
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
511506
--rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
512507
$$(CTEST_TESTARGS)
513508

514-
else
515-
516-
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
517-
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
518-
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
519-
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
520-
--aux-base $$(S)src/test/auxiliary/ \
521-
--stage-id stage$(1)-$(2) \
522-
--host $(CFG_BUILD_TRIPLE) \
523-
--target $(2) \
524-
--rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
525-
$$(CTEST_TESTARGS)
526-
527-
endif
528-
529509
CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
530510
CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
531511
CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)

src/compiletest/compiletest.rc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ pub fn parse_config(args: ~[~str]) -> config {
108108
else {
109109
match getopts::opt_maybe_str(matches, ~"target") {
110110
Some(~"arm-linux-androideabi") => {
111-
if (getopts::opt_maybe_str(matches, ~"adb-path") !=
112-
option::None) { true }
111+
if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
112+
~"(none)" &&
113+
opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
114+
~"") { true }
113115
else { false }
114116
}
115-
_ => { false }
117+
_ => { true }
116118
}
117119
},
118120
verbose: getopts::opt_present(matches, ~"verbose")

src/compiletest/runtest.rs

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,18 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) {
7777
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes);
7878
}
7979
80-
if (config.flag_runnable) {
80+
if (config.host == config.target) {
8181
check_correct_failure_status(ProcRes);
8282
check_error_patterns(props, testfile, ProcRes);
83+
} else {
84+
match (config.target, config.flag_runnable) {
85+
86+
(~"arm-linux-androideabi", false) => { }
87+
_ => {
88+
check_correct_failure_status(ProcRes);
89+
check_error_patterns(props, testfile, ProcRes);
90+
}
91+
}
8392
}
8493
}
8594

@@ -490,16 +499,10 @@ fn exec_compiled_test(config: config, props: TestProps,
490499
make_run_args(config, props, testfile),
491500
env,
492501
config.run_lib_path, None)
493-
}
494-
else {
502+
} else {
495503
let args = make_run_args(config, props, testfile);
496504
let cmdline = make_cmdline(~"", args.prog, args.args);
497505

498-
let defaultRes = match config.mode {
499-
mode_run_fail => ProcRes {status: 101, stdout: ~"", stderr: ~"", cmdline: cmdline},
500-
_ => ProcRes {status: 0, stdout: ~"", stderr: ~"", cmdline: cmdline}
501-
};
502-
503506
match (config.target, config.flag_runnable) {
504507

505508
(~"arm-linux-androideabi", true) => {
@@ -524,8 +527,8 @@ fn exec_compiled_test(config: config, props: TestProps,
524527
// execute program
525528
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
526529

527-
// NOTE : adb shell dose not forward to each stdout and stderr of internal result
528-
// but forward to stdout only
530+
// NOTE: adb shell dose not forward stdout and stderr of internal result
531+
// to stdout and stderr seperately but to stdout only
529532
let mut newargs_out = ~[];
530533
let mut newargs_err = ~[];
531534
let subargs = args.args;
@@ -534,12 +537,11 @@ fn exec_compiled_test(config: config, props: TestProps,
534537

535538
let mut newcmd_out = ~"";
536539
let mut newcmd_err = ~"";
537-
newcmd_out.push_str(fmt!(
538-
"LD_LIBRARY_PATH=%s; export LD_LIBRARY_PATH; cd %s; ./%s",
540+
541+
newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
539542
config.adb_test_dir, config.adb_test_dir, prog_short));
540543

541-
newcmd_err.push_str(fmt!(
542-
"LD_LIBRARY_PATH=%s; export LD_LIBRARY_PATH; cd %s; ./%s",
544+
newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
543545
config.adb_test_dir, config.adb_test_dir, prog_short));
544546

545547
for vec::each(subargs) |tv| {
@@ -569,7 +571,22 @@ fn exec_compiled_test(config: config, props: TestProps,
569571
stderr: exe_result_err.out, cmdline: cmdline }
570572
}
571573
}
572-
_=> defaultRes
574+
575+
(~"arm-linux-androideabi", false) => {
576+
match config.mode {
577+
mode_run_fail => ProcRes {status: 101, stdout: ~"",
578+
stderr: ~"", cmdline: cmdline},
579+
_ => ProcRes {status: 0, stdout: ~"",
580+
stderr: ~"", cmdline: cmdline}
581+
}
582+
}
583+
584+
_=> {
585+
compose_and_run(config, testfile,
586+
make_run_args(config, props, testfile),
587+
env,
588+
config.run_lib_path, None)
589+
}
573590
}
574591
}
575592
}

0 commit comments

Comments
 (0)