< prev index next >

test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java

Print this page

 29  * @library /test/lib
 30  * @run driver TestPeriodicGC
 31  */
 32 
 33 import java.util.*;
 34 
 35 import jdk.test.lib.Asserts;
 36 import jdk.test.lib.process.ProcessTools;
 37 import jdk.test.lib.process.OutputAnalyzer;
 38 
 39 public class TestPeriodicGC {
 40 
 41     public static void testWith(String msg, boolean periodic, String... args) throws Exception {
 42         String[] cmds = Arrays.copyOf(args, args.length + 2);
 43         cmds[args.length] = TestPeriodicGC.class.getName();
 44         cmds[args.length + 1] = "test";
 45         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);
 46 
 47         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 48         output.shouldHaveExitValue(0);
 49         if (periodic && !output.getOutput().contains("Trigger: Time since last GC")) {
 50             throw new AssertionError(msg + ": Should have periodic GC in logs");
 51         }
 52         if (!periodic && output.getOutput().contains("Trigger: Time since last GC")) {
 53             throw new AssertionError(msg + ": Should not have periodic GC in logs");
 54         }
 55     }
 56 
 57     public static void main(String[] args) throws Exception {
 58         if (args.length > 0 && args[0].equals("test")) {
 59             Thread.sleep(5000); // stay idle
 60             return;
 61         }
 62 
 63         String[] enabled = new String[] {
 64                 "adaptive",
 65                 "compact",
 66                 "static",
 67         };
 68 
 69         for (String h : enabled) {
 70             testWith("Zero interval with " + h,
 71                     false,
 72                     "-Xlog:gc",

 29  * @library /test/lib
 30  * @run driver TestPeriodicGC
 31  */
 32 
 33 import java.util.*;
 34 
 35 import jdk.test.lib.Asserts;
 36 import jdk.test.lib.process.ProcessTools;
 37 import jdk.test.lib.process.OutputAnalyzer;
 38 
 39 public class TestPeriodicGC {
 40 
 41     public static void testWith(String msg, boolean periodic, String... args) throws Exception {
 42         String[] cmds = Arrays.copyOf(args, args.length + 2);
 43         cmds[args.length] = TestPeriodicGC.class.getName();
 44         cmds[args.length + 1] = "test";
 45         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);
 46 
 47         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 48         output.shouldHaveExitValue(0);
 49         if (periodic && !output.getOutput().contains("Trigger (GLOBAL): Time since last GC")) {
 50             throw new AssertionError(msg + ": Should have periodic GC in logs");
 51         }
 52         if (!periodic && output.getOutput().contains("Trigger (GLOBAL): Time since last GC")) {
 53             throw new AssertionError(msg + ": Should not have periodic GC in logs");
 54         }
 55     }
 56 
 57     public static void main(String[] args) throws Exception {
 58         if (args.length > 0 && args[0].equals("test")) {
 59             Thread.sleep(5000); // stay idle
 60             return;
 61         }
 62 
 63         String[] enabled = new String[] {
 64                 "adaptive",
 65                 "compact",
 66                 "static",
 67         };
 68 
 69         for (String h : enabled) {
 70             testWith("Zero interval with " + h,
 71                     false,
 72                     "-Xlog:gc",
< prev index next >