Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
32284 views
/*1* Copyright (c) 2014, 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*/2223/**24* @test TestDynMinHeapFreeRatio25* @bug 802839126* @summary Verify that MinHeapFreeRatio flag is manageable27* @library /testlibrary28* @run main TestDynMinHeapFreeRatio29* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMinHeapFreeRatio30* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 -XX:-UseAdaptiveSizePolicy TestDynMinHeapFreeRatio31* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 TestDynMinHeapFreeRatio32* @run main/othervm -XX:MinHeapFreeRatio=51 -XX:MaxHeapFreeRatio=52 TestDynMinHeapFreeRatio33* @run main/othervm -XX:MinHeapFreeRatio=75 -XX:MaxHeapFreeRatio=100 TestDynMinHeapFreeRatio34*/35import static com.oracle.java.testlibrary.Asserts.assertEQ;36import static com.oracle.java.testlibrary.Asserts.assertFalse;37import static com.oracle.java.testlibrary.Asserts.assertTrue;38import com.oracle.java.testlibrary.DynamicVMOption;3940public class TestDynMinHeapFreeRatio {4142public static void main(String args[]) throws Exception {4344// high boundary value45int maxValue = DynamicVMOption.getInt("MaxHeapFreeRatio");46System.out.println("MaxHeapFreeRatio= " + maxValue);4748String badValues[] = {49null,50"",51"not a number",52"8.5", "-0.01",53Integer.toString(Integer.MIN_VALUE),54Integer.toString(Integer.MAX_VALUE),55Integer.toString(maxValue + 1),56"-1024", "-1", "101", "1997"57};5859String goodValues[] = {60Integer.toString(maxValue),61Integer.toString(maxValue - 1),62Integer.toString(maxValue / 2),63"0", "1"64};6566// option under test67DynamicVMOption option = new DynamicVMOption("MinHeapFreeRatio");6869assertTrue(option.isWriteable(), "Option " + option.name70+ " is expected to be writable");7172for (String v : badValues) {73assertFalse(option.isValidValue(v),74"'" + v + "' is expected to be illegal for flag " + option.name);75}7677for (String v : goodValues) {78option.setValue(v);79String newValue = option.getValue();80assertEQ(v, newValue);81}82}83}848586