Make script suitable for vogar use on device.

Also update device expectations that need investigation.

Change-Id: I86a613f3f62c2f999296f8b7505646a96ab4adf8
diff --git a/tools/art b/tools/art
index af96b47..d5d546b 100644
--- a/tools/art
+++ b/tools/art
@@ -1,5 +1,3 @@
-#!/bin/bash
-#
 # Copyright (C) 2011 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,6 +12,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# This script is used on host and device. It uses a common subset
+# shell dialect that should work on the host (e.g. bash), and
+# Android (e.g. mksh).
+
 function follow_links() {
   if [ z"$BASH_SOURCE" != z ]; then
     file="$BASH_SOURCE"
@@ -28,7 +30,8 @@
 }
 
 function find_libdir() {
-  if [ "$(readlink "$ANDROID_ROOT/bin/$DALVIKVM")" = "dalvikvm64" ]; then
+  # Use realpath instead of readlink because Android does not have a readlink.
+  if [ "$(realpath "$ANDROID_ROOT/bin/$DALVIKVM")" = "$(realpath "$ANDROID_ROOT/bin/dalvikvm64")" ]; then
     echo "lib64"
   else
     echo "lib"
@@ -70,16 +73,22 @@
 PROG_NAME="$(follow_links)"
 PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
 ANDROID_ROOT=$PROG_DIR/..
-ANDROID_DATA=$PWD/android-data$$
 LIBDIR=$(find_libdir)
 LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR
 
-
 if [ z"$PERF" != z ]; then
   invoke_with="perf record -o $ANDROID_DATA/perf.data -e cycles:u $invoke_with"
 fi
 
-mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64}
+DELETE_ANDROID_DATA=false
+# If ANDROID_DATA is the system ANDROID_DATA or is not set, use our own,
+# and ensure we delete it at the end.
+if [ "$ANDROID_DATA" = "/data" ] || [ "$ANDROID_DATA" = "" ]; then
+  ANDROID_DATA=$PWD/android-data$$
+  mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64}
+  DELETE_ANDROID_DATA=true
+fi
+
 ANDROID_DATA=$ANDROID_DATA \
   ANDROID_ROOT=$ANDROID_ROOT \
   LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
@@ -97,7 +106,9 @@
   fi
   echo "Perf data saved in: $ANDROID_DATA/perf.data"
 else
-  rm -rf $ANDROID_DATA
+  if [ "$DELETE_ANDROID_DATA" = "true" ]; then
+    rm -rf $ANDROID_DATA
+  fi
 fi
 
 exit $EXIT_STATUS
diff --git a/tools/libcore_failures.txt b/tools/libcore_failures.txt
index 8eac1d3..febc48c 100644
--- a/tools/libcore_failures.txt
+++ b/tools/libcore_failures.txt
@@ -11,11 +11,26 @@
 {
   description: "Assert.java differences between vogar and junit.",
   result: EXEC_FAILED,
+  modes: [host],
   name: "libcore.java.math.RunCSVTests#test_csv"
 },
 {
   description: "Test is currently being updated.",
   result: EXEC_FAILED,
   name: "libcore.java.util.OldTimeZoneTest#test_getDisplayNameZILjava_util_Locale"
+},
+{
+  description: "Differences between vogar and cts in user directory",
+  result: EXEC_FAILED,
+  modes: [device],
+  name: "libcore.java.lang.SystemTest#testSystemProperties_mutable"
+},
+{
+  description: "Differences between vogar and cts",
+  result: EXEC_FAILED,
+  modes: [device],
+  names: ["libcore.java.lang.OldSystemTest#test_getProperties",
+          "org.apache.harmony.tests.java.lang.Process2Test#test_getErrorStream",
+          "org.apache.harmony.tests.java.lang.ProcessTest#test_exitValue"]
 }
 ]