Workaround adb issue in run-test.

Try a few times before giving up on fetching the architecture.

bug:32655576
Change-Id: I05c6520efa56570ebe23820fca30fc234c368c88
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 8ee4ca2..c525b2b 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -397,14 +397,26 @@
 fi
 
 if [ "$HOST" = "n" ]; then
-  adb_invocation=$(adb shell ls -F /data/dalvik-cache)
-  outcome=$?
-  ISA=$(echo $adb_invocation | grep -Ewo "${ARCHITECTURES_PATTERN}")
+  # Need to be root to query /data/dalvik-cache
+  adb root > /dev/null
+  adb wait-for-device
+  ISA=
+  ISA_adb_invocation=
+  ISA_outcome=
+  # We iterate a few times to workaround an adb issue. b/32655576
+  for i in {1..10}; do
+    ISA_adb_invocation=$(adb shell ls -F /data/dalvik-cache)
+    ISA_outcome=$?
+    ISA=$(echo $ISA_adb_invocation | grep -Ewo "${ARCHITECTURES_PATTERN}")
+    if [ x"$ISA" != "x" ]; then
+      break;
+    fi
+  done
   if [ x"$ISA" = "x" ]; then
     echo "Unable to determine architecture"
     # Print a few things for helping diagnosing the problem.
-    echo "adb invocation output: $adb_invocation"
-    echo "adb invocation outcome: $outcome"
+    echo "adb invocation output: $ISA_adb_invocation"
+    echo "adb invocation outcome: $ISA_outcome"
     echo $(adb shell ls -F /data/dalvik-cache)
     echo $(adb shell ls /data/dalvik-cache)
     echo ${ARCHITECTURES_PATTERN}