< prev index next >

test/gc/TestVerifySilently.java

Print this page




  43 
  44 
  45 public class TestVerifySilently {
  46   private static String[] getTestJavaOpts() {
  47     String testVmOptsStr = System.getProperty("test.java.opts");
  48     if (!testVmOptsStr.isEmpty()) {
  49       return testVmOptsStr.split(" ");
  50     } else {
  51       return new String[] {};
  52     }
  53   }
  54 
  55   private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
  56     ArrayList<String> vmOpts = new ArrayList();
  57 
  58     Collections.addAll(vmOpts, getTestJavaOpts());
  59     Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
  60                                              "-XX:+VerifyDuringStartup",
  61                                              "-XX:+VerifyBeforeGC",
  62                                              "-XX:+VerifyAfterGC",
  63                                              "-XX:" + (verifySilently ? "+":"-") + "VerifySilently",
  64                                              RunSystemGC.class.getName()});
  65     ProcessBuilder pb =
  66       ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  67     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  68 
  69     System.out.println("Output:\n" + output.getOutput());
  70     return output;
  71   }
  72 
  73 
  74   public static void main(String args[]) throws Exception {
  75 
  76     OutputAnalyzer output;
  77 
  78     output = runTest(false);
  79     output.shouldContain("[Verifying");
  80     output.shouldHaveExitValue(0);
  81 
  82     output = runTest(true);
  83     output.shouldNotContain("[Verifying");
  84     output.shouldHaveExitValue(0);
  85   }
  86 }


  43 
  44 
  45 public class TestVerifySilently {
  46   private static String[] getTestJavaOpts() {
  47     String testVmOptsStr = System.getProperty("test.java.opts");
  48     if (!testVmOptsStr.isEmpty()) {
  49       return testVmOptsStr.split(" ");
  50     } else {
  51       return new String[] {};
  52     }
  53   }
  54 
  55   private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
  56     ArrayList<String> vmOpts = new ArrayList();
  57 
  58     Collections.addAll(vmOpts, getTestJavaOpts());
  59     Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
  60                                              "-XX:+VerifyDuringStartup",
  61                                              "-XX:+VerifyBeforeGC",
  62                                              "-XX:+VerifyAfterGC",
  63                                              (verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"),
  64                                              RunSystemGC.class.getName()});
  65     ProcessBuilder pb =
  66       ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  67     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  68 
  69     System.out.println("Output:\n" + output.getOutput());
  70     return output;
  71   }
  72 
  73 
  74   public static void main(String args[]) throws Exception {
  75 
  76     OutputAnalyzer output;
  77 
  78     output = runTest(false);
  79     output.shouldContain("Verifying");
  80     output.shouldHaveExitValue(0);
  81 
  82     output = runTest(true);
  83     output.shouldNotContain("Verifying");
  84     output.shouldHaveExitValue(0);
  85   }
  86 }
< prev index next >