diff options
| author | 2018-03-15 22:29:24 +0000 | |
|---|---|---|
| committer | 2018-03-16 13:20:27 +0000 | |
| commit | 499b8f89e1c7cb096eca17740d238d40d63f9e85 (patch) | |
| tree | daf22ce943fb490e44e64f770c77bde219052327 | |
| parent | f4dc659183546a2ed7fe0ec5cacf0162a1655ec6 (diff) | |
Fix a few issues with 616-cha-unloading.
- Disable test on RI
- Disable test on trace
- Don't try N times for getting the allocation we want, do it
until we get it. We shouldn't get in an infinite loop. If
we do the harness will kill the test.
Test: 616-cha-unloading
bug: 73143991
(cherry picked from commit a3cd12412475049c51ff16369d8044cae2438d54)
Change-Id: I8d37dbcde472b19f63c7c692acea9e7d90f17d25
| -rw-r--r-- | test/616-cha-unloading/cha_unload.cc | 14 | ||||
| -rw-r--r-- | test/616-cha-unloading/expected.txt | 2 | ||||
| -rw-r--r-- | test/616-cha-unloading/src-art/Main.java | 12 | ||||
| -rw-r--r-- | test/knownfailures.json | 12 |
4 files changed, 22 insertions, 18 deletions
diff --git a/test/616-cha-unloading/cha_unload.cc b/test/616-cha-unloading/cha_unload.cc index 46ceac640b..4be3456e3d 100644 --- a/test/616-cha-unloading/cha_unload.cc +++ b/test/616-cha-unloading/cha_unload.cc @@ -37,20 +37,16 @@ extern "C" JNIEXPORT jlong JNICALL Java_Main_getArtMethod(JNIEnv* env, return static_cast<jlong>(reinterpret_cast<uintptr_t>(method)); } -extern "C" JNIEXPORT jboolean JNICALL Java_Main_tryReuseArenaOfMethod(JNIEnv*, - jclass, - jlong art_method, - jint tries_count) { +extern "C" JNIEXPORT void JNICALL Java_Main_reuseArenaOfMethod(JNIEnv*, + jclass, + jlong art_method) { // Create a new allocation and use it to request a specified amount of arenas. // Hopefully one of them is a reused one, the one that covers the art_method pointer. std::unique_ptr<LinearAlloc> alloc(Runtime::Current()->CreateLinearAlloc()); - for (int i = static_cast<int>(tries_count); i > 0; --i) { + do { // Ask for a byte - it's sufficient to get an arena and not have issues with size. alloc->Alloc(Thread::Current(), 1); - } - bool retval = alloc->Contains(reinterpret_cast<void*>(static_cast<uintptr_t>(art_method))); - - return retval; + } while (!alloc->Contains(reinterpret_cast<void*>(static_cast<uintptr_t>(art_method)))); } } // namespace diff --git a/test/616-cha-unloading/expected.txt b/test/616-cha-unloading/expected.txt index a71b724876..77a1486479 100644 --- a/test/616-cha-unloading/expected.txt +++ b/test/616-cha-unloading/expected.txt @@ -1,4 +1,2 @@ JNI_OnLoad called -null -true Done diff --git a/test/616-cha-unloading/src-art/Main.java b/test/616-cha-unloading/src-art/Main.java index b633a0c22e..effa315e25 100644 --- a/test/616-cha-unloading/src-art/Main.java +++ b/test/616-cha-unloading/src-art/Main.java @@ -53,12 +53,12 @@ public class Main { WeakReference<ClassLoader> loader = result.cl; long methodPtr = result.methodPtr; // Check that the classloader is indeed unloaded. - System.out.println(loader.get()); + if (loader.get() != null) { + throw new Error("Expected class loader to be unloaded"); + } - // Reuse the linear alloc so old pointers so it becomes invalid. - boolean ret = tryReuseArenaOfMethod(methodPtr, 10); - // Check that we indeed reused it. - System.out.println(ret); + // Reuse the linear alloc used by the unloaded class loader. + reuseArenaOfMethod(methodPtr); // Try to JIT-compile under dangerous conditions. ensureJitCompiled(Main.class, "targetMethodForJit"); @@ -117,5 +117,5 @@ public class Main { private static native void ensureJitCompiled(Class<?> itf, String method_name); private static native long getArtMethod(Object javaMethod); - private static native boolean tryReuseArenaOfMethod(long artMethod, int tries_count); + private static native void reuseArenaOfMethod(long artMethod); } diff --git a/test/knownfailures.json b/test/knownfailures.json index 41f4e1a09f..6993e2c490 100644 --- a/test/knownfailures.json +++ b/test/knownfailures.json @@ -975,7 +975,17 @@ ], "variant": "jvm", "bug": "b/73888836", - "description": ["Failing on JVM. Needs further investigating."] + "description": ["Failing on RI. Needs further investigating."] + }, + { + "tests": ["616-cha-unloading"], + "variant": "jvm", + "description": ["Doesn't run on RI."] + }, + { + "tests": ["616-cha-unloading"], + "variant": "trace", + "description": ["Trace prevents class unloading."] }, { "tests": "677-fsi", |