hotspot/test/runtime/SharedArchiveFile/MaxMetaspaceSize.java
author goetz
Thu, 03 Aug 2017 10:24:34 +0200
changeset 46779 d80ca591ae48
parent 46746 ea379ebb9447
permissions -rw-r--r--
8185436: jtreg: introduce @requires property to disable cds tests Summary: Fix CompressedClassPointers test to succeed also if cds is not available. Reviewed-by: jiangli, mseledtsov, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     1
/*
46491
e43953993af3 8180631: [TESTBUG] CDS tests should use CDSTestUtils.executeAndLog whenever spawning sub processes
mseledtsov
parents: 40631
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     4
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     8
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    13
 * accompanied this code).
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    14
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    18
 *
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    21
 * questions.
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    22
 */
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    23
46779
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46746
diff changeset
    24
/**
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    25
 * @test
46779
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46746
diff changeset
    26
 * @requires vm.cds
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    27
 * @bug 8067187
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    28
 * @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 37776
diff changeset
    29
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 30604
diff changeset
    30
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28476
diff changeset
    31
 *          java.management
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    32
 */
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    33
46491
e43953993af3 8180631: [TESTBUG] CDS tests should use CDSTestUtils.executeAndLog whenever spawning sub processes
mseledtsov
parents: 40631
diff changeset
    34
import jdk.test.lib.cds.CDSTestUtils;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 37776
diff changeset
    35
import jdk.test.lib.process.ProcessTools;
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    36
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    37
public class MaxMetaspaceSize {
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    38
  public static void main(String[] args) throws Exception {
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46491
diff changeset
    39
    String msg = "OutOfMemoryError: Metaspace";
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    40
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46491
diff changeset
    41
        "-XX:MaxMetaspaceSize=1m", "-Xshare:dump");
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46491
diff changeset
    42
    CDSTestUtils.executeAndLog(pb, "dump").shouldContain(msg).shouldHaveExitValue(1);
28476
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    43
  }
ae1ca3bf45ca 8067187: -XX:MaxMetaspaceSize=20m -Xshare:dump caused JVM to crash
ccheung
parents:
diff changeset
    44
}