< prev index next >

test/jtreg-ext/requires/VMProps.java

Print this page




  80         // and jhsdb and it can attach to the VM.
  81         map.put("vm.hasSAandCanAttach", vmHasSAandCanAttach());
  82         // vm.hasJFR is "true" if JFR is included in the build of the VM and
  83         // so tests can be executed.
  84         map.put("vm.hasJFR", vmHasJFR());
  85         map.put("vm.cpu.features", cpuFeatures());
  86         map.put("vm.rtm.cpu", vmRTMCPU());
  87         map.put("vm.rtm.compiler", vmRTMCompiler());
  88         map.put("vm.aot", vmAOT());
  89         map.put("vm.aot.enabled", vmAotEnabled());
  90         // vm.cds is true if the VM is compiled with cds support.
  91         map.put("vm.cds", vmCDS());
  92         map.put("vm.cds.custom.loaders", vmCDSForCustomLoaders());
  93         map.put("vm.cds.archived.java.heap", vmCDSForArchivedJavaHeap());
  94         // vm.graal.enabled is true if Graal is used as JIT
  95         map.put("vm.graal.enabled", isGraalEnabled());
  96         map.put("vm.compiler1.enabled", isCompiler1Enabled());
  97         map.put("vm.compiler2.enabled", isCompiler2Enabled());
  98         map.put("docker.support", dockerSupport());
  99         map.put("release.implementor", implementor());

 100         vmGC(map); // vm.gc.X = true/false
 101         vmOptFinalFlags(map);
 102 
 103         VMProps.dump(map);
 104         return map;
 105     }
 106 
 107     /**
 108      * Prints a stack trace before returning null.
 109      * Used by the various helper functions which parse information from
 110      * VM properties in the case where they don't find an expected property
 111      * or a propoerty doesn't conform to an expected format.
 112      *
 113      * @return null
 114      */
 115     private String nullWithException(String message) {
 116         new Exception(message).printStackTrace();
 117         return null;
 118     }
 119 


 451         ProcessBuilder pb = new ProcessBuilder("docker", "ps");
 452         Process p = pb.start();
 453         p.waitFor(10, TimeUnit.SECONDS);
 454 
 455         return (p.exitValue() == 0);
 456     }
 457 
 458 
 459     private String implementor() {
 460         try (InputStream in = new BufferedInputStream(new FileInputStream(
 461                 System.getProperty("java.home") + "/release"))) {
 462             Properties properties = new Properties();
 463             properties.load(in);
 464             String implementorProperty = properties.getProperty("IMPLEMENTOR");
 465             return (implementorProperty == null) ? "null" : implementorProperty.replace("\"", "");
 466         } catch (IOException e) {
 467             e.printStackTrace();
 468         }
 469         return null;
 470     }









 471 
 472 
 473     /**
 474      * Dumps the map to the file if the file name is given as the property.
 475      * This functionality could be helpful to know context in the real
 476      * execution.
 477      *
 478      * @param map
 479      */
 480     protected static void dump(Map<String, String> map) {
 481         String dumpFileName = System.getProperty("vmprops.dump");
 482         if (dumpFileName == null) {
 483             return;
 484         }
 485         List<String> lines = new ArrayList<>();
 486         map.forEach((k, v) -> lines.add(k + ":" + v));
 487         try {
 488             Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
 489         } catch (IOException e) {
 490             throw new RuntimeException("Failed to dump properties into '"


  80         // and jhsdb and it can attach to the VM.
  81         map.put("vm.hasSAandCanAttach", vmHasSAandCanAttach());
  82         // vm.hasJFR is "true" if JFR is included in the build of the VM and
  83         // so tests can be executed.
  84         map.put("vm.hasJFR", vmHasJFR());
  85         map.put("vm.cpu.features", cpuFeatures());
  86         map.put("vm.rtm.cpu", vmRTMCPU());
  87         map.put("vm.rtm.compiler", vmRTMCompiler());
  88         map.put("vm.aot", vmAOT());
  89         map.put("vm.aot.enabled", vmAotEnabled());
  90         // vm.cds is true if the VM is compiled with cds support.
  91         map.put("vm.cds", vmCDS());
  92         map.put("vm.cds.custom.loaders", vmCDSForCustomLoaders());
  93         map.put("vm.cds.archived.java.heap", vmCDSForArchivedJavaHeap());
  94         // vm.graal.enabled is true if Graal is used as JIT
  95         map.put("vm.graal.enabled", isGraalEnabled());
  96         map.put("vm.compiler1.enabled", isCompiler1Enabled());
  97         map.put("vm.compiler2.enabled", isCompiler2Enabled());
  98         map.put("docker.support", dockerSupport());
  99         map.put("release.implementor", implementor());
 100         map.put("vm.nvdimm.test.enabled", isNvdimmTestEnabled());
 101         vmGC(map); // vm.gc.X = true/false
 102         vmOptFinalFlags(map);
 103 
 104         VMProps.dump(map);
 105         return map;
 106     }
 107 
 108     /**
 109      * Prints a stack trace before returning null.
 110      * Used by the various helper functions which parse information from
 111      * VM properties in the case where they don't find an expected property
 112      * or a propoerty doesn't conform to an expected format.
 113      *
 114      * @return null
 115      */
 116     private String nullWithException(String message) {
 117         new Exception(message).printStackTrace();
 118         return null;
 119     }
 120 


 452         ProcessBuilder pb = new ProcessBuilder("docker", "ps");
 453         Process p = pb.start();
 454         p.waitFor(10, TimeUnit.SECONDS);
 455 
 456         return (p.exitValue() == 0);
 457     }
 458 
 459 
 460     private String implementor() {
 461         try (InputStream in = new BufferedInputStream(new FileInputStream(
 462                 System.getProperty("java.home") + "/release"))) {
 463             Properties properties = new Properties();
 464             properties.load(in);
 465             String implementorProperty = properties.getProperty("IMPLEMENTOR");
 466             return (implementorProperty == null) ? "null" : implementorProperty.replace("\"", "");
 467         } catch (IOException e) {
 468             e.printStackTrace();
 469         }
 470         return null;
 471     }
 472 
 473     private String isNvdimmTestEnabled() {
 474         String isEnbled = System.getenv("VM_NVDIMM_TEST");
 475         if (isEnbled != null && isEnbled.toLowerCase().equals("true")) {
 476             return "true";
 477         }
 478         return "false";
 479     }
 480 
 481 
 482 
 483     /**
 484      * Dumps the map to the file if the file name is given as the property.
 485      * This functionality could be helpful to know context in the real
 486      * execution.
 487      *
 488      * @param map
 489      */
 490     protected static void dump(Map<String, String> map) {
 491         String dumpFileName = System.getProperty("vmprops.dump");
 492         if (dumpFileName == null) {
 493             return;
 494         }
 495         List<String> lines = new ArrayList<>();
 496         map.forEach((k, v) -> lines.add(k + ":" + v));
 497         try {
 498             Files.write(Paths.get(dumpFileName), lines, StandardOpenOption.APPEND);
 499         } catch (IOException e) {
 500             throw new RuntimeException("Failed to dump properties into '"
< prev index next >