36 * jdk.internal.jvmstat/sun.jvmstat.monitor |
36 * jdk.internal.jvmstat/sun.jvmstat.monitor |
37 * @run testng EventsTest |
37 * @run testng EventsTest |
38 */ |
38 */ |
39 public class EventsTest { |
39 public class EventsTest { |
40 |
40 |
|
41 static String buildHeaderPattern(String logname) { |
|
42 return "^" + logname + ".*\\(\\d+ events\\):"; |
|
43 } |
|
44 |
41 public void run_all(CommandExecutor executor) { |
45 public void run_all(CommandExecutor executor) { |
42 OutputAnalyzer output = executor.execute("VM.events"); |
46 OutputAnalyzer output = executor.execute("VM.events"); |
43 // This tests for the output to contain the event log *names*. Those are always |
47 // This tests for the output to contain the event log header line (e.g. "Classes unloaded (0 events):"). |
44 // printed even if the corresponding event log is empty (e.g. "Classes redefined (0 events)") |
48 // Those are always printed even if the corresponding event log is empty. |
45 output.shouldContain("Events"); |
49 output.stdoutShouldMatch(buildHeaderPattern("Events")); |
46 output.shouldContain("Compilation"); |
50 output.stdoutShouldMatch(buildHeaderPattern("Compilation")); |
47 output.shouldContain("GC"); |
51 output.stdoutShouldMatch(buildHeaderPattern("GC Heap History")); |
48 output.shouldContain("Deoptimization"); |
52 output.stdoutShouldMatch(buildHeaderPattern("Deoptimization")); |
49 output.shouldContain("Classes unloaded"); |
53 output.stdoutShouldMatch(buildHeaderPattern("Classes unloaded")); |
50 } |
54 } |
51 |
55 |
52 public void run_selected(CommandExecutor executor) { |
56 public void run_selected(CommandExecutor executor) { |
53 OutputAnalyzer output = executor.execute("VM.events log=deopt"); |
57 OutputAnalyzer output = executor.execute("VM.events log=deopt"); |
54 // This tests for the output to contain the event log *names*. Those are always |
58 // We only expect one log to be printed here. |
55 // printed even if the corresponding event log is empty (e.g. "Classes redefined (0 events)") |
59 output.stdoutShouldMatch(buildHeaderPattern("Deoptimization")); |
56 output.shouldContain("Deoptimization"); |
|
57 |
60 |
58 output.shouldNotContain("Events"); |
61 output.stdoutShouldNotMatch(buildHeaderPattern("Events")); |
59 output.shouldNotContain("Compilation"); |
62 output.stdoutShouldNotMatch(buildHeaderPattern("Compilation")); |
60 output.shouldNotContain("GC"); |
63 output.stdoutShouldNotMatch(buildHeaderPattern("GC Heap History")); |
61 output.shouldNotContain("Classes unloaded"); |
64 output.stdoutShouldNotMatch(buildHeaderPattern("Classes unloaded")); |
62 } |
65 } |
63 |
66 |
64 @Test |
67 @Test |
65 public void jmx() { |
68 public void jmx() { |
66 run_all(new JMXExecutor()); |
69 run_all(new JMXExecutor()); |