test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8130120 Sdiff test/compiler/intrinsics/sha/cli

test/compiler/intrinsics/sha/cli/SHAOptionsBase.java

Print this page




  30 /**
  31  * Base class for all CLI tests on SHA-related options.
  32  *
  33  * Instead of using huge complex tests for each option, each test is constructed
  34  * from several test cases shared among different tests.
  35  */
  36 public class SHAOptionsBase extends CommandLineOptionTest {
  37     protected static final String USE_SHA_OPTION = "UseSHA";
  38     protected static final String USE_SHA1_INTRINSICS_OPTION
  39             = "UseSHA1Intrinsics";
  40     protected static final String USE_SHA256_INTRINSICS_OPTION
  41             = "UseSHA256Intrinsics";
  42     protected static final String USE_SHA512_INTRINSICS_OPTION
  43             = "UseSHA512Intrinsics";
  44 
  45     // Note that strings below will be passed to
  46     // CommandLineOptionTest.verifySameJVMStartup and thus are regular
  47     // expressions, not just a plain strings.
  48     protected static final String SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE
  49             = "SHA instructions are not available on this CPU";
  50     protected static final String SHA1_INSTRUCTION_IS_NOT_AVAILABLE
  51             = "SHA1 instruction is not available on this CPU\\.";
  52     protected static final String SHA256_INSTRUCTION_IS_NOT_AVAILABLE
  53             = "SHA256 instruction \\(for SHA-224 and SHA-256\\) "
  54             + "is not available on this CPU\\.";
  55     protected static final String SHA512_INSTRUCTION_IS_NOT_AVAILABLE
  56             = "SHA512 instruction \\(for SHA-384 and SHA-512\\) "
  57             + "is not available on this CPU\\.";
  58     protected static final String SHA_INTRINSICS_ARE_NOT_AVAILABLE
  59             = "SHA intrinsics are not available on this CPU";
  60 
  61     private final TestCase[] testCases;
  62 
  63     /**
  64      * Returns warning message that should occur in VM output if an option with
  65      * the name {@code optionName} was turned on and CPU does not support
  66      * required instructions.
  67      *
  68      * @param optionName The name of the option for which warning message should
  69      *                   be returned.
  70      * @return A warning message that will be printed out to VM output if CPU
  71      *         instructions required by the option are not supported.
  72      */
  73     protected static String getWarningForUnsupportedCPU(String optionName) {
  74         if (Platform.isSparc() || Platform.isAArch64()) {

  75             switch (optionName) {
  76                 case SHAOptionsBase.USE_SHA_OPTION:
  77                     return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
  78                 case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
  79                     return SHAOptionsBase.SHA1_INSTRUCTION_IS_NOT_AVAILABLE;
  80                 case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
  81                     return SHAOptionsBase.SHA256_INSTRUCTION_IS_NOT_AVAILABLE;
  82                 case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
  83                     return SHAOptionsBase.SHA512_INSTRUCTION_IS_NOT_AVAILABLE;
  84                 default:
  85                     throw new Error("Unexpected option " + optionName);
  86             }
  87         } else if (Platform.isX64() || Platform.isX86()) {
  88             switch (optionName) {
  89                 case SHAOptionsBase.USE_SHA_OPTION:
  90                     return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
  91                 case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
  92                 case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
  93                 case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
  94                     return SHAOptionsBase.SHA_INTRINSICS_ARE_NOT_AVAILABLE;
  95                 default:
  96                     throw new Error("Unexpected option " + optionName);
  97             }
  98         } else {
  99             throw new Error("Support for CPUs other then X86 or SPARC is not "
 100                     + "implemented.");
 101         }
 102     }
 103 
 104     /**
 105      * Returns the predicate indicating whether or not CPU instructions required
 106      * by the option with name {@code optionName} are available.
 107      *
 108      * @param optionName The name of the option for which a predicate should be
 109      *                   returned.
 110      * @return The predicate on availability of CPU instructions required by the
 111      *         option.
 112      */
 113     protected static BooleanSupplier getPredicateForOption(String optionName) {
 114         switch (optionName) {
 115             case SHAOptionsBase.USE_SHA_OPTION:
 116                 return IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE;
 117             case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
 118                 return IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE;
 119             case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
 120                 return IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE;




  30 /**
  31  * Base class for all CLI tests on SHA-related options.
  32  *
  33  * Instead of using huge complex tests for each option, each test is constructed
  34  * from several test cases shared among different tests.
  35  */
  36 public class SHAOptionsBase extends CommandLineOptionTest {
  37     protected static final String USE_SHA_OPTION = "UseSHA";
  38     protected static final String USE_SHA1_INTRINSICS_OPTION
  39             = "UseSHA1Intrinsics";
  40     protected static final String USE_SHA256_INTRINSICS_OPTION
  41             = "UseSHA256Intrinsics";
  42     protected static final String USE_SHA512_INTRINSICS_OPTION
  43             = "UseSHA512Intrinsics";
  44 
  45     // Note that strings below will be passed to
  46     // CommandLineOptionTest.verifySameJVMStartup and thus are regular
  47     // expressions, not just a plain strings.
  48     protected static final String SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE
  49             = "SHA instructions are not available on this CPU";
  50     protected static final String SHA1_INTRINSICS_ARE_NOT_AVAILABLE
  51             = "Intrinsics for SHA-1 crypto hash functions not available.";
  52     protected static final String SHA256_INTRINSICS_ARE_NOT_AVAILABLE
  53             = "Intrinsics for SHA-224 and SHA-256 crypto hash functions not available.";
  54     protected static final String SHA512_INTRINSICS_ARE_NOT_AVAILABLE
  55             = "Intrinsics for SHA-384 and SHA-512 crypto hash functions not available.";




  56 
  57     private final TestCase[] testCases;
  58 
  59     /**
  60      * Returns warning message that should occur in VM output if an option with
  61      * the name {@code optionName} was turned on and CPU does not support
  62      * required instructions.
  63      *
  64      * @param optionName The name of the option for which warning message should
  65      *                   be returned.
  66      * @return A warning message that will be printed out to VM output if CPU
  67      *         instructions required by the option are not supported.
  68      */
  69     protected static String getWarningForUnsupportedCPU(String optionName) {
  70         if (Platform.isSparc() || Platform.isAArch64() ||
  71             Platform.isX64() || Platform.isX86()) {
  72             switch (optionName) {
  73             case SHAOptionsBase.USE_SHA_OPTION:
  74                 return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
  75             case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
  76                 return SHAOptionsBase.SHA1_INTRINSICS_ARE_NOT_AVAILABLE;
  77             case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
  78                 return SHAOptionsBase.SHA256_INTRINSICS_ARE_NOT_AVAILABLE;
  79             case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
  80                 return SHAOptionsBase.SHA512_INTRINSICS_ARE_NOT_AVAILABLE;











  81             default:
  82                 throw new Error("Unexpected option " + optionName);
  83             }
  84         } else {
  85             throw new Error("Support for CPUs different fromn X86, SPARC, and AARCH64 "
  86                             + "is not implemented");
  87         }
  88     }
  89 
  90     /**
  91      * Returns the predicate indicating whether or not CPU instructions required
  92      * by the option with name {@code optionName} are available.
  93      *
  94      * @param optionName The name of the option for which a predicate should be
  95      *                   returned.
  96      * @return The predicate on availability of CPU instructions required by the
  97      *         option.
  98      */
  99     protected static BooleanSupplier getPredicateForOption(String optionName) {
 100         switch (optionName) {
 101             case SHAOptionsBase.USE_SHA_OPTION:
 102                 return IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE;
 103             case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
 104                 return IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE;
 105             case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
 106                 return IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE;


test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File