Path: blob/master/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java
41153 views
/*1* Copyright (c) 2015, 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*/2223// --- start auto-generated24// the following portion is auto-generated by TestOptionsWithRanges_generate.sh. Do not edit manually.25/*26* @test27* @bug 820563328* @summary Test VM Options with ranges (1 of 10)29* @library /test/lib /runtime/CommandLine/OptionsValidation/common30* @modules java.base/jdk.internal.misc31* java.management32* jdk.attach/sun.tools.attach33* jdk.internal.jvmstat/sun.jvmstat.monitor34* @run driver/timeout=1800 TestOptionsWithRanges 1 of 1035*/36/*37* @test38* @bug 820563339* @summary Test VM Options with ranges (2 of 10)40* @library /test/lib /runtime/CommandLine/OptionsValidation/common41* @modules java.base/jdk.internal.misc42* java.management43* jdk.attach/sun.tools.attach44* jdk.internal.jvmstat/sun.jvmstat.monitor45* @run driver/timeout=1800 TestOptionsWithRanges 2 of 1046*/47/*48* @test49* @bug 820563350* @summary Test VM Options with ranges (3 of 10)51* @library /test/lib /runtime/CommandLine/OptionsValidation/common52* @modules java.base/jdk.internal.misc53* java.management54* jdk.attach/sun.tools.attach55* jdk.internal.jvmstat/sun.jvmstat.monitor56* @run driver/timeout=1800 TestOptionsWithRanges 3 of 1057*/58/*59* @test60* @bug 820563361* @summary Test VM Options with ranges (4 of 10)62* @library /test/lib /runtime/CommandLine/OptionsValidation/common63* @modules java.base/jdk.internal.misc64* java.management65* jdk.attach/sun.tools.attach66* jdk.internal.jvmstat/sun.jvmstat.monitor67* @run driver/timeout=1800 TestOptionsWithRanges 4 of 1068*/69/*70* @test71* @bug 820563372* @summary Test VM Options with ranges (5 of 10)73* @library /test/lib /runtime/CommandLine/OptionsValidation/common74* @modules java.base/jdk.internal.misc75* java.management76* jdk.attach/sun.tools.attach77* jdk.internal.jvmstat/sun.jvmstat.monitor78* @run driver/timeout=1800 TestOptionsWithRanges 5 of 1079*/80/*81* @test82* @bug 820563383* @summary Test VM Options with ranges (6 of 10)84* @library /test/lib /runtime/CommandLine/OptionsValidation/common85* @modules java.base/jdk.internal.misc86* java.management87* jdk.attach/sun.tools.attach88* jdk.internal.jvmstat/sun.jvmstat.monitor89* @run driver/timeout=1800 TestOptionsWithRanges 6 of 1090*/91/*92* @test93* @bug 820563394* @summary Test VM Options with ranges (7 of 10)95* @library /test/lib /runtime/CommandLine/OptionsValidation/common96* @modules java.base/jdk.internal.misc97* java.management98* jdk.attach/sun.tools.attach99* jdk.internal.jvmstat/sun.jvmstat.monitor100* @run driver/timeout=1800 TestOptionsWithRanges 7 of 10101*/102/*103* @test104* @bug 8205633105* @summary Test VM Options with ranges (8 of 10)106* @library /test/lib /runtime/CommandLine/OptionsValidation/common107* @modules java.base/jdk.internal.misc108* java.management109* jdk.attach/sun.tools.attach110* jdk.internal.jvmstat/sun.jvmstat.monitor111* @run driver/timeout=1800 TestOptionsWithRanges 8 of 10112*/113/*114* @test115* @bug 8205633116* @summary Test VM Options with ranges (9 of 10)117* @library /test/lib /runtime/CommandLine/OptionsValidation/common118* @modules java.base/jdk.internal.misc119* java.management120* jdk.attach/sun.tools.attach121* jdk.internal.jvmstat/sun.jvmstat.monitor122* @run driver/timeout=1800 TestOptionsWithRanges 9 of 10123*/124/*125* @test126* @bug 8205633127* @summary Test VM Options with ranges (10 of 10)128* @library /test/lib /runtime/CommandLine/OptionsValidation/common129* @modules java.base/jdk.internal.misc130* java.management131* jdk.attach/sun.tools.attach132* jdk.internal.jvmstat/sun.jvmstat.monitor133* @run driver/timeout=1800 TestOptionsWithRanges 10 of 10134*/135// --- end auto-generated136137import java.util.ArrayList;138import java.util.Collections;139import java.util.List;140import java.util.Map;141import jdk.test.lib.Asserts;142import optionsvalidation.JVMOption;143import optionsvalidation.JVMOptionsUtils;144145public class TestOptionsWithRanges {146147private static Map<String, JVMOption> allOptionsAsMap;148149private static void excludeTestMaxRange(String optionName) {150JVMOption option = allOptionsAsMap.get(optionName);151152if (option != null) {153option.excludeTestMaxRange();154}155}156157private static void excludeTestMinRange(String optionName) {158JVMOption option = allOptionsAsMap.get(optionName);159160if (option != null) {161option.excludeTestMinRange();162}163}164165private static void excludeTestRange(String optionName) {166allOptionsAsMap.remove(optionName);167}168169private static void setAllowedExitCodes(String optionName, Integer... allowedExitCodes) {170JVMOption option = allOptionsAsMap.get(optionName);171172if (option != null) {173option.setAllowedExitCodes(allowedExitCodes);174}175}176177// Return a subset of the test cases, so we can break up allOptionsAsMap into small parts178// and use them in separate JTREG @test blocks (for parallel execution).179//180// args[] must be {part, "of", numParts}. The first part should be "1".181private static List<JVMOption> getTestSubset(String[] args) throws Exception {182int part = Integer.parseInt(args[0]) - 1;183int numParts = Integer.parseInt(args[2]);184List<String> keys = new ArrayList<>(allOptionsAsMap.keySet());185Collections.sort(keys);186int numTests = keys.size();187int start = numTests * (part ) / numParts;188int end = numTests * (part + 1) / numParts;189190List<JVMOption> subset = new ArrayList<>();191for (int i=start; i < end; i++) {192subset.add(allOptionsAsMap.get(keys.get(i)));193}194System.out.println("Generating subset [" + start + " ... " + end + ") of " +195subset.size() + " tests out of " + keys.size() + " total tests");196return subset;197}198199public static void main(String[] args) throws Exception {200int failedTests;201202allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(origin -> (!(origin.contains("develop") || origin.contains("notproduct"))));203204/*205* Exclude VMThreadStackSize from max range testing, because it will always exit with code 1,206* which technically passes, but really it fails, and worse yet, it produces hs_err_pid file.207*/208excludeTestMaxRange("VMThreadStackSize");209210/*211* Exclude CICompilerCount from testing because currently it can hang system212*/213excludeTestMaxRange("CICompilerCount");214215/*216* Exclude JVMCI threads counts from testing similar to other threads counts.217*/218excludeTestMaxRange("JVMCIThreads");219excludeTestMaxRange("JVMCIHostThreads");220221/*222* Exclude MallocMaxTestWords as it is expected to exit VM at small values (>=0)223*/224excludeTestMinRange("MallocMaxTestWords");225226/*227* Exclude below options as their maximum value would consume too much memory228* and would affect other tests that run in parallel.229*/230excludeTestMaxRange("ConcGCThreads");231excludeTestMaxRange("G1ConcRefinementThreads");232excludeTestMaxRange("G1RSetRegionEntries");233excludeTestMaxRange("G1RSetSparseRegionEntries");234excludeTestMaxRange("G1UpdateBufferSize");235excludeTestMaxRange("InitialHeapSize");236excludeTestMaxRange("MaxHeapSize");237excludeTestMaxRange("MaxRAM");238excludeTestMaxRange("NewSize");239excludeTestMaxRange("OldSize");240excludeTestMaxRange("ParallelGCThreads");241excludeTestMaxRange("TLABSize");242243/*244* Remove parameters controlling the code cache. As these245* parameters have implications on the physical memory246* reserved by the VM, setting them to large values may hang247* the system and/or may cause concurrently executed tests to248* fail. These parameters are rigorously checked when the code249* cache is initialized (see250* hotspot/src/shared/vm/code/codeCache.cpp), therefore251* omitting testing for them does not pose a problem.252*/253excludeTestMaxRange("InitialCodeCacheSize");254excludeTestMaxRange("CodeCacheMinimumUseSpace");255excludeTestMaxRange("ReservedCodeCacheSize");256excludeTestMaxRange("NonProfiledCodeHeapSize");257excludeTestMaxRange("ProfiledCodeHeapSize");258excludeTestMaxRange("NonNMethodCodeHeapSize");259excludeTestMaxRange("CodeCacheExpansionSize");260261List<JVMOption> testSubset = getTestSubset(args);262263Asserts.assertGT(testSubset.size(), 0, "Options with ranges not found!");264265System.out.println("Parsed " + testSubset.size() + " options with ranges. Start test!");266267failedTests = JVMOptionsUtils.runCommandLineTests(testSubset);268269Asserts.assertEQ(failedTests, 0,270String.format("%d tests failed! %s", failedTests, JVMOptionsUtils.getMessageWithFailures()));271}272}273274275