< prev index next >

test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpParallelTest.java

Print this page

 38 import jdk.test.lib.process.ProcessTools;
 39 
 40 import jdk.test.lib.hprof.HprofParser;
 41 
 42 /**
 43  * @test
 44  * @bug 8306441 8319053
 45  * @summary Verify the integrity of generated heap dump and capability of parallel dump
 46  * @library /test/lib
 47  * @run main HeapDumpParallelTest
 48  */
 49 
 50 public class HeapDumpParallelTest {
 51 
 52     private static final String heapDumpFileName = "parallelHeapDump.bin";
 53 
 54     private static void checkAndVerify(OutputAnalyzer dcmdOut, LingeredApp app, File heapDumpFile, boolean expectSerial) throws Exception {
 55         dcmdOut.shouldHaveExitValue(0);
 56         dcmdOut.shouldContain("Heap dump file created");
 57         OutputAnalyzer appOut = new OutputAnalyzer(app.getProcessStdout());
 58         appOut.shouldContain("[heapdump]");
 59         String opts = Arrays.asList(Utils.getTestJavaOpts()).toString();
 60         if (opts.contains("-XX:+UseSerialGC") || opts.contains("-XX:+UseEpsilonGC")) {
 61             System.out.println("UseSerialGC detected.");
 62             expectSerial = true;
 63         }
 64         if (!expectSerial && Runtime.getRuntime().availableProcessors() > 1) {
 65             appOut.shouldContain("Dump heap objects in parallel");
 66             appOut.shouldContain("Merge heap files complete");
 67         } else {
 68             appOut.shouldNotContain("Dump heap objects in parallel");
 69         }
 70         HprofParser.parseAndVerify(heapDumpFile);
 71 
 72         List<String> files
 73             = Stream.of(heapDumpFile.getAbsoluteFile().getParentFile().listFiles())
 74                 .filter(file -> !file.isDirectory())
 75                 .map(File::getName)
 76                 .filter(name -> name.startsWith(heapDumpFileName) && !name.equals(heapDumpFileName))
 77                 .collect(Collectors.toList());
 78         if (!files.isEmpty()) {

 38 import jdk.test.lib.process.ProcessTools;
 39 
 40 import jdk.test.lib.hprof.HprofParser;
 41 
 42 /**
 43  * @test
 44  * @bug 8306441 8319053
 45  * @summary Verify the integrity of generated heap dump and capability of parallel dump
 46  * @library /test/lib
 47  * @run main HeapDumpParallelTest
 48  */
 49 
 50 public class HeapDumpParallelTest {
 51 
 52     private static final String heapDumpFileName = "parallelHeapDump.bin";
 53 
 54     private static void checkAndVerify(OutputAnalyzer dcmdOut, LingeredApp app, File heapDumpFile, boolean expectSerial) throws Exception {
 55         dcmdOut.shouldHaveExitValue(0);
 56         dcmdOut.shouldContain("Heap dump file created");
 57         OutputAnalyzer appOut = new OutputAnalyzer(app.getProcessStdout());
 58         appOut.shouldMatch("\\[heapdump *\\]");
 59         String opts = Arrays.asList(Utils.getTestJavaOpts()).toString();
 60         if (opts.contains("-XX:+UseSerialGC") || opts.contains("-XX:+UseEpsilonGC")) {
 61             System.out.println("UseSerialGC detected.");
 62             expectSerial = true;
 63         }
 64         if (!expectSerial && Runtime.getRuntime().availableProcessors() > 1) {
 65             appOut.shouldContain("Dump heap objects in parallel");
 66             appOut.shouldContain("Merge heap files complete");
 67         } else {
 68             appOut.shouldNotContain("Dump heap objects in parallel");
 69         }
 70         HprofParser.parseAndVerify(heapDumpFile);
 71 
 72         List<String> files
 73             = Stream.of(heapDumpFile.getAbsoluteFile().getParentFile().listFiles())
 74                 .filter(file -> !file.isDirectory())
 75                 .map(File::getName)
 76                 .filter(name -> name.startsWith(heapDumpFileName) && !name.equals(heapDumpFileName))
 77                 .collect(Collectors.toList());
 78         if (!files.isEmpty()) {
< prev index next >