From 5076bca1baded13d5657496a10843d86a937f8aa Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 29 May 2013 16:03:14 +0900 Subject: [PATCH 1/8] mk: test.mk modify to better support --- mk/tests.mk | 10 ++++++++++ 1 file changed, 10 insertions(+) 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= From 0ea8274fcaf1585b597f80a3c9d2bbef83549932 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 29 May 2013 16:04:11 +0900 Subject: [PATCH 2/8] etc: adb_run_wrapper added --- src/etc/adb_run_wrapper.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 src/etc/adb_run_wrapper.sh diff --git a/src/etc/adb_run_wrapper.sh b/src/etc/adb_run_wrapper.sh new file mode 100755 index 0000000000000..7d5fdb1cdd175 --- /dev/null +++ b/src/etc/adb_run_wrapper.sh @@ -0,0 +1,17 @@ + +PATH=$(echo $0 | sed 's#/[^/]*$##') +RUN=$1 + +if [ ! -z "$RUN" ] +then + shift + while [ -f $PATH/lock ] + do + sleep 1 + done + touch $PATH/lock + LD_LIBRARY_PATH=$PATH $PATH/$RUN $@ 1>$PATH/$RUN.stdout 2>$PATH/$RUN.stderr + echo $? > $PATH/$RUN.exitcode + /system/bin/rm $PATH/lock +fi + From fe1dc3280f63fe4cec441837ae20020cbe26dc61 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Wed, 29 May 2013 16:04:47 +0900 Subject: [PATCH 3/8] compiletest: improve exit code handling with adb_run_wrapper --- src/compiletest/runtest.rs | 93 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index f0f6469e923fa..61371dd94d6c7 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -753,6 +753,99 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, copy_result.out, copy_result.err)); } + logv(config, fmt!("executing (%s) %s", config.target, cmdline)); + + + let mut runargs = ~[]; + let mut exitcode : int = 1; + let mut maxtry = 10; + + // sometimes code generates exit code 1 which is "1 : General unknown error" + // in this case, force to retry +// while exitcode == 1 && maxtry > 0 { + // since adb shell doesnot forward internal result (exit code) and + // distingush stderr and stdout, adb_run_wrapper is used + + runargs.push(~"shell"); + runargs.push(fmt!("%s/adb_run_wrapper.sh", config.adb_test_dir)); + runargs.push(fmt!("%s", prog_short)); + + for args.args.each |tv| { + runargs.push(tv.to_owned()); + } + + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); + + // 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: exitcode_err, status: exitcode_status } = + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], + Some(~"")); + + exitcode = 0; + for str::each_char(exitcode_out) |c| { + if !char::is_digit(c) { break; } + exitcode = exitcode * 10 + match c { + '0' .. '9' => c as int - ('0' as int), + _ => 0, + } + } + maxtry = maxtry - 1; +// unsafe { libc::sleep(1); } +// } + + // 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: stdout_err, status: stdout_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: stderr_err, status: stderr_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 _arm_exec_compiled_test2(config: &config, props: &TestProps, + testfile: &Path) -> ProcRes { + + let args = make_run_args(config, props, testfile); + let cmdline = make_cmdline("", args.prog, args.args); + + // get bare program string + let mut tvec = ~[]; + for str::each_split_char(args.prog, '/') |ts| { tvec.push(ts.to_owned()) } + let prog_short = tvec.pop(); + + // copy to target + let copy_result = procsrv::run("", config.adb_path, + [~"push", copy args.prog, copy config.adb_test_dir], + ~[(~"",~"")], Some(~"")); + + if config.verbose { + io::stdout().write_str(fmt!("push (%s) %s %s %s", + config.target, args.prog, + copy_result.out, copy_result.err)); + } + // execute program logv(config, fmt!("executing (%s) %s", config.target, cmdline)); From 0521d54ca1e194ba8564f4a000c50b7f708022ba Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Thu, 30 May 2013 09:36:53 +0900 Subject: [PATCH 4/8] etc: adb_run_wrapper argument change --- src/compiletest/runtest.rs | 3 ++- src/etc/adb_run_wrapper.sh | 34 ++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 61371dd94d6c7..0c899b0435dbf 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -768,6 +768,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, 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| { @@ -795,7 +796,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, _ => 0, } } - maxtry = maxtry - 1; +// maxtry = maxtry - 1; // unsafe { libc::sleep(1); } // } diff --git a/src/etc/adb_run_wrapper.sh b/src/etc/adb_run_wrapper.sh index 7d5fdb1cdd175..516c6a9fca32a 100755 --- a/src/etc/adb_run_wrapper.sh +++ b/src/etc/adb_run_wrapper.sh @@ -1,17 +1,23 @@ - -PATH=$(echo $0 | sed 's#/[^/]*$##') -RUN=$1 - -if [ ! -z "$RUN" ] +# +# usage : adb_run_wrapper [test dir - where test executables exist] [test executable] +# +PATH=$1 +if [ -d "$PATH" ] then shift - while [ -f $PATH/lock ] - do - sleep 1 - done - touch $PATH/lock - LD_LIBRARY_PATH=$PATH $PATH/$RUN $@ 1>$PATH/$RUN.stdout 2>$PATH/$RUN.stderr - echo $? > $PATH/$RUN.exitcode - /system/bin/rm $PATH/lock -fi + RUN=$1 + if [ ! -z "$RUN" ] + then + shift + while [ -f $PATH/lock ] + do + /system/bin/sleep 1 + done + /system/bin/touch $PATH/lock + LD_LIBRARY_PATH=$PATH $PATH/$RUN $@ 1>$PATH/$RUN.stdout 2>$PATH/$RUN.stderr + echo $? > $PATH/$RUN.exitcode + /system/bin/rm $PATH/lock + /system/bin/sync + fi +fi From c28c495414d8d5bec83ca4c7e2781c1a7cc8d489 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 1 Jun 2013 17:27:05 +0900 Subject: [PATCH 5/8] etc: adb_run_wrapper.sh - fix to clean test (not produce Text File Busy) --- src/etc/adb_run_wrapper.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/etc/adb_run_wrapper.sh b/src/etc/adb_run_wrapper.sh index 516c6a9fca32a..68ac6b4242c3e 100755 --- a/src/etc/adb_run_wrapper.sh +++ b/src/etc/adb_run_wrapper.sh @@ -1,6 +1,10 @@ # # 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 @@ -10,14 +14,22 @@ then if [ ! -z "$RUN" ] then shift - while [ -f $PATH/lock ] + + L_RET=1 + L_COUNT=0 + while [ $L_RET -eq 1 ] do - /system/bin/sleep 1 + 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 - /system/bin/touch $PATH/lock - LD_LIBRARY_PATH=$PATH $PATH/$RUN $@ 1>$PATH/$RUN.stdout 2>$PATH/$RUN.stderr - echo $? > $PATH/$RUN.exitcode - /system/bin/rm $PATH/lock - /system/bin/sync + + echo $L_RET > $PATH/$RUN.exitcode + fi fi From 8b24a96e1734d4fc028dfeebf5b13760790a9ac4 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 1 Jun 2013 17:27:30 +0900 Subject: [PATCH 6/8] compiletest: runtest.rs cleanup --- src/compiletest/runtest.rs | 145 ++++++++----------------------------- 1 file changed, 30 insertions(+), 115 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 0c899b0435dbf..8ae4f7c37931f 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -755,50 +755,38 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, logv(config, fmt!("executing (%s) %s", config.target, cmdline)); - let mut runargs = ~[]; - let mut exitcode : int = 1; - let mut maxtry = 10; - - // sometimes code generates exit code 1 which is "1 : General unknown error" - // in this case, force to retry -// while exitcode == 1 && maxtry > 0 { - // since adb shell doesnot forward internal result (exit code) and - // distingush stderr and stdout, adb_run_wrapper is used - - 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| { - runargs.push(tv.to_owned()); - } - - procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); - // get exitcode of result - runargs = ~[]; + // 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)); - runargs.push(~"shell"); - runargs.push(~"cat"); - runargs.push(fmt!("%s/%s.exitcode", config.adb_test_dir, prog_short)); + for args.args.each |tv| { + runargs.push(tv.to_owned()); + } - let procsrv::Result{ out: exitcode_out, err: exitcode_err, status: exitcode_status } = - procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], - Some(~"")); + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); - exitcode = 0; - for str::each_char(exitcode_out) |c| { - if !char::is_digit(c) { break; } - exitcode = exitcode * 10 + match c { - '0' .. '9' => c as int - ('0' as int), - _ => 0, - } + // 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 !char::is_digit(c) { break; } + exitcode = exitcode * 10 + match c { + '0' .. '9' => c as int - ('0' as int), + _ => 101, } -// maxtry = maxtry - 1; -// unsafe { libc::sleep(1); } -// } + } // get stdout of result runargs = ~[]; @@ -806,9 +794,8 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, runargs.push(~"cat"); runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short)); - let procsrv::Result{ out: stdout_out, err: stdout_err, status: stdout_status } = - procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], - Some(~"")); + let procsrv::Result{ out: stdout_out, err: _, status: _ } = + procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); // get stderr of result runargs = ~[]; @@ -816,86 +803,14 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, runargs.push(~"cat"); runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short)); - let procsrv::Result{ out: stderr_out, err: stderr_err, status: stderr_status } = - procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], - Some(~"")); + 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 _arm_exec_compiled_test2(config: &config, props: &TestProps, - testfile: &Path) -> ProcRes { - - let args = make_run_args(config, props, testfile); - let cmdline = make_cmdline("", args.prog, args.args); - - // get bare program string - let mut tvec = ~[]; - for str::each_split_char(args.prog, '/') |ts| { tvec.push(ts.to_owned()) } - let prog_short = tvec.pop(); - - // copy to target - let copy_result = procsrv::run("", config.adb_path, - [~"push", copy args.prog, copy config.adb_test_dir], - ~[(~"",~"")], Some(~"")); - - if config.verbose { - io::stdout().write_str(fmt!("push (%s) %s %s %s", - config.target, args.prog, - 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 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)); - - for args.args.each |tv| { - newcmd_out.push_str(" "); - newcmd_err.push_str(" "); - newcmd_out.push_str(*tv); - newcmd_err.push_str(*tv); - } - - newcmd_out.push_str(" 2>/dev/null"); - newcmd_err.push_str(" 1>/dev/null"); - - newargs_out.push(newcmd_out); - newargs_err.push(newcmd_err); - - 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(~"")); - - 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 } - } -} - fn _dummy_exec_compiled_test(config: &config, props: &TestProps, testfile: &Path) -> ProcRes { From 89c5ad69f052cf9f8ee5e8db6af4bf31a626088b Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 1 Jun 2013 17:33:11 +0900 Subject: [PATCH 7/8] compiletest: runtest.rs tidy --- src/compiletest/runtest.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 8ae4f7c37931f..5673cce26685e 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -789,7 +789,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, } // get stdout of result - runargs = ~[]; + runargs = ~[]; runargs.push(~"shell"); runargs.push(~"cat"); runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short)); @@ -798,7 +798,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~"")); // get stderr of result - runargs = ~[]; + runargs = ~[]; runargs.push(~"shell"); runargs.push(~"cat"); runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short)); From 18bee38bbea9ffc784a5857b6f819b1b529b22fc Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 1 Jun 2013 18:09:20 +0900 Subject: [PATCH 8/8] compiletest: update for language change --- src/compiletest/runtest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 5673cce26685e..c174057aaaa85 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -781,7 +781,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, let mut exitcode : int = 0; for str::each_char(exitcode_out) |c| { - if !char::is_digit(c) { break; } + if !c.is_digit() { break; } exitcode = exitcode * 10 + match c { '0' .. '9' => c as int - ('0' as int), _ => 101,