8225348: serviceability/dcmd/vm/EventsTest.java failed
Reviewed-by: jcbeyler, cjplummer
--- a/test/hotspot/jtreg/serviceability/dcmd/vm/EventsTest.java Wed Jun 05 09:12:45 2019 +0200
+++ b/test/hotspot/jtreg/serviceability/dcmd/vm/EventsTest.java Wed Jun 05 21:14:46 2019 +0200
@@ -38,27 +38,30 @@
*/
public class EventsTest {
+ static String buildHeaderPattern(String logname) {
+ return "^" + logname + ".*\\(\\d+ events\\):";
+ }
+
public void run_all(CommandExecutor executor) {
OutputAnalyzer output = executor.execute("VM.events");
- // This tests for the output to contain the event log *names*. Those are always
- // printed even if the corresponding event log is empty (e.g. "Classes redefined (0 events)")
- output.shouldContain("Events");
- output.shouldContain("Compilation");
- output.shouldContain("GC");
- output.shouldContain("Deoptimization");
- output.shouldContain("Classes unloaded");
+ // This tests for the output to contain the event log header line (e.g. "Classes unloaded (0 events):").
+ // Those are always printed even if the corresponding event log is empty.
+ output.stdoutShouldMatch(buildHeaderPattern("Events"));
+ output.stdoutShouldMatch(buildHeaderPattern("Compilation"));
+ output.stdoutShouldMatch(buildHeaderPattern("GC Heap History"));
+ output.stdoutShouldMatch(buildHeaderPattern("Deoptimization"));
+ output.stdoutShouldMatch(buildHeaderPattern("Classes unloaded"));
}
public void run_selected(CommandExecutor executor) {
OutputAnalyzer output = executor.execute("VM.events log=deopt");
- // This tests for the output to contain the event log *names*. Those are always
- // printed even if the corresponding event log is empty (e.g. "Classes redefined (0 events)")
- output.shouldContain("Deoptimization");
+ // We only expect one log to be printed here.
+ output.stdoutShouldMatch(buildHeaderPattern("Deoptimization"));
- output.shouldNotContain("Events");
- output.shouldNotContain("Compilation");
- output.shouldNotContain("GC");
- output.shouldNotContain("Classes unloaded");
+ output.stdoutShouldNotMatch(buildHeaderPattern("Events"));
+ output.stdoutShouldNotMatch(buildHeaderPattern("Compilation"));
+ output.stdoutShouldNotMatch(buildHeaderPattern("GC Heap History"));
+ output.stdoutShouldNotMatch(buildHeaderPattern("Classes unloaded"));
}
@Test