hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 38285 20b85a0ba796
child 40631 ed82623d7831
permissions -rw-r--r--
8132919: Put compiler tests in packages Reviewed-by: vlivanov, dpochepk Contributed-by: igor.ignatyev@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     1
/*
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     4
 *
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     8
 *
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    13
 * accompanied this code).
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    14
 *
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    18
 *
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    21
 * questions.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    22
 */
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    23
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38285
diff changeset
    24
package compiler.intrinsics.sha.cli.testcases;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38285
diff changeset
    25
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38285
diff changeset
    26
import compiler.intrinsics.sha.cli.SHAOptionsBase;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28200
diff changeset
    27
import jdk.test.lib.ExitCode;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28200
diff changeset
    28
import jdk.test.lib.Platform;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28200
diff changeset
    29
import jdk.test.lib.cli.CommandLineOptionTest;
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    30
import jdk.test.lib.cli.predicate.AndPredicate;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38285
diff changeset
    31
import jdk.test.lib.cli.predicate.NotPredicate;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28200
diff changeset
    32
import jdk.test.lib.cli.predicate.OrPredicate;
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    33
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    34
/**
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    35
 * Generic test case for SHA-related options targeted to X86 CPUs that don't
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    36
 * support SHA-related instructions.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    37
 */
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    38
public class GenericTestCaseForUnsupportedX86CPU
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    39
        extends SHAOptionsBase.TestCase {
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    40
    public GenericTestCaseForUnsupportedX86CPU(String optionName) {
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    41
        super(optionName, new AndPredicate(new OrPredicate(Platform::isX64, Platform::isX86),
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    42
                new NotPredicate(SHAOptionsBase.getPredicateForOption(
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    43
                        optionName))));
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    44
    }
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    45
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    46
    @Override
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    47
    protected void verifyWarnings() throws Throwable {
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    48
        String shouldPassMessage = String.format("JVM should start with '-XX:-%s' "
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    49
                + "flag without any warnings", optionName);
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    50
        // Verify that the tested option could be explicitly disabled without
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    51
        // a warning.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    52
        CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    53
                        SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    54
                }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
38285
20b85a0ba796 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents: 38135
diff changeset
    55
                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    56
                CommandLineOptionTest.prepareBooleanFlag(optionName, false));
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    57
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    58
        // Verify that when the tested option is enabled, then
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    59
        // a warning will occur in VM output if UseSHA is disabled.
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    60
        if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    61
            CommandLineOptionTest.verifySameJVMStartup(
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    62
                    new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    63
                    null,
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    64
                    shouldPassMessage,
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    65
                    shouldPassMessage,
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    66
                    ExitCode.OK,
38285
20b85a0ba796 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents: 38135
diff changeset
    67
                    SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    68
                    CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    69
                    CommandLineOptionTest.prepareBooleanFlag(optionName, true));
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 30604
diff changeset
    70
        }
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    71
    }
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    72
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    73
    @Override
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    74
    protected void verifyOptionValues() throws Throwable {
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    75
        // Verify that the tested option is disabled by default.
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    76
        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    77
                String.format("Option '%s' should be disabled by default",
38285
20b85a0ba796 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents: 38135
diff changeset
    78
                        optionName),
20b85a0ba796 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents: 38135
diff changeset
    79
                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    80
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    81
        // Verify that it is not possible to explicitly enable the option.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    82
        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    83
                String.format("Option '%s' should be off on unsupported "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    84
                        + "X86CPU even if set to true directly", optionName),
38285
20b85a0ba796 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents: 38135
diff changeset
    85
                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    86
                CommandLineOptionTest.prepareBooleanFlag(optionName, true));
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    87
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    88
        // Verify that the tested option is disabled even if +UseSHA was passed
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    89
        // to JVM.
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    90
        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
28200
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    91
                String.format("Option '%s' should be off on unsupported "
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    92
                        + "X86CPU even if %s flag set to JVM",
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    93
                        optionName, CommandLineOptionTest.prepareBooleanFlag(
38d3bf236c31 8054892: Improve compiler's CLI tests error reporting
eistepan
parents: 26439
diff changeset
    94
                            SHAOptionsBase.USE_SHA_OPTION, true)),
38285
20b85a0ba796 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents: 38135
diff changeset
    95
                SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
26439
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    96
                CommandLineOptionTest.prepareBooleanFlag(
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    97
                        SHAOptionsBase.USE_SHA_OPTION, true));
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    98
    }
0fa6c2cb6007 8055904: Develop tests for new command-line options related to SHA intrinsics
fzhinkin
parents:
diff changeset
    99
}