author | stefank |
Fri, 10 Jun 2016 14:06:36 +0200 | |
changeset 39230 | b991240ffb0d |
parent 36851 | 03e2f4d0a421 |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
1 |
/* |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
4 |
* |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
8 |
* |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
13 |
* accompanied this code). |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
14 |
* |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
18 |
* |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
21 |
* questions. |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
22 |
*/ |
28944 | 23 |
|
24 |
||
25 |
/* |
|
26 |
* @test |
|
27 |
* @bug 8065896 |
|
28 |
* @summary Synchronous signals during error reporting may terminate or hang VM process |
|
29 |
* @library /testlibrary |
|
30 |
* @author Thomas Stuefe (SAP) |
|
36851 | 31 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28944
diff
changeset
|
32 |
* java.management |
28944 | 33 |
*/ |
34 |
||
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
35 |
import java.io.BufferedReader; |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
36 |
import java.io.File; |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
37 |
import java.io.FileInputStream; |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
38 |
import java.io.InputStreamReader; |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
39 |
import java.util.regex.Pattern; |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
40 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30240
diff
changeset
|
41 |
import jdk.test.lib.OutputAnalyzer; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30240
diff
changeset
|
42 |
import jdk.test.lib.Platform; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30240
diff
changeset
|
43 |
import jdk.test.lib.ProcessTools; |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
44 |
|
28944 | 45 |
public class SecondaryErrorTest { |
46 |
||
47 |
||
48 |
public static void main(String[] args) throws Exception { |
|
49 |
||
50 |
// Do not execute for windows, nor for non-debug builds |
|
51 |
if (Platform.isWindows()) { |
|
52 |
return; |
|
53 |
} |
|
54 |
||
55 |
if (!Platform.isDebugBuild()) { |
|
56 |
return; |
|
57 |
} |
|
58 |
||
59 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
|
60 |
"-XX:+UnlockDiagnosticVMOptions", |
|
61 |
"-Xmx100M", |
|
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
62 |
"-XX:-CreateCoredumpOnCrash", |
28944 | 63 |
"-XX:ErrorHandlerTest=15", |
64 |
"-XX:TestCrashInErrorHandler=14", |
|
65 |
"-version"); |
|
66 |
||
67 |
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start()); |
|
68 |
||
69 |
// we should have crashed with a SIGFPE |
|
70 |
output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*"); |
|
71 |
output_detail.shouldMatch("# +SIGFPE.*"); |
|
72 |
||
73 |
// extract hs-err file |
|
74 |
String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); |
|
75 |
if (hs_err_file == null) { |
|
76 |
throw new RuntimeException("Did not find hs-err file in output.\n"); |
|
77 |
} |
|
78 |
||
79 |
// scan hs-err file: File should contain the "[error occurred during error reporting..]" |
|
80 |
// markers which show that the secondary error handling kicked in and handled the |
|
81 |
// error successfully. As an added test, we check that the last line contains "END.", |
|
82 |
// which is an end marker written in the last step and proves that hs-err file was |
|
83 |
// completely written. |
|
84 |
File f = new File(hs_err_file); |
|
85 |
if (!f.exists()) { |
|
86 |
throw new RuntimeException("hs-err file missing at " |
|
87 |
+ f.getAbsolutePath() + ".\n"); |
|
88 |
} |
|
89 |
||
90 |
System.out.println("Found hs_err file. Scanning..."); |
|
91 |
||
92 |
FileInputStream fis = new FileInputStream(f); |
|
93 |
BufferedReader br = new BufferedReader(new InputStreamReader(fis)); |
|
94 |
String line = null; |
|
95 |
||
96 |
Pattern [] pattern = new Pattern[] { |
|
97 |
Pattern.compile("Will crash now \\(TestCrashInErrorHandler=14\\)..."), |
|
98 |
Pattern.compile("\\[error occurred during error reporting \\(test secondary crash 1\\).*\\]"), |
|
99 |
Pattern.compile("Will crash now \\(TestCrashInErrorHandler=14\\)..."), |
|
100 |
Pattern.compile("\\[error occurred during error reporting \\(test secondary crash 2\\).*\\]"), |
|
101 |
}; |
|
102 |
int currentPattern = 0; |
|
103 |
||
104 |
String lastLine = null; |
|
105 |
while ((line = br.readLine()) != null) { |
|
106 |
if (currentPattern < pattern.length) { |
|
107 |
if (pattern[currentPattern].matcher(line).matches()) { |
|
108 |
System.out.println("Found: " + line + "."); |
|
109 |
currentPattern ++; |
|
110 |
} |
|
111 |
} |
|
112 |
lastLine = line; |
|
113 |
} |
|
114 |
br.close(); |
|
115 |
||
116 |
if (currentPattern < pattern.length) { |
|
117 |
throw new RuntimeException("hs-err file incomplete (first missing pattern: " + currentPattern + ")"); |
|
118 |
} |
|
119 |
||
120 |
if (!lastLine.equals("END.")) { |
|
121 |
throw new RuntimeException("hs-err file incomplete (missing END marker.)"); |
|
122 |
} else { |
|
123 |
System.out.println("End marker found."); |
|
124 |
} |
|
125 |
||
126 |
System.out.println("OK."); |
|
127 |
||
128 |
} |
|
129 |
||
130 |
} |
|
131 |
||
132 |