8058712: [TESTBUG] serviceability/dcmd/CodeCacheTest.java fails with java.lang.Exception
The test is changed to check the output according to the number of available code segments. Reviewed-by: kvn
This commit is contained in:
parent
37c8ef911c
commit
b9eae7f74f
@ -25,7 +25,8 @@
|
|||||||
* @test CodeCacheTest
|
* @test CodeCacheTest
|
||||||
* @bug 8054889
|
* @bug 8054889
|
||||||
* @build DcmdUtil CodeCacheTest
|
* @build DcmdUtil CodeCacheTest
|
||||||
* @run main CodeCacheTest
|
* @run main/othervm -XX:+SegmentedCodeCache CodeCacheTest
|
||||||
|
* @run main/othervm -XX:-SegmentedCodeCache CodeCacheTest
|
||||||
* @summary Test of diagnostic command Compiler.codecache
|
* @summary Test of diagnostic command Compiler.codecache
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -39,34 +40,78 @@ public class CodeCacheTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This test calls Jcmd (diagnostic command tool) Compiler.codecache and then parses the output,
|
* This test calls Jcmd (diagnostic command tool) Compiler.codecache and then parses the output,
|
||||||
* making sure that all number look ok
|
* making sure that all numbers look ok
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Expected output:
|
* Expected output without code cache segmentation:
|
||||||
*
|
*
|
||||||
* CodeCache: size=245760Kb used=4680Kb max_used=4680Kb free=241079Kb
|
* CodeCache: size=245760Kb used=4680Kb max_used=4680Kb free=241079Kb
|
||||||
* bounds [0x00007f5bd9000000, 0x00007f5bd94a0000, 0x00007f5be8000000]
|
* bounds [0x00007f5bd9000000, 0x00007f5bd94a0000, 0x00007f5be8000000]
|
||||||
* total_blobs=575 nmethods=69 adapters=423
|
* total_blobs=575 nmethods=69 adapters=423
|
||||||
* compilation: enabled
|
* compilation: enabled
|
||||||
|
*
|
||||||
|
* Expected output with code cache segmentation (number of segments may change):
|
||||||
|
*
|
||||||
|
* CodeHeap 'non-methods': size=5696Kb used=2236Kb max_used=2238Kb free=3459Kb
|
||||||
|
* bounds [0x00007fa0f0ffe000, 0x00007fa0f126e000, 0x00007fa0f158e000]
|
||||||
|
* CodeHeap 'profiled nmethods': size=120036Kb used=8Kb max_used=8Kb free=120027Kb
|
||||||
|
* bounds [0x00007fa0f158e000, 0x00007fa0f17fe000, 0x00007fa0f8ac7000]
|
||||||
|
* CodeHeap 'non-profiled nmethods': size=120036Kb used=2Kb max_used=2Kb free=120034Kb
|
||||||
|
* bounds [0x00007fa0f8ac7000, 0x00007fa0f8d37000, 0x00007fa100000000]
|
||||||
|
* total_blobs=486 nmethods=8 adapters=399
|
||||||
|
* compilation: enabled
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Pattern line1 = Pattern.compile("CodeCache: size=(\\p{Digit}*)Kb used=(\\p{Digit}*)Kb max_used=(\\p{Digit}*)Kb free=(\\p{Digit}*)Kb");
|
static Pattern line1 = Pattern.compile("(CodeCache|CodeHeap.*): size=(\\p{Digit}*)Kb used=(\\p{Digit}*)Kb max_used=(\\p{Digit}*)Kb free=(\\p{Digit}*)Kb");
|
||||||
static Pattern line2 = Pattern.compile(" bounds \\[0x(\\p{XDigit}*), 0x(\\p{XDigit}*), 0x(\\p{XDigit}*)\\]");
|
static Pattern line2 = Pattern.compile(" bounds \\[0x(\\p{XDigit}*), 0x(\\p{XDigit}*), 0x(\\p{XDigit}*)\\]");
|
||||||
static Pattern line3 = Pattern.compile(" total_blobs=(\\p{Digit}*) nmethods=(\\p{Digit}*) adapters=(\\p{Digit}*)");
|
static Pattern line3 = Pattern.compile(" total_blobs=(\\p{Digit}*) nmethods=(\\p{Digit}*) adapters=(\\p{Digit}*)");
|
||||||
static Pattern line4 = Pattern.compile(" compilation: (\\w*)");
|
static Pattern line4 = Pattern.compile(" compilation: (.*)");
|
||||||
|
|
||||||
|
private static boolean getFlagBool(String flag, String where) {
|
||||||
|
Matcher m = Pattern.compile(flag + "\\s+:?= (true|false)").matcher(where);
|
||||||
|
if (!m.find()) {
|
||||||
|
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
|
||||||
|
}
|
||||||
|
return m.group(1).equals("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getFlagInt(String flag, String where) {
|
||||||
|
Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where);
|
||||||
|
if (!m.find()) {
|
||||||
|
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
|
||||||
|
}
|
||||||
|
String match = m.group();
|
||||||
|
return Integer.parseInt(match.substring(match.lastIndexOf(" ") + 1, match.length()));
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String arg[]) throws Exception {
|
public static void main(String arg[]) throws Exception {
|
||||||
|
// Get number of code cache segments
|
||||||
|
int segmentsCount = 0;
|
||||||
|
String flags = DcmdUtil.executeDcmd("VM.flags", "-all");
|
||||||
|
if (!getFlagBool("SegmentedCodeCache", flags) || !getFlagBool("UseCompiler", flags)) {
|
||||||
|
// No segmentation
|
||||||
|
segmentsCount = 1;
|
||||||
|
} else if (getFlagBool("TieredCompilation", flags) && getFlagInt("TieredStopAtLevel", flags) > 1) {
|
||||||
|
// Tiered compilation: use all segments
|
||||||
|
segmentsCount = 3;
|
||||||
|
} else {
|
||||||
|
// No TieredCompilation: only non-method and non-profiled segment
|
||||||
|
segmentsCount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// Get output from dcmd (diagnostic command)
|
// Get output from dcmd (diagnostic command)
|
||||||
String result = DcmdUtil.executeDcmd("Compiler.codecache");
|
String result = DcmdUtil.executeDcmd("Compiler.codecache");
|
||||||
BufferedReader r = new BufferedReader(new StringReader(result));
|
BufferedReader r = new BufferedReader(new StringReader(result));
|
||||||
|
|
||||||
// Validate first line
|
// Validate code cache segments
|
||||||
String line;
|
String line;
|
||||||
|
Matcher m;
|
||||||
|
for (int s = 0; s < segmentsCount; ++s) {
|
||||||
|
// Validate first line
|
||||||
line = r.readLine();
|
line = r.readLine();
|
||||||
Matcher m = line1.matcher(line);
|
m = line1.matcher(line);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
for(int i = 1; i <= 4; i++) {
|
for (int i = 2; i <= 5; i++) {
|
||||||
int val = Integer.parseInt(m.group(i));
|
int val = Integer.parseInt(m.group(i));
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
throw new Exception("Failed parsing dcmd codecache output");
|
throw new Exception("Failed parsing dcmd codecache output");
|
||||||
@ -94,6 +139,7 @@ public class CodeCacheTest {
|
|||||||
} else {
|
} else {
|
||||||
throw new Exception("Regexp 2 failed line: " + line);
|
throw new Exception("Regexp 2 failed line: " + line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Validate third line
|
// Validate third line
|
||||||
line = r.readLine();
|
line = r.readLine();
|
||||||
@ -104,7 +150,7 @@ public class CodeCacheTest {
|
|||||||
throw new Exception("Failed parsing dcmd codecache output");
|
throw new Exception("Failed parsing dcmd codecache output");
|
||||||
}
|
}
|
||||||
int nmethods = Integer.parseInt(m.group(2));
|
int nmethods = Integer.parseInt(m.group(2));
|
||||||
if (nmethods <= 0) {
|
if (nmethods < 0) {
|
||||||
throw new Exception("Failed parsing dcmd codecache output");
|
throw new Exception("Failed parsing dcmd codecache output");
|
||||||
}
|
}
|
||||||
int adapters = Integer.parseInt(m.group(3));
|
int adapters = Integer.parseInt(m.group(3));
|
||||||
@ -121,11 +167,7 @@ public class CodeCacheTest {
|
|||||||
// Validate fourth line
|
// Validate fourth line
|
||||||
line = r.readLine();
|
line = r.readLine();
|
||||||
m = line4.matcher(line);
|
m = line4.matcher(line);
|
||||||
if (m.matches()) {
|
if (!m.matches()) {
|
||||||
if (!m.group(1).equals("enabled")) {
|
|
||||||
throw new Exception("Invalid message: '" + m.group(1) + "'");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Exception("Regexp 4 failed");
|
throw new Exception("Regexp 4 failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user