diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/457-regs/expected.txt | 0 | ||||
| -rw-r--r-- | test/457-regs/info.txt | 1 | ||||
| -rw-r--r-- | test/457-regs/regs_jni.cc | 150 | ||||
| -rw-r--r-- | test/457-regs/smali/PhiLiveness.smali | 82 | ||||
| -rw-r--r-- | test/457-regs/src/Main.java | 45 | ||||
| -rw-r--r-- | test/703-floating-point-div/src/Main.java | 14 | ||||
| -rw-r--r-- | test/Android.libarttest.mk | 3 | ||||
| -rw-r--r-- | test/Android.run-test.mk | 16 | ||||
| -rw-r--r-- | test/MultiDex/Main.java | 22 | ||||
| -rw-r--r-- | test/MultiDex/Second.java | 21 | ||||
| -rw-r--r-- | test/MultiDex/main.list | 1 |
11 files changed, 349 insertions, 6 deletions
diff --git a/test/457-regs/expected.txt b/test/457-regs/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/457-regs/expected.txt diff --git a/test/457-regs/info.txt b/test/457-regs/info.txt new file mode 100644 index 0000000000..d9500030bb --- /dev/null +++ b/test/457-regs/info.txt @@ -0,0 +1 @@ +Tests debuggability of DEX registers. diff --git a/test/457-regs/regs_jni.cc b/test/457-regs/regs_jni.cc new file mode 100644 index 0000000000..ce701e898b --- /dev/null +++ b/test/457-regs/regs_jni.cc @@ -0,0 +1,150 @@ +/* + * 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. + */ + +#include "arch/context.h" +#include "jni.h" +#include "mirror/art_method-inl.h" +#include "scoped_thread_state_change.h" +#include "stack.h" +#include "thread.h" + +namespace art { + +namespace { + +class TestVisitor : public StackVisitor { + public: + TestVisitor(Thread* thread, Context* context) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) + : StackVisitor(thread, context) {} + + bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtMethod* m = GetMethod(); + std::string m_name(m->GetName()); + + if (m_name.compare("mergeOk") == 0) { + uint32_t value = 0; + + CHECK(GetVReg(m, 0, kIntVReg, &value)); + CHECK_EQ(value, 0u); + + CHECK(GetVReg(m, 1, kIntVReg, &value)); + CHECK_EQ(value, 1u); + + CHECK(GetVReg(m, 2, kIntVReg, &value)); + CHECK_EQ(value, 2u); + + CHECK(GetVReg(m, 3, kIntVReg, &value)); + CHECK_EQ(value, 1u); + + CHECK(GetVReg(m, 4, kIntVReg, &value)); + CHECK_EQ(value, 2u); + did_check_ = true; + } else if (m_name.compare("mergeNotOk") == 0) { + uint32_t value = 0; + + CHECK(GetVReg(m, 0, kIntVReg, &value)); + CHECK_EQ(value, 0u); + + CHECK(GetVReg(m, 1, kIntVReg, &value)); + CHECK_EQ(value, 1u); + + bool success = GetVReg(m, 2, kIntVReg, &value); + if (m->IsOptimized(sizeof(void*))) CHECK(!success); + + CHECK(GetVReg(m, 3, kReferenceVReg, &value)); + CHECK_EQ(value, 1u); + + CHECK(GetVReg(m, 4, kFloatVReg, &value)); + uint32_t cast = bit_cast<float, uint32_t>(4.0f); + CHECK_EQ(value, cast); + did_check_ = true; + } else if (m_name.compare("phiEquivalent") == 0) { + uint32_t value = 0; + + CHECK(GetVReg(m, 0, kIntVReg, &value)); + // Quick doesn't like this one on x64. + CHECK_EQ(value, 0u); + + CHECK(GetVReg(m, 1, kIntVReg, &value)); + CHECK_EQ(value, 1u); + + CHECK(GetVReg(m, 2, kFloatVReg, &value)); + CHECK_EQ(value, 1u); + + did_check_ = true; + } else if (m_name.compare("mergeReferences") == 0) { + uint32_t value = 0; + + CHECK(GetVReg(m, 0, kIntVReg, &value)); + CHECK_EQ(value, 0u); + + CHECK(GetVReg(m, 1, kIntVReg, &value)); + CHECK_EQ(value, 1u); + + CHECK(GetVReg(m, 2, kReferenceVReg, &value)); + CHECK_EQ(value, 0u); + + CHECK(GetVReg(m, 3, kReferenceVReg, &value)); + CHECK_NE(value, 0u); + + did_check_ = true; + } else if (m_name.compare("phiAllEquivalents") == 0) { + uint32_t value = 0; + + CHECK(GetVReg(m, 0, kIntVReg, &value)); + CHECK_EQ(value, 0u); + + CHECK(GetVReg(m, 1, kIntVReg, &value)); + CHECK_EQ(value, 1u); + + CHECK(GetVReg(m, 2, kReferenceVReg, &value)); + CHECK_EQ(value, 0u); + + did_check_ = true; + } + + return true; + } + + bool did_check_ = false; +}; + +extern "C" JNIEXPORT void JNICALL Java_PhiLiveness_regsNativeCall( + JNIEnv*, jclass value ATTRIBUTE_UNUSED) { + ScopedObjectAccess soa(Thread::Current()); + std::unique_ptr<Context> context(Context::Create()); + TestVisitor visitor(soa.Self(), context.get()); + visitor.WalkStack(); + CHECK(visitor.did_check_); +} + +extern "C" JNIEXPORT void JNICALL Java_PhiLiveness_regsNativeCallWithParameters( + JNIEnv*, jclass value ATTRIBUTE_UNUSED, jobject main, jint int_value, jfloat float_value) { + ScopedObjectAccess soa(Thread::Current()); + std::unique_ptr<Context> context(Context::Create()); + CHECK(soa.Decode<mirror::Object*>(main) == nullptr); + CHECK_EQ(int_value, 0); + int32_t cast = bit_cast<float, int32_t>(float_value); + CHECK_EQ(cast, 0); + TestVisitor visitor(soa.Self(), context.get()); + visitor.WalkStack(); + CHECK(visitor.did_check_); +} + +} // namespace + +} // namespace art diff --git a/test/457-regs/smali/PhiLiveness.smali b/test/457-regs/smali/PhiLiveness.smali new file mode 100644 index 0000000000..c8a6773d44 --- /dev/null +++ b/test/457-regs/smali/PhiLiveness.smali @@ -0,0 +1,82 @@ +# 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. + +.class public LPhiLiveness; + +.super Ljava/lang/Object; + +.method public static mergeOk(ZB)V + .registers 5 + const/4 v0, 0x0 + const/4 v1, 0x1 + move v2, v3 + if-eq v1, v0, :else + move v2, v4 + :else + invoke-static {}, LPhiLiveness;->regsNativeCall()V + return-void +.end method + +.method public static mergeNotOk(ZF)V + .registers 5 + const/4 v0, 0x0 + const/4 v1, 0x1 + move v2, v3 + if-eq v1, v0, :else + move v2, v4 + :else + invoke-static {}, LPhiLiveness;->regsNativeCall()V + return-void +.end method + +.method public static mergeReferences(LMain;)V + .registers 4 + const/4 v0, 0x0 + const/4 v1, 0x1 + move-object v2, p0 + if-eq v1, v0, :else + move v2, v0 + :else + invoke-static {}, LPhiLiveness;->regsNativeCall()V + return-void +.end method + +.method public static phiEquivalent()F + .registers 5 + const/4 v0, 0x0 + const/4 v1, 0x1 + move v2, v0 + if-eq v1, v0, :else + move v2, v1 + :else + invoke-static {}, LPhiLiveness;->regsNativeCall()V + return v2 +.end method + +.method public static phiAllEquivalents(LMain;)V + .registers 4 + const/4 v0, 0x0 + const/4 v1, 0x1 + move v2, v0 + if-eq v1, v0, :else + move v2, v0 + :else + invoke-static {v2, v2, v2}, LPhiLiveness;->regsNativeCallWithParameters(LMain;IF)V + return-void +.end method + +.method public static native regsNativeCall()V +.end method +.method public static native regsNativeCallWithParameters(LMain;IF)V +.end method diff --git a/test/457-regs/src/Main.java b/test/457-regs/src/Main.java new file mode 100644 index 0000000000..0d82033195 --- /dev/null +++ b/test/457-regs/src/Main.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +import java.lang.reflect.Method; + +public class Main { + + // Workaround for b/18051191. + class InnerClass {} + + public static void main(String[] args) throws Exception { + Class<?> c = Class.forName("PhiLiveness"); + Method m = c.getMethod("mergeOk", boolean.class, byte.class); + m.invoke(null, new Boolean(true), new Byte((byte)2)); + + m = c.getMethod("mergeNotOk", boolean.class, float.class); + m.invoke(null, new Boolean(true), new Float(4.0f)); + + m = c.getMethod("mergeReferences", Main.class); + m.invoke(null, new Main()); + + m = c.getMethod("phiEquivalent"); + m.invoke(null); + + m = c.getMethod("phiAllEquivalents", Main.class); + m.invoke(null, new Main()); + } + + static { + System.loadLibrary("arttest"); + } +} diff --git a/test/703-floating-point-div/src/Main.java b/test/703-floating-point-div/src/Main.java index 9990a545f4..23037022fb 100644 --- a/test/703-floating-point-div/src/Main.java +++ b/test/703-floating-point-div/src/Main.java @@ -41,7 +41,7 @@ public class Main { double d7 = -0.0; double d8 = Double.MAX_VALUE; double d9 = Double.MIN_VALUE; - double d0 = Double.NaN; + double dNaN = Double.NaN; expectEquals(Double.doubleToRawLongBits(dPi/d1), 0x1921fb54442d18L); expectEquals(Double.doubleToRawLongBits(dPi/d2), 0xbff921fb54442d18L); @@ -53,7 +53,10 @@ public class Main { expectEquals(Double.doubleToRawLongBits(dPi/d8), 0xc90fdaa22168cL); expectEquals(Double.doubleToRawLongBits(dPi/d9), 0x7ff0000000000000L); - expectEquals(Double.doubleToRawLongBits(dPi/d0), 0x7ff8000000000000L); + + // Not-a-number computation. Use doubleToLongBits to get canonical NaN. The literal value + // is the canonical NaN (see Double.doubleToLongBits). + expectEquals(Double.doubleToLongBits(dPi/dNaN), 0x7ff8000000000000L); } public static void divFloatTest() { @@ -66,7 +69,7 @@ public class Main { float f7 = -0.0f; float f8 = Float.MAX_VALUE; float f9 = Float.MIN_VALUE; - float f0 = Float.NaN; + float fNaN = Float.NaN; expectEquals(Float.floatToRawIntBits(fPi/f1), 0xc90fdb); expectEquals(Float.floatToRawIntBits(fPi/f2), 0xbfc90fdb); @@ -78,7 +81,10 @@ public class Main { expectEquals(Float.floatToRawIntBits(fPi/f8), 0x6487ee); expectEquals(Float.floatToRawIntBits(fPi/f9), 0x7f800000); - expectEquals(Float.floatToRawIntBits(fPi/f0), 0x7fc00000); + + // Not-a-number computation. Use floatToIntBits to get canonical NaN. The literal value + // is the canonical NaN (see Float.floatToIntBits). + expectEquals(Float.floatToIntBits(fPi/fNaN), 0x7fc00000); } public static void main(String[] args) { diff --git a/test/Android.libarttest.mk b/test/Android.libarttest.mk index 75c5d72f18..f4bab3f9fd 100644 --- a/test/Android.libarttest.mk +++ b/test/Android.libarttest.mk @@ -29,7 +29,8 @@ LIBARTTEST_COMMON_SRC_FILES := \ 117-nopatchoat/nopatchoat.cc \ 118-noimage-dex2oat/noimage-dex2oat.cc \ 454-get-vreg/get_vreg_jni.cc \ - 455-set-vreg/set_vreg_jni.cc + 455-set-vreg/set_vreg_jni.cc \ + 457-regs/regs_jni.cc ART_TARGET_LIBARTTEST_$(ART_PHONY_TEST_TARGET_SUFFIX) += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libarttest.so ifdef TARGET_2ND_ARCH diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk index 63d5984aed..b85ece8303 100644 --- a/test/Android.run-test.mk +++ b/test/Android.run-test.mk @@ -311,6 +311,7 @@ TEST_ART_BROKEN_NDEBUG_TESTS := \ 131-structural-change \ 454-get-vreg \ 455-set-vreg \ + 457-regs \ ifneq (,$(filter ndebug,$(RUN_TYPES))) ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),ndebug,$(PREBUILD_TYPES), \ @@ -321,7 +322,8 @@ endif TEST_ART_BROKEN_NDEBUG_TESTS := # Known broken tests for the default compiler (Quick). -TEST_ART_BROKEN_DEFAULT_RUN_TESTS := +TEST_ART_BROKEN_DEFAULT_RUN_TESTS := \ + 457-regs ifneq (,$(filter default,$(COMPILER_TYPES))) ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \ @@ -377,6 +379,18 @@ endif TEST_ART_BROKEN_OPTIMIZING_RUN_TESTS := +# Tests that should fail when the optimizing compiler compiles them non-debuggable. +TEST_ART_BROKEN_OPTIMIZING_NONDEBUGGABLE_RUN_TESTS := \ + 457-regs \ + +ifneq (,$(filter optimizing,$(COMPILER_TYPES))) + ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \ + optimizing,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \ + $(IMAGE_TYPES),$(PICTEST_TYPES),nondebuggable,$(TEST_ART_BROKEN_OPTIMIZING_NONDEBUGGABLE_RUN_TESTS),$(ALL_ADDRESS_SIZES)) +endif + +TEST_ART_BROKEN_OPTIMIZING_NONDEBUGGABLE_RUN_TESTS := + # Clear variables ahead of appending to them when defining tests. $(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=)) diff --git a/test/MultiDex/Main.java b/test/MultiDex/Main.java new file mode 100644 index 0000000000..659dba9af6 --- /dev/null +++ b/test/MultiDex/Main.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +class Main { + public static void main(String args[]) { + Second second = new Second(); + System.out.println(second.getSecond()); + } +} diff --git a/test/MultiDex/Second.java b/test/MultiDex/Second.java new file mode 100644 index 0000000000..540aedbb1a --- /dev/null +++ b/test/MultiDex/Second.java @@ -0,0 +1,21 @@ +/* + * 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. + */ + +class Second { + public String getSecond() { + return "I Second That."; + } +} diff --git a/test/MultiDex/main.list b/test/MultiDex/main.list new file mode 100644 index 0000000000..44ba78ead5 --- /dev/null +++ b/test/MultiDex/main.list @@ -0,0 +1 @@ +Main.class |