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