From dca88701a311c7dffec1ee5e990df9570647ba03 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 1 May 2013 18:49:19 +0900 Subject: [PATCH 01/11] mk: install-runtime-target added to install.mk (pushing shared library to android target) --- mk/install.mk | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/mk/install.mk b/mk/install.mk index a84f527a165..693589980ce 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -154,3 +154,66 @@ uninstall: done $(Q)rm -Rf $(PHL)/rustc $(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustc.1 + +# target platform specific variables +# for arm-linux-androidabi +define DEF_ADB_STATUS +CFG_ADB_DEVICE=$(1) +endef + +$(foreach target,$(CFG_TARGET_TRIPLES), \ + $(if $(findstring $(target),"arm-linux-androideabi"), \ + $(if $(findstring adb,$(shell which adb)), \ + $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9]+[[:blank:]]+device')), \ + $(info install: install-runtime-target for arm-linux-androideabi enabled \ + $(info install: android device attached) \ + $(eval $(call DEF_ADB_STATUS, true))), \ + $(info install: install-runtime-target for arm-linux-androideabi disabled \ + $(info install: android device not attached) \ + $(eval $(call DEF_ADB_STATUS, false))) \ + ), \ + $(info install: install-runtime-target for arm-linux-androideabi disabled \ + $(info install: adb not found) \ + $(eval $(call DEF_ADB_STATUS, false))) \ + ), \ + ) \ +) + +ifeq ($(CFG_ADB_DEVICE),true) + +ifdef VERBOSE + ADB = adb $(1) + ADB_PUSH = adb push $(1) $(2) + ADB_SHELL = adb shell $(1) $(2) +else + ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null 2>/dev/null + ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null 2>/dev/null + ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null 2>/dev/null +endif + +define INSTALL_RUNTIME_TARGET_N +install-runtime-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2)) + $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CFG_RUNTIME_$(1)),/system/lib) + $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CORELIB_GLOB_$(1)),/system/lib) + $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(STDLIB_GLOB_$(1)),/system/lib) +endef + +define INSTALL_RUNTIME_TARGET_CLEANUP_N +install-runtime-target-$(1)-cleanup: + $(Q)$(call ADB,remount) + $(Q)$(call ADB_SHELL,rm,/system/lib/$(CFG_RUNTIME_$(1))) + $(Q)$(call ADB_SHELL,rm,/system/lib/$(CORELIB_GLOB_$(1))) + $(Q)$(call ADB_SHELL,rm,/system/lib/$(STDLIB_GLOB_$(1))) +endef + +$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD_TRIPLE))) +$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi)) + +install-runtime-target: \ + install-runtime-target-arm-linux-androideabi-cleanup \ + install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD_TRIPLE) + +else +install-runtime-target: + @echo +endif From 57c126e9bbcb4d02c40787afc46f5865874220d7 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 1 May 2013 18:50:23 +0900 Subject: [PATCH 02/11] mk: test.mk expanded to ARM test automation --- mk/tests.mk | 113 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 108 insertions(+), 5 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index f96b7325f60..9b01c4af80f 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -92,6 +92,48 @@ endef $(foreach target,$(CFG_TARGET_TRIPLES), \ $(eval $(call DEF_TARGET_COMMANDS,$(target)))) +# Target specific variables +# for arm-linux-androidabi +define DEF_RUNNABLE_STATUS +CFG_RUNNABLE_$(1)=$(2) +endef + +$(foreach target,$(CFG_TARGET_TRIPLES), \ + $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \ + $(info check: $(target) test set is runnable \ + $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \ + $(if $(findstring $(target),"arm-linux-androideabi"), \ + $(if $(findstring adb,$(shell which adb)), \ + $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9]+[[:blank:]]+device')), \ + $(info check: $(target) test set is runnable \ + $(info check: adb device attached) \ + $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \ + $(info check: $(target) test set is not runnable \ + $(info check: adb device not attached) \ + $(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \ + ), \ + $(info check: $(target) test set is not runnable \ + $(info check: adb not found) \ + $(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \ + ), \ + $(info check: $(target) test set is not runnable \ + $(eval $(call DEF_RUNNABLE_STATUS,$(target),false)) \ + ) \ + ) \ + ) \ +) + +ifeq ($(CFG_RUNNABLE_arm-linux-androideabi),true) +CFG_ADB_DEVICE=true +CFG_ADB_PATH := $(shell which adb) +CFG_ADB_TEST_DIR=/system/tmp + +$(info check: device $(CFG_ADB_TEST_DIR) \ + $(shell $(CFG_ADB_PATH) shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \ + $(shell $(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \ + $(shell $(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \ + ) +endif ###################################################################### # Main test targets @@ -319,11 +361,52 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ && touch $$@ endef +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)): \ + $(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2)) + @$$(call E, run: $$< via adb) + @$(CFG_ADB_PATH) push $$< $(CFG_ADB_TEST_DIR) + @$(CFG_ADB_PATH) shell $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \ + --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \ + tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp + @cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp + @touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log + @$(CFG_ADB_PATH) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/ + @$(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log + @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)): \ + $(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2)) + @$$(call E, run: skipped $$< ) + @touch $$@ +endef + $(foreach host,$(CFG_HOST_TRIPLES), \ $(foreach target,$(CFG_TARGET_TRIPLES), \ $(foreach stage,$(STAGES), \ $(foreach crate, $(TEST_CRATES), \ - $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))))))) + $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \ + $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \ + $(if $(findstring $(target),"arm-linux-androideabi"), \ + $(if $(findstring $(CFG_RUNNABLE_arm-linux-androideabi),"true"), \ + $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \ + $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \ + ), \ + $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \ + )))))) ###################################################################### @@ -414,15 +497,35 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \ # Rules for the cfail/rfail/rpass/bench/perf test runner +ifeq ($(CFG_ADB_DEVICE),true) + CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \ --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ + --host $(3) \ + --target $(2) \ + --adb-path=$(CFG_ADB_PATH) \ --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ $$(CTEST_TESTARGS) +else + +CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ + --compile-lib-path $$(HLIB$(1)_H_$(3)) \ + --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ + --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ + --aux-base $$(S)src/test/auxiliary/ \ + --stage-id stage$(1)-$(2) \ + --host $(3) \ + --target $(2) \ + --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ + $$(CTEST_TESTARGS) + +endif + 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) @@ -454,7 +557,7 @@ ifeq ($$(CTEST_DISABLE_$(4)),) $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3)) - @$$(call E, run $(4): $$<) + @$$(call E, run $(4) [$(2)]: $$<) $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \ $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \ --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \ @@ -465,7 +568,7 @@ else $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3)) - @$$(call E, run $(4): $$<) + @$$(call E, run $(4) [$(2)]: $$<) @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4))) touch $$@ @@ -506,7 +609,7 @@ 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)): \ $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ $$(PRETTY_DEPS_$(4)) - @$$(call E, run pretty-rpass: $$<) + @$$(call E, run pretty-rpass [$(2)]: $$<) $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \ $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \ --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \ @@ -533,7 +636,7 @@ check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3) $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \ $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ doc-$(4)-extract$(3) - @$$(call E, run doc-$(4): $$<) + @$$(call E, run doc-$(4) [$(2)]: $$<) $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \ $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \ --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \ From f7ef71d491fe432eab3c3c9d2ee80a6678ebb952 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 1 May 2013 18:52:08 +0900 Subject: [PATCH 03/11] compiletest: expanded to ARM test automation --- src/compiletest/common.rs | 12 ++++ src/compiletest/compiletest.rc | 26 ++++++- src/compiletest/runtest.rs | 127 +++++++++++++++++++++++++++++++-- 3 files changed, 158 insertions(+), 7 deletions(-) diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index e515ef302f6..73322fe1bde 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -64,6 +64,18 @@ pub struct config { // Run tests using the new runtime newrt: bool, + // Host System to be built + host: ~str, + + // Target System to be executed + target: ~str, + + // Extra parameter to run arm-linux-androideabi + adb_path: ~str, + + // check if can be run or not + flag_runnable: bool, + // Explain what's going on verbose: bool diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 4392ce7ba28..70e09fc7bab 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -60,7 +60,11 @@ pub fn parse_config(args: ~[~str]) -> config { getopts::optflag(~"verbose"), getopts::optopt(~"logfile"), getopts::optflag(~"jit"), - getopts::optflag(~"newrt")]; + getopts::optflag(~"newrt"), + getopts::optopt(~"host"), + getopts::optopt(~"target"), + getopts::optopt(~"adb-path") + ]; assert!(!args.is_empty()); let args_ = vec::tail(args); @@ -93,6 +97,22 @@ pub fn parse_config(args: ~[~str]) -> config { rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"), jit: getopts::opt_present(matches, ~"jit"), newrt: getopts::opt_present(matches, ~"newrt"), + host: opt_str(getopts::opt_maybe_str(matches, ~"host")), + target: opt_str(getopts::opt_maybe_str(matches, ~"target")), + adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")), + flag_runnable: + if (getopts::opt_maybe_str(matches, ~"host") == + getopts::opt_maybe_str(matches, ~"target")) { true } + else { + match getopts::opt_maybe_str(matches, ~"target") { + Some(~"arm-linux-androideabi") => { + if (getopts::opt_maybe_str(matches, ~"adb-path") != + option::None) { true } + else { false } + } + _ => { false } + } + }, verbose: getopts::opt_present(matches, ~"verbose") } } @@ -113,6 +133,10 @@ pub fn log_config(config: config) { logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags))); logv(c, fmt!("jit: %b", config.jit)); logv(c, fmt!("newrt: %b", config.newrt)); + logv(c, fmt!("host: %s", config.host)); + logv(c, fmt!("target: %s", config.target)); + logv(c, fmt!("adb_path: %s", config.adb_path)); + logv(c, fmt!("flag_runnable: %b", config.flag_runnable)); logv(c, fmt!("verbose: %b", config.verbose)); logv(c, fmt!("\n")); } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index fef4cabf7fd..4b07835163c 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -77,8 +77,10 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) { fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes); } - check_correct_failure_status(ProcRes); - check_error_patterns(props, testfile, ProcRes); + if (config.flag_runnable) { + check_correct_failure_status(ProcRes); + check_error_patterns(props, testfile, ProcRes); + } } fn check_correct_failure_status(ProcRes: ProcRes) { @@ -483,10 +485,96 @@ fn exec_compiled_test(config: config, props: TestProps, props.exec_env }; - compose_and_run(config, testfile, - make_run_args(config, props, testfile), - env, - config.run_lib_path, None) + if (config.host == config.target) { + compose_and_run(config, testfile, + make_run_args(config, props, testfile), + env, + config.run_lib_path, None) + } + else { + let args = make_run_args(config, props, testfile); + let cmdline = make_cmdline(~"", args.prog, args.args); + + let defaultRes = match config.mode { + mode_run_fail => ProcRes {status: 101, stdout: ~"", stderr: ~"", cmdline: cmdline}, + _ => ProcRes {status: 0, stdout: ~"", stderr: ~"", cmdline: cmdline} + }; + + match (config.target, config.flag_runnable) { + + (~"arm-linux-androideabi", true) => { + + // get bare program string + let mut tvec = ~[]; + let tstr = args.prog; + for str::each_split_char(tstr, '/') |ts| { tvec.push(ts.to_owned()) } + let prog_short = tvec.pop(); + + // copy to target + let copy_result = procsrv::run(~"", config.adb_path, + ~[~"push", args.prog, ~"/system/tmp"], + ~[(~"",~"")], Some(~"")); + + if config.verbose { + io::stdout().write_str(fmt!("push (%s) %s %s %s", + config.target, args.prog, + copy_result.out, copy_result.err)); + } + + // execute program + logv(config, fmt!("executing (%s) %s", config.target, cmdline)); + + // NOTE : adb shell dose not forward to each stdout and stderr of internal result + // but forward to stdout only + let mut newargs_out = ~[]; + let mut newargs_err = ~[]; + let subargs = args.args; + newargs_out.push(~"shell"); + newargs_err.push(~"shell"); + + let mut newcmd_out = ~""; + let mut newcmd_err = ~""; + newcmd_out.push_str(~"LD_LIBRARY_PATH=/system/tmp; "); + newcmd_err.push_str(~"LD_LIBRARY_PATH=/system/tmp; "); + newcmd_out.push_str(~"export LD_LIBRARY_PATH; "); + newcmd_err.push_str(~"export LD_LIBRARY_PATH; "); + newcmd_out.push_str(~"cd /system/tmp; "); + newcmd_err.push_str(~"cd /system/tmp; "); + newcmd_out.push_str("./"); + newcmd_err.push_str("./"); + newcmd_out.push_str(prog_short); + newcmd_err.push_str(prog_short); + + for vec::each(subargs) |tv| { + newcmd_out.push_str(" "); + newcmd_err.push_str(" "); + newcmd_out.push_str(tv.to_owned()); + newcmd_err.push_str(tv.to_owned()); + } + + newcmd_out.push_str(" 2>/dev/null"); + newcmd_err.push_str(" 1>/dev/null"); + + newargs_out.push(newcmd_out); + newargs_err.push(newcmd_err); + + let exe_result_out = procsrv::run(~"", config.adb_path, + newargs_out, ~[(~"",~"")], Some(~"")); + let exe_result_err = procsrv::run(~"", config.adb_path, + newargs_err, ~[(~"",~"")], Some(~"")); + + dump_output(config, testfile, exe_result_out.out, exe_result_err.out); + + match exe_result_err.out { + ~"" => ProcRes {status: exe_result_out.status, stdout: exe_result_out.out, + stderr: exe_result_err.out, cmdline: cmdline }, + _ => ProcRes {status: 101, stdout: exe_result_out.out, + stderr: exe_result_err.out, cmdline: cmdline } + } + } + _=> defaultRes + } + } } fn compose_and_run_compiler( @@ -516,6 +604,33 @@ fn compose_and_run_compiler( abs_ab.to_str()), auxres); } + if (config.host != config.target) + { + match (config.target, config.flag_runnable) { + + (~"arm-linux-androideabi", true) => { + + let tstr = aux_output_dir_name(config, testfile).to_str(); + + for os::list_dir_path(&Path(tstr)).each |file| { + + if (file.filetype() == Some(~".so")) { + + let copy_result = procsrv::run(~"", config.adb_path, + ~[~"push", file.to_str(), ~"/system/tmp"], + ~[(~"",~"")], Some(~"")); + + if config.verbose { + io::stdout().write_str(fmt!("push (%s) %s %s %s", + config.target, file.to_str(), + copy_result.out, copy_result.err)); + } + } + } + } + _=> () + } + } } compose_and_run(config, testfile, args, ~[], From 9d6544667e09259e0a4ccab72e0bd1687102f2c8 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 1 May 2013 19:18:57 +0900 Subject: [PATCH 04/11] compiletest: fix to remove trailing whitespace --- src/compiletest/runtest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 4b07835163c..ad128f4529c 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -524,7 +524,7 @@ fn exec_compiled_test(config: config, props: TestProps, // execute program logv(config, fmt!("executing (%s) %s", config.target, cmdline)); - // NOTE : adb shell dose not forward to each stdout and stderr of internal result + // NOTE : adb shell dose not forward to each stdout and stderr of internal result // but forward to stdout only let mut newargs_out = ~[]; let mut newargs_err = ~[]; From 3afd708e2acd767f1af90de52c139c1b6b877311 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Thu, 2 May 2013 08:58:24 +0900 Subject: [PATCH 05/11] mk: minor fix for test.mk to support mutiple target test --- mk/tests.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 9b01c4af80f..21754a9f51d 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -505,7 +505,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ - --host $(3) \ + --host $(CFG_BUILD_TRIPLE) \ --target $(2) \ --adb-path=$(CFG_ADB_PATH) \ --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ @@ -519,7 +519,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ - --host $(3) \ + --host $(CFG_BUILD_TRIPLE) \ --target $(2) \ --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ $$(CTEST_TESTARGS) From 6f6dd86248d5c3ece0e668537e78a71198f36ddd Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Thu, 2 May 2013 13:16:01 +0900 Subject: [PATCH 06/11] compiletest: configurable test dir for ARM --- mk/tests.mk | 7 ++++--- src/compiletest/common.rs | 5 ++++- src/compiletest/compiletest.rc | 5 ++++- src/compiletest/runtest.rs | 21 +++++++++------------ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 21754a9f51d..310dec8de79 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -502,12 +502,13 @@ ifeq ($(CFG_ADB_DEVICE),true) CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \ --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ - --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ - --aux-base $$(S)src/test/auxiliary/ \ + --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ + --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ --host $(CFG_BUILD_TRIPLE) \ --target $(2) \ --adb-path=$(CFG_ADB_PATH) \ + --adb-test-dir=$(CFG_ADB_TEST_DIR) \ --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ $$(CTEST_TESTARGS) @@ -516,7 +517,7 @@ else CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \ --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ - --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ + --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ --host $(CFG_BUILD_TRIPLE) \ diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 73322fe1bde..87a7dae5a7f 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -70,9 +70,12 @@ pub struct config { // Target System to be executed target: ~str, - // Extra parameter to run arm-linux-androideabi + // Extra parameter to run adb on arm-linux-androideabi adb_path: ~str, + // Extra parameter to run test sute on arm-linux-androideabi + adb_test_dir: ~str, + // check if can be run or not flag_runnable: bool, diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 70e09fc7bab..5575c01a906 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -63,7 +63,8 @@ pub fn parse_config(args: ~[~str]) -> config { getopts::optflag(~"newrt"), getopts::optopt(~"host"), getopts::optopt(~"target"), - getopts::optopt(~"adb-path") + getopts::optopt(~"adb-path"), + getopts::optopt(~"adb-test-dir") ]; assert!(!args.is_empty()); @@ -100,6 +101,7 @@ pub fn parse_config(args: ~[~str]) -> config { host: opt_str(getopts::opt_maybe_str(matches, ~"host")), target: opt_str(getopts::opt_maybe_str(matches, ~"target")), adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")), + adb_test_dir: opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")), flag_runnable: if (getopts::opt_maybe_str(matches, ~"host") == getopts::opt_maybe_str(matches, ~"target")) { true } @@ -136,6 +138,7 @@ pub fn log_config(config: config) { logv(c, fmt!("host: %s", config.host)); logv(c, fmt!("target: %s", config.target)); logv(c, fmt!("adb_path: %s", config.adb_path)); + logv(c, fmt!("adb_test_dir: %s", config.adb_test_dir)); logv(c, fmt!("flag_runnable: %b", config.flag_runnable)); logv(c, fmt!("verbose: %b", config.verbose)); logv(c, fmt!("\n")); diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index ad128f4529c..142460fe0dc 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -512,7 +512,7 @@ fn exec_compiled_test(config: config, props: TestProps, // copy to target let copy_result = procsrv::run(~"", config.adb_path, - ~[~"push", args.prog, ~"/system/tmp"], + ~[~"push", args.prog, config.adb_test_dir], ~[(~"",~"")], Some(~"")); if config.verbose { @@ -534,16 +534,13 @@ fn exec_compiled_test(config: config, props: TestProps, let mut newcmd_out = ~""; let mut newcmd_err = ~""; - newcmd_out.push_str(~"LD_LIBRARY_PATH=/system/tmp; "); - newcmd_err.push_str(~"LD_LIBRARY_PATH=/system/tmp; "); - newcmd_out.push_str(~"export LD_LIBRARY_PATH; "); - newcmd_err.push_str(~"export LD_LIBRARY_PATH; "); - newcmd_out.push_str(~"cd /system/tmp; "); - newcmd_err.push_str(~"cd /system/tmp; "); - newcmd_out.push_str("./"); - newcmd_err.push_str("./"); - newcmd_out.push_str(prog_short); - newcmd_err.push_str(prog_short); + newcmd_out.push_str(fmt!( + "LD_LIBRARY_PATH=%s; export LD_LIBRARY_PATH; cd %s; ./%s", + config.adb_test_dir, config.adb_test_dir, prog_short)); + + newcmd_err.push_str(fmt!( + "LD_LIBRARY_PATH=%s; export LD_LIBRARY_PATH; cd %s; ./%s", + config.adb_test_dir, config.adb_test_dir, prog_short)); for vec::each(subargs) |tv| { newcmd_out.push_str(" "); @@ -617,7 +614,7 @@ fn compose_and_run_compiler( if (file.filetype() == Some(~".so")) { let copy_result = procsrv::run(~"", config.adb_path, - ~[~"push", file.to_str(), ~"/system/tmp"], + ~[~"push", file.to_str(), config.adb_test_dir], ~[(~"",~"")], Some(~"")); if config.verbose { From 17b368fd2225ffc65333a9a5293fca4f6bdcf7f5 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Fri, 3 May 2013 11:14:01 +0900 Subject: [PATCH 07/11] mk: configurable android test directory --- mk/install.mk | 17 ++++++++++------- mk/tests.mk | 5 ++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mk/install.mk b/mk/install.mk index 693589980ce..71ea1d02a0e 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -164,7 +164,7 @@ endef $(foreach target,$(CFG_TARGET_TRIPLES), \ $(if $(findstring $(target),"arm-linux-androideabi"), \ $(if $(findstring adb,$(shell which adb)), \ - $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9]+[[:blank:]]+device')), \ + $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9-]+[[:blank:]]+device')), \ $(info install: install-runtime-target for arm-linux-androideabi enabled \ $(info install: android device attached) \ $(eval $(call DEF_ADB_STATUS, true))), \ @@ -181,6 +181,8 @@ $(foreach target,$(CFG_TARGET_TRIPLES), \ ifeq ($(CFG_ADB_DEVICE),true) +CFG_RUNTIME_PUSH_DIR=/system/lib + ifdef VERBOSE ADB = adb $(1) ADB_PUSH = adb push $(1) $(2) @@ -193,17 +195,18 @@ endif define INSTALL_RUNTIME_TARGET_N install-runtime-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2)) - $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CFG_RUNTIME_$(1)),/system/lib) - $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CORELIB_GLOB_$(1)),/system/lib) - $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(STDLIB_GLOB_$(1)),/system/lib) + $(Q)$(call ADB_SHELL,mkdir,$(CFG_RUNTIME_PUSH_DIR)) + $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CFG_RUNTIME_$(1)),$(CFG_RUNTIME_PUSH_DIR)) + $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CORELIB_GLOB_$(1)),$(CFG_RUNTIME_PUSH_DIR)) + $(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(STDLIB_GLOB_$(1)),$(CFG_RUNTIME_PUSH_DIR)) endef define INSTALL_RUNTIME_TARGET_CLEANUP_N install-runtime-target-$(1)-cleanup: $(Q)$(call ADB,remount) - $(Q)$(call ADB_SHELL,rm,/system/lib/$(CFG_RUNTIME_$(1))) - $(Q)$(call ADB_SHELL,rm,/system/lib/$(CORELIB_GLOB_$(1))) - $(Q)$(call ADB_SHELL,rm,/system/lib/$(STDLIB_GLOB_$(1))) + $(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(CFG_RUNTIME_$(1))) + $(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(CORELIB_GLOB_$(1))) + $(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(STDLIB_GLOB_$(1))) endef $(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD_TRIPLE))) diff --git a/mk/tests.mk b/mk/tests.mk index 310dec8de79..7fbba309562 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -104,7 +104,7 @@ $(foreach target,$(CFG_TARGET_TRIPLES), \ $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \ $(if $(findstring $(target),"arm-linux-androideabi"), \ $(if $(findstring adb,$(shell which adb)), \ - $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9]+[[:blank:]]+device')), \ + $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9-]+[[:blank:]]+device')), \ $(info check: $(target) test set is runnable \ $(info check: adb device attached) \ $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \ @@ -129,9 +129,8 @@ CFG_ADB_PATH := $(shell which adb) CFG_ADB_TEST_DIR=/system/tmp $(info check: device $(CFG_ADB_TEST_DIR) \ + $(shell $(CFG_ADB_PATH) remount 1>/dev/null) \ $(shell $(CFG_ADB_PATH) shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \ - $(shell $(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \ - $(shell $(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \ ) endif From 35214d3c6cd5f70b38baa6d879ca40d9db8118ba Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 4 May 2013 00:46:52 +0900 Subject: [PATCH 08/11] configure: CFG_ADB for adb added --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index 884ececa24b..0c4afa0566d 100755 --- a/configure +++ b/configure @@ -439,6 +439,10 @@ then probe CFG_ZCAT zcat fi +step_msg "looking for target specific programs" + +probe CFG_ADB adb + if [ ! -z "$CFG_PANDOC" ] then PV_MAJOR_MINOR=$(pandoc --version | grep '^pandoc ' | From 9ecb97ae58c6fde97bfe58aeddd11790899bd4ec Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 4 May 2013 00:47:54 +0900 Subject: [PATCH 09/11] mk: install.mk directory argument pass for install-runtime-target --- mk/install.mk | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/mk/install.mk b/mk/install.mk index 71ea1d02a0e..5fa477a790d 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -157,40 +157,46 @@ uninstall: # target platform specific variables # for arm-linux-androidabi -define DEF_ADB_STATUS -CFG_ADB_DEVICE=$(1) +define DEF_ADB_DEVICE_STATUS +CFG_ADB_DEVICE_STATUS=$(1) endef $(foreach target,$(CFG_TARGET_TRIPLES), \ $(if $(findstring $(target),"arm-linux-androideabi"), \ - $(if $(findstring adb,$(shell which adb)), \ - $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9-]+[[:blank:]]+device')), \ - $(info install: install-runtime-target for arm-linux-androideabi enabled \ + $(if $(findstring adb,$(CFG_ADB)), \ + $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \ + $(info install: install-runtime-target for $(target) enabled \ $(info install: android device attached) \ - $(eval $(call DEF_ADB_STATUS, true))), \ - $(info install: install-runtime-target for arm-linux-androideabi disabled \ + $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \ + $(info install: install-runtime-target for $(target) disabled \ $(info install: android device not attached) \ - $(eval $(call DEF_ADB_STATUS, false))) \ + $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \ ), \ - $(info install: install-runtime-target for arm-linux-androideabi disabled \ + $(info install: install-runtime-target for $(target) disabled \ $(info install: adb not found) \ - $(eval $(call DEF_ADB_STATUS, false))) \ + $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \ ), \ ) \ ) -ifeq ($(CFG_ADB_DEVICE),true) - +ifeq (install-runtime-target,$(firstword $(MAKECMDGOALS))) +$(eval $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:) +L_TOKEN := $(word 2,$(MAKECMDGOALS)) +ifeq ($(L_TOKEN),) CFG_RUNTIME_PUSH_DIR=/system/lib +else +CFG_RUNTIME_PUSH_DIR=$(L_TOKEN) +endif +ifeq ($(CFG_ADB_DEVICE_STATUS),true) ifdef VERBOSE ADB = adb $(1) ADB_PUSH = adb push $(1) $(2) ADB_SHELL = adb shell $(1) $(2) else - ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null 2>/dev/null - ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null 2>/dev/null - ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null 2>/dev/null + ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null + ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null + ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null endif define INSTALL_RUNTIME_TARGET_N @@ -215,8 +221,9 @@ $(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi)) install-runtime-target: \ install-runtime-target-arm-linux-androideabi-cleanup \ install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD_TRIPLE) - else install-runtime-target: - @echo + @echo "No device to install runtime library" + @echo +endif endif From 84bdd05accba00254e999e1d73b963cca3388d33 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 4 May 2013 00:49:18 +0900 Subject: [PATCH 10/11] compiletest: fix decision rule to run and cleanup --- mk/tests.mk | 90 +++++++++++++--------------------- src/compiletest/compiletest.rc | 8 +-- src/compiletest/runtest.rs | 47 ++++++++++++------ 3 files changed, 72 insertions(+), 73 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 7fbba309562..9997f170a98 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -92,48 +92,44 @@ endef $(foreach target,$(CFG_TARGET_TRIPLES), \ $(eval $(call DEF_TARGET_COMMANDS,$(target)))) -# Target specific variables +# Target platform specific variables # for arm-linux-androidabi -define DEF_RUNNABLE_STATUS -CFG_RUNNABLE_$(1)=$(2) +define DEF_ADB_DEVICE_STATUS +CFG_ADB_DEVICE_STATUS=$(1) endef $(foreach target,$(CFG_TARGET_TRIPLES), \ - $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \ - $(info check: $(target) test set is runnable \ - $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \ - $(if $(findstring $(target),"arm-linux-androideabi"), \ - $(if $(findstring adb,$(shell which adb)), \ - $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9-]+[[:blank:]]+device')), \ - $(info check: $(target) test set is runnable \ - $(info check: adb device attached) \ - $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \ - $(info check: $(target) test set is not runnable \ - $(info check: adb device not attached) \ - $(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \ - ), \ - $(info check: $(target) test set is not runnable \ - $(info check: adb not found) \ - $(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \ + $(if $(findstring $(target),"arm-linux-androideabi"), \ + $(if $(findstring adb,$(CFG_ADB)), \ + $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \ + $(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))) \ ), \ - $(info check: $(target) test set is not runnable \ - $(eval $(call DEF_RUNNABLE_STATUS,$(target),false)) \ - ) \ - ) \ + $(info check: $(target) test disabled \ + $(info check: adb not found) \ + $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \ + ), \ ) \ ) -ifeq ($(CFG_RUNNABLE_arm-linux-androideabi),true) -CFG_ADB_DEVICE=true -CFG_ADB_PATH := $(shell which adb) -CFG_ADB_TEST_DIR=/system/tmp +ifeq ($(CFG_ADB_DEVICE_STATUS),true) +CFG_ADB_TEST_DIR=/data/tmp -$(info check: device $(CFG_ADB_TEST_DIR) \ - $(shell $(CFG_ADB_PATH) remount 1>/dev/null) \ - $(shell $(CFG_ADB_PATH) shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \ +$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \ + $(shell adb remount 1>/dev/null) \ + $(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \ + $(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \ + $(CFG_ADB_TEST_DIR) 1>/dev/null) \ ) +else +CFG_ADB_TEST_DIR= endif + ###################################################################### # Main test targets ###################################################################### @@ -366,14 +362,15 @@ 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)): \ $(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2)) @$$(call E, run: $$< via adb) - @$(CFG_ADB_PATH) push $$< $(CFG_ADB_TEST_DIR) - @$(CFG_ADB_PATH) shell $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \ + @$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR) + @$(CFG_ADB) shell LD_LIBRARY_PATH=$(CFG_ADB_TEST_DIR) \ + $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \ --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \ tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp @cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp @touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log - @$(CFG_ADB_PATH) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/ - @$(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log + @$(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 @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; \ @@ -400,11 +397,11 @@ $(foreach host,$(CFG_HOST_TRIPLES), \ $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \ $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \ $(if $(findstring $(target),"arm-linux-androideabi"), \ - $(if $(findstring $(CFG_RUNNABLE_arm-linux-androideabi),"true"), \ + $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \ $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \ $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \ ), \ - $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \ + $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \ )))))) @@ -496,36 +493,19 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \ # Rules for the cfail/rfail/rpass/bench/perf test runner -ifeq ($(CFG_ADB_DEVICE),true) - CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \ --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ - --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ + --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ --host $(CFG_BUILD_TRIPLE) \ --target $(2) \ - --adb-path=$(CFG_ADB_PATH) \ + --adb-path=$(CFG_ADB) \ --adb-test-dir=$(CFG_ADB_TEST_DIR) \ --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ $$(CTEST_TESTARGS) -else - -CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ - --compile-lib-path $$(HLIB$(1)_H_$(3)) \ - --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ - --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ - --aux-base $$(S)src/test/auxiliary/ \ - --stage-id stage$(1)-$(2) \ - --host $(CFG_BUILD_TRIPLE) \ - --target $(2) \ - --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \ - $$(CTEST_TESTARGS) - -endif - 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) diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 5575c01a906..fab73d78021 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -108,11 +108,13 @@ pub fn parse_config(args: ~[~str]) -> config { else { match getopts::opt_maybe_str(matches, ~"target") { Some(~"arm-linux-androideabi") => { - if (getopts::opt_maybe_str(matches, ~"adb-path") != - option::None) { true } + if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != + ~"(none)" && + opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != + ~"") { true } else { false } } - _ => { false } + _ => { true } } }, verbose: getopts::opt_present(matches, ~"verbose") diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 142460fe0dc..d1319c395ad 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -77,9 +77,18 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) { fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes); } - if (config.flag_runnable) { + if (config.host == config.target) { check_correct_failure_status(ProcRes); check_error_patterns(props, testfile, ProcRes); + } else { + match (config.target, config.flag_runnable) { + + (~"arm-linux-androideabi", false) => { } + _ => { + check_correct_failure_status(ProcRes); + check_error_patterns(props, testfile, ProcRes); + } + } } } @@ -490,16 +499,10 @@ fn exec_compiled_test(config: config, props: TestProps, make_run_args(config, props, testfile), env, config.run_lib_path, None) - } - else { + } else { let args = make_run_args(config, props, testfile); let cmdline = make_cmdline(~"", args.prog, args.args); - let defaultRes = match config.mode { - mode_run_fail => ProcRes {status: 101, stdout: ~"", stderr: ~"", cmdline: cmdline}, - _ => ProcRes {status: 0, stdout: ~"", stderr: ~"", cmdline: cmdline} - }; - match (config.target, config.flag_runnable) { (~"arm-linux-androideabi", true) => { @@ -524,8 +527,8 @@ fn exec_compiled_test(config: config, props: TestProps, // execute program logv(config, fmt!("executing (%s) %s", config.target, cmdline)); - // NOTE : adb shell dose not forward to each stdout and stderr of internal result - // but forward to stdout only + // NOTE: adb shell dose not forward stdout and stderr of internal result + // to stdout and stderr seperately but to stdout only let mut newargs_out = ~[]; let mut newargs_err = ~[]; let subargs = args.args; @@ -534,12 +537,11 @@ fn exec_compiled_test(config: config, props: TestProps, let mut newcmd_out = ~""; let mut newcmd_err = ~""; - newcmd_out.push_str(fmt!( - "LD_LIBRARY_PATH=%s; export LD_LIBRARY_PATH; cd %s; ./%s", + + newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", config.adb_test_dir, config.adb_test_dir, prog_short)); - newcmd_err.push_str(fmt!( - "LD_LIBRARY_PATH=%s; export LD_LIBRARY_PATH; cd %s; ./%s", + newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", config.adb_test_dir, config.adb_test_dir, prog_short)); for vec::each(subargs) |tv| { @@ -569,7 +571,22 @@ fn exec_compiled_test(config: config, props: TestProps, stderr: exe_result_err.out, cmdline: cmdline } } } - _=> defaultRes + + (~"arm-linux-androideabi", false) => { + match config.mode { + mode_run_fail => ProcRes {status: 101, stdout: ~"", + stderr: ~"", cmdline: cmdline}, + _ => ProcRes {status: 0, stdout: ~"", + stderr: ~"", cmdline: cmdline} + } + } + + _=> { + compose_and_run(config, testfile, + make_run_args(config, props, testfile), + env, + config.run_lib_path, None) + } } } } From 5681571f6c3480ececdefd07eb313baa6c13ae22 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 4 May 2013 10:35:07 +0900 Subject: [PATCH 11/11] compiletest: remove --host and cleanup --- mk/tests.mk | 3 +- src/compiletest/common.rs | 9 +- src/compiletest/compiletest.rc | 29 ++-- src/compiletest/runtest.rs | 250 +++++++++++++++++---------------- 4 files changed, 145 insertions(+), 146 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 9997f170a98..35ced32f1f2 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -497,9 +497,8 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \ --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ - --aux-base $$(S)src/test/auxiliary/ \ + --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ - --host $(CFG_BUILD_TRIPLE) \ --target $(2) \ --adb-path=$(CFG_ADB) \ --adb-test-dir=$(CFG_ADB_TEST_DIR) \ diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 87a7dae5a7f..38289f62741 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -64,10 +64,7 @@ pub struct config { // Run tests using the new runtime newrt: bool, - // Host System to be built - host: ~str, - - // Target System to be executed + // Target system to be tested target: ~str, // Extra parameter to run adb on arm-linux-androideabi @@ -76,8 +73,8 @@ pub struct config { // Extra parameter to run test sute on arm-linux-androideabi adb_test_dir: ~str, - // check if can be run or not - flag_runnable: bool, + // status whether android device available or not + adb_device_status: bool, // Explain what's going on verbose: bool diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index fab73d78021..3fb6937819e 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -61,7 +61,6 @@ pub fn parse_config(args: ~[~str]) -> config { getopts::optopt(~"logfile"), getopts::optflag(~"jit"), getopts::optflag(~"newrt"), - getopts::optopt(~"host"), getopts::optopt(~"target"), getopts::optopt(~"adb-path"), getopts::optopt(~"adb-test-dir") @@ -98,25 +97,18 @@ pub fn parse_config(args: ~[~str]) -> config { rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"), jit: getopts::opt_present(matches, ~"jit"), newrt: getopts::opt_present(matches, ~"newrt"), - host: opt_str(getopts::opt_maybe_str(matches, ~"host")), target: opt_str(getopts::opt_maybe_str(matches, ~"target")), adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")), adb_test_dir: opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")), - flag_runnable: - if (getopts::opt_maybe_str(matches, ~"host") == - getopts::opt_maybe_str(matches, ~"target")) { true } - else { - match getopts::opt_maybe_str(matches, ~"target") { - Some(~"arm-linux-androideabi") => { - if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != - ~"(none)" && - opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != - ~"") { true } - else { false } - } - _ => { true } - } - }, + adb_device_status: + if (opt_str(getopts::opt_maybe_str(matches, ~"target")) == + ~"arm-linux-androideabi") { + if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != + ~"(none)" && + opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != + ~"") { true } + else { false } + } else { false }, verbose: getopts::opt_present(matches, ~"verbose") } } @@ -137,11 +129,10 @@ pub fn log_config(config: config) { logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags))); logv(c, fmt!("jit: %b", config.jit)); logv(c, fmt!("newrt: %b", config.newrt)); - logv(c, fmt!("host: %s", config.host)); logv(c, fmt!("target: %s", config.target)); logv(c, fmt!("adb_path: %s", config.adb_path)); logv(c, fmt!("adb_test_dir: %s", config.adb_test_dir)); - logv(c, fmt!("flag_runnable: %b", config.flag_runnable)); + logv(c, fmt!("adb_device_status: %b", config.adb_device_status)); logv(c, fmt!("verbose: %b", config.verbose)); logv(c, fmt!("\n")); } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index d1319c395ad..07b439174be 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -77,18 +77,19 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) { fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes); } - if (config.host == config.target) { - check_correct_failure_status(ProcRes); - check_error_patterns(props, testfile, ProcRes); - } else { - match (config.target, config.flag_runnable) { + match config.target { - (~"arm-linux-androideabi", false) => { } - _ => { + ~"arm-linux-androideabi" => { + if (config.adb_device_status) { check_correct_failure_status(ProcRes); check_error_patterns(props, testfile, ProcRes); } } + + _=> { + check_correct_failure_status(ProcRes); + check_error_patterns(props, testfile, ProcRes); + } } } @@ -494,99 +495,21 @@ fn exec_compiled_test(config: config, props: TestProps, props.exec_env }; - if (config.host == config.target) { - compose_and_run(config, testfile, - make_run_args(config, props, testfile), - env, - config.run_lib_path, None) - } else { - let args = make_run_args(config, props, testfile); - let cmdline = make_cmdline(~"", args.prog, args.args); + match config.target { - match (config.target, config.flag_runnable) { - - (~"arm-linux-androideabi", true) => { - - // get bare program string - let mut tvec = ~[]; - let tstr = args.prog; - for str::each_split_char(tstr, '/') |ts| { tvec.push(ts.to_owned()) } - let prog_short = tvec.pop(); - - // copy to target - let copy_result = procsrv::run(~"", config.adb_path, - ~[~"push", args.prog, config.adb_test_dir], - ~[(~"",~"")], Some(~"")); - - if config.verbose { - io::stdout().write_str(fmt!("push (%s) %s %s %s", - config.target, args.prog, - copy_result.out, copy_result.err)); - } - - // execute program - logv(config, fmt!("executing (%s) %s", config.target, cmdline)); - - // NOTE: adb shell dose not forward stdout and stderr of internal result - // to stdout and stderr seperately but to stdout only - let mut newargs_out = ~[]; - let mut newargs_err = ~[]; - let subargs = args.args; - newargs_out.push(~"shell"); - newargs_err.push(~"shell"); - - let mut newcmd_out = ~""; - let mut newcmd_err = ~""; - - newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", - config.adb_test_dir, config.adb_test_dir, prog_short)); - - newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", - config.adb_test_dir, config.adb_test_dir, prog_short)); - - for vec::each(subargs) |tv| { - newcmd_out.push_str(" "); - newcmd_err.push_str(" "); - newcmd_out.push_str(tv.to_owned()); - newcmd_err.push_str(tv.to_owned()); - } - - newcmd_out.push_str(" 2>/dev/null"); - newcmd_err.push_str(" 1>/dev/null"); - - newargs_out.push(newcmd_out); - newargs_err.push(newcmd_err); - - let exe_result_out = procsrv::run(~"", config.adb_path, - newargs_out, ~[(~"",~"")], Some(~"")); - let exe_result_err = procsrv::run(~"", config.adb_path, - newargs_err, ~[(~"",~"")], Some(~"")); - - dump_output(config, testfile, exe_result_out.out, exe_result_err.out); - - match exe_result_err.out { - ~"" => ProcRes {status: exe_result_out.status, stdout: exe_result_out.out, - stderr: exe_result_err.out, cmdline: cmdline }, - _ => ProcRes {status: 101, stdout: exe_result_out.out, - stderr: exe_result_err.out, cmdline: cmdline } - } + ~"arm-linux-androideabi" => { + if (config.adb_device_status) { + _arm_exec_compiled_test(config, props, testfile) + } else { + _dummy_exec_compiled_test(config, props, testfile) } + } - (~"arm-linux-androideabi", false) => { - match config.mode { - mode_run_fail => ProcRes {status: 101, stdout: ~"", - stderr: ~"", cmdline: cmdline}, - _ => ProcRes {status: 0, stdout: ~"", - stderr: ~"", cmdline: cmdline} - } - } - - _=> { - compose_and_run(config, testfile, - make_run_args(config, props, testfile), - env, - config.run_lib_path, None) - } + _=> { + compose_and_run(config, testfile, + make_run_args(config, props, testfile), + env, + config.run_lib_path, None) } } } @@ -618,32 +541,16 @@ fn compose_and_run_compiler( abs_ab.to_str()), auxres); } - if (config.host != config.target) - { - match (config.target, config.flag_runnable) { - (~"arm-linux-androideabi", true) => { + match config.target { - let tstr = aux_output_dir_name(config, testfile).to_str(); - - for os::list_dir_path(&Path(tstr)).each |file| { - - if (file.filetype() == Some(~".so")) { - - let copy_result = procsrv::run(~"", config.adb_path, - ~[~"push", file.to_str(), config.adb_test_dir], - ~[(~"",~"")], Some(~"")); - - if config.verbose { - io::stdout().write_str(fmt!("push (%s) %s %s %s", - config.target, file.to_str(), - copy_result.out, copy_result.err)); - } - } - } + ~"arm-linux-androideabi" => { + if (config.adb_device_status) { + _arm_push_aux_shared_library(config, testfile); } - _=> () } + + _=> { } } } @@ -829,3 +736,108 @@ stderr:\n\ io::stdout().write_str(msg); fail!(); } + +fn _arm_exec_compiled_test(config: config, props: TestProps, + testfile: &Path) -> ProcRes { + + let args = make_run_args(config, props, testfile); + let cmdline = make_cmdline(~"", args.prog, args.args); + + // get bare program string + let mut tvec = ~[]; + let tstr = args.prog; + for str::each_split_char(tstr, '/') |ts| { tvec.push(ts.to_owned()) } + let prog_short = tvec.pop(); + + // copy to target + let copy_result = procsrv::run(~"", config.adb_path, + ~[~"push", args.prog, config.adb_test_dir], + ~[(~"",~"")], Some(~"")); + + if config.verbose { + io::stdout().write_str(fmt!("push (%s) %s %s %s", + config.target, args.prog, + copy_result.out, copy_result.err)); + } + + // execute program + logv(config, fmt!("executing (%s) %s", config.target, cmdline)); + + // adb shell dose not forward stdout and stderr of internal result + // to stdout and stderr seperately but to stdout only + let mut newargs_out = ~[]; + let mut newargs_err = ~[]; + let subargs = args.args; + newargs_out.push(~"shell"); + newargs_err.push(~"shell"); + + let mut newcmd_out = ~""; + let mut newcmd_err = ~""; + + newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", + config.adb_test_dir, config.adb_test_dir, prog_short)); + + newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", + config.adb_test_dir, config.adb_test_dir, prog_short)); + + for vec::each(subargs) |tv| { + newcmd_out.push_str(" "); + newcmd_err.push_str(" "); + newcmd_out.push_str(tv.to_owned()); + newcmd_err.push_str(tv.to_owned()); + } + + newcmd_out.push_str(" 2>/dev/null"); + newcmd_err.push_str(" 1>/dev/null"); + + newargs_out.push(newcmd_out); + newargs_err.push(newcmd_err); + + let exe_result_out = procsrv::run(~"", config.adb_path, + newargs_out, ~[(~"",~"")], Some(~"")); + let exe_result_err = procsrv::run(~"", config.adb_path, + newargs_err, ~[(~"",~"")], Some(~"")); + + dump_output(config, testfile, exe_result_out.out, exe_result_err.out); + + match exe_result_err.out { + ~"" => ProcRes {status: exe_result_out.status, stdout: exe_result_out.out, + stderr: exe_result_err.out, cmdline: cmdline }, + _ => ProcRes {status: 101, stdout: exe_result_out.out, + stderr: exe_result_err.out, cmdline: cmdline } + } +} + +fn _dummy_exec_compiled_test(config: config, props: TestProps, + testfile: &Path) -> ProcRes { + + let args = make_run_args(config, props, testfile); + let cmdline = make_cmdline(~"", args.prog, args.args); + + match config.mode { + mode_run_fail => ProcRes {status: 101, stdout: ~"", + stderr: ~"", cmdline: cmdline}, + _ => ProcRes {status: 0, stdout: ~"", + stderr: ~"", cmdline: cmdline} + } +} + +fn _arm_push_aux_shared_library(config: config, testfile: &Path) { + let tstr = aux_output_dir_name(config, testfile).to_str(); + + for os::list_dir_path(&Path(tstr)).each |file| { + + if (file.filetype() == Some(~".so")) { + + let copy_result = procsrv::run(~"", config.adb_path, + ~[~"push", file.to_str(), config.adb_test_dir], + ~[(~"",~"")], Some(~"")); + + if config.verbose { + io::stdout().write_str(fmt!("push (%s) %s %s %s", + config.target, file.to_str(), + copy_result.out, copy_result.err)); + } + } + } +}