8038924: Test bit-instructions fails with unexpected exit value on sparc
authoriignatyev
Mon, 26 May 2014 19:05:01 +0400
changeset 24674 dbf660a72081
parent 24673 2ec56802b829
child 24675 8dd2c4604ff4
8038924: Test bit-instructions fails with unexpected exit value on sparc Reviewed-by: kvn, iignatyev Contributed-by: filipp.zhinkin@oracle.com
hotspot/test/compiler/arguments/BMICommandLineOptionTestBase.java
hotspot/test/compiler/arguments/BMISupportedCPUTest.java
hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java
hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java
hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java
--- a/hotspot/test/compiler/arguments/BMICommandLineOptionTestBase.java	Mon May 26 14:27:01 2014 +0200
+++ b/hotspot/test/compiler/arguments/BMICommandLineOptionTestBase.java	Mon May 26 19:05:01 2014 +0400
@@ -25,6 +25,12 @@
 
 /**
  * Base class for all X86 bit manipulation related command line options.
+ *
+ * Note that this test intended to verify that VM could be launched with
+ * specific options and that values of these options processed correctly.
+ * In order to do that test launch a new VM with tested options, the same
+ * flavor-specific flag as one that was used for parent VM (-client, -server,
+ * -minimal, -graal) and '-version'.
  */
 public abstract class BMICommandLineOptionTestBase
               extends CPUSpecificCommandLineOptionTest {
@@ -58,10 +64,11 @@
                                         String supportedCPUFeatures[],
                                         String unsupportedCPUFeatures[]) {
         super(".*", supportedCPUFeatures, unsupportedCPUFeatures);
-            this.optionName = optionName;
-            this.warningMessage = warningMessage;
-            this.errorMessage = CommandLineOptionTest.
-                UNRECOGNIZED_OPTION_ERROR_FORMAT.format(optionName);
+        this.optionName = optionName;
+        this.warningMessage = warningMessage;
+        this.errorMessage = String.format(
+                CommandLineOptionTest.UNRECOGNIZED_OPTION_ERROR_FORMAT,
+                optionName);
     }
 
 }
--- a/hotspot/test/compiler/arguments/BMISupportedCPUTest.java	Mon May 26 14:27:01 2014 +0200
+++ b/hotspot/test/compiler/arguments/BMISupportedCPUTest.java	Mon May 26 19:05:01 2014 +0400
@@ -28,6 +28,12 @@
  * Test on bit manipulation related command line options,
  * that should be executed on CPU that supports all required
  * features.
