Move test/etc/default_run.py one directory up.

Also merge in the single use of apex_bootclasspath_utils.

This removes the awkwardly named etc/ directory.

Test: test.py -b -r --all-target --optimizing --64
Change-Id: I79a752cb3c2da4d50a6fc4c26e58056dc9224d0c
diff --git a/test/etc/default_run.py b/test/default_run.py
similarity index 96%
rename from test/etc/default_run.py
rename to test/default_run.py
index 268ec2f..de6b8fe 100755
--- a/test/etc/default_run.py
+++ b/test/default_run.py
@@ -14,7 +14,6 @@
 # limitations under the License.
 
 import sys, os, shutil, shlex, re, subprocess, glob
-from etc.apex_bootclasspath_utils import get_apex_bootclasspath, get_apex_bootclasspath_locations
 from argparse import ArgumentParser, BooleanOptionalAction, Namespace
 from os import path
 from os.path import isfile, isdir
@@ -129,6 +128,59 @@
   return argp.parse_args(argv)
 
 
+# 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.
+# It may contain additional modules from TEST_CORE_JARS.
+bpath_modules = ("core-oj core-libart okhttp bouncycastle apache-xml core-icu4j"
+                 " conscrypt")
+
+
+# Helper function to construct paths for apex modules (for both -Xbootclasspath and
+# -Xbootclasspath-location).
+def get_apex_bootclasspath_impl(bpath_prefix: str):
+  bpath_separator = ""
+  bpath = ""
+  bpath_jar = ""
+  for bpath_module in bpath_modules.split(" "):
+    apex_module = "com.android.art"
+    if bpath_module == "conscrypt":
+      apex_module = "com.android.conscrypt"
+    if bpath_module == "core-icu4j":
+      apex_module = "com.android.i18n"
+    bpath_jar = f"/apex/{apex_module}/javalib/{bpath_module}.jar"
+    bpath += f"{bpath_separator}{bpath_prefix}{bpath_jar}"
+    bpath_separator = ":"
+  return bpath
+
+
+# Gets a -Xbootclasspath paths with the apex modules.
+def get_apex_bootclasspath(host: bool):
+  bpath_prefix = ""
+
+  if host:
+    bpath_prefix = os.environ["ANDROID_HOST_OUT"]
+
+  return get_apex_bootclasspath_impl(bpath_prefix)
+
+
+# Gets a -Xbootclasspath-location paths with the apex modules.
+def get_apex_bootclasspath_locations(host: bool):
+  bpath_location_prefix = ""
+
+  if host:
+    ANDROID_BUILD_TOP=os.environ["ANDROID_BUILD_TOP"]
+    ANDROID_HOST_OUT=os.environ["ANDROID_HOST_OUT"]
+    if ANDROID_HOST_OUT[0:len(ANDROID_BUILD_TOP)+1] == f"{ANDROID_BUILD_TOP}/":
+      bpath_location_prefix=ANDROID_HOST_OUT[len(ANDROID_BUILD_TOP)+1:]
+    else:
+      print(f"ANDROID_BUILD_TOP/ is not a prefix of ANDROID_HOST_OUT"\
+            "\nANDROID_BUILD_TOP={ANDROID_BUILD_TOP}"\
+            "\nANDROID_HOST_OUT={ANDROID_HOST_OUT}")
+      sys.exit(1)
+
+  return get_apex_bootclasspath_impl(bpath_location_prefix)
+
+
 def default_run(ctx, args, **kwargs):
   # Clone the args so we can modify them without affecting args in the caller.
   args = Namespace(**vars(args))
