Path: blob/master/test/hotspot/jtreg/gc/arguments/TestSoftMaxHeapSizeFlag.java
40943 views
/*1* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package gc.arguments;2425/*26* @test TestSoftMaxHeapSizeFlag27* @library /test/lib28* @modules java.base/jdk.internal.misc29* java.management30* @run driver gc.arguments.TestSoftMaxHeapSizeFlag31*/3233import jdk.test.lib.process.ProcessTools;3435public class TestSoftMaxHeapSizeFlag {36// Note: Xms and Xmx values get aligned up by HeapAlignment which is 32M with 64k pages.37private static final long Xms = 224 * 1024 * 1024;38private static final long Xmx = 320 * 1024 * 1024;39private static final long greaterThanXmx = Xmx + 1;40private static final long betweenXmsAndXmx = (Xms + Xmx) / 2;4142public static void main(String args[]) throws Exception {43// Test default value44ProcessTools.executeTestJvm("-Xms" + Xms, "-Xmx" + Xmx,45"-XX:+PrintFlagsFinal", "-version")46.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + Xmx)47.shouldHaveExitValue(0);4849// Test setting small value50ProcessTools.executeTestJvm("-Xms" + Xms, "-Xmx" + Xmx,51"-XX:SoftMaxHeapSize=" + Xms,52"-XX:+PrintFlagsFinal", "-version")53.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + Xms)54.shouldHaveExitValue(0);5556// Test setting middle value57ProcessTools.executeTestJvm("-Xms" + Xms, "-Xmx" + Xmx,58"-XX:SoftMaxHeapSize=" + betweenXmsAndXmx,59"-XX:+PrintFlagsFinal", "-version")60.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + betweenXmsAndXmx)61.shouldHaveExitValue(0);6263// Test setting largest value64ProcessTools.executeTestJvm("-Xms" + Xms, "-Xmx" + Xmx,65"-XX:SoftMaxHeapSize=" + Xmx,66"-XX:+PrintFlagsFinal", "-version")67.shouldMatch("SoftMaxHeapSize[ ]+=[ ]+" + Xmx)68.shouldHaveExitValue(0);6970// Test setting a too large value71ProcessTools.executeTestJvm("-Xms" + Xms, "-Xmx" + Xmx,72"-XX:SoftMaxHeapSize=" + greaterThanXmx,73"-XX:+PrintFlagsFinal", "-version")74.shouldContain("SoftMaxHeapSize must be less than or equal to the maximum heap size")75.shouldHaveExitValue(1);76}77}787980