Path: blob/master/test/hotspot/jtreg/gc/arguments/TestInitialTenuringThreshold.java
40943 views
/*1* Copyright (c) 2013, 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 TestInitialTenuringThreshold27* @bug 801476528* @requires vm.gc.Parallel29* @summary Tests argument processing for initial tenuring threshold30* @library /test/lib31* @library /32* @modules java.base/jdk.internal.misc33* java.management34* @run driver gc.arguments.TestInitialTenuringThreshold35* @author [email protected]36*/3738import jdk.test.lib.process.OutputAnalyzer;39import jdk.test.lib.process.ProcessTools;4041public class TestInitialTenuringThreshold {4243public static void runWithThresholds(int initial, int max, boolean shouldfail) throws Exception {44ProcessBuilder pb = GCArguments.createJavaProcessBuilder(45"-XX:+UseParallelGC",46"-XX:InitialTenuringThreshold=" + String.valueOf(initial),47"-XX:MaxTenuringThreshold=" + String.valueOf(max),48"-version"49);5051OutputAnalyzer output = new OutputAnalyzer(pb.start());52if (shouldfail) {53output.shouldHaveExitValue(1);54} else {55output.shouldHaveExitValue(0);56}57}585960public static void main(String args[]) throws Exception {61ProcessBuilder pb = GCArguments.createJavaProcessBuilder(62// some value below the default value of InitialTenuringThreshold of 763"-XX:MaxTenuringThreshold=1",64"-version"65);6667OutputAnalyzer output = new OutputAnalyzer(pb.start());68output.shouldHaveExitValue(0);69// successful tests70runWithThresholds(0, 10, false);71runWithThresholds(5, 5, false);72runWithThresholds(8, 16, false);73// failing tests74runWithThresholds(10, 0, true);75runWithThresholds(9, 8, true);76runWithThresholds(-1, 8, true);77runWithThresholds(0, -1, true);78runWithThresholds(8, -1, true);79runWithThresholds(16, 8, true);80runWithThresholds(8, 17, true);81}82}838485