mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8247776: JFR: TestThreadContextSwitches.java failed "RuntimeException: No events: expected false, was true"
Reviewed-by: mgronlun
This commit is contained in:
parent
8a20656ed0
commit
eb729f0aaa
@ -28,6 +28,7 @@ import jdk.jfr.Recording;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
import jdk.test.lib.jfr.EventNames;
|
||||
import jdk.test.lib.jfr.Events;
|
||||
import jdk.test.lib.Platform;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -40,15 +41,25 @@ public class TestThreadContextSwitches {
|
||||
private final static String EVENT_NAME = EventNames.ThreadContextSwitchRate;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
Recording recording = new Recording();
|
||||
recording.enable(EVENT_NAME);
|
||||
recording.start();
|
||||
recording.stop();
|
||||
List<RecordedEvent> events = Events.fromRecording(recording);
|
||||
Events.hasEvents(events);
|
||||
for (RecordedEvent event : events) {
|
||||
System.out.println("Event: " + event);
|
||||
Events.assertField(event, "switchRate").atLeast(0.0f);
|
||||
while (true) {
|
||||
try (Recording recording = new Recording()) {
|
||||
recording.enable(EVENT_NAME);
|
||||
recording.start();
|
||||
recording.stop();
|
||||
List<RecordedEvent> events = Events.fromRecording(recording);
|
||||
if (!events.isEmpty()) {
|
||||
for (RecordedEvent event : events) {
|
||||
System.out.println("Event: " + event);
|
||||
Events.assertField(event, "switchRate").atLeast(0.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Thread context switch rate is unreliable on Windows because
|
||||
// the way processes are identified with performance counters.
|
||||
if (!Platform.isWindows()) {
|
||||
Events.hasEvents(events);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user