8151283: Implement setting jtreg @requires property vm.isG1Supported.
authordfazunen
Tue, 21 Jun 2016 18:36:37 +0400
changeset 39377 07739ee0b28a
parent 39199 ec6fd961811c
child 39378 d64644e5228d
8151283: Implement setting jtreg @requires property vm.isG1Supported. Reviewed-by: tschatzl, iignatyev, mchernov
test/jtreg-ext/requires/VMProps.java
--- a/test/jtreg-ext/requires/VMProps.java	Fri Jun 17 18:45:24 2016 +0300
+++ b/test/jtreg-ext/requires/VMProps.java	Tue Jun 21 18:36:37 2016 +0400
@@ -34,6 +34,7 @@
 import java.util.concurrent.Callable;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import sun.hotspot.gc.GC;
 
 /**
  * The Class to be invoked by jtreg prior Test Suite execution to
@@ -56,11 +57,12 @@
         map.put("vm.bits", vmBits());
         map.put("vm.flightRecorder", vmFlightRecorder());
         map.put("vm.simpleArch", vmArch());
+        vmGC(map); // vm.gc.X = true/false
+
         dump(map);
         return map;
     }
 
-
     /**
      * @return vm.simpleArch value of "os.simpleArch" property of tested JDK.
      */
@@ -147,6 +149,24 @@
     }
 
     /**
+     * For all existing GC sets vm.gc.X property.
+     * Example vm.gc.G1=true means:
+     *    VM supports G1
+     *    User either set G1 explicitely (-XX:+UseG1GC) or did not set any GC
+     * @param map - property-value pairs
+     */
+    protected void vmGC(Map<String, String> map){
+        GC currentGC = GC.current();
+        boolean isByErgo = GC.currentSetByErgo();
+        List<GC> supportedGC = GC.allSupported();
+        for (GC gc: GC.values()) {
+            boolean isSupported = supportedGC.contains(gc);
+            boolean isAcceptable = isSupported && (gc == currentGC || isByErgo);
+            map.put("vm.gc." + gc.name(), "" + isAcceptable);
+        }
+    }
+
+    /**
      * Dumps the map to the file if the file name is given as the property.
      * This functionality could be helpful to know context in the real
      * execution.