< prev index next >

test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java

Print this page

        

*** 21,34 **** * questions. */ /* * @test TestHeapDumpOnOutOfMemoryError ! * @summary Test verifies that -XX:HeapDumpOnOutOfMemoryError dump heap when OutOfMemory is thrown ! * @modules java.base/jdk.internal.misc * @library /test/lib ! * @run driver/timeout=240 TestHeapDumpOnOutOfMemoryError */ import jdk.test.lib.Asserts; import jdk.test.lib.classloader.GeneratingClassLoader; import jdk.test.lib.hprof.HprofParser; --- 21,33 ---- * questions. */ /* * @test TestHeapDumpOnOutOfMemoryError ! * @summary Test verifies that -XX:HeapDumpOnOutOfMemoryError dump heap when OutOfMemory is thrown in heap * @library /test/lib ! * @run driver TestHeapDumpOnOutOfMemoryError run heap */ import jdk.test.lib.Asserts; import jdk.test.lib.classloader.GeneratingClassLoader; import jdk.test.lib.hprof.HprofParser;
*** 59,71 **** throw new Error("OOME not triggered"); } catch (OutOfMemoryError err) { return; } } ! test(HEAP_OOME); ! test(METASPACE_OOME); ! testHeapDumpPath(); } static void test(String type) throws Exception { String heapdumpFilename = type + ".hprof"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError", --- 58,68 ---- throw new Error("OOME not triggered"); } catch (OutOfMemoryError err) { return; } } ! test(args[1]); } static void test(String type) throws Exception { String heapdumpFilename = type + ".hprof"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError",
*** 81,113 **** HprofParser.parse(new File(heapdumpFilename)); System.out.println("PASSED"); } - static void testHeapDumpPath() throws Exception { - String heapdumpPath = "dumps"; - File dumpDirectory = new File(heapdumpPath); - dumpDirectory.mkdir(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError", - "-XX:HeapDumpPath=" + heapdumpPath, "-Xmx256m", "-XX:MaxMetaspaceSize=64m", - TestHeapDumpOnOutOfMemoryError.class.getName(), HEAP_OOME); - - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.stdoutShouldNotBeEmpty(); - output.shouldContain("Dumping heap"); - - Asserts.assertFalse(dumpDirectory.listFiles().length == 0, - "There is no dump files found in " + dumpDirectory ); - - Asserts.assertTrue(dumpDirectory.listFiles().length == 1, - "There are unexpected files in " + dumpDirectory - + ": " + String.join(",", dumpDirectory.list()) +"."); - - File dump = dumpDirectory.listFiles()[0]; - Asserts.assertTrue(dump.exists() && dump.isFile(), - "Could not find dump file " + dump.getAbsolutePath()); - - HprofParser.parse(dump); - System.out.println("PASSED"); - } - } --- 78,83 ----
< prev index next >