55283
|
1 |
/*
|
|
2 |
* Copyright (c) 2019, 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 |
package gc.arguments;
|
|
25 |
|
|
26 |
/*
|
|
27 |
* @test TestSoftMaxHeapSizeFlag
|
|
28 |
* @key gc
|
|
29 |
* @library /test/lib
|
|
30 |
* @modules java.base/jdk.internal.misc
|
|
31 |
* java.management
|
|
32 |
* @run main/othervm gc.arguments.TestSoftMaxHeapSizeFlag
|
|
33 |
*/
|
|
34 |
|
|
35 |
import jdk.test.lib.process.ProcessTools;
|
|
36 |
|
|
37 |
public class TestSoftMaxHeapSizeFlag {
|
|
38 |
private static final long Xms = 200 * 1024 * 1024;
|
|
39 |
private static final long Xmx = 300 * 1024 * 1024;
|
|
40 |
private static final long greaterThanXmx = Xmx + 1;
|
|
41 |
private static final long betweenXmsAndXmx = (Xms + Xmx) / 2;
|
|
42 |
|
|
43 |
public static void main(String args[]) throws Exception {
|
|
44 |
// Test default value
|
|
45 |
ProcessTools.executeTestJvm(new String[]{ "-Xms" + Xms, "-Xmx" + Xmx,
|
|
46 |
"-XX:+PrintFlagsFinal", "-version" })
|
|
47 |
.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + Xmx)
|
|
48 |
.shouldHaveExitValue(0);
|
|
49 |
|
|
50 |
// Test setting small value
|
|
51 |
ProcessTools.executeTestJvm(new String[]{ "-Xms" + Xms, "-Xmx" + Xmx,
|
|
52 |
"-XX:SoftMaxHeapSize=" + Xms,
|
|
53 |
"-XX:+PrintFlagsFinal", "-version" })
|
|
54 |
.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + Xms)
|
|
55 |
.shouldHaveExitValue(0);
|
|
56 |
|
|
57 |
// Test setting middle value
|
|
58 |
ProcessTools.executeTestJvm(new String[]{ "-Xms" + Xms, "-Xmx" + Xmx,
|
|
59 |
"-XX:SoftMaxHeapSize=" + betweenXmsAndXmx,
|
|
60 |
"-XX:+PrintFlagsFinal", "-version" })
|
|
61 |
.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + betweenXmsAndXmx)
|
|
62 |
.shouldHaveExitValue(0);
|
|
63 |
|
|
64 |
// Test setting largest value
|
|
65 |
ProcessTools.executeTestJvm(new String[]{ "-Xms" + Xms, "-Xmx" + Xmx,
|
|
66 |
"-XX:SoftMaxHeapSize=" + Xmx,
|
|
67 |
"-XX:+PrintFlagsFinal", "-version" })
|
|
68 |
.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + Xmx)
|
|
69 |
.shouldHaveExitValue(0);
|
|
70 |
|
|
71 |
// Test setting a too large value
|
|
72 |
ProcessTools.executeTestJvm(new String[]{ "-Xms" + Xms, "-Xmx" + Xmx,
|
|
73 |
"-XX:SoftMaxHeapSize=" + greaterThanXmx,
|
|
74 |
"-XX:+PrintFlagsFinal", "-version" })
|
|
75 |
.shouldContain("SoftMaxHeapSize must be less than or equal to the maximum heap size")
|
|
76 |
.shouldHaveExitValue(1);
|
|
77 |
}
|
|
78 |
}
|