Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.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*/2223import static com.oracle.java.testlibrary.Asserts.assertEQ;24import static com.oracle.java.testlibrary.Asserts.assertFalse;25import static com.oracle.java.testlibrary.Asserts.assertTrue;26import com.oracle.java.testlibrary.DynamicVMOption;2728/**29* @test TestDynMaxHeapFreeRatio30* @bug 802839131* @summary Verify that MaxHeapFreeRatio flag is manageable32* @library /testlibrary33* @run main TestDynMaxHeapFreeRatio34* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMaxHeapFreeRatio35* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 -XX:-UseAdaptiveSizePolicy TestDynMaxHeapFreeRatio36* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 TestDynMaxHeapFreeRatio37* @run main/othervm -XX:MinHeapFreeRatio=51 -XX:MaxHeapFreeRatio=52 TestDynMaxHeapFreeRatio38* @run main/othervm -XX:MinHeapFreeRatio=75 -XX:MaxHeapFreeRatio=100 TestDynMaxHeapFreeRatio39*/40public class TestDynMaxHeapFreeRatio {4142public static void main(String args[]) throws Exception {4344// low boundary value45int minValue = DynamicVMOption.getInt("MinHeapFreeRatio");46System.out.println("MinHeapFreeRatio= " + minValue);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(minValue - 1),56"-1024", "-1", "101", "1997"57};5859String goodValues[] = {60Integer.toString(minValue),61Integer.toString(minValue + 1),62Integer.toString((minValue + 100) / 2),63"99", "100"64};6566DynamicVMOption option = new DynamicVMOption("MaxHeapFreeRatio");6768assertTrue(option.isWriteable(), "Option " + option.name69+ " is expected to be writable");7071for (String v : badValues) {72assertFalse(option.isValidValue(v),73"'" + v + "' is expected to be illegal for flag " + option.name);74}75for (String v : goodValues) {76option.setValue(v);77String newValue = option.getValue();78assertEQ(v, newValue);79}80}81}828384