8145728: compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java Expected message not found
authorepavlova
Thu, 01 Jun 2017 17:33:07 -0700
changeset 46514 38a2f229b094
parent 46513 c61eea516a0a
child 46515 dbb676a40899
8145728: compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java Expected message not found Reviewed-by: kvn
hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java
hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java
hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java
hotspot/test/compiler/cpuflags/predicate/AESSupportPredicate.java
--- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java	Thu Jun 01 09:34:53 2017 -0700
+++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java	Thu Jun 01 17:33:07 2017 -0700
@@ -24,15 +24,9 @@
 package compiler.cpuflags;
 
 import compiler.codegen.aes.TestAESMain;
-import compiler.cpuflags.predicate.AESSupportPredicate;
-import jdk.test.lib.cli.CommandLineOptionTest;
+import java.util.Arrays;
 
-import java.util.Arrays;
-import java.util.function.BooleanSupplier;
-
-public abstract class AESIntrinsicsBase extends CommandLineOptionTest {
-    public static final BooleanSupplier AES_SUPPORTED_PREDICATE
-            = new AESSupportPredicate();
+public abstract class AESIntrinsicsBase {
     public static final String CIPHER_INTRINSIC = "com\\.sun\\.crypto\\"
             + ".provider\\.CipherBlockChaining::"
             + "(implEncrypt|implDecrypt) \\([0-9]+ bytes\\)\\s+\\(intrinsic[,\\)]";
@@ -50,10 +44,6 @@
             "-Xbatch", "-XX:CompileThresholdScaling=0.01", "-DcheckOutput=true", "-Dmode=CBC",
             TestAESMain.class.getName(), "100", "1000"};
 
-    protected AESIntrinsicsBase(BooleanSupplier predicate) {
-        super(predicate);
-    }
-
     /**
      * Prepares command for TestAESMain execution.
      * Intrinsics flags are of diagnostic type
--- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java	Thu Jun 01 09:34:53 2017 -0700
+++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java	Thu Jun 01 17:33:07 2017 -0700
@@ -26,6 +26,7 @@
  * @library /test/lib /
  * @modules java.base/jdk.internal.misc
  *          java.management
+ * @requires vm.cpu.features ~= ".*aes.*"
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -40,18 +41,11 @@
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.Platform;
 import jdk.test.lib.process.ProcessTools;
+import sun.hotspot.WhiteBox;
+import static jdk.test.lib.cli.CommandLineOptionTest.*;
 
 public class TestAESIntrinsicsOnSupportedConfig extends AESIntrinsicsBase {
 
-    /**
-     * Constructs new TestAESIntrinsicsOnSupportedConfig that will be executed
-     * only if AESSupportPredicate returns true
-     */
-    private TestAESIntrinsicsOnSupportedConfig() {
-        super(AESIntrinsicsBase.AES_SUPPORTED_PREDICATE);
-    }
-
-    @Override
     protected void runTestCases() throws Throwable {
         testUseAES();
         testUseAESUseSSE2();
@@ -63,6 +57,16 @@
     }
 
     /**
+     * Check if value of TieredStopAtLevel flag is greater than specified level.
+     *
+     * @param level tiered compilation level to compare with
+     */
+    private boolean isTieredLevelGreaterThan(int level) {
+        Long val = WhiteBox.getWhiteBox().getIntxVMFlag("TieredStopAtLevel");
+        return (val != null && val > level);
+    }
+
+    /**
      * Test checks following situation: <br/>
      * UseAES flag is set to true, TestAESMain is executed <br/>
      * Expected result: UseAESIntrinsics flag is set to true <br/>
@@ -75,7 +79,7 @@
                 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                         .USE_AES, true)));
         final String errorMessage = "Case testUseAES failed";
-        if (Platform.isServer() && !Platform.isEmulatedClient()) {
+        if (Platform.isServer() && !Platform.isEmulatedClient() && isTieredLevelGreaterThan(3)) {
             verifyOutput(new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                     AESIntrinsicsBase.AES_INTRINSIC}, null, errorMessage,
                     outputAnalyzer);
@@ -252,6 +256,6 @@
     }
 
     public static void main(String args[]) throws Throwable {
-        new TestAESIntrinsicsOnSupportedConfig().test();
+        new TestAESIntrinsicsOnSupportedConfig().runTestCases();
     }
 }
--- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java	Thu Jun 01 09:34:53 2017 -0700
+++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java	Thu Jun 01 17:33:07 2017 -0700
@@ -28,6 +28,7 @@
  *          java.management
  *
  * @build sun.hotspot.WhiteBox
+ * @requires !(vm.cpu.features ~= ".*aes.*")
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -40,6 +41,7 @@
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.cli.predicate.NotPredicate;
+import static jdk.test.lib.cli.CommandLineOptionTest.*;
 
 public class TestAESIntrinsicsOnUnsupportedConfig extends AESIntrinsicsBase {
 
@@ -48,15 +50,6 @@
     private static final String AES_NOT_AVAILABLE_MSG = "warning: AES "
             + "instructions are not available on this CPU";
 
-    /**
-     * Constructs new TestAESIntrinsicsOnUnsupportedConfig that will be
-     * executed only if AESSupportPredicate returns false
-     */
-    private TestAESIntrinsicsOnUnsupportedConfig() {
-        super(new NotPredicate(AESIntrinsicsBase.AES_SUPPORTED_PREDICATE));
-    }
-
-    @Override
     protected void runTestCases() throws Throwable {
         testUseAES();
         testUseAESIntrinsics();
@@ -110,6 +103,6 @@
     }
 
     public static void main(String args[]) throws Throwable {
-        new TestAESIntrinsicsOnUnsupportedConfig().test();
+        new TestAESIntrinsicsOnUnsupportedConfig().runTestCases();
     }
 }
--- a/hotspot/test/compiler/cpuflags/predicate/AESSupportPredicate.java	Thu Jun 01 09:34:53 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package compiler.cpuflags.predicate;
-
-import sun.hotspot.cpuinfo.CPUInfo;
-
-import java.util.function.BooleanSupplier;
-
-public class AESSupportPredicate implements BooleanSupplier {
-
-    private static final String AES = "aes";
-
-    @Override
-    public boolean getAsBoolean() {
-        return CPUInfo.getFeatures().contains(AES);
-    }
-}