32 import jdk.test.lib.hprof.HprofParser; 33 import jdk.test.lib.hprof.model.Snapshot; 34 35 import jdk.test.lib.JDKToolFinder; 36 import jdk.test.lib.OutputAnalyzer; 37 import jdk.test.lib.dcmd.CommandExecutor; 38 import jdk.test.lib.dcmd.PidJcmdExecutor; 39 40 /* 41 * @test 42 * @summary Test of diagnostic command GC.heap_dump 43 * @library /testlibrary 44 * @library /test/lib/share/classes 45 * @modules java.base/sun.misc 46 * java.compiler 47 * java.management 48 * jdk.jvmstat/sun.jvmstat.monitor 49 * @build jdk.test.lib.* 50 * @build jdk.test.lib.dcmd.* 51 * @build jdk.test.lib.hprof.* 52 * @build jdk.test.lib.hprof.module.* 53 * @build jdk.test.lib.hprof.parser.* 54 * @build jdk.test.lib.hprof.utils.* 55 * @run testng HeapDumpTest 56 */ 57 public class HeapDumpTest { 58 protected String heapDumpArgs = ""; 59 60 public void run(CommandExecutor executor) throws IOException { 61 File dump = new File("jcmd.gc.heap_dump." + System.currentTimeMillis() + ".hprof"); 62 if (dump.exists()) { 63 dump.delete(); 64 } 65 66 String cmd = "GC.heap_dump " + heapDumpArgs + " " + dump.getAbsolutePath(); 67 executor.execute(cmd); 68 69 verifyHeapDump(dump); 70 dump.delete(); 71 } 72 73 private void verifyHeapDump(File dump) { 74 Assert.assertTrue(dump.exists() && dump.isFile(), "Could not create dump file " + dump.getAbsolutePath()); | 32 import jdk.test.lib.hprof.HprofParser; 33 import jdk.test.lib.hprof.model.Snapshot; 34 35 import jdk.test.lib.JDKToolFinder; 36 import jdk.test.lib.OutputAnalyzer; 37 import jdk.test.lib.dcmd.CommandExecutor; 38 import jdk.test.lib.dcmd.PidJcmdExecutor; 39 40 /* 41 * @test 42 * @summary Test of diagnostic command GC.heap_dump 43 * @library /testlibrary 44 * @library /test/lib/share/classes 45 * @modules java.base/sun.misc 46 * java.compiler 47 * java.management 48 * jdk.jvmstat/sun.jvmstat.monitor 49 * @build jdk.test.lib.* 50 * @build jdk.test.lib.dcmd.* 51 * @build jdk.test.lib.hprof.* 52 * @build jdk.test.lib.hprof.model.* 53 * @build jdk.test.lib.hprof.parser.* 54 * @build jdk.test.lib.hprof.util.* 55 * @run testng HeapDumpTest 56 */ 57 public class HeapDumpTest { 58 protected String heapDumpArgs = ""; 59 60 public void run(CommandExecutor executor) throws IOException { 61 File dump = new File("jcmd.gc.heap_dump." + System.currentTimeMillis() + ".hprof"); 62 if (dump.exists()) { 63 dump.delete(); 64 } 65 66 String cmd = "GC.heap_dump " + heapDumpArgs + " " + dump.getAbsolutePath(); 67 executor.execute(cmd); 68 69 verifyHeapDump(dump); 70 dump.delete(); 71 } 72 73 private void verifyHeapDump(File dump) { 74 Assert.assertTrue(dump.exists() && dump.isFile(), "Could not create dump file " + dump.getAbsolutePath()); |