author | hseigel |
Tue, 14 Jan 2014 13:51:47 -0500 | |
changeset 22492 | b6440c46dbce |
parent 21769 | 61c68af507c9 |
child 25334 | aadafa984752 |
permissions | -rw-r--r-- |
21554
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
1 |
/* |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
4 |
* |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
8 |
* |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
13 |
* accompanied this code). |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
14 |
* |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
18 |
* |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
21 |
* questions. |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
22 |
*/ |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
23 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
24 |
/* |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
25 |
* @test |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
26 |
* @summary Test that touching noaccess area in class ReservedHeapSpace results in SIGSEGV/ACCESS_VIOLATION |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
27 |
* @library /testlibrary /testlibrary/whitebox |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
28 |
* @build ReadFromNoaccessArea |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
29 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
30 |
* @run main ReadFromNoaccessArea |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
31 |
*/ |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
32 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
33 |
import com.oracle.java.testlibrary.*; |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
34 |
import sun.hotspot.WhiteBox; |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
35 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
36 |
public class ReadFromNoaccessArea { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
37 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
38 |
public static void main(String args[]) throws Exception { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
39 |
if (!Platform.is64bit()) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
40 |
System.out.println("ReadFromNoaccessArea tests is useful only on 64bit architecture. Passing silently."); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
41 |
return; |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
42 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
43 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
44 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
45 |
"-Xbootclasspath/a:.", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
46 |
"-XX:+UnlockDiagnosticVMOptions", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
47 |
"-XX:+WhiteBoxAPI", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
48 |
"-XX:+UseCompressedOops", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
49 |
"-XX:HeapBaseMinAddress=33G", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
50 |
DummyClassWithMainTryingToReadFromNoaccessArea.class.getName()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
51 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
52 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
53 |
System.out.println("******* Printing stdout for analysis in case of failure *******"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
54 |
System.out.println(output.getStdout()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
55 |
System.out.println("******* Printing stderr for analysis in case of failure *******"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
56 |
System.out.println(output.getStderr()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
57 |
System.out.println("***************************************************************"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
58 |
if (output.getStdout() != null && output.getStdout().contains("WB_ReadFromNoaccessArea method is useless")) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
59 |
// Test conditions broken. There is no protected page in ReservedHeapSpace in these circumstances. Silently passing test. |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
60 |
return; |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
61 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
62 |
if (Platform.isWindows()) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
63 |
output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
64 |
} else if (Platform.isOSX()) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
65 |
output.shouldContain("SIGBUS"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
66 |
} else { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
67 |
output.shouldContain("SIGSEGV"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
68 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
69 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
70 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
71 |
public static class DummyClassWithMainTryingToReadFromNoaccessArea { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
72 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
73 |
// This method calls whitebox method reading from noaccess area |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
74 |
public static void main(String args[]) throws Exception { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
75 |
WhiteBox.getWhiteBox().readFromNoaccessArea(); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
76 |
throw new Exception("Call of readFromNoaccessArea succeeded! This is wrong. Crash expected. Test failed."); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
77 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
78 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
79 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
80 |
} |