annotate test/runtime/SharedArchiveFile/LimitSharedSizes.java @ 20700:0558eb13dcf3

8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid Summary: in FileMapInfo::fail_continue do not set UseSharedSpaces = false Reviewed-by: dholmes, ccheung
author iklam
date Thu, 04 Dec 2014 15:20:09 -0800
parents 03e6d34be1f5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20488
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
1 /*
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
4 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
7 * published by the Free Software Foundation.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
8 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
13 * accompanied this code).
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
14 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
18 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
21 * questions.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
22 */
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
23
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
24 /* @test LimitSharedSizes
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
25 * @summary Test handling of limits on shared space size
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
26 * @library /testlibrary
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
27 * @run main LimitSharedSizes
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
28 */
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
29
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
30 import com.oracle.java.testlibrary.*;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
31
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
32 public class LimitSharedSizes {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
33 private static class SharedSizeTestData {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
34 public String optionName;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
35 public String optionValue;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
36 public String expectedErrorMsg;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
37
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
38 public SharedSizeTestData(String name, String value, String msg) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
39 optionName = name;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
40 optionValue = value;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
41 expectedErrorMsg = msg;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
42 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
43 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
44
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
45 private static final SharedSizeTestData[] testTable = {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
46 // values in this part of the test table should cause failure
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
47 // (shared space sizes are deliberately too small)
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
48 new SharedSizeTestData("-XX:SharedReadOnlySize", "4M", "read only"),
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
49 new SharedSizeTestData("-XX:SharedReadWriteSize","4M", "read write"),
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
50
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
51 // Known issue, JDK-8038422 (assert() on Windows)
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
52 // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k", "miscellaneous data"),
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
53
20586
03e6d34be1f5 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 20488
diff changeset
54 // Too small of a misc code size should not cause a vm crash.
03e6d34be1f5 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 20488
diff changeset
55 // It should result in the following error message:
03e6d34be1f5 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 20488
diff changeset
56 // The shared miscellaneous code space is not large enough
03e6d34be1f5 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 20488
diff changeset
57 // to preload requested classes. Use -XX:SharedMiscCodeSize=
03e6d34be1f5 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 20488
diff changeset
58 // to increase the initial size of shared miscellaneous code space.
03e6d34be1f5 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 20488
diff changeset
59 new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k", "miscellaneous code"),
20488
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
60
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
61 // these values are larger than default ones, but should
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
62 // be acceptable and not cause failure
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
63 new SharedSizeTestData("-XX:SharedReadOnlySize", "20M", null),
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
64 new SharedSizeTestData("-XX:SharedReadWriteSize", "20M", null),
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
65 new SharedSizeTestData("-XX:SharedMiscDataSize", "20M", null),
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
66 new SharedSizeTestData("-XX:SharedMiscCodeSize", "20M", null)
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
67 };
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
68
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
69 public static void main(String[] args) throws Exception {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
70 String fileName = "test.jsa";
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
71
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
72 for (SharedSizeTestData td : testTable) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
73 String option = td.optionName + "=" + td.optionValue;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
74 System.out.println("testing option <" + option + ">");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
75
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
76 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
77 "-XX:+UnlockDiagnosticVMOptions",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
78 "-XX:SharedArchiveFile=./" + fileName,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
79 option,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
80 "-Xshare:dump");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
81
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
82 OutputAnalyzer output = new OutputAnalyzer(pb.start());
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
83
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
84 if (td.expectedErrorMsg != null) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
85 output.shouldContain("The shared " + td.expectedErrorMsg
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
86 + " space is not large enough");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
87
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
88 output.shouldHaveExitValue(2);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
89 } else {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
90 output.shouldNotContain("space is not large enough");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
91 output.shouldHaveExitValue(0);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
92 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
93 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
94 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
95 }