Skip to content

Commit 8b24a96

Browse files
committed
compiletest: runtest.rs cleanup
1 parent c28c495 commit 8b24a96

File tree

1 file changed

+30
-115
lines changed

1 file changed

+30
-115
lines changed

src/compiletest/runtest.rs

Lines changed: 30 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -755,147 +755,62 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
755755

756756
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
757757

758-
759758
let mut runargs = ~[];
760-
let mut exitcode : int = 1;
761-
let mut maxtry = 10;
762-
763-
// sometimes code generates exit code 1 which is "1 : General unknown error"
764-
// in this case, force to retry
765-
// while exitcode == 1 && maxtry > 0 {
766-
// since adb shell doesnot forward internal result (exit code) and
767-
// distingush stderr and stdout, adb_run_wrapper is used
768-
769-
runargs.push(~"shell");
770-
runargs.push(fmt!("%s/adb_run_wrapper.sh", config.adb_test_dir));
771-
runargs.push(fmt!("%s", config.adb_test_dir));
772-
runargs.push(fmt!("%s", prog_short));
773-
774-
for args.args.each |tv| {
775-
runargs.push(tv.to_owned());
776-
}
777-
778-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
779759

780-
// get exitcode of result
781-
runargs = ~[];
760+
// run test via adb_run_wrapper
761+
runargs.push(~"shell");
762+
runargs.push(fmt!("%s/adb_run_wrapper.sh", config.adb_test_dir));
763+
runargs.push(fmt!("%s", config.adb_test_dir));
764+
runargs.push(fmt!("%s", prog_short));
782765

783-
runargs.push(~"shell");
784-
runargs.push(~"cat");
785-
runargs.push(fmt!("%s/%s.exitcode", config.adb_test_dir, prog_short));
766+
for args.args.each |tv| {
767+
runargs.push(tv.to_owned());
768+
}
786769

787-
let procsrv::Result{ out: exitcode_out, err: exitcode_err, status: exitcode_status } =
788-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
789-
Some(~""));
770+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
790771

791-
exitcode = 0;
792-
for str::each_char(exitcode_out) |c| {
793-
if !char::is_digit(c) { break; }
794-
exitcode = exitcode * 10 + match c {
795-
'0' .. '9' => c as int - ('0' as int),
796-
_ => 0,
797-
}
772+
// get exitcode of result
773+
runargs = ~[];
774+
runargs.push(~"shell");
775+
runargs.push(~"cat");
776+
runargs.push(fmt!("%s/%s.exitcode", config.adb_test_dir, prog_short));
777+
778+
let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
779+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
780+
Some(~""));
781+
782+
let mut exitcode : int = 0;
783+
for str::each_char(exitcode_out) |c| {
784+
if !char::is_digit(c) { break; }
785+
exitcode = exitcode * 10 + match c {
786+
'0' .. '9' => c as int - ('0' as int),
787+
_ => 101,
798788
}
799-
// maxtry = maxtry - 1;
800-
// unsafe { libc::sleep(1); }
801-
// }
789+
}
802790

803791
// get stdout of result
804792
runargs = ~[];
805793
runargs.push(~"shell");
806794
runargs.push(~"cat");
807795
runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short));
808796

809-
let procsrv::Result{ out: stdout_out, err: stdout_err, status: stdout_status } =
810-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
811-
Some(~""));
797+
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
798+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
812799

813800
// get stderr of result
814801
runargs = ~[];
815802
runargs.push(~"shell");
816803
runargs.push(~"cat");
817804
runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short));
818805

819-
let procsrv::Result{ out: stderr_out, err: stderr_err, status: stderr_status } =
820-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
821-
Some(~""));
806+
let procsrv::Result{ out: stderr_out, err: _, status: _ } =
807+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
822808

823809
dump_output(config, testfile, stdout_out, stderr_out);
824810

825811
ProcRes {status: exitcode, stdout: stdout_out, stderr: stderr_out, cmdline: cmdline }
826812
}
827813

828-
fn _arm_exec_compiled_test2(config: &config, props: &TestProps,
829-
testfile: &Path) -> ProcRes {
830-
831-
let args = make_run_args(config, props, testfile);
832-
let cmdline = make_cmdline("", args.prog, args.args);
833-
834-
// get bare program string
835-
let mut tvec = ~[];
836-
for str::each_split_char(args.prog, '/') |ts| { tvec.push(ts.to_owned()) }
837-
let prog_short = tvec.pop();
838-
839-
// copy to target
840-
let copy_result = procsrv::run("", config.adb_path,
841-
[~"push", copy args.prog, copy config.adb_test_dir],
842-
~[(~"",~"")], Some(~""));
843-
844-
if config.verbose {
845-
io::stdout().write_str(fmt!("push (%s) %s %s %s",
846-
config.target, args.prog,
847-
copy_result.out, copy_result.err));
848-
}
849-
850-
// execute program
851-
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
852-
853-
// adb shell dose not forward stdout and stderr of internal result
854-
// to stdout and stderr separately but to stdout only
855-
let mut newargs_out = ~[];
856-
let mut newargs_err = ~[];
857-
newargs_out.push(~"shell");
858-
newargs_err.push(~"shell");
859-
860-
let mut newcmd_out = ~"";
861-
let mut newcmd_err = ~"";
862-
863-
newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
864-
config.adb_test_dir, config.adb_test_dir, prog_short));
865-
866-
newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
867-
config.adb_test_dir, config.adb_test_dir, prog_short));
868-
869-
for args.args.each |tv| {
870-
newcmd_out.push_str(" ");
871-
newcmd_err.push_str(" ");
872-
newcmd_out.push_str(*tv);
873-
newcmd_err.push_str(*tv);
874-
}
875-
876-
newcmd_out.push_str(" 2>/dev/null");
877-
newcmd_err.push_str(" 1>/dev/null");
878-
879-
newargs_out.push(newcmd_out);
880-
newargs_err.push(newcmd_err);
881-
882-
let procsrv::Result{ out: out_out, err: _out_err, status: out_status } =
883-
procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")],
884-
Some(~""));
885-
let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } =
886-
procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")],
887-
Some(~""));
888-
889-
dump_output(config, testfile, out_out, err_out);
890-
891-
match err_out {
892-
~"" => ProcRes {status: out_status, stdout: out_out,
893-
stderr: err_out, cmdline: cmdline },
894-
_ => ProcRes {status: 101, stdout: out_out,
895-
stderr: err_out, cmdline: cmdline }
896-
}
897-
}
898-
899814
fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
900815
testfile: &Path) -> ProcRes {
901816

0 commit comments

Comments
 (0)