auto merge of #6879 : yichoi/rust/arm-test, r=brson
Fix #6353 and better support for ARM Test
This commit is contained in:
commit
dad945646f
3 changed files with 90 additions and 36 deletions
10
mk/tests.mk
10
mk/tests.mk
|
|
@ -122,8 +122,18 @@ CFG_ADB_TEST_DIR=/data/tmp
|
|||
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
|
||||
$(shell adb remount 1>/dev/null) \
|
||||
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
|
||||
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \
|
||||
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \
|
||||
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi.* 1>/dev/null) \
|
||||
$(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
|
||||
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
|
||||
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
|
||||
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
|
||||
$(CFG_ADB_TEST_DIR)) \
|
||||
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
|
||||
$(CFG_ADB_TEST_DIR)) \
|
||||
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
|
||||
$(CFG_ADB_TEST_DIR)) \
|
||||
)
|
||||
else
|
||||
CFG_ADB_TEST_DIR=
|
||||
|
|
|
|||
|
|
@ -753,53 +753,62 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
|
|||
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 runargs = ~[];
|
||||
|
||||
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));
|
||||
// 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));
|
||||
|
||||
for args.args.each |tv| {
|
||||
newcmd_out.push_str(" ");
|
||||
newcmd_err.push_str(" ");
|
||||
newcmd_out.push_str(*tv);
|
||||
newcmd_err.push_str(*tv);
|
||||
runargs.push(tv.to_owned());
|
||||
}
|
||||
|
||||
newcmd_out.push_str(" 2>/dev/null");
|
||||
newcmd_err.push_str(" 1>/dev/null");
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
|
||||
|
||||
newargs_out.push(newcmd_out);
|
||||
newargs_err.push(newcmd_err);
|
||||
// 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: 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(~""));
|
||||
let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
|
||||
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 }
|
||||
let mut exitcode : int = 0;
|
||||
for str::each_char(exitcode_out) |c| {
|
||||
if !c.is_digit() { break; }
|
||||
exitcode = exitcode * 10 + match c {
|
||||
'0' .. '9' => c as int - ('0' as int),
|
||||
_ => 101,
|
||||
}
|
||||
}
|
||||
|
||||
// get stdout of result
|
||||
runargs = ~[];
|
||||
runargs.push(~"shell");
|
||||
runargs.push(~"cat");
|
||||
runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
|
||||
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
|
||||
|
||||
// get stderr of result
|
||||
runargs = ~[];
|
||||
runargs.push(~"shell");
|
||||
runargs.push(~"cat");
|
||||
runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short));
|
||||
|
||||
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 _dummy_exec_compiled_test(config: &config, props: &TestProps,
|
||||
|
|
|
|||
35
src/etc/adb_run_wrapper.sh
Executable file
35
src/etc/adb_run_wrapper.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# usage : adb_run_wrapper [test dir - where test executables exist] [test executable]
|
||||
#
|
||||
|
||||
# Sometimes android shell produce exitcode "1 : Text File Busy"
|
||||
# Retry after $WAIT seconds, expecting resource cleaned-up
|
||||
WAIT=10
|
||||
PATH=$1
|
||||
if [ -d "$PATH" ]
|
||||
then
|
||||
shift
|
||||
RUN=$1
|
||||
|
||||
if [ ! -z "$RUN" ]
|
||||
then
|
||||
shift
|
||||
|
||||
L_RET=1
|
||||
L_COUNT=0
|
||||
while [ $L_RET -eq 1 ]
|
||||
do
|
||||
LD_LIBRARY_PATH=$PATH $PATH/$RUN $@ 1>$PATH/$RUN.stdout 2>$PATH/$RUN.stderr
|
||||
L_RET=$?
|
||||
if [ $L_COUNT -gt 0 ]
|
||||
then
|
||||
/system/bin/sleep $WAIT
|
||||
/system/bin/sync
|
||||
fi
|
||||
L_COUNT=`expr $L_COUNT+1`
|
||||
done
|
||||
|
||||
echo $L_RET > $PATH/$RUN.exitcode
|
||||
|
||||
fi
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue