author | alanb |
Thu, 01 Dec 2016 15:54:39 +0000 | |
changeset 42309 | 21f9f3fbc302 |
parent 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
21554
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
21554
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 |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
27 |
* @library /test/lib |
36851 | 28 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
29 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
30 |
* @build sun.hotspot.WhiteBox |
21554
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
31 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
25958
8dc85547d6d6
8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents:
25334
diff
changeset
|
32 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
21554
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
33 |
* @run main ReadFromNoaccessArea |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
34 |
*/ |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
35 |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
36 |
import jdk.test.lib.Platform; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
37 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
38 |
import jdk.test.lib.process.OutputAnalyzer; |
21554
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
39 |
import sun.hotspot.WhiteBox; |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
40 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
41 |
public class ReadFromNoaccessArea { |
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 |
public static void main(String args[]) throws Exception { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
44 |
if (!Platform.is64bit()) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
45 |
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
|
46 |
return; |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
47 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
48 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
49 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
50 |
"-Xbootclasspath/a:.", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
51 |
"-XX:+UnlockDiagnosticVMOptions", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
52 |
"-XX:+WhiteBoxAPI", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
53 |
"-XX:+UseCompressedOops", |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
54 |
"-XX:HeapBaseMinAddress=33G", |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
29678
diff
changeset
|
55 |
"-XX:-CreateCoredumpOnCrash", |
25334
aadafa984752
8047878: [TESTBUG] runtime/memory/ReadFromNoaccessArea.java and runtime/memory/ReserveMemory.java time out on Solaris
ctornqvi
parents:
22492
diff
changeset
|
56 |
"-Xmx32m", |
21554
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
57 |
DummyClassWithMainTryingToReadFromNoaccessArea.class.getName()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
58 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
59 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
60 |
System.out.println("******* Printing stdout for analysis in case of failure *******"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
61 |
System.out.println(output.getStdout()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
62 |
System.out.println("******* Printing stderr for analysis in case of failure *******"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
63 |
System.out.println(output.getStderr()); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
64 |
System.out.println("***************************************************************"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
65 |
if (output.getStdout() != null && output.getStdout().contains("WB_ReadFromNoaccessArea method is useless")) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
66 |
// 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
|
67 |
return; |
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 |
if (Platform.isWindows()) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
70 |
output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
71 |
} else if (Platform.isOSX()) { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
72 |
output.shouldContain("SIGBUS"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
73 |
} else { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
74 |
output.shouldContain("SIGSEGV"); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
75 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
76 |
} |
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 |
public static class DummyClassWithMainTryingToReadFromNoaccessArea { |
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 |
// This method calls whitebox method reading from noaccess area |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
81 |
public static void main(String args[]) throws Exception { |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
82 |
WhiteBox.getWhiteBox().readFromNoaccessArea(); |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
83 |
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
|
84 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
85 |
} |
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
86 |
|
20b1821f4fbd
8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff
changeset
|
87 |
} |