test/runtime/SharedArchiveFile/LimitSharedSizes.java

Mon, 06 Nov 2017 16:51:47 +0800

author
aoqi
date
Mon, 06 Nov 2017 16:51:47 +0800
changeset 7997
6cbff0651f1a
parent 7300
03e6d34be1f5
permissions
-rw-r--r--

[Code Reorganization] remove trailing whitespace to pass jcheck test

     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    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
    21  * questions.
    22  */
    24 /* @test LimitSharedSizes
    25  * @summary Test handling of limits on shared space size
    26  * @library /testlibrary
    27  * @run main LimitSharedSizes
    28  */
    30 import com.oracle.java.testlibrary.*;
    32 public class LimitSharedSizes {
    33     private static class SharedSizeTestData {
    34         public String optionName;
    35         public String optionValue;
    36         public String expectedErrorMsg;
    38         public SharedSizeTestData(String name, String value, String msg) {
    39             optionName = name;
    40             optionValue = value;
    41             expectedErrorMsg = msg;
    42         }
    43     }
    45     private static final SharedSizeTestData[] testTable = {
    46         // values in this part of the test table should cause failure
    47         // (shared space sizes are deliberately too small)
    48         new SharedSizeTestData("-XX:SharedReadOnlySize", "4M",      "read only"),
    49         new SharedSizeTestData("-XX:SharedReadWriteSize","4M",      "read write"),
    51         // Known issue, JDK-8038422 (assert() on Windows)
    52         // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k",    "miscellaneous data"),
    54         // Too small of a misc code size should not cause a vm crash.
    55         // It should result in the following error message:
    56         // The shared miscellaneous code space is not large enough
    57         // to preload requested classes. Use -XX:SharedMiscCodeSize=
    58         // to increase the initial size of shared miscellaneous code space.
    59         new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k",     "miscellaneous code"),
    61         // these values are larger than default ones, but should
    62         // be acceptable and not cause failure
    63         new SharedSizeTestData("-XX:SharedReadOnlySize",    "20M", null),
    64         new SharedSizeTestData("-XX:SharedReadWriteSize",   "20M", null),
    65         new SharedSizeTestData("-XX:SharedMiscDataSize",    "20M", null),
    66         new SharedSizeTestData("-XX:SharedMiscCodeSize",    "20M", null)
    67     };
    69     public static void main(String[] args) throws Exception {
    70         String fileName = "test.jsa";
    72         for (SharedSizeTestData td : testTable) {
    73             String option = td.optionName + "=" + td.optionValue;
    74             System.out.println("testing option <" + option + ">");
    76             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    77                "-XX:+UnlockDiagnosticVMOptions",
    78                "-XX:SharedArchiveFile=./" + fileName,
    79                option,
    80                "-Xshare:dump");
    82             OutputAnalyzer output = new OutputAnalyzer(pb.start());
    84             if (td.expectedErrorMsg != null) {
    85                 output.shouldContain("The shared " + td.expectedErrorMsg
    86                     + " space is not large enough");
    88                 output.shouldHaveExitValue(2);
    89             } else {
    90                 output.shouldNotContain("space is not large enough");
    91                 output.shouldHaveExitValue(0);
    92             }
    93         }
    94     }
    95 }

mercurial