< prev index next >

test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java

Print this page
rev 47862 : imported patch 10.07.open.rebase_20171110.dcubed
rev 47867 : coleenp CR: Change ThreadsList::_threads from 'mtGC' -> 'mtThread', add header comment to threadSMR.hpp file, cleanup JavaThreadIteratorWithHandle ctr, make ErrorHandling more efficient.


  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.BufferedReader;
  25 import java.io.File;
  26 import java.io.FileInputStream;
  27 import java.io.InputStreamReader;
  28 import java.util.regex.Pattern;
  29 
  30 import jdk.test.lib.process.OutputAnalyzer;
  31 import jdk.test.lib.Platform;
  32 import jdk.test.lib.process.ProcessTools;
  33 
  34 /*
  35  * @test

  36  * @bug 8167108
  37  * @summary Nested ThreadsListHandle info should be in error handling output.
  38  * @modules java.base/jdk.internal.misc
  39  * @library /test/lib
  40  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+EnableThreadSMRStatistics NestedThreadsListHandleInErrorHandlingTest
  41  */
  42 
  43 /*
  44  * This test was created using SafeFetchInErrorHandlingTest.java
  45  * as a guide.
  46  */
  47 public class NestedThreadsListHandleInErrorHandlingTest {
  48   public static void main(String[] args) throws Exception {
  49 
  50     if (!Platform.isDebugBuild()) {
  51         // -XX:ErrorHandlerTest=N option requires debug bits.
  52         return;
  53     }
  54 
  55     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  56         "-XX:+UnlockDiagnosticVMOptions",
  57         "-Xmx100M",
  58         "-XX:ErrorHandlerTest=17",
  59         "-XX:-CreateCoredumpOnCrash",
  60         "-version");
  61 
  62     OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
  63 
  64     // We should have crashed with a specific fatal error:
  65     output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
  66     System.out.println("Found fatal error header.");
  67     output_detail.shouldMatch("# +fatal error: Force crash with a nested ThreadsListHandle.");
  68     System.out.println("Found specific fatal error.");
  69 
  70     // Extract hs_err_pid file.
  71     String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
  72     if (hs_err_file == null) {
  73         throw new RuntimeException("Did not find hs_err_pid file in output.\n");
  74     }




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.BufferedReader;
  25 import java.io.File;
  26 import java.io.FileInputStream;
  27 import java.io.InputStreamReader;
  28 import java.util.regex.Pattern;
  29 
  30 import jdk.test.lib.process.OutputAnalyzer;
  31 import jdk.test.lib.Platform;
  32 import jdk.test.lib.process.ProcessTools;
  33 
  34 /*
  35  * @test
  36  * @requires (vm.debug == true)
  37  * @bug 8167108
  38  * @summary Nested ThreadsListHandle info should be in error handling output.
  39  * @modules java.base/jdk.internal.misc
  40  * @library /test/lib
  41  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+EnableThreadSMRStatistics NestedThreadsListHandleInErrorHandlingTest
  42  */
  43 
  44 /*
  45  * This test was created using SafeFetchInErrorHandlingTest.java
  46  * as a guide.
  47  */
  48 public class NestedThreadsListHandleInErrorHandlingTest {
  49   public static void main(String[] args) throws Exception {
  50 
  51     // The -XX:ErrorHandlerTest=N option requires debug bits.




  52     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  53         "-XX:+UnlockDiagnosticVMOptions",
  54         "-Xmx100M",
  55         "-XX:ErrorHandlerTest=17",
  56         "-XX:-CreateCoredumpOnCrash",
  57         "-version");
  58 
  59     OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
  60 
  61     // We should have crashed with a specific fatal error:
  62     output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
  63     System.out.println("Found fatal error header.");
  64     output_detail.shouldMatch("# +fatal error: Force crash with a nested ThreadsListHandle.");
  65     System.out.println("Found specific fatal error.");
  66 
  67     // Extract hs_err_pid file.
  68     String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
  69     if (hs_err_file == null) {
  70         throw new RuntimeException("Did not find hs_err_pid file in output.\n");
  71     }


< prev index next >