8254864: vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted001/TestDescription.java timed out
Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
parent
0b7fba75c1
commit
a9dff9420a
test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,17 +22,28 @@
|
|||||||
*/
|
*/
|
||||||
package nsk.jvmti.ResourceExhausted;
|
package nsk.jvmti.ResourceExhausted;
|
||||||
|
|
||||||
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
public class Helper {
|
public class Helper {
|
||||||
|
|
||||||
static native boolean gotExhaustedEvent();
|
static native int getExhaustedEventFlags();
|
||||||
static native void resetExhaustedEvent();
|
static native void resetExhaustedEvent();
|
||||||
|
|
||||||
static boolean checkResult(String eventName) {
|
static final int JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR = 1;
|
||||||
if ( ! gotExhaustedEvent() ) {
|
static final int JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 2;
|
||||||
|
static final int JVMTI_RESOURCE_EXHAUSTED_THREADS = 4;
|
||||||
|
|
||||||
|
static boolean checkResult(int expectedFlag, String eventName) {
|
||||||
|
int got = getExhaustedEventFlags();
|
||||||
|
if (got == 0) {
|
||||||
System.err.println("Failure: Expected ResourceExhausted event after " + eventName + " did not occur");
|
System.err.println("Failure: Expected ResourceExhausted event after " + eventName + " did not occur");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((got & expectedFlag) == 0) {
|
||||||
|
System.err.println("Warning: did not get expected flag bit (expected: "+ expectedFlag + ", got: " + got + ")");
|
||||||
|
throw new SkippedException("Test did not get expected flag value");
|
||||||
|
}
|
||||||
System.out.println("Got expected ResourceExhausted event");
|
System.out.println("Got expected ResourceExhausted event");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,7 +33,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static jvmtiEnv* gJvmti = NULL;
|
static jvmtiEnv* gJvmti = NULL;
|
||||||
static volatile jboolean gGotEvent = JNI_FALSE;
|
static volatile jint gEventFlags = 0;
|
||||||
|
|
||||||
void JNICALL
|
void JNICALL
|
||||||
resourceExhausted(jvmtiEnv *jvmti_env,
|
resourceExhausted(jvmtiEnv *jvmti_env,
|
||||||
@ -46,19 +46,19 @@ resourceExhausted(jvmtiEnv *jvmti_env,
|
|||||||
if (flags & JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR) NSK_DISPLAY0("Agent: JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR\n");
|
if (flags & JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR) NSK_DISPLAY0("Agent: JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR\n");
|
||||||
if (flags & JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP) NSK_DISPLAY0("Agent: JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP\n");
|
if (flags & JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP) NSK_DISPLAY0("Agent: JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP\n");
|
||||||
if (flags & JVMTI_RESOURCE_EXHAUSTED_THREADS) NSK_DISPLAY0("Agent: JVMTI_RESOURCE_EXHAUSTED_THREADS\n");
|
if (flags & JVMTI_RESOURCE_EXHAUSTED_THREADS) NSK_DISPLAY0("Agent: JVMTI_RESOURCE_EXHAUSTED_THREADS\n");
|
||||||
gGotEvent = JNI_TRUE;
|
gEventFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_nsk_jvmti_ResourceExhausted_Helper_gotExhaustedEvent(JNIEnv* env, jclass cls)
|
Java_nsk_jvmti_ResourceExhausted_Helper_getExhaustedEventFlags(JNIEnv* env, jclass cls)
|
||||||
{
|
{
|
||||||
return gGotEvent;
|
return gEventFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_nsk_jvmti_ResourceExhausted_Helper_resetExhaustedEvent(JNIEnv* env, jclass cls)
|
Java_nsk_jvmti_ResourceExhausted_Helper_resetExhaustedEvent(JNIEnv* env, jclass cls)
|
||||||
{
|
{
|
||||||
gGotEvent = JNI_FALSE;
|
gEventFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATIC_BUILD
|
#ifdef STATIC_BUILD
|
||||||
|
@ -25,6 +25,7 @@ package nsk.jvmti.ResourceExhausted;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import jdk.test.lib.Platform;
|
||||||
import nsk.share.Consts;
|
import nsk.share.Consts;
|
||||||
import nsk.share.test.Stresser;
|
import nsk.share.test.Stresser;
|
||||||
import jtreg.SkippedException;
|
import jtreg.SkippedException;
|
||||||
@ -42,6 +43,11 @@ public class resexhausted001 {
|
|||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
public static int run(String args[], PrintStream out) {
|
||||||
|
|
||||||
|
// Check platform here (instead of @requires) as this test is also called from resexhausted004
|
||||||
|
if (Platform.isWindows()) {
|
||||||
|
throw new SkippedException("Cannot get JVMTI_RESOURCE_EXHAUSTED_THREADS on Windows");
|
||||||
|
}
|
||||||
|
|
||||||
Stresser stress = new Stresser(args);
|
Stresser stress = new Stresser(args);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -56,14 +62,15 @@ public class resexhausted001 {
|
|||||||
makeThread();
|
makeThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Can't reproduce OOME due to a limit on iterations/execution time. Test was useless.");
|
System.out.println("Can't reproduce OOME due to a limit on iterations/execution time. Test was useless."
|
||||||
|
+ " threadCount=" + threadCount.get());
|
||||||
throw new SkippedException("Test did not get an OutOfMemory error");
|
throw new SkippedException("Test did not get an OutOfMemory error");
|
||||||
|
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
count = threadCount.get();
|
count = threadCount.get();
|
||||||
} finally {
|
} finally {
|
||||||
threadsDone = true;
|
|
||||||
synchronized (hanger) {
|
synchronized (hanger) {
|
||||||
|
threadsDone = true;
|
||||||
hanger.notifyAll();
|
hanger.notifyAll();
|
||||||
}
|
}
|
||||||
stress.finish();
|
stress.finish();
|
||||||
@ -74,7 +81,8 @@ public class resexhausted001 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
if (!Helper.checkResult("creating " + count + " threads")) {
|
System.out.println("got OOME with threadCount=" + count);
|
||||||
|
if (!Helper.checkResult(Helper.JVMTI_RESOURCE_EXHAUSTED_THREADS, "creating " + count + " threads")) {
|
||||||
return Consts.TEST_FAILED;
|
return Consts.TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,16 +93,17 @@ public class resexhausted001 {
|
|||||||
final Thread thr = new Thread(new Runnable() {
|
final Thread thr = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
threadCount.getAndIncrement();
|
threadCount.getAndIncrement();
|
||||||
while (!threadsDone) {
|
synchronized (hanger) {
|
||||||
try {
|
while (!threadsDone) {
|
||||||
synchronized (hanger) {
|
try {
|
||||||
hanger.wait();
|
hanger.wait();
|
||||||
}
|
} catch (InterruptedException ignored) {}
|
||||||
} catch (InterruptedException ignored) {}
|
}
|
||||||
}
|
}
|
||||||
threadCount.getAndDecrement();
|
threadCount.getAndDecrement();
|
||||||
}
|
}
|
||||||
}, "fleece");
|
}, "fleece");
|
||||||
|
thr.setDaemon(true);
|
||||||
thr.start();
|
thr.start();
|
||||||
return thr;
|
return thr;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
* @run main/othervm/native/timeout=240
|
* @run main/othervm/native/timeout=240
|
||||||
* -agentlib:resexhausted=-waittime=5
|
* -agentlib:resexhausted=-waittime=5
|
||||||
* -XX:-UseGCOverheadLimit
|
* -XX:-UseGCOverheadLimit
|
||||||
|
* -Xms16m
|
||||||
|
* -Xmx16m
|
||||||
* nsk.jvmti.ResourceExhausted.resexhausted001
|
* nsk.jvmti.ResourceExhausted.resexhausted001
|
||||||
* -stressTime 220
|
* -stressTime 220
|
||||||
*/
|
*/
|
||||||
|
@ -64,8 +64,9 @@ public class resexhausted002 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
if ( ! Helper.checkResult("creating " + count + " objects") )
|
if (!Helper.checkResult(Helper.JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP, "creating " + count + " objects")) {
|
||||||
return Consts.TEST_FAILED;
|
return Consts.TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
return Consts.TEST_PASSED;
|
return Consts.TEST_PASSED;
|
||||||
}
|
}
|
||||||
|
@ -125,8 +125,10 @@ public class resexhausted003 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
if ( ! Helper.checkResult("loading " + count + " classes of " + bloatBytes.length + " bytes") )
|
if (!Helper.checkResult(Helper.JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
|
||||||
|
"loading " + count + " classes of " + bloatBytes.length + " bytes")) {
|
||||||
return Consts.TEST_FAILED;
|
return Consts.TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
return Consts.TEST_PASSED;
|
return Consts.TEST_PASSED;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user