8285032: vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008/ fails with "eventSet.suspendPolicy() != policyExpected"

Reviewed-by: sspitsyn, amenkov
This commit is contained in:
Chris Plummer 2022-04-27 20:38:18 +00:00
parent 1f868f1d09
commit 5c0934931b
3 changed files with 31 additions and 18 deletions
test/hotspot/jtreg/vmTestbase/nsk
jdi/EventSet/suspendPolicy
share/jdi

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -247,8 +247,8 @@ public class suspendpolicy008 extends JDIBase {
getEventSet();
cpRequest.disable();
ClassPrepareEvent event = (ClassPrepareEvent) eventIterator.next();
debuggeeClass = event.referenceType();
ClassPrepareEvent cpEvent = (ClassPrepareEvent) eventIterator.next();
debuggeeClass = cpEvent.referenceType();
if (!debuggeeClass.name().equals(debuggeeName))
throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **");
@ -371,13 +371,14 @@ public class suspendpolicy008 extends JDIBase {
}
mainThread.resume();
getEventSet();
getEventSetForThreadStartDeath("thread" + i);
if ( !(eventIterator.nextEvent() instanceof ThreadStartEvent)) {
log3("ERROR: new event is not ThreadStartEvent");
Event event = eventIterator.nextEvent();
if (!(event instanceof ThreadStartEvent)) {
log3("ERROR: new event is not ThreadStartEvent: " + event);
testExitCode = FAILED;
} else {
log2("......got : instanceof ThreadStartEvent");
log2("......got : instanceof ThreadStartEvent: " + event);
policy = eventSet.suspendPolicy();
if (policy != policyExpected[i]) {
log3("ERROR: eventSet.suspendPolicy() != policyExpected");
@ -418,8 +419,6 @@ public class suspendpolicy008 extends JDIBase {
throws JDITestRuntimeException {
try {
ThreadStartRequest tsr = eventRManager.createThreadStartRequest();
// tsr.addThreadFilter(mainThread);
tsr.addCountFilter(1);
tsr.setSuspendPolicy(suspendPolicy);
tsr.putProperty("number", property);
return tsr;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -337,6 +337,10 @@ public class EventFilters
if (event.toString().contains("JFR request timer"))
return true;
// Filter out any carrier thread that starts while running the test.
if (event.toString().contains("ForkJoinPool"))
return true;
return false;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -165,18 +165,21 @@ public class JDIBase {
Event event = eventIterator.nextEvent();
if (event instanceof ThreadStartEvent evt) {
if (evt.thread().name().equals(threadName)) {
log2("Got ThreadStartEvent for '" + evt.thread().name());
break;
}
log2("Got ThreadStartEvent for '" + evt.thread().name()
+ "' instead of '" + threadName + "', skipping");
} else if (event instanceof ThreadDeathEvent evt) {
if (evt.thread().name().equals(threadName)) {
log2("Got ThreadDeathEvent for '" + evt.thread().name());
break;
}
log2("Got ThreadDeathEvent for '" + evt.thread().name()
+ "' instead of '" + threadName + "', skipping");
} else {
// not ThreadStartEvent nor ThreadDeathEvent
log2("Did't get ThreadStartEvent or ThreadDeathEvent: " + event);
break;
}
eventSet.resume();
@ -188,15 +191,22 @@ public class JDIBase {
protected void breakpointForCommunication() throws JDITestRuntimeException {
log2("breakpointForCommunication");
getEventSet();
while (true) {
getEventSet();
Event event = eventIterator.nextEvent();
if (event instanceof BreakpointEvent) {
bpEvent = (BreakpointEvent) event;
return;
Event event = eventIterator.nextEvent();
if (event instanceof BreakpointEvent) {
bpEvent = (BreakpointEvent) event;
return;
}
if (EventFilters.filtered(event)) {
// We filter out spurious ThreadStartEvents
continue;
}
throw new JDITestRuntimeException("** event '" + event + "' IS NOT a breakpoint **");
}
throw new JDITestRuntimeException("** event '" + event + "' IS NOT a breakpoint **");
}
// Similar to breakpointForCommunication, but skips Locatable events from unexpected locations.