< prev index next >

test/runtime/ErrorHandling/TestOnError.java

Print this page
rev 8694 : [mq]: 8080733


  28  * @build TestOnError
  29  * @run main TestOnError
  30  * @bug 8078470
  31  */
  32 
  33 import jdk.test.lib.*;
  34 
  35 public class TestOnError {
  36 
  37     public static void main(String[] args) throws Exception {
  38         if (!Platform.isDebugBuild()) {
  39             System.out.println("Test requires a non-product build - skipping");
  40             return;
  41         }
  42 
  43         String msg = "Test Succeeded";
  44 
  45         // Execute the VM so that a
  46         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  47            "-XX:-TransmitErrorReport",

  48            "-XX:ErrorHandlerTest=12", // trigger potential SEGV
  49            "-XX:OnError=echo " + msg,
  50            TestOnError.class.getName());
  51 
  52         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  53 
  54         /* Actual output will include:
  55            #
  56            # -XX:OnError="echo Test Succeeded"
  57            #   Executing /bin/sh -c "echo Test Succeeded"...
  58            Test Succeeded
  59 
  60            So we don't want to match on the "# Executing ..." line, and they
  61            both get written to stdout.
  62         */
  63         output.stdoutShouldMatch("^" + msg); // match start of line only
  64         System.out.println("PASSED");
  65     }
  66 }


  28  * @build TestOnError
  29  * @run main TestOnError
  30  * @bug 8078470
  31  */
  32 
  33 import jdk.test.lib.*;
  34 
  35 public class TestOnError {
  36 
  37     public static void main(String[] args) throws Exception {
  38         if (!Platform.isDebugBuild()) {
  39             System.out.println("Test requires a non-product build - skipping");
  40             return;
  41         }
  42 
  43         String msg = "Test Succeeded";
  44 
  45         // Execute the VM so that a
  46         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  47            "-XX:-TransmitErrorReport",
  48            "-XX:-CreateCoredumpOnCrash",
  49            "-XX:ErrorHandlerTest=12", // trigger potential SEGV
  50            "-XX:OnError=echo " + msg,
  51            TestOnError.class.getName());
  52 
  53         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  54 
  55         /* Actual output will include:
  56            #
  57            # -XX:OnError="echo Test Succeeded"
  58            #   Executing /bin/sh -c "echo Test Succeeded"...
  59            Test Succeeded
  60 
  61            So we don't want to match on the "# Executing ..." line, and they
  62            both get written to stdout.
  63         */
  64         output.stdoutShouldMatch("^" + msg); // match start of line only
  65         System.out.println("PASSED");
  66     }
  67 }
< prev index next >