diff options
129 files changed, 1281 insertions, 1226 deletions
diff --git a/test/000-nop/build b/test/000-nop/build deleted file mode 100644 index 5233a2d716..0000000000 --- a/test/000-nop/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -# Nothing to do here. diff --git a/test/066-mismatched-super/build b/test/000-nop/build.py index 50aceb4f21..846e9a6862 100644 --- a/test/066-mismatched-super/build +++ b/test/000-nop/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -USE_DESUGAR=false ./default-build "$@" +# Nothing to do here. diff --git a/test/003-omnibus-opcodes/build b/test/003-omnibus-opcodes/build deleted file mode 100644 index a14ddc94f2..0000000000 --- a/test/003-omnibus-opcodes/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2008 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/004-JniTest/build b/test/004-JniTest/build.py index 460f2db5f8..e31d770292 100755..100644 --- a/test/004-JniTest/build +++ b/test/004-JniTest/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2017 The Android Open Source Project +# 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. @@ -14,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from art_build_rules import build_run_test +import shutil, os + # # Perform a mostly normal build. # Since this test imports 'dalvik.annotation.optimization.FastNative' (and CriticalNative), @@ -25,12 +27,11 @@ # has a different ABI and cannot be tested on RI. # -# Stop on failure. -set -e - # Use release mode to check optimizations do not break JNI. -export D8_FLAGS=--release -./default-build "$@" +build_run_test(d8_flags=['--release']) # Remove the *-aotex build artifacts (but keep src-aotex) with dalvik.* annotations. -rm -rf classes-aotex classes-aotex.jar $TEST_NAME-aotex.jar +shutil.rmtree("classes-aotex") +if os.environ["BUILD_MODE"] != "jvm": + os.remove("classes-aotex.jar") + os.remove("004-JniTest-aotex.jar") diff --git a/test/004-StackWalk/build b/test/004-ReferenceMap/generate-sources index 6203c97769..9edc200083 100644..100755 --- a/test/004-StackWalk/build +++ b/test/004-ReferenceMap/generate-sources @@ -23,4 +23,3 @@ export D8=':' ###################################################################### ${SOONG_ZIP} --jar -o classes.jar -f classes.dex -./default-build "$@" diff --git a/test/004-ReferenceMap/build b/test/004-StackWalk/generate-sources index 6203c97769..9edc200083 100644..100755 --- a/test/004-ReferenceMap/build +++ b/test/004-StackWalk/generate-sources @@ -23,4 +23,3 @@ export D8=':' ###################################################################### ${SOONG_ZIP} --jar -o classes.jar -f classes.dex -./default-build "$@" diff --git a/test/005-annotations/build b/test/005-annotations/build.py index bdc1950523..8cf988c7ca 100644 --- a/test/005-annotations/build +++ b/test/005-annotations/build.py @@ -1,12 +1,11 @@ -#!/bin/bash # -# Copyright (C) 2012 The Android Open Source Project +# 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 +# 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, @@ -14,9 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Stop if something fails. -set -e +from art_build_rules import build_run_test # Build intermediate object to preserve class-retention annotations. -export D8_FLAGS=--intermediate -./default-build "$@" +build_run_test(d8_flags=['--intermediate']) diff --git a/test/023-many-interfaces/build b/test/023-many-interfaces/generate-sources index 6d1c8e36ce..f9ba1b84b6 100644..100755 --- a/test/023-many-interfaces/build +++ b/test/023-many-interfaces/generate-sources @@ -19,5 +19,3 @@ set -e # Write out a bunch of interface source files. ./iface-gen - -./default-build "$@" diff --git a/test/056-const-string-jumbo/build b/test/056-const-string-jumbo/generate-sources index c1d711b436..5c7ade8aac 100644..100755 --- a/test/056-const-string-jumbo/build +++ b/test/056-const-string-jumbo/generate-sources @@ -38,5 +38,3 @@ function writeFile(name, start, end) { } printf("}\n") > fileName; }' - -./default-build "$@" diff --git a/test/065-mismatched-implements/build b/test/065-mismatched-implements/build.py index 41823b5025..4284d83cb1 100755..100644 --- a/test/065-mismatched-implements/build +++ b/test/065-mismatched-implements/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2017 The Android Open Source Project +# 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. @@ -13,15 +12,12 @@ # 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. -# Make us exit on a failure. -set -e +from art_build_rules import build_run_test # Don't use desugar because the build fails when it encounters ICCE. # # Exception in thread "main" java.lang.IllegalArgumentException # at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108) # at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:295) -export USE_DESUGAR=false - -./default-build "$@" +build_run_test(use_desugar=False) diff --git a/test/066-mismatched-super/build.py b/test/066-mismatched-super/build.py new file mode 100644 index 0000000000..337bd29ebb --- /dev/null +++ b/test/066-mismatched-super/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_desugar=False) diff --git a/test/071-dexfile-get-static-size/build b/test/071-dexfile-get-static-size/generate-sources index 4ce24cfc15..4ce24cfc15 100755 --- a/test/071-dexfile-get-static-size/build +++ b/test/071-dexfile-get-static-size/generate-sources diff --git a/test/071-dexfile-map-clean/build b/test/071-dexfile-map-clean/build.py index a171fc3b3b..f8c3efd6e2 100755..100644 --- a/test/071-dexfile-map-clean/build +++ b/test/071-dexfile-map-clean/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2017 The Android Open Source Project +# 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. @@ -14,8 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +from art_build_rules import build_run_test + # Any JAR files used by this test shall have their classes.dex be stored, NOT compressed. # This is needed for our test correctness which validates classes.dex are mapped file-backed. # # In addition, align to at least 4 bytes since that's the dex alignment requirement. -./default-build "$@" --zip-compression-method store --zip-align 4 +build_run_test(zip_compression_method="store", zip_align_bytes="4") diff --git a/test/089-many-methods/build.py b/test/089-many-methods/build.py new file mode 100644 index 0000000000..052ae727a5 --- /dev/null +++ b/test/089-many-methods/build.py @@ -0,0 +1,26 @@ +# +# 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. + +from art_build_rules import build_run_test + +# Specify old API level as d8 automagically produces a multidex file +# when the API level is above 20. Failing the build here is deliberate. +# Force DEX generation so test also passes with --jvm. +try: + build_run_test(api_level=20, need_dex=True) + assert False, "Test was not expected to build successfully" +except Exception as e: + # Check that a build failure happened (the test is not expected to run). + assert "Cannot fit requested classes in a single dex" in str(e), e diff --git a/test/089-many-methods/build b/test/089-many-methods/generate-sources index 5225e3ffc7..f38a025a93 100644..100755 --- a/test/089-many-methods/build +++ b/test/089-many-methods/generate-sources @@ -42,15 +42,3 @@ function writeFileMethod(name) { } printf("}\n") > fileName; }' - -# Force DEX generation so test also passes with --jvm. -export NEED_DEX=true - -# Specify old API level as d8 automagically produces a multidex file -# when the API level is above 20. Failing the build here is deliberate. -./default-build --api-level 20 "$@" > /dev/null 2> stderr.txt || true - -# Check that a build failure happened (the test is not expected to run). -EXPECTED_ERROR="Cannot fit requested classes in a single dex" -grep -q "$EXPECTED_ERROR" stderr.txt -rm stderr.txt # Check passed. Remove output due to non-deterministic paths. diff --git a/test/091-override-package-private-method/build b/test/091-override-package-private-method/build deleted file mode 100755 index 6b298f7e8d..0000000000 --- a/test/091-override-package-private-method/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2015 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/1001-app-image-regions/build b/test/1001-app-image-regions/generate-sources index 16c3a5b566..0fbe23ffd8 100755 --- a/test/1001-app-image-regions/build +++ b/test/1001-app-image-regions/generate-sources @@ -30,5 +30,3 @@ for i in $(seq 1 "$count"); do echo " static class Inner${i} { void test(){} }" >> "${other_file}" done echo "}" >> "${other_file}" - -./default-build "$@" diff --git a/test/1003-metadata-section-strings/build b/test/1003-metadata-section-strings/generate-sources index cd2cacd834..c3e73f5941 100755 --- a/test/1003-metadata-section-strings/build +++ b/test/1003-metadata-section-strings/generate-sources @@ -37,5 +37,3 @@ return "not found"; } } EOF - -./default-build "$@" diff --git a/test/111-unresolvable-exception/build b/test/111-unresolvable-exception/build deleted file mode 100644 index f378df1d46..0000000000 --- a/test/111-unresolvable-exception/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2014 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/124-missing-classes/build b/test/124-missing-classes/build deleted file mode 100644 index a40cbc9b96..0000000000 --- a/test/124-missing-classes/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2012 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/126-miranda-multidex/build b/test/126-miranda-multidex/generate-sources index c827e550ef..b35d5ef1c1 100644..100755 --- a/test/126-miranda-multidex/build +++ b/test/126-miranda-multidex/generate-sources @@ -19,4 +19,3 @@ set -e # Signal to default-build that this is a multidex test. mkdir src-multidex -./default-build "$@" diff --git a/test/127-checker-secondarydex/build b/test/127-checker-secondarydex/build deleted file mode 100755 index f378df1d46..0000000000 --- a/test/127-checker-secondarydex/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2014 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/138-duplicate-classes-check2/build b/test/138-duplicate-classes-check2/build deleted file mode 100755 index 6b298f7e8d..0000000000 --- a/test/138-duplicate-classes-check2/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2015 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/807-method-handle-and-mr/build b/test/160-read-barrier-stress/build.py index 12a8e18d0b..d6b35b10dc 100755..100644 --- a/test/807-method-handle-and-mr/build +++ b/test/160-read-barrier-stress/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2017 The Android Open Source Project +# 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. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Exit on failure. -set -e +from art_build_rules import build_run_test -./default-build "$@" --experimental method-handles +build_run_test(experimental="var-handles") diff --git a/test/161-final-abstract-class/build b/test/161-final-abstract-class/generate-sources index 12f27d1370..12f27d1370 100644..100755 --- a/test/161-final-abstract-class/build +++ b/test/161-final-abstract-class/generate-sources diff --git a/test/166-bad-interface-super/build b/test/166-bad-interface-super/build.py index bba6184e16..f74f0e9b9a 100644 --- a/test/166-bad-interface-super/build +++ b/test/166-bad-interface-super/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,14 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Use the jasmin sources for JVM, otherwise the smali sources. -extra_arg="--no-jasmin" - -for arg in "$@"; do - if [[ "$arg" == "--jvm" ]]; then - extra_arg="--no-smali" - break - fi -done +from art_build_rules import build_run_test +import os -./default-build "$@" "$extra_arg" +# Use the jasmin sources for JVM, otherwise the smali sources. +if os.environ["BUILD_MODE"] == "jvm": + build_run_test(has_smali=False) +else: + build_run_test(has_jasmin=False) diff --git a/test/180-native-default-method/build b/test/180-native-default-method/build.py index b6b604f8ed..122bcc0573 100644 --- a/test/180-native-default-method/build +++ b/test/180-native-default-method/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2020 The Android Open Source Project +# 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. @@ -14,20 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# make us exit on a failure -set -e +from art_build_rules import build_run_test +import subprocess, os -./default-build "$@" +build_run_test() -if [[ $@ != *"--jvm"* ]]; then +if os.environ["BUILD_MODE"] != "jvm": # Change the generated dex file to have a v35 magic number if it is version 38 - if test -f classes.dex && head -c 7 classes.dex | grep -q 038; then - # place ascii value '035' into the classes.dex file starting at byte 4. - printf '035' | dd status=none conv=notrunc of=classes.dex bs=1 seek=4 count=3 - rm -f $TEST_NAME.jar - ${SOONG_ZIP} -o $TEST_NAME.jar -f classes.dex - else - echo Unexpected dex verison - exit 1 - fi -fi + with open("classes.dex", "rb+") as f: + assert f.read(8) == b'dex\n038\x00' + f.seek(0) + f.write(b'dex\n035\x00') + os.remove("180-native-default-method.jar") + subprocess.run([os.environ["SOONG_ZIP"], "-o", + "180-native-default-method.jar", "-f", "classes.dex"], check=True) diff --git a/test/1983-structural-redefinition-failures/build b/test/181-default-methods/build.py index c80d7adf73..48cb485759 100755..100644 --- a/test/1983-structural-redefinition-failures/build +++ b/test/181-default-methods/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2019 The Android Open Source Project +# 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. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Make us exit on a failure -set -e +from art_build_rules import build_run_test -./default-build "$@" --experimental var-handles +build_run_test(experimental="default-methods") diff --git a/test/616-cha-interface-default/build b/test/1948-obsolete-const-method-handle/build.py index d9654f8d38..193aa910c6 100644 --- a/test/616-cha-interface-default/build +++ b/test/1948-obsolete-const-method-handle/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2017 The Android Open Source Project +# 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. @@ -14,4 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -./default-build "$@" --experimental default-methods +from art_build_rules import build_run_test + +build_run_test(api_level=28) diff --git a/test/1948-obsolete-const-method-handle/build b/test/1948-obsolete-const-method-handle/generate-sources index d0e7a8c0d8..9cdc7496c4 100644..100755 --- a/test/1948-obsolete-const-method-handle/build +++ b/test/1948-obsolete-const-method-handle/generate-sources @@ -19,5 +19,3 @@ set -e mkdir classes ./util-src/build-classes $PWD/classes - -./default-build --api-level 28 "$@" diff --git a/test/1965-get-set-local-primitive-no-tables/build b/test/1965-get-set-local-primitive-no-tables/generate-sources index 6631df91b7..c2f8653ef6 100644..100755 --- a/test/1965-get-set-local-primitive-no-tables/build +++ b/test/1965-get-set-local-primitive-no-tables/generate-sources @@ -22,4 +22,3 @@ if [[ $@ != *"--jvm"* ]]; then else mv smali smali-unused fi -./default-build "$@" diff --git a/test/1966-get-set-local-objects-no-table/build b/test/1966-get-set-local-objects-no-table/generate-sources index 6631df91b7..c2f8653ef6 100644..100755 --- a/test/1966-get-set-local-objects-no-table/build +++ b/test/1966-get-set-local-objects-no-table/generate-sources @@ -22,4 +22,3 @@ if [[ $@ != *"--jvm"* ]]; then else mv smali smali-unused fi -./default-build "$@" diff --git a/test/1981-structural-redef-private-method-handles/build.py b/test/1981-structural-redef-private-method-handles/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/1981-structural-redef-private-method-handles/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/1983-structural-redefinition-failures/build.py b/test/1983-structural-redefinition-failures/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/1983-structural-redefinition-failures/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/2000-virtual-list-structural/build.py b/test/2000-virtual-list-structural/build.py new file mode 100644 index 0000000000..0d8dc0c068 --- /dev/null +++ b/test/2000-virtual-list-structural/build.py @@ -0,0 +1,23 @@ +# +# 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. + +from art_build_rules import build_run_test +import os + +build_run_test(use_desugar=False) + +os.rename("src-ex/java/util/AbstractCollection.bak", + "src-ex/java/util/AbstractCollection.java") + diff --git a/test/2000-virtual-list-structural/build b/test/2000-virtual-list-structural/generate-sources index f8496bec3e..5e21f12bac 100755 --- a/test/2000-virtual-list-structural/build +++ b/test/2000-virtual-list-structural/generate-sources @@ -23,9 +23,3 @@ cp src-ex/java/util/AbstractCollection.bak src-ex/java/util/AbstractCollection.j # Patch the copied version. patch src-ex/java/util/AbstractCollection.java AbstractCollection.patch - -USE_DESUGAR=false ./default-build "$@" - -# restore the symlink -rm src-ex/java/util/AbstractCollection.java -mv src-ex/java/util/AbstractCollection.bak src-ex/java/util/AbstractCollection.java diff --git a/test/2034-spaces-in-SimpleName/build.py b/test/2034-spaces-in-SimpleName/build.py new file mode 100644 index 0000000000..7601e120ef --- /dev/null +++ b/test/2034-spaces-in-SimpleName/build.py @@ -0,0 +1,19 @@ +# +# 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. + +from art_build_rules import build_run_test + +# Use API level 10000 for spaces in SimpleName +build_run_test(use_desugar=False, api_level="10000") diff --git a/test/2034-spaces-in-SimpleName/build b/test/2034-spaces-in-SimpleName/generate-sources index 8261ed2307..99fc7e06c7 100755 --- a/test/2034-spaces-in-SimpleName/build +++ b/test/2034-spaces-in-SimpleName/generate-sources @@ -24,6 +24,3 @@ cd src_gen ${JAVA:-java} -cp "$ASM_JAR:." SpacesInSimpleName.java mkdir ../classes && mv Main.class ../classes/Main.class cd .. - -# Use API level 10000 for spaces in SimpleName -USE_DESUGAR=false ./default-build "$@" --api-level 10000 diff --git a/test/2038-hiddenapi-jvmti-ext/build.py b/test/2038-hiddenapi-jvmti-ext/build.py new file mode 100644 index 0000000000..8367ad04bd --- /dev/null +++ b/test/2038-hiddenapi-jvmti-ext/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_hiddenapi=True) diff --git a/test/2239-varhandle-perf/build.py b/test/2239-varhandle-perf/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/2239-varhandle-perf/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/2239-varhandle-perf/build b/test/2239-varhandle-perf/generate-sources index 115a0fba49..310ad06f46 100755 --- a/test/2239-varhandle-perf/build +++ b/test/2239-varhandle-perf/generate-sources @@ -28,5 +28,3 @@ mkdir -p src2 # Generate tests and Main that covers both the generated tests and manual tests python3 ./util-src/generate_java.py "${GENERATED_SRC}" - -./default-build "$@" --experimental var-handles diff --git a/test/303-verification-stress/build b/test/303-verification-stress/generate-sources index 6e4a1d61c5..2a2cdb622e 100644..100755 --- a/test/303-verification-stress/build +++ b/test/303-verification-stress/generate-sources @@ -19,5 +19,3 @@ set -e # Write out a bunch of source files. ./classes-gen - -./default-build "$@" diff --git a/test/370-dex-v37/build b/test/370-dex-v37/build.py index f472428e27..5ae5a034ff 100755..100644 --- a/test/370-dex-v37/build +++ b/test/370-dex-v37/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2015 The Android Open Source Project +# 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. @@ -14,17 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# make us exit on a failure -set -e +from art_build_rules import build_run_test +import subprocess, os -./default-build "$@" +build_run_test() -if [[ $@ != *"--jvm"* ]]; then - # Change the generated dex file to have a v36 magic number if it is version 35 - if test -f classes.dex && head -c 7 classes.dex | grep -q 035; then - # place ascii value '037' into the classes.dex file starting at byte 4. - printf '037' | dd status=none conv=notrunc of=classes.dex bs=1 seek=4 count=3 - rm -f $TEST_NAME.jar - zip $TEST_NAME.jar classes.dex - fi -fi +if os.environ["BUILD_MODE"] != "jvm": + # Change the generated dex file to have a v37 magic number if it is version 35 + with open("classes.dex", "rb+") as f: + if f.read(8) == b'dex\n035\x00': + f.seek(0) + f.write(b'dex\n037\x00') + os.remove("370-dex-v37.jar") + subprocess.run([os.environ["SOONG_ZIP"], "-o", + "370-dex-v37.jar", "-f", "classes.dex"], check=True) diff --git a/test/1981-structural-redef-private-method-handles/build b/test/616-cha-interface-default/build.py index c80d7adf73..48cb485759 100755..100644 --- a/test/1981-structural-redef-private-method-handles/build +++ b/test/616-cha-interface-default/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2019 The Android Open Source Project +# 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. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Make us exit on a failure -set -e +from art_build_rules import build_run_test -./default-build "$@" --experimental var-handles +build_run_test(experimental="default-methods") diff --git a/test/638-no-line-number/build b/test/638-no-line-number/build.py index 9cd19554bc..bc8b68122e 100644 --- a/test/638-no-line-number/build +++ b/test/638-no-line-number/build.py @@ -1,12 +1,11 @@ -#!/bin/bash # -# Copyright (C) 2017 The Android Open Source Project +# 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 +# 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, @@ -14,9 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Stop if something fails. -set -e +from art_build_rules import build_run_test # Only keep the source name, to make sure we do remove it in the stack trace # when there is no line number mapping. -JAVAC_ARGS="$JAVAC_ARGS -g:source" ./default-build "$@" +build_run_test(javac_args=["-g:source"]) diff --git a/test/648-many-direct-methods/build b/test/648-many-direct-methods/generate-sources index 7e888e5bca..8907645982 100755 --- a/test/648-many-direct-methods/build +++ b/test/648-many-direct-methods/generate-sources @@ -21,5 +21,3 @@ mkdir -p ./src # Generate the Java file or fail. ./util-src/generate_java.py ./src - -./default-build "$@" diff --git a/test/663-odd-dex-size2/build b/test/663-odd-dex-size2/build deleted file mode 100644 index 5636558dad..0000000000 --- a/test/663-odd-dex-size2/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Nothing to do diff --git a/test/691-hiddenapi-proxy/build b/test/663-odd-dex-size2/build.py index c364b3b057..76845c9583 100644 --- a/test/691-hiddenapi-proxy/build +++ b/test/663-odd-dex-size2/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2019 The Android Open Source Project +# 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. @@ -14,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -USE_HIDDENAPI=true ./default-build "$@" +# Nothing to do. diff --git a/test/663-odd-dex-size3/build b/test/663-odd-dex-size3/build deleted file mode 100644 index 5636558dad..0000000000 --- a/test/663-odd-dex-size3/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Nothing to do diff --git a/test/2038-hiddenapi-jvmti-ext/build b/test/663-odd-dex-size3/build.py index f4b029fb82..c4fc9eed1f 100644 --- a/test/2038-hiddenapi-jvmti-ext/build +++ b/test/663-odd-dex-size3/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -USE_HIDDENAPI=true ./default-build "$@" +# Nothing to do diff --git a/test/663-odd-dex-size4/build b/test/663-odd-dex-size4/build deleted file mode 100644 index 5636558dad..0000000000 --- a/test/663-odd-dex-size4/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Nothing to do diff --git a/test/690-hiddenapi-same-name-methods/build b/test/663-odd-dex-size4/build.py index c364b3b057..c4fc9eed1f 100644 --- a/test/690-hiddenapi-same-name-methods/build +++ b/test/663-odd-dex-size4/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2019 The Android Open Source Project +# 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. @@ -14,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -USE_HIDDENAPI=true ./default-build "$@" +# Nothing to do diff --git a/test/670-bitstring-type-check/build b/test/670-bitstring-type-check/generate-sources index 38307f2c0f..4d888399a5 100644..100755 --- a/test/670-bitstring-type-check/build +++ b/test/670-bitstring-type-check/generate-sources @@ -212,5 +212,3 @@ class Helper { } } EOF - -./default-build "$@" diff --git a/test/817-hiddenapi/build b/test/674-hiddenapi/build.py index 330a6def29..f518d51aee 100644 --- a/test/817-hiddenapi/build +++ b/test/674-hiddenapi/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -e +from art_build_rules import build_run_test, rm +import os # Build the jars twice. First with applying hiddenapi, creating a boot jar, then # a second time without to create a normal jar. We need to do this because we @@ -23,16 +23,14 @@ set -e # hidden API access flags in dex files. DexFileVerifier is not invoked on boot # class path dex files, so the boot jar loads fine in the latter case. -export USE_HIDDENAPI=true -./default-build "$@" +build_run_test(use_hiddenapi=True) # Move the jar file into the resource folder to be bundled with the test. -mkdir res -mv ${TEST_NAME}.jar res/boot.jar +os.mkdir("res") +os.rename("674-hiddenapi.jar", "res/boot.jar") # Clear all intermediate files otherwise default-build would either skip # compilation or fail rebuilding. -rm -rf classes* +rm("classes*") -export USE_HIDDENAPI=false -./default-build "$@" +build_run_test(use_hiddenapi=False) diff --git a/test/674-vdex-uncompress/build b/test/674-vdex-uncompress/build.py index 7b1804d3e0..a694a9d8e2 100755..100644 --- a/test/674-vdex-uncompress/build +++ b/test/674-vdex-uncompress/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from art_build_rules import build_run_test + # Uncompress and align the dex files so that dex2oat will not copy the dex # code to the .vdex file. -./default-build "$@" --zip-compression-method store --zip-align 4 +build_run_test(zip_compression_method="store", zip_align_bytes="4") diff --git a/test/677-fsi/build b/test/677-fsi/build deleted file mode 100755 index b90b408d9c..0000000000 --- a/test/677-fsi/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2018 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. - -./default-build "$@" --zip-compression-method store --zip-align 4 diff --git a/test/677-fsi/build.py b/test/677-fsi/build.py new file mode 100644 index 0000000000..d16a9962a9 --- /dev/null +++ b/test/677-fsi/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(zip_compression_method="store", zip_align_bytes=4) diff --git a/test/690-hiddenapi-same-name-methods/build.py b/test/690-hiddenapi-same-name-methods/build.py new file mode 100644 index 0000000000..8367ad04bd --- /dev/null +++ b/test/690-hiddenapi-same-name-methods/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_hiddenapi=True) diff --git a/test/691-hiddenapi-proxy/build.py b/test/691-hiddenapi-proxy/build.py new file mode 100644 index 0000000000..8367ad04bd --- /dev/null +++ b/test/691-hiddenapi-proxy/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_hiddenapi=True) diff --git a/test/701-easy-div-rem/build b/test/701-easy-div-rem/generate-sources index 6d114b64e6..efe4b05c23 100644..100755 --- a/test/701-easy-div-rem/build +++ b/test/701-easy-div-rem/generate-sources @@ -20,5 +20,3 @@ set -e # Write out the source file. mkdir src python3 ./genMain.py - -./default-build "$@" diff --git a/test/702-LargeBranchOffset/build b/test/702-LargeBranchOffset/generate-sources index 2505b0a36c..b01afc4492 100644..100755 --- a/test/702-LargeBranchOffset/build +++ b/test/702-LargeBranchOffset/generate-sources @@ -20,5 +20,3 @@ set -e # Write out the source file. mkdir -p src ./generate - -./default-build "$@" diff --git a/test/710-varhandle-creation/build b/test/710-varhandle-creation/build deleted file mode 100644 index ca1e557129..0000000000 --- a/test/710-varhandle-creation/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Stop if something fails. -set -e - -./default-build "$@" --experimental var-handles diff --git a/test/710-varhandle-creation/build.py b/test/710-varhandle-creation/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/710-varhandle-creation/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/712-varhandle-invocations/build.py b/test/712-varhandle-invocations/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/712-varhandle-invocations/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/712-varhandle-invocations/build b/test/712-varhandle-invocations/generate-sources index 9a6e96e18b..d025b269b6 100755 --- a/test/712-varhandle-invocations/build +++ b/test/712-varhandle-invocations/generate-sources @@ -31,5 +31,3 @@ MANUAL_TESTS=$(cd "${MANUAL_SRC}" && find . -name 'Var*Tests.java' | sed -e 's@. # Generate tests and Main that covers both the generated tests and manual tests python3 ./util-src/generate_java.py "${GENERATED_SRC}" ${MANUAL_TESTS} - -./default-build "$@" --experimental var-handles diff --git a/test/713-varhandle-invokers/build.py b/test/713-varhandle-invokers/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/713-varhandle-invokers/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/714-invoke-custom-lambda-metafactory/build b/test/714-invoke-custom-lambda-metafactory/build deleted file mode 100644 index b5002ba79c..0000000000 --- a/test/714-invoke-custom-lambda-metafactory/build +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# -# Copyright 2018 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. - -# Make us exit on a failure -set -e - -# Opt-out from desugaring to ensure offending lambda is in the DEX. -export USE_DESUGAR=false -./default-build "$@" --experimental method-handles diff --git a/test/714-invoke-custom-lambda-metafactory/build.py b/test/714-invoke-custom-lambda-metafactory/build.py new file mode 100644 index 0000000000..7563062c3f --- /dev/null +++ b/test/714-invoke-custom-lambda-metafactory/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_desugar=False, experimental="method-handles") diff --git a/test/715-clinit-implicit-parameter-annotations/build b/test/715-clinit-implicit-parameter-annotations/build deleted file mode 100644 index 2b5f92cc88..0000000000 --- a/test/715-clinit-implicit-parameter-annotations/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2018 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. - -# Make us exit on a failure -set -e - -./default-build "$@" --experimental parameter-annotations diff --git a/test/181-default-methods/build b/test/715-clinit-implicit-parameter-annotations/build.py index 9cd5738e70..19c759cbc0 100644 --- a/test/181-default-methods/build +++ b/test/715-clinit-implicit-parameter-annotations/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2022 The Android Open Source Project +# 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. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# make us exit on a failure -set -e +from art_build_rules import build_run_test -./default-build "$@" --experimental default-methods +build_run_test(experimental="parameter-annotations") diff --git a/test/716-jli-jit-samples/build.py b/test/716-jli-jit-samples/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/716-jli-jit-samples/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/719-varhandle-concurrency/build b/test/719-varhandle-concurrency/build deleted file mode 100755 index 98a99673b9..0000000000 --- a/test/719-varhandle-concurrency/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 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. - -# Make us exit on a failure -set -e - -./default-build "$@" --experimental var-handles diff --git a/test/719-varhandle-concurrency/build.py b/test/719-varhandle-concurrency/build.py new file mode 100644 index 0000000000..d6b35b10dc --- /dev/null +++ b/test/719-varhandle-concurrency/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="var-handles") diff --git a/test/804-class-extends-itself/build b/test/804-class-extends-itself/generate-sources index ec28799ff9..ec28799ff9 100644..100755 --- a/test/804-class-extends-itself/build +++ b/test/804-class-extends-itself/generate-sources diff --git a/test/807-method-handle-and-mr/build.py b/test/807-method-handle-and-mr/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/807-method-handle-and-mr/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/674-hiddenapi/build b/test/817-hiddenapi/build.py index 330a6def29..1de286ab26 100644 --- a/test/674-hiddenapi/build +++ b/test/817-hiddenapi/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -e +from art_build_rules import build_run_test, rm +import os # Build the jars twice. First with applying hiddenapi, creating a boot jar, then # a second time without to create a normal jar. We need to do this because we @@ -23,16 +23,14 @@ set -e # hidden API access flags in dex files. DexFileVerifier is not invoked on boot # class path dex files, so the boot jar loads fine in the latter case. -export USE_HIDDENAPI=true -./default-build "$@" +build_run_test(use_hiddenapi=True) # Move the jar file into the resource folder to be bundled with the test. -mkdir res -mv ${TEST_NAME}.jar res/boot.jar +os.mkdir("res") +os.rename("817-hiddenapi.jar", "res/boot.jar") # Clear all intermediate files otherwise default-build would either skip # compilation or fail rebuilding. -rm -rf classes* +rm("classes*") -export USE_HIDDENAPI=false -./default-build "$@" +build_run_test(use_hiddenapi=False) diff --git a/test/822-hiddenapi-future/build b/test/822-hiddenapi-future/build deleted file mode 100644 index 02ce5491cc..0000000000 --- a/test/822-hiddenapi-future/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2021 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. - -USE_HIDDENAPI=true ./default-build "$@" diff --git a/test/822-hiddenapi-future/build.py b/test/822-hiddenapi-future/build.py new file mode 100644 index 0000000000..8367ad04bd --- /dev/null +++ b/test/822-hiddenapi-future/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_hiddenapi=True) diff --git a/test/829-unresolved-enclosing/build b/test/829-unresolved-enclosing/build deleted file mode 100644 index f378df1d46..0000000000 --- a/test/829-unresolved-enclosing/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2014 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. - -# Stop if something fails. -set -e - -./default-build "$@" diff --git a/test/948-change-annotations/build b/test/948-change-annotations/build deleted file mode 100755 index 898e2e54a2..0000000000 --- a/test/948-change-annotations/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -./default-build "$@" --experimental agents diff --git a/test/948-change-annotations/build.py b/test/948-change-annotations/build.py new file mode 100644 index 0000000000..f0496d7120 --- /dev/null +++ b/test/948-change-annotations/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="agents") diff --git a/test/713-varhandle-invokers/build b/test/952-invoke-custom/build.py index 09d376bbac..ce6dd897ea 100755..100644 --- a/test/713-varhandle-invokers/build +++ b/test/952-invoke-custom/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Make us exit on a failure -set -e +from art_build_rules import build_run_test -./default-build "$@" --experimental var-handles +build_run_test(use_desugar=False, api_level=28) diff --git a/test/952-invoke-custom/build b/test/952-invoke-custom/generate-sources index e835517c62..4244f8ce8f 100755 --- a/test/952-invoke-custom/build +++ b/test/952-invoke-custom/generate-sources @@ -24,6 +24,3 @@ mkdir classes ${JAVAC:-javac} ${JAVAC_ARGS} -cp "${ASM_JAR}" -d classes $(find util-src -name '*.java') ${SOONG_ZIP} --jar -o transformer.jar -C classes -D classes rm -rf classes - -# Use API level 28 for invoke-custom bytecode support. -USE_DESUGAR=false ./default-build "$@" --api-level 28 diff --git a/test/952-invoke-custom/javac_wrapper.sh b/test/952-invoke-custom/javac_wrapper.sh index 86590308dd..c8e0716b5d 100755 --- a/test/952-invoke-custom/javac_wrapper.sh +++ b/test/952-invoke-custom/javac_wrapper.sh @@ -16,6 +16,8 @@ set -e # Stop on error - the caller script may not have this set. +export ASM_JAR="${ANDROID_BUILD_TOP}/prebuilts/misc/common/asm/asm-9.2.jar" + # Update arguments to add transformer and ASM to the compiler classpath. classpath="./transformer.jar:$ASM_JAR" args=(-cp $classpath) diff --git a/test/953-invoke-polymorphic-compiler/build b/test/953-invoke-polymorphic-compiler/build deleted file mode 100755 index 2b0b2c1274..0000000000 --- a/test/953-invoke-polymorphic-compiler/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/953-invoke-polymorphic-compiler/build.py b/test/953-invoke-polymorphic-compiler/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/953-invoke-polymorphic-compiler/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/954-invoke-polymorphic-verifier/build b/test/954-invoke-polymorphic-verifier/build deleted file mode 100755 index 2b0b2c1274..0000000000 --- a/test/954-invoke-polymorphic-verifier/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/954-invoke-polymorphic-verifier/build.py b/test/954-invoke-polymorphic-verifier/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/954-invoke-polymorphic-verifier/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/955-methodhandles-smali/build b/test/955-methodhandles-smali/build deleted file mode 100755 index 2b0b2c1274..0000000000 --- a/test/955-methodhandles-smali/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/955-methodhandles-smali/build.py b/test/955-methodhandles-smali/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/955-methodhandles-smali/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/956-methodhandles/build b/test/956-methodhandles/build deleted file mode 100755 index 2b0b2c1274..0000000000 --- a/test/956-methodhandles/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/956-methodhandles/build.py b/test/956-methodhandles/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/956-methodhandles/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/957-methodhandle-transforms/build b/test/957-methodhandle-transforms/build deleted file mode 100755 index 2b0b2c1274..0000000000 --- a/test/957-methodhandle-transforms/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/957-methodhandle-transforms/build.py b/test/957-methodhandle-transforms/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/957-methodhandle-transforms/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/958-methodhandle-stackframe/build b/test/958-methodhandle-stackframe/build deleted file mode 100755 index 2b0b2c1274..0000000000 --- a/test/958-methodhandle-stackframe/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/958-methodhandle-stackframe/build.py b/test/958-methodhandle-stackframe/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/958-methodhandle-stackframe/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/959-invoke-polymorphic-accessors/build b/test/959-invoke-polymorphic-accessors/build deleted file mode 100644 index 2b0b2c1274..0000000000 --- a/test/959-invoke-polymorphic-accessors/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental method-handles diff --git a/test/959-invoke-polymorphic-accessors/build.py b/test/959-invoke-polymorphic-accessors/build.py new file mode 100644 index 0000000000..e8e08ebd8b --- /dev/null +++ b/test/959-invoke-polymorphic-accessors/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="method-handles") diff --git a/test/716-jli-jit-samples/build b/test/960-default-smali/build.py index 730a8a14bb..48cb485759 100755..100644 --- a/test/716-jli-jit-samples/build +++ b/test/960-default-smali/build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2018 The Android Open Source Project +# 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. @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# make us exit on a failure -set -e +from art_build_rules import build_run_test -./default-build "$@" --experimental var-handles +build_run_test(experimental="default-methods") diff --git a/test/960-default-smali/build b/test/960-default-smali/generate-sources index 44d6bd2046..1fffc71486 100755 --- a/test/960-default-smali/build +++ b/test/960-default-smali/generate-sources @@ -19,5 +19,3 @@ set -e # Generate the Main.java file or fail ${ANDROID_BUILD_TOP}/art/test/utils/python/generate_java_main.py ./src - -./default-build "$@" --experimental default-methods diff --git a/test/961-default-iface-resolution-gen/build.py b/test/961-default-iface-resolution-gen/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/961-default-iface-resolution-gen/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/961-default-iface-resolution-gen/build b/test/961-default-iface-resolution-gen/generate-sources index b9b36d0f86..4d12e5fbf8 100755 --- a/test/961-default-iface-resolution-gen/build +++ b/test/961-default-iface-resolution-gen/generate-sources @@ -21,5 +21,3 @@ mkdir -p ./src # Generate the smali files and expected-stdout.txt or fail ./util-src/generate_java.py ./src ./expected-stdout.txt - -./default-build "$@" --experimental default-methods diff --git a/test/962-iface-static/build b/test/962-iface-static/build deleted file mode 100644 index 82f49312ef..0000000000 --- a/test/962-iface-static/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2017 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental default-methods diff --git a/test/962-iface-static/build.py b/test/962-iface-static/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/962-iface-static/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/964-default-iface-init-gen/build.py b/test/964-default-iface-init-gen/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/964-default-iface-init-gen/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/964-default-iface-init-gen/build b/test/964-default-iface-init-gen/generate-sources index b9b36d0f86..4d12e5fbf8 100755 --- a/test/964-default-iface-init-gen/build +++ b/test/964-default-iface-init-gen/generate-sources @@ -21,5 +21,3 @@ mkdir -p ./src # Generate the smali files and expected-stdout.txt or fail ./util-src/generate_java.py ./src ./expected-stdout.txt - -./default-build "$@" --experimental default-methods diff --git a/test/968-default-partial-compile-gen/build.py b/test/968-default-partial-compile-gen/build.py new file mode 100644 index 0000000000..e4416ec0bd --- /dev/null +++ b/test/968-default-partial-compile-gen/build.py @@ -0,0 +1,20 @@ +# +# 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. + +from art_build_rules import build_run_test +import os + +if os.environ["BUILD_MODE"] != "jvm": + build_run_test(experimental="default-methods") diff --git a/test/968-default-partial-compile-gen/build b/test/968-default-partial-compile-gen/generate-sources index 04532b0ffc..83aad655d7 100755 --- a/test/968-default-partial-compile-gen/build +++ b/test/968-default-partial-compile-gen/generate-sources @@ -31,6 +31,4 @@ else mkdir -p ./smali # Generate the smali files and expected-stdout.txt or fail ./util-src/generate_smali.py ./smali ./expected-stdout.txt - # Use the default build script - ./default-build "$@" --experimental default-methods fi diff --git a/test/969-iface-super/build.py b/test/969-iface-super/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/969-iface-super/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/969-iface-super/build b/test/969-iface-super/generate-sources index 44d6bd2046..1fffc71486 100755 --- a/test/969-iface-super/build +++ b/test/969-iface-super/generate-sources @@ -19,5 +19,3 @@ set -e # Generate the Main.java file or fail ${ANDROID_BUILD_TOP}/art/test/utils/python/generate_java_main.py ./src - -./default-build "$@" --experimental default-methods diff --git a/test/970-iface-super-resolution-gen/build.py b/test/970-iface-super-resolution-gen/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/970-iface-super-resolution-gen/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/970-iface-super-resolution-gen/build b/test/970-iface-super-resolution-gen/generate-sources index 6eecd71386..175497f730 100755 --- a/test/970-iface-super-resolution-gen/build +++ b/test/970-iface-super-resolution-gen/generate-sources @@ -29,5 +29,3 @@ else mkdir -p smali ./util-src/generate_smali.py ./smali ./expected-stdout.txt fi - -./default-build "$@" --experimental default-methods diff --git a/test/971-iface-super/build.py b/test/971-iface-super/build.py new file mode 100644 index 0000000000..e4416ec0bd --- /dev/null +++ b/test/971-iface-super/build.py @@ -0,0 +1,20 @@ +# +# 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. + +from art_build_rules import build_run_test +import os + +if os.environ["BUILD_MODE"] != "jvm": + build_run_test(experimental="default-methods") diff --git a/test/971-iface-super/build b/test/971-iface-super/generate-sources index 04532b0ffc..83aad655d7 100755 --- a/test/971-iface-super/build +++ b/test/971-iface-super/generate-sources @@ -31,6 +31,4 @@ else mkdir -p ./smali # Generate the smali files and expected-stdout.txt or fail ./util-src/generate_smali.py ./smali ./expected-stdout.txt - # Use the default build script - ./default-build "$@" --experimental default-methods fi diff --git a/test/975-iface-private/build b/test/975-iface-private/build deleted file mode 100755 index 14230c2e1d..0000000000 --- a/test/975-iface-private/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental default-methods diff --git a/test/975-iface-private/build.py b/test/975-iface-private/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/975-iface-private/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/978-virtual-interface/build b/test/978-virtual-interface/build deleted file mode 100755 index 14230c2e1d..0000000000 --- a/test/978-virtual-interface/build +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 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. - -# make us exit on a failure -set -e - -./default-build "$@" --experimental default-methods diff --git a/test/978-virtual-interface/build.py b/test/978-virtual-interface/build.py new file mode 100644 index 0000000000..48cb485759 --- /dev/null +++ b/test/978-virtual-interface/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(experimental="default-methods") diff --git a/test/979-const-method-handle/build.py b/test/979-const-method-handle/build.py new file mode 100644 index 0000000000..193aa910c6 --- /dev/null +++ b/test/979-const-method-handle/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(api_level=28) diff --git a/test/979-const-method-handle/build b/test/979-const-method-handle/generate-sources index fa6a0ea950..d102d73c38 100755 --- a/test/979-const-method-handle/build +++ b/test/979-const-method-handle/generate-sources @@ -24,6 +24,3 @@ mkdir classes ${JAVAC:-javac} ${JAVAC_ARGS} -cp "${ASM_JAR}" -d classes $(find util-src -name '*.java') ${SOONG_ZIP} --jar -o transformer.jar -C classes -D classes rm -rf classes - -# Use API level 28 for DEX file support constant method handles. -./default-build "$@" --api-level 28 diff --git a/test/979-const-method-handle/javac_wrapper.sh b/test/979-const-method-handle/javac_wrapper.sh index 77b6bc3a6f..3e2a0a3664 100755 --- a/test/979-const-method-handle/javac_wrapper.sh +++ b/test/979-const-method-handle/javac_wrapper.sh @@ -16,6 +16,8 @@ set -e +export ASM_JAR="${ANDROID_BUILD_TOP}/prebuilts/misc/common/asm/asm-9.2.jar" + # Add annotation src files to our compiler inputs. asrcs=util-src/annotations/*.java diff --git a/test/999-redefine-hiddenapi/build b/test/999-redefine-hiddenapi/build deleted file mode 100644 index f4b029fb82..0000000000 --- a/test/999-redefine-hiddenapi/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2018 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. - -USE_HIDDENAPI=true ./default-build "$@" diff --git a/test/999-redefine-hiddenapi/build.py b/test/999-redefine-hiddenapi/build.py new file mode 100644 index 0000000000..8367ad04bd --- /dev/null +++ b/test/999-redefine-hiddenapi/build.py @@ -0,0 +1,18 @@ +# +# 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. + +from art_build_rules import build_run_test + +build_run_test(use_hiddenapi=True) diff --git a/test/Android.bp b/test/Android.bp index 9907347f15..1e28ac0a74 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -1868,11 +1868,13 @@ genrule_defaults { "art_module_source_build_genrule_defaults", ], tool_files: [ + "art_build_rules.py", "run-test-build.py", "buildfailures.json", - "etc/default-build", - "etc/default-run", + "etc/default-build.py", "etc/default-check", + "etc/default-run", + "etc/run-test-jar", ":art-run-test-bootclasspath", ], tools: [ diff --git a/test/art_build_rules.py b/test/art_build_rules.py new file mode 100644 index 0000000000..4e4a95930c --- /dev/null +++ b/test/art_build_rules.py @@ -0,0 +1,403 @@ +# +# Copyright (C) 2021 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 is the default build script for run-tests. + +It can be overwrite by specific run-tests if needed. +It is used from soong build and not intended to be called directly. +""" + +import argparse +import functools +import glob +import os +from os import path +import shlex +import shutil +import subprocess +import tempfile +import zipfile +from shutil import rmtree +from os import remove + +def rm(*patterns): + for pattern in patterns: + for path in glob.glob(pattern): + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.remove(path) + +def build_run_test( + use_desugar=True, + use_hiddenapi=True, + need_dex=None, + experimental="no-experiment", + zip_compression_method="deflate", + zip_align_bytes=None, + api_level=None, + javac_args=[], + d8_flags=[], + smali_args=[], + has_smali=None, + has_jasmin=None, + ): + + def parse_bool(text): + return {"true": True, "false": False}[text.lower()] + + TEST_NAME = os.environ["TEST_NAME"] + ART_TEST_RUN_TEST_BOOTCLASSPATH = os.environ["ART_TEST_RUN_TEST_BOOTCLASSPATH"] + NEED_DEX = parse_bool(os.environ["NEED_DEX"]) if need_dex is None else need_dex + + # Set default values for directories. + HAS_SMALI = path.exists("smali") if has_smali is None else has_smali + HAS_JASMIN = path.exists("jasmin") if has_jasmin is None else has_jasmin + HAS_SRC = path.exists("src") + HAS_SRC_ART = path.exists("src-art") + HAS_SRC2 = path.exists("src2") + HAS_SRC_MULTIDEX = path.exists("src-multidex") + HAS_SMALI_MULTIDEX = path.exists("smali-multidex") + HAS_JASMIN_MULTIDEX = path.exists("jasmin-multidex") + HAS_SMALI_EX = path.exists("smali-ex") + HAS_SRC_EX = path.exists("src-ex") + HAS_SRC_EX2 = path.exists("src-ex2") + HAS_SRC_AOTEX = path.exists("src-aotex") + HAS_SRC_BCPEX = path.exists("src-bcpex") + HAS_HIDDENAPI_SPEC = path.exists("hiddenapi-flags.csv") + + JAVAC_ARGS = shlex.split(os.environ.get("JAVAC_ARGS", "")) + javac_args + SMALI_ARGS = shlex.split(os.environ.get("SMALI_ARGS", "")) + smali_args + D8_FLAGS = shlex.split(os.environ.get("D8_FLAGS", "")) + d8_flags + + BUILD_MODE = os.environ["BUILD_MODE"] + + # Setup experimental API level mappings in a bash associative array. + EXPERIMENTAL_API_LEVEL = {} + EXPERIMENTAL_API_LEVEL["no-experiment"] = "26" + EXPERIMENTAL_API_LEVEL["default-methods"] = "24" + EXPERIMENTAL_API_LEVEL["parameter-annotations"] = "25" + EXPERIMENTAL_API_LEVEL["agents"] = "26" + EXPERIMENTAL_API_LEVEL["method-handles"] = "26" + EXPERIMENTAL_API_LEVEL["var-handles"] = "28" + + if BUILD_MODE == "jvm": + # No desugaring on jvm because it supports the latest functionality. + use_desugar = False + # Do not attempt to build src-art directories on jvm, + # since it would fail without libcore. + HAS_SRC_ART = False + + # Set API level for smali and d8. + if not api_level: + api_level = EXPERIMENTAL_API_LEVEL[experimental] + + # Add API level arguments to smali and dx + SMALI_ARGS.extend(["--api", str(api_level)]) + D8_FLAGS.extend(["--min-api", str(api_level)]) + + + def run(executable, args): + cmd = shlex.split(executable) + args + if executable.endswith(".sh"): + cmd = ["/bin/bash"] + cmd + p = subprocess.run(cmd, + encoding=os.sys.stdout.encoding, + stderr=subprocess.STDOUT, + stdout=subprocess.PIPE) + if p.returncode != 0: + raise Exception("Command failed with exit code {}\n$ {}\n{}".format( + p.returncode, " ".join(cmd), p.stdout)) + + + # Helper functions to execute tools. + soong_zip = functools.partial(run, os.environ["SOONG_ZIP"]) + zipalign = functools.partial(run, os.environ["ZIPALIGN"]) + javac = functools.partial(run, os.environ["JAVAC"]) + jasmin = functools.partial(run, os.environ["JASMIN"]) + smali = functools.partial(run, os.environ["SMALI"]) + d8 = functools.partial(run, os.environ["D8"]) + hiddenapi = functools.partial(run, os.environ["HIDDENAPI"]) + + # If wrapper script exists, use it instead of the default javac. + if os.path.exists("javac_wrapper.sh"): + javac = functools.partial(run, "javac_wrapper.sh") + + def find(root, name): + return sorted(glob.glob(path.join(root, "**", name), recursive=True)) + + + def zip(zip_target, *files): + zip_args = ["-o", zip_target] + if zip_compression_method == "store": + zip_args.extend(["-L", "0"]) + for f in files: + zip_args.extend(["-f", f]) + soong_zip(zip_args) + + if zip_align_bytes: + # zipalign does not operate in-place, so write results to a temp file. + with tempfile.TemporaryDirectory(dir=".") as tmp_dir: + tmp_file = path.join(tmp_dir, "aligned.zip") + zipalign(["-f", str(zip_align_bytes), zip_target, tmp_file]) + # replace original zip target with our temp file. + os.rename(tmp_file, zip_target) + + + def make_jasmin(out_directory, jasmin_sources): + os.makedirs(out_directory, exist_ok=True) + jasmin(["-d", out_directory] + sorted(jasmin_sources)) + + + # Like regular javac but may include libcore on the bootclasspath. + def javac_with_bootclasspath(args): + flags = JAVAC_ARGS + ["-encoding", "utf8"] + if BUILD_MODE != "jvm": + flags.extend(["-bootclasspath", ART_TEST_RUN_TEST_BOOTCLASSPATH]) + javac(flags + args) + + + # Make a "dex" file given a directory of classes. This will be + # packaged in a jar file. + def make_dex(name): + d8_inputs = find(name, "*.class") + d8_output = name + ".jar" + dex_output = name + ".dex" + if use_desugar: + flags = ["--lib", ART_TEST_RUN_TEST_BOOTCLASSPATH] + else: + flags = ["--no-desugaring"] + assert d8_inputs + d8(D8_FLAGS + flags + ["--output", d8_output] + d8_inputs) + + # D8 outputs to JAR files today rather than DEX files as DX used + # to. To compensate, we extract the DEX from d8's output to meet the + # expectations of make_dex callers. + with tempfile.TemporaryDirectory(dir=".") as tmp_dir: + zipfile.ZipFile(d8_output, "r").extractall(tmp_dir) + os.rename(path.join(tmp_dir, "classes.dex"), dex_output) + + + # Merge all the dex files. + # Skip non-existing files, but at least 1 file must exist. + def make_dexmerge(*dex_files_to_merge): + # Dex file that acts as the destination. + dst_file = dex_files_to_merge[0] + + # Skip any non-existing files. + dex_files_to_merge = list(filter(path.exists, dex_files_to_merge)) + + # NB: We merge even if there is just single input. + # It is useful to normalize non-deterministic smali output. + + with tempfile.TemporaryDirectory(dir=".") as tmp_dir: + d8(["--min-api", str(api_level), "--output", tmp_dir] + dex_files_to_merge) + assert not path.exists(path.join(tmp_dir, "classes2.dex")) + for input_dex in dex_files_to_merge: + os.remove(input_dex) + os.rename(path.join(tmp_dir, "classes.dex"), dst_file) + + + def make_hiddenapi(*dex_files): + args = ["encode"] + for dex_file in dex_files: + args.extend(["--input-dex=" + dex_file, "--output-dex=" + dex_file]) + args.append("--api-flags=hiddenapi-flags.csv") + args.append("--no-force-assign-all") + hiddenapi(args) + + + if path.exists("classes.dex"): + zip(TEST_NAME + ".jar", "classes.dex") + return + + + def has_multidex(): + return HAS_SRC_MULTIDEX or HAS_JASMIN_MULTIDEX or HAS_SMALI_MULTIDEX + + + def add_to_cp_args(old_cp_args, path): + if len(old_cp_args) == 0: + return ["-cp", path] + else: + return ["-cp", old_cp_args[1] + ":" + path] + + + src_tmp_all = [] + + if HAS_JASMIN: + make_jasmin("jasmin_classes", find("jasmin", "*.j")) + src_tmp_all = add_to_cp_args(src_tmp_all, "jasmin_classes") + + if HAS_JASMIN_MULTIDEX: + make_jasmin("jasmin_classes2", find("jasmin-multidex", "*.j")) + src_tmp_all = add_to_cp_args(src_tmp_all, "jasmin_classes2") + + if HAS_SRC and (HAS_SRC_MULTIDEX or HAS_SRC_AOTEX or HAS_SRC_BCPEX or + HAS_SRC_EX or HAS_SRC_ART or HAS_SRC2 or HAS_SRC_EX2): + # To allow circular references, compile src/, src-multidex/, src-aotex/, + # src-bcpex/, src-ex/ together and pass the output as class path argument. + # Replacement sources in src-art/, src2/ and src-ex2/ can replace symbols + # used by the other src-* sources we compile here but everything needed to + # compile the other src-* sources should be present in src/ (and jasmin*/). + os.makedirs("classes-tmp-all") + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes-tmp-all"] + + find("src", "*.java") + + find("src-multidex", "*.java") + + find("src-aotex", "*.java") + + find("src-bcpex", "*.java") + + find("src-ex", "*.java")) + src_tmp_all = add_to_cp_args(src_tmp_all, "classes-tmp-all") + + if HAS_SRC_AOTEX: + os.makedirs("classes-aotex") + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes-aotex"] + + find("src-aotex", "*.java")) + if NEED_DEX: + make_dex("classes-aotex") + # rename it so it shows up as "classes.dex" in the zip file. + os.rename("classes-aotex.dex", "classes.dex") + zip(TEST_NAME + "-aotex.jar", "classes.dex") + + if HAS_SRC_BCPEX: + os.makedirs("classes-bcpex") + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes-bcpex"] + + find("src-bcpex", "*.java")) + if NEED_DEX: + make_dex("classes-bcpex") + # rename it so it shows up as "classes.dex" in the zip file. + os.rename("classes-bcpex.dex", "classes.dex") + zip(TEST_NAME + "-bcpex.jar", "classes.dex") + + if HAS_SRC: + os.makedirs("classes", exist_ok=True) + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes"] + find("src", "*.java")) + + if HAS_SRC_ART: + os.makedirs("classes", exist_ok=True) + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes"] + find("src-art", "*.java")) + + if HAS_SRC_MULTIDEX: + os.makedirs("classes2") + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes2"] + + find("src-multidex", "*.java")) + if NEED_DEX: + make_dex("classes2") + + if HAS_SRC2: + os.makedirs("classes", exist_ok=True) + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes"] + + find("src2", "*.java")) + + # If the classes directory is not-empty, package classes in a DEX file. + # NB: some tests provide classes rather than java files. + if find("classes", "*"): + if NEED_DEX: + make_dex("classes") + + if HAS_JASMIN: + # Compile Jasmin classes as if they were part of the classes.dex file. + if NEED_DEX: + make_dex("jasmin_classes") + make_dexmerge("classes.dex", "jasmin_classes.dex") + else: + # Move jasmin classes into classes directory so that they are picked up + # with -cp classes. + os.makedirs("classes", exist_ok=True) + shutil.copytree("jasmin_classes", "classes", dirs_exist_ok=True) + + if HAS_SMALI and NEED_DEX: + # Compile Smali classes + smali(["-JXmx512m", "assemble"] + SMALI_ARGS + + ["--output", "smali_classes.dex"] + find("smali", "*.smali")) + assert path.exists("smali_classes.dex") + # Merge smali files into classes.dex, + # this takes priority over any jasmin files. + make_dexmerge("classes.dex", "smali_classes.dex") + + # Compile Jasmin classes in jasmin-multidex as if they were part of + # the classes2.jar + if HAS_JASMIN_MULTIDEX: + if NEED_DEX: + make_dex("jasmin_classes2") + make_dexmerge("classes2.dex", "jasmin_classes2.dex") + else: + # Move jasmin classes into classes2 directory so that + # they are picked up with -cp classes2. + os.makedirs("classes2", exist_ok=True) + shutil.copytree("jasmin_classes2", "classes2", dirs_exist_ok=True) + shutil.rmtree("jasmin_classes2") + + if HAS_SMALI_MULTIDEX and NEED_DEX: + # Compile Smali classes + smali(["-JXmx512m", "assemble"] + SMALI_ARGS + + ["--output", "smali_classes2.dex"] + find("smali-multidex", "*.smali")) + + # Merge smali_classes2.dex into classes2.dex + make_dexmerge("classes2.dex", "smali_classes2.dex") + + if HAS_SRC_EX: + os.makedirs("classes-ex", exist_ok=True) + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes-ex"] + find("src-ex", "*.java")) + + if HAS_SRC_EX2: + os.makedirs("classes-ex", exist_ok=True) + javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + + ["-d", "classes-ex"] + find("src-ex2", "*.java")) + + if path.exists("classes-ex") and NEED_DEX: + make_dex("classes-ex") + + if HAS_SMALI_EX and NEED_DEX: + # Compile Smali classes + smali(["-JXmx512m", "assemble"] + SMALI_ARGS + + ["--output", "smali_classes-ex.dex"] + find("smali-ex", "*.smali")) + assert path.exists("smali_classes-ex.dex") + # Merge smali files into classes-ex.dex. + make_dexmerge("classes-ex.dex", "smali_classes-ex.dex") + + if path.exists("classes-ex.dex"): + # Apply hiddenapi on the dex files if the test has API list file(s). + if use_hiddenapi and HAS_HIDDENAPI_SPEC: + make_hiddenapi("classes-ex.dex") + + # quick shuffle so that the stored name is "classes.dex" + os.rename("classes.dex", "classes-1.dex") + os.rename("classes-ex.dex", "classes.dex") + zip(TEST_NAME + "-ex.jar", "classes.dex") + os.rename("classes.dex", "classes-ex.dex") + os.rename("classes-1.dex", "classes.dex") + + # Apply hiddenapi on the dex files if the test has API list file(s). + if NEED_DEX and use_hiddenapi and HAS_HIDDENAPI_SPEC: + if has_multidex(): + make_hiddenapi("classes.dex", "classes2.dex") + else: + make_hiddenapi("classes.dex") + + # Create a single dex jar with two dex files for multidex. + if NEED_DEX: + if path.exists("classes2.dex"): + zip(TEST_NAME + ".jar", "classes.dex", "classes2.dex") + else: + zip(TEST_NAME + ".jar", "classes.dex") diff --git a/test/etc/default-build b/test/etc/default-build deleted file mode 100755 index 26820f2e4b..0000000000 --- a/test/etc/default-build +++ /dev/null @@ -1,430 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2021 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 is the default build script for run-tests. - -It can be overwrite by specific run-tests if needed. -It is used from soong build and not intended to be called directly. -""" - -import argparse -import functools -import glob -import os -from os import path -import shlex -import shutil -import subprocess -import tempfile -import zipfile - -if not os.sys.argv: - print( - 'Error: default-build should have the parameters from the "build" script forwarded to it' - ) - print('Error: An example of how do it correctly is ./default-build "$@"') - os.sys.exit(1) - - -def parse_bool(text): - return {"true": True, "false": False}[text.lower()] - - -TEST_NAME = os.environ["TEST_NAME"] -ART_TEST_RUN_TEST_BOOTCLASSPATH = os.environ["ART_TEST_RUN_TEST_BOOTCLASSPATH"] -NEED_DEX = parse_bool(os.environ["NEED_DEX"]) - -# Set default values for directories. -HAS_SMALI = path.exists("smali") -HAS_JASMIN = path.exists("jasmin") -HAS_SRC = path.exists("src") -HAS_SRC_ART = path.exists("src-art") -HAS_SRC2 = path.exists("src2") -HAS_SRC_MULTIDEX = path.exists("src-multidex") -HAS_SMALI_MULTIDEX = path.exists("smali-multidex") -HAS_JASMIN_MULTIDEX = path.exists("jasmin-multidex") -HAS_SMALI_EX = path.exists("smali-ex") -HAS_SRC_EX = path.exists("src-ex") -HAS_SRC_EX2 = path.exists("src-ex2") -HAS_SRC_AOTEX = path.exists("src-aotex") -HAS_SRC_BCPEX = path.exists("src-bcpex") -HAS_HIDDENAPI_SPEC = path.exists("hiddenapi-flags.csv") - -# USE_HIDDENAPI=false run-test... will disable hiddenapi. -USE_HIDDENAPI = parse_bool(os.environ.get("USE_HIDDENAPI", "true")) - -# USE_DESUGAR=false run-test... will disable desugaring. -USE_DESUGAR = parse_bool(os.environ.get("USE_DESUGAR", "true")) - -JAVAC_ARGS = shlex.split(os.environ.get("JAVAC_ARGS", "")) -SMALI_ARGS = shlex.split(os.environ.get("SMALI_ARGS", "")) -D8_FLAGS = shlex.split(os.environ.get("D8_FLAGS", "")) - -# Allow overriding ZIP_COMPRESSION_METHOD with e.g. 'store' -ZIP_COMPRESSION_METHOD = "deflate" -# Align every ZIP file made by calling $ZIPALIGN command? -ZIP_ALIGN_BYTES = None - -DEV_MODE = False -BUILD_MODE = "target" -API_LEVEL = None -DEFAULT_EXPERIMENT = "no-experiment" -EXPERIMENTAL = DEFAULT_EXPERIMENT - -# Setup experimental API level mappings in a bash associative array. -EXPERIMENTAL_API_LEVEL = {} -EXPERIMENTAL_API_LEVEL[DEFAULT_EXPERIMENT] = "26" -EXPERIMENTAL_API_LEVEL["default-methods"] = "24" -EXPERIMENTAL_API_LEVEL["parameter-annotations"] = "25" -EXPERIMENTAL_API_LEVEL["agents"] = "26" -EXPERIMENTAL_API_LEVEL["method-handles"] = "26" -EXPERIMENTAL_API_LEVEL["var-handles"] = "28" - -# Parse command line arguments. -opt_bool = argparse.BooleanOptionalAction # Bool also accepts the --no- prefix. -parser = argparse.ArgumentParser(description=__doc__) -parser.add_argument("--src", dest="HAS_SRC", action=opt_bool) -parser.add_argument("--src2", dest="HAS_SRC2", action=opt_bool) -parser.add_argument("--src-multidex", dest="HAS_SRC_MULTIDEX", action=opt_bool) -parser.add_argument( - "--smali-multidex", dest="HAS_SMALI_MULTIDEX", action=opt_bool) -parser.add_argument("--src-ex", dest="HAS_SRC_EX", action=opt_bool) -parser.add_argument("--src-ex2", dest="HAS_SRC_EX2", action=opt_bool) -parser.add_argument("--smali", dest="HAS_SMALI", action=opt_bool) -parser.add_argument("--jasmin", dest="HAS_JASMIN", action=opt_bool) -parser.add_argument("--api-level", dest="API_LEVEL", type=int) -parser.add_argument( - "--experimental", dest="EXPERIMENTAL", type=str) -parser.add_argument( - "--zip-compression-method", dest="ZIP_COMPRESSION_METHOD", type=str) -parser.add_argument("--zip-align", dest="ZIP_ALIGN_BYTES", type=int) -parser.add_argument( - "--host", dest="BUILD_MODE", action="store_const", const="host") -parser.add_argument( - "--target", dest="BUILD_MODE", action="store_const", const="target") -parser.add_argument( - "--jvm", dest="BUILD_MODE", action="store_const", const="jvm") -parser.add_argument("--dev", dest="DEV_MODE", action=opt_bool) -# Update variables with command line arguments that were set. -globals().update( - {k: v for k, v in parser.parse_args().__dict__.items() if v is not None}) - -if BUILD_MODE == "jvm": - # No desugaring on jvm because it supports the latest functionality. - USE_DESUGAR = False - # Do not attempt to build src-art directories on jvm, - # since it would fail without libcore. - HAS_SRC_ART = False - -# Set API level for smali and d8. -if not API_LEVEL: - API_LEVEL = EXPERIMENTAL_API_LEVEL[EXPERIMENTAL] - -# Add API level arguments to smali and dx -SMALI_ARGS.extend(["--api", str(API_LEVEL)]) -D8_FLAGS.extend(["--min-api", str(API_LEVEL)]) - - -def run(executable, args): - cmd = shlex.split(executable) + args - if executable.endswith(".sh"): - cmd = ["/bin/bash"] + cmd - if DEV_MODE: - print("Run:", " ".join(cmd)) - p = subprocess.run(cmd, check=True) - if p.returncode != 0: - raise Exception("Failed command: " + " ".join(cmd)) - - -# Helper functions to execute tools. -soong_zip = functools.partial(run, os.environ["SOONG_ZIP"]) -zipalign = functools.partial(run, os.environ["ZIPALIGN"]) -javac = functools.partial(run, os.environ["JAVAC"]) -jasmin = functools.partial(run, os.environ["JASMIN"]) -smali = functools.partial(run, os.environ["SMALI"]) -d8 = functools.partial(run, os.environ["D8"]) -hiddenapi = functools.partial(run, os.environ["HIDDENAPI"]) - -# If wrapper script exists, use it instead of the default javac. -if os.path.exists("javac_wrapper.sh"): - javac = functools.partial(run, "javac_wrapper.sh") - -def find(root, name): - return sorted(glob.glob(path.join(root, "**", name), recursive=True)) - - -def zip(zip_target, *files): - zip_args = ["-o", zip_target] - if ZIP_COMPRESSION_METHOD == "store": - zip_args.extend(["-L", "0"]) - for f in files: - zip_args.extend(["-f", f]) - soong_zip(zip_args) - - if ZIP_ALIGN_BYTES: - # zipalign does not operate in-place, so write results to a temp file. - with tempfile.TemporaryDirectory(dir=".") as tmp_dir: - tmp_file = path.join(tmp_dir, "aligned.zip") - zipalign(["-f", str(ZIP_ALIGN_BYTES), zip_target, tmp_file]) - # replace original zip target with our temp file. - os.rename(tmp_file, zip_target) - - -def make_jasmin(out_directory, jasmin_sources): - os.makedirs(out_directory, exist_ok=True) - jasmin(["-d", out_directory] + sorted(jasmin_sources)) - - -# Like regular javac but may include libcore on the bootclasspath. -def javac_with_bootclasspath(args): - flags = JAVAC_ARGS + ["-encoding", "utf8"] - if BUILD_MODE != "jvm": - flags.extend(["-bootclasspath", ART_TEST_RUN_TEST_BOOTCLASSPATH]) - javac(flags + args) - - -# Make a "dex" file given a directory of classes. This will be -# packaged in a jar file. -def make_dex(name): - d8_inputs = find(name, "*.class") - d8_output = name + ".jar" - dex_output = name + ".dex" - if USE_DESUGAR: - flags = ["--lib", ART_TEST_RUN_TEST_BOOTCLASSPATH] - else: - flags = ["--no-desugaring"] - assert d8_inputs - d8(D8_FLAGS + flags + ["--output", d8_output] + d8_inputs) - - # D8 outputs to JAR files today rather than DEX files as DX used - # to. To compensate, we extract the DEX from d8's output to meet the - # expectations of make_dex callers. - with tempfile.TemporaryDirectory(dir=".") as tmp_dir: - zipfile.ZipFile(d8_output, "r").extractall(tmp_dir) - os.rename(path.join(tmp_dir, "classes.dex"), dex_output) - - -# Merge all the dex files. -# Skip non-existing files, but at least 1 file must exist. -def make_dexmerge(*dex_files_to_merge): - # Dex file that acts as the destination. - dst_file = dex_files_to_merge[0] - - # Skip any non-existing files. - dex_files_to_merge = list(filter(path.exists, dex_files_to_merge)) - - # NB: We merge even if there is just single input. - # It is useful to normalize non-deterministic smali output. - - with tempfile.TemporaryDirectory(dir=".") as tmp_dir: - d8(["--min-api", API_LEVEL, "--output", tmp_dir] + dex_files_to_merge) - assert not path.exists(path.join(tmp_dir, "classes2.dex")) - for input_dex in dex_files_to_merge: - os.remove(input_dex) - os.rename(path.join(tmp_dir, "classes.dex"), dst_file) - - -def make_hiddenapi(*dex_files): - args = ["encode"] - for dex_file in dex_files: - args.extend(["--input-dex=" + dex_file, "--output-dex=" + dex_file]) - args.append("--api-flags=hiddenapi-flags.csv") - args.append("--no-force-assign-all") - hiddenapi(args) - - -if path.exists("classes.dex"): - zip(TEST_NAME + ".jar", "classes.dex") - os.sys.exit(0) - - -def has_multidex(): - return HAS_SRC_MULTIDEX or HAS_JASMIN_MULTIDEX or HAS_SMALI_MULTIDEX - - -def add_to_cp_args(old_cp_args, path): - if len(old_cp_args) == 0: - return ["-cp", path] - else: - return ["-cp", old_cp_args[1] + ":" + path] - - -src_tmp_all = [] - -if HAS_JASMIN: - make_jasmin("jasmin_classes", find("jasmin", "*.j")) - src_tmp_all = add_to_cp_args(src_tmp_all, "jasmin_classes") - -if HAS_JASMIN_MULTIDEX: - make_jasmin("jasmin_classes2", find("jasmin-multidex", "*.j")) - src_tmp_all = add_to_cp_args(src_tmp_all, "jasmin_classes2") - -if HAS_SRC and (HAS_SRC_MULTIDEX or HAS_SRC_AOTEX or HAS_SRC_BCPEX or - HAS_SRC_EX or HAS_SRC_ART or HAS_SRC2 or HAS_SRC_EX2): - # To allow circular references, compile src/, src-multidex/, src-aotex/, - # src-bcpex/, src-ex/ together and pass the output as class path argument. - # Replacement sources in src-art/, src2/ and src-ex2/ can replace symbols - # used by the other src-* sources we compile here but everything needed to - # compile the other src-* sources should be present in src/ (and jasmin*/). - os.makedirs("classes-tmp-all") - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes-tmp-all"] + - find("src", "*.java") + - find("src-multidex", "*.java") + - find("src-aotex", "*.java") + - find("src-bcpex", "*.java") + - find("src-ex", "*.java")) - src_tmp_all = add_to_cp_args(src_tmp_all, "classes-tmp-all") - -if HAS_SRC_AOTEX: - os.makedirs("classes-aotex") - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes-aotex"] + - find("src-aotex", "*.java")) - if NEED_DEX: - make_dex("classes-aotex") - # rename it so it shows up as "classes.dex" in the zip file. - os.rename("classes-aotex.dex", "classes.dex") - zip(TEST_NAME + "-aotex.jar", "classes.dex") - -if HAS_SRC_BCPEX: - os.makedirs("classes-bcpex") - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes-bcpex"] + - find("src-bcpex", "*.java")) - if NEED_DEX: - make_dex("classes-bcpex") - # rename it so it shows up as "classes.dex" in the zip file. - os.rename("classes-bcpex.dex", "classes.dex") - zip(TEST_NAME + "-bcpex.jar", "classes.dex") - -if HAS_SRC: - os.makedirs("classes", exist_ok=True) - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes"] + find("src", "*.java")) - -if HAS_SRC_ART: - os.makedirs("classes", exist_ok=True) - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes"] + find("src-art", "*.java")) - -if HAS_SRC_MULTIDEX: - os.makedirs("classes2") - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes2"] + - find("src-multidex", "*.java")) - if NEED_DEX: - make_dex("classes2") - -if HAS_SRC2: - os.makedirs("classes", exist_ok=True) - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes"] + - find("src2", "*.java")) - -# If the classes directory is not-empty, package classes in a DEX file. -# NB: some tests provide classes rather than java files. -if find("classes", "*"): - if NEED_DEX: - make_dex("classes") - -if HAS_JASMIN: - # Compile Jasmin classes as if they were part of the classes.dex file. - if NEED_DEX: - make_dex("jasmin_classes") - make_dexmerge("classes.dex", "jasmin_classes.dex") - else: - # Move jasmin classes into classes directory so that they are picked up - # with -cp classes. - os.makedirs("classes", exist_ok=True) - shutil.copytree("jasmin_classes", "classes", dirs_exist_ok=True) - -if HAS_SMALI and NEED_DEX: - # Compile Smali classes - smali(["-JXmx512m", "assemble"] + SMALI_ARGS + - ["--output", "smali_classes.dex"] + find("smali", "*.smali")) - assert path.exists("smali_classes.dex") - # Merge smali files into classes.dex, - # this takes priority over any jasmin files. - make_dexmerge("classes.dex", "smali_classes.dex") - -# Compile Jasmin classes in jasmin-multidex as if they were part of -# the classes2.jar -if HAS_JASMIN_MULTIDEX: - if NEED_DEX: - make_dex("jasmin_classes2") - make_dexmerge("classes2.dex", "jasmin_classes2.dex") - else: - # Move jasmin classes into classes2 directory so that - # they are picked up with -cp classes2. - os.makedirs("classes2", exist_ok=True) - shutil.copytree("jasmin_classes2", "classes2", dirs_exist_ok=True) - shutil.rmtree("jasmin_classes2") - -if HAS_SMALI_MULTIDEX and NEED_DEX: - # Compile Smali classes - smali(["-JXmx512m", "assemble"] + SMALI_ARGS + - ["--output", "smali_classes2.dex"] + find("smali-multidex", "*.smali")) - - # Merge smali_classes2.dex into classes2.dex - make_dexmerge("classes2.dex", "smali_classes2.dex") - -if HAS_SRC_EX: - os.makedirs("classes-ex", exist_ok=True) - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes-ex"] + find("src-ex", "*.java")) - -if HAS_SRC_EX2: - os.makedirs("classes-ex", exist_ok=True) - javac_with_bootclasspath(["-implicit:none"] + src_tmp_all + - ["-d", "classes-ex"] + find("src-ex2", "*.java")) - -if path.exists("classes-ex") and NEED_DEX: - make_dex("classes-ex") - -if HAS_SMALI_EX and NEED_DEX: - # Compile Smali classes - smali(["-JXmx512m", "assemble"] + SMALI_ARGS + - ["--output", "smali_classes-ex.dex"] + find("smali-ex", "*.smali")) - assert path.exists("smali_classes-ex.dex") - # Merge smali files into classes-ex.dex. - make_dexmerge("classes-ex.dex", "smali_classes-ex.dex") - -if path.exists("classes-ex.dex"): - # Apply hiddenapi on the dex files if the test has API list file(s). - if USE_HIDDENAPI and HAS_HIDDENAPI_SPEC: - make_hiddenapi("classes-ex.dex") - - # quick shuffle so that the stored name is "classes.dex" - os.rename("classes.dex", "classes-1.dex") - os.rename("classes-ex.dex", "classes.dex") - zip(TEST_NAME + "-ex.jar", "classes.dex") - os.rename("classes.dex", "classes-ex.dex") - os.rename("classes-1.dex", "classes.dex") - -# Apply hiddenapi on the dex files if the test has API list file(s). -if NEED_DEX and USE_HIDDENAPI and HAS_HIDDENAPI_SPEC: - if has_multidex(): - make_hiddenapi("classes.dex", "classes2.dex") - else: - make_hiddenapi("classes.dex") - -# Create a single dex jar with two dex files for multidex. -if NEED_DEX: - if path.exists("classes2.dex"): - zip(TEST_NAME + ".jar", "classes.dex", "classes2.dex") - else: - zip(TEST_NAME + ".jar", "classes.dex") diff --git a/test/160-read-barrier-stress/build b/test/etc/default-build.py index 90b6b95841..7a229c730b 100755..100644 --- a/test/160-read-barrier-stress/build +++ b/test/etc/default-build.py @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright 2020 The Android Open Source Project +# 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. @@ -14,4 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -./default-build "$@" --experimental var-handles +from art_build_rules import build_run_test + +build_run_test() diff --git a/test/run-test-build.py b/test/run-test-build.py index f8eb2830ea..93e95997e6 100755 --- a/test/run-test-build.py +++ b/test/run-test-build.py @@ -19,7 +19,9 @@ This scripts compiles Java files which are needed to execute run-tests. It is intended to be used only from soong genrule. """ -import argparse, os, tempfile, shutil, subprocess, glob, textwrap, re, json, concurrent.futures +import argparse, os, shutil, subprocess, glob, re, json, multiprocessing, pathlib +import art_build_rules +from importlib.machinery import SourceFileLoader ZIP = "prebuilts/build-tools/linux-x86/bin/soong_zip" BUILDFAILURES = json.loads(open(os.path.join("art", "test", "buildfailures.json"), "rt").read()) @@ -41,7 +43,7 @@ def copy_sources(args, tmp, mode, srcdir): shutil.copytree(srcdir, dstdir) # Copy the default scripts if the test does not have a custom ones. - for name in ["build", "run", "check"]: + for name in ["build.py", "run", "check"]: src, dst = f"art/test/etc/default-{name}", join(dstdir, name) if os.path.exists(dst): shutil.copy2(src, dstdir) # Copy default script next to the custom script. @@ -51,18 +53,20 @@ def copy_sources(args, tmp, mode, srcdir): return dstdir -def build_test(args, mode, dstdir): +def build_test(args, mode, build_top, sbox, dstdir): """Run the build script for single run-test""" join = os.path.join - build_top = os.getcwd() java_home = os.environ.get("JAVA_HOME") tools_dir = os.path.abspath(join(os.path.dirname(__file__), "../../../out/bin")) - env = { - "PATH": os.environ.get("PATH"), + test_name = os.path.basename(dstdir) + env = dict(os.environ) + env.update({ + "BUILD_MODE": mode, "ANDROID_BUILD_TOP": build_top, + "SBOX_PATH": sbox, "ART_TEST_RUN_TEST_BOOTCLASSPATH": join(build_top, args.bootclasspath), - "TEST_NAME": os.path.basename(dstdir), + "TEST_NAME": test_name, "SOONG_ZIP": join(build_top, "prebuilts/build-tools/linux-x86/bin/soong_zip"), "ZIPALIGN": join(build_top, "prebuilts/build-tools/linux-x86/bin/zipalign"), "JAVA": join(java_home, "bin/java"), @@ -73,15 +77,23 @@ def build_test(args, mode, dstdir): "JASMIN": join(tools_dir, "jasmin"), "SMALI": join(tools_dir, "smali"), "NEED_DEX": {"host": "true", "target": "true", "jvm": "false"}[mode], - "USE_DESUGAR": "true", - } - proc = subprocess.run([join(dstdir, "build"), "--" + mode], - cwd=dstdir, - env=env, - encoding=os.sys.stdout.encoding, - stderr=subprocess.STDOUT, - stdout=subprocess.PIPE) - return proc.stdout, proc.returncode + }) + + generate_sources = join(dstdir, "generate-sources") + if os.path.exists(generate_sources): + proc = subprocess.run([generate_sources, "--" + mode], + cwd=dstdir, + env=env, + encoding=os.sys.stdout.encoding, + stderr=subprocess.STDOUT, + stdout=subprocess.PIPE) + if proc.returncode: + raise Exception("Failed to generate sources for " + test_name + ":\n" + proc.stdout) + + os.chdir(dstdir) + for name, value in env.items(): + os.environ[name] = str(value) + SourceFileLoader("build_" + test_name, join(dstdir, "build.py")).load_module() def main(): parser = argparse.ArgumentParser(description=__doc__) @@ -91,19 +103,26 @@ def main(): parser.add_argument("--bootclasspath", help="JAR files used for javac compilation") args = parser.parse_args() - with tempfile.TemporaryDirectory(prefix=os.path.basename(__file__)) as tmp: - srcdirs = sorted(glob.glob(os.path.join("art", "test", "*"))) - srcdirs = filter(lambda srcdir: re.match(".*/\d*{}-.*".format(args.shard), srcdir), srcdirs) - dstdirs = [copy_sources(args, tmp, args.mode, srcdir) for srcdir in srcdirs] - dstdirs = filter(lambda dstdir: dstdir, dstdirs) # Remove None (skipped tests). - with concurrent.futures.ThreadPoolExecutor() as pool: - for stdout, exitcode in pool.map(lambda dstdir: build_test(args, args.mode, dstdir), dstdirs): - if stdout: - print(stdout.strip()) - assert(exitcode == 0) # Build failed. Add test to buildfailures.json if this is expected. - - # Create the final zip file which contains the content of the temporary directory. - proc = subprocess.run([ZIP, "-o", args.out, "-C", tmp, "-D", tmp], check=True) + build_top = os.getcwd() + sbox = pathlib.Path(__file__).absolute().parent.parent.parent.parent.parent + assert sbox.parent.name == "sbox" and len(sbox.name) == 40 + + ziproot = os.path.join(sbox, "zip") + srcdirs = sorted(glob.glob(os.path.join("art", "test", "*"))) + srcdirs = filter(lambda srcdir: re.match(".*/\d*{}-.*".format(args.shard), srcdir), srcdirs) + dstdirs = [copy_sources(args, ziproot, args.mode, srcdir) for srcdir in srcdirs] + dstdirs = filter(lambda dstdir: dstdir, dstdirs) # Remove None (skipped tests). + # Use multiprocess (i.e. forking) since tests modify their current working directory. + with multiprocessing.Pool() as pool: + jobs = [(d, pool.apply_async(build_test, (args, args.mode, build_top, sbox, d))) for d in dstdirs] + for dstdir, job in jobs: + try: + job.get() + except Exception as e: + raise Exception("Failed to build " + os.path.basename(dstdir)) from e.__cause__ + + # Create the final zip file which contains the content of the temporary directory. + proc = subprocess.run([ZIP, "-o", args.out, "-C", ziproot, "-D", ziproot], check=True) if __name__ == "__main__": main() diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files index 046f02dd08..934b801806 100755 --- a/test/utils/regen-test-files +++ b/test/utils/regen-test-files @@ -335,13 +335,12 @@ class Generator: 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) + def is_import(line): + return re.match("^\\s*from .* import .*", 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)) + return not (is_comment(line) or is_blank(line) or is_import(line)) with open(build_file, "r") as f: lines = f.readlines() @@ -351,7 +350,7 @@ class Generator: 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": + if build_script[0] == 'build_run_test(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. @@ -365,8 +364,11 @@ class Generator: # 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")): - if not self.can_ignore_build_script(os.path.join(run_test_path, "build")): + if (os.path.isfile(os.path.join(run_test_path, "generate-sources")) or + os.path.isfile(os.path.join(run_test_path, "javac_wrapper.sh"))): + return False + if os.path.isfile(os.path.join(run_test_path, "build.py")): + if not self.can_ignore_build_script(os.path.join(run_test_path, "build.py")): return False # Skip tests with sources outside the `src` directory. for subdir in ["jasmin", |