Skip to content

Commit dad9456

Browse files
committed
auto merge of #6879 : yichoi/rust/arm-test, r=brson
Fix #6353 and better support for ARM Test
2 parents 63b11e4 + 18bee38 commit dad9456

File tree

3 files changed

+89
-35
lines changed

3 files changed

+89
-35
lines changed

mk/tests.mk

+10
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,18 @@ CFG_ADB_TEST_DIR=/data/tmp
122122
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
123123
$(shell adb remount 1>/dev/null) \
124124
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125+
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \
126+
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \
127+
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi.* 1>/dev/null) \
128+
$(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125129
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
126130
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
131+
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
132+
$(CFG_ADB_TEST_DIR)) \
133+
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
134+
$(CFG_ADB_TEST_DIR)) \
135+
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
136+
$(CFG_ADB_TEST_DIR)) \
127137
)
128138
else
129139
CFG_ADB_TEST_DIR=

src/compiletest/runtest.rs

+44-35
Original file line numberDiff line numberDiff line change
@@ -753,53 +753,62 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
753753
copy_result.out, copy_result.err));
754754
}
755755

756-
// execute program
757756
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
758757

759-
// adb shell dose not forward stdout and stderr of internal result
760-
// to stdout and stderr separately but to stdout only
761-
let mut newargs_out = ~[];
762-
let mut newargs_err = ~[];
763-
newargs_out.push(~"shell");
764-
newargs_err.push(~"shell");
758+
let mut runargs = ~[];
765759

766-
let mut newcmd_out = ~"";
767-
let mut newcmd_err = ~"";
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));
768765

769-
newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
770-
config.adb_test_dir, config.adb_test_dir, prog_short));
766+
for args.args.each |tv| {
767+
runargs.push(tv.to_owned());
768+
}
771769

772-
newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
773-
config.adb_test_dir, config.adb_test_dir, prog_short));
770+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
774771

775-
for args.args.each |tv| {
776-
newcmd_out.push_str(" ");
777-
newcmd_err.push_str(" ");
778-
newcmd_out.push_str(*tv);
779-
newcmd_err.push_str(*tv);
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 !c.is_digit() { break; }
785+
exitcode = exitcode * 10 + match c {
786+
'0' .. '9' => c as int - ('0' as int),
787+
_ => 101,
788+
}
780789
}
781790

782-
newcmd_out.push_str(" 2>/dev/null");
783-
newcmd_err.push_str(" 1>/dev/null");
791+
// get stdout of result
792+
runargs = ~[];
793+
runargs.push(~"shell");
794+
runargs.push(~"cat");
795+
runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short));
784796

785-
newargs_out.push(newcmd_out);
786-
newargs_err.push(newcmd_err);
797+
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
798+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
787799

788-
let procsrv::Result{ out: out_out, err: _out_err, status: out_status } =
789-
procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")],
790-
Some(~""));
791-
let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } =
792-
procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")],
793-
Some(~""));
800+
// get stderr of result
801+
runargs = ~[];
802+
runargs.push(~"shell");
803+
runargs.push(~"cat");
804+
runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short));
794805

795-
dump_output(config, testfile, out_out, err_out);
806+
let procsrv::Result{ out: stderr_out, err: _, status: _ } =
807+
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
796808

797-
match err_out {
798-
~"" => ProcRes {status: out_status, stdout: out_out,
799-
stderr: err_out, cmdline: cmdline },
800-
_ => ProcRes {status: 101, stdout: out_out,
801-
stderr: err_out, cmdline: cmdline }
802-
}
809+
dump_output(config, testfile, stdout_out, stderr_out);
810+
811+
ProcRes {status: exitcode, stdout: stdout_out, stderr: stderr_out, cmdline: cmdline }
803812
}
804813

805814
fn _dummy_exec_compiled_test(config: &config, props: &TestProps,

src/etc/adb_run_wrapper.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# usage : adb_run_wrapper [test dir - where test executables exist] [test executable]
3+
#
4+
5+
# Sometimes android shell produce exitcode "1 : Text File Busy"
6+
# Retry after $WAIT seconds, expecting resource cleaned-up
7+
WAIT=10
8+
PATH=$1
9+
if [ -d "$PATH" ]
10+
then
11+
shift
12+
RUN=$1
13+
14+
if [ ! -z "$RUN" ]
15+
then
16+
shift
17+
18+
L_RET=1
19+
L_COUNT=0
20+
while [ $L_RET -eq 1 ]
21+
do
22+
LD_LIBRARY_PATH=$PATH $PATH/$RUN $@ 1>$PATH/$RUN.stdout 2>$PATH/$RUN.stderr
23+
L_RET=$?
24+
if [ $L_COUNT -gt 0 ]
25+
then
26+
/system/bin/sleep $WAIT
27+
/system/bin/sync
28+
fi
29+
L_COUNT=`expr $L_COUNT+1`
30+
done
31+
32+
echo $L_RET > $PATH/$RUN.exitcode
33+
34+
fi
35+
fi

0 commit comments

Comments
 (0)