Allow running art run-tests with simpleperf.

Add "--simpleperf" option to art/test/run-test and pass it to
art/test/etc/run-test-jar. With this option dalvikvm invocation is
wrapped in "simpleperf record ... simpleperf report".

The new option can be used with chroot-based testsing approach described
in art/test/README.chroot.md. For example, to profile 001-HelloWorld on
a sargo device with serial 8BLAY00EVN (64-bit), do the following steps:

  unset ART_TEST_ANDROID_ROOT
  unset CUSTOM_TARGET_LINKER
  unset ART_TEST_ANDROID_ART_ROOT
  unset ART_TEST_ANDROID_RUNTIME_ROOT
  unset ART_TEST_ANDROID_I18N_ROOT
  unset ART_TEST_ANDROID_TZDATA_ROOT

  export ART_TEST_CHROOT=/data/local/art-test-chroot
  export ANDROID_SERIAL=8BLAY00EVN
  export ART_HEAP_POISONING=true

  . ./build/envsetup.sh
  lunch aosp_sargo-userdebug

  art/tools/buildbot-build.sh --target -j72 # --installclean
  art/tools/buildbot-cleanup-device.sh
  art/tools/buildbot-setup-device.sh
  art/tools/buildbot-sync.sh

  art/test/run-test --simpleperf --chroot $ART_TEST_CHROOT --64 001-HelloWorld

  art/tools/buildbot-teardown-device.sh
  art/tools/buildbot-cleanup-device.sh

Bug: none
Test: Ran the above steps, observed simpleperf stats in the output.
Change-Id: I1ce14fa94add3a1a6e7cec59382909ad6d11ef2a
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index cc22e6e..cfac63b 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -425,6 +425,9 @@
         shift
         CHROOT="$1"
         shift
+    elif [ "x$1" = "x--simpleperf" ]; then
+        SIMPLEPERF="yes"
+        shift
     elif [ "x$1" = "x--android-root" ]; then
         shift
         ANDROID_ROOT="$1"
@@ -1165,6 +1168,7 @@
 # We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind.
 # b/27185632
 # b/24664297
+
 dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ART_BIN_DIR/$DALVIKVM \
                   $GDB_ARGS \
                   $FLAGS \
@@ -1181,6 +1185,10 @@
                   -XX:DumpNativeStackOnSigQuit:false \
                   -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS"
 
+if [ "x$SIMPLEPERF" == xyes ]; then
+  dalvikvm_cmdline="simpleperf record ${dalvikvm_cmdline} && simpleperf report"
+fi
+
 sanitize_dex2oat_cmdline() {
   local args=()
   for arg in "$@"; do
diff --git a/test/run-test b/test/run-test
index 50b09a7..bb690f5 100755
--- a/test/run-test
+++ b/test/run-test
@@ -346,6 +346,9 @@
         chroot="$1"
         run_args+=(--chroot "$1")
         shift
+    elif [ "x$1" = "x--simpleperf" ]; then
+        run_args+=(--simpleperf)
+        shift
     elif [ "x$1" = "x--android-root" ]; then
         shift
         if [ "x$1" = "x" ]; then