diff options
Diffstat (limited to 'test')
25 files changed, 475 insertions, 109 deletions
diff --git a/test/003-omnibus-opcodes/build b/test/003-omnibus-opcodes/build index f909fb2..faa2983 100644 --- a/test/003-omnibus-opcodes/build +++ b/test/003-omnibus-opcodes/build @@ -22,5 +22,10 @@ ${JAVAC} -d classes `find src -name '*.java'` rm classes/UnresClass.class ${JAVAC} -d classes `find src2 -name '*.java'` -${DX} -JXmx256m --debug --dex --output=classes.dex classes +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + ${JACK} --import classes.jack --output-dex . +else + ${DX} -JXmx256m --debug --dex --output=classes.dex classes + fi zip $TEST_NAME.jar classes.dex diff --git a/test/004-ReferenceMap/build b/test/004-ReferenceMap/build new file mode 100644 index 0000000..08987b5 --- /dev/null +++ b/test/004-ReferenceMap/build @@ -0,0 +1,26 @@ +#!/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 + +# The test relies on DEX file produced by javac+dx so keep building with them for now +# (see b/19467889) +mkdir classes +${JAVAC} -d classes `find src -name '*.java'` +${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \ + --dump-width=1000 ${DX_FLAGS} classes +zip $TEST_NAME.jar classes.dex diff --git a/test/004-StackWalk/build b/test/004-StackWalk/build new file mode 100644 index 0000000..08987b5 --- /dev/null +++ b/test/004-StackWalk/build @@ -0,0 +1,26 @@ +#!/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 + +# The test relies on DEX file produced by javac+dx so keep building with them for now +# (see b/19467889) +mkdir classes +${JAVAC} -d classes `find src -name '*.java'` +${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \ + --dump-width=1000 ${DX_FLAGS} classes +zip $TEST_NAME.jar classes.dex diff --git a/test/005-annotations/build b/test/005-annotations/build index 2474055..3f00a1a 100644 --- a/test/005-annotations/build +++ b/test/005-annotations/build @@ -25,4 +25,12 @@ ${JAVAC} -d classes `find src -name '*.java'` # ...but not at run time. rm 'classes/android/test/anno/MissingAnnotation.class' rm 'classes/android/test/anno/ClassWithInnerAnnotationClass$MissingInnerAnnotationClass.class' -${DX} -JXmx256m --debug --dex --output=$TEST_NAME.jar classes + +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + ${JACK} --import classes.jack --output-dex . +else + ${DX} -JXmx256m --debug --dex --output=classes.dex classes +fi + +zip $TEST_NAME.jar classes.dex diff --git a/test/022-interface/build b/test/022-interface/build index c86b1dc..3f8915c 100644 --- a/test/022-interface/build +++ b/test/022-interface/build @@ -19,5 +19,11 @@ set -e # Use classes that are compiled with ecj that exposes an invokeinterface # issue when interfaces override methods in Object -${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + ${JACK} --import classes.jack --output-dex . +else + ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +fi + zip $TEST_NAME.jar classes.dex diff --git a/test/023-many-interfaces/build b/test/023-many-interfaces/build index ad42a2d..b4381f4 100644 --- a/test/023-many-interfaces/build +++ b/test/023-many-interfaces/build @@ -21,8 +21,14 @@ set -e gcc -Wall -Werror -o iface-gen iface-gen.c ./iface-gen -mkdir classes -${JAVAC} -d classes src/*.java +if [ ${USE_JACK} = "true" ]; then + ${JACK} --output-dex . src +else + mkdir classes + ${JAVAC} -d classes src/*.java + + # dx needs more memory for that test so do not pass Xmx option here. + ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +fi -${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes zip $TEST_NAME.jar classes.dex diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java index e3cf4ee..cac034e 100644 --- a/test/036-finalizer/src/Main.java +++ b/test/036-finalizer/src/Main.java @@ -89,10 +89,15 @@ public class Main { return s[0]; } + private static void printWeakReference(WeakReference<FinalizerTest> wimp) { + // Reference ft so we are sure the WeakReference cannot be cleared. + FinalizerTest keepLive = wimp.get(); + System.out.println("wimp: " + wimpString(wimp)); + } + public static void main(String[] args) { WeakReference<FinalizerTest> wimp = makeRef(); - - System.out.println("wimp: " + wimpString(wimp)); + printWeakReference(wimp); /* this will try to collect and finalize ft */ System.out.println("gc"); diff --git a/test/056-const-string-jumbo/build b/test/056-const-string-jumbo/build index ef286d1..ae42519 100644 --- a/test/056-const-string-jumbo/build +++ b/test/056-const-string-jumbo/build @@ -39,8 +39,13 @@ function writeFile(name, start, end) { printf("}\n") > fileName; }' -mkdir classes -${JAVAC} -d classes src/*.java +if [ ${USE_JACK} = "true" ]; then + ${JACK} --output-dex . src +else + mkdir classes + ${JAVAC} -d classes src/*.java + + ${DX} -JXmx500m --debug --dex --no-optimize --positions=none --no-locals --output=classes.dex classes +fi -${DX} -JXmx500m --debug --dex --no-optimize --positions=none --no-locals --output=classes.dex classes zip $TEST_NAME.jar classes.dex diff --git a/test/074-gc-thrash/src/Main.java b/test/074-gc-thrash/src/Main.java index 238e73a..f947d0b 100644 --- a/test/074-gc-thrash/src/Main.java +++ b/test/074-gc-thrash/src/Main.java @@ -218,17 +218,7 @@ class Deep extends Thread { return; } - /* - * Check the results of the last trip through. Everything in - * "weak" should be matched in "strong", and the two should be - * equivalent (object-wise, not just string-equality-wise). - */ - for (int i = 0; i < MAX_DEPTH; i++) { - if (strong[i] != weak[i].get()) { - System.err.println("Deep: " + i + " strong=" + strong[i] + - ", weak=" + weak[i].get()); - } - } + checkStringReferences(); /* * Wipe "strong", do a GC, see if "weak" got collected. @@ -248,6 +238,26 @@ class Deep extends Thread { System.out.println("Deep: iters=" + iter / MAX_DEPTH); } + + /** + * Check the results of the last trip through. Everything in + * "weak" should be matched in "strong", and the two should be + * equivalent (object-wise, not just string-equality-wise). + * + * We do that check in a separate method to avoid retaining these + * String references in local DEX registers. In interpreter mode, + * they would retain these references until the end of the method + * or until they are updated to another value. + */ + private static void checkStringReferences() { + for (int i = 0; i < MAX_DEPTH; i++) { + if (strong[i] != weak[i].get()) { + System.err.println("Deep: " + i + " strong=" + strong[i] + + ", weak=" + weak[i].get()); + } + } + } + /** * Recursively dive down, setting one or more local variables. * diff --git a/test/085-old-style-inner-class/build b/test/085-old-style-inner-class/build index 963d6b3..6f50a76 100644 --- a/test/085-old-style-inner-class/build +++ b/test/085-old-style-inner-class/build @@ -22,7 +22,12 @@ set -e mkdir classes ${JAVAC} -source 1.4 -target 1.4 -d classes `find src -name '*.java'` -# Suppress stderr to keep the inner class warnings out of the expected output. -${DX} --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes 2>/dev/null +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + ${JACK} --import classes.jack --output-dex . +else + # Suppress stderr to keep the inner class warnings out of the expected output. + ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes 2>/dev/null +fi zip $TEST_NAME.jar classes.dex diff --git a/test/089-many-methods/build b/test/089-many-methods/build index 7ede759..ff77c60 100644 --- a/test/089-many-methods/build +++ b/test/089-many-methods/build @@ -43,7 +43,8 @@ function writeFileMethod(name) { printf("}\n") > fileName; }' +# The test relies on the error message produced by dx, not jack, so keep building with dx for now +# (b/19467889). mkdir classes ${JAVAC} -d classes `find src -name '*.java'` ${DX} -JXmx1024m --dex --no-optimize classes - diff --git a/test/097-duplicate-method/build b/test/097-duplicate-method/build index 6576779..a855873 100644 --- a/test/097-duplicate-method/build +++ b/test/097-duplicate-method/build @@ -18,8 +18,19 @@ set -e mkdir classes -${JAVAC} -d classes src/*.java -${JASMIN} -d classes src/*.j -${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +if [ ${USE_JACK} = "true" ]; then + ${JACK} --output-jack src.jack src + + ${JASMIN} -d classes src/*.j + ${JILL} classes --output jasmin.jack + + # We set jack.import.type.policy=keep-first to consider class definitions from jasmin first. + ${JACK} --import jasmin.jack --import src.jack -D jack.import.type.policy=keep-first --output-dex . +else + ${JAVAC} -d classes src/*.java + ${JASMIN} -d classes src/*.j + + ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +fi zip $TEST_NAME.jar classes.dex diff --git a/test/111-unresolvable-exception/build b/test/111-unresolvable-exception/build index c21a9ef..e772fb8 100644 --- a/test/111-unresolvable-exception/build +++ b/test/111-unresolvable-exception/build @@ -21,5 +21,10 @@ mkdir classes ${JAVAC} -d classes `find src -name '*.java'` rm classes/TestException.class -${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + ${JACK} --import classes.jack --output-dex . +else + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes +fi zip $TEST_NAME.jar classes.dex diff --git a/test/113-multidex/build b/test/113-multidex/build index ec8706e..8ef5c0e 100644 --- a/test/113-multidex/build +++ b/test/113-multidex/build @@ -17,16 +17,32 @@ # Stop if something fails. set -e -mkdir classes - # All except Main +mkdir classes ${JAVAC} -d classes `find src -name '*.java'` rm classes/Main.class -${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes # Only Main -${JAVAC} -d classes `find src -name '*.java'` -rm classes/Second.class classes/FillerA.class classes/FillerB.class classes/Inf*.class -${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes +mkdir classes2 +${JAVAC} -d classes2 `find src -name '*.java'` +rm classes2/Second.class classes2/FillerA.class classes2/FillerB.class classes2/Inf*.class + +if [ ${USE_JACK} = "true" ]; then + # Create .jack files from classes generated with javac. + ${JILL} classes --output classes.jack + ${JILL} classes2 --output classes2.jack + + # Create DEX files from .jack files. + ${JACK} --import classes.jack --output-dex . + mv classes.dex classes-1.dex + ${JACK} --import classes2.jack --output-dex . + mv classes.dex classes2.dex + mv classes-1.dex classes.dex +else + # All except Main + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes + # Only Main + ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes2 +fi zip $TEST_NAME.jar classes.dex classes2.dex diff --git a/test/114-ParallelGC/src/Main.java b/test/114-ParallelGC/src/Main.java index 46029cf..159dd5c 100644 --- a/test/114-ParallelGC/src/Main.java +++ b/test/114-ParallelGC/src/Main.java @@ -53,20 +53,21 @@ public class Main implements Runnable { } // Allocate objects to definitely run GC before quitting. - ArrayList<Object> l = new ArrayList<Object>(); - try { - for (int i = 0; i < 100000; i++) { - l.add(new ArrayList<Object>(i)); - } - } catch (OutOfMemoryError oom) { - } - // Make the (outer) ArrayList unreachable. Note it may still - // be reachable under an interpreter or a compiler without a - // liveness analysis. - l = null; + allocateObjectsToRunGc(); + new ArrayList<Object>(50); } + private static void allocateObjectsToRunGc() { + ArrayList<Object> l = new ArrayList<Object>(); + try { + for (int i = 0; i < 100000; i++) { + l.add(new ArrayList<Object>(i)); + } + } catch (OutOfMemoryError oom) { + } + } + private Main(CyclicBarrier startBarrier) { this.startBarrier = startBarrier; } diff --git a/test/121-modifiers/build b/test/121-modifiers/build index d73be86..85b69e9 100644 --- a/test/121-modifiers/build +++ b/test/121-modifiers/build @@ -30,5 +30,11 @@ set -e # mv NonInf.out classes/NonInf.class # mv Main.class A.class A\$B.class A\$C.class classes/ -${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + # Workaround b/19561685: disable sanity checks to produce a DEX file with invalid modifiers. + ${JACK} --sanity-checks off --import classes.jack --output-dex . +else + ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes +fi zip $TEST_NAME.jar classes.dex diff --git a/test/124-missing-classes/build b/test/124-missing-classes/build index 62e57c8..b92ecf9 100644 --- a/test/124-missing-classes/build +++ b/test/124-missing-classes/build @@ -25,4 +25,11 @@ ${JAVAC} -d classes `find src -name '*.java'` # ...but not at run time. rm 'classes/MissingClass.class' rm 'classes/Main$MissingInnerClass.class' -${DX} -JXmx256m --debug --dex --output=$TEST_NAME.jar classes + +if [ ${USE_JACK} = "true" ]; then + ${JILL} classes --output classes.jack + ${JACK} --import classes.jack --output-dex . +else + ${DX} -JXmx256m --debug --dex --output=classes.dex classes +fi +zip $TEST_NAME.jar classes.dex diff --git a/test/126-miranda-multidex/build b/test/126-miranda-multidex/build index 4c30f3f..b7f2118 100644 --- a/test/126-miranda-multidex/build +++ b/test/126-miranda-multidex/build @@ -17,16 +17,32 @@ # Stop if something fails. set -e +# All except MirandaInterface mkdir classes - -# All except Main ${JAVAC} -d classes `find src -name '*.java'` rm classes/MirandaInterface.class -${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes -# Only Main -${JAVAC} -d classes `find src -name '*.java'` -rm classes/Main.class classes/MirandaAbstract.class classes/MirandaClass*.class classes/MirandaInterface2*.class -${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes +# Only MirandaInterface +mkdir classes2 +${JAVAC} -d classes2 `find src -name '*.java'` +rm classes2/Main.class classes2/MirandaAbstract.class classes2/MirandaClass*.class classes2/MirandaInterface2*.class + +if [ ${USE_JACK} = "true" ]; then + # Create .jack files from classes generated with javac. + ${JILL} classes --output classes.jack + ${JILL} classes2 --output classes2.jack + + # Create DEX files from .jack files. + ${JACK} --import classes.jack --output-dex . + mv classes.dex classes-1.dex + ${JACK} --import classes2.jack --output-dex . + mv classes.dex classes2.dex + mv classes-1.dex classes.dex +else + # All except Main + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes + # Only Main + ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes2 +fi zip $TEST_NAME.jar classes.dex classes2.dex diff --git a/test/127-secondarydex/build b/test/127-secondarydex/build index 712774f..0d9f4d6 100755 --- a/test/127-secondarydex/build +++ b/test/127-secondarydex/build @@ -23,9 +23,21 @@ ${JAVAC} -d classes `find src -name '*.java'` mkdir classes-ex mv classes/Super.class classes-ex -if [ ${NEED_DEX} = "true" ]; then - ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes +if [ ${USE_JACK} = "true" ]; then + # Create .jack files from classes generated with javac. + ${JILL} classes --output classes.jack + ${JILL} classes-ex --output classes-ex.jack + + # Create DEX files from .jack files. + ${JACK} --import classes.jack --output-dex . zip $TEST_NAME.jar classes.dex - ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex + ${JACK} --import classes-ex.jack --output-dex . zip ${TEST_NAME}-ex.jar classes.dex +else + if [ ${NEED_DEX} = "true" ]; then + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes + zip $TEST_NAME.jar classes.dex + ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex + zip ${TEST_NAME}-ex.jar classes.dex + fi fi diff --git a/test/131-structural-change/build b/test/131-structural-change/build index 7ddc81d..ff0da20 100755 --- a/test/131-structural-change/build +++ b/test/131-structural-change/build @@ -17,15 +17,23 @@ # Stop if something fails. set -e -mkdir classes -${JAVAC} -d classes `find src -name '*.java'` - -mkdir classes-ex -${JAVAC} -d classes-ex `find src-ex -name '*.java'` - -if [ ${NEED_DEX} = "true" ]; then - ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes +if [ ${USE_JACK} = "true" ]; then + ${JACK} --output-dex . src zip $TEST_NAME.jar classes.dex - ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex + + ${JACK} --output-dex . src-ex zip ${TEST_NAME}-ex.jar classes.dex +else + mkdir classes + ${JAVAC} -d classes `find src -name '*.java'` + + mkdir classes-ex + ${JAVAC} -d classes-ex `find src-ex -name '*.java'` + + if [ ${NEED_DEX} = "true" ]; then + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes + zip $TEST_NAME.jar classes.dex + ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex + zip ${TEST_NAME}-ex.jar classes.dex + fi fi diff --git a/test/303-verification-stress/build b/test/303-verification-stress/build index 789d38e..9d19809 100644 --- a/test/303-verification-stress/build +++ b/test/303-verification-stress/build @@ -21,8 +21,14 @@ set -e gcc -Wall -Werror -o classes-gen classes-gen.c ./classes-gen -mkdir classes -${JAVAC} -d classes src/*.java +if [ ${USE_JACK} = "true" ]; then + ${JACK} --output-dex . src +else + mkdir classes + ${JAVAC} -d classes src/*.java + + # dx needs more memory for that test so do not pass Xmx option here. + ${DX} --debug --dex --output=classes.dex classes +fi -${DX} --debug --dex --output=classes.dex classes zip $TEST_NAME.jar classes.dex diff --git a/test/454-get-vreg/build b/test/454-get-vreg/build new file mode 100644 index 0000000..08987b5 --- /dev/null +++ b/test/454-get-vreg/build @@ -0,0 +1,26 @@ +#!/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 + +# The test relies on DEX file produced by javac+dx so keep building with them for now +# (see b/19467889) +mkdir classes +${JAVAC} -d classes `find src -name '*.java'` +${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \ + --dump-width=1000 ${DX_FLAGS} classes +zip $TEST_NAME.jar classes.dex diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk index b043d46..b1edc3b 100644 --- a/test/Android.run-test.mk +++ b/test/Android.run-test.mk @@ -32,20 +32,47 @@ art_run_tests_dir := $(call intermediates-dir-for,PACKAGING,art-run-tests)/DATA # an empty file touched in the intermediate directory. TEST_ART_RUN_TEST_BUILD_RULES := +# Dependencies for actually running a run-test. +TEST_ART_RUN_TEST_DEPENDENCIES := \ + $(DX) \ + $(HOST_OUT_EXECUTABLES)/jasmin \ + $(HOST_OUT_EXECUTABLES)/smali \ + $(HOST_OUT_EXECUTABLES)/dexmerger + +ifeq ($(ANDROID_COMPILE_WITH_JACK),true) + TEST_ART_RUN_TEST_DEPENDENCIES += \ + $(JACK_JAR) \ + $(JACK_LAUNCHER_JAR) \ + $(JILL_JAR) +endif + # Helper to create individual build targets for tests. Must be called with $(eval). # $(1): the test number define define-build-art-run-test dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch -$$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger + run_test_options = --build-only + ifeq ($(ANDROID_COMPILE_WITH_JACK),true) + run_test_options += --build-with-jack + else + run_test_options += --build-with-javac-dx + endif +$$(dmart_target): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options) +$$(dmart_target): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@) $(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \ SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \ DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \ - $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1) + JACK=$(abspath $(JACK)) \ + JACK_VM_COMMAND="$(JACK_VM) $(DEFAULT_JACK_VM_ARGS) $(JAVA_TMPDIR_ARG) -jar $(abspath $(JACK_LAUNCHER_JAR)) " \ + JACK_CLASSPATH=$(TARGET_JACK_CLASSPATH) \ + JACK_JAR=$(abspath $(JACK_JAR)) \ + JILL_JAR=$(abspath $(JILL_JAR)) \ + $(LOCAL_PATH)/run-test $$(PRIVATE_RUN_TEST_OPTIONS) --output-path $$(abspath $$(dir $$@)) $(1) $(hide) touch $$@ TEST_ART_RUN_TEST_BUILD_RULES += $$(dmart_target) dmart_target := + run_test_options := endef $(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call define-build-art-run-test,$(test)))) @@ -590,6 +617,12 @@ define define-test-art-run-test prereq_rule := test_groups := uc_host_or_target := + jack_classpath := + ifeq ($(ANDROID_COMPILE_WITH_JACK),true) + run_test_options += --build-with-jack + else + run_test_options += --build-with-javac-dx + endif ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true) run_test_options += --always-clean endif @@ -598,11 +631,13 @@ define define-test-art-run-test test_groups := ART_RUN_TEST_HOST_RULES run_test_options += --host prereq_rule := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES) + jack_classpath := $(HOST_JACK_CLASSPATH) else ifeq ($(1),target) uc_host_or_target := TARGET test_groups := ART_RUN_TEST_TARGET_RULES prereq_rule := test-art-target-sync + jack_classpath := $(TARGET_JACK_CLASSPATH) else $$(error found $(1) expected $(TARGET_TYPES)) endif @@ -797,12 +832,19 @@ define define-test-art-run-test run_test_options := --android-root $(ART_TEST_ANDROID_ROOT) $$(run_test_options) endif $$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options) +$$(run_test_rule_name): PRIVATE_JACK_CLASSPATH := $$(jack_classpath) .PHONY: $$(run_test_rule_name) -$$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger $(HOST_OUT_EXECUTABLES)/hprof-conv $$(prereq_rule) +$$(run_test_rule_name): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(HOST_OUT_EXECUTABLES)/hprof-conv $$(prereq_rule) $(hide) $$(call ART_TEST_SKIP,$$@) && \ - DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \ + DX=$(abspath $(DX)) \ + JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \ SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \ DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \ + JACK=$(abspath $(JACK)) \ + JACK_VM_COMMAND="$(JACK_VM) $(DEFAULT_JACK_VM_ARGS) $(JAVA_TMPDIR_ARG) -jar $(abspath $(JACK_LAUNCHER_JAR)) " \ + JACK_CLASSPATH=$$(PRIVATE_JACK_CLASSPATH) \ + JACK_JAR=$(abspath $(JACK_JAR)) \ + JILL_JAR=$(abspath $(JILL_JAR)) \ art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(12) \ && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@) $$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \ @@ -817,6 +859,7 @@ $$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTAB run_test_options := run_test_rule_name := prereq_rule := + jack_classpath := endef # define-test-art-run-test $(foreach target, $(TARGET_TYPES), \ diff --git a/test/etc/default-build b/test/etc/default-build index fbe97f9..7995bd5 100755 --- a/test/etc/default-build +++ b/test/etc/default-build @@ -38,16 +38,52 @@ if [ -e classes.dex ]; then exit 0 fi -mkdir classes -${JAVAC} -implicit:none -classpath src-multidex -d classes `find src -name '*.java'` - -if [ -d src2 ]; then - ${JAVAC} -d classes `find src2 -name '*.java'` +if [ -d src-multidex ]; then + # Jack does not support this configuration unless we specify how to partition the DEX file + # with a .jpp file. + USE_JACK="false" fi -if [ ${NEED_DEX} = "true" ]; then - ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \ - --dump-width=1000 ${DX_FLAGS} classes +if [ ${USE_JACK} = "true" ]; then + # Jack toolchain + if [ -d src ]; then + ${JACK} --output-jack src.jack src + imported_jack_files="--import src.jack" + fi + + if [ -d src2 ]; then + ${JACK} --output-jack src2.jack src2 + imported_jack_files="--import src2.jack ${imported_jack_files}" + fi + + # Compile jack files into a DEX file. We set jack.import.type.policy=keep-first to consider + # class definitions from src2 first. + ${JACK} ${imported_jack_files} -D jack.import.type.policy=keep-first --output-dex . +else + # Legacy toolchain with javac+dx + if [ -d src ]; then + mkdir classes + ${JAVAC} -implicit:none -classpath src-multidex -d classes `find src -name '*.java'` + fi + + if [ -d src-multidex ]; then + mkdir classes2 + ${JAVAC} -implicit:none -classpath src -d classes2 `find src-multidex -name '*.java'` + if [ ${NEED_DEX} = "true" ]; then + ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex \ + --dump-width=1000 ${DX_FLAGS} classes2 + fi + fi + + if [ -d src2 ]; then + mkdir -p classes + ${JAVAC} -d classes `find src2 -name '*.java'` + fi + + if [ ${NEED_DEX} = "true" ]; then + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \ + --dump-width=1000 ${DX_FLAGS} classes + fi fi if [ -d smali ]; then @@ -57,30 +93,34 @@ if [ -d smali ]; then fi if [ -d src-ex ]; then - mkdir classes-ex - ${JAVAC} -d classes-ex -cp classes `find src-ex -name '*.java'` - if [ ${NEED_DEX} = "true" ]; then - ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes-ex.dex \ - --dump-width=1000 ${DX_FLAGS} classes-ex + if [ ${USE_JACK} = "true" ]; then + # Rename previous "classes.dex" so it is not overwritten. + mv classes.dex classes-1.dex + #TODO find another way to append src.jack to the jack classpath + ${JACK}:src.jack --output-dex . src-ex + zip $TEST_NAME-ex.jar classes.dex + # Restore previous "classes.dex" so it can be zipped. + mv classes-1.dex classes.dex + else + mkdir classes-ex + ${JAVAC} -d classes-ex -cp classes `find src-ex -name '*.java'` + if [ ${NEED_DEX} = "true" ]; then + ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes-ex.dex \ + --dump-width=1000 ${DX_FLAGS} classes-ex - # quick shuffle so that the stored name is "classes.dex" - mv classes.dex classes-1.dex - mv classes-ex.dex classes.dex - zip $TEST_NAME-ex.jar classes.dex - mv classes.dex classes-ex.dex - mv classes-1.dex classes.dex + # quick shuffle so that the stored name is "classes.dex" + mv classes.dex classes-1.dex + mv classes-ex.dex classes.dex + zip $TEST_NAME-ex.jar classes.dex + mv classes.dex classes-ex.dex + mv classes-1.dex classes.dex + fi fi fi # Create a single jar with two dex files for multidex. if [ -d src-multidex ]; then - mkdir classes2 - ${JAVAC} -implicit:none -classpath src -d classes2 `find src-multidex -name '*.java'` - if [ ${NEED_DEX} = "true" ]; then - ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex \ - --dump-width=1000 ${DX_FLAGS} classes2 - zip $TEST_NAME.jar classes.dex classes2.dex - fi + zip $TEST_NAME.jar classes.dex classes2.dex elif [ ${NEED_DEX} = "true" ]; then zip $TEST_NAME.jar classes.dex fi diff --git a/test/run-test b/test/run-test index 3f17861..8410387 100755 --- a/test/run-test +++ b/test/run-test @@ -46,6 +46,7 @@ export JAVAC="javac -g" export RUN="${progdir}/etc/run-test-jar" export DEX_LOCATION=/data/run-test/${test_dir} export NEED_DEX="true" +export USE_JACK="false" # If dx was not set by the environment variable, assume it is in the path. if [ -z "$DX" ]; then @@ -67,6 +68,46 @@ if [ -z "$DXMERGER" ]; then export DXMERGER="dexmerger" fi +# If jack was not set by the environment variable, assume it is in the path. +if [ -z "$JACK" ]; then + export JACK="jack" +fi + +# If the tree is compiled with Jack, build test with Jack by default. +if [ "$ANDROID_COMPILE_WITH_JACK" = "true" ]; then + USE_JACK="true" +fi + +# ANDROID_BUILD_TOP is not set in a build environment. +if [ -z "$ANDROID_BUILD_TOP" ]; then + export ANDROID_BUILD_TOP=$oldwd +fi + +# If JACK_VM_COMMAND is not set, assume it launches the prebuilt jack-launcher. +if [ -z "$JACK_VM_COMMAND" ]; then + if [ ! -z "$TMPDIR" ]; then + jack_temp_dir="-Djava.io.tmpdir=$TMPDIR" + fi + export JACK_VM_COMMAND="java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation $jack_temp_dir -jar $ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack-launcher.jar" +fi + +# If JACK_CLASSPATH is not set, assume it only contains core-libart. +if [ -z "$JACK_CLASSPATH" ]; then + export JACK_CLASSPATH="$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack" +fi + +# If JACK_JAR is not set, assume it is located in the prebuilts directory. +if [ -z "$JACK_JAR" ]; then + export JACK_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack.jar" +fi + +# If JILL_JAR is not set, assume it is located in the prebuilts directory. +if [ -z "$JILL_JAR" ]; then + export JILL_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jill.jar" +fi + +export JACK="$JACK -g -cp $JACK_CLASSPATH" +export JILL="java -jar $JILL_JAR" info="info.txt" build="build" @@ -115,6 +156,7 @@ while true; do runtime="jvm" prebuild_mode="no" NEED_DEX="false" + USE_JACK="false" run_args="${run_args} --jvm" shift elif [ "x$1" = "x-O" ]; then @@ -236,6 +278,12 @@ while true; do elif [ "x$1" = "x--build-only" ]; then build_only="yes" shift + elif [ "x$1" = "x--build-with-javac-dx" ]; then + USE_JACK="false" + shift + elif [ "x$1" = "x--build-with-jack" ]; then + USE_JACK="true" + shift elif [ "x$1" = "x--output-path" ]; then shift tmp_dir=$1 @@ -365,10 +413,7 @@ if [ "$runtime" = "dalvik" ]; then fi elif [ "$runtime" = "art" ]; then if [ "$target_mode" = "no" ]; then - # ANDROID_BUILD_TOP and ANDROID_HOST_OUT are not set in a build environment. - if [ -z "$ANDROID_BUILD_TOP" ]; then - export ANDROID_BUILD_TOP=$oldwd - fi + # ANDROID_HOST_OUT is not set in a build environment. if [ -z "$ANDROID_HOST_OUT" ]; then export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86 fi @@ -458,6 +503,8 @@ if [ "$usage" = "yes" ]; then echo " --debuggable Whether to compile Java code for a debugger." echo " --gdb Run under gdb; incompatible with some tests." echo " --build-only Build test files only (off by default)." + echo " --build-with-javac-dx Build test files with javac and dx (on by default)." + echo " --build-with-jack Build test files with jack and jill (off by default)." echo " --interpreter Enable interpreter only mode (off by default)." echo " --jit Enable jit (off by default)." echo " --optimizing Enable optimizing compiler (default)." @@ -545,6 +592,10 @@ if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then # if Checker is not invoked and the test only runs the program. build_args="${build_args} --dx-option --no-optimize" + # Jack does not necessarily generate the same DEX output than dx. Because these tests depend + # on a particular DEX output, keep building them with dx for now (b/19467889). + USE_JACK="false" + if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" -a "$target_mode" = "no" -a "$debuggable" = "no" ]; then run_checker="yes" run_args="${run_args} -Xcompiler-option --dump-cfg=$tmp_dir/$cfg_output \ @@ -553,14 +604,20 @@ if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then fi # To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB. -file_size_limit=2048 +build_file_size_limit=2048 +run_file_size_limit=2048 if echo "$test_dir" | grep 089; then - file_size_limit=5120 + build_file_size_limit=5120 + run_file_size_limit=5120 elif echo "$test_dir" | grep 083; then - file_size_limit=5120 + build_file_size_limit=5120 + run_file_size_limit=5120 fi -if ! ulimit -S "$file_size_limit"; then - echo "ulimit file size setting failed" +if [ ${USE_JACK} = "false" ]; then + # Set ulimit if we build with dx only, Jack can generate big temp files. + if ! ulimit -S "$build_file_size_limit"; then + echo "ulimit file size setting failed" + fi fi good="no" @@ -571,6 +628,9 @@ if [ "$dev_mode" = "yes" ]; then build_exit="$?" echo "build exit status: $build_exit" 1>&2 if [ "$build_exit" = '0' ]; then + if ! ulimit -S "$run_file_size_limit"; then + echo "ulimit file size setting failed" + fi echo "${test_dir}: running..." 1>&2 "./${run}" $run_args "$@" 2>&1 run_exit="$?" @@ -593,6 +653,9 @@ elif [ "$update_mode" = "yes" ]; then "./${build}" $build_args >"$build_output" 2>&1 build_exit="$?" if [ "$build_exit" = '0' ]; then + if ! ulimit -S "$run_file_size_limit"; then + echo "ulimit file size setting failed" + fi echo "${test_dir}: running..." 1>&2 "./${run}" $run_args "$@" >"$output" 2>&1 if [ "$run_checker" = "yes" ]; then @@ -624,6 +687,9 @@ else "./${build}" $build_args >"$build_output" 2>&1 build_exit="$?" if [ "$build_exit" = '0' ]; then + if ! ulimit -S "$run_file_size_limit"; then + echo "ulimit file size setting failed" + fi echo "${test_dir}: running..." 1>&2 "./${run}" $run_args "$@" >"$output" 2>&1 run_exit="$?" |