Introduce arch-specific checker tests.

- The '.cfg' output is now created on target.
- Arch-specific checker tests can be created by inserting a
  suffix. For example:
      /// CHECK-START-ARM64: int Main.foo(int) register (after)
      /// CHECK-DAG:   <<Arg:i\d+>>     ParameterValue

Change-Id: I55cdb37f8e806c7ffdde6b676c8f44ac30b59051
diff --git a/test/run-test b/test/run-test
index 3d6f073..84c818b 100755
--- a/test/run-test
+++ b/test/run-test
@@ -626,12 +626,19 @@
   # on a particular DEX output, keep building them with dx for now (b/19467889).
   USE_JACK="false"
 
-  if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" -a "$target_mode" = "no" -a "$debuggable" = "no" ]; then
+  if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" -a "$debuggable" = "no" ]; then
     # In no-prebuild mode, the compiler is only invoked if both dex2oat and
     # patchoat are available. Disable Checker otherwise (b/22552692).
     if [ "$prebuild_mode" = "yes" ] || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
       run_checker="yes"
-      run_args="${run_args} -Xcompiler-option --dump-cfg=$tmp_dir/$cfg_output \
+      if [ "$target_mode" = "no" ]; then
+        cfg_output_dir="$tmp_dir"
+        checker_arch_option=
+      else
+        cfg_output_dir="$DEX_LOCATION"
+        checker_arch_option="--arch=${target_arch_name^^}"
+      fi
+      run_args="${run_args} -Xcompiler-option --dump-cfg=$cfg_output_dir/$cfg_output \
                             -Xcompiler-option -j1"
     fi
   fi
@@ -647,6 +654,12 @@
   build_file_size_limit=5120
   run_file_size_limit=5120
 fi
+if [ "$run_checker" = "yes" -a "$target_mode" = "yes" ]; then
+  # We will need to `adb pull` the .cfg output from the target onto the host to
+  # run checker on it. This file can be big.
+  build_file_size_limit=16384
+  run_file_size_limit=16384
+fi
 if [ ${USE_JACK} = "false" ]; then
   # Set ulimit if we build with dx only, Jack can generate big temp files.
   if ! ulimit -S "$build_file_size_limit"; then
@@ -671,7 +684,10 @@
 
         if [ "$run_exit" = "0" ]; then
             if [ "$run_checker" = "yes" ]; then
-                "$checker" "$cfg_output" "$tmp_dir" 2>&1
+                if [ "$target_mode" = "yes" ]; then
+                  adb pull $cfg_output_dir/$cfg_output &> /dev/null
+                fi
+                "$checker" $checker_arch_option "$cfg_output" "$tmp_dir" 2>&1
                 checker_exit="$?"
                 if [ "$checker_exit" = "0" ]; then
                     good="yes"
@@ -693,7 +709,10 @@
         echo "${test_dir}: running..." 1>&2
         "./${run}" $run_args "$@" >"$output" 2>&1
         if [ "$run_checker" = "yes" ]; then
-          "$checker" -q "$cfg_output" "$tmp_dir" >> "$output" 2>&1
+          if [ "$target_mode" = "yes" ]; then
+            adb pull $cfg_output_dir/$cfg_output &> /dev/null
+          fi
+          "$checker" -q $checker_arch_option "$cfg_output" "$tmp_dir" >> "$output" 2>&1
         fi
         sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
         good="yes"
@@ -731,7 +750,10 @@
             echo "run exit status: $run_exit" 1>&2
             good_run="no"
         elif [ "$run_checker" = "yes" ]; then
-            "$checker" -q "$cfg_output" "$tmp_dir" >> "$output" 2>&1
+            if [ "$target_mode" = "yes" ]; then
+              adb pull $cfg_output_dir/$cfg_output &> /dev/null
+            fi
+            "$checker" -q $checker_arch_option "$cfg_output" "$tmp_dir" >> "$output" 2>&1
             checker_exit="$?"
             if [ "$checker_exit" != "0" ]; then
                 echo "checker exit status: $checker_exit" 1>&2