ART: Make run-test timeout dependent on sanitization

Only sanitization shows really long runs. Lower the default timeout
to 10 minutes and attempt to detect sanitized builds.

Bug: 140935398
Test: art/test/testrunner/testrunner.py -b --host
Test: SANITIZE_HOST=address art/test/testrunner/testrunner.py -b --host
Change-Id: I6c40ba310e8c177c1621ac75264a838efecfac83
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 01a0346..75b29d1 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -64,9 +64,9 @@
 SECONDARY_DEX=""
 TIME_OUT="timeout"  # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb)
 TIMEOUT_DUMPER=signal_dumper
-# Value in seconds. If you change this, update the timeout in testrunner.py as well.
-# TODO: Only ASAN builds come close to this value. Distinguish ASAN from non-ASAN builds.
-TIME_OUT_VALUE=1500  # 25 minutes.
+# Values in seconds.
+TIME_OUT_EXTRA=
+TIME_OUT_VALUE=
 USE_GDB="n"
 USE_GDBSERVER="n"
 GDBSERVER_PORT=":5039"
@@ -143,7 +143,7 @@
         shift
     elif [ "x$1" = "x--gc-stress" ]; then
         # Give an extra 5 mins if we are gc-stress.
-        TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300))
+        TIME_OUT_EXTRA=300
         shift
     elif [ "x$1" = "x--testlib" ]; then
         shift
@@ -444,6 +444,22 @@
     fi
 done
 
+# If you change this, update the timeout in testrunner.py as well.
+if [ -z "$TIME_OUT_VALUE" ] ; then
+  # 10 minutes is the default.
+  TIME_OUT_VALUE=600
+
+  # For sanitized builds use a larger base.
+  # TODO: Consider sanitized target builds?
+  if [ "x$SANITIZE_HOST" != "x" ] ; then
+    TIME_OUT_VALUE=1500  # 25 minutes.
+  fi
+
+  if [ ! -z "$TIME_OUT_EXTRA" ] ; then
+    TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + ${TIME_OUT_EXTRA}))
+  fi
+fi
+
 # The DEX_LOCATION with the chroot prefix, if any.
 CHROOT_DEX_LOCATION="$CHROOT$DEX_LOCATION"