Move main method tests from gtests to oat tests
Change-Id: Ifffa4d083488114d6cc14d578ec2be7db8a7553f
diff --git a/Android.mk b/Android.mk
index 62adeb7..a7d41d7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -38,7 +38,8 @@
include $(build_path)/Android.oat.mk
include $(build_path)/Android.libarttest.mk
-include $(build_path)/Android.test.mk
+include $(build_path)/Android.gtest.mk
+include $(build_path)/Android.oattest.mk
# "m build-art" for quick minimal build
.PHONY: build-art
@@ -92,23 +93,7 @@
$(hide) rm /tmp/test-art-target-gtest
.PHONY: test-art-target-oat
-test-art-target-oat: test-art-target-oat-HelloWorld test-art-target-oat-Fibonacci
-
-.PHONY: test-art-target-oat-HelloWorld
-test-art-target-oat-HelloWorld: test-art-target-sync
- adb shell touch /sdcard/test-art-target-oat-HelloWorld
- adb shell rm /sdcard/test-art-target-oat-HelloWorld
- adb shell sh -c "oatexecd -Xbootclasspath:/system/framework/core.jar -Xbootimage:/system/framework/boot.oat -classpath /system/framework/art-test-dex-HelloWorld.jar -Ximage:/system/framework/art-test-dex-HelloWorld.oat HelloWorld && touch /sdcard/test-art-target-oat-HelloWorld"
- $(hide) (adb pull /sdcard/test-art-target-oat-HelloWorld /tmp/ && echo test-art-target-oat-HelloWorld PASSED) || (echo test-art-target-oat-HelloWorld FAILED && exit 1)
- $(hide) rm /tmp/test-art-target-oat-HelloWorld
-
-.PHONY: test-art-target-oat-Fibonacci
-test-art-target-oat-Fibonacci: test-art-target-sync
- adb shell touch /sdcard/test-art-target-oat-Fibonacci
- adb shell rm /sdcard/test-art-target-oat-Fibonacci
- adb shell sh -c "oatexecd -Xbootclasspath:/system/framework/core.jar -Xbootimage:/system/framework/boot.oat -classpath /system/framework/art-test-dex-Fibonacci.jar -Ximage:/system/framework/art-test-dex-Fibonacci.oat Fibonacci 10 && touch /sdcard/test-art-target-oat-Fibonacci"
- $(hide) (adb pull /sdcard/test-art-target-oat-Fibonacci /tmp/ && echo test-art-target-oat-Fibonacci PASSED) || (echo test-art-target-oat-Fibonacci FAILED && exit 1)
- $(hide) rm /tmp/test-art-target-oat-Fibonacci
+test-art-target-oat: $(ART_TEST_OAT_TARGETS)
.PHONY: dump-boot-oat
dump-boot-oat: $(TARGET_BOOT_OAT) $(OATDUMP)
diff --git a/build/Android.test.mk b/build/Android.gtest.mk
similarity index 65%
rename from build/Android.test.mk
rename to build/Android.gtest.mk
index 531c775..e35758d 100644
--- a/build/Android.test.mk
+++ b/build/Android.gtest.mk
@@ -57,31 +57,3 @@
ifeq ($(ART_BUILD_HOST),true)
$(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
endif
-
-ART_TEST_DEX_FILES :=
-
-# $(1): directory
-define build-art-test-dex
- include $(CLEAR_VARS)
- LOCAL_MODULE := art-test-dex-$(1)
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(call all-java-files-under, test/$(1))
- LOCAL_JAVA_LIBRARIES := core
- LOCAL_NO_STANDARD_LIBRARIES := true
- include $(BUILD_JAVA_LIBRARY)
- ART_TEST_DEX_FILES += $(TARGET_OUT_JAVA_LIBRARIES)/$$(LOCAL_MODULE).jar
-endef
-$(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,$(dir))))
-
-ART_TEST_OAT_FILES :=
-
-# $(1): directory
-define build-art-test-oat
-# TODO: change DEX2OATD to order-only prerequisite when output is stable
-$(TARGET_OUT_JAVA_LIBRARIES)/art-test-dex-$(1).oat: $(TARGET_OUT_JAVA_LIBRARIES)/art-test-dex-$(1).jar $(TARGET_BOOT_OAT) $(DEX2OAT)
- @echo "target dex2oat: $$@ ($$<)"
- $(hide) $(DEX2OAT) $(addprefix --boot-dex-file=,$(TARGET_BOOT_DEX)) --boot=$(TARGET_BOOT_OAT) $(addprefix --dex-file=,$$<) --image=$$@ --strip-prefix=$(PRODUCT_OUT)
-
-ART_TEST_OAT_FILES += $(TARGET_OUT_JAVA_LIBRARIES)/art-test-dex-$(1).oat
-endef
-$(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-oat,$(dir))))
diff --git a/build/Android.oattest.mk b/build/Android.oattest.mk
new file mode 100644
index 0000000..f01d2f5
--- /dev/null
+++ b/build/Android.oattest.mk
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2011 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.
+#
+
+########################################################################
+
+ART_TEST_DEX_FILES :=
+
+# $(1): directory
+define build-art-test-dex
+ include $(CLEAR_VARS)
+ LOCAL_MODULE := art-test-dex-$(1)
+ LOCAL_MODULE_TAGS := optional
+ LOCAL_SRC_FILES := $(call all-java-files-under, test/$(1))
+ LOCAL_JAVA_LIBRARIES := core
+ LOCAL_NO_STANDARD_LIBRARIES := true
+ include $(BUILD_JAVA_LIBRARY)
+ ART_TEST_DEX_FILES += $(TARGET_OUT_JAVA_LIBRARIES)/$$(LOCAL_MODULE).jar
+endef
+$(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,$(dir))))
+
+########################################################################
+
+ART_TEST_OAT_FILES :=
+
+# $(1): directory
+define build-art-test-oat
+# TODO: change DEX2OATD to order-only prerequisite when output is stable
+$(TARGET_OUT_JAVA_LIBRARIES)/art-test-dex-$(1).oat: $(TARGET_OUT_JAVA_LIBRARIES)/art-test-dex-$(1).jar $(TARGET_BOOT_OAT) $(DEX2OAT)
+ @echo "target dex2oat: $$@ ($$<)"
+ $(hide) $(DEX2OAT) $(addprefix --boot-dex-file=,$(TARGET_BOOT_DEX)) --boot=$(TARGET_BOOT_OAT) $(addprefix --dex-file=,$$<) --image=$$@ --strip-prefix=$(PRODUCT_OUT)
+
+ART_TEST_OAT_FILES += $(TARGET_OUT_JAVA_LIBRARIES)/art-test-dex-$(1).oat
+endef
+$(foreach dir,$(TEST_DEX_DIRECTORIES), $(eval $(call build-art-test-oat,$(dir))))
+
+########################################################################
+
+ART_TEST_OAT_TARGETS :=
+
+# $(1): directory
+# $(2): arguments
+define declare-test-test-target
+.PHONY: test-art-target-oat-$(1)
+test-art-target-oat-$(1): test-art-target-sync
+ adb shell touch /sdcard/test-art-target-oat-$(1)
+ adb shell rm /sdcard/test-art-target-oat-$(1)
+ adb shell sh -c "oatexecd -Xbootclasspath:/system/framework/core.jar -Xbootimage:/system/framework/boot.oat -classpath /system/framework/art-test-dex-$(1).jar -Ximage:/system/framework/art-test-dex-$(1).oat $(1) $(2) && touch /sdcard/test-art-target-oat-$(1)"
+ $(hide) (adb pull /sdcard/test-art-target-oat-$(1) /tmp/ && echo test-art-target-oat-$(1) PASSED) || (echo test-art-target-oat-$(1) FAILED && exit 1)
+ $(hide) rm /tmp/test-art-target-oat-$(1)
+
+ART_TEST_OAT_TARGETS += test-art-target-oat-$(1)
+endef
+
+$(eval $(call declare-test-test-target,HelloWorld,))
+$(eval $(call declare-test-test-target,Fibonacci,10))
+# TODO: enable this when manyArgs is passing (and remove compiler_test IntMath test cases)
+#$(eval $(call declare-test-test-target,IntMath,))
+$(eval $(call declare-test-test-target,ExceptionTest,))
+
+########################################################################
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index c1e666e..fd8a0ec 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -163,25 +163,11 @@
}
}
-TEST_F(CompilerTest, NullCheckElimination1) {
- CompileDirectMethod(NULL, "java.lang.Object", "<init>", "()V");
- AssertStaticIntMethod(2054, LoadDex("ExceptionTest"), "ExceptionTest", "nullCheckTestNoThrow", "(I)I", 1976);
-}
-
-TEST_F(CompilerTest, DISABLED_NullCheckElimination2) {
- CompileDirectMethod(NULL, "java.lang.Object", "<init>", "()V");
- AssertStaticIntMethod(2057, LoadDex("ExceptionTest"), "ExceptionTest", "nullCheckTestThrow", "(I)I", 1976);
-}
-
TEST_F(CompilerTest, ByBillion) {
CompileDirectMethod(NULL, "java.lang.Object", "<init>", "()V");
AssertStaticLongMethod(123, LoadDex("IntMath"), "IntMath", "divideLongByBillion", "(J)J", 123000000000LL);
}
-TEST_F(CompilerTest, BasicCodegen) {
- AssertStaticIntMethod(55, LoadDex("Fibonacci"), "Fibonacci", "fibonacci", "(I)I", 10);
-}
-
TEST_F(CompilerTest, DISABLED_AbstractMethodErrorStub) {
const ClassLoader* class_loader = LoadDex("AbstractMethod");
EnsureCompiled(class_loader, "AbstractMethod", "callme", "()V", true);
diff --git a/test/ExceptionTest/ExceptionTest.java b/test/ExceptionTest/ExceptionTest.java
index 13ef058..973e9e9 100644
--- a/test/ExceptionTest/ExceptionTest.java
+++ b/test/ExceptionTest/ExceptionTest.java
@@ -139,6 +139,7 @@
public static void main(String[] args) {
+ boolean failure = false;
int res;
res = nullCheckTestNoThrow(1976);
@@ -146,13 +147,18 @@
System.out.println("nullCheckTestNoThrow PASSED");
} else {
System.out.println("nullCheckTestNoThrow FAILED: " + res);
+ failure = true;
}
+if (false) { // TODO: enable this test when passing
res = nullCheckTestThrow(1976);
if (res == 2057) {
- System.out.println("nullCheckTestNoThrow PASSED");
+ System.out.println("nullCheckTestThrow PASSED");
} else {
- System.out.println("nullCheckTestNoThrow FAILED: " + res);
+ System.out.println("nullCheckTestThrow FAILED: " + res);
+ failure = true;
}
+}
+ System.exit(failure ? 1 : 0);
}
}
diff --git a/test/IntMath/IntMath.java b/test/IntMath/IntMath.java
index bffa894..2c4510a 100644
--- a/test/IntMath/IntMath.java
+++ b/test/IntMath/IntMath.java
@@ -91,7 +91,7 @@
return x * 2;
} else {
return x;
- }
+ }
}
static int constStringTest(int x) {
@@ -692,12 +692,12 @@
}
static int throwAndCatch() {
- try {
- throwNullPointerException();
- return 1;
- } catch (NullPointerException npe) {
- return 0;
- }
+ try {
+ throwNullPointerException();
+ return 1;
+ } catch (NullPointerException npe) {
+ return 0;
+ }
}
static int manyArgs(int a0, long a1, int a2, long a3, int a4, long a5,
@@ -768,6 +768,7 @@
}
public static void main(String[] args) {
+ boolean failure = false;
int res;
long lres;
@@ -776,60 +777,70 @@
System.out.println("divideLongByBillion PASSED");
} else {
System.out.println("divideLongByBillion FAILED: " + lres);
+ failure = true;
}
res = unopTest(38);
if (res == 37) {
System.out.println("unopTest PASSED");
} else {
System.out.println("unopTest FAILED: " + res);
+ failure = true;
}
res = shiftTest1();
if (res == 0) {
System.out.println("shiftTest1 PASSED");
} else {
System.out.println("shiftTest1 FAILED: " + res);
+ failure = true;
}
res = shiftTest2();
if (res == 0) {
System.out.println("shiftTest2 PASSED");
} else {
System.out.println("shiftTest2 FAILED: " + res);
+ failure = true;
}
res = unsignedShiftTest();
if (res == 0) {
System.out.println("unsignedShiftTest PASSED");
} else {
System.out.println("unsignedShiftTest FAILED: " + res);
+ failure = true;
}
res = convTest();
if (res == 0) {
System.out.println("convTest PASSED");
} else {
System.out.println("convTest FAILED: " + res);
+ failure = true;
}
res = charSubTest();
if (res == 0) {
System.out.println("charSubTest PASSED");
} else {
System.out.println("charSubTest FAILED: " + res);
+ failure = true;
}
res = intOperTest(70000, -3);
if (res == 0) {
System.out.println("intOperTest PASSED");
} else {
System.out.println("intOperTest FAILED: " + res);
+ failure = true;
}
res = longOperTest(70000000000L, -3L);
if (res == 0) {
System.out.println("longOperTest PASSED");
} else {
System.out.println("longOperTest FAILED: " + res);
+ failure = true;
}
lres = longShiftTest(0xd5aa96deff00aa01L, 16);
if (lres == 0x96deff00aa010000L) {
System.out.println("longShiftTest PASSED");
} else {
System.out.println("longShiftTest FAILED: " + res);
+ failure = true;
}
res = switchTest(1);
@@ -837,6 +848,7 @@
System.out.println("switchTest PASSED");
} else {
System.out.println("switchTest FAILED: " + res);
+ failure = true;
}
res = testIntCompare(-5, 4, 4, 0);
@@ -844,6 +856,7 @@
System.out.println("testIntCompare PASSED");
} else {
System.out.println("testIntCompare FAILED: " + res);
+ failure = true;
}
res = testLongCompare(-5L, -4294967287L, 4L, 8L);
@@ -851,6 +864,7 @@
System.out.println("testLongCompare PASSED");
} else {
System.out.println("testLongCompare FAILED: " + res);
+ failure = true;
}
res = testFloatCompare(-5.0f, 4.0f, 4.0f, (1.0f/0.0f) / (1.0f/0.0f));
@@ -858,6 +872,7 @@
System.out.println("testFloatCompare PASSED");
} else {
System.out.println("testFloatCompare FAILED: " + res);
+ failure = true;
}
res = testDoubleCompare(-5.0, 4.0, 4.0, (1.0/0.0) / (1.0/0.0));
@@ -865,6 +880,7 @@
System.out.println("testDoubleCompare PASSED");
} else {
System.out.println("testDoubleCompare FAILED: " + res);
+ failure = true;
}
res = fibonacci(10);
@@ -872,13 +888,15 @@
System.out.println("fibonacci PASSED");
} else {
System.out.println("fibonacci FAILED: " + res);
+ failure = true;
}
res = throwAndCatch();
if (res == 0) {
- System.out.println("throwAndCatch PASSED");
+ System.out.println("throwAndCatch PASSED");
} else {
- System.out.println("throwAndCatch FAILED: " + res);
+ System.out.println("throwAndCatch FAILED: " + res);
+ failure = true;
}
res = manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0,
@@ -888,6 +906,7 @@
System.out.println("manyArgs PASSED");
} else {
System.out.println("manyArgs FAILED: " + res);
+ failure = true;
}
res = staticCall(3);
@@ -895,6 +914,7 @@
System.out.println("virtualCall PASSED");
} else {
System.out.println("virtualCall FAILED: " + res);
+ failure = true;
}
res = testIGetPut(111);
@@ -902,6 +922,7 @@
System.out.println("testGetPut PASSED");
} else {
System.out.println("testGetPut FAILED: " + res);
+ failure = true;
}
res = staticFieldTest(404);
@@ -909,6 +930,7 @@
System.out.println("staticFieldTest PASSED");
} else {
System.out.println("staticFieldTest FAILED: " + res);
+ failure = true;
}
res = catchBlock(1000);
@@ -916,6 +938,7 @@
System.out.println("catchBlock PASSED");
} else {
System.out.println("catchBlock FAILED: " + res);
+ failure = true;
}
res = catchBlockNoThrow(1000);
@@ -923,6 +946,7 @@
System.out.println("catchBlockNoThrow PASSED");
} else {
System.out.println("catchBlockNoThrow FAILED: " + res);
+ failure = true;
}
res = superTest(4141);
@@ -930,6 +954,7 @@
System.out.println("superTest PASSED");
} else {
System.out.println("superTest FAILED: " + res);
+ failure = true;
}
res = constStringTest(10);
@@ -937,6 +962,7 @@
System.out.println("stringTest PASSED");
} else {
System.out.println("stringTest FAILED: " + res);
+ failure = true;
}
res = instanceTest(10);
@@ -944,7 +970,10 @@
System.out.println("instanceTest PASSED");
} else {
System.out.println("instanceTest FAILED: " + res);
+ failure = true;
}
+
+ System.exit(failure ? 1 : 0);
}
}