summaryrefslogtreecommitdiffstats
path: root/test/116-nodex2oat
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-07-22 10:48:00 +0100
committerNicolas Geoffray <ngeoffray@google.com>2014-08-13 18:01:51 +0100
commit4fcdc94d22a4608e355aa8df36240181149d10e8 (patch)
treecb600df7e9b585720c03a08b10509151aa96d5dd /test/116-nodex2oat
parentb66252112d45fd24eab85122fa8902afd1324542 (diff)
downloadart-4fcdc94d22a4608e355aa8df36240181149d10e8.tar.gz
art-4fcdc94d22a4608e355aa8df36240181149d10e8.tar.bz2
art-4fcdc94d22a4608e355aa8df36240181149d10e8.zip
Execute an application even when dex2oat crashes.
Bug: 17000769 Change-Id: Iffeb582862a5e794b6c7364c7ec2368cfd0f2214
Diffstat (limited to 'test/116-nodex2oat')
-rw-r--r--test/116-nodex2oat/expected.txt6
-rw-r--r--test/116-nodex2oat/info.txt1
-rw-r--r--test/116-nodex2oat/nodex2oat.cc45
-rwxr-xr-xtest/116-nodex2oat/run30
-rw-r--r--test/116-nodex2oat/src/Main.java36
5 files changed, 118 insertions, 0 deletions
diff --git a/test/116-nodex2oat/expected.txt b/test/116-nodex2oat/expected.txt
new file mode 100644
index 0000000000..05b1c2f387
--- /dev/null
+++ b/test/116-nodex2oat/expected.txt
@@ -0,0 +1,6 @@
+Run -Xnodex2oat
+Has oat is false, is dex2oat enabled is false.
+Run -Xdex2oat
+Has oat is true, is dex2oat enabled is true.
+Run default
+Has oat is true, is dex2oat enabled is true.
diff --git a/test/116-nodex2oat/info.txt b/test/116-nodex2oat/info.txt
new file mode 100644
index 0000000000..f063d9f12e
--- /dev/null
+++ b/test/116-nodex2oat/info.txt
@@ -0,0 +1 @@
+Test that disables dex2oat'ing the application.
diff --git a/test/116-nodex2oat/nodex2oat.cc b/test/116-nodex2oat/nodex2oat.cc
new file mode 100644
index 0000000000..4326db0e54
--- /dev/null
+++ b/test/116-nodex2oat/nodex2oat.cc
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include "class_linker.h"
+#include "dex_file-inl.h"
+#include "mirror/class-inl.h"
+#include "scoped_thread_state_change.h"
+#include "thread.h"
+
+namespace art {
+
+class NoDex2OatTest {
+ public:
+ static bool hasOat(jclass cls) {
+ ScopedObjectAccess soa(Thread::Current());
+ mirror::Class* klass = soa.Decode<mirror::Class*>(cls);
+ const DexFile& dex_file = klass->GetDexFile();
+ const OatFile* oat_file =
+ Runtime::Current()->GetClassLinker()->FindOpenedOatFileForDexFile(dex_file);
+ return oat_file != nullptr;
+ }
+};
+
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasOat(JNIEnv*, jclass cls) {
+ return NoDex2OatTest::hasOat(cls);
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_isDex2OatEnabled(JNIEnv*, jclass cls) {
+ return Runtime::Current()->IsDex2OatEnabled();
+}
+
+} // namespace art
diff --git a/test/116-nodex2oat/run b/test/116-nodex2oat/run
new file mode 100755
index 0000000000..5ffeecdbb1
--- /dev/null
+++ b/test/116-nodex2oat/run
@@ -0,0 +1,30 @@
+#!/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.
+
+# Remove prebuild from the flags, this test is for testing not having oat files.
+flags="${@/--prebuild/}"
+
+# Make sure we can run without an oat file,
+echo "Run -Xnodex2oat"
+${RUN} ${flags} --runtime-option -Xnodex2oat
+
+# Make sure we can run with the oat file.
+echo "Run -Xdex2oat"
+${RUN} ${flags} --runtime-option -Xdex2oat
+
+# Make sure we can run with the default settings.
+echo "Run default"
+${RUN} ${flags}
diff --git a/test/116-nodex2oat/src/Main.java b/test/116-nodex2oat/src/Main.java
new file mode 100644
index 0000000000..37ac9d5b78
--- /dev/null
+++ b/test/116-nodex2oat/src/Main.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+public class Main {
+ public static void main(String[] args) {
+ System.out.println(
+ "Has oat is " + hasOat() + ", is dex2oat enabled is " + isDex2OatEnabled() + ".");
+
+ if (hasOat() && !isDex2OatEnabled()) {
+ throw new Error("Application with dex2oat disabled runs with an oat file");
+ } else if (!hasOat() && isDex2OatEnabled()) {
+ throw new Error("Application with dex2oat enabled runs without an oat file");
+ }
+ }
+
+ static {
+ System.loadLibrary("arttest");
+ }
+
+ private native static boolean hasOat();
+
+ private native static boolean isDex2OatEnabled();
+}