ART: Move target APEX checks

Move testing and printing from runtests.sh to art_apex_test.py.
Add previously missed target-debug-only checks. Add runtests.sh
debugfs check/building. Remove guestfs code.

Test: art/build/apex/runtests.sh
Test: art/build/apex/runtests.sh -l
Test: art/build/apex/runtests.sh -t
Change-Id: Id0485a090d190ed7a1c3103b7edf01c1dc28e0ed
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 2d6b370..e636a72 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -117,15 +117,19 @@
   def error_count(self):
     return self._errors
 
-  def check_file(self, file):
+  def is_file(self, file):
     fs_object = self._provider.get(file)
     if fs_object is None:
-      self.fail('Could not find %s', file)
-      return False
+      return (False, 'Could not find %s')
     if fs_object.is_dir:
-      self.fail('%s is a directory', file)
-      return False
-    return True
+      return (False, '%s is a directory')
+    return (True, '')
+
+  def check_file(self, file):
+    chk = self.is_file(file)
+    if not chk[0]:
+      self.fail(chk[1], file)
+    return chk[0]
 
   def check_binary(self, file):
     path = 'bin/%s' % (file)
@@ -165,6 +169,14 @@
       res = self.check_file('lib64/%s' % (file)) and res
     return res
 
+  def check_single_library(self, file):
+    res1 = self.is_file('lib/%s' % (file))
+    res2 = self.is_file('lib64/%s' % (file))
+    if not res1[0] and not res2[0]:
+      self.fail('Library missing: %s', file)
+      return False
+    return True
+
   def check_java_library(self, file):
     return self.check_file('javalib/%s' % (file))
 
@@ -258,6 +270,17 @@
     # Check that the mounted image contains additional required debug libraries.
     self.check_library('libadbconnectiond.so')
 
+class DebugTargetChecker(Checker):
+  def __init__(self, provider):
+    super().__init__(provider)
+  def __str__(self):
+    return 'Debug (Target) Checker'
+
+  def run(self):
+    # Check for files pulled in from debug target-only oatdump.
+    self.check_binary('oatdump')
+    self.check_single_library('libart-disassembler.so')
+
 def print_list(provider):
     def print_list_impl(provider, path):
       map = provider.read_dir(path)
@@ -333,8 +356,8 @@
 
   try:
     apex_provider = TargetApexProvider(args.apex, args.tmpdir, args.debugfs)
-  except:
-    logging.error('Failed to create provider')
+  except Exception as e:
+    logging.error('Failed to create provider: %s', e)
     return 1
 
   if args.tree:
@@ -352,6 +375,8 @@
   checkers.append(ReleaseChecker(apex_provider))
   if args.debug:
     checkers.append(DebugChecker(apex_provider))
+  if args.debug and args.target:
+    checkers.append(DebugTargetChecker(apex_provider))
 
   failed = False
   for checker in checkers: