Add support for running specific tests to run-gtests.sh.

Test: art/tools/run-gtests.sh
Test: art/tools/run-gtests.sh -h
Test: art/tools/run-gtests.sh -j4
Test: art/tools/run-gtests.sh /apex/com.android.art/bin/art/arm/instruction_set_features_test
Test: art/tools/run-gtests.sh -j4 /apex/com.android.art/bin/art/arm/instruction_set_features_test
Change-Id: Ie29819d27e2657e7c32c2b1f9ce830cbc136f2ed
diff --git a/test/README.chroot.md b/test/README.chroot.md
index 447b17a..1bd7581 100644
--- a/test/README.chroot.md
+++ b/test/README.chroot.md
@@ -87,6 +87,8 @@
         * Workaround: Run `m clean-oat-host` before the build step
         (`art/tools/buildbot-build.sh --target -j40`) above.
     * Note: The `-j` option is not honored yet (b/129930445).
+    * Specific tests to run can be passed on the command line, specified by
+    their absolute paths beginning with "/apex/".
 8. Run ART run-tests:
     * On a 64-bit target:
         ```bash
diff --git a/tools/run-gtests.sh b/tools/run-gtests.sh
index a1df7c3..290cb7d 100755
--- a/tools/run-gtests.sh
+++ b/tools/run-gtests.sh
@@ -14,7 +14,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Script to run all gtests located in the (Testing) Runtime APEX.
+if [[ $1 = -h ]]; then
+  cat <<EOF
+Script to run gtests located in the ART (Testing) APEX.
+
+If called with arguments, only those tests are run, as specified by their
+absolute paths (starting with /apex). All gtests are run otherwise.
+EOF
+  exit
+fi
 
 if [[ -z "$ART_TEST_CHROOT" ]]; then
   echo 'ART_TEST_CHROOT environment variable is empty; please set it before running this script.'
@@ -27,9 +35,18 @@
 android_runtime_root=/apex/com.android.runtime
 android_tzdata_root=/apex/com.android.tzdata
 
-# Search for executables under the `bin/art` directory of the Runtime APEX.
-tests=$("$adb" shell chroot "$ART_TEST_CHROOT" \
-  find "$android_runtime_root/bin/art" -type f -perm /ugo+x | sort)
+if [[ $1 = -j* ]]; then
+  # TODO(b/129930445): Implement support for parallel execution.
+  shift
+fi
+
+if [ $# -gt 0 ]; then
+  tests="$@"
+else
+  # Search for executables under the `bin/art` directory of the ART APEX.
+  tests=$("$adb" shell chroot "$ART_TEST_CHROOT" \
+    find "$android_runtime_root/bin/art" -type f -perm /ugo+x | sort)
+fi
 
 failing_tests=()