Add build support in Soong for some run-tests exercising VarHandles.
Add build support for ART run-tests tests in Soong, which have custom
build scripts enabling support for Java variable handles. Ignore these
build script, as they are just used to enable build support for Java
variable handles, which are supported by default in Soong.
Note: We may later reconsider using different API levels when building
ART run-tests with Soong for use with TradeFed (as does the
`art/test/etc/default-build` script).
Test: m \
art-run-test-160-read-barrier-stress \
art-run-test-1981-structural-redef-private-method-handles \
art-run-test-1983-structural-redefinition-failures \
art-run-test-713-varhandle-invokers
Bug: 147814778
Change-Id: I39a033370c28b446b3a97bf553fd2a5c719c3173
diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files
index b017faa5..d9d54e2 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -446,18 +446,53 @@
for run_test in os.listdir(self.art_test_dir)
if re.match("^[0-9]{3,}-", run_test)])
+ # Read build file (Bash script) and return a canonized version of it
+ # (without comments, blank lines, "debugging" statements, etc.).
+ def canonize_build_script(self, build_file):
+
+ def is_comment(line):
+ return re.match("^\\s*#", line)
+
+ def is_blank(line):
+ return re.match("^\\s*$", line)
+
+ # Is `line` a `set -e` statement?
+ def is_set_e(line):
+ return re.match("^\\s*set -e\\s*", line)
+
+ # Should `line` be kept in the canonized build script?
+ def keep_line(line):
+ return not (is_comment(line) or is_blank(line) or is_set_e(line))
+
+ with open(build_file, "r") as f:
+ lines = f.readlines()
+ return list(filter(keep_line, lines))
+
+ # Can the build script in `build_file` be safely ignored?
+ def can_ignore_build_script(self, build_file):
+ build_script = self.canonize_build_script(build_file)
+ if len(build_script) == 1:
+ if build_script[0] == "./default-build \"$@\" --experimental var-handles\n":
+ # Soong builds JARs with VarHandle support by default (i.e. by
+ # using an API level greater or equal to 28), so we can ignore
+ # build scripts that just request support for this feature.
+ return True
+ return False
+
# Is building `run_test` supported?
# TODO(b/147814778): Add build support for more tests.
def is_buildable(self, run_test):
run_test_path = os.path.join(self.art_test_dir, run_test)
- # Ignore tests with non-default build rules.
+ # Skip tests with non-default build rules, unless these build
+ # rules can be safely ignored.
if os.path.isfile(os.path.join(run_test_path, "build")):
- return False
- # Ignore tests with no `src` directory.
+ if not self.can_ignore_build_script(os.path.join(run_test_path, "build")):
+ return False
+ # Skip tests with no `src` directory.
if not os.path.isdir(os.path.join(run_test_path, "src")):
return False
- # Ignore tests with sources outside the `src` directory.
+ # Skip tests with sources outside the `src` directory.
for subdir in ["jasmin",
"jasmin-multidex",
"smali",
@@ -471,10 +506,10 @@
"src2"]:
if os.path.isdir(os.path.join(run_test_path, subdir)):
return False
- # Ignore test with a copy of `sun.misc.Unsafe`.
+ # Skip test with a copy of `sun.misc.Unsafe`.
if os.path.isfile(os.path.join(run_test_path, "src", "sun", "misc", "Unsafe.java")):
return False
- # Ignore tests with Hidden API specs.
+ # Skip tests with Hidden API specs.
if os.path.isfile(os.path.join(run_test_path, "hiddenapi-flags.csv")):
return False
# All other tests are considered buildable.