test/gc/logging/TestGCId.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8u-push Sdiff test/gc/logging

test/gc/logging/TestGCId.java

Print this page




  55 
  56   private static void verifyContainsNoGCIDs(OutputAnalyzer output) {
  57     output.shouldNotMatch("^#[0-9]+: \\[");
  58     output.shouldHaveExitValue(0);
  59   }
  60 
  61   private static void testGCId(String gcFlag, String logFlag) throws Exception {
  62     // GCID logging enabled
  63     ProcessBuilder pb_enabled =
  64       ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName());
  65     verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start()));
  66 
  67     // GCID logging disabled
  68     ProcessBuilder pb_disabled =
  69       ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName());
  70     verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start()));
  71 
  72     // GCID logging default
  73     ProcessBuilder pb_default =
  74       ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName());
  75     verifyContainsGCIDs(new OutputAnalyzer(pb_default.start()));
  76   }
  77 
  78   static class GCTest {
  79     private static byte[] garbage;
  80     public static void main(String [] args) {
  81       System.out.println("Creating garbage");
  82       // create 128MB of garbage. This should result in at least one GC
  83       for (int i = 0; i < 1024; i++) {
  84         garbage = new byte[128 * 1024];
  85       }
  86       // do a system gc to get one more gc
  87       System.gc();
  88       System.out.println("Done");
  89     }
  90   }
  91 }


  55 
  56   private static void verifyContainsNoGCIDs(OutputAnalyzer output) {
  57     output.shouldNotMatch("^#[0-9]+: \\[");
  58     output.shouldHaveExitValue(0);
  59   }
  60 
  61   private static void testGCId(String gcFlag, String logFlag) throws Exception {
  62     // GCID logging enabled
  63     ProcessBuilder pb_enabled =
  64       ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName());
  65     verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start()));
  66 
  67     // GCID logging disabled
  68     ProcessBuilder pb_disabled =
  69       ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName());
  70     verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start()));
  71 
  72     // GCID logging default
  73     ProcessBuilder pb_default =
  74       ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName());
  75     verifyContainsNoGCIDs(new OutputAnalyzer(pb_default.start()));
  76   }
  77 
  78   static class GCTest {
  79     private static byte[] garbage;
  80     public static void main(String [] args) {
  81       System.out.println("Creating garbage");
  82       // create 128MB of garbage. This should result in at least one GC
  83       for (int i = 0; i < 1024; i++) {
  84         garbage = new byte[128 * 1024];
  85       }
  86       // do a system gc to get one more gc
  87       System.gc();
  88       System.out.println("Done");
  89     }
  90   }
  91 }
test/gc/logging/TestGCId.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File