ART: Detect target run-test timeout and print a message

To make it more obvious that a timeout has happened, detect it
and print a message to appear in the shell log (not logcat).

Bug: 140935398
Test: manual
Change-Id: I0c9d939a7822c835f603ff42cb4972a44dce29b0
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index f924386..1ef64ae 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -1092,6 +1092,7 @@
     fi
 
     timeout_prefix=
+    timeout_suffix=
     if [ "$TIME_OUT" = "timeout" ]; then
       # Add timeout command if time out is desired.
       #
@@ -1100,7 +1101,10 @@
       #       dumping do not lead to a deadlock, we also use the "-k" option to definitely kill the
       #       child.
       # Note: Using "--foreground" to not propagate the signal to children, i.e., the runtime.
-      timeout_prefix="timeout --foreground -k 120s ${TIME_OUT_VALUE}s ${timeout_dumper_cmd} $cmdline"
+      timeout_prefix="timeout --foreground -k 120s ${TIME_OUT_VALUE}s ${timeout_dumper_cmd}"
+      # Use a suffix to detect timeout and echo something. Otherwise there's no immediate
+      # visible feedback (outside of logcat).
+      timeout_suffix=' || if [ $? -eq 124 ] ; then echo "TIMED OUT!" ; false ; fi'
     fi
 
     # Create a script with the command. The command can get longer than the longest
@@ -1127,7 +1131,7 @@
              $vdex_cmdline && \
              $strip_cmdline && \
              $sync_cmdline && \
-             $timeout_prefix $dalvikvm_cmdline"
+             $timeout_prefix $dalvikvm_cmdline $timeout_suffix"
 
     cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME")
     echo "$cmdline" > $cmdfile