Run test run: Don't use arch guessing heuristics (part 1)

Don't guess the arch from the devices filesystem.
Just check which arch we are building for instead.

As the first step, only assert that those two equal.

Test: ./art/test.py -r --target --optimizing --32 -t 001-HelloWorld
Test: ./art/test.py -r --target --optimizing --64 -t 001-HelloWorld
Change-Id: I2a82cfee472b7ce2c0e1109bddbfd681b85d553c
diff --git a/test/run-test b/test/run-test
index 2bffe37..5e4403c 100755
--- a/test/run-test
+++ b/test/run-test
@@ -22,6 +22,7 @@
 from inspect import currentframe, getframeinfo, FrameInfo
 from pathlib import Path
 from shutil import copyfile
+from testrunner import env
 from typing import Optional
 
 COLOR = (os.environ.get("LUCI_CONTEXT") == None)  # Disable colors on LUCI.
@@ -656,6 +657,19 @@
         target_arch_name = grep64bit
       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]}"
+
     return target_arch_name.strip()
 
   def guess_host_arch_name():