+ *
+ * Note that this test intended to verify that VM could be launched with
+ * specific options and that values of these options processed correctly.
+ * In order to do that test launch a new VM with tested options, the same
+ * flavor-specific flag as one that was used for parent VM (-client, -server,
+ * -minimal, -graal) and '-version'.
  */
 public class BMISupportedCPUTest extends BMICommandLineOptionTestBase {
 
@@ -49,24 +55,38 @@
 
     @Override
     public void runTestCases() throws Throwable {
-        // verify that VM will succesfully start up whithout warnings
-        CommandLineOptionTest.
-            verifyJVMStartup("-XX:+" + optionName,
-                             null, new String[] { warningMessage },
-                             ExitCode.OK);
+        /*
+          Verify that VM will successfully start up without warnings.
+          VM will be launched with following flags:
+          -XX:+<tested option> -version
+        */
+        CommandLineOptionTest.verifySameJVMStartup(null,
+                new String[] { warningMessage }, ExitCode.OK,
+                CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
-        // verify that VM will succesfully start up whithout warnings
-        CommandLineOptionTest.
-            verifyJVMStartup("-XX:-" + optionName,
-                             null, new String[] { warningMessage },
-                             ExitCode.OK);
+        /*
+          Verify that VM will successfully start up without warnings.
+          VM will be launched with following flags:
+          -XX:-<tested option> -version
+        */
+        CommandLineOptionTest.verifySameJVMStartup(null,
+                new String[] { warningMessage }, ExitCode.OK,
+                CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
-        // verify that on appropriate CPU option in on by default
-        CommandLineOptionTest.verifyOptionValue(optionName, "true");
+        /*
+          Verify that on appropriate CPU option in on by default.
+          VM will be launched with following flags:
+          -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true");
 
-        // verify that option could be explicitly turned off
-        CommandLineOptionTest.verifyOptionValue(optionName, "false",
-                                                "-XX:-" + optionName);
+        /*
+          Verify that option could be explicitly turned off.
+          VM will be launched with following flags:
+          -XX:-<tested option> -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 }
 
--- a/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java	Mon May 26 14:27:01 2014 +0200
+++ b/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java	Mon May 26 19:05:01 2014 +0400
@@ -28,6 +28,12 @@
  * Test on bit manipulation related command line options,
  * that should be executed on CPU that does not support
  * required features.
+ *
+ * Note that this test intended to verify that VM could be launched with
+ * specific options and that values of these options processed correctly.
+ * In order to do that test launch a new VM with tested options, the same
+ * flavor-specific flag as one that was used for parent VM (-client, -server,
+ * -minimal, -graal) and '-version'.
  */
 public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase {
 
@@ -64,28 +70,38 @@
      */
     public void unsupportedX86CPUTestCases() throws Throwable {
 
-        // verify that VM will succesfully start up, but output will
-        // contain a warning
-        CommandLineOptionTest.
-            verifyJVMStartup("-XX:+" + optionName,
-                             new String[] { warningMessage },
-                             new String[] { errorMessage },
-                             ExitCode.OK);
+        /*
+          Verify that VM will successfully start up, but output will contain a
+          warning. VM will be launched with following options:
+          -XX:+<tested option> -version
+        */
+        CommandLineOptionTest.verifySameJVMStartup(
+                new String[] { warningMessage }, new String[] { errorMessage },
+                ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(
+                        optionName, true));
 
-        // verify that VM will succesfully startup without any warnings
-        CommandLineOptionTest.
-            verifyJVMStartup("-XX:-" + optionName,
-                             null,
-                             new String[] { warningMessage, errorMessage },
-                             ExitCode.OK);
+        /*
+          Verify that VM will successfully startup without any warnings.
+          VM will be launched with following options:
+          -XX:-<tested option> -version
+        */
+        CommandLineOptionTest.verifySameJVMStartup(null,
+                new String[] { warningMessage, errorMessage }, ExitCode.OK,
+                CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
-        // verify that on unsupported CPUs option is off by default
-        CommandLineOptionTest.verifyOptionValue(optionName, "false");
+        /*
+          Verify that on unsupported CPUs option is off by default.
+          VM will be launched with following options: -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false");
 
-        // verify that on unsupported CPUs option will be off even if
-        // it was explicitly turned on by uset
-        CommandLineOptionTest.verifyOptionValue(optionName, "false",
-                                                     "-XX:+" + optionName);
+        /*
+          Verify that on unsupported CPUs option will be off even if
+          it was explicitly turned on by user. VM will be launched with
+          following options: -XX:+<tested option> -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
     }
 
@@ -97,18 +113,17 @@
      */
     public void unsupportedNonX86CPUTestCases() throws Throwable {
 
-        // verify that VM known nothing about tested option
-        CommandLineOptionTest.
-            verifyJVMStartup("-XX:+" + optionName,
-                             new String[] { errorMessage },
-                             null,
-                             ExitCode.FAIL);
+        /*
+          Verify that VM known nothing about tested option. VM will be launched
+          with following options: -XX:[+-]<tested option> -version
+        */
+        CommandLineOptionTest.verifySameJVMStartup(
+                new String[] { errorMessage }, null, ExitCode.FAIL,
+                CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
-        CommandLineOptionTest.
-            verifyJVMStartup("-XX:-" + optionName,
-                             new String[] { errorMessage },
-                             null,
-                             ExitCode.FAIL);
+        CommandLineOptionTest.verifySameJVMStartup(
+                new String[] { errorMessage }, null, ExitCode.FAIL,
+                CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 }
 
--- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java	Mon May 26 14:27:01 2014 +0200
+++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java	Mon May 26 19:05:01 2014 +0400
@@ -40,7 +40,8 @@
 import com.oracle.java.testlibrary.cli.*;
 
 public class TestUseCountTrailingZerosInstructionOnSupportedCPU
-     extends BMISupportedCPUTest {
+        extends BMISupportedCPUTest {
+    private static final String DISABLE_BMI = "-XX:-UseBMI1Instructions";
 
     public TestUseCountTrailingZerosInstructionOnSupportedCPU() {
         super("UseCountTrailingZerosInstruction", TZCNT_WARNING, "bmi1");
@@ -51,18 +52,23 @@
 
         super.runTestCases();
 
-        // verify that option will be disabled if all BMI1 instuctions
-        // are explicitly disabled
-        CommandLineOptionTest.
-            verifyOptionValue("UseCountTrailingZerosInstruction", "false",
-                              "-XX:-UseBMI1Instructions");
+        /*
+          Verify that option will be disabled if all BMI1 instructions
+          are explicitly disabled. VM will be launched with following options:
+          -XX:-UseBMI1Instructions -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI);
 
-        // verify that option could be turned on even if other BMI1
-        // instructions were turned off
-        CommandLineOptionTest.
-            verifyOptionValue("UseCountTrailingZerosInstruction", "true",
-                              "-XX:-UseBMI1Instructions",
-                              "-XX:+UseCountTrailingZerosInstruction");
+        /*
+          Verify that option could be turned on even if other BMI1
+          instructions were turned off. VM will be launched with following
+          options: -XX:-UseBMI1Instructions
+          -XX:+UseCountTrailingZerosInstruction -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+                TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI,
+                CommandLineOptionTest.prepareBooleanFlag(optionName, true));
     }
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java	Mon May 26 14:27:01 2014 +0200
+++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java	Mon May 26 19:05:01 2014 +0400
@@ -25,7 +25,7 @@
  * @test
  * @bug 8031321
  * @summary Verify processing of UseCountTrailingZerosInstruction option
- *          on CPU without TZCNT instuction (BMI1 feature) support.
+ *          on CPU without TZCNT instruction (BMI1 feature) support.
  * @library /testlibrary /testlibrary/whitebox
  * @build TestUseCountTrailingZerosInstructionOnUnsupportedCPU
  *        BMIUnsupportedCPUTest
@@ -40,7 +40,8 @@
 import com.oracle.java.testlibrary.cli.*;
 
 public class TestUseCountTrailingZerosInstructionOnUnsupportedCPU
-     extends BMIUnsupportedCPUTest {
+        extends BMIUnsupportedCPUTest {
+    private static final String ENABLE_BMI = "-XX:+UseBMI1Instructions";
 
     public TestUseCountTrailingZerosInstructionOnUnsupportedCPU() {
         super("UseCountTrailingZerosInstruction", TZCNT_WARNING, "bmi1");
@@ -51,16 +52,24 @@
 
         super.unsupportedX86CPUTestCases();
 
-        // verify that option will not be turned on during
-        // UseBMI1Instuctions processing
-        CommandLineOptionTest.
-            verifyOptionValue("UseCountTrailingZerosInstruction", "false",
-                              "-XX:+UseBMI1Instructions");
+        /*
+          Verify that option will not be turned on during UseBMI1Instructions
+          processing. VM will be launched with following options:
+          -XX:+UseBMI1Instructions -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                TestUseCountTrailingZerosInstructionOnUnsupportedCPU.
+                        ENABLE_BMI);
 
-        CommandLineOptionTest.
-            verifyOptionValue("UseCountTrailingZerosInstruction", "false",
-                              "-XX:+UseCountTrailingZerosInstruction",
-                              "-XX:+UseBMI1Instructions");
+        /*
+          VM will be launched with following options:
+          -XX:+UseCountTrailingZerosInstruction -XX:+UseBMI1Instructions
+          -version
+        */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                CommandLineOptionTest.prepareBooleanFlag(optionName, true),
+                TestUseCountTrailingZerosInstructionOnUnsupportedCPU.
+                        ENABLE_BMI);
     }
 
     public static void main(String args[]) throws Throwable {