summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/706-checker-scheduler/expected.txt0
-rw-r--r--test/706-checker-scheduler/info.txt1
-rw-r--r--test/706-checker-scheduler/src/Main.java82
-rw-r--r--test/934-load-transform/src/Main.java4
-rw-r--r--test/935-non-retransformable/src-ex/TestMain.java21
-rw-r--r--test/935-non-retransformable/src/Main.java5
-rw-r--r--test/938-load-transform-bcp/src/Main.java3
-rw-r--r--test/Android.run-test.mk5
-rw-r--r--test/ti-agent/common_helper.cc26
9 files changed, 131 insertions, 16 deletions
diff --git a/test/706-checker-scheduler/expected.txt b/test/706-checker-scheduler/expected.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/706-checker-scheduler/expected.txt
diff --git a/test/706-checker-scheduler/info.txt b/test/706-checker-scheduler/info.txt
new file mode 100644
index 0000000000..b4ad9b4378
--- /dev/null
+++ b/test/706-checker-scheduler/info.txt
@@ -0,0 +1 @@
+Tests for HInstruction scheduler.
diff --git a/test/706-checker-scheduler/src/Main.java b/test/706-checker-scheduler/src/Main.java
new file mode 100644
index 0000000000..1721e4294e
--- /dev/null
+++ b/test/706-checker-scheduler/src/Main.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 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.
+ */
+
+public class Main {
+
+ static int static_variable = 0;
+
+ /// CHECK-START-ARM64: int Main.arrayAccess() scheduler (before)
+ /// CHECK: <<Const1:i\d+>> IntConstant 1
+ /// CHECK: <<i0:i\d+>> Phi
+ /// CHECK: <<res0:i\d+>> Phi
+ /// CHECK: <<Array:i\d+>> IntermediateAddress
+ /// CHECK: <<ArrayGet1:i\d+>> ArrayGet [<<Array>>,<<i0>>]
+ /// CHECK: <<res1:i\d+>> Add [<<res0>>,<<ArrayGet1>>]
+ /// CHECK: <<i1:i\d+>> Add [<<i0>>,<<Const1>>]
+ /// CHECK: <<ArrayGet2:i\d+>> ArrayGet [<<Array>>,<<i1>>]
+ /// CHECK: Add [<<res1>>,<<ArrayGet2>>]
+
+ /// CHECK-START-ARM64: int Main.arrayAccess() scheduler (after)
+ /// CHECK: <<Const1:i\d+>> IntConstant 1
+ /// CHECK: <<i0:i\d+>> Phi
+ /// CHECK: <<res0:i\d+>> Phi
+ /// CHECK: <<Array:i\d+>> IntermediateAddress
+ /// CHECK: <<ArrayGet1:i\d+>> ArrayGet [<<Array>>,<<i0>>]
+ /// CHECK: <<i1:i\d+>> Add [<<i0>>,<<Const1>>]
+ /// CHECK: <<ArrayGet2:i\d+>> ArrayGet [<<Array>>,<<i1>>]
+ /// CHECK: <<res1:i\d+>> Add [<<res0>>,<<ArrayGet1>>]
+ /// CHECK: Add [<<res1>>,<<ArrayGet2>>]
+
+ public static int arrayAccess() {
+ int res = 0;
+ int [] array = new int[10];
+ for (int i = 0; i < 9; i++) {
+ res += array[i];
+ res += array[i + 1];
+ }
+ return res;
+ }
+
+ /// CHECK-START-ARM64: int Main.intDiv(int) scheduler (before)
+ /// CHECK: Sub
+ /// CHECK: DivZeroCheck
+ /// CHECK: Div
+ /// CHECK: StaticFieldSet
+
+ /// CHECK-START-ARM64: int Main.intDiv(int) scheduler (after)
+ /// CHECK: Sub
+ /// CHECK-NOT: StaticFieldSet
+ /// CHECK: DivZeroCheck
+ /// CHECK-NOT: Sub
+ /// CHECK: Div
+ public static int intDiv(int arg) {
+ int res = 0;
+ int tmp = arg;
+ for (int i = 1; i < arg; i++) {
+ tmp -= i;
+ res = res / i; // div-zero check barrier.
+ static_variable++;
+ }
+ res += tmp;
+ return res;
+ }
+
+ public static void main(String[] args) {
+ if ((arrayAccess() + intDiv(10)) != -35) {
+ System.out.println("FAIL");
+ }
+ }
+}
diff --git a/test/934-load-transform/src/Main.java b/test/934-load-transform/src/Main.java
index 3bd913bfe0..de312b03da 100644
--- a/test/934-load-transform/src/Main.java
+++ b/test/934-load-transform/src/Main.java
@@ -66,6 +66,9 @@ class Main {
}
public static void main(String[] args) {
+ // Don't pop transformations. Make sure that even if 2 threads race to define the class both
+ // will get the same result.
+ setPopRetransformations(false);
addCommonTransformationResult("Transform", CLASS_BYTES, DEX_BYTES);
enableCommonRetransformation(true);
try {
@@ -83,6 +86,7 @@ class Main {
}
}
+ private static native void setPopRetransformations(boolean should_pop);
// Transforms the class
private static native void enableCommonRetransformation(boolean enable);
private static native void addCommonTransformationResult(String target_name,
diff --git a/test/935-non-retransformable/src-ex/TestMain.java b/test/935-non-retransformable/src-ex/TestMain.java
index aebcdee851..d412fba37a 100644
--- a/test/935-non-retransformable/src-ex/TestMain.java
+++ b/test/935-non-retransformable/src-ex/TestMain.java
@@ -17,19 +17,14 @@
import java.lang.reflect.Method;
public class TestMain {
- public static void runTest() {
+ public static void runTest() throws Exception {
Transform t = new Transform();
- try {
- // Call functions with reflection. Since the sayGoodbye function does not exist in the
- // LTransform; when we compile this for the first time we need to use reflection.
- Method hi = Transform.class.getMethod("sayHi");
- Method bye = Transform.class.getMethod("sayGoodbye");
- hi.invoke(t);
- t.sayHi();
- bye.invoke(t);
- } catch (Exception e) {
- System.out.println("Unexpected error occured! " + e.toString());
- e.printStackTrace();
- }
+ // Call functions with reflection. Since the sayGoodbye function does not exist in the
+ // LTransform; when we compile this for the first time we need to use reflection.
+ Method hi = Transform.class.getMethod("sayHi");
+ Method bye = Transform.class.getMethod("sayGoodbye");
+ hi.invoke(t);
+ t.sayHi();
+ bye.invoke(t);
}
}
diff --git a/test/935-non-retransformable/src/Main.java b/test/935-non-retransformable/src/Main.java
index 0d103ab86d..82ba197b7e 100644
--- a/test/935-non-retransformable/src/Main.java
+++ b/test/935-non-retransformable/src/Main.java
@@ -74,6 +74,7 @@ class Main {
}
public static void main(String[] args) {
+ setPopRetransformations(false);
addCommonTransformationResult("Transform", CLASS_BYTES, DEX_BYTES);
enableCommonRetransformation(true);
try {
@@ -86,6 +87,8 @@ class Main {
Method run_test = klass.getMethod("runTest");
run_test.invoke(null);
+ // Remove the original transformation. It has been used by now.
+ popTransformationFor("Transform");
// Make sure we don't get called for transformation again.
addCommonTransformationResult("Transform", new byte[0], new byte[0]);
doCommonClassRetransformation(new_loader.loadClass("Transform"));
@@ -102,4 +105,6 @@ class Main {
private static native void addCommonTransformationResult(String target_name,
byte[] class_bytes,
byte[] dex_bytes);
+ private static native void setPopRetransformations(boolean should_pop);
+ private static native void popTransformationFor(String target_name);
}
diff --git a/test/938-load-transform-bcp/src/Main.java b/test/938-load-transform-bcp/src/Main.java
index 13bc5da461..548489939e 100644
--- a/test/938-load-transform-bcp/src/Main.java
+++ b/test/938-load-transform-bcp/src/Main.java
@@ -96,7 +96,7 @@ class Main {
}
public static void main(String[] args) {
- // TODO WHAT TO TRANSFORM
+ setPopRetransformations(false);
addCommonTransformationResult("java/util/OptionalLong", CLASS_BYTES, DEX_BYTES);
enableCommonRetransformation(true);
try {
@@ -114,6 +114,7 @@ class Main {
}
}
+ private static native void setPopRetransformations(boolean should_pop);
// Transforms the class
private static native void enableCommonRetransformation(boolean enable);
private static native void addCommonTransformationResult(String target_name,
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index 1b4f19509f..742353da46 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -439,13 +439,14 @@ TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
629-vdex-speed
# This test fails without an image.
-# 018, 961, 964 often time out. b/34369284
+# 018, 961, 964, 968 often time out. b/34369284
TEST_ART_BROKEN_NO_IMAGE_RUN_TESTS := \
137-cfi \
138-duplicate-classes-check \
018-stack-overflow \
961-default-iface-resolution-gen \
- 964-default-iface-init
+ 964-default-iface-init \
+ 968-default-partial-compile-gen \
ifneq (,$(filter no-dex2oat,$(PREBUILD_TYPES)))
ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),no-dex2oat, \
diff --git a/test/ti-agent/common_helper.cc b/test/ti-agent/common_helper.cc
index ed82bb04cf..ea6359e5e0 100644
--- a/test/ti-agent/common_helper.cc
+++ b/test/ti-agent/common_helper.cc
@@ -210,6 +210,7 @@ struct CommonTransformationResult {
// Map from class name to transformation result.
std::map<std::string, std::deque<CommonTransformationResult>> gTransformations;
+bool gPopTransformations = true;
extern "C" JNIEXPORT void JNICALL Java_Main_addCommonTransformationResult(JNIEnv* env,
jclass,
@@ -266,7 +267,32 @@ void JNICALL CommonClassFileLoadHookRetransformable(jvmtiEnv* jvmti_env,
memcpy(new_data, desired_array.data(), desired_array.size());
*new_class_data = new_data;
*new_class_data_len = desired_array.size();
+ if (gPopTransformations) {
+ gTransformations[name_str].pop_front();
+ }
+ }
+}
+
+extern "C" JNIEXPORT void Java_Main_setPopRetransformations(JNIEnv*,
+ jclass,
+ jboolean enable) {
+ gPopTransformations = enable;
+}
+
+extern "C" JNIEXPORT void Java_Main_popTransformationFor(JNIEnv* env,
+ jclass,
+ jstring class_name) {
+ const char* name_chrs = env->GetStringUTFChars(class_name, nullptr);
+ std::string name_str(name_chrs);
+ env->ReleaseStringUTFChars(class_name, name_chrs);
+ if (gTransformations.find(name_str) != gTransformations.end() &&
+ gTransformations[name_str].size() > 0) {
gTransformations[name_str].pop_front();
+ } else {
+ std::stringstream err;
+ err << "No transformations found for class " << name_str;
+ std::string message = err.str();
+ env->ThrowNew(env->FindClass("java/lang/Exception"), message.c_str());
}
}