author | jbachorik |
Fri, 17 Oct 2014 10:53:30 +0200 | |
changeset 27189 | b90845965ee9 |
parent 24964 | 296ec671ea4a |
child 30376 | 2ccf2cf7ea48 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
24 |
import java.io.File; |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
25 |
import java.util.Arrays; |
2 | 26 |
|
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
27 |
import jdk.testlibrary.Asserts; |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
28 |
import jdk.testlibrary.JDKToolLauncher; |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
29 |
import jdk.testlibrary.OutputAnalyzer; |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
30 |
import jdk.testlibrary.ProcessTools; |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
31 |
|
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
32 |
/* @test |
2 | 33 |
* @bug 5102009 |
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
34 |
* @summary Sanity test of jhat functionality |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
35 |
* @library /lib/testlibrary |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
36 |
* @build jdk.testlibarary.* |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
37 |
* @compile -g HelloWorld.java |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
38 |
* @run main HatHeapDump1Test |
2 | 39 |
*/ |
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
40 |
public class HatHeapDump1Test { |
2 | 41 |
|
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
42 |
private static final String TEST_CLASSES = System.getProperty("test.classes", "."); |
2 | 43 |
|
44 |
public static void main(String args[]) throws Exception { |
|
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
45 |
String className = "HelloWorld"; |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
46 |
File dumpFile = new File(className + ".hdump"); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
47 |
|
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
48 |
// Generate a heap dump |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
49 |
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder("-cp", |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
50 |
TEST_CLASSES, |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
51 |
"-Xcheck:jni", |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
52 |
"-Xverify:all", |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
53 |
"-agentlib:hprof=heap=dump,format=b,file=" + dumpFile.getAbsolutePath(), |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
54 |
className); |
27189
b90845965ee9
8056143: interrupted java/lang/management/MemoryMXBean/LowMemoryTest.java leaves running process
jbachorik
parents:
24964
diff
changeset
|
55 |
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); |
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
56 |
System.out.println(output.getOutput()); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
57 |
output.shouldHaveExitValue(0); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
58 |
output.shouldContain("Dumping Java heap ... done"); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
59 |
Asserts.assertTrue(dumpFile.exists() && dumpFile.isFile(), "Invalid dump file " + dumpFile.getAbsolutePath()); |
2 | 60 |
|
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
61 |
// Run jhat to analyze the heap dump |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
62 |
output = jhat("-debug", "2", dumpFile.getAbsolutePath()); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
63 |
output.shouldHaveExitValue(0); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
64 |
output.shouldContain("Snapshot resolved"); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
65 |
output.shouldContain("-debug 2 was used"); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
66 |
output.shouldNotContain("ERROR"); |
2 | 67 |
|
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
68 |
dumpFile.delete(); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
69 |
} |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
70 |
|
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
71 |
private static OutputAnalyzer jhat(String... toolArgs) throws Exception { |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
72 |
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhat"); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
73 |
if (toolArgs != null) { |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
74 |
for (String toolArg : toolArgs) { |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
75 |
launcher.addToolArg(toolArg); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
76 |
} |
2 | 77 |
} |
78 |
||
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
79 |
ProcessBuilder processBuilder = new ProcessBuilder(); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
80 |
processBuilder.command(launcher.getCommand()); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
81 |
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); |
27189
b90845965ee9
8056143: interrupted java/lang/management/MemoryMXBean/LowMemoryTest.java leaves running process
jbachorik
parents:
24964
diff
changeset
|
82 |
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); |
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
83 |
System.out.println(output.getOutput()); |
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
84 |
|
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
85 |
return output; |
2 | 86 |
} |
24964
296ec671ea4a
6545295: TEST BUG: The test HatHeapDump1Test uses wrong path in exec call.
ykantser
parents:
5506
diff
changeset
|
87 |
|
2 | 88 |
} |