changeset 47702:df4f4688b13d

8190703: TestSystemGCWith* infrequently times out on SPARC Summary: Give the test a timeout after which it ends on its own. Reviewed-by: shade, sjohanss
author tschatzl
date Tue, 07 Nov 2017 13:51:18 +0100
parents 1772ebf07d1f
children c7b50c23ea71
files test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithCMS.java test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithG1.java test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithParallel.java test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithSerial.java
diffstat 5 files changed, 27 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java	Mon Nov 06 21:28:03 2017 -0800
+++ b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java	Tue Nov 07 13:51:18 2017 +0100
@@ -103,6 +103,8 @@
 }
 
 public class TestSystemGC {
+    private static long endTime;
+
     private static final int numGroups = 7;
     private static final int numGCsPerGroup = 4;
 
@@ -133,8 +135,11 @@
 
         for (int i = 0; i < numGroups; i++) {
             for (int j = 0; j < numGCsPerGroup; j++) {
-                System.gc();
-                ThreadUtils.sleep(getDelayMS(i));
+               System.gc();
+               if (System.currentTimeMillis() >= endTime) {
+                   return;
+               }
+               ThreadUtils.sleep(getDelayMS(i));
             }
         }
     }
@@ -159,7 +164,7 @@
     }
 
     private static void runAllPhases() {
-        for (int i = 0; i < 4; i++) {
+        for (int i = 0; i < 4 && System.currentTimeMillis() < endTime; i++) {
             SystemGCTask gcTask =
                 (i % 2 == 1) ? createSystemGCTask(numGroups / 3) : null;
             ShortLivedAllocationTask shortTask =
@@ -181,12 +186,15 @@
         }
     }
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0) {
+            throw new IllegalArgumentException("Must specify timeout in seconds as first argument");
+        }
+        int timeout = Integer.parseInt(args[0]) * 1000;
+        System.out.println("Running with timeout of " + timeout + "ms");
+        endTime = System.currentTimeMillis() + timeout;
         // First allocate the long lived objects and then run all phases.
         populateLongLived();
         runAllPhases();
-        if (args.length > 0 && args[0].equals("long")) {
-            runAllPhases();
-        }
     }
 }
--- a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithCMS.java	Mon Nov 06 21:28:03 2017 -0800
+++ b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithCMS.java	Tue Nov 07 13:51:18 2017 +0100
@@ -24,14 +24,15 @@
 
 /*
  * @test TestSystemGCWithCMS
+ * @bug 8190703
  * @key gc
  * @key stress
  * @requires vm.gc.ConcMarkSweep
  * @summary Stress the CMS GC full GC by allocating objects of different lifetimes concurrently with System.gc().
- * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseConcMarkSweepGC TestSystemGCWithCMS
+ * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseConcMarkSweepGC TestSystemGCWithCMS 270
  */
 public class TestSystemGCWithCMS {
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
         TestSystemGC.main(args);
     }
 }
--- a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithG1.java	Mon Nov 06 21:28:03 2017 -0800
+++ b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithG1.java	Tue Nov 07 13:51:18 2017 +0100
@@ -24,14 +24,15 @@
 
 /*
  * @test TestSystemGCWithG1
+ * @bug 8190703
  * @key gc
  * @key stress
  * @requires vm.gc.G1
  * @summary Stress the G1 GC full GC by allocating objects of different lifetimes concurrently with System.gc().
- * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseG1GC TestSystemGCWithG1
+ * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseG1GC TestSystemGCWithG1 270
  */
 public class TestSystemGCWithG1 {
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
         TestSystemGC.main(args);
     }
 }
--- a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithParallel.java	Mon Nov 06 21:28:03 2017 -0800
+++ b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithParallel.java	Tue Nov 07 13:51:18 2017 +0100
@@ -24,14 +24,15 @@
 
 /*
  * @test TestSystemGCWithParallel
+ * @bug 8190703
  * @key gc
  * @key stress
  * @requires vm.gc.Parallel
  * @summary Stress the Parallel GC full GC by allocating objects of different lifetimes concurrently with System.gc().
- * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseParallelGC TestSystemGCWithParallel
+ * @run main/othervm/timeout=300 -Xlog:gc=info -Xmx512m -XX:+UseParallelGC TestSystemGCWithParallel 270
  */
 public class TestSystemGCWithParallel {
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
         TestSystemGC.main(args);
     }
 }
--- a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithSerial.java	Mon Nov 06 21:28:03 2017 -0800
+++ b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGCWithSerial.java	Tue Nov 07 13:51:18 2017 +0100
@@ -24,14 +24,15 @@
 
 /*
  * @test TestSystemGCWithSerial
+ * @bug 8190703
  * @key gc
  * @key stress
  * @requires vm.gc.Serial
  * @summary Stress the Serial GC full GC by allocating objects of different lifetimes concurrently with System.gc().
- * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseSerialGC TestSystemGCWithSerial
+ * @run main/othervm/timeout=300 -Xlog:gc*=info -Xmx512m -XX:+UseSerialGC TestSystemGCWithSerial 270
  */
 public class TestSystemGCWithSerial {
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
         TestSystemGC.main(args);
     }
 }