mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8069160: serviceability/dcmd/compiler/CompilerQueueTest.java fails due to class not found
Use whitebox to test specific cases making test less fragile Reviewed-by: kvn
This commit is contained in:
parent
607365df56
commit
d596cf06af
1 changed files with 108 additions and 47 deletions
|
@ -24,25 +24,33 @@
|
||||||
/*
|
/*
|
||||||
* @test CompilerQueueTest
|
* @test CompilerQueueTest
|
||||||
* @bug 8054889
|
* @bug 8054889
|
||||||
* @library /testlibrary
|
* @library /testlibrary /test/lib /
|
||||||
* @modules java.base/sun.misc
|
* @modules java.base/sun.misc
|
||||||
* java.compiler
|
* java.compiler
|
||||||
* java.management
|
* java.management
|
||||||
* jdk.jvmstat/sun.jvmstat.monitor
|
* jdk.jvmstat/sun.jvmstat.monitor
|
||||||
* @ignore 8069160
|
|
||||||
* @build jdk.test.lib.*
|
* @build jdk.test.lib.*
|
||||||
* @build jdk.test.lib.dcmd.*
|
* jdk.test.lib.dcmd.*
|
||||||
* @run testng CompilerQueueTest
|
* sun.hotspot.WhiteBox
|
||||||
* @run testng/othervm -XX:-TieredCompilation CompilerQueueTest
|
* compiler.testlibrary.CompilerUtils
|
||||||
* @run testng/othervm -Xint CompilerQueueTest
|
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
|
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:+WhiteBoxAPI CompilerQueueTest
|
||||||
|
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:-TieredCompilation -XX:+WhiteBoxAPI CompilerQueueTest
|
||||||
|
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xint -XX:+WhiteBoxAPI CompilerQueueTest
|
||||||
* @summary Test of diagnostic command Compiler.queue
|
* @summary Test of diagnostic command Compiler.queue
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import compiler.testlibrary.CompilerUtils;
|
||||||
import jdk.test.lib.OutputAnalyzer;
|
import jdk.test.lib.OutputAnalyzer;
|
||||||
import jdk.test.lib.dcmd.CommandExecutor;
|
import jdk.test.lib.dcmd.CommandExecutor;
|
||||||
import jdk.test.lib.dcmd.JMXExecutor;
|
import jdk.test.lib.dcmd.JMXExecutor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import sun.hotspot.WhiteBox;
|
||||||
|
|
||||||
|
import java.lang.reflect.Executable;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class CompilerQueueTest {
|
public class CompilerQueueTest {
|
||||||
|
@ -54,70 +62,123 @@ public class CompilerQueueTest {
|
||||||
*
|
*
|
||||||
* Output example:
|
* Output example:
|
||||||
*
|
*
|
||||||
* Contents of C1 compile queue
|
* Current compiles:
|
||||||
* ----------------------------
|
* C1 CompilerThread14 267 3 java.net.URLStreamHandler::parseURL (1166 bytes)
|
||||||
* 73 3 java.lang.AbstractStringBuilder::append (50 bytes)
|
* C1 CompilerThread13 760 3 javax.management.StandardMBean::getDescription (11 bytes)
|
||||||
* 74 1 java.util.TreeMap::size (5 bytes)
|
* C1 CompilerThread12 757 s 3 com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::getMapping (27 bytes)
|
||||||
* 75 3 java.lang.StringBuilder::append (8 bytes)
|
* C1 CompilerThread11 756 s! 3 com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::mappingForType (110 bytes)
|
||||||
* 83 3 java.util.TreeMap$ValueIterator::next (8 bytes)
|
* C1 CompilerThread10 761 3 java.lang.StringLatin1::indexOf (121 bytes)
|
||||||
* 84 1 javax.management.MBeanFeatureInfo::getName (5 bytes)
|
* C2 CompilerThread7 769 4 CompilerQueueTest::testcaseMethod4 (1 bytes)
|
||||||
* ----------------------------
|
*
|
||||||
* Contents of C2 compile queue
|
* C1 compile queue:
|
||||||
* ----------------------------
|
* 762 3 java.lang.invoke.MethodType::basicType (8 bytes)
|
||||||
|
* 763 3 java.util.ArrayList::rangeCheck (22 bytes)
|
||||||
|
* 764 3 java.util.ArrayList::elementData (7 bytes)
|
||||||
|
* 765 3 jdk.internal.org.objectweb.asm.MethodVisitor::<init> (35 bytes)
|
||||||
|
* 766 1 CompilerQueueTest::testcaseMethod1 (1 bytes)
|
||||||
|
* 767 2 CompilerQueueTest::testcaseMethod2 (1 bytes)
|
||||||
|
* 768 3 CompilerQueueTest::testcaseMethod3 (1 bytes)
|
||||||
|
* 770 3 java.util.Properties::getProperty (46 bytes)
|
||||||
|
*
|
||||||
|
* C2 compile queue:
|
||||||
* Empty
|
* Empty
|
||||||
* ----------------------------
|
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
protected static final WhiteBox WB = WhiteBox.getWhiteBox();
|
||||||
|
|
||||||
public void run(CommandExecutor executor) {
|
public void run(CommandExecutor executor) {
|
||||||
|
|
||||||
|
TestCase[] testcases = {
|
||||||
|
new TestCase(1, "testcaseMethod1"),
|
||||||
|
new TestCase(2, "testcaseMethod2"),
|
||||||
|
new TestCase(3, "testcaseMethod3"),
|
||||||
|
new TestCase(4, "testcaseMethod4"),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Lock compilation makes all compiles stay in queue or compile thread before completion
|
||||||
|
WB.lockCompilation();
|
||||||
|
|
||||||
|
// Enqueue one test method for each available level
|
||||||
|
int[] complevels = CompilerUtils.getAvailableCompilationLevels();
|
||||||
|
for (int level : complevels) {
|
||||||
|
TestCase testcase = testcases[level - 1];
|
||||||
|
|
||||||
|
boolean added = WB.enqueueMethodForCompilation(testcase.method, testcase.level);
|
||||||
|
// Set results to false for those methods we must to find
|
||||||
|
// We will also assert if we find any test method we don't expect
|
||||||
|
Assert.assertTrue(WB.isMethodQueuedForCompilation(testcase.method));
|
||||||
|
testcase.check = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get output from dcmd (diagnostic command)
|
// Get output from dcmd (diagnostic command)
|
||||||
OutputAnalyzer output = executor.execute("Compiler.queue");
|
OutputAnalyzer output = executor.execute("Compiler.queue");
|
||||||
Iterator<String> lines = output.asLines().iterator();
|
Iterator<String> lines = output.asLines().iterator();
|
||||||
|
|
||||||
|
// Loop over output set result for all found methods
|
||||||
while (lines.hasNext()) {
|
while (lines.hasNext()) {
|
||||||
String str = lines.next();
|
String str = lines.next();
|
||||||
if (str.startsWith("Contents of C")) {
|
// Fast check for common part of method name
|
||||||
match(lines.next(), "----------------------------");
|
if (str.contains("testcaseMethod")) {
|
||||||
str = lines.next();
|
for (TestCase testcase : testcases) {
|
||||||
if (!str.equals("Empty")) {
|
if (str.contains(testcase.methodName)) {
|
||||||
while (str.charAt(0) != '-') {
|
Assert.assertFalse(testcase.check, "Must not be found or already found.");
|
||||||
validateMethodLine(str);
|
testcase.check = true;
|
||||||
str = lines.next();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
str = lines.next();
|
|
||||||
}
|
|
||||||
match(str,"----------------------------");
|
|
||||||
} else {
|
|
||||||
Assert.fail("Failed parsing dcmd queue, line: " + str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateMethodLine(String str) {
|
for (TestCase testcase : testcases) {
|
||||||
// Skip until package/class name begins. Trim to remove whitespace that
|
if (!testcase.check) {
|
||||||
// may differ.
|
// If this method wasn't found it must have been removed by policy,
|
||||||
String name = str.substring(14).trim();
|
// verify that it is now removed from the queue
|
||||||
int sep = name.indexOf("::");
|
Assert.assertFalse(WB.isMethodQueuedForCompilation(testcase.method), "Must be found or not in queue");
|
||||||
if (sep == -1) {
|
|
||||||
Assert.fail("Failed dcmd queue, didn't find separator :: in: " + name);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Class.forName(name.substring(0, sep));
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
Assert.fail("Failed dcmd queue, Class for name: " + str);
|
|
||||||
}
|
}
|
||||||
|
// Otherwise all good.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void match(String line, String str) {
|
// Enable compilations again
|
||||||
if (!line.equals(str)) {
|
WB.unlockCompilation();
|
||||||
Assert.fail("String equals: " + line + ", " + str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jmx() {
|
public void jmx() {
|
||||||
run(new JMXExecutor());
|
run(new JMXExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testcaseMethod1() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testcaseMethod2() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testcaseMethod3() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testcaseMethod4() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Method getMethod(Class klass, String name, Class<?>... parameterTypes) {
|
||||||
|
try {
|
||||||
|
return klass.getDeclaredMethod(name, parameterTypes);
|
||||||
|
} catch (NoSuchMethodException | SecurityException e) {
|
||||||
|
throw new RuntimeException("exception on getting method Helper." + name, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestCase {
|
||||||
|
Method method;
|
||||||
|
int level;
|
||||||
|
String methodName;
|
||||||
|
Boolean check;
|
||||||
|
|
||||||
|
public TestCase(int level, String methodName) {
|
||||||
|
this.method = getMethod(CompilerQueueTest.class, methodName);
|
||||||
|
this.level = level;
|
||||||
|
this.methodName = methodName;
|
||||||
|
this.check = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue