Run test: Remove use of 'get-device-isa' (part 1)

Get the ISA from build configuration rather than investigating
the attached device.

As the first step, assert that those two match.

Test: ./art/test.py -b -r --optimizing --32 001-HelloWorld
Test: ./art/test.py -b -r --optimizing --64 001-HelloWorld
Change-Id: I74e750666f427e741be417e755bd11ad65e32a99
diff --git a/test/default_run.py b/test/default_run.py
index c30b651..3f311a8 100755
--- a/test/default_run.py
+++ b/test/default_run.py
@@ -17,9 +17,10 @@
 from argparse import ArgumentParser, BooleanOptionalAction, Namespace
 from os import path
 from os.path import isfile, isdir, basename
-from typing import List
 from subprocess import DEVNULL, PIPE, STDOUT
 from tempfile import NamedTemporaryFile
+from testrunner import env
+from typing import List
 
 COLOR = (os.environ.get("LUCI_CONTEXT") == None)  # Disable colors on LUCI.
 COLOR_BLUE = '\033[94m' if COLOR else ''
@@ -133,6 +134,17 @@
 
   return argp.parse_args(argv)
 
+def get_target_arch(is64: bool) -> str:
+  # We may build for two arches. Get the one with the expected bitness.
+  arches = [a for a in [env.TARGET_ARCH, env.TARGET_2ND_ARCH] if a]
+  assert len(arches) > 0, "TARGET_ARCH/TARGET_2ND_ARCH not set"
+  if is64:
+    arches = [a for a in arches if a.endswith("64")]
+    assert len(arches) == 1, f"Can not find (unique) 64-bit arch in {arches}"
+  else:
+    arches = [a for a in arches if not a.endswith("64")]
+    assert len(arches) == 1, f"Can not find (unique) 32-bit arch in {arches}"
+  return arches[0]
 
 # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
 # because that's what we use for compiling the boot.art image.
@@ -580,6 +592,8 @@
         f"{ANDROID_BUILD_TOP}/art/test/utils/get-device-isa {GET_DEVICE_ISA_BITNESS_FLAG}",
         adb.env,
         save_cmd=False).stdout.strip()
+    target_arch = get_target_arch(args.is64)  # Should return the same ISA.
+    assert ISA == target_arch, f"{ISA} vs {target_arch}"
 
   if not USE_JVM:
     FLAGS += f" {ANDROID_FLAGS}"
diff --git a/test/run-test b/test/run-test
index b405de1..4612622 100755
--- a/test/run-test
+++ b/test/run-test
@@ -18,6 +18,7 @@
 
 import default_run as default_run_module
 
+from default_run import get_target_arch
 from importlib.machinery import SourceFileLoader
 from inspect import currentframe, getframeinfo, FrameInfo
 from pathlib import Path
@@ -666,17 +667,9 @@
       else:
         target_arch_name = grep32bit
 
-    # We may build for two arches. Get the one with the expected bitness.
-    arches = [env.TARGET_ARCH, env.TARGET_2ND_ARCH]
-    if suffix64 == "64":
-      arch = [a for a in arches if a and a.endswith("64")]
-      assert len(arch) == 1, f"Can not find unique 64-bit arch in {arches}"
-    else:
-      arch = [a for a in arches if a and not a.endswith("64")]
-      assert len(arch) == 1, f"Can not find unique 32-bit arch in {arches}"
-
     # Check that the heuristics matches build configuration.
-    assert target_arch_name.strip() == arch[0], f"{target_arch_name.strip()} != {arch[0]}"
+    arch = get_target_arch(suffix64 == "64")
+    assert target_arch_name.strip() == arch, f"{target_arch_name.strip()} != {arch}"
 
     return target_arch_name.strip()