changeset 35074:4ac430acedd7

8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases Reviewed-by: gtriantafill, stsmirno, ctornqvi, gziemski
author ddmitriev
date Sat, 12 Dec 2015 21:23:20 +0300
parents 3b3c2fb85d58
children ca79cbf3f106
files hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java
diffstat 3 files changed, 46 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java	Fri Dec 11 13:36:15 2015 -0800
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java	Sat Dec 12 21:23:20 2015 +0300
@@ -63,12 +63,26 @@
         allOptionsAsMap.remove(optionName);
     }
 
+    private static void setAllowedExitCodes(String optionName, Integer... allowedExitCodes) {
+        JVMOption option = allOptionsAsMap.get(optionName);
+
+        if (option != null) {
+            option.setAllowedExitCodes(allowedExitCodes);
+        }
+    }
+
     public static void main(String[] args) throws Exception {
         int failedTests;
         List<JVMOption> allOptions;
 
         allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap();
 
+        /* Shared flags can cause JVM to exit with error code 2 */
+        setAllowedExitCodes("SharedReadWriteSize", 2);
+        setAllowedExitCodes("SharedReadOnlySize", 2);
+        setAllowedExitCodes("SharedMiscDataSize", 2);
+        setAllowedExitCodes("SharedMiscCodeSize", 2);
+
         /*
          * Remove CICompilerCount from testing because currently it can hang system
          */
@@ -82,23 +96,13 @@
         excludeTestRange("ThreadStackSize");
 
         /*
-         * JDK-8141650
-         * Temporarily exclude SharedMiscDataSize as it will exit the VM with exit code 2 and
-         * "The shared miscellaneous data space is not large enough to preload requested classes."
-         * message at min value.
+         * JDK-8143958
+         * Temporarily exclude testing of max range for Shared* flags
          */
-        excludeTestRange("SharedMiscDataSize");
-
-        /*
-         * JDK-8142874
-         * Temporarily exclude Shared* flagse as they will exit the VM with exit code 2 and
-         * "The shared miscellaneous data space is not large enough to preload requested classes."
-         * message at max values.
-         */
-        excludeTestRange("SharedReadWriteSize");
-        excludeTestRange("SharedReadOnlySize");
-        excludeTestRange("SharedMiscDataSize");
-        excludeTestRange("SharedMiscCodeSize");
+        excludeTestMaxRange("SharedReadWriteSize");
+        excludeTestMaxRange("SharedReadOnlySize");
+        excludeTestMaxRange("SharedMiscDataSize");
+        excludeTestMaxRange("SharedMiscCodeSize");
 
         /*
          * Remove the flag controlling the size of the stack because the
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java	Fri Dec 11 13:36:15 2015 -0800
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java	Sat Dec 12 21:23:20 2015 +0300
@@ -25,7 +25,10 @@
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.AttachOperationFailedException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import jdk.test.lib.DynamicVMOption;
 import jdk.test.lib.OutputAnalyzer;
 import jdk.test.lib.ProcessTools;
@@ -64,6 +67,8 @@
      */
     protected boolean testMaxRange;
 
+    private Set<Integer> allowedExitCodes;
+
     /**
      * Prepend string which added before testing option to the command line
      */
@@ -73,6 +78,9 @@
     protected JVMOption() {
         this.prepend = new ArrayList<>();
         prependString = new StringBuilder();
+        allowedExitCodes = new HashSet<>();
+        allowedExitCodes.add(0);
+        allowedExitCodes.add(1);
         withRange = false;
         testMinRange = true;
         testMaxRange = true;
@@ -161,6 +169,10 @@
         testMaxRange = false;
     }
 
+    public final void setAllowedExitCodes(Integer... allowedExitCodes) {
+        this.allowedExitCodes.addAll(Arrays.asList(allowedExitCodes));
+    }
+
     /**
      * Set new minimum option value
      *
@@ -384,13 +396,13 @@
             printOutputContent(out);
             result = false;
         } else if (valid == true) {
-            if ((exitCode != 0) && (exitCode != 1)) {
+            if (!allowedExitCodes.contains(exitCode)) {
                 failedMessage(name, fullOptionString, valid, "JVM exited with unexpected error code = " + exitCode);
                 printOutputContent(out);
                 result = false;
-            } else if ((exitCode == 1) && (out.getOutput().isEmpty() == true)) {
-                failedMessage(name, fullOptionString, valid, "JVM exited with error(exitcode == 1)"
-                        + ", but with empty stdout and stderr. Description of error is needed!");
+            } else if ((exitCode != 0) && (out.getOutput().isEmpty() == true)) {
+                failedMessage(name, fullOptionString, valid, "JVM exited with error(exitcode == " + exitCode +
+                        "), but with empty stdout and stderr. Description of error is needed!");
                 result = false;
             } else if (out.getOutput().contains("is outside the allowed range")) {
                 failedMessage(name, fullOptionString, valid, "JVM output contains \"is outside the allowed range\"");
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java	Fri Dec 11 13:36:15 2015 -0800
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java	Sat Dec 12 21:23:20 2015 +0300
@@ -161,13 +161,6 @@
             option.addPrepend("-XX:+UseConcMarkSweepGC");
         }
 
-        if (name.startsWith("Shared")) {
-            option.addPrepend("-XX:+UnlockDiagnosticVMOptions");
-            String fileName = "Test" + name + ".jsa";
-            option.addPrepend("-XX:SharedArchiveFile=" + fileName);
-            option.addPrepend("-Xshare:dump");
-        }
-
         if (name.startsWith("NUMA")) {
             option.addPrepend("-XX:+UseNUMA");
         }
@@ -213,6 +206,16 @@
             case "NewSizeThreadIncrease":
                 option.addPrepend("-XX:+UseSerialGC");
                 break;
+            case "SharedReadWriteSize":
+            case "SharedReadOnlySize":
+            case "SharedMiscDataSize":
+            case "SharedMiscCodeSize":
+            case "SharedBaseAddress":
+            case "SharedSymbolTableBucketSize":
+                option.addPrepend("-XX:+UnlockDiagnosticVMOptions");
+                option.addPrepend("-XX:SharedArchiveFile=TestOptionsWithRanges.jsa");
+                option.addPrepend("-Xshare:dump");
+                break;
             default:
                 /* Do nothing */
                 break;