1 /*
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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 /*
25 * @test
26 * @bug 6888954
27 * @bug 8015884
28 * @summary Exercise HotSpot error handling code by invoking java with
29 * -XX:ErrorHandlerTest option to cause an error report. Check the results.
30 * @modules java.base/jdk.internal.misc
31 * @library /test/lib
32 * @run driver ErrorHandler
33 */
34
35 import jdk.test.lib.Platform;
36 import jdk.test.lib.process.ProcessTools;
37 import jdk.test.lib.process.OutputAnalyzer;
38
39 public class ErrorHandler {
40
41 public static OutputAnalyzer runTest(int testcase) throws Exception {
42 return new OutputAnalyzer(
43 ProcessTools.createJavaProcessBuilder(
44 "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase)
45 .start());
46 }
47
48 public static void main(String[] args) throws Exception {
49 // Test is only applicable for debug builds
50 if (!Platform.isDebugBuild()) {
51 return;
52 }
53 // Keep this in sync with hotspot/src/share/vm/utilities/debug.cpp
54 int i = 1;
55 String[] strings = {
56 "assert(str == NULL) failed: expected null",
57 "assert(num == 1023 && *str == 'X') failed: num=",
58 "guarantee(str == NULL) failed: expected null",
59 "guarantee(num == 1023 && *str == 'X') failed: num=",
60 "fatal error: expected null",
61 "fatal error: num=",
62 "fatal error: this message should be truncated during formatting",
63 "ChunkPool::allocate",
64 "Error: ShouldNotCall()",
65 "Error: ShouldNotReachHere()",
66 "Error: Unimplemented()"
67 };
68
69 String[] patterns = {
70 "(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=",
71 "(SIGBUS|SIGSEGV|SIGILL|EXCEPTION_ACCESS_VIOLATION).* at pc="
72 };
73
74 for (String s : strings) {
75 runTest(i++).shouldContain(s);
76 }
77
78 for (String p : patterns) {
79 runTest(i++).shouldMatch(p);
80 }
81 }
82 }
|
1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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 /*
25 * @test
26 * @requires (vm.debug == true)
27 * @bug 6888954
28 * @bug 8015884
29 * @summary Exercise HotSpot error handling code by invoking java with
30 * -XX:ErrorHandlerTest option to cause an error report. Check the results.
31 * @modules java.base/jdk.internal.misc
32 * @library /test/lib
33 * @run driver ErrorHandler
34 */
35
36 import jdk.test.lib.Platform;
37 import jdk.test.lib.process.ProcessTools;
38 import jdk.test.lib.process.OutputAnalyzer;
39
40 public class ErrorHandler {
41
42 public static OutputAnalyzer runTest(int testcase) throws Exception {
43 // The -XX:ErrorHandlerTest=N option requires debug bits.
44 return new OutputAnalyzer(
45 ProcessTools.createJavaProcessBuilder(
46 "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase)
47 .start());
48 }
49
50 public static void main(String[] args) throws Exception {
51 // Keep this in sync with hotspot/src/share/vm/utilities/debug.cpp
52 int i = 1;
53 String[] strings = {
54 "assert(str == NULL) failed: expected null",
55 "assert(num == 1023 && *str == 'X') failed: num=",
56 "guarantee(str == NULL) failed: expected null",
57 "guarantee(num == 1023 && *str == 'X') failed: num=",
58 "fatal error: expected null",
59 "fatal error: num=",
60 "fatal error: this message should be truncated during formatting",
61 "ChunkPool::allocate",
62 "Error: ShouldNotCall()",
63 "Error: ShouldNotReachHere()",
64 "Error: Unimplemented()"
65 };
66
67 String[] patterns = {
68 "(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=",
69 "(SIGBUS|SIGSEGV|SIGILL|EXCEPTION_ACCESS_VIOLATION).* at pc="
70 // -XX:ErrorHandlerTest=14 is tested by SafeFetchInErrorHandlingTest.java
71 // -XX:ErrorHandlerTest=15 is tested by SecondaryErrorTest.java
72 // -XX:ErrorHandlerTest=16 is tested by ThreadsListHandleInErrorHandlingTest.java
73 // -XX:ErrorHandlerTest=17 is tested by NestedThreadsListHandleInErrorHandlingTest.java
74 };
75
76 for (String s : strings) {
77 runTest(i++).shouldContain(s);
78 }
79
80 for (String p : patterns) {
81 runTest(i++).shouldMatch(p);
82 }
83 }
84 }
|