Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java
40942 views
1
/*
2
* Copyright (c) 2015, 2020, 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
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.process.ProcessTools;
32
33
/*
34
* @test
35
* @bug 8074552
36
* @summary SafeFetch32 and SafeFetchN do not work in error handling
37
* @modules java.base/jdk.internal.misc
38
* @library /test/lib
39
* @requires vm.debug
40
* @requires vm.flavor != "zero"
41
* @author Thomas Stuefe (SAP)
42
* @run driver SafeFetchInErrorHandlingTest
43
*/
44
45
public class SafeFetchInErrorHandlingTest {
46
47
public static void main(String[] args) throws Exception {
48
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
49
"-XX:+UnlockDiagnosticVMOptions",
50
"-Xmx100M",
51
"-XX:ErrorHandlerTest=14",
52
"-XX:+TestSafeFetchInErrorHandler",
53
"-XX:-CreateCoredumpOnCrash",
54
"-version");
55
56
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
57
58
// we should have crashed with a SIGSEGV
59
output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
60
output_detail.shouldMatch("# +(?:SIGSEGV|SIGBUS|EXCEPTION_ACCESS_VIOLATION).*");
61
62
// extract hs-err file
63
String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
64
if (hs_err_file == null) {
65
throw new RuntimeException("Did not find hs-err file in output.\n");
66
}
67
68
File f = new File(hs_err_file);
69
if (!f.exists()) {
70
throw new RuntimeException("hs-err file missing at "
71
+ f.getAbsolutePath() + ".\n");
72
}
73
74
System.out.println("Found hs_err file. Scanning...");
75
76
FileInputStream fis = new FileInputStream(f);
77
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
78
String line = null;
79
80
Pattern [] pattern = new Pattern[] {
81
Pattern.compile("Will test SafeFetch..."),
82
Pattern.compile("SafeFetch OK."),
83
};
84
int currentPattern = 0;
85
86
String lastLine = null;
87
while ((line = br.readLine()) != null) {
88
if (currentPattern < pattern.length) {
89
if (pattern[currentPattern].matcher(line).matches()) {
90
System.out.println("Found: " + line + ".");
91
currentPattern ++;
92
}
93
}
94
lastLine = line;
95
}
96
br.close();
97
98
if (currentPattern < pattern.length) {
99
throw new RuntimeException("hs-err file incomplete (first missing pattern: " + currentPattern + ")");
100
}
101
102
if (!lastLine.equals("END.")) {
103
throw new RuntimeException("hs-err file incomplete (missing END marker.)");
104
} else {
105
System.out.println("End marker found.");
106
}
107
108
System.out.println("OK.");
109
110
}
111
112
}
113
114
115