mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8234622: [TESTBUG] ArchivedModuleCompareTest.java fails with -vmoptions:-Xlog:cds
Reviewed-by: mseledtsov
This commit is contained in:
parent
2429c8a484
commit
4edbdd1cb3
2 changed files with 24 additions and 4 deletions
|
@ -662,4 +662,24 @@ public class TestCommon extends CDSTestUtils {
|
|||
}
|
||||
return linkedJar;
|
||||
}
|
||||
|
||||
// Remove all UL log messages from a JVM's STDOUT (such as those printed by -Xlog:cds)
|
||||
static Pattern logPattern = Pattern.compile("^\\[[0-9. ]*s\\].*");
|
||||
public static String filterOutLogs(String stdout) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String prefix = "";
|
||||
for (String line : stdout.split("\n")) {
|
||||
if (logPattern.matcher(line).matches()) {
|
||||
continue;
|
||||
}
|
||||
sb.append(prefix);
|
||||
sb.append(line);
|
||||
prefix = "\n";
|
||||
}
|
||||
if (stdout.endsWith("\n")) {
|
||||
// String.split("A\n") returns {"A"}, not {"A", ""}.
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ public class ArchivedModuleCompareTest {
|
|||
|
||||
output = TestCommon.execOff("-cp", appJar, "PrintSystemModulesApp");
|
||||
output.shouldHaveExitValue(0);
|
||||
String bootModules1 = output.getStdout();
|
||||
String bootModules1 = TestCommon.filterOutLogs(output.getStdout());
|
||||
|
||||
output = TestCommon.exec(appJar, "PrintSystemModulesApp");
|
||||
TestCommon.checkExec(output);
|
||||
if (output.getStderr().contains("sharing")) {
|
||||
String bootModules2 = output.getStdout();
|
||||
String bootModules2 = TestCommon.filterOutLogs(output.getStdout());
|
||||
TestCommon.checkOutputStrings(bootModules1, bootModules2, ", ");
|
||||
}
|
||||
|
||||
|
@ -66,14 +66,14 @@ public class ArchivedModuleCompareTest {
|
|||
"--show-module-resolution",
|
||||
"-version");
|
||||
output.shouldHaveExitValue(0);
|
||||
String moduleResolutionOut1 = output.getStdout();
|
||||
String moduleResolutionOut1 = TestCommon.filterOutLogs(output.getStdout());
|
||||
|
||||
output = TestCommon.exec(appJar,
|
||||
"--show-module-resolution",
|
||||
"-version");
|
||||
TestCommon.checkExec(output);
|
||||
if (output.getStderr().contains("sharing")) {
|
||||
String moduleResolutionOut2 = output.getStdout();
|
||||
String moduleResolutionOut2 = TestCommon.filterOutLogs(output.getStdout());
|
||||
TestCommon.checkOutputStrings(
|
||||
moduleResolutionOut1, moduleResolutionOut2, "\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue