Skip to content

Commit a8a8bc7

Browse files
committed
made DumpPathTest a subprocess test
1 parent e9f9eba commit a8a8bc7

File tree

1 file changed

+47
-31
lines changed
  • compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test

1 file changed

+47
-31
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/DumpPathTest.java

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import java.util.ArrayList;
3232
import java.util.List;
3333

34-
import jdk.graal.compiler.core.GraalCompilerOptions;
3534
import org.graalvm.collections.EconomicMap;
3635
import org.junit.Test;
3736

37+
import jdk.graal.compiler.core.GraalCompilerOptions;
3838
import jdk.graal.compiler.debug.DebugOptions;
3939
import jdk.graal.compiler.debug.DebugOptions.PrintGraphTarget;
4040
import jdk.graal.compiler.debug.TTY;
@@ -45,46 +45,61 @@
4545
* Check that setting the dump path results in files ending up in the right directory with matching
4646
* names.
4747
*/
48-
public class DumpPathTest extends GraalCompilerTest {
48+
public class DumpPathTest extends SubprocessTest {
49+
50+
/**
51+
* If this test does not complete in 60 seconds, something is very wrong.
52+
*/
53+
private static final int TIME_LIMIT = 60000;
4954

5055
public static Object snippet() {
5156
return new String("snippet");
5257
}
5358

5459
@Test
55-
public void testDump() throws Exception {
60+
public void test() throws IOException, InterruptedException {
61+
launchSubprocess(this::runInSubprocess, "-Xmx50M");
62+
63+
}
64+
65+
public void runInSubprocess() {
5666
assumeManagementLibraryIsLoadable();
57-
try (TemporaryDirectory temp = new TemporaryDirectory("DumpPathTest")) {
58-
String[] extensions = {".cfg", ".bgv", ".graph-strings"};
59-
EconomicMap<OptionKey<?>, Object> overrides = OptionValues.newOptionMap();
60-
overrides.put(DebugOptions.DumpPath, temp.toString());
61-
overrides.put(DebugOptions.ShowDumpFiles, false);
62-
overrides.put(DebugOptions.PrintBackendCFG, true);
63-
overrides.put(DebugOptions.PrintGraph, PrintGraphTarget.File);
64-
overrides.put(DebugOptions.PrintCanonicalGraphStrings, true);
65-
overrides.put(DebugOptions.Dump, "*");
66-
overrides.put(GraalCompilerOptions.DumpHeapAfter, "<compilation>:Schedule");
67-
overrides.put(DebugOptions.MethodFilter, null);
67+
try (var _ = new TTY.Filter();
68+
TimeLimit _ = TimeLimit.create(TIME_LIMIT, "DumpPathTest")) {
69+
try (TemporaryDirectory temp = new TemporaryDirectory("DumpPathTest")) {
70+
String[] extensions = {".cfg", ".bgv", ".graph-strings"};
71+
EconomicMap<OptionKey<?>, Object> overrides = OptionValues.newOptionMap();
72+
overrides.put(DebugOptions.DumpPath, temp.toString());
73+
overrides.put(DebugOptions.ShowDumpFiles, false);
74+
overrides.put(DebugOptions.PrintBackendCFG, true);
75+
overrides.put(DebugOptions.PrintGraph, PrintGraphTarget.File);
76+
overrides.put(DebugOptions.PrintCanonicalGraphStrings, true);
77+
overrides.put(DebugOptions.Dump, "*");
78+
overrides.put(GraalCompilerOptions.DumpHeapAfter, "<compilation>:Schedule");
79+
overrides.put(DebugOptions.MethodFilter, null);
6880

69-
try (AutoCloseable _ = new TTY.Filter()) {
70-
// Generate dump files.
71-
test(new OptionValues(getInitialOptions(), overrides), "snippet");
72-
}
73-
// Check that IGV files got created, in the right place.
74-
List<Path> paths = checkForFiles(temp.path, extensions);
75-
List<Path> compilationHeapDumps = new ArrayList<>();
76-
List<Path> phaseHeapDumps = new ArrayList<>();
77-
for (Path path : paths) {
78-
String name = path.toString();
79-
if (name.endsWith(".compilation.hprof")) {
80-
compilationHeapDumps.add(path);
81-
} else if (name.endsWith(".hprof")) {
82-
phaseHeapDumps.add(path);
81+
try (var _ = new TTY.Filter()) {
82+
// Generate dump files.
83+
test(new OptionValues(getInitialOptions(), overrides), "snippet");
84+
}
85+
// Check that IGV files got created, in the right place.
86+
List<Path> paths = checkForFiles(temp.path, extensions);
87+
List<Path> compilationHeapDumps = new ArrayList<>();
88+
List<Path> phaseHeapDumps = new ArrayList<>();
89+
for (Path path : paths) {
90+
String name = path.toString();
91+
if (name.endsWith(".compilation.hprof")) {
92+
compilationHeapDumps.add(path);
93+
} else if (name.endsWith(".hprof")) {
94+
phaseHeapDumps.add(path);
95+
}
8396
}
84-
}
8597

86-
assertTrue(!compilationHeapDumps.isEmpty());
87-
assertTrue(!phaseHeapDumps.isEmpty());
98+
assertTrue(!compilationHeapDumps.isEmpty());
99+
assertTrue(!phaseHeapDumps.isEmpty());
100+
}
101+
} catch (IOException e) {
102+
throw new AssertionError(e);
88103
}
89104
}
90105

@@ -99,6 +114,7 @@ private static List<Path> checkForFiles(Path directoryPath, String[] extensions)
99114
for (Path filePath : stream) {
100115
result.add(filePath);
101116
String fileName = filePath.getFileName().toString();
117+
System.out.printf("%s -> %,d bytes%n", filePath, Files.size(filePath));
102118
for (int i = 0; i < extensions.length; i++) {
103119
String extension = extensions[i];
104120
if (fileName.endsWith(extensions[i])) {

0 commit comments

Comments
 (0)