Skip to content

Commit 5a68074

Browse files
committed
---
yaml --- r: 140489 b: refs/heads/try2 c: f7ef71d h: refs/heads/master i: 140487: 2ab1a7d v: v3
1 parent 64c0793 commit 5a68074

File tree

4 files changed

+159
-8
lines changed

4 files changed

+159
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 57c126e9bbcb4d02c40787afc46f5865874220d7
8+
refs/heads/try2: f7ef71d491fe432eab3c3c9d2ee80a6678ebb952
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/common.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ pub struct config {
6464
// Run tests using the new runtime
6565
newrt: bool,
6666

67+
// Host System to be built
68+
host: ~str,
69+
70+
// Target System to be executed
71+
target: ~str,
72+
73+
// Extra parameter to run arm-linux-androideabi
74+
adb_path: ~str,
75+
76+
// check if can be run or not
77+
flag_runnable: bool,
78+
6779
// Explain what's going on
6880
verbose: bool
6981

branches/try2/src/compiletest/compiletest.rc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ pub fn parse_config(args: ~[~str]) -> config {
6060
getopts::optflag(~"verbose"),
6161
getopts::optopt(~"logfile"),
6262
getopts::optflag(~"jit"),
63-
getopts::optflag(~"newrt")];
63+
getopts::optflag(~"newrt"),
64+
getopts::optopt(~"host"),
65+
getopts::optopt(~"target"),
66+
getopts::optopt(~"adb-path")
67+
];
6468

6569
assert!(!args.is_empty());
6670
let args_ = vec::tail(args);
@@ -93,6 +97,22 @@ pub fn parse_config(args: ~[~str]) -> config {
9397
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
9498
jit: getopts::opt_present(matches, ~"jit"),
9599
newrt: getopts::opt_present(matches, ~"newrt"),
100+
host: opt_str(getopts::opt_maybe_str(matches, ~"host")),
101+
target: opt_str(getopts::opt_maybe_str(matches, ~"target")),
102+
adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")),
103+
flag_runnable:
104+
if (getopts::opt_maybe_str(matches, ~"host") ==
105+
getopts::opt_maybe_str(matches, ~"target")) { true }
106+
else {
107+
match getopts::opt_maybe_str(matches, ~"target") {
108+
Some(~"arm-linux-androideabi") => {
109+
if (getopts::opt_maybe_str(matches, ~"adb-path") !=
110+
option::None) { true }
111+
else { false }
112+
}
113+
_ => { false }
114+
}
115+
},
96116
verbose: getopts::opt_present(matches, ~"verbose")
97117
}
98118
}
@@ -113,6 +133,10 @@ pub fn log_config(config: config) {
113133
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
114134
logv(c, fmt!("jit: %b", config.jit));
115135
logv(c, fmt!("newrt: %b", config.newrt));
136+
logv(c, fmt!("host: %s", config.host));
137+
logv(c, fmt!("target: %s", config.target));
138+
logv(c, fmt!("adb_path: %s", config.adb_path));
139+
logv(c, fmt!("flag_runnable: %b", config.flag_runnable));
116140
logv(c, fmt!("verbose: %b", config.verbose));
117141
logv(c, fmt!("\n"));
118142
}

branches/try2/src/compiletest/runtest.rs

