hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java
author ykantser
Thu, 26 Mar 2015 16:36:56 +0100
changeset 29678 dd2f3932c21e
parent 28018 abc067cd68fd
child 30146 a5809dde4617
permissions -rw-r--r--
8075586: Add @modules as needed to the open hotspot tests Reviewed-by: sla, ctornqvi, lfoltan, mchung, alanb Contributed-by: alexander.kulyakhtin@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28018
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     4
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     8
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    13
 * accompanied this code).
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    14
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    18
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    21
 * questions.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    22
 */
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    23
25896
5f21a029fdeb 8053956: [TESTBUG] Remove @ignore tag from fixed runtime issues
ctornqvi
parents: 24840
diff changeset
    24
/* @test LimitSharedSizes
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    25
 * @summary Test handling of limits on shared space size
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    26
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28018
diff changeset
    27
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28018
diff changeset
    28
 *          java.management
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    29
 * @run main LimitSharedSizes
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    30
 */
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    31
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    32
import com.oracle.java.testlibrary.*;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    33
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    34
public class LimitSharedSizes {
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    35
    static enum Region {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    36
        RO, RW, MD, MC
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    37
    }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    38
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    39
    private static class SharedSizeTestData {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    40
        public String optionName;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    41
        public String optionValue;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    42
        public String expectedErrorMsg;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    43
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    44
        public SharedSizeTestData(Region region, String value, String msg) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    45
            optionName = getName(region);
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    46
            optionValue = value;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    47
            expectedErrorMsg = msg;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    48
        }
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    49
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    50
        public SharedSizeTestData(Region region, String msg) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    51
            optionName = getName(region);
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    52
            optionValue = getValue(region);
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    53
            expectedErrorMsg = msg;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    54
        }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    55
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    56
        private String getName(Region region) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    57
            String name;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    58
            switch (region) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    59
                case RO:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    60
                    name = "-XX:SharedReadOnlySize";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    61
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    62
                case RW:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    63
                    name = "-XX:SharedReadWriteSize";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    64
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    65
                case MD:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    66
                    name = "-XX:SharedMiscDataSize";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    67
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    68
                case MC:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    69
                    name = "-XX:SharedMiscCodeSize";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    70
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    71
                default:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    72
                    name = "Unknown";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    73
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    74
            }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    75
            return name;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    76
        }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    77
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    78
        private String getValue(Region region) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    79
            String value;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    80
            switch (region) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    81
                case RO:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    82
                    value = Platform.is64bit() ? "9M" : "8M";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    83
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    84
                case RW:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    85
                    value = Platform.is64bit() ? "12M" : "7M";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    86
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    87
                case MD:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    88
                    value = Platform.is64bit() ? "4M" : "2M";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    89
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    90
                case MC:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    91
                    value = "120k";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    92
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    93
                default:
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    94
                    value = "0M";
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    95
                    break;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    96
            }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    97
            return value;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
    98
        }
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    99
    }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   100
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   101
    private static final SharedSizeTestData[] testTable = {
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   102
        // Too small of a region size should not cause a vm crash.
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   103
        // It should result in an error message like the following:
27404
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
   104
        // The shared miscellaneous code space is not large enough
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
   105
        // to preload requested classes. Use -XX:SharedMiscCodeSize=
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
   106
        // to increase the initial size of shared miscellaneous code space.
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   107
        new SharedSizeTestData(Region.RO, "4M",   "read only"),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   108
        new SharedSizeTestData(Region.RW, "4M",   "read write"),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   109
        new SharedSizeTestData(Region.MD, "50k",  "miscellaneous data"),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   110
        new SharedSizeTestData(Region.MC, "20k",  "miscellaneous code"),
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   111
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   112
        // these values are larger than default ones, but should
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   113
        // be acceptable and not cause failure
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   114
        new SharedSizeTestData(Region.RO, "20M", null),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   115
        new SharedSizeTestData(Region.RW, "20M", null),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   116
        new SharedSizeTestData(Region.MD, "20M", null),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   117
        new SharedSizeTestData(Region.MC, "20M", null),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   118
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   119
        // test with sizes which just meet the minimum required sizes
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   120
        // the following tests also attempt to use the shared archive
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   121
        new SharedSizeTestData(Region.RO, "UseArchive"),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   122
        new SharedSizeTestData(Region.RW, "UseArchive"),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   123
        new SharedSizeTestData(Region.MD, "UseArchive"),
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   124
        new SharedSizeTestData(Region.MC, "UseArchive")
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   125
    };
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   126
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   127
    public static void main(String[] args) throws Exception {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   128
        String fileName = "test.jsa";
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   129
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   130
        for (SharedSizeTestData td : testTable) {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   131
            String option = td.optionName + "=" + td.optionValue;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   132
            System.out.println("testing option <" + option + ">");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   133
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   134
            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   135
               "-XX:+UnlockDiagnosticVMOptions",
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   136
               "-XX:SharedArchiveFile=./" + fileName,
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   137
               option,
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   138
               "-Xshare:dump");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   139
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   140
            OutputAnalyzer output = new OutputAnalyzer(pb.start());
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   141
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   142
            if (td.expectedErrorMsg != null) {
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   143
                if (!td.expectedErrorMsg.equals("UseArchive")) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   144
                    output.shouldContain("The shared " + td.expectedErrorMsg
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   145
                        + " space is not large enough");
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   146
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   147
                    output.shouldHaveExitValue(2);
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   148
                } else {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   149
                    output.shouldNotContain("space is not large enough");
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   150
                    output.shouldHaveExitValue(0);
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   151
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   152
                    // try to use the archive
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   153
                    pb = ProcessTools.createJavaProcessBuilder(
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   154
                       "-XX:+UnlockDiagnosticVMOptions",
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   155
                       "-XX:SharedArchiveFile=./" + fileName,
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   156
                       "-XX:+PrintSharedArchiveAndExit",
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   157
                       "-version");
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   158
28018
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   159
                    try {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   160
                        output = new OutputAnalyzer(pb.start());
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   161
                        output.shouldContain("archive is valid");
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   162
                    } catch (RuntimeException e) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   163
                        // if sharing failed due to ASLR or similar reasons,
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   164
                        // check whether sharing was attempted at all (UseSharedSpaces)
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   165
                        if ((output.getOutput().contains("Unable to use shared archive") ||
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   166
                             output.getOutput().contains("Unable to map ReadOnly shared space at required address.") ||
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   167
                             output.getOutput().contains("Unable to map ReadWrite shared space at required address.") ||
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   168
                             output.getOutput().contains("Unable to reserve shared space at required address")) &&
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   169
                             output.getExitValue() == 1) {
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   170
                             System.out.println("Unable to use shared archive: test not executed; assumed passed");
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   171
                             return;
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   172
                        }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   173
                    }
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   174
                    output.shouldHaveExitValue(0);
abc067cd68fd 8065050: vm crashes during CDS dump when very small SharedMiscDataSize is specified
ccheung
parents: 27404
diff changeset
   175
                }
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   176
            } else {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   177
                output.shouldNotContain("space is not large enough");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   178
                output.shouldHaveExitValue(0);
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   179
            }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   180
        }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   181
    }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
   182
}