test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8039260 Sdiff test/testlibrary/com/oracle/java/testlibrary

test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java

Print this page
rev 6236 : 8039260: c.o.j.t.ProcessTools::createJavaProcessBuilder(boolean, String... ) must also take TestJavaOptions
Reviewed-by: iignatyev
Contributed-by: lev.priima@oracle.com


 128    *
 129    * @return String[] with platform specific arguments, empty if there are none
 130    */
 131   public static String[] getPlatformSpecificVMArgs() {
 132 
 133     if (Platform.is64bit() && Platform.isSolaris()) {
 134       return new String[] { "-d64" };
 135     }
 136 
 137     return new String[] {};
 138   }
 139 
 140   /**
 141    * Create ProcessBuilder using the java launcher from the jdk to be tested and
 142    * with any platform specific arguments prepended
 143    */
 144   public static ProcessBuilder createJavaProcessBuilder(String... command) throws Exception {
 145     return createJavaProcessBuilder(false, command);
 146   }
 147 
 148   public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmOptions, String... command) throws Exception {
 149     String javapath = JDKToolFinder.getJDKTool("java");
 150 
 151     ArrayList<String> args = new ArrayList<>();
 152     args.add(javapath);
 153     Collections.addAll(args, getPlatformSpecificVMArgs());
 154 
 155     if (addTestVmOptions) {
 156       String vmopts = System.getProperty("test.vm.opts");
 157       if (vmopts != null && vmopts.length() > 0) {
 158         Collections.addAll(args, vmopts.split("\\s"));
 159       }
 160     }
 161 
 162     Collections.addAll(args, command);
 163 
 164     // Reporting
 165     StringBuilder cmdLine = new StringBuilder();
 166     for (String cmd : args) {
 167       cmdLine.append(cmd).append(' ');
 168     }
 169     System.out.println("Command line: [" + cmdLine.toString() + "]");
 170 
 171     return new ProcessBuilder(args.toArray(new String[args.size()]));
 172   }
 173 
 174   /**
 175    * Executes a test jvm process, waits for it to finish and returns the process output.
 176    * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
 177    * The java from the test.jdk is used to execute the command.
 178    *
 179    * The command line will be like:




 128    *
 129    * @return String[] with platform specific arguments, empty if there are none
 130    */
 131   public static String[] getPlatformSpecificVMArgs() {
 132 
 133     if (Platform.is64bit() && Platform.isSolaris()) {
 134       return new String[] { "-d64" };
 135     }
 136 
 137     return new String[] {};
 138   }
 139 
 140   /**
 141    * Create ProcessBuilder using the java launcher from the jdk to be tested and
 142    * with any platform specific arguments prepended
 143    */
 144   public static ProcessBuilder createJavaProcessBuilder(String... command) throws Exception {
 145     return createJavaProcessBuilder(false, command);
 146   }
 147 
 148   public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
 149     String javapath = JDKToolFinder.getJDKTool("java");
 150 
 151     ArrayList<String> args = new ArrayList<>();
 152     args.add(javapath);
 153     Collections.addAll(args, getPlatformSpecificVMArgs());
 154 
 155     if (addTestVmAndJavaOptions) {
 156       Collections.addAll(args, Utils.getTestJavaOpts());



 157     }
 158 
 159     Collections.addAll(args, command);
 160 
 161     // Reporting
 162     StringBuilder cmdLine = new StringBuilder();
 163     for (String cmd : args) {
 164       cmdLine.append(cmd).append(' ');
 165     }
 166     System.out.println("Command line: [" + cmdLine.toString() + "]");
 167 
 168     return new ProcessBuilder(args.toArray(new String[args.size()]));
 169   }
 170 
 171   /**
 172    * Executes a test jvm process, waits for it to finish and returns the process output.
 173    * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
 174    * The java from the test.jdk is used to execute the command.
 175    *
 176    * The command line will be like:


test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File