--- old/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java 2015-11-18 22:07:34.828532875 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java 2015-11-18 22:07:34.248532847 +0300 @@ -41,37 +41,60 @@ public class TestOptionsWithRanges { + private static Map allOptionsAsMap; + + private static void notTestMaxRange(String optionName) { + JVMOption option = allOptionsAsMap.get(optionName); + + if (option != null) { + option.notTestMaxRange(); + } + } + + private static void notTestMinRange(String optionName) { + JVMOption option = allOptionsAsMap.get(optionName); + + if (option != null) { + option.notTestMinRange(); + } + } + + private static void notTestRange(String optionName) { + allOptionsAsMap.remove(optionName); + } + public static void main(String[] args) throws Exception { - int failedTests; - Map allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(); + int failedTests; List allOptions; + allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(); + /* * Remove CICompilerCount from testing because currently it can hang system */ - allOptionsAsMap.remove("CICompilerCount"); + notTestMaxRange("CICompilerCount"); /* * JDK-8136766 * Temporarily remove ThreadStackSize from testing because Windows can set it to 0 * (for default OS size) but other platforms insist it must be greater than 0 */ - allOptionsAsMap.remove("ThreadStackSize"); + notTestRange("ThreadStackSize"); /* * Exclude MallocMaxTestWords as it is expected to exit VM at small values (>=0) */ - allOptionsAsMap.remove("MallocMaxTestWords"); + notTestMinRange("MallocMaxTestWords"); /* * Exclude below options as their maximum value would consume too much memory * and would affect other tests that run in parallel. */ - allOptionsAsMap.remove("G1ConcRefinementThreads"); - allOptionsAsMap.remove("G1RSetRegionEntries"); - allOptionsAsMap.remove("G1RSetSparseRegionEntries"); - allOptionsAsMap.remove("G1UpdateBufferSize"); - allOptionsAsMap.remove("InitialBootClassLoaderMetaspaceSize"); + notTestMaxRange("G1ConcRefinementThreads"); + notTestMaxRange("G1RSetRegionEntries"); + notTestMaxRange("G1RSetSparseRegionEntries"); + notTestMaxRange("G1UpdateBufferSize"); + notTestMaxRange("InitialBootClassLoaderMetaspaceSize"); /* * Remove parameters controlling the code cache. As these @@ -83,13 +106,13 @@ * hotspot/src/shared/vm/code/codeCache.cpp), therefore * omitting testing for them does not pose a problem. */ - allOptionsAsMap.remove("InitialCodeCacheSize"); - allOptionsAsMap.remove("CodeCacheMinimumUseSpace"); - allOptionsAsMap.remove("ReservedCodeCacheSize"); - allOptionsAsMap.remove("NonProfiledCodeHeapSize"); - allOptionsAsMap.remove("ProfiledCodeHeapSize"); - allOptionsAsMap.remove("NonNMethodCodeHeapSize"); - allOptionsAsMap.remove("CodeCacheExpansionSize"); + notTestMaxRange("InitialCodeCacheSize"); + notTestMaxRange("CodeCacheMinimumUseSpace"); + notTestMaxRange("ReservedCodeCacheSize"); + notTestMaxRange("NonProfiledCodeHeapSize"); + notTestMaxRange("ProfiledCodeHeapSize"); + notTestMaxRange("NonNMethodCodeHeapSize"); + notTestMaxRange("CodeCacheExpansionSize"); allOptions = new ArrayList<>(allOptionsAsMap.values()); --- old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java 2015-11-18 22:07:35.308532898 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java 2015-11-18 22:07:35.188532892 +0300 @@ -123,22 +123,28 @@ protected List getValidValues() { List validValues = new ArrayList<>(); - validValues.add(formatValue(min)); - validValues.add(formatValue(max)); - - if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_NEGATIVE) < 0) - && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_NEGATIVE) > 0)) { - validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_NEGATIVE)); + if (testMinRange) { + validValues.add(formatValue(min)); } - - if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_ZERO) < 0) - && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_ZERO) > 0)) { - validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_ZERO)); + if (testMaxRange) { + validValues.add(formatValue(max)); } - if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_POSITIVE) < 0) - && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_POSITIVE) > 0)) { - validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_POSITIVE)); + if (testMinRange) { + if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_NEGATIVE) < 0) + && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_NEGATIVE) > 0)) { + validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_NEGATIVE)); + } + + if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_ZERO) < 0) + && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_ZERO) > 0)) { + validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_ZERO)); + } + + if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_POSITIVE) < 0) + && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_POSITIVE) > 0)) { + validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_POSITIVE)); + } } return validValues; --- old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/IntJVMOption.java 2015-11-18 22:07:35.836532923 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/IntJVMOption.java 2015-11-18 22:07:35.704532917 +0300 @@ -200,43 +200,51 @@ protected List getValidValues() { List validValues = new ArrayList<>(); - validValues.add(min.toString()); - validValues.add(max.toString()); - - if ((min.compareTo(MINUS_ONE) == -1) && (max.compareTo(MINUS_ONE) == 1)) { - /* - * Add -1 as valid value if min is less than -1 and max is greater than -1 - */ - validValues.add("-1"); - } - - if ((min.compareTo(BigInteger.ZERO) == -1) && (max.compareTo(BigInteger.ZERO) == 1)) { - /* - * Add 0 as valid value if min is less than 0 and max is greater than 0 - */ - validValues.add("0"); + if (testMinRange) { + validValues.add(min.toString()); } - if ((min.compareTo(BigInteger.ONE) == -1) && (max.compareTo(BigInteger.ONE) == 1)) { - /* - * Add 1 as valid value if min is less than 1 and max is greater than 1 - */ - validValues.add("1"); + if (testMaxRange) { + validValues.add(max.toString()); } - if (max.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == 1) { - /* - * Check for overflow when flag is assigned to the - * 4 byte int variable - */ - validValues.add(MAX_4_BYTE_INT_PLUS_ONE.toString()); + if (testMinRange) { + if ((min.compareTo(MINUS_ONE) == -1) && (max.compareTo(MINUS_ONE) == 1)) { + /* + * Add -1 as valid value if min is less than -1 and max is greater than -1 + */ + validValues.add("-1"); + } + + if ((min.compareTo(BigInteger.ZERO) == -1) && (max.compareTo(BigInteger.ZERO) == 1)) { + /* + * Add 0 as valid value if min is less than 0 and max is greater than 0 + */ + validValues.add("0"); + } + if ((min.compareTo(BigInteger.ONE) == -1) && (max.compareTo(BigInteger.ONE) == 1)) { + /* + * Add 1 as valid value if min is less than 1 and max is greater than 1 + */ + validValues.add("1"); + } } - if (max.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == 1) { - /* - * Check for overflow when flag is assigned to the - * 4 byte unsigned int variable - */ - validValues.add(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE.toString()); + if (testMaxRange) { + if (max.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == 1) { + /* + * Check for overflow when flag is assigned to the + * 4 byte int variable + */ + validValues.add(MAX_4_BYTE_INT_PLUS_ONE.toString()); + } + + if (max.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == 1) { + /* + * Check for overflow when flag is assigned to the + * 4 byte unsigned int variable + */ + validValues.add(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE.toString()); + } } return validValues; @@ -252,24 +260,28 @@ protected List getInvalidValues() { List invalidValues = new ArrayList<>(); + /* Return invalid values only for options which have defined range in VM */ if (withRange) { - /* Return invalid values only for options which have defined range in VM */ - if ((is32Bit && min.compareTo(MIN_4_BYTE_INT) != 0) - || (!is32Bit && min.compareTo(MIN_LONG) != 0)) { - invalidValues.add(min.subtract(BigInteger.ONE).toString()); - } - - if (!unsigned - && ((is32Bit && (max.compareTo(MAX_4_BYTE_INT) != 0)) - || (!is32Bit && (max.compareTo(MAX_LONG) != 0)))) { - invalidValues.add(max.add(BigInteger.ONE).toString()); - } - - if (unsigned - && ((is32Bit && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT) != 0)) - || (!is32Bit && !uint64 && (max.compareTo(MAX_UNSIGNED_LONG) != 0)) - || (uint64 && (max.compareTo(MAX_UNSIGNED_LONG_64) != 0)))) { - invalidValues.add(max.add(BigInteger.ONE).toString()); + if (unsigned) { + /* Only add non-negative out-of-range values for unsigned options */ + if (min.compareTo(BigInteger.ZERO) == 1) { + invalidValues.add(min.subtract(BigInteger.ONE).toString()); + } + + if ((is32Bit && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT) != 0)) + || (!is32Bit && !uint64 && (max.compareTo(MAX_UNSIGNED_LONG) != 0)) + || (uint64 && (max.compareTo(MAX_UNSIGNED_LONG_64) != 0))) { + invalidValues.add(max.add(BigInteger.ONE).toString()); + } + } else { + if ((is32Bit && min.compareTo(MIN_4_BYTE_INT) != 0) + || (!is32Bit && min.compareTo(MIN_LONG) != 0)) { + invalidValues.add(min.subtract(BigInteger.ONE).toString()); + } + if ((is32Bit && (max.compareTo(MAX_4_BYTE_INT) != 0)) + || (!is32Bit && (max.compareTo(MAX_LONG) != 0))) { + invalidValues.add(max.add(BigInteger.ONE).toString()); + } } } --- old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java 2015-11-18 22:07:36.368532948 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java 2015-11-18 22:07:36.240532942 +0300 @@ -55,6 +55,16 @@ protected boolean withRange; /** + * Test valid min range value and additional small values + */ + protected boolean testMinRange; + + /** + * Test valid max range value and additional big values + */ + protected boolean testMaxRange; + + /** * Prepend string which added before testing option to the command line */ private final List prepend; @@ -64,6 +74,8 @@ this.prepend = new ArrayList<>(); prependString = new StringBuilder(); withRange = false; + testMinRange = true; + testMaxRange = true; } /** @@ -136,6 +148,20 @@ } /** + * Not test min range value for this option + */ + public final void notTestMinRange() { + testMinRange = false; + } + + /** + * Not test max range value for this option + */ + public final void notTestMaxRange() { + testMaxRange = false; + } + + /** * Set new minimum option value * * @param min new minimum value