Thu, 27 Mar 2014 17:29:41 +0400
8038193: Add command line option tests for BMI options
Reviewed-by: iveresov, kvn, iignatyev
Contributed-by: filipp.zhinkin@oracle.com
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/compiler/arguments/BMICommandLineOptionTestBase.java Thu Mar 27 17:29:41 2014 +0400 1.3 @@ -0,0 +1,68 @@ 1.4 +/* 1.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +import com.oracle.java.testlibrary.cli.*; 1.28 + 1.29 +/** 1.30 + * Base class for all X86 bit manipulation related command line options. 1.31 + */ 1.32 +public abstract class BMICommandLineOptionTestBase 1.33 + extends CPUSpecificCommandLineOptionTest { 1.34 + 1.35 + public static final String LZCNT_WARNING = 1.36 + "lzcnt instruction is not available on this CPU"; 1.37 + public static final String TZCNT_WARNING = 1.38 + "tzcnt instruction is not available on this CPU"; 1.39 + public static final String BMI1_WARNING = 1.40 + "BMI1 instructions are not available on this CPU"; 1.41 + 1.42 + protected final String optionName; 1.43 + protected final String warningMessage; 1.44 + protected final String errorMessage; 1.45 + 1.46 + /** 1.47 + * Construct new test on {@code optionName} option. 1.48 + * 1.49 + * @param optionName Name of the option to be tested 1.50 + * without -XX:[+-] prefix. 1.51 + * @param warningMessage Message that can occur in VM output 1.52 + * if CPU on test box does not support 1.53 + * features required by the option. 1.54 + * @param supportedCPUFeatures CPU features requires by the option, 1.55 + * that should be supported on test box. 1.56 + * @param unsupportedCPUFeatures CPU features requires by the option, 1.57 + * that should not be supported on test box. 1.58 + */ 1.59 + public BMICommandLineOptionTestBase(String optionName, 1.60 + String warningMessage, 1.61 + String supportedCPUFeatures[], 1.62 + String unsupportedCPUFeatures[]) { 1.63 + super(".*", supportedCPUFeatures, unsupportedCPUFeatures); 1.64 + this.optionName = optionName; 1.65 + this.warningMessage = warningMessage; 1.66 + this.errorMessage = CommandLineOptionTest. 1.67 + UNRECOGNIZED_OPTION_ERROR_FORMAT.format(optionName); 1.68 + } 1.69 + 1.70 +} 1.71 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/arguments/BMISupportedCPUTest.java Thu Mar 27 17:29:41 2014 +0400 2.3 @@ -0,0 +1,72 @@ 2.4 +/* 2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +import com.oracle.java.testlibrary.*; 2.28 +import com.oracle.java.testlibrary.cli.*; 2.29 + 2.30 +/** 2.31 + * Test on bit manipulation related command line options, 2.32 + * that should be executed on CPU that supports all required 2.33 + * features. 2.34 + */ 2.35 +public class BMISupportedCPUTest extends BMICommandLineOptionTestBase { 2.36 + 2.37 + /** 2.38 + * Construct new test on {@code optionName} option. 2.39 + * 2.40 + * @param optionName Name of the option to be tested 2.41 + * without -XX:[+-] prefix. 2.42 + * @param warningMessage Message that can occur in VM output 2.43 + * if CPU on test box does not support 2.44 + * features required by the option. 2.45 + * @param cpuFeatures CPU features requires by the option. 2.46 + */ 2.47 + public BMISupportedCPUTest(String optionName, 2.48 + String warningMessage, 2.49 + String... cpuFeatures) { 2.50 + super(optionName, warningMessage, cpuFeatures, null); 2.51 + } 2.52 + 2.53 + @Override 2.54 + public void runTestCases() throws Throwable { 2.55 + // verify that VM will succesfully start up whithout warnings 2.56 + CommandLineOptionTest. 2.57 + verifyJVMStartup("-XX:+" + optionName, 2.58 + null, new String[] { warningMessage }, 2.59 + ExitCode.OK); 2.60 + 2.61 + // verify that VM will succesfully start up whithout warnings 2.62 + CommandLineOptionTest. 2.63 + verifyJVMStartup("-XX:-" + optionName, 2.64 + null, new String[] { warningMessage }, 2.65 + ExitCode.OK); 2.66 + 2.67 + // verify that on appropriate CPU option in on by default 2.68 + CommandLineOptionTest.verifyOptionValue(optionName, "true"); 2.69 + 2.70 + // verify that option could be explicitly turned off 2.71 + CommandLineOptionTest.verifyOptionValue(optionName, "false", 2.72 + "-XX:-" + optionName); 2.73 + } 2.74 +} 2.75 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/compiler/arguments/BMIUnsupportedCPUTest.java Thu Mar 27 17:29:41 2014 +0400 3.3 @@ -0,0 +1,114 @@ 3.4 +/* 3.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +import com.oracle.java.testlibrary.*; 3.28 +import com.oracle.java.testlibrary.cli.*; 3.29 + 3.30 +/** 3.31 + * Test on bit manipulation related command line options, 3.32 + * that should be executed on CPU that does not support 3.33 + * required features. 3.34 + */ 3.35 +public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase { 3.36 + 3.37 + /** 3.38 + * Construct new test on {@code optionName} option. 3.39 + * 3.40 + * @param optionName Name of the option to be tested 3.41 + * without -XX:[+-] prefix. 3.42 + * @param warningMessage Message that can occur in VM output 3.43 + * if CPU on test box does not support 3.44 + * features required by the option. 3.45 + * @param cpuFeatures CPU features requires by the option. 3.46 + */ 3.47 + public BMIUnsupportedCPUTest(String optionName, 3.48 + String warningMessage, 3.49 + String... cpuFeatures) { 3.50 + super(optionName, warningMessage, null, cpuFeatures); 3.51 + } 3.52 + 3.53 + @Override 3.54 + public void runTestCases() throws Throwable { 3.55 + if (Platform.isX86() || Platform.isX64()) { 3.56 + unsupportedX86CPUTestCases(); 3.57 + } else { 3.58 + unsupportedNonX86CPUTestCases(); 3.59 + } 3.60 + } 3.61 + 3.62 + /** 3.63 + * Run test cases common for all bit manipulation related VM options 3.64 + * targeted to X86 CPU that does not support required features. 3.65 + * 3.66 + * @throws Throwable if test failed. 3.67 + */ 3.68 + public void unsupportedX86CPUTestCases() throws Throwable { 3.69 + 3.70 + // verify that VM will succesfully start up, but output will 3.71 + // contain a warning 3.72 + CommandLineOptionTest. 3.73 + verifyJVMStartup("-XX:+" + optionName, 3.74 + new String[] { warningMessage }, 3.75 + new String[] { errorMessage }, 3.76 + ExitCode.OK); 3.77 + 3.78 + // verify that VM will succesfully startup without any warnings 3.79 + CommandLineOptionTest. 3.80 + verifyJVMStartup("-XX:-" + optionName, 3.81 + null, 3.82 + new String[] { warningMessage, errorMessage }, 3.83 + ExitCode.OK); 3.84 + 3.85 + // verify that on unsupported CPUs option is off by default 3.86 + CommandLineOptionTest.verifyOptionValue(optionName, "false"); 3.87 + 3.88 + // verify that on unsupported CPUs option will be off even if 3.89 + // it was explicitly turned on by uset 3.90 + CommandLineOptionTest.verifyOptionValue(optionName, "false", 3.91 + "-XX:+" + optionName); 3.92 + 3.93 + } 3.94 + 3.95 + /** 3.96 + * Run test cases common for all bit manipulation related VM options 3.97 + * targeted to non-X86 CPU that does not support required features. 3.98 + * 3.99 + * @throws Throwable if test failed. 3.100 + */ 3.101 + public void unsupportedNonX86CPUTestCases() throws Throwable { 3.102 + 3.103 + // verify that VM known nothing about tested option 3.104 + CommandLineOptionTest. 3.105 + verifyJVMStartup("-XX:+" + optionName, 3.106 + new String[] { errorMessage }, 3.107 + null, 3.108 + ExitCode.FAIL); 3.109 + 3.110 + CommandLineOptionTest. 3.111 + verifyJVMStartup("-XX:-" + optionName, 3.112 + new String[] { errorMessage }, 3.113 + null, 3.114 + ExitCode.FAIL); 3.115 + } 3.116 +} 3.117 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/compiler/arguments/TestUseBMI1InstructionsOnSupportedCPU.java Thu Mar 27 17:29:41 2014 +0400 4.3 @@ -0,0 +1,51 @@ 4.4 +/* 4.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +/** 4.28 + * @test 4.29 + * @bug 8031321 4.30 + * @summary Verify processing of UseBMI1Instructions option on CPU with 4.31 + * BMI1 feature support. 4.32 + * @library /testlibrary /testlibrary/whitebox 4.33 + * @build TestUseBMI1InstructionsOnSupportedCPU 4.34 + * BMISupportedCPUTest 4.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 4.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 4.37 + * -XX:+WhiteBoxAPI TestUseBMI1InstructionsOnSupportedCPU 4.38 + */ 4.39 + 4.40 +import sun.hotspot.cpuinfo.CPUInfo; 4.41 +import com.oracle.java.testlibrary.*; 4.42 + 4.43 +public class TestUseBMI1InstructionsOnSupportedCPU 4.44 + extends BMISupportedCPUTest { 4.45 + 4.46 + public TestUseBMI1InstructionsOnSupportedCPU() { 4.47 + super("UseBMI1Instructions", BMI1_WARNING, "bmi1"); 4.48 + } 4.49 + 4.50 + public static void main(String args[]) throws Throwable { 4.51 + new TestUseBMI1InstructionsOnSupportedCPU().test(); 4.52 + } 4.53 +} 4.54 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/compiler/arguments/TestUseBMI1InstructionsOnUnsupportedCPU.java Thu Mar 27 17:29:41 2014 +0400 5.3 @@ -0,0 +1,52 @@ 5.4 +/* 5.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + */ 5.26 + 5.27 +/** 5.28 + * @test 5.29 + * @bug 8031321 5.30 + * @summary Verify processing of UseBMI1Instructions option on CPU without 5.31 + * BMI1 feature support. 5.32 + * @library /testlibrary /testlibrary/whitebox 5.33 + * @build TestUseBMI1InstructionsOnUnsupportedCPU 5.34 + * BMIUnsupportedCPUTest 5.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 5.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 5.37 + * -XX:+WhiteBoxAPI TestUseBMI1InstructionsOnUnsupportedCPU 5.38 + */ 5.39 + 5.40 +import sun.hotspot.cpuinfo.CPUInfo; 5.41 +import com.oracle.java.testlibrary.*; 5.42 +import com.oracle.java.testlibrary.cli.*; 5.43 + 5.44 +public class TestUseBMI1InstructionsOnUnsupportedCPU 5.45 + extends BMIUnsupportedCPUTest { 5.46 + 5.47 + public TestUseBMI1InstructionsOnUnsupportedCPU() { 5.48 + super("UseBMI1Instructions", BMI1_WARNING, "bmi1"); 5.49 + } 5.50 + 5.51 + public static void main(String args[]) throws Throwable { 5.52 + new TestUseBMI1InstructionsOnUnsupportedCPU().test(); 5.53 + } 5.54 +} 5.55 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnSupportedCPU.java Thu Mar 27 17:29:41 2014 +0400 6.3 @@ -0,0 +1,52 @@ 6.4 +/* 6.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. 6.11 + * 6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.15 + * version 2 for more details (a copy is included in the LICENSE file that 6.16 + * accompanied this code). 6.17 + * 6.18 + * You should have received a copy of the GNU General Public License version 6.19 + * 2 along with this work; if not, write to the Free Software Foundation, 6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.21 + * 6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.23 + * or visit www.oracle.com if you need additional information or have any 6.24 + * questions. 6.25 + */ 6.26 + 6.27 +/** 6.28 + * @test 6.29 + * @bug 8031321 6.30 + * @summary Verify processing of UseCountLeadingZerosInstruction option 6.31 + * on CPU with LZCNT support. 6.32 + * @library /testlibrary /testlibrary/whitebox 6.33 + * @build TestUseCountLeadingZerosInstructionOnSupportedCPU 6.34 + * BMISupportedCPUTest 6.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 6.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 6.37 + * -XX:+WhiteBoxAPI 6.38 + * TestUseCountLeadingZerosInstructionOnSupportedCPU 6.39 + */ 6.40 + 6.41 +import sun.hotspot.cpuinfo.CPUInfo; 6.42 +import com.oracle.java.testlibrary.*; 6.43 + 6.44 +public class TestUseCountLeadingZerosInstructionOnSupportedCPU 6.45 + extends BMISupportedCPUTest { 6.46 + 6.47 + public TestUseCountLeadingZerosInstructionOnSupportedCPU() { 6.48 + super("UseCountLeadingZerosInstruction", LZCNT_WARNING, "lzcnt"); 6.49 + } 6.50 + 6.51 + public static void main(String args[]) throws Throwable { 6.52 + new TestUseCountLeadingZerosInstructionOnSupportedCPU().test(); 6.53 + } 6.54 +} 6.55 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnUnsupportedCPU.java Thu Mar 27 17:29:41 2014 +0400 7.3 @@ -0,0 +1,52 @@ 7.4 +/* 7.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +/** 7.28 + * @test 7.29 + * @bug 8031321 7.30 + * @summary Verify processing of UseCountLeadingZerosInstruction option 7.31 + * on CPU without LZCNT support. 7.32 + * @library /testlibrary /testlibrary/whitebox 7.33 + * @build TestUseCountLeadingZerosInstructionOnUnsupportedCPU 7.34 + * BMIUnsupportedCPUTest 7.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 7.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 7.37 + * -XX:+WhiteBoxAPI 7.38 + * TestUseCountLeadingZerosInstructionOnUnsupportedCPU 7.39 + */ 7.40 + 7.41 +import sun.hotspot.cpuinfo.CPUInfo; 7.42 +import com.oracle.java.testlibrary.*; 7.43 + 7.44 +public class TestUseCountLeadingZerosInstructionOnUnsupportedCPU 7.45 + extends BMIUnsupportedCPUTest { 7.46 + 7.47 + public TestUseCountLeadingZerosInstructionOnUnsupportedCPU() { 7.48 + super("UseCountLeadingZerosInstruction", LZCNT_WARNING, "lzcnt"); 7.49 + } 7.50 + 7.51 + public static void main(String args[]) throws Throwable { 7.52 + new TestUseCountLeadingZerosInstructionOnUnsupportedCPU().test(); 7.53 + } 7.54 +} 7.55 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java Thu Mar 27 17:29:41 2014 +0400 8.3 @@ -0,0 +1,72 @@ 8.4 +/* 8.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 + * or visit www.oracle.com if you need additional information or have any 8.24 + * questions. 8.25 + */ 8.26 + 8.27 +/** 8.28 + * @test 8.29 + * @bug 8031321 8.30 + * @summary Verify processing of UseCountTrailingZerosInstruction option 8.31 + * on CPU with TZCNT (BMI1 feature) support. 8.32 + * @library /testlibrary /testlibrary/whitebox 8.33 + * @build TestUseCountTrailingZerosInstructionOnSupportedCPU 8.34 + * BMISupportedCPUTest 8.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 8.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 8.37 + * -XX:+WhiteBoxAPI 8.38 + * TestUseCountTrailingZerosInstructionOnSupportedCPU 8.39 + */ 8.40 + 8.41 +import sun.hotspot.cpuinfo.CPUInfo; 8.42 +import com.oracle.java.testlibrary.*; 8.43 +import com.oracle.java.testlibrary.cli.*; 8.44 + 8.45 +public class TestUseCountTrailingZerosInstructionOnSupportedCPU 8.46 + extends BMISupportedCPUTest { 8.47 + 8.48 + public TestUseCountTrailingZerosInstructionOnSupportedCPU() { 8.49 + super("UseCountTrailingZerosInstruction", TZCNT_WARNING, "bmi1"); 8.50 + } 8.51 + 8.52 + @Override 8.53 + public void runTestCases() throws Throwable { 8.54 + 8.55 + super.runTestCases(); 8.56 + 8.57 + // verify that option will be disabled if all BMI1 instuctions 8.58 + // are explicitly disabled 8.59 + CommandLineOptionTest. 8.60 + verifyOptionValue("UseCountTrailingZerosInstruction", "false", 8.61 + "-XX:-UseBMI1Instructions"); 8.62 + 8.63 + // verify that option could be turned on even if other BMI1 8.64 + // instructions were turned off 8.65 + CommandLineOptionTest. 8.66 + verifyOptionValue("UseCountTrailingZerosInstruction", "true", 8.67 + "-XX:-UseBMI1Instructions", 8.68 + "-XX:+UseCountTrailingZerosInstruction"); 8.69 + } 8.70 + 8.71 + public static void main(String args[]) throws Throwable { 8.72 + new TestUseCountTrailingZerosInstructionOnSupportedCPU().test(); 8.73 + } 8.74 +} 8.75 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java Thu Mar 27 17:29:41 2014 +0400 9.3 @@ -0,0 +1,70 @@ 9.4 +/* 9.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 +/** 9.28 + * @test 9.29 + * @bug 8031321 9.30 + * @summary Verify processing of UseCountTrailingZerosInstruction option 9.31 + * on CPU without TZCNT instuction (BMI1 feature) support. 9.32 + * @library /testlibrary /testlibrary/whitebox 9.33 + * @build TestUseCountTrailingZerosInstructionOnUnsupportedCPU 9.34 + * BMIUnsupportedCPUTest 9.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 9.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 9.37 + * -XX:+WhiteBoxAPI 9.38 + * TestUseCountTrailingZerosInstructionOnUnsupportedCPU 9.39 + */ 9.40 + 9.41 +import sun.hotspot.cpuinfo.CPUInfo; 9.42 +import com.oracle.java.testlibrary.*; 9.43 +import com.oracle.java.testlibrary.cli.*; 9.44 + 9.45 +public class TestUseCountTrailingZerosInstructionOnUnsupportedCPU 9.46 + extends BMIUnsupportedCPUTest { 9.47 + 9.48 + public TestUseCountTrailingZerosInstructionOnUnsupportedCPU() { 9.49 + super("UseCountTrailingZerosInstruction", TZCNT_WARNING, "bmi1"); 9.50 + } 9.51 + 9.52 + @Override 9.53 + public void unsupportedX86CPUTestCases() throws Throwable { 9.54 + 9.55 + super.unsupportedX86CPUTestCases(); 9.56 + 9.57 + // verify that option will not be turned on during 9.58 + // UseBMI1Instuctions processing 9.59 + CommandLineOptionTest. 9.60 + verifyOptionValue("UseCountTrailingZerosInstruction", "false", 9.61 + "-XX:+UseBMI1Instructions"); 9.62 + 9.63 + CommandLineOptionTest. 9.64 + verifyOptionValue("UseCountTrailingZerosInstruction", "false", 9.65 + "-XX:+UseCountTrailingZerosInstruction", 9.66 + "-XX:+UseBMI1Instructions"); 9.67 + } 9.68 + 9.69 + public static void main(String args[]) throws Throwable { 9.70 + new TestUseCountTrailingZerosInstructionOnUnsupportedCPU().test(); 9.71 + } 9.72 +} 9.73 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/ExitCode.java Thu Mar 27 17:29:41 2014 +0400 10.3 @@ -0,0 +1,40 @@ 10.4 +/* 10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +package com.oracle.java.testlibrary; 10.28 + 10.29 +/** 10.30 + * Exit code values that could be returned by the JVM. 10.31 + */ 10.32 +public enum ExitCode { 10.33 + OK(0), 10.34 + FAIL(1), 10.35 + CRASH(134); 10.36 + 10.37 + public final int value; 10.38 + 10.39 + ExitCode(int value) { 10.40 + this.value = value; 10.41 + } 10.42 +} 10.43 +
11.1 --- a/test/testlibrary/com/oracle/java/testlibrary/Utils.java Tue Jan 28 10:19:45 2014 -0800 11.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/Utils.java Thu Mar 27 17:29:41 2014 +0400 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -108,6 +108,40 @@ 11.11 } 11.12 11.13 /** 11.14 + * Returns the default JTReg arguments for a jvm running a test without 11.15 + * options that matches regular expresions in {@code filters}. 11.16 + * This is the combination of JTReg arguments test.vm.opts and test.java.opts. 11.17 + * @param filters Regular expressions used to filter out options. 11.18 + * @return An array of options, or an empty array if no opptions. 11.19 + */ 11.20 + public static String[] getFilteredTestJavaOpts(String... filters) { 11.21 + String options[] = getTestJavaOpts(); 11.22 + 11.23 + if (filters.length == 0) { 11.24 + return options; 11.25 + } 11.26 + 11.27 + List<String> filteredOptions = new ArrayList<String>(options.length); 11.28 + Pattern patterns[] = new Pattern[filters.length]; 11.29 + for (int i = 0; i < filters.length; i++) { 11.30 + patterns[i] = Pattern.compile(filters[i]); 11.31 + } 11.32 + 11.33 + for (String option : options) { 11.34 + boolean matched = false; 11.35 + for (int i = 0; i < patterns.length && !matched; i++) { 11.36 + Matcher matcher = patterns[i].matcher(option); 11.37 + matched = matcher.find(); 11.38 + } 11.39 + if (!matched) { 11.40 + filteredOptions.add(option); 11.41 + } 11.42 + } 11.43 + 11.44 + return filteredOptions.toArray(new String[filteredOptions.size()]); 11.45 + } 11.46 + 11.47 + /** 11.48 * Combines given arguments with default JTReg arguments for a jvm running a test. 11.49 * This is the combination of JTReg arguments test.vm.opts and test.java.opts 11.50 * @return The combination of JTReg test java options and user args.
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/cli/CPUSpecificCommandLineOptionTest.java Thu Mar 27 17:29:41 2014 +0400 12.3 @@ -0,0 +1,110 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +package com.oracle.java.testlibrary.cli; 12.28 + 12.29 +import sun.hotspot.cpuinfo.CPUInfo; 12.30 +import com.oracle.java.testlibrary.*; 12.31 + 12.32 +/** 12.33 + * Base class for command line options tests that 12.34 + * requires specific CPU arch or specific CPU features. 12.35 + */ 12.36 +public abstract class CPUSpecificCommandLineOptionTest 12.37 + extends CommandLineOptionTest { 12.38 + 12.39 + private String cpuArchPattern; 12.40 + private String supportedCPUFeatures[]; 12.41 + private String unsupportedCPUFeatures[]; 12.42 + 12.43 + /** 12.44 + * Create new CPU specific test instance that does not 12.45 + * require any CPU features. 12.46 + * 12.47 + * @param cpuArchPattern Regular expression that should 12.48 + * match os.arch. 12.49 + */ 12.50 + public CPUSpecificCommandLineOptionTest(String cpuArchPattern) { 12.51 + this(cpuArchPattern, null, null); 12.52 + } 12.53 + 12.54 + /** 12.55 + * Create new CPU specific test instance that does not 12.56 + * require from CPU support of {@code supportedCPUFeatures} features 12.57 + * and no support of {@code unsupportedCPUFeatures}. 12.58 + * 12.59 + * @param cpuArchPattern Regular expression that should 12.60 + * match os.arch. 12.61 + * @param supportedCPUFeatures Array with names of features that 12.62 + * should be supported by CPU. If <b>null</b>, 12.63 + * then no features have to be supported. 12.64 + * @param unsupportedCPUFeatures Array with names of features that 12.65 + * should not be supported by CPU. 12.66 + * If <b>null</b>, then CPU may support any 12.67 + * features. 12.68 + */ 12.69 + public CPUSpecificCommandLineOptionTest(String cpuArchPattern, 12.70 + String supportedCPUFeatures[], 12.71 + String unsupportedCPUFeatures[]) { 12.72 + this.cpuArchPattern = cpuArchPattern; 12.73 + this.supportedCPUFeatures = supportedCPUFeatures; 12.74 + this.unsupportedCPUFeatures = unsupportedCPUFeatures; 12.75 + } 12.76 + 12.77 + /** 12.78 + * Check that CPU on test box has appropriate architecture, support all 12.79 + * required features and does not support all features that should not be 12.80 + * supported. 12.81 + * 12.82 + * @return <b>true</b> if CPU on test box fulfill all requirements. 12.83 + */ 12.84 + @Override 12.85 + public boolean checkPreconditions() { 12.86 + if (!Platform.getOsArch().matches(cpuArchPattern)) { 12.87 + System.out.println("CPU arch does not match " + cpuArchPattern); 12.88 + return false; 12.89 + } 12.90 + 12.91 + if (supportedCPUFeatures != null) { 12.92 + for (String feature : supportedCPUFeatures) { 12.93 + if (!CPUInfo.hasFeature(feature)) { 12.94 + System.out.println("CPU does not support " + feature + 12.95 + " feature"); 12.96 + return false; 12.97 + } 12.98 + } 12.99 + } 12.100 + 12.101 + if (unsupportedCPUFeatures != null) { 12.102 + for (String feature : unsupportedCPUFeatures) { 12.103 + if (CPUInfo.hasFeature(feature)) { 12.104 + System.out.println("CPU support " + feature + " feature"); 12.105 + return false; 12.106 + } 12.107 + } 12.108 + } 12.109 + 12.110 + return true; 12.111 + } 12.112 +} 12.113 +
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java Thu Mar 27 17:29:41 2014 +0400 13.3 @@ -0,0 +1,173 @@ 13.4 +/* 13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + */ 13.26 + 13.27 +package com.oracle.java.testlibrary.cli; 13.28 + 13.29 +import java.util.List; 13.30 +import java.util.ArrayList; 13.31 +import java.util.Collections; 13.32 + 13.33 +import com.oracle.java.testlibrary.*; 13.34 + 13.35 +/** 13.36 + * Base class for command line option tests. 13.37 + */ 13.38 +public abstract class CommandLineOptionTest { 13.39 + 13.40 + public static final String UNRECOGNIZED_OPTION_ERROR_FORMAT = 13.41 + "Unrecognized VM option '[+-]?%s'"; 13.42 + 13.43 + public static final String printFlagsFinalFormat = "%s\\s*:?=\\s*%s"; 13.44 + 13.45 + /** 13.46 + * Verify that JVM startup behaviour matches our expectations. 13.47 + * 13.48 + * @param option The option that should be passed to JVM 13.49 + * @param excpectedMessages Array of patterns that should occur 13.50 + * in JVM output. If <b>null</b> then 13.51 + * JVM output could be empty. 13.52 + * @param unexpectedMessages Array of patterns that should not 13.53 + * occur in JVM output. If <b>null</b> then 13.54 + * JVM output could be empty. 13.55 + * @param exitCode expected exit code. 13.56 + * @throws Throwable if verification fails or some other issues occur. 13.57 + */ 13.58 + public static void verifyJVMStartup(String option, 13.59 + String expectedMessages[], 13.60 + String unexpectedMessages[], 13.61 + ExitCode exitCode) 13.62 + throws Throwable { 13.63 + 13.64 + OutputAnalyzer outputAnalyzer = 13.65 + ProcessTools.executeTestJvm(option, "-version"); 13.66 + 13.67 + outputAnalyzer.shouldHaveExitValue(exitCode.value); 13.68 + 13.69 + if (expectedMessages != null) { 13.70 + for (String expectedMessage : expectedMessages) { 13.71 + outputAnalyzer.shouldMatch(expectedMessage); 13.72 + } 13.73 + } 13.74 + 13.75 + if (unexpectedMessages != null) { 13.76 + for (String unexpectedMessage : unexpectedMessages) { 13.77 + outputAnalyzer.shouldNotMatch(unexpectedMessage); 13.78 + } 13.79 + } 13.80 + } 13.81 + 13.82 + /** 13.83 + * Verify that value of specified JVM option is the same as 13.84 + * expected value. 13.85 + * This method filter out option with {@code optionName} 13.86 + * name from test java options. 13.87 + * 13.88 + * @param optionName Name of tested option. 13.89 + * @param expectedValue Expected value of tested option. 13.90 + * @param additionalVMOpts Additonal options that should be 13.91 + * passed to JVM. 13.92 + * @throws Throwable if verification fails or some other issues occur. 13.93 + */ 13.94 + public static void verifyOptionValue(String optionName, 13.95 + String expectedValue, 13.96 + String... additionalVMOpts) 13.97 + throws Throwable { 13.98 + verifyOptionValue(optionName, expectedValue, true, additionalVMOpts); 13.99 + } 13.100 + 13.101 + /** 13.102 + * Verify that value of specified JVM option is the same as 13.103 + * expected value. 13.104 + * This method filter out option with {@code optionName} 13.105 + * name from test java options. 13.106 + * 13.107 + * @param optionName Name of tested option. 13.108 + * @param expectedValue Expected value of tested option. 13.109 + * @param addTestVmOptions If <b>true</b>, then test VM options 13.110 + * will be used. 13.111 + * @param additionalVMOpts Additonal options that should be 13.112 + * passed to JVM. 13.113 + * @throws Throwable if verification fails or some other issues occur. 13.114 + */ 13.115 + public static void verifyOptionValue(String optionName, 13.116 + String expectedValue, 13.117 + boolean addTestVmOptions, 13.118 + String... additionalVMOpts) 13.119 + throws Throwable { 13.120 + 13.121 + List<String> vmOpts = new ArrayList<String>(); 13.122 + 13.123 + if (addTestVmOptions) { 13.124 + Collections.addAll(vmOpts, 13.125 + Utils.getFilteredTestJavaOpts(optionName)); 13.126 + } 13.127 + Collections.addAll(vmOpts, additionalVMOpts); 13.128 + Collections.addAll(vmOpts, new String[] { 13.129 + "-XX:+PrintFlagsFinal", 13.130 + "-version" 13.131 + }); 13.132 + 13.133 + ProcessBuilder processBuilder = 13.134 + ProcessTools. 13.135 + createJavaProcessBuilder(vmOpts. 13.136 + toArray(new String[vmOpts.size()])); 13.137 + 13.138 + OutputAnalyzer outputAnalyzer = 13.139 + new OutputAnalyzer(processBuilder.start()); 13.140 + 13.141 + outputAnalyzer.shouldHaveExitValue(0); 13.142 + outputAnalyzer.shouldMatch(String. 13.143 + format(printFlagsFinalFormat, 13.144 + optionName, 13.145 + expectedValue)); 13.146 + } 13.147 + 13.148 + 13.149 + /** 13.150 + * Run command line option test. 13.151 + * 13.152 + * @throws Throwable if test failed. 13.153 + */ 13.154 + public final void test() throws Throwable { 13.155 + if (checkPreconditions()) { 13.156 + runTestCases(); 13.157 + } 13.158 + } 13.159 + 13.160 + /** 13.161 + * Check that all preconditions for test execution are met. 13.162 + * 13.163 + * @return <b>true</b> if test could be executed. 13.164 + */ 13.165 + public boolean checkPreconditions() { 13.166 + return true; 13.167 + } 13.168 + 13.169 + /** 13.170 + * Run test cases. 13.171 + * 13.172 + * @throws Throwable if test failed. 13.173 + */ 13.174 + public abstract void runTestCases() throws Throwable; 13.175 +} 13.176 +