Lines changed: 121 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) {
7777
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes);
7878
}
7979
80-
check_correct_failure_status(ProcRes);
81-
check_error_patterns(props, testfile, ProcRes);
80+
if (config.flag_runnable) {
81+
check_correct_failure_status(ProcRes);
82+
check_error_patterns(props, testfile, ProcRes);
83+
}
8284
}
8385
8486
fn check_correct_failure_status(ProcRes: ProcRes) {
@@ -483,10 +485,96 @@ fn exec_compiled_test(config: config, props: TestProps,
483485
props.exec_env
484486
};
485487

486-
compose_and_run(config, testfile,
487-
make_run_args(config, props, testfile),
488-
env,
489-
config.run_lib_path, None)
488+
if (config.host == config.target) {
489+
compose_and_run(config, testfile,
490+
make_run_args(config, props, testfile),
491+
env,
492+
config.run_lib_path, None)
493+
}
494+
else {
495+
let args = make_run_args(config, props, testfile);
496+
let cmdline = make_cmdline(~"", args.prog, args.args);
497+
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+
503+
match (config.target, config.flag_runnable) {
504+
505+
(~"arm-linux-androideabi", true) => {
506+
507+
// get bare program string
508+
let mut tvec = ~[];
509+
let tstr = args.prog;
510+
for str::each_split_char(tstr, '/') |ts| { tvec.push(ts.to_owned()) }
511+
let prog_short = tvec.pop();
512+
513+
// copy to target
514+
let copy_result = procsrv::run(~"", config.adb_path,
515+
~[~"push", args.prog, ~"/system/tmp"],
516+
~[(~"",~"")], Some(~""));
517+
518+
if config.verbose {
519+
io::stdout().write_str(fmt!("push (%s) %s %s %s",
520+
config.target, args.prog,
521+
copy_result.out, copy_result.err));
522+
}
523+
524+
// execute program
525+
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
526+
527+
// NOTE : adb shell dose not forward to each stdout and stderr of internal result
528+
// but forward to stdout only
529+
let mut newargs_out = ~[];
530+
let mut newargs_err = ~[];
531+
let subargs = args.args;
532+
newargs_out.push(~"shell");
533+
newargs_err.push(~"shell");
534+
535+
let mut newcmd_out = ~"";
536+
let mut newcmd_err = ~"";
537+
newcmd_out.push_str(~"LD_LIBRARY_PATH=/system/tmp; ");
538+
newcmd_err.push_str(~"LD_LIBRARY_PATH=/system/tmp; ");
539+
newcmd_out.push_str(~"export LD_LIBRARY_PATH; ");
540+
newcmd_err.push_str(~"export LD_LIBRARY_PATH; ");
541+
newcmd_out.push_str(~"cd /system/tmp; ");
542+
newcmd_err.push_str(~"cd /system/tmp; ");
543+
newcmd_out.push_str("./");
544+
newcmd_err.push_str("./");
545+
newcmd_out.push_str(prog_short);
546+
newcmd_err.push_str(prog_short);
547+
548+
for vec::each(subargs) |tv| {
549+
newcmd_out.push_str(" ");
550+
newcmd_err.push_str(" ");
551+
newcmd_out.push_str(tv.to_owned());
552+
newcmd_err.push_str(tv.to_owned());
553+
}
554+
555+
newcmd_out.push_str(" 2>/dev/null");
556+
newcmd_err.push_str(" 1>/dev/null");
557+
558+
newargs_out.push(newcmd_out);
559+
newargs_err.push(newcmd_err);
560+
561+
let exe_result_out = procsrv::run(~"", config.adb_path,
562+
newargs_out, ~[(~"",~"")], Some(~""));
563+
let exe_result_err = procsrv::run(~"", config.adb_path,
564+
newargs_err, ~[(~"",~"")], Some(~""));
565+
566+
dump_output(config, testfile, exe_result_out.out, exe_result_err.out);
567+
568+
match exe_result_err.out {
569+
~"" => ProcRes {status: exe_result_out.status, stdout: exe_result_out.out,
570+
stderr: exe_result_err.out, cmdline: cmdline },
571+
_ => ProcRes {status: 101, stdout: exe_result_out.out,
572+
stderr: exe_result_err.out, cmdline: cmdline }
573+
}
574+
}
575+
_=> defaultRes
576+
}
577+
}
490578
}
491579

492580
fn compose_and_run_compiler(
@@ -516,6 +604,33 @@ fn compose_and_run_compiler(
516604
abs_ab.to_str()),
517605
auxres);
518606
}
607+
if (config.host != config.target)
608+
{
609+
match (config.target, config.flag_runnable) {
610+
611+
(~"arm-linux-androideabi", true) => {
612+
613+
let tstr = aux_output_dir_name(config, testfile).to_str();
614+
615+
for os::list_dir_path(&Path(tstr)).each |file| {
616+
617+
if (file.filetype() == Some(~".so")) {
618+
619+
let copy_result = procsrv::run(~"", config.adb_path,
620+
~[~"push", file.to_str(), ~"/system/tmp"],
621+
~[(~"",~"")], Some(~""));
622+
623+
if config.verbose {
624+
io::stdout().write_str(fmt!("push (%s) %s %s %s",
625+
config.target, file.to_str(),
626+
copy_result.out, copy_result.err));
627+
}
628+
}
629+
}
630+
}
631+
_=> ()
632+
}
633+
}
519634
}
520635

521636
compose_and_run(config, testfile, args, ~[],

0 commit comments

Comments
 (0)