diff --git a/test/etc/apex_bootclasspath_utils.py b/test/etc/apex_bootclasspath_utils.py
deleted file mode 100755
index d2415e5..0000000
--- a/test/etc/apex_bootclasspath_utils.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Copyright (C) 2022 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# This file contains utils for constructing -Xbootclasspath and -Xbootclasspath-location
-# for dex2oat and dalvikvm from apex modules list.
-#
-# Those utils could be used outside of art/test/ to run ART in chroot setup.
-
-import os, sys
-
-# 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.
-# It may contain additional modules from TEST_CORE_JARS.
-bpath_modules = ("core-oj core-libart okhttp bouncycastle apache-xml core-icu4j"
-                 " conscrypt")
-
-
-# Helper function to construct paths for apex modules (for both -Xbootclasspath and
-# -Xbootclasspath-location).
-#
-#  Arguments.
-#   ${1}: path prefix.
-def get_apex_bootclasspath_impl(bpath_prefix: str):
-  bpath_separator = ""
-  bpath = ""
-  bpath_jar = ""
-  for bpath_module in bpath_modules.split(" "):
-    apex_module = "com.android.art"
-    if bpath_module == "conscrypt":
-      apex_module = "com.android.conscrypt"
-    if bpath_module == "core-icu4j":
-      apex_module = "com.android.i18n"
-    bpath_jar = f"/apex/{apex_module}/javalib/{bpath_module}.jar"
-    bpath += f"{bpath_separator}{bpath_prefix}{bpath_jar}"
-    bpath_separator = ":"
-  return bpath
-
-
-# Gets a -Xbootclasspath paths with the apex modules.
-#
-#  Arguments.
-#   ${1}: host (y|n).
-def get_apex_bootclasspath(host: bool):
-  bpath_prefix = ""
-
-  if host:
-    bpath_prefix = os.environ["ANDROID_HOST_OUT"]
-
-  return get_apex_bootclasspath_impl(bpath_prefix)
-
-
-# Gets a -Xbootclasspath-location paths with the apex modules.
-#
-#  Arguments.
-#   ${1}: host (y|n).
-def get_apex_bootclasspath_locations(host: bool):
-  bpath_location_prefix = ""
-
-  if host:
-    ANDROID_BUILD_TOP=os.environ["ANDROID_BUILD_TOP"]
-    ANDROID_HOST_OUT=os.environ["ANDROID_HOST_OUT"]
-    if ANDROID_HOST_OUT[0:len(ANDROID_BUILD_TOP)+1] == f"{ANDROID_BUILD_TOP}/":
-      bpath_location_prefix=ANDROID_HOST_OUT[len(ANDROID_BUILD_TOP)+1:]
-    else:
-      print(f"ANDROID_BUILD_TOP/ is not a prefix of ANDROID_HOST_OUT"\
-            "\nANDROID_BUILD_TOP={ANDROID_BUILD_TOP}"\
-            "\nANDROID_HOST_OUT={ANDROID_HOST_OUT}")
-      sys.exit(1)
-
-  return get_apex_bootclasspath_impl(bpath_location_prefix)
diff --git a/test/run-test b/test/run-test
index 8980c2e..db0885e 100755
--- a/test/run-test
+++ b/test/run-test
@@ -16,7 +16,7 @@
 
 import os, sys, glob, re, shutil, subprocess, shlex, resource
 
-import etc.default_run
+import default_run as default_run_module
 
 from importlib.machinery import SourceFileLoader
 from inspect import currentframe, getframeinfo, FrameInfo
@@ -58,7 +58,7 @@
 
   # Execute the default runner (possibly with modified arguments).
   def default_run(self, args, **kwargs):
-    etc.default_run.default_run(self, args, **kwargs)
+    default_run_module.default_run(self, args, **kwargs)
 
 
 # TODO: Replace with 'def main():' (which might change variables from globals to locals)
@@ -939,7 +939,7 @@
 
   # Execute the "run" method in the per-test specific script file.
   def run_test_script():
-    parsed_args = etc.default_run.parse_args(shlex.split(" ".join(run_args + args)))
+    parsed_args = default_run_module.parse_args(shlex.split(" ".join(run_args + args)))
     parsed_args.stdout_file = os.path.join(tmp_dir, test_stdout)
     parsed_args.stderr_file = os.path.join(tmp_dir, test_stderr)
 
@@ -948,7 +948,7 @@
       module = SourceFileLoader("run_" + TEST_NAME, script).load_module()
       module.run(ctx, parsed_args)
     else:
-      etc.default_run.default_run(ctx, parsed_args)
+      default_run_module.default_run(ctx, parsed_args)
 
   # Test might not execute anything but we still expect the output files to exist.
   Path(test_stdout).touch()