Skip to content

Commit 5681571

Browse files
committed
compiletest: remove --host and cleanup
1 parent 84bdd05 commit 5681571

File tree

4 files changed

+145
-146
lines changed

4 files changed

+145
-146
lines changed

mk/tests.mk

+1-2
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,8 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
497497
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
498498
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
499499
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
500-
--aux-base $$(S)src/test/auxiliary/ \
500+
--aux-base $$(S)src/test/auxiliary/ \
501501
--stage-id stage$(1)-$(2) \
502-
--host $(CFG_BUILD_TRIPLE) \
503502
--target $(2) \
504503
--adb-path=$(CFG_ADB) \
505504
--adb-test-dir=$(CFG_ADB_TEST_DIR) \

src/compiletest/common.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ 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
67+
// Target system to be tested
7168
target: ~str,
7269

7370
// Extra parameter to run adb on arm-linux-androideabi
@@ -76,8 +73,8 @@ pub struct config {
7673
// Extra parameter to run test sute on arm-linux-androideabi
7774
adb_test_dir: ~str,
7875

79-
// check if can be run or not
80-
flag_runnable: bool,
76+
// status whether android device available or not
77+
adb_device_status: bool,
8178

8279
// Explain what's going on
8380
verbose: bool

src/compiletest/compiletest.rc

+10-19
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ pub fn parse_config(args: ~[~str]) -> config {
6161
getopts::optopt(~"logfile"),
6262
getopts::optflag(~"jit"),
6363
getopts::optflag(~"newrt"),
64-
getopts::optopt(~"host"),
6564
getopts::optopt(~"target"),
6665
getopts::optopt(~"adb-path"),
6766
getopts::optopt(~"adb-test-dir")
@@ -98,25 +97,18 @@ pub fn parse_config(args: ~[~str]) -> config {
9897
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
9998
jit: getopts::opt_present(matches, ~"jit"),
10099
newrt: getopts::opt_present(matches, ~"newrt"),
101-
host: opt_str(getopts::opt_maybe_str(matches, ~"host")),
102100
target: opt_str(getopts::opt_maybe_str(matches, ~"target")),
103101
adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")),
104102
adb_test_dir: opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")),
105-
flag_runnable:
106-
if (getopts::opt_maybe_str(matches, ~"host") ==
107-
getopts::opt_maybe_str(matches, ~"target")) { true }
108-
else {
109-
match getopts::opt_maybe_str(matches, ~"target") {
110-
Some(~"arm-linux-androideabi") => {
111-
if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
112-
~"(none)" &&
113-
opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
114-
~"") { true }
115-
else { false }
116-
}
117-
_ => { true }
118-
}
119-
},
103+
adb_device_status:
104+
if (opt_str(getopts::opt_maybe_str(matches, ~"target")) ==
105+
~"arm-linux-androideabi") {
106+
if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
107+
~"(none)" &&
108+
opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
109+
~"") { true }
110+
else { false }
111+
} else { false },
120112
verbose: getopts::opt_present(matches, ~"verbose")
121113
}
122114
}
@@ -137,11 +129,10 @@ pub fn log_config(config: config) {
137129
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
138130
logv(c, fmt!("jit: %b", config.jit));
139131
logv(c, fmt!("newrt: %b", config.newrt));
140-
logv(c, fmt!("host: %s", config.host));
141132
logv(c, fmt!("target: %s", config.target));
142133
logv(c, fmt!("adb_path: %s", config.adb_path));
143134
logv(c, fmt!("adb_test_dir: %s", config.adb_test_dir));
144-
logv(c, fmt!("flag_runnable: %b", config.flag_runnable));
135+
logv(c, fmt!("adb_device_status: %b", config.adb_device_status));
145136
logv(c, fmt!("verbose: %b", config.verbose));
146137
logv(c, fmt!("\n"));
147138
}

src/compiletest/runtest.rs

