run-libcore-tests.sh: add --timeout command-line option

This is to force timeout issues when working on vogar.

Bug: 161420453
Test: run-libcore-tests.sh --mode=host --variant=X32 --timeout 100
Change-Id: Ieff1e0559e01a328b87ffedd62589b44820b0890
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index 888dc66..8dac57c 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -239,7 +239,7 @@
 fi
 
 # Default timeout, gets overridden on device under gcstress.
-timeout_secs=480
+default_timeout_secs=480
 
 if [ $execution_mode = "device" ]; then
   # Honor environment variable ART_TEST_CHROOT.
@@ -259,16 +259,18 @@
   # the default timeout.
   if $gcstress; then
     if $debug; then
-      timeout_secs=1440
+      default_timeout_secs=1440
     else
-      timeout_secs=900
+      default_timeout_secs=900
     fi
   fi
 fi  # $execution_mode = "device"
 
 if [ $execution_mode = "device" -o $execution_mode = "host" ]; then
-  # Add timeout to vogar command-line.
-  vogar_args="$vogar_args --timeout $timeout_secs"
+  # Add timeout to vogar command-line (if not explicitly present in the command-line arguments) .
+  if [[ "$vogar_args" != *" --timeout "* ]]; then
+    vogar_args="$vogar_args --timeout $default_timeout_secs"
+  fi
 
   # Suppress explicit gc logs that are triggered an absurd number of times by these tests.
   vogar_args="$vogar_args --vm-arg -XX:AlwaysLogExplicitGcs:false"