This commit is contained in:
Dmitry Dmitriev 2015-11-24 20:01:45 +00:00
commit 7171a533ff
4 changed files with 150 additions and 83 deletions

View File

@ -41,22 +41,45 @@ import optionsvalidation.JVMOptionsUtils;
public class TestOptionsWithRanges {
private static Map<String, JVMOption> allOptionsAsMap;
private static void excludeTestMaxRange(String optionName) {
JVMOption option = allOptionsAsMap.get(optionName);
if (option != null) {
option.excludeTestMaxRange();
}
}
private static void excludeTestMinRange(String optionName) {
JVMOption option = allOptionsAsMap.get(optionName);
if (option != null) {
option.excludeTestMinRange();
}
}
private static void excludeTestRange(String optionName) {
allOptionsAsMap.remove(optionName);
}
public static void main(String[] args) throws Exception {
int failedTests;
Map<String, JVMOption> allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap();
List<JVMOption> allOptions;
allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap();
/*
* Remove CICompilerCount from testing because currently it can hang system
*/
allOptionsAsMap.remove("CICompilerCount");
excludeTestMaxRange("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");
*/
excludeTestRange("ThreadStackSize");
/*
* JDK-8141650
@ -64,7 +87,7 @@ public class TestOptionsWithRanges {
* "The shared miscellaneous data space is not large enough to preload requested classes."
* message at min value.
*/
allOptionsAsMap.remove("SharedMiscDataSize");
excludeTestRange("SharedMiscDataSize");
/*
* JDK-8142874
@ -72,25 +95,25 @@ public class TestOptionsWithRanges {
* "The shared miscellaneous data space is not large enough to preload requested classes."
* message at max values.
*/
allOptionsAsMap.remove("SharedReadWriteSize");
allOptionsAsMap.remove("SharedReadOnlySize");
allOptionsAsMap.remove("SharedMiscDataSize");
allOptionsAsMap.remove("SharedMiscCodeSize");
excludeTestRange("SharedReadWriteSize");
excludeTestRange("SharedReadOnlySize");
excludeTestRange("SharedMiscDataSize");
excludeTestRange("SharedMiscCodeSize");
/*
* Exclude MallocMaxTestWords as it is expected to exit VM at small values (>=0)
*/
allOptionsAsMap.remove("MallocMaxTestWords");
excludeTestMinRange("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");
excludeTestMaxRange("G1ConcRefinementThreads");
excludeTestMaxRange("G1RSetRegionEntries");
excludeTestMaxRange("G1RSetSparseRegionEntries");
excludeTestMaxRange("G1UpdateBufferSize");
excludeTestMaxRange("InitialBootClassLoaderMetaspaceSize");
/*
* Remove parameters controlling the code cache. As these
@ -102,13 +125,13 @@ public class TestOptionsWithRanges {
* 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");
excludeTestMaxRange("InitialCodeCacheSize");
excludeTestMaxRange("CodeCacheMinimumUseSpace");
excludeTestMaxRange("ReservedCodeCacheSize");
excludeTestMaxRange("NonProfiledCodeHeapSize");
excludeTestMaxRange("ProfiledCodeHeapSize");
excludeTestMaxRange("NonNMethodCodeHeapSize");
excludeTestMaxRange("CodeCacheExpansionSize");
allOptions = new ArrayList<>(allOptionsAsMap.values());

View File

@ -123,22 +123,28 @@ public class DoubleJVMOption extends JVMOption {
protected List<String> getValidValues() {
List<String> 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 (testMaxRange) {
validValues.add(formatValue(max));
}
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 (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_POSITIVE) < 0)
&& (Double.compare(max, ADDITIONAL_TEST_DOUBLE_POSITIVE) > 0)) {
validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_POSITIVE));
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;

View File

@ -200,43 +200,51 @@ public class IntJVMOption extends JVMOption {
protected List<String> getValidValues() {
List<String> 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 (testMinRange) {
validValues.add(min.toString());
}
if (testMaxRange) {
validValues.add(max.toString());
}
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 (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 ((min.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == -1) && (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 (testMaxRange) {
if ((min.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == -1) && (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 ((min.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == -1) && (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 ((min.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == -1) && (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 @@ public class IntJVMOption extends JVMOption {
protected List<String> getInvalidValues() {
List<String> 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) {
/* 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 (!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 ((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());
}
}
}

View File

@ -54,6 +54,16 @@ public abstract class JVMOption {
*/
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
*/
@ -64,6 +74,8 @@ public abstract class JVMOption {
this.prepend = new ArrayList<>();
prependString = new StringBuilder();
withRange = false;
testMinRange = true;
testMaxRange = true;
}
/**
@ -135,6 +147,20 @@ public abstract class JVMOption {
withRange = true;
}
/**
* Exclude testing of min range value for this option
*/
public final void excludeTestMinRange() {
testMinRange = false;
}
/**
* Exclude testing of max range value for this option
*/
public final void excludeTestMaxRange() {
testMaxRange = false;
}
/**
* Set new minimum option value
*