Use a test-specific name for each generated file.

This lets us run multiple tests in parallel (and know what we've got lying
around on our devices).

Change-Id: I90ecc4ceaae0ee4b323d861c2b408e2944a2f8c1
diff --git a/test/003-omnibus-opcodes/build b/test/003-omnibus-opcodes/build
index c3af10c..2a09167 100644
--- a/test/003-omnibus-opcodes/build
+++ b/test/003-omnibus-opcodes/build
@@ -23,11 +23,11 @@
 ${JAVAC} -d classes `find src2 -name '*.java'`
 
 dx -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
-zip ${ANDROID_PRODUCT_OUT}/system/framework/test.jar classes.dex
+zip ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar classes.dex
 
 dex2oatd -Xms16m -Xmx16m \
     --boot-image=${ANDROID_PRODUCT_OUT}/system/framework/core.art \
-    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/test.jar \
-    --oat=${ANDROID_PRODUCT_OUT}/system/framework/test.oat \
-    --image=${ANDROID_PRODUCT_OUT}/system/framework/test.art \
+    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar \
+    --oat=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat \
+    --image=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art \
     --host-prefix=${ANDROID_PRODUCT_OUT}
diff --git a/test/023-many-interfaces/build b/test/023-many-interfaces/build
index d0f376c..10c1c06 100644
--- a/test/023-many-interfaces/build
+++ b/test/023-many-interfaces/build
@@ -25,11 +25,11 @@
 ${JAVAC} -d classes src/*.java
 
 dx --debug --dex --dump-to=classes.lst --output=classes.dex classes
-zip ${ANDROID_PRODUCT_OUT}/system/framework/test.jar classes.dex
+zip ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar classes.dex
 
 dex2oatd -Xms16m -Xmx16m \
     --boot-image=${ANDROID_PRODUCT_OUT}/system/framework/core.art \
-    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/test.jar \
-    --oat=${ANDROID_PRODUCT_OUT}/system/framework/test.oat \
-    --image=${ANDROID_PRODUCT_OUT}/system/framework/test.art \
+    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar \
+    --oat=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat \
+    --image=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art \
     --host-prefix=${ANDROID_PRODUCT_OUT}
diff --git a/test/056-const-string-jumbo/build b/test/056-const-string-jumbo/build
index a780c13..22c9646 100644
--- a/test/056-const-string-jumbo/build
+++ b/test/056-const-string-jumbo/build
@@ -44,11 +44,11 @@
 
 dx -JXmx500m --debug --dex --no-optimize --positions=none --no-locals \
     --dump-to=classes.lst --output=classes.dex classes
-zip ${ANDROID_PRODUCT_OUT}/system/framework/test.jar classes.dex
+zip ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar classes.dex
 
 dex2oatd -Xms16m -Xmx16m \
     --boot-image=${ANDROID_PRODUCT_OUT}/system/framework/core.art \
-    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/test.jar \
-    --oat=${ANDROID_PRODUCT_OUT}/system/framework/test.oat \
-    --image=${ANDROID_PRODUCT_OUT}/system/framework/test.art \
+    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar \
+    --oat=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat \
+    --image=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art \
     --host-prefix=${ANDROID_PRODUCT_OUT}
diff --git a/test/085-old-style-inner-class/build b/test/085-old-style-inner-class/build
index d3dc15f..db6a5dd 100644
--- a/test/085-old-style-inner-class/build
+++ b/test/085-old-style-inner-class/build
@@ -26,11 +26,11 @@
 dx --debug --dex --dump-to=classes.lst --output=classes.dex \
     --dump-width=1000 classes 2>/dev/null
 
-zip ${ANDROID_PRODUCT_OUT}/system/framework/test.jar classes.dex
+zip ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar classes.dex
 
 dex2oatd -Xms16m -Xmx16m \
     --boot-image=${ANDROID_PRODUCT_OUT}/system/framework/core.art \
-    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/test.jar \
-    --oat=${ANDROID_PRODUCT_OUT}/system/framework/test.oat \
-    --image=${ANDROID_PRODUCT_OUT}/system/framework/test.art \
+    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar \
+    --oat=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat \
+    --image=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art \
     --host-prefix=${ANDROID_PRODUCT_OUT}
diff --git a/test/etc/default-build b/test/etc/default-build
index 0ef8ba8..a2e9066 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -26,13 +26,13 @@
 
 dx -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
     --dump-width=1000 classes
-zip ${ANDROID_PRODUCT_OUT}/system/framework/test.jar classes.dex
+zip ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar classes.dex
 
 dex2oatd -Xms16m -Xmx16m \
     --boot-image=${ANDROID_PRODUCT_OUT}/system/framework/core.art \
-    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/test.jar \
-    --oat=${ANDROID_PRODUCT_OUT}/system/framework/test.oat \
-    --image=${ANDROID_PRODUCT_OUT}/system/framework/test.art \
+    --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar \
+    --oat=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat \
+    --image=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art \
     --host-prefix=${ANDROID_PRODUCT_OUT}
 
 if [ -r src-ex ]; then
@@ -44,14 +44,14 @@
     # quick shuffle so that the stored name is "classes.dex"
     mv classes.dex classes-1.dex
     mv classes-ex.dex classes.dex
-    zip ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.jar classes.dex
+    zip ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.jar classes.dex
     mv classes.dex classes-ex.dex
     mv classes-1.dex classes.dex
 
     dex2oatd -Xms16m -Xmx16m \
         --boot-image=${ANDROID_PRODUCT_OUT}/system/framework/core.art \
-        --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/test-ex.jar \
-        --oat=${ANDROID_PRODUCT_OUT}/system/framework/test-ex.oat \
-        --image=${ANDROID_PRODUCT_OUT}/system/framework/test-ex.art \
+        --dex-file=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.jar \
+        --oat=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.oat \
+        --image=${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.art \
         --host-prefix=${ANDROID_PRODUCT_OUT}
 fi
diff --git a/test/etc/push-and-run-test-jar b/test/etc/push-and-run-test-jar
index 0d4e3b4..8bbf8d8 100755
--- a/test/etc/push-and-run-test-jar
+++ b/test/etc/push-and-run-test-jar
@@ -106,19 +106,19 @@
 msg "------------------------------"
 
 if [ "$QUIET" = "n" ]; then
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test.jar /system/framework
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test.oat /system/framework
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test.art /system/framework
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.jar /system/framework
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.oat /system/framework
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.art /system/framework
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar /system/framework
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat /system/framework
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art /system/framework
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.jar /system/framework
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.oat /system/framework
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.art /system/framework
 else
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test.jar /system/framework >/dev/null 2>&1
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test.oat /system/framework >/dev/null 2>&1
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test.art /system/framework >/dev/null 2>&1
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.jar /system/framework >/dev/null 2>&1
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.oat /system/framework >/dev/null 2>&1
-    adb push ${ANDROID_PRODUCT_OUT}/system/framework/test-ex.art /system/framework >/dev/null 2>&1
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar /system/framework >/dev/null 2>&1
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat /system/framework >/dev/null 2>&1
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art /system/framework >/dev/null 2>&1
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.jar /system/framework >/dev/null 2>&1
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.oat /system/framework >/dev/null 2>&1
+  adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.art /system/framework >/dev/null 2>&1
 fi
 
 if [ "$DEBUG" = "y" ]; then
@@ -132,16 +132,17 @@
 fi
 
 if [ "$ZYGOTE" = "y" ]; then
-    adb shell cd /data \; dvz -classpath test.jar Main "$@"
+  adb shell cd /data \; dvz -classpath $TEST_NAME.jar Main "$@"
 else
-    cmdline="cd /data; oatexecd \
+  cmdline="cd /data; oatexecd \
       -Ximage:/system/framework/core.art \
-      -Ximage:/system/framework/test.art Main"
-    #cmdline="cd /data; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \
-    #    $GC_OPTS -cp test.jar -Xint:${INTERP} -ea Main"
-    if [ "$DEV_MODE" = "y" ]; then
-        echo $cmdline "$@"
-    fi
+      -Ximage:/system/framework/$TEST_NAME.art \
+      Main"
+  #cmdline="cd /data; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \
+  #    $GC_OPTS -cp test.jar -Xint:${INTERP} -ea Main"
+  if [ "$DEV_MODE" = "y" ]; then
+    echo $cmdline "$@"
+  fi
 
-    adb shell $cmdline "$@"
+  adb shell $cmdline "$@"
 fi
diff --git a/test/run-all-tests b/test/run-all-tests
index f66cd76..94c7c31 100755
--- a/test/run-all-tests
+++ b/test/run-all-tests
@@ -100,25 +100,30 @@
     exit 1
 fi
 
-passed=0
-failed=0
-failNames=""
-
-for i in *; do
-    if [ -d "$i" -a -r "$i" -a -r "${i}/info.txt" ]; then
-        ./run-test ${run_args} "$i"
-        if [ "$?" = "0" ]; then
-            ((passed += 1))
-        else
-            ((failed += 1))
-            failNames="$failNames $i"
-        fi
-    fi
+# start all the tests
+i=0
+for test_name in *; do
+  if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then
+    ./run-test ${run_args} "$test_name" &
+    test_pids[i]=$!
+    test_names[test_pids[i]]="$test_name"
+    let i+=1
+  fi
 done
 
-echo "passed: $passed test(s)"
-echo "failed: $failed test(s)"
+# wait for all the tests, collecting the failures
+failure_count=0
+failed_test_names=""
+for pid in ${test_pids[@]}; do
+  wait $pid
+  if [ "$?" != "0" ]; then
+    let failure_count+=1
+    failed_test_names="$failed_test_names $test_names[$pid]"
+  fi
+done
 
-for i in $failNames; do
-    echo "failed: $i"
+echo "failed tests: $failure_count"
+
+for i in $failed_test_names; do
+  echo "failed: $i"
 done
diff --git a/test/run-test b/test/run-test
index fb758d7..4132a9d 100755
--- a/test/run-test
+++ b/test/run-test
@@ -196,6 +196,8 @@
 chmod 755 "$build"
 chmod 755 "$run"
 
+export TEST_NAME=`basename ${test_dir}`
+
 good="no"
 if [ "$dev_mode" = "yes" ]; then
     "./${build}" 2>&1
@@ -248,7 +250,7 @@
         echo '####################'
         echo ' '
     fi
-    echo "files left in ${tmp_dir}"
+    echo "${TEST_NAME} files left in ${tmp_dir}"
 ) 1>&2
 
 exit 1