atest: Add com.android.compatibility* lookup in the test xml.

Some device side test targets depend on host side runtime jars.
These can't be listed as build deps but will cause atest to fail
if the host side runtime dep is not built. Until we can resolve
this via the base harness, include cts-tradefed as a build target.

Bug: 70813166
Test: atest CtsAslrMallocTestCases
Change-Id: I95a00b7903341634ed57e1dde3cfd6260b8cd9fc
diff --git a/atest/cli_translator.py b/atest/cli_translator.py
index 1b6edc6..5356e81 100644
--- a/atest/cli_translator.py
+++ b/atest/cli_translator.py
@@ -53,6 +53,9 @@
 PACKAGE_RE = re.compile(r'\s*package\s+(?P<package>[^;]+)\s*;\s*', re.I)
 TEST_MODULE_NAME = 'test-module-name'
 
+COMPATIBILITY_PACKAGE_PREFIX = "com.android.compatibility"
+CTS_JAR = "cts-tradefed"
+
 class NoTestFoundError(Exception):
     """Raised when no tests are found."""
 
@@ -374,6 +377,13 @@
                 logging.warning('Build target (%s) parsed out of %s but not '
                                 'present in %s, skipping build', target_to_add,
                                 xml_file, MODULE_INFO)
+        # TODO (b/70813166): Remove this lookup once all runtime dependencies
+        # can belisted as a build dependencies or are in the base test harness.
+        nodes_with_class = root.findall(".//*[@class]")
+        for class_attr in nodes_with_class:
+            fqcn = class_attr.attrib['class'].strip()
+            if fqcn.startswith(COMPATIBILITY_PACKAGE_PREFIX):
+                targets.add(CTS_JAR)
         logging.debug('Targets found in config file: %s', targets)
         return targets