mirror of https://github.com/rust-lang/rust.git
Make Android tests fail if no device is available
This commit is contained in:
parent
8f6df87c1d
commit
4a03e04755
19
mk/tests.mk
19
mk/tests.mk
|
@ -133,16 +133,13 @@ $(foreach target,$(CFG_TARGET), \
|
||||||
$(if $(findstring $(target),"arm-linux-androideabi"), \
|
$(if $(findstring $(target),"arm-linux-androideabi"), \
|
||||||
$(if $(findstring adb,$(CFG_ADB)), \
|
$(if $(findstring adb,$(CFG_ADB)), \
|
||||||
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
|
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
|
||||||
$(info check: $(target) test enabled \
|
$(info check: android device attached) \
|
||||||
$(info check: android device attached) \
|
$(eval $(call DEF_ADB_DEVICE_STATUS, true)), \
|
||||||
$(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
|
$(info check: android device not attached) \
|
||||||
$(info check: $(target) test disabled \
|
$(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
|
||||||
$(info check: android device not attached) \
|
|
||||||
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
|
|
||||||
), \
|
), \
|
||||||
$(info check: $(target) test disabled \
|
$(info check: adb not found) \
|
||||||
$(info check: adb not found) \
|
$(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
|
||||||
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
|
|
||||||
), \
|
), \
|
||||||
) \
|
) \
|
||||||
)
|
)
|
||||||
|
@ -451,8 +448,8 @@ 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)): \
|
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
|
||||||
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
|
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
|
||||||
@$$(call E, run: skipped $$< )
|
@$$(call E, failing: no device for $$< )
|
||||||
@touch $$@
|
false
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach host,$(CFG_HOST), \
|
$(foreach host,$(CFG_HOST), \
|
||||||
|
|
|
@ -37,6 +37,18 @@ use std::vec;
|
||||||
use extra::test::MetricMap;
|
use extra::test::MetricMap;
|
||||||
|
|
||||||
pub fn run(config: config, testfile: ~str) {
|
pub fn run(config: config, testfile: ~str) {
|
||||||
|
|
||||||
|
match config.target {
|
||||||
|
|
||||||
|
~"arm-linux-androideabi" => {
|
||||||
|
if !config.adb_device_status {
|
||||||
|
fail!("android device not available");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_=> { }
|
||||||
|
}
|
||||||
|
|
||||||
let mut _mm = MetricMap::new();
|
let mut _mm = MetricMap::new();
|
||||||
run_metrics(config, testfile, &mut _mm);
|
run_metrics(config, testfile, &mut _mm);
|
||||||
}
|
}
|
||||||
|
@ -99,20 +111,8 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||||
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", &ProcRes);
|
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", &ProcRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
match config.target {
|
check_correct_failure_status(&ProcRes);
|
||||||
|
check_error_patterns(props, testfile, &ProcRes);
|
||||||
~"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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_correct_failure_status(ProcRes: &ProcRes) {
|
fn check_correct_failure_status(ProcRes: &ProcRes) {
|
||||||
|
@ -275,86 +275,86 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||||
let mut ProcArgs;
|
let mut ProcArgs;
|
||||||
match config.target {
|
match config.target {
|
||||||
~"arm-linux-androideabi" => {
|
~"arm-linux-androideabi" => {
|
||||||
if (config.adb_device_status) {
|
|
||||||
|
|
||||||
cmds = cmds.replace("run","continue");
|
cmds = cmds.replace("run","continue");
|
||||||
|
|
||||||
// write debugger script
|
// write debugger script
|
||||||
let script_str = [~"set charset UTF-8",
|
let script_str = [~"set charset UTF-8",
|
||||||
format!("file {}",exe_file.as_str().unwrap().to_owned()),
|
format!("file {}",exe_file.as_str().unwrap().to_owned()),
|
||||||
~"target remote :5039",
|
~"target remote :5039",
|
||||||
cmds,
|
cmds,
|
||||||
~"quit"].connect("\n");
|
~"quit"].connect("\n");
|
||||||
debug!("script_str = {}", script_str);
|
debug!("script_str = {}", script_str);
|
||||||
dump_output_file(config, testfile, script_str, "debugger.script");
|
dump_output_file(config, testfile, script_str, "debugger.script");
|
||||||
|
|
||||||
|
|
||||||
procsrv::run("", config.adb_path,
|
procsrv::run("", config.adb_path,
|
||||||
[~"push", exe_file.as_str().unwrap().to_owned(), config.adb_test_dir.clone()],
|
[~"push", exe_file.as_str().unwrap().to_owned(),
|
||||||
~[(~"",~"")], Some(~""))
|
config.adb_test_dir.clone()],
|
||||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
~[(~"",~"")], Some(~""))
|
||||||
|
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||||
|
|
||||||
procsrv::run("", config.adb_path,
|
procsrv::run("", config.adb_path,
|
||||||
[~"forward", ~"tcp:5039", ~"tcp:5039"],
|
[~"forward", ~"tcp:5039", ~"tcp:5039"],
|
||||||
~[(~"",~"")], Some(~""))
|
~[(~"",~"")], Some(~""))
|
||||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||||
|
|
||||||
let adb_arg = format!("export LD_LIBRARY_PATH={}; gdbserver :5039 {}/{}",
|
let adb_arg = format!("export LD_LIBRARY_PATH={}; gdbserver :5039 {}/{}",
|
||||||
config.adb_test_dir.clone(), config.adb_test_dir.clone(),
|
config.adb_test_dir.clone(), config.adb_test_dir.clone(),
|
||||||
str::from_utf8(exe_file.filename().unwrap()));
|
str::from_utf8(exe_file.filename().unwrap()));
|
||||||
|
|
||||||
let mut process = procsrv::run_background("", config.adb_path,
|
let mut process = procsrv::run_background("", config.adb_path,
|
||||||
[~"shell",adb_arg.clone()],~[(~"",~"")], Some(~""))
|
[~"shell",adb_arg.clone()],
|
||||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
~[(~"",~"")], Some(~""))
|
||||||
loop {
|
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||||
//waiting 1 second for gdbserver start
|
loop {
|
||||||
timer::sleep(1000);
|
//waiting 1 second for gdbserver start
|
||||||
let result = do task::try {
|
timer::sleep(1000);
|
||||||
tcp::TcpStream::connect(
|
let result = do task::try {
|
||||||
|
tcp::TcpStream::connect(
|
||||||
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 5039 });
|
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 5039 });
|
||||||
};
|
};
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let args = split_maybe_args(&config.rustcflags);
|
||||||
|
let mut tool_path:~str = ~"";
|
||||||
|
for arg in args.iter() {
|
||||||
|
if arg.contains("--android-cross-path=") {
|
||||||
|
tool_path = arg.replace("--android-cross-path=","");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = split_maybe_args(&config.rustcflags);
|
|
||||||
let mut tool_path:~str = ~"";
|
|
||||||
for arg in args.iter() {
|
|
||||||
if arg.contains("--android-cross-path=") {
|
|
||||||
tool_path = arg.replace("--android-cross-path=","");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if tool_path.equals(&~"") {
|
|
||||||
fatal(~"cannot found android cross path");
|
|
||||||
}
|
|
||||||
|
|
||||||
let debugger_script = make_out_name(config, testfile, "debugger.script");
|
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
|
||||||
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
|
|
||||||
"-command=" + debugger_script.as_str().unwrap().to_owned()];
|
|
||||||
|
|
||||||
let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb");
|
|
||||||
let procsrv::Result{ out, err, status }=
|
|
||||||
procsrv::run("",
|
|
||||||
gdb_path,
|
|
||||||
debugger_opts, ~[(~"",~"")], None)
|
|
||||||
.expect(format!("failed to exec `{}`", gdb_path));
|
|
||||||
let cmdline = {
|
|
||||||
let cmdline = make_cmdline("", "arm-linux-androideabi-gdb", debugger_opts);
|
|
||||||
logv(config, format!("executing {}", cmdline));
|
|
||||||
cmdline
|
|
||||||
};
|
|
||||||
|
|
||||||
ProcRes = ProcRes {status: status,
|
|
||||||
stdout: out,
|
|
||||||
stderr: err,
|
|
||||||
cmdline: cmdline};
|
|
||||||
process.force_destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tool_path.equals(&~"") {
|
||||||
|
fatal(~"cannot found android cross path");
|
||||||
|
}
|
||||||
|
|
||||||
|
let debugger_script = make_out_name(config, testfile, "debugger.script");
|
||||||
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
|
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
|
||||||
|
"-command=" + debugger_script.as_str().unwrap().to_owned()];
|
||||||
|
|
||||||
|
let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb");
|
||||||
|
let procsrv::Result{ out, err, status }=
|
||||||
|
procsrv::run("",
|
||||||
|
gdb_path,
|
||||||
|
debugger_opts, ~[(~"",~"")], None)
|
||||||
|
.expect(format!("failed to exec `{}`", gdb_path));
|
||||||
|
let cmdline = {
|
||||||
|
let cmdline = make_cmdline("", "arm-linux-androideabi-gdb", debugger_opts);
|
||||||
|
logv(config, format!("executing {}", cmdline));
|
||||||
|
cmdline
|
||||||
|
};
|
||||||
|
|
||||||
|
ProcRes = ProcRes {status: status,
|
||||||
|
stdout: out,
|
||||||
|
stderr: err,
|
||||||
|
cmdline: cmdline};
|
||||||
|
process.force_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
_=> {
|
_=> {
|
||||||
|
@ -662,11 +662,7 @@ fn exec_compiled_test(config: &config, props: &TestProps,
|
||||||
match config.target {
|
match config.target {
|
||||||
|
|
||||||
~"arm-linux-androideabi" => {
|
~"arm-linux-androideabi" => {
|
||||||
if (config.adb_device_status) {
|
_arm_exec_compiled_test(config, props, testfile, env)
|
||||||
_arm_exec_compiled_test(config, props, testfile, env)
|
|
||||||
} else {
|
|
||||||
_dummy_exec_compiled_test(config, props, testfile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_=> {
|
_=> {
|
||||||
|
@ -710,9 +706,7 @@ fn compose_and_run_compiler(
|
||||||
match config.target {
|
match config.target {
|
||||||
|
|
||||||
~"arm-linux-androideabi" => {
|
~"arm-linux-androideabi" => {
|
||||||
if (config.adb_device_status) {
|
_arm_push_aux_shared_library(config, testfile);
|
||||||
_arm_push_aux_shared_library(config, testfile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_=> { }
|
_=> { }
|
||||||
|
@ -992,20 +986,6 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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: process::ExitStatus(101), stdout: ~"",
|
|
||||||
stderr: ~"", cmdline: cmdline},
|
|
||||||
_ => ProcRes {status: process::ExitStatus(0), stdout: ~"",
|
|
||||||
stderr: ~"", cmdline: cmdline}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
|
fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
|
||||||
let tdir = aux_output_dir_name(config, testfile);
|
let tdir = aux_output_dir_name(config, testfile);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue