Path: blob/master/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRangesDynamic.java
41153 views
/*1* Copyright (c) 2015, 2019, 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* @test25* @summary Test writeable VM Options with ranges.26* @library /test/lib /runtime/CommandLine/OptionsValidation/common27* @modules java.base/jdk.internal.misc28* jdk.attach/sun.tools.attach29* java.management30* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Djdk.attach.allowAttachSelf TestOptionsWithRangesDynamic31*/3233import java.util.List;34import jdk.test.lib.Asserts;35import optionsvalidation.JVMOption;36import optionsvalidation.JVMOptionsUtils;3738public class TestOptionsWithRangesDynamic {3940private static List<JVMOption> allWriteableOptions;4142private static void excludeTestRange(String optionName) {43for (JVMOption option: allWriteableOptions) {44if (option.getName().equals(optionName)) {45option.excludeTestMinRange();46option.excludeTestMaxRange();47break;48}49}50}5152public static void main(String[] args) throws Exception {53int failedTests;5455/* Get only writeable options */56allWriteableOptions = JVMOptionsUtils.getOptionsWithRange(origin -> (origin.contains("manageable") || origin.contains("rw")));5758/*59* Exclude SoftMaxHeapSize as its valid range is only known at runtime.60*/61excludeTestRange("SoftMaxHeapSize");6263Asserts.assertGT(allWriteableOptions.size(), 0, "Options with ranges not found!");6465System.out.println("Test " + allWriteableOptions.size() + " writeable options with ranges. Start test!");6667failedTests = JVMOptionsUtils.runDynamicTests(allWriteableOptions);6869failedTests += JVMOptionsUtils.runJcmdTests(allWriteableOptions);7071failedTests += JVMOptionsUtils.runAttachTests(allWriteableOptions);7273Asserts.assertEQ(failedTests, 0,74String.format("%d tests failed! %s", failedTests, JVMOptionsUtils.getMessageWithFailures()));75}76}777879