< prev index next >

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

Print this page
@@ -1,7 +1,8 @@
  /*
   * Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
+  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -44,18 +45,43 @@
          cmds[args.length + 1] = "test";
          ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds);
  
          OutputAnalyzer output = new OutputAnalyzer(pb.start());
          output.shouldHaveExitValue(0);
-         if (periodic && !output.getOutput().contains("Trigger: Time since last GC")) {
+         if (periodic && !output.getOutput().contains("Trigger (GLOBAL): Time since last GC")) {
              throw new AssertionError(msg + ": Should have periodic GC in logs");
          }
-         if (!periodic && output.getOutput().contains("Trigger: Time since last GC")) {
+         if (!periodic && output.getOutput().contains("Trigger (GLOBAL): Time since last GC")) {
              throw new AssertionError(msg + ": Should not have periodic GC in logs");
          }
      }
  
+     public static void testGenerational(boolean periodic, String... args) throws Exception {
+         String[] cmds = Arrays.copyOf(args, args.length + 2);
+         cmds[args.length] = TestPeriodicGC.class.getName();
+         cmds[args.length + 1] = "test";
+         ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds);
+ 
+         OutputAnalyzer output = new OutputAnalyzer(pb.start());
+         output.shouldHaveExitValue(0);
+         if (periodic) {
+             if (!output.getOutput().contains("Trigger (YOUNG): Time since last GC")) {
+                 throw new AssertionError("Generational mode: Should have periodic young GC in logs");
+             }
+             if (!output.getOutput().contains("Trigger (OLD): Time since last GC")) {
+                 throw new AssertionError("Generational mode: Should have periodic old GC in logs");
+             }
+         } else {
+             if (output.getOutput().contains("Trigger (YOUNG): Time since last GC")) {
+                 throw new AssertionError("Generational mode: Should not have periodic young GC in logs");
+             }
+             if (output.getOutput().contains("Trigger (OLD): Time since last GC")) {
+                 throw new AssertionError("Generational mode: Should not have periodic old GC in logs");
+             }
+         }
+     }
+ 
      public static void main(String[] args) throws Exception {
          if (args.length > 0 && args[0].equals("test")) {
              Thread.sleep(5000); // stay idle
              return;
          }

@@ -155,8 +181,28 @@
                   "-XX:+UnlockExperimentalVMOptions",
                   "-XX:+UseShenandoahGC",
                   "-XX:ShenandoahGCMode=passive",
                   "-XX:ShenandoahGuaranteedGCInterval=1000"
          );
+ 
+         testGenerational(true,
+                          "-Xlog:gc",
+                          "-XX:+UnlockDiagnosticVMOptions",
+                          "-XX:+UnlockExperimentalVMOptions",
+                          "-XX:+UseShenandoahGC",
+                          "-XX:ShenandoahGCMode=generational",
+                          "-XX:ShenandoahGuaranteedYoungGCInterval=1000",
+                          "-XX:ShenandoahGuaranteedOldGCInterval=1500"
+         );
+ 
+         testGenerational(false,
+                          "-Xlog:gc",
+                          "-XX:+UnlockDiagnosticVMOptions",
+                          "-XX:+UnlockExperimentalVMOptions",
+                          "-XX:+UseShenandoahGC",
+                          "-XX:ShenandoahGCMode=generational",
+                          "-XX:ShenandoahGuaranteedYoungGCInterval=0",
+                          "-XX:ShenandoahGuaranteedOldGCInterval=0"
+         );
      }
  
  }
< prev index next >