Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/arguments/TestHeapFreeRatio.java
32285 views
/*1* Copyright (c) 2013, 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 TestHeapFreeRatio25* @key gc26* @bug 802566127* @summary Test parsing of -Xminf and -Xmaxf28* @library /testlibrary29* @run main/othervm TestHeapFreeRatio30*/3132import com.oracle.java.testlibrary.*;3334public class TestHeapFreeRatio {3536enum Validation {37VALID,38MIN_INVALID,39MAX_INVALID,40COMBINATION_INVALID41}4243private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception {44ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(45"-Xminf" + min,46"-Xmaxf" + max,47"-version");48OutputAnalyzer output = new OutputAnalyzer(pb.start());4950switch (type) {51case VALID:52output.shouldNotContain("Error");53output.shouldHaveExitValue(0);54break;55case MIN_INVALID:56output.shouldContain("Bad min heap free percentage size: -Xminf" + min);57output.shouldContain("Error");58output.shouldHaveExitValue(1);59break;60case MAX_INVALID:61output.shouldContain("Bad max heap free percentage size: -Xmaxf" + max);62output.shouldContain("Error");63output.shouldHaveExitValue(1);64break;65case COMBINATION_INVALID:66output.shouldContain("must be less than or equal to MaxHeapFreeRatio");67output.shouldContain("Error");68output.shouldHaveExitValue(1);69break;70default:71throw new IllegalStateException("Must specify expected validation type");72}7374System.out.println(output.getOutput());75}7677public static void main(String args[]) throws Exception {78testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID);79testMinMaxFreeRatio( ".1", ".5", Validation.VALID);80testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID);8182testMinMaxFreeRatio("-0.1", "0.5", Validation.MIN_INVALID);83testMinMaxFreeRatio( "1.1", "0.5", Validation.MIN_INVALID);84testMinMaxFreeRatio("=0.1", "0.5", Validation.MIN_INVALID);85testMinMaxFreeRatio("0.1f", "0.5", Validation.MIN_INVALID);86testMinMaxFreeRatio(87"INVALID", "0.5", Validation.MIN_INVALID);88testMinMaxFreeRatio(89"2147483647", "0.5", Validation.MIN_INVALID);9091testMinMaxFreeRatio( "0.1", "-0.5", Validation.MAX_INVALID);92testMinMaxFreeRatio( "0.1", "1.5", Validation.MAX_INVALID);93testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID);94testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID);95testMinMaxFreeRatio(96"0.1", "INVALID", Validation.MAX_INVALID);97testMinMaxFreeRatio(98"0.1", "2147483647", Validation.MAX_INVALID);99100testMinMaxFreeRatio( "0.5", "0.1", Validation.COMBINATION_INVALID);101testMinMaxFreeRatio( ".5", ".10", Validation.COMBINATION_INVALID);102testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID);103}104}105106107