348 System.out.println("\t" + t +
349 " stack: (length = " + stack.length + ")");
350 if (t != null) {
351 for (StackTraceElement stack1 : stack) {
352 System.out.println("\t" + stack1);
353 }
354 System.out.println();
355 }
356 }
357
358 /**
359 * Executes a test jvm process, waits for it to finish and returns the process output.
360 * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
361 * The java from the test.jdk is used to execute the command.
362 *
363 * The command line will be like:
364 * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds
365 *
366 * The jvm process will have exited before this method returns.
367 *
368 * @param cmds User specifed arguments.
369 * @return The output from the process.
370 */
371 public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception {
372 ProcessBuilder pb = createJavaProcessBuilder(Utils.addTestJavaOpts(cmds));
373 return executeProcess(pb);
374 }
375
376 /**
377 * Executes a process, waits for it to finish and returns the process output.
378 * The process will have exited before this method returns.
379 * @param pb The ProcessBuilder to execute.
380 * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
381 */
382 public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
383 OutputAnalyzer output = null;
384 Process p = null;
385 boolean failed = false;
386 try {
387 p = pb.start();
388 output = new OutputAnalyzer(p);
389 p.waitFor();
390
391 return output;
392 } catch (Throwable t) {
393 if (p != null) {
394 p.destroyForcibly().waitFor();
395 }
396
|
348 System.out.println("\t" + t +
349 " stack: (length = " + stack.length + ")");
350 if (t != null) {
351 for (StackTraceElement stack1 : stack) {
352 System.out.println("\t" + stack1);
353 }
354 System.out.println();
355 }
356 }
357
358 /**
359 * Executes a test jvm process, waits for it to finish and returns the process output.
360 * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
361 * The java from the test.jdk is used to execute the command.
362 *
363 * The command line will be like:
364 * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds
365 *
366 * The jvm process will have exited before this method returns.
367 *
368 * @param cmds User specified arguments.
369 * @return The output from the process.
370 */
371 public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception {
372 ProcessBuilder pb = createJavaProcessBuilder(Utils.addTestJavaOpts(cmds));
373 return executeProcess(pb);
374 }
375
376 /**
377 * @see #executeTestJvm(String...)
378 * @param cmds User specified arguments.
379 * @return The output from the process.
380 */
381 public static OutputAnalyzer executeTestJava(String... cmds) throws Exception {
382 return executeTestJvm(cmds);
383 }
384
385 /**
386 * Executes a process, waits for it to finish and returns the process output.
387 * The process will have exited before this method returns.
388 * @param pb The ProcessBuilder to execute.
389 * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
390 */
391 public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
392 OutputAnalyzer output = null;
393 Process p = null;
394 boolean failed = false;
395 try {
396 p = pb.start();
397 output = new OutputAnalyzer(p);
398 p.waitFor();
399
400 return output;
401 } catch (Throwable t) {
402 if (p != null) {
403 p.destroyForcibly().waitFor();
404 }
405
|