+131-119
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,19 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) {
7777
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes);
7878
}
7979
80-
if (config.host == config.target) {
81-
check_correct_failure_status(ProcRes);
82-
check_error_patterns(props, testfile, ProcRes);
83-
} else {
84-
match (config.target, config.flag_runnable) {
80+
match config.target {
8581
86-
(~"arm-linux-androideabi", false) => { }
87-
_ => {
82+
~"arm-linux-androideabi" => {
83+
if (config.adb_device_status) {
8884
check_correct_failure_status(ProcRes);
8985
check_error_patterns(props, testfile, ProcRes);
9086
}
9187
}
88+
89+
_=> {
90+
check_correct_failure_status(ProcRes);
91+
check_error_patterns(props, testfile, ProcRes);
92+
}
9293
}
9394
}
9495

@@ -494,99 +495,21 @@ fn exec_compiled_test(config: config, props: TestProps,
494495
props.exec_env
495496
};
496497

497-
if (config.host == config.target) {
498-
compose_and_run(config, testfile,
499-
make_run_args(config, props, testfile),
500-
env,
501-
config.run_lib_path, None)
502-
} else {
503-
let args = make_run_args(config, props, testfile);
504-
let cmdline = make_cmdline(~"", args.prog, args.args);
505-
506-
match (config.target, config.flag_runnable) {
507-
508-
(~"arm-linux-androideabi", true) => {
509-
510-
// get bare program string
511-
let mut tvec = ~[];
512-
let tstr = args.prog;
513-
for str::each_split_char(tstr, '/') |ts| { tvec.push(ts.to_owned()) }
514-
let prog_short = tvec.pop();
515-
516-
// copy to target
517-
let copy_result = procsrv::run(~"", config.adb_path,
518-
~[~"push", args.prog, config.adb_test_dir],
519-
~[(~"",~"")], Some(~""));
520-
521-
if config.verbose {
522-
io::stdout().write_str(fmt!("push (%s) %s %s %s",
523-
config.target, args.prog,
524-
copy_result.out, copy_result.err));
525-
}
526-
527-
// execute program
528-
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
529-
530-
// NOTE: adb shell dose not forward stdout and stderr of internal result
531-
// to stdout and stderr seperately but to stdout only
532-
let mut newargs_out = ~[];
533-
let mut newargs_err = ~[];
534-
let subargs = args.args;
535-
newargs_out.push(~"shell");
536-
newargs_err.push(~"shell");
537-
538-
let mut newcmd_out = ~"";
539-
let mut newcmd_err = ~"";
540-
541-
newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
542-
config.adb_test_dir, config.adb_test_dir, prog_short));
543-
544-
newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
545-
config.adb_test_dir, config.adb_test_dir, prog_short));
546-
547-
for vec::each(subargs) |tv| {
548-
newcmd_out.push_str(" ");
549-
newcmd_err.push_str(" ");
550-
newcmd_out.push_str(tv.to_owned());
551-
newcmd_err.push_str(tv.to_owned());
552-
}
553-
554-
newcmd_out.push_str(" 2>/dev/null");
555-
newcmd_err.push_str(" 1>/dev/null");
556-
557-
newargs_out.push(newcmd_out);
558-
newargs_err.push(newcmd_err);
559-
560-
let exe_result_out = procsrv::run(~"", config.adb_path,
561-
newargs_out, ~[(~"",~"")], Some(~""));
562-
let exe_result_err = procsrv::run(~"", config.adb_path,
563-
newargs_err, ~[(~"",~"")], Some(~""));
498+
match config.target {
564499

565-
dump_output(config, testfile, exe_result_out.out, exe_result_err.out);
566-
567-
match exe_result_err.out {
568-
~"" => ProcRes {status: exe_result_out.status, stdout: exe_result_out.out,
569-
stderr: exe_result_err.out, cmdline: cmdline },
570-
_ => ProcRes {status: 101, stdout: exe_result_out.out,
571-
stderr: exe_result_err.out, cmdline: cmdline }
572-
}
573-
}
574-
575-
(~"arm-linux-androideabi", false) => {
576-
match config.mode {
577-
mode_run_fail => ProcRes {status: 101, stdout: ~"",
578-
stderr: ~"", cmdline: cmdline},
579-
_ => ProcRes {status: 0, stdout: ~"",
580-
stderr: ~"", cmdline: cmdline}
581-
}
500+
~"arm-linux-androideabi" => {
501+
if (config.adb_device_status) {
502+
_arm_exec_compiled_test(config, props, testfile)
503+
} else {
504+
_dummy_exec_compiled_test(config, props, testfile)
582505
}
506+
}
583507

584-
_=> {
585-
compose_and_run(config, testfile,
586-
make_run_args(config, props, testfile),
587-
env,
588-
config.run_lib_path, None)
589-
}
508+
_=> {
509+
compose_and_run(config, testfile,
510+
make_run_args(config, props, testfile),
511+
env,
512+
config.run_lib_path, None)
590513
}
591514
}
592515
}
@@ -618,32 +541,16 @@ fn compose_and_run_compiler(
618541
abs_ab.to_str()),
619542
auxres);
620543
}
621-
if (config.host != config.target)
622-
{
623-
match (config.target, config.flag_runnable) {
624-
625-
(~"arm-linux-androideabi", true) => {
626-
627-
let tstr = aux_output_dir_name(config, testfile).to_str();
628-
629-
for os::list_dir_path(&Path(tstr)).each |file| {
630544

631-
if (file.filetype() == Some(~".so")) {
545+
match config.target {
632546

633-
let copy_result = procsrv::run(~"", config.adb_path,
634-
~[~"push", file.to_str(), config.adb_test_dir],
635-
~[(~"",~"")], Some(~""));
636-
637-
if config.verbose {
638-
io::stdout().write_str(fmt!("push (%s) %s %s %s",
639-
config.target, file.to_str(),
640-
copy_result.out, copy_result.err));
641-
}
642-
}
643-
}
547+
~"arm-linux-androideabi" => {
548+
if (config.adb_device_status) {
549+
_arm_push_aux_shared_library(config, testfile);
644550
}
645-
_=> ()
646551
}
552+
553+
_=> { }
647554
}
648555
}
649556

@@ -829,3 +736,108 @@ stderr:\n\
829736
io::stdout().write_str(msg);
830737
fail!();
831738
}
739+
740+
fn _arm_exec_compiled_test(config: config, props: TestProps,
741+
testfile: &Path) -> ProcRes {
742+
743+
let args = make_run_args(config, props, testfile);
744+
let cmdline = make_cmdline(~"", args.prog, args.args);
745+
746+
// get bare program string
747+
let mut tvec = ~[];
748+
let tstr = args.prog;
749+
for str::each_split_char(tstr, '/') |ts| { tvec.push(ts.to_owned()) }
750+
let prog_short = tvec.pop();
751+
752+
// copy to target
753+
let copy_result = procsrv::run(~"", config.adb_path,
754+
~[~"push", args.prog, config.adb_test_dir],
755+
~[(~"",~"")], Some(~""));
756+
757+
if config.verbose {
758+
io::stdout().write_str(fmt!("push (%s) %s %s %s",
759+
config.target, args.prog,
760+
copy_result.out, copy_result.err));
761+
}
762+
763+
// execute program
764+
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
765+
766+
// adb shell dose not forward stdout and stderr of internal result
767+
// to stdout and stderr seperately but to stdout only
768+
let mut newargs_out = ~[];
769+
let mut newargs_err = ~[];
770+
let subargs = args.args;
771+
newargs_out.push(~"shell");
772+
newargs_err.push(~"shell");
773+
774+
let mut newcmd_out = ~"";
775+
let mut newcmd_err = ~"";
776+
777+
newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
778+
config.adb_test_dir, config.adb_test_dir, prog_short));
779+
780+
newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
781+
config.adb_test_dir, config.adb_test_dir, prog_short));
782+
783+
for vec::each(subargs) |tv| {
784+
newcmd_out.push_str(" ");
785+
newcmd_err.push_str(" ");
786+
newcmd_out.push_str(tv.to_owned());
787+
newcmd_err.push_str(tv.to_owned());
788+
}
789+
790+
newcmd_out.push_str(" 2>/dev/null");
791+
newcmd_err.push_str(" 1>/dev/null");
792+
793+
newargs_out.push(newcmd_out);
794+
newargs_err.push(newcmd_err);
795+
796+
let exe_result_out = procsrv::run(~"", config.adb_path,
797+
newargs_out, ~[(~"",~"")], Some(~""));
798+
let exe_result_err = procsrv::run(~"", config.adb_path,
799+
newargs_err, ~[(~"",~"")], Some(~""));
800+
801+
dump_output(config, testfile, exe_result_out.out, exe_result_err.out);
802+
803+
match exe_result_err.out {
804+
~"" => ProcRes {status: exe_result_out.status, stdout: exe_result_out.out,
805+
stderr: exe_result_err.out, cmdline: cmdline },
806+
_ => ProcRes {status: 101, stdout: exe_result_out.out,
807+
stderr: exe_result_err.out, cmdline: cmdline }
808+
}
809+
}
810+
811+
fn _dummy_exec_compiled_test(config: config, props: TestProps,
812+
testfile: &Path) -> ProcRes {
813+
814+
let args = make_run_args(config, props, testfile);
815+
let cmdline = make_cmdline(~"", args.prog, args.args);
816+
817+
match config.mode {
818+
mode_run_fail => ProcRes {status: 101, stdout: ~"",
819+
stderr: ~"", cmdline: cmdline},
820+
_ => ProcRes {status: 0, stdout: ~"",
821+
stderr: ~"", cmdline: cmdline}
822+
}
823+
}
824+
825+
fn _arm_push_aux_shared_library(config: config, testfile: &Path) {
826+
let tstr = aux_output_dir_name(config, testfile).to_str();
827+
828+
for os::list_dir_path(&Path(tstr)).each |file| {
829+
830+
if (file.filetype() == Some(~".so")) {
831+
832+
let copy_result = procsrv::run(~"", config.adb_path,
833+
~[~"push", file.to_str(), config.adb_test_dir],
834+
~[(~"",~"")], Some(~""));
835+
836+
if config.verbose {
837+
io::stdout().write_str(fmt!("push (%s) %s %s %s",
838+
config.target, file.to_str(),
839+
copy_result.out, copy_result.err));
840+
}
841+
}
842+
}
843+
}

0 commit comments

Comments
 (0)