|
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 */ |
|
23 |
|
24 /* @ignore JDK-8043896 |
|
25 * @test LimitSharedSizes |
|
26 * @summary Test handling of limits on shared space size |
|
27 * @library /testlibrary |
|
28 * @run main LimitSharedSizes |
|
29 */ |
|
30 |
|
31 import com.oracle.java.testlibrary.*; |
|
32 |
|
33 public class LimitSharedSizes { |
|
34 private static class SharedSizeTestData { |
|
35 public String optionName; |
|
36 public String optionValue; |
|
37 public String expectedErrorMsg; |
|
38 |
|
39 public SharedSizeTestData(String name, String value, String msg) { |
|
40 optionName = name; |
|
41 optionValue = value; |
|
42 expectedErrorMsg = msg; |
|
43 } |
|
44 } |
|
45 |
|
46 private static final SharedSizeTestData[] testTable = { |
|
47 // values in this part of the test table should cause failure |
|
48 // (shared space sizes are deliberately too small) |
|
49 new SharedSizeTestData("-XX:SharedReadOnlySize", "4M", "read only"), |
|
50 new SharedSizeTestData("-XX:SharedReadWriteSize","4M", "read write"), |
|
51 |
|
52 // Known issue, JDK-8038422 (assert() on Windows) |
|
53 // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k", "miscellaneous data"), |
|
54 |
|
55 // This will cause a VM crash; commenting out for now; see bug JDK-8038268 |
|
56 // @ignore JDK-8038268 |
|
57 // new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k", "miscellaneous code"), |
|
58 |
|
59 // these values are larger than default ones, but should |
|
60 // be acceptable and not cause failure |
|
61 new SharedSizeTestData("-XX:SharedReadOnlySize", "20M", null), |
|
62 new SharedSizeTestData("-XX:SharedReadWriteSize", "20M", null), |
|
63 new SharedSizeTestData("-XX:SharedMiscDataSize", "20M", null), |
|
64 new SharedSizeTestData("-XX:SharedMiscCodeSize", "20M", null) |
|
65 }; |
|
66 |
|
67 public static void main(String[] args) throws Exception { |
|
68 String fileName = "test.jsa"; |
|
69 |
|
70 for (SharedSizeTestData td : testTable) { |
|
71 String option = td.optionName + "=" + td.optionValue; |
|
72 System.out.println("testing option <" + option + ">"); |
|
73 |
|
74 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
|
75 "-XX:+UnlockDiagnosticVMOptions", |
|
76 "-XX:SharedArchiveFile=./" + fileName, |
|
77 option, |
|
78 "-Xshare:dump"); |
|
79 |
|
80 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
|
81 |
|
82 if (td.expectedErrorMsg != null) { |
|
83 output.shouldContain("The shared " + td.expectedErrorMsg |
|
84 + " space is not large enough"); |
|
85 |
|
86 output.shouldHaveExitValue(2); |
|
87 } else { |
|
88 output.shouldNotContain("space is not large enough"); |
|
89 output.shouldHaveExitValue(0); |
|
90 } |
|
91 } |
|
92 } |
|
93 } |