hotspot/test/runtime/memory/ReserveMemory.java
changeset 39279 2a8201076dd6
parent 36851 03e2f4d0a421
child 40631 ed82623d7831
equal deleted inserted replaced
39278:f3f298ae1023 39279:2a8201076dd6
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
       
    24 // Aix commits on touch, so this test won't work.
    24 /*
    25 /*
    25  * @test
    26  * @test
    26  * @key regression
    27  * @key regression
    27  * @bug 8012015
    28  * @bug 8012015
       
    29  * @requires !(os.family == "aix")
    28  * @summary Make sure reserved (but uncommitted) memory is not accessible
    30  * @summary Make sure reserved (but uncommitted) memory is not accessible
    29  * @library /testlibrary /test/lib
    31  * @library /testlibrary /test/lib
    30  * @modules java.base/jdk.internal.misc
    32  * @modules java.base/jdk.internal.misc
    31  *          java.management
    33  *          java.management
    32  * @build ReserveMemory
    34  * @build ReserveMemory
    34  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
    36  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
    35  * @run main ReserveMemory
    37  * @run main ReserveMemory
    36  */
    38  */
    37 
    39 
    38 import jdk.test.lib.*;
    40 import jdk.test.lib.*;
       
    41 import jdk.test.lib.Platform;
    39 
    42 
    40 import sun.hotspot.WhiteBox;
    43 import sun.hotspot.WhiteBox;
    41 
    44 
    42 public class ReserveMemory {
    45 public class ReserveMemory {
    43   private static boolean isWindows() {
       
    44     return System.getProperty("os.name").toLowerCase().startsWith("win");
       
    45   }
       
    46 
       
    47   private static boolean isOsx() {
       
    48     return System.getProperty("os.name").toLowerCase().startsWith("mac");
       
    49   }
       
    50 
       
    51   public static void main(String args[]) throws Exception {
    46   public static void main(String args[]) throws Exception {
    52     if (args.length > 0) {
    47     if (args.length > 0) {
    53       WhiteBox.getWhiteBox().readReservedMemory();
    48       WhiteBox.getWhiteBox().readReservedMemory();
    54 
    49 
    55       throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
    50       throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
    64           "-Xmx32m",
    59           "-Xmx32m",
    65           "ReserveMemory",
    60           "ReserveMemory",
    66           "test");
    61           "test");
    67 
    62 
    68     OutputAnalyzer output = new OutputAnalyzer(pb.start());
    63     OutputAnalyzer output = new OutputAnalyzer(pb.start());
    69     if (isWindows()) {
    64     if (Platform.isWindows()) {
    70       output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
    65       output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
    71     } else if (isOsx()) {
    66     } else if (Platform.isOSX()) {
    72       output.shouldContain("SIGBUS");
    67       output.shouldContain("SIGBUS");
    73     } else {
    68     } else {
    74       output.shouldContain("SIGSEGV");
    69       output.shouldContain("SIGSEGV");
    75     }
    70     }
    76   }
    71   }