compiletest: runtest.rs cleanup
This commit is contained in:
parent
c28c495414
commit
8b24a96e17
@ -755,50 +755,38 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
|
||||
|
||||
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
|
||||
|
||||
|
||||
let mut runargs = ~[];
|
||||
let mut exitcode : int = 1;
|
||||
let mut maxtry = 10;
|
||||
|
||||
// sometimes code generates exit code 1 which is "1 : General unknown error"
|
||||
// in this case, force to retry
|
||||
// while exitcode == 1 && maxtry > 0 {
|
||||
// since adb shell doesnot forward internal result (exit code) and
|
||||
// distingush stderr and stdout, adb_run_wrapper is used
|
||||
// run test via adb_run_wrapper
|
||||
runargs.push(~"shell");
|
||||
runargs.push(fmt!("%s/adb_run_wrapper.sh", config.adb_test_dir));
|
||||
runargs.push(fmt!("%s", config.adb_test_dir));
|
||||
runargs.push(fmt!("%s", prog_short));
|
||||
|
||||
runargs.push(~"shell");
|
||||
runargs.push(fmt!("%s/adb_run_wrapper.sh", config.adb_test_dir));
|
||||
runargs.push(fmt!("%s", config.adb_test_dir));
|
||||
runargs.push(fmt!("%s", prog_short));
|
||||
for args.args.each |tv| {
|
||||
runargs.push(tv.to_owned());
|
||||
}
|
||||
|
||||
for args.args.each |tv| {
|
||||
runargs.push(tv.to_owned());
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
|
||||
|
||||
// get exitcode of result
|
||||
runargs = ~[];
|
||||
runargs.push(~"shell");
|
||||
runargs.push(~"cat");
|
||||
runargs.push(fmt!("%s/%s.exitcode", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
|
||||
Some(~""));
|
||||
|
||||
let mut exitcode : int = 0;
|
||||
for str::each_char(exitcode_out) |c| {
|
||||
if !char::is_digit(c) { break; }
|
||||
exitcode = exitcode * 10 + match c {
|
||||
'0' .. '9' => c as int - ('0' as int),
|
||||
_ => 101,
|
||||
}
|
||||
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
|
||||
|
||||
// get exitcode of result
|
||||
runargs = ~[];
|
||||
|
||||
runargs.push(~"shell");
|
||||
runargs.push(~"cat");
|
||||
runargs.push(fmt!("%s/%s.exitcode", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: exitcode_out, err: exitcode_err, status: exitcode_status } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
|
||||
Some(~""));
|
||||
|
||||
exitcode = 0;
|
||||
for str::each_char(exitcode_out) |c| {
|
||||
if !char::is_digit(c) { break; }
|
||||
exitcode = exitcode * 10 + match c {
|
||||
'0' .. '9' => c as int - ('0' as int),
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
// maxtry = maxtry - 1;
|
||||
// unsafe { libc::sleep(1); }
|
||||
// }
|
||||
}
|
||||
|
||||
// get stdout of result
|
||||
runargs = ~[];
|
||||
@ -806,9 +794,8 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
|
||||
runargs.push(~"cat");
|
||||
runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: stdout_out, err: stdout_err, status: stdout_status } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
|
||||
Some(~""));
|
||||
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
|
||||
|
||||
// get stderr of result
|
||||
runargs = ~[];
|
||||
@ -816,86 +803,14 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
|
||||
runargs.push(~"cat");
|
||||
runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: stderr_out, err: stderr_err, status: stderr_status } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
|
||||
Some(~""));
|
||||
let procsrv::Result{ out: stderr_out, err: _, status: _ } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
|
||||
|
||||
dump_output(config, testfile, stdout_out, stderr_out);
|
||||
|
||||
ProcRes {status: exitcode, stdout: stdout_out, stderr: stderr_out, cmdline: cmdline }
|
||||
}
|
||||
|
||||
fn _arm_exec_compiled_test2(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 = ~[];
|
||||
for str::each_split_char(args.prog, '/') |ts| { tvec.push(ts.to_owned()) }
|
||||
let prog_short = tvec.pop();
|
||||
|
||||
// copy to target
|
||||
let copy_result = procsrv::run("", config.adb_path,
|
||||
[~"push", copy args.prog, copy 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 separately but to stdout only
|
||||
let mut newargs_out = ~[];
|
||||
let mut newargs_err = ~[];
|
||||
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 args.args.each |tv| {
|
||||
newcmd_out.push_str(" ");
|
||||
newcmd_err.push_str(" ");
|
||||
newcmd_out.push_str(*tv);
|
||||
newcmd_err.push_str(*tv);
|
||||
}
|
||||
|
||||
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 procsrv::Result{ out: out_out, err: _out_err, status: out_status } =
|
||||
procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")],
|
||||
Some(~""));
|
||||
let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } =
|
||||
procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")],
|
||||
Some(~""));
|
||||
|
||||
dump_output(config, testfile, out_out, err_out);
|
||||
|
||||
match err_out {
|
||||
~"" => ProcRes {status: out_status, stdout: out_out,
|
||||
stderr: err_out, cmdline: cmdline },
|
||||
_ => ProcRes {status: 101, stdout: out_out,
|
||||
stderr: err_out, cmdline: cmdline }
|
||||
}
|
||||
}
|
||||
|
||||
fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
|
||||
testfile: &Path) -> ProcRes {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user