< prev index next >

test/serviceability/dcmd/compiler/CompilerQueueTest.java

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test CompilerQueueTest
  26  * @bug 8054889
  27  * @library /testlibrary /test/lib /
  28  * @modules java.base/jdk.internal.misc
  29  *          java.compiler
  30  *          java.management
  31  *          jdk.jvmstat/sun.jvmstat.monitor
  32  * @summary Test of diagnostic command Compiler.queue
  33  * Fails intermittently on 32-bit VMs due to 8158756 so quarantine
  34  * it on those platforms:
  35  * @requires vm.bits != "32"
  36  * @build jdk.test.lib.*
  37  *        jdk.test.lib.dcmd.*
  38  *        sun.hotspot.WhiteBox
  39  *        compiler.testlibrary.CompilerUtils
  40  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  41  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  42  * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:+WhiteBoxAPI CompilerQueueTest
  43  * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:-TieredCompilation -XX:+WhiteBoxAPI CompilerQueueTest
  44  * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xint -XX:+WhiteBoxAPI CompilerQueueTest
  45  */
  46 
  47 import compiler.testlibrary.CompilerUtils;
  48 import jdk.test.lib.OutputAnalyzer;
  49 import jdk.test.lib.dcmd.CommandExecutor;
  50 import jdk.test.lib.dcmd.JMXExecutor;
  51 import org.testng.annotations.Test;
  52 import org.testng.Assert;
  53 import sun.hotspot.WhiteBox;
  54 
  55 import java.lang.reflect.Executable;


  93     public void run(CommandExecutor executor) {
  94 
  95         TestCase[] testcases = {
  96                 new TestCase(1, "testcaseMethod1"),
  97                 new TestCase(2, "testcaseMethod2"),
  98                 new TestCase(3, "testcaseMethod3"),
  99                 new TestCase(4, "testcaseMethod4"),
 100         };
 101 
 102         // Lock compilation makes all compiles stay in queue or compile thread before completion
 103         WB.lockCompilation();
 104 
 105         // Enqueue one test method for each available level
 106         int[] complevels = CompilerUtils.getAvailableCompilationLevels();
 107         for (int level : complevels) {
 108             TestCase testcase = testcases[level - 1];
 109 
 110             boolean added = WB.enqueueMethodForCompilation(testcase.method, testcase.level);
 111             // Set results to false for those methods we must to find
 112             // We will also assert if we find any test method we don't expect
 113             Assert.assertTrue(WB.isMethodQueuedForCompilation(testcase.method));
 114             testcase.check = false;
 115         }
 116 
 117         // Get output from dcmd (diagnostic command)
 118         OutputAnalyzer output = executor.execute("Compiler.queue");
 119         Iterator<String> lines = output.asLines().iterator();
 120 
 121         // Loop over output set result for all found methods
 122         while (lines.hasNext()) {
 123             String str = lines.next();
 124             // Fast check for common part of method name
 125             if (str.contains("testcaseMethod")) {
 126                 for (TestCase testcase : testcases) {
 127                     if (str.contains(testcase.methodName)) {
 128                         Assert.assertFalse(testcase.check, "Must not be found or already found.");
 129                         testcase.check = true;
 130                     }
 131                 }
 132             }
 133         }




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test CompilerQueueTest
  26  * @bug 8054889
  27  * @library /testlibrary /test/lib /
  28  * @modules java.base/jdk.internal.misc
  29  *          java.compiler
  30  *          java.management
  31  *          jdk.jvmstat/sun.jvmstat.monitor
  32  * @summary Test of diagnostic command Compiler.queue



  33  * @build jdk.test.lib.*
  34  *        jdk.test.lib.dcmd.*
  35  *        sun.hotspot.WhiteBox
  36  *        compiler.testlibrary.CompilerUtils
  37  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  38  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  39  * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:+WhiteBoxAPI CompilerQueueTest
  40  * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:-TieredCompilation -XX:+WhiteBoxAPI CompilerQueueTest
  41  * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xint -XX:+WhiteBoxAPI CompilerQueueTest
  42  */
  43 
  44 import compiler.testlibrary.CompilerUtils;
  45 import jdk.test.lib.OutputAnalyzer;
  46 import jdk.test.lib.dcmd.CommandExecutor;
  47 import jdk.test.lib.dcmd.JMXExecutor;
  48 import org.testng.annotations.Test;
  49 import org.testng.Assert;
  50 import sun.hotspot.WhiteBox;
  51 
  52 import java.lang.reflect.Executable;


  90     public void run(CommandExecutor executor) {
  91 
  92         TestCase[] testcases = {
  93                 new TestCase(1, "testcaseMethod1"),
  94                 new TestCase(2, "testcaseMethod2"),
  95                 new TestCase(3, "testcaseMethod3"),
  96                 new TestCase(4, "testcaseMethod4"),
  97         };
  98 
  99         // Lock compilation makes all compiles stay in queue or compile thread before completion
 100         WB.lockCompilation();
 101 
 102         // Enqueue one test method for each available level
 103         int[] complevels = CompilerUtils.getAvailableCompilationLevels();
 104         for (int level : complevels) {
 105             TestCase testcase = testcases[level - 1];
 106 
 107             boolean added = WB.enqueueMethodForCompilation(testcase.method, testcase.level);
 108             // Set results to false for those methods we must to find
 109             // We will also assert if we find any test method we don't expect
 110             Assert.assertEquals(added, WB.isMethodQueuedForCompilation(testcase.method));
 111             testcase.check = false;
 112         }
 113 
 114         // Get output from dcmd (diagnostic command)
 115         OutputAnalyzer output = executor.execute("Compiler.queue");
 116         Iterator<String> lines = output.asLines().iterator();
 117 
 118         // Loop over output set result for all found methods
 119         while (lines.hasNext()) {
 120             String str = lines.next();
 121             // Fast check for common part of method name
 122             if (str.contains("testcaseMethod")) {
 123                 for (TestCase testcase : testcases) {
 124                     if (str.contains(testcase.methodName)) {
 125                         Assert.assertFalse(testcase.check, "Must not be found or already found.");
 126                         testcase.check = true;
 127                     }
 128                 }
 129             }
 130         }


< prev index next >