test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java
changeset 54638 9b8926bf85c1
parent 53523 4c5184c56dc2
child 55610 47fdb5b0fa41
--- a/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java	Fri Apr 26 12:49:51 2019 -0400
+++ b/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java	Fri Apr 26 11:33:32 2019 -0700
@@ -28,7 +28,9 @@
  * @key gc
  * @summary Test defaults processing for -XX:+ParallelRefProcEnabled.
  * @library /test/lib
- * @run driver gc.arguments.TestParallelRefProc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.arguments.TestParallelRefProc
  */
 
 import java.util.Arrays;
@@ -37,15 +39,34 @@
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 
+import jtreg.SkippedException;
+import sun.hotspot.gc.GC;
+
 public class TestParallelRefProc {
 
     public static void main(String args[]) throws Exception {
-        testFlag(new String[] { "-XX:+UseSerialGC" }, false);
-        testFlag(new String[] { "-XX:+UseConcMarkSweepGC" }, false);
-        testFlag(new String[] { "-XX:+UseParallelGC" }, false);
-        testFlag(new String[] { "-XX:+UseG1GC", "-XX:ParallelGCThreads=1" }, false);
-        testFlag(new String[] { "-XX:+UseG1GC", "-XX:ParallelGCThreads=2" }, true);
-        testFlag(new String[] { "-XX:+UseG1GC", "-XX:-ParallelRefProcEnabled", "-XX:ParallelGCThreads=2" }, false);
+        boolean noneGCSupported = true;
+        if (GC.Serial.isSupported()) {
+            noneGCSupported = false;
+            testFlag(new String[] { "-XX:+UseSerialGC" }, false);
+        }
+        if (GC.ConcMarkSweep.isSupported()) {
+            noneGCSupported = false;
+            testFlag(new String[] { "-XX:+UseConcMarkSweepGC" }, false);
+        }
+        if (GC.Parallel.isSupported()) {
+            noneGCSupported = false;
+            testFlag(new String[] { "-XX:+UseParallelGC" }, false);
+        }
+        if (GC.G1.isSupported()) {
+            noneGCSupported = false;
+            testFlag(new String[] { "-XX:+UseG1GC", "-XX:ParallelGCThreads=1" }, false);
+            testFlag(new String[] { "-XX:+UseG1GC", "-XX:ParallelGCThreads=2" }, true);
+            testFlag(new String[] { "-XX:+UseG1GC", "-XX:-ParallelRefProcEnabled", "-XX:ParallelGCThreads=2" }, false);
+        }
+        if (noneGCSupported) {
+            throw new SkippedException("Skipping test because none of Serial/ConcMarkSweep/Parallel/G1 is supported.");
+        }
     }
 
     private static final String parallelRefProcEnabledPattern =