diff --git a/mk/tests.mk b/mk/tests.mk index 386cbe528defa..3858de3f264df 100644 --- a/mk/tests.mk +++ b/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= diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index f0f6469e923fa..c174057aaaa85 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -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 = ~""; + // 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)); - newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", - config.adb_test_dir, config.adb_test_dir, prog_short)); + for args.args.each |tv| { + runargs.push(tv.to_owned()); + } - newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s", - config.adb_test_dir, config.adb_test_dir, prog_short)); + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); - for args.args.each |tv| { - newcmd_out.push_str(" "); - newcmd_err.push_str(" "); - newcmd_out.push_str(*tv); - newcmd_err.push_str(*tv); + // 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: exitcode_out, err: _, status: _ } = + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], + Some(~"")); + + 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, + } } - newcmd_out.push_str(" 2>/dev/null"); - newcmd_err.push_str(" 1>/dev/null"); + // get stdout of result + runargs = ~[]; + runargs.push(~"shell"); + runargs.push(~"cat"); + runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short)); - newargs_out.push(newcmd_out); - newargs_err.push(newcmd_err); + let procsrv::Result{ out: stdout_out, err: _, status: _ } = + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); - 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(~"")); + // get stderr of result + runargs = ~[]; + runargs.push(~"shell"); + runargs.push(~"cat"); + runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short)); - dump_output(config, testfile, out_out, err_out); + let procsrv::Result{ out: stderr_out, err: _, status: _ } = + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); - 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 } - } + 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, diff --git a/src/etc/adb_run_wrapper.sh b/src/etc/adb_run_wrapper.sh new file mode 100755 index 0000000000000..68ac6b4242c3e --- /dev/null +++ b/src/etc/adb_run_wrapper.sh @@ -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