< prev index next >

test/jtreg-ext/requires/VMProps.java

Print this page




  56      *
  57      * @return Map of property-value pairs.
  58      */
  59     @Override
  60     public Map<String, String> call() {
  61         Map<String, String> map = new HashMap<>();
  62         map.put("vm.flavor", vmFlavor());
  63         map.put("vm.compMode", vmCompMode());
  64         map.put("vm.bits", vmBits());
  65         map.put("vm.flightRecorder", vmFlightRecorder());
  66         map.put("vm.simpleArch", vmArch());
  67         map.put("vm.debug", vmDebug());
  68         map.put("vm.jvmci", vmJvmci());
  69         map.put("vm.emulatedClient", vmEmulatedClient());
  70         map.put("vm.cpu.features", cpuFeatures());
  71         map.put("vm.rtm.cpu", vmRTMCPU());
  72         map.put("vm.rtm.os", vmRTMOS());
  73         map.put("vm.aot", vmAOT());
  74         // vm.cds is true if the VM is compiled with cds support.
  75         map.put("vm.cds", vmCDS());

  76         vmGC(map); // vm.gc.X = true/false
  77 
  78         VMProps.dump(map);
  79         return map;
  80     }
  81 
  82     /**
  83      * Prints a stack trace before returning null.
  84      * Used by the various helper functions which parse information from
  85      * VM properties in the case where they don't find an expected property
  86      * or a propoerty doesn't conform to an expected format.
  87      *
  88      * @return null
  89      */
  90     private String nullWithException(String message) {
  91         new Exception(message).printStackTrace();
  92         return null;
  93     }
  94 
  95     /**


 274         if (Platform.isWindows()) {
 275             jaotc = bin.resolve("jaotc.exe");
 276         } else {
 277             jaotc = bin.resolve("jaotc");
 278         }
 279         return "" + Files.exists(jaotc);
 280     }
 281 
 282     /**
 283      * Check for CDS support.
 284      *
 285      * @return true if CDS is supported by the VM to be tested.
 286      */
 287     protected String vmCDS() {
 288         if (WB.isCDSIncludedInVmBuild()) {
 289             return "true";
 290         } else {
 291             return "false";
 292         }
 293     }



























 294 
 295     /**
 296      * Dumps the map to the file if the file name is given as the property.
 297      * This functionality could be helpful to know context in the real
 298      * execution.
 299      *
 300      * @param map
 301      */
 302     protected static void dump(Map<String, String> map) {
 303         String dumpFileName = System.getProperty("vmprops.dump");
 304         if (dumpFileName == null) {
 305             return;
 306         }
 307         List<String> lines = new ArrayList<>();
 308         map.forEach((k, v) -> lines.add(k + ":" + v));
 309         try {
 310             Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
 311         } catch (IOException e) {
 312             throw new RuntimeException("Failed to dump properties into '"
 313                     + dumpFileName + "'", e);


  56      *
  57      * @return Map of property-value pairs.
  58      */
  59     @Override
  60     public Map<String, String> call() {
  61         Map<String, String> map = new HashMap<>();
  62         map.put("vm.flavor", vmFlavor());
  63         map.put("vm.compMode", vmCompMode());
  64         map.put("vm.bits", vmBits());
  65         map.put("vm.flightRecorder", vmFlightRecorder());
  66         map.put("vm.simpleArch", vmArch());
  67         map.put("vm.debug", vmDebug());
  68         map.put("vm.jvmci", vmJvmci());
  69         map.put("vm.emulatedClient", vmEmulatedClient());
  70         map.put("vm.cpu.features", cpuFeatures());
  71         map.put("vm.rtm.cpu", vmRTMCPU());
  72         map.put("vm.rtm.os", vmRTMOS());
  73         map.put("vm.aot", vmAOT());
  74         // vm.cds is true if the VM is compiled with cds support.
  75         map.put("vm.cds", vmCDS());
  76         map.put("docker.support", dockerSupport());
  77         vmGC(map); // vm.gc.X = true/false
  78 
  79         VMProps.dump(map);
  80         return map;
  81     }
  82 
  83     /**
  84      * Prints a stack trace before returning null.
  85      * Used by the various helper functions which parse information from
  86      * VM properties in the case where they don't find an expected property
  87      * or a propoerty doesn't conform to an expected format.
  88      *
  89      * @return null
  90      */
  91     private String nullWithException(String message) {
  92         new Exception(message).printStackTrace();
  93         return null;
  94     }
  95 
  96     /**


 275         if (Platform.isWindows()) {
 276             jaotc = bin.resolve("jaotc.exe");
 277         } else {
 278             jaotc = bin.resolve("jaotc");
 279         }
 280         return "" + Files.exists(jaotc);
 281     }
 282 
 283     /**
 284      * Check for CDS support.
 285      *
 286      * @return true if CDS is supported by the VM to be tested.
 287      */
 288     protected String vmCDS() {
 289         if (WB.isCDSIncludedInVmBuild()) {
 290             return "true";
 291         } else {
 292             return "false";
 293         }
 294     }
 295 
 296     /**
 297      * A simple check for docker support
 298      *
 299      * @return true if docker is supported in a given environment
 300      */
 301     protected String dockerSupport() {
 302         boolean isSupported;
 303         try {
 304             isSupported = checkDockerSupport();
 305         } catch (Exception e) {
 306             isSupported = false;
 307             System.err.println("dockerSupprt() threw exception: " + e);
 308         }
 309 
 310         return (isSupported) ? "true" : "false";
 311     }
 312 
 313     private boolean checkDockerSupport() throws IOException, InterruptedException {
 314         ProcessBuilder pb = new ProcessBuilder("docker", "ps");
 315         Process p = pb.start();
 316         p.waitFor();
 317 
 318         return (p.exitValue() == 0);
 319     }
 320 
 321 
 322 
 323     /**
 324      * Dumps the map to the file if the file name is given as the property.
 325      * This functionality could be helpful to know context in the real
 326      * execution.
 327      *
 328      * @param map
 329      */
 330     protected static void dump(Map<String, String> map) {
 331         String dumpFileName = System.getProperty("vmprops.dump");
 332         if (dumpFileName == null) {
 333             return;
 334         }
 335         List<String> lines = new ArrayList<>();
 336         map.forEach((k, v) -> lines.add(k + ":" + v));
 337         try {
 338             Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
 339         } catch (IOException e) {
 340             throw new RuntimeException("Failed to dump properties into '"
 341                     + dumpFileName + "'", e);
< prev index next >