< prev index next >

test/gc/g1/TestGCLogMessages.java

Print this page




  21  * questions.
  22  */
  23 
  24 /*
  25  * @test TestGCLogMessages
  26  * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962 8069330
  27  * @summary Ensure the output for a minor GC with G1
  28  * includes the expected necessary messages.
  29  * @key gc
  30  * @library /testlibrary
  31  * @modules java.base/sun.misc
  32  *          java.management
  33  */
  34 
  35 import jdk.test.lib.ProcessTools;
  36 import jdk.test.lib.OutputAnalyzer;
  37 
  38 public class TestGCLogMessages {
  39 
  40     private enum Level {
  41         OFF, DEBUG, TRACE;
  42         public boolean lessOrEqualTo(Level other) {










  43             return this.compareTo(other) < 0;
  44         }




  45     }
  46 
  47     private class LogMessageWithLevel {
  48         String message;
  49         Level level;
  50 
  51         public LogMessageWithLevel(String message, Level level) {
  52             this.message = message;
  53             this.level = level;
  54         }
  55     };
  56 
  57     private LogMessageWithLevel allLogMessages[] = new LogMessageWithLevel[] {
  58         // Update RS
  59         new LogMessageWithLevel("Scan HCC", Level.DEBUG),
  60         // Ext Root Scan
  61         new LogMessageWithLevel("Thread Roots:", Level.DEBUG),
  62         new LogMessageWithLevel("StringTable Roots:", Level.DEBUG),
  63         new LogMessageWithLevel("Universe Roots:", Level.DEBUG),
  64         new LogMessageWithLevel("JNI Handles Roots:", Level.DEBUG),
  65         new LogMessageWithLevel("ObjectSynchronizer Roots:", Level.DEBUG),
  66         new LogMessageWithLevel("FlatProfiler Roots", Level.DEBUG),
  67         new LogMessageWithLevel("Management Roots", Level.DEBUG),
  68         new LogMessageWithLevel("SystemDictionary Roots", Level.DEBUG),
  69         new LogMessageWithLevel("CLDG Roots", Level.DEBUG),
  70         new LogMessageWithLevel("JVMTI Roots", Level.DEBUG),
  71         new LogMessageWithLevel("SATB Filtering", Level.DEBUG),
  72         new LogMessageWithLevel("CM RefProcessor Roots", Level.DEBUG),
  73         new LogMessageWithLevel("Wait For Strong CLD", Level.DEBUG),
  74         new LogMessageWithLevel("Weak CLD Roots", Level.DEBUG),
  75         // Redirty Cards
  76         new LogMessageWithLevel("Redirty Cards", Level.DEBUG),
  77         new LogMessageWithLevel("Parallel Redirty", Level.DEBUG),
  78         new LogMessageWithLevel("Redirtied Cards", Level.DEBUG),
  79         // Misc Top-level
  80         new LogMessageWithLevel("Code Root Purge", Level.DEBUG),
  81         new LogMessageWithLevel("String Dedup Fixup", Level.DEBUG),
  82         new LogMessageWithLevel("Expand Heap After Collection", Level.DEBUG),
  83         // Free CSet
  84         new LogMessageWithLevel("Young Free CSet", Level.TRACE),
  85         new LogMessageWithLevel("Non-Young Free CSet", Level.TRACE),
  86         // Humongous Eager Reclaim
  87         new LogMessageWithLevel("Humongous Reclaim", Level.DEBUG),
  88         new LogMessageWithLevel("Humongous Register", Level.DEBUG),
  89     };
  90 
  91     void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
  92         for (LogMessageWithLevel l : messages) {
  93             if (level.lessOrEqualTo(l.level)) {
  94                 output.shouldNotContain(l.message);
  95             } else {
  96                 output.shouldContain(l.message);
  97             }
  98         }
  99     }
 100 
 101     public static void main(String[] args) throws Exception {
 102         new TestGCLogMessages().testNormalLogs();
 103         new TestGCLogMessages().testWithToSpaceExhaustionLogs();
 104     }
 105 
 106     private void testNormalLogs() throws Exception {
 107 
 108         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
 109                                                                   "-Xmx10M",
 110                                                                   GCTest.class.getName());
 111 
 112         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 113         checkMessagesAtLevel(output, allLogMessages, Level.OFF);
 114         output.shouldHaveExitValue(0);
 115 
 116         pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",




  21  * questions.
  22  */
  23 
  24 /*
  25  * @test TestGCLogMessages
  26  * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962 8069330
  27  * @summary Ensure the output for a minor GC with G1
  28  * includes the expected necessary messages.
  29  * @key gc
  30  * @library /testlibrary
  31  * @modules java.base/sun.misc
  32  *          java.management
  33  */
  34 
  35 import jdk.test.lib.ProcessTools;
  36 import jdk.test.lib.OutputAnalyzer;
  37 
  38 public class TestGCLogMessages {
  39 
  40     private enum Level {
  41         OFF(""),
  42         INFO("info"),
  43         DEBUG("debug"),
  44         TRACE("trace");
  45 
  46         private String logName;
  47 
  48         Level(String logName) {
  49             this.logName = logName;
  50         }
  51 
  52         public boolean lessThan(Level other) {
  53             return this.compareTo(other) < 0;
  54         }
  55 
  56         public String toString() {
  57             return logName;
  58         }
  59     }
  60 
  61     private class LogMessageWithLevel {
  62         String message;
  63         Level level;
  64 
  65         public LogMessageWithLevel(String message, Level level) {
  66             this.message = message;
  67             this.level = level;
  68         }
  69     };
  70 
  71     private LogMessageWithLevel allLogMessages[] = new LogMessageWithLevel[] {
  72         // Update RS
  73         new LogMessageWithLevel("Scan HCC", Level.TRACE),
  74         // Ext Root Scan
  75         new LogMessageWithLevel("Thread Roots", Level.TRACE),
  76         new LogMessageWithLevel("StringTable Roots", Level.TRACE),
  77         new LogMessageWithLevel("Universe Roots", Level.TRACE),
  78         new LogMessageWithLevel("JNI Handles Roots", Level.TRACE),
  79         new LogMessageWithLevel("ObjectSynchronizer Roots", Level.TRACE),
  80         new LogMessageWithLevel("FlatProfiler Roots", Level.TRACE),
  81         new LogMessageWithLevel("Management Roots", Level.TRACE),
  82         new LogMessageWithLevel("SystemDictionary Roots", Level.TRACE),
  83         new LogMessageWithLevel("CLDG Roots", Level.TRACE),
  84         new LogMessageWithLevel("JVMTI Roots", Level.TRACE),
  85         new LogMessageWithLevel("SATB Filtering", Level.TRACE),
  86         new LogMessageWithLevel("CM RefProcessor Roots", Level.TRACE),
  87         new LogMessageWithLevel("Wait For Strong CLD", Level.TRACE),
  88         new LogMessageWithLevel("Weak CLD Roots", Level.TRACE),
  89         // Redirty Cards
  90         new LogMessageWithLevel("Redirty Cards", Level.DEBUG),
  91         new LogMessageWithLevel("Parallel Redirty", Level.TRACE),
  92         new LogMessageWithLevel("Redirtied Cards", Level.TRACE),
  93         // Misc Top-level
  94         new LogMessageWithLevel("Code Roots Purge", Level.DEBUG),
  95         new LogMessageWithLevel("String Dedup Fixup", Level.INFO),
  96         new LogMessageWithLevel("Expand Heap After Collection", Level.INFO),
  97         // Free CSet
  98         new LogMessageWithLevel("Young Free Collection Set", Level.DEBUG),
  99         new LogMessageWithLevel("Non-Young Free Collection Set", Level.DEBUG),
 100         // Humongous Eager Reclaim
 101         new LogMessageWithLevel("Humongous Reclaim", Level.DEBUG),
 102         new LogMessageWithLevel("Humongous Register", Level.DEBUG),
 103     };
 104 
 105     void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
 106         for (LogMessageWithLevel l : messages) {
 107             if (level.lessThan(l.level)) {
 108                 output.shouldNotContain(l.message);
 109             } else {
 110                 output.shouldMatch("\\[" + l.level + ".*" + l.message);
 111             }
 112         }
 113     }
 114 
 115     public static void main(String[] args) throws Exception {
 116         new TestGCLogMessages().testNormalLogs();
 117         new TestGCLogMessages().testWithToSpaceExhaustionLogs();
 118     }
 119 
 120     private void testNormalLogs() throws Exception {
 121 
 122         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
 123                                                                   "-Xmx10M",
 124                                                                   GCTest.class.getName());
 125 
 126         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 127         checkMessagesAtLevel(output, allLogMessages, Level.OFF);
 128         output.shouldHaveExitValue(0);
 129 
 130         pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",


< prev index next >