Push the test executables just before we run it.

We used to pushing many executables to the devices at once.
It may take long time for some test.  As a result, we can't
distinguish the long file transfering time or the device
hang.

In this CL, we slightly changed the run-tests.sh so that
we can push the executables just before the execution.

Change-Id: I972c7181e7cd833108523cc9707807e8eaf86ad2
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 8a5d3e6..6c510b7 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -669,7 +669,6 @@
         local DSTDIR="$4/ndk-tests"
         local SRCFILE
         local DSTFILE
-        local PROGRAMS=
         local PROGRAM
         # Do not run the test if BROKEN_RUN is defined
         if [ -z "$RUN_TESTS" ]; then
@@ -704,11 +703,35 @@
         # First, copy all files to the device, except for gdbserver, gdb.setup, and
         # those declared in $TEST/BROKEN_RUN
         adb_shell_mkdir "$DEVICE" $DSTDIR
+
+        for SRCFILE in `ls $SRCDIR`; do
+            DSTFILE=`basename $SRCFILE`
+            echo "$DSTFILE" | grep -q -e '\.so$'
+            if [ $? != 0 ] ; then
+                continue
+            fi
+            SRCFILE="$SRCDIR/$SRCFILE"
+            if [ $HOST_OS = cygwin ]; then
+                SRCFILE=`cygpath -m $SRCFILE`
+            fi
+            DSTFILE="$DSTDIR/$DSTFILE"
+            run $ADB_CMD -s "$DEVICE" push "$SRCFILE" "$DSTFILE" &&
+            run $ADB_CMD -s "$DEVICE" shell chmod 0755 $DSTFILE
+            if [ $? != 0 ] ; then
+                dump "ERROR: Could not install $SRCFILE to device $DEVICE!"
+                exit 1
+            fi
+        done
+
         for SRCFILE in `ls $SRCDIR`; do
             DSTFILE=`basename $SRCFILE`
             if [ "$DSTFILE" = "gdbserver" -o "$DSTFILE" = "gdb.setup" ] ; then
                 continue
             fi
+            echo "$DSTFILE" | grep -q -e '\.so$'
+            if [ $? = 0 ] ; then
+              continue
+            fi
             if [ -z "$RUN_TESTS" -a -f "$TEST/BROKEN_RUN" ]; then
                 grep -q -w -e "$DSTFILE" "$TEST/BROKEN_RUN"
                 if [ $? = 0 ] ; then
@@ -726,13 +749,7 @@
                 dump "ERROR: Could not install $SRCFILE to device $DEVICE!"
                 exit 1
             fi
-            # If its name doesn't end with .so, add it to PROGRAMS
-            echo "$DSTFILE" | grep -q -e '\.so$'
-            if [ $? != 0 ] ; then
-                PROGRAMS="$PROGRAMS `basename $DSTFILE`"
-            fi
-        done
-        for PROGRAM in $PROGRAMS; do
+            PROGRAM="`basename $DSTFILE`"
             dump "Running device test [$CPU_ABI]: $TEST_NAME (`basename $PROGRAM`)"
             adb_var_shell_cmd "$DEVICE" "" "cd $DSTDIR && LD_LIBRARY_PATH=$DSTDIR ./$PROGRAM"
             if [ $? != 0 ] ; then