8374181: failure_handler: The cores.html file is formatted incorrectly and so hides the core dump information

Reviewed-by: erikj
This commit is contained in:
Jaikiran Pai 2026-01-13 01:29:20 +00:00
parent 15b7a4252b
commit e89c1290ca

View File

@ -29,13 +29,14 @@ import com.sun.javatest.TestResult;
import com.sun.javatest.regtest.config.RegressionParameters; import com.sun.javatest.regtest.config.RegressionParameters;
import jdk.test.failurehandler.*; import jdk.test.failurehandler.*;
import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;
/** /**
* The jtreg test execution observer, which gathers info about * The jtreg test execution observer, which gathers info about
@ -85,11 +86,15 @@ public class GatherDiagnosticInfoObserver implements Harness.Observer {
testJdk, compileJdk); testJdk, compileJdk);
gatherEnvInfo(workDir, name, log, gatherEnvInfo(workDir, name, log,
gathererFactory.getEnvironmentInfoGatherer()); gathererFactory.getEnvironmentInfoGatherer());
Files.walk(workDir) // generate a cores.html file after parsing the core dump files (if any)
.filter(Files::isRegularFile) List<Path> coreFiles;
.filter(f -> (f.getFileName().toString().contains("core") || f.getFileName().toString().contains("mdmp"))) try (Stream<Path> paths = Files.walk(workDir)) {
.forEach(core -> gatherCoreInfo(workDir, name, coreFiles = paths.filter(Files::isRegularFile)
core, log, gathererFactory.getCoreInfoGatherer())); .filter(f -> (f.getFileName().toString().contains("core")
|| f.getFileName().toString().contains("mdmp")))
.toList();
}
gatherCoreInfo(workDir, name, coreFiles, log, gathererFactory.getCoreInfoGatherer());
} catch (Throwable e) { } catch (Throwable e) {
log.printf("ERROR: exception in observer %s:", name); log.printf("ERROR: exception in observer %s:", name);
e.printStackTrace(log); e.printStackTrace(log);
@ -103,16 +108,22 @@ public class GatherDiagnosticInfoObserver implements Harness.Observer {
} }
} }
private void gatherCoreInfo(Path workDir, String name, Path core, PrintWriter log, private void gatherCoreInfo(Path workDir, String name, List<Path> coreFiles,
CoreInfoGatherer gatherer) { PrintWriter log, CoreInfoGatherer gatherer) {
if (coreFiles.isEmpty()) {
return;
}
try (HtmlPage html = new HtmlPage(workDir, CORES_OUTPUT, true)) { try (HtmlPage html = new HtmlPage(workDir, CORES_OUTPUT, true)) {
try (ElapsedTimePrinter timePrinter try (ElapsedTimePrinter timePrinter
= new ElapsedTimePrinter(new Stopwatch(), name, log)) { = new ElapsedTimePrinter(new Stopwatch(), name, log)) {
gatherer.gatherCoreInfo(html.getRootSection(), core); // gather information from the contents of each core file
for (Path coreFile : coreFiles) {
gatherer.gatherCoreInfo(html.getRootSection(), coreFile);
}
} }
} catch (Throwable e) { } catch (Throwable e) {
log.printf("ERROR: exception in observer on getting environment " log.printf("ERROR: exception in %s observer while gathering information from"
+ "information %s:", name); + " core dump file", name);
e.printStackTrace(log); e.printStackTrace(log);
} }
} }