diff options
| -rw-r--r-- | test/117-nopatchoat/nopatchoat.cc | 12 | ||||
| -rwxr-xr-x | test/117-nopatchoat/run | 2 | ||||
| -rw-r--r-- | test/117-nopatchoat/src/Main.java | 10 |
3 files changed, 20 insertions, 4 deletions
diff --git a/test/117-nopatchoat/nopatchoat.cc b/test/117-nopatchoat/nopatchoat.cc index 7eac412681..3e533ad62e 100644 --- a/test/117-nopatchoat/nopatchoat.cc +++ b/test/117-nopatchoat/nopatchoat.cc @@ -16,7 +16,10 @@ #include "class_linker.h" #include "dex_file-inl.h" +#include "gc/heap.h" +#include "gc/space/image_space.h" #include "mirror/class-inl.h" +#include "runtime.h" #include "scoped_thread_state_change.h" #include "thread.h" @@ -31,6 +34,11 @@ class NoPatchoatTest { return dex_file.GetOatDexFile(); } + static bool isRelocationDeltaZero() { + gc::space::ImageSpace* space = Runtime::Current()->GetHeap()->GetImageSpace(); + return space != nullptr && space->GetImageHeader().GetPatchDelta() == 0; + } + static bool hasExecutableOat(jclass cls) { const OatFile::OatDexFile* oat_dex_file = getOatDexFile(cls); @@ -49,6 +57,10 @@ class NoPatchoatTest { } }; +extern "C" JNIEXPORT jboolean JNICALL Java_Main_isRelocationDeltaZero(JNIEnv*, jclass) { + return NoPatchoatTest::isRelocationDeltaZero(); +} + extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasExecutableOat(JNIEnv*, jclass cls) { return NoPatchoatTest::hasExecutableOat(cls); } diff --git a/test/117-nopatchoat/run b/test/117-nopatchoat/run index c749c74345..c634900218 100755 --- a/test/117-nopatchoat/run +++ b/test/117-nopatchoat/run @@ -36,8 +36,6 @@ fi # Make sure we can run without relocation echo "Run without dex2oat/patchoat" -# /bin/false is actually not even there for either, so the exec will fail. -# Unfortunately there is no equivalent to /bin/false in android. ${RUN} ${flags} --runtime-option -Xnodex2oat # Make sure we can run with the oat file. diff --git a/test/117-nopatchoat/src/Main.java b/test/117-nopatchoat/src/Main.java index 223e12084d..5cca309847 100644 --- a/test/117-nopatchoat/src/Main.java +++ b/test/117-nopatchoat/src/Main.java @@ -18,9 +18,13 @@ public class Main { public static void main(String[] args) { System.loadLibrary(args[0]); + // With a relocationDelta of 0, the runtime has no way to determine if the oat file in + // ANDROID_DATA has been relocated, since a non-relocated oat file always has a 0 delta. + // Hitting this condition should be rare and ideally we would prevent it from happening but + // there is no way to do so without major changes to the run-test framework. boolean executable_correct = (isPic() ? - hasExecutableOat() == true : - hasExecutableOat() == isDex2OatEnabled()); + hasExecutableOat() == true : + hasExecutableOat() == (isDex2OatEnabled() || isRelocationDeltaZero())); System.out.println( "dex2oat & patchoat are " + ((isDex2OatEnabled()) ? "enabled" : "disabled") + @@ -50,4 +54,6 @@ public class Main { private native static boolean hasOat(); private native static boolean hasExecutableOat(); + + private native static boolean isRelocationDeltaZero(); } |