Clean up linux bionic and zipapex test support.

They were only needed for the host APEX, which has been removed.

Test: art/tools/buildbot-build.sh --host
      art/test/testrunner/testrunner.py --host --64
Bug: 279835185
Change-Id: I86bee85ce3d5eeba2a031cedc2d1ea5768a77f2d
diff --git a/build/apex/runtests.sh b/build/apex/runtests.sh
index 11ca28b..f848bd9 100755
--- a/build/apex/runtests.sh
+++ b/build/apex/runtests.sh
@@ -99,7 +99,7 @@
   -l, --list-files    list the contents of the ext4 image (\`find\`-like style)
   -t, --print-tree    list the contents of the ext4 image (\`tree\`-like style)
   -s, --print-sizes   print the size in bytes of each file when listing contents
-  --bitness=32|64|multilib|auto  passed on to art_apex_test.py for non-host APEXes
+  --bitness=32|64|multilib|auto  passed on to art_apex_test.py
   -h, --help          display this help and exit
 
 EOF
@@ -191,36 +191,28 @@
 
   art_apex_test_args="--tmpdir $work_dir"
   test_only_args=""
-  if [[ $apex_module = *.host ]]; then
-    apex_path="$HOST_OUT/apex/${apex_module}.zipapex"
-    art_apex_test_args="$art_apex_test_args --host"
-    test_only_args="--flavor debug"
-    # The host APEX is always built multilib.
-    art_apex_test_args="$art_apex_test_args --bitness=multilib"
+  art_apex_test_args="$art_apex_test_args $device_bitness_arg"
+  if [[ "$TARGET_FLATTEN_APEX" = true ]]; then
+    apex_path="$PRODUCT_OUT/system/apex/${apex_module}"
+    art_apex_test_args="$art_apex_test_args --flattened"
   else
-    art_apex_test_args="$art_apex_test_args $device_bitness_arg"
-    if [[ "$TARGET_FLATTEN_APEX" = true ]]; then
-      apex_path="$PRODUCT_OUT/system/apex/${apex_module}"
-      art_apex_test_args="$art_apex_test_args --flattened"
+    # Note: The Testing ART APEX is never built as a Compressed APEX.
+    if [[ "$PRODUCT_COMPRESSED_APEX" = true && $apex_module != *.testing ]]; then
+      apex_path="$PRODUCT_OUT/system/apex/${apex_module}.capex"
     else
-      # Note: The Testing ART APEX is never built as a Compressed APEX.
-      if [[ "$PRODUCT_COMPRESSED_APEX" = true && $apex_module != *.testing ]]; then
-        apex_path="$PRODUCT_OUT/system/apex/${apex_module}.capex"
-      else
-        apex_path="$PRODUCT_OUT/system/apex/${apex_module}.apex"
-      fi
+      apex_path="$PRODUCT_OUT/system/apex/${apex_module}.apex"
     fi
-    if $have_deapex_binaries; then
-      art_apex_test_args="$art_apex_test_args --deapexer $HOST_OUT/bin/deapexer"
-      art_apex_test_args="$art_apex_test_args --debugfs $HOST_OUT/bin/debugfs_static"
-      art_apex_test_args="$art_apex_test_args --fsckerofs $HOST_OUT/bin/fsck.erofs"
-    fi
-    case $apex_module in
-      (*.debug)   test_only_args="--flavor debug";;
-      (*.testing) test_only_args="--flavor testing";;
-      (*)         test_only_args="--flavor release";;
-    esac
   fi
+  if $have_deapex_binaries; then
+    art_apex_test_args="$art_apex_test_args --deapexer $HOST_OUT/bin/deapexer"
+    art_apex_test_args="$art_apex_test_args --debugfs $HOST_OUT/bin/debugfs_static"
+    art_apex_test_args="$art_apex_test_args --fsckerofs $HOST_OUT/bin/fsck.erofs"
+  fi
+  case $apex_module in
+    (*.debug)   test_only_args="--flavor debug";;
+    (*.testing) test_only_args="--flavor testing";;
+    (*)         test_only_args="--flavor release";;
+  esac
   say "APEX package path: $apex_path"
 
   # List the contents of the APEX image (optional).
diff --git a/test/default_run.py b/test/default_run.py
index 7a482df..5ae0430 100755
--- a/test/default_run.py
+++ b/test/default_run.py
@@ -89,9 +89,7 @@
   argp.add_argument("--random-profile", action="store_true")
   argp.add_argument("--relocate", default=False, action=opt_bool)
   argp.add_argument("--runtime-dm", action="store_true")
-  argp.add_argument("--runtime-extracted-zipapex", default="")
   argp.add_argument("--runtime-option", default=[], action="append")
-  argp.add_argument("--runtime-zipapex", default="")
   argp.add_argument("--secondary", action="store_true")
   argp.add_argument("--secondary-app-image", default=True, action=opt_bool)
   argp.add_argument("--secondary-class-loader-context", default="")
@@ -238,7 +236,6 @@
   PATH = os.environ.get("PATH", "")
   SANITIZE_HOST = os.environ.get("SANITIZE_HOST", "")
   TEST_NAME = os.environ["TEST_NAME"]
-  USE_EXRACTED_ZIPAPEX = os.environ.get("USE_EXRACTED_ZIPAPEX", "")
 
   assert ANDROID_BUILD_TOP, "Did you forget to run `lunch`?"
 
@@ -273,10 +270,6 @@
   HOST = args.host
   BIONIC = args.bionic
   CREATE_ANDROID_ROOT = False
-  USE_ZIPAPEX = (args.runtime_zipapex != "")
-  ZIPAPEX_LOC = args.runtime_zipapex
-  USE_EXTRACTED_ZIPAPEX = (args.runtime_extracted_zipapex != "")
-  EXTRACTED_ZIPAPEX_LOC = args.runtime_extracted_zipapex
   INTERPRETER = args.interpreter
   SWITCH_INTERPRETER = args.switch_interpreter
   JIT = args.jit
@@ -404,12 +397,6 @@
     # the frameworks/libcore with linux_bionic so we need to use the normal
     # host ones which are in a different location.
     CREATE_ANDROID_ROOT = True
-  if USE_ZIPAPEX:
-    # TODO (b/119942078): Currently apex does not support
-    # symlink_preferred_arch so we will not have a dex2oatd to execute and
-    # need to manually provide
-    # dex2oatd64.
-    DEX2OAT_DEBUG_BINARY = "dex2oatd64"
   if WITH_AGENT:
     USE_JVMTI = True
   if DEBUGGER_AGENT:
@@ -738,9 +725,6 @@
   sync_cmdline = "true"
   linkroot_cmdline = "true"
   linkroot_overlay_cmdline = "true"
-  setupapex_cmdline = "true"
-  installapex_cmdline = "true"
-  installapex_test_cmdline = "true"
 
   def linkdirs(host_out: str, root: str):
     dirs = list(filter(os.path.isdir, glob.glob(os.path.join(host_out, "*"))))
@@ -758,20 +742,6 @@
     # Replace the boot image to a location expected by the runtime.
     DALVIKVM_BOOT_OPT = f"-Ximage:{ANDROID_ROOT}/art_boot_images/javalib/boot.art"
 
-  if USE_ZIPAPEX:
-    # TODO Currently this only works for linux_bionic zipapexes because those are
-    # stripped and so small enough that the ulimit doesn't kill us.
-    mkdir_locations += f" {DEX_LOCATION}/zipapex"
-    setupapex_cmdline = f"unzip -o -u {ZIPAPEX_LOC} apex_payload.zip -d {DEX_LOCATION}"
-    installapex_cmdline = f"unzip -o -u {DEX_LOCATION}/apex_payload.zip -d {DEX_LOCATION}/zipapex"
-    ANDROID_ART_BIN_DIR = f"{DEX_LOCATION}/zipapex/bin"
-  elif USE_EXTRACTED_ZIPAPEX:
-    # Just symlink the zipapex binaries
-    ANDROID_ART_BIN_DIR = f"{DEX_LOCATION}/zipapex/bin"
-    # Force since some tests manually run this file twice.
-    # If the {RUN} is executed multiple times we don't need to recreate the link
-    installapex_cmdline = f"ln -sfTv {EXTRACTED_ZIPAPEX_LOC} {DEX_LOCATION}/zipapex"
-
   # PROFILE takes precedence over RANDOM_PROFILE, since PROFILE tests require a
   # specific profile to run properly.
   if PROFILE or RANDOM_PROFILE:
@@ -1094,11 +1064,7 @@
 
   else:
     # Host run.
-    if USE_ZIPAPEX or USE_EXRACTED_ZIPAPEX:
-      # Put the zipapex files in front of the ld-library-path
-      LD_LIBRARY_PATH = f"{ANDROID_DATA}/zipapex/{LIBRARY_DIRECTORY}:{ANDROID_ROOT}/{TEST_DIRECTORY}"
-    else:
-      LD_LIBRARY_PATH = f"{ANDROID_ROOT}/{LIBRARY_DIRECTORY}:{ANDROID_ROOT}/{TEST_DIRECTORY}"
+    LD_LIBRARY_PATH = f"{ANDROID_ROOT}/{LIBRARY_DIRECTORY}:{ANDROID_ROOT}/{TEST_DIRECTORY}"
 
     ctx.export(
       ANDROID_PRINTF_LOG = "brief",
@@ -1152,9 +1118,6 @@
     ctx.run(f"rm -rf {DEX_LOCATION}/{{oat,dalvik-cache}}/")
 
     ctx.run(f"mkdir -p {mkdir_locations}")
-    ctx.run(setupapex_cmdline)
-    if USE_EXTRACTED_ZIPAPEX:
-      ctx.run(installapex_cmdline)
     ctx.run(linkroot_cmdline)
     ctx.run(linkroot_overlay_cmdline)
     ctx.run(profman_cmdline)
diff --git a/test/run-test b/test/run-test
index e650e02..de676a0 100755
--- a/test/run-test
+++ b/test/run-test
@@ -520,27 +520,6 @@
       DEX_LOCATION = tmp_dir
       host_lib_root = f"{OUT_DIR}/soong/host/linux_bionic-x86"
       shift()
-    elif arg == "--runtime-extracted-zipapex":
-      shift()
-      # TODO Should we allow the java.library.path to search the zipapex too?
-      # Not needed at the moment and adding it will be complicated so for now
-      # we'll ignore this.
-      run_args += [f'--host --runtime-extracted-zipapex "{arg}"']
-      target_mode = "no"
-      DEX_LOCATION = tmp_dir
-      shift()
-    elif arg == "--runtime-zipapex":
-      shift()
-      # TODO Should we allow the java.library.path to search the zipapex too?
-      # Not needed at the moment and adding it will be complicated so for now
-      # we'll ignore this.
-      run_args += [f'--host --runtime-zipapex "{arg}"']
-      target_mode = "no"
-      DEX_LOCATION = tmp_dir
-      # apex_payload.zip is quite large we need a high enough ulimit to
-      # extract it. 512mb should be good enough.
-      file_ulimit = 512000
-      shift()
     elif arg == "--timeout":
       shift()
       if not arg:
@@ -846,11 +825,6 @@
         "                          (if applicable) to run the test with.\n"
         "    --64                  Run the test in 64-bit mode\n"
         "    --bionic              Use the (host, 64-bit only) linux_bionic libc runtime\n"
-        "    --runtime-zipapex [file]\n"
-        "                          Use the given zipapex file to provide runtime binaries\n"
-        "    --runtime-extracted-zipapex [dir]\n"
-        "                          Use the given extracted zipapex directory to provide\n"
-        "                          runtime binaries\n"
         "    --timeout n           Test timeout in seconds\n"
         "    --trace               Run with method tracing\n"
         "    --strace              Run with syscall tracing from strace.\n"
diff --git a/test/testrunner/target_config.py b/test/testrunner/target_config.py
index 0c170f2..38c170d 100644
--- a/test/testrunner/target_config.py
+++ b/test/testrunner/target_config.py
@@ -306,19 +306,4 @@
     'art-golem-linux-x64': {
         'golem' : 'linux-x64'
     },
-    'art-linux-bionic-x64': {
-        'build': '{ANDROID_BUILD_TOP}/art/tools/build_linux_bionic_tests.sh {MAKE_OPTIONS}',
-        'run-test': ['--run-test-option=--bionic',
-                     '--host',
-                     '--64',
-                     '--no-build-dependencies'],
-    },
-    # TODO(b/279835185) Remove this when the internal reference is removed.
-    'art-linux-bionic-x64-zipapex': {
-        'build': '{ANDROID_BUILD_TOP}/art/tools/build_linux_bionic_tests.sh {MAKE_OPTIONS}',
-        'run-test': ['--run-test-option=--bionic',
-                     '--host',
-                     '--64',
-                     '--no-build-dependencies'],
-    },
 }
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 6a348dc..00f34d3 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -60,7 +60,6 @@
   sys.stdout.flush()
   raise
 
-import contextlib
 import csv
 import datetime
 import fnmatch
@@ -145,7 +144,6 @@
 csv_writer = None
 runtime_option = ''
 with_agent: List[str] = []
-zipapex_loc = None
 run_test_option: List[str] = []
 dex2oat_jobs = -1   # -1 corresponds to default threads for dex2oat
 run_all_configs = False
@@ -595,53 +593,33 @@
       args_test = [python3_bin, run_test_sh] + args_test + extra_arguments[target] + [test]
       return executor.submit(run_test, args_test, test, variant_set, test_name)
 
-  #  Use a context-manager to handle cleaning up the extracted zipapex if needed.
-  with handle_zipapex(zipapex_loc) as zipapex_opt:
-    args_all += zipapex_opt
-    global n_thread
-    with concurrent.futures.ThreadPoolExecutor(max_workers=n_thread) as executor:
-      test_futures = []
-      for config_tuple in config:
-        target = config_tuple[1]
-        for address_size in _user_input_variants['address_sizes_target'][target]:
-          test_futures.append(start_combination(executor, config_tuple, args_all, address_size))
+  global n_thread
+  with concurrent.futures.ThreadPoolExecutor(max_workers=n_thread) as executor:
+    test_futures = []
+    for config_tuple in config:
+      target = config_tuple[1]
+      for address_size in _user_input_variants['address_sizes_target'][target]:
+        test_futures.append(start_combination(executor, config_tuple, args_all, address_size))
 
-      for config_tuple in uncombinated_config:
-        test_futures.append(
-            start_combination(executor, config_tuple, args_all, ""))  # no address size
+    for config_tuple in uncombinated_config:
+      test_futures.append(
+          start_combination(executor, config_tuple, args_all, ""))  # no address size
 
-      try:
-        tests_done = 0
-        for test_future in concurrent.futures.as_completed(f for f in test_futures if f):
-          (test, status, failure_info, test_time) = test_future.result()
-          tests_done += 1
-          print_test_info(tests_done, test, status, failure_info, test_time)
-          if failure_info and not env.ART_TEST_KEEP_GOING:
-            for f in test_futures:
-              f.cancel()
-            break
-      except KeyboardInterrupt:
-        for f in test_futures:
-          f.cancel()
-        child_process_tracker.kill_all()
-      executor.shutdown(True)
-
-@contextlib.contextmanager
-def handle_zipapex(ziploc):
-  """Extracts the zipapex (if present) and handles cleanup.
-
-  If we are running out of a zipapex we want to unzip it once and have all the tests use the same
-  extracted contents. This extracts the files and handles cleanup if needed. It returns the
-  required extra arguments to pass to the run-test.
-  """
-  if ziploc is not None:
-    with tempfile.TemporaryDirectory() as tmpdir:
-      subprocess.check_call(["unzip", "-qq", ziploc, "apex_payload.zip", "-d", tmpdir])
-      subprocess.check_call(
-        ["unzip", "-qq", os.path.join(tmpdir, "apex_payload.zip"), "-d", tmpdir])
-      yield ['--runtime-extracted-zipapex', tmpdir]
-  else:
-    yield []
+    try:
+      tests_done = 0
+      for test_future in concurrent.futures.as_completed(f for f in test_futures if f):
+        (test, status, failure_info, test_time) = test_future.result()
+        tests_done += 1
+        print_test_info(tests_done, test, status, failure_info, test_time)
+        if failure_info and not env.ART_TEST_KEEP_GOING:
+          for f in test_futures:
+            f.cancel()
+          break
+    except KeyboardInterrupt:
+      for f in test_futures:
+        f.cancel()
+      child_process_tracker.kill_all()
+    executor.shutdown(True)
 
 def _popen(**kwargs):
   if sys.version_info.major == 3 and sys.version_info.minor >= 6:
@@ -832,7 +810,6 @@
       'variant' : (str,),
       'devices': (list, str),
       'env_vars' : (dict,),
-      'zipapex' : (bool,),
   }
   for field in entry:
     field_type = type(entry[field])
@@ -893,16 +870,6 @@
         else:
           disabled_test_info[test] = variants
 
-    zipapex_disable = failure.get("zipapex", False)
-    if zipapex_disable and zipapex_loc is not None:
-      for test in tests:
-        if test not in RUN_TEST_SET:
-          raise ValueError('%s is not a valid run-test' % (test))
-        if test in disabled_test_info:
-          disabled_test_info[test] = disabled_test_info[test].union(variants)
-        else:
-          disabled_test_info[test] = variants
-
   return disabled_test_info
 
 def gather_disabled_test_info():
@@ -1119,7 +1086,6 @@
   global dex2oat_jobs
   global run_all_configs
   global with_agent
-  global zipapex_loc
   global csv_result
 
   parser = argparse.ArgumentParser(description="Runs all or a subset of the ART test suite.")
@@ -1173,8 +1139,6 @@
                             example '--runtime-option=-Xjitthreshold:0'.""")
   global_group.add_argument('--dex2oat-jobs', type=int, dest='dex2oat_jobs',
                             help='Number of dex2oat jobs')
-  global_group.add_argument('--runtime-zipapex', dest='runtime_zipapex', default=None,
-                            help='Location for runtime zipapex.')
   global_group.add_argument('-a', '--all', action='store_true', dest='run_all',
                             help="Run all the possible configurations for the input test set")
   global_group.add_argument('--csv-results', action='store', dest='csv_result', default=None,
@@ -1238,7 +1202,6 @@
   runtime_option = options['runtime_option'];
   with_agent = options['with_agent'];
   run_test_option = sum(map(shlex.split, options['run_test_option']), [])
-  zipapex_loc = options['runtime_zipapex']
 
   timeout = options['timeout']
   if options['dex2oat_jobs']: