31
31
import java .util .ArrayList ;
32
32
import java .util .List ;
33
33
34
- import jdk .graal .compiler .core .GraalCompilerOptions ;
35
34
import org .graalvm .collections .EconomicMap ;
36
35
import org .junit .Test ;
37
36
37
+ import jdk .graal .compiler .core .GraalCompilerOptions ;
38
38
import jdk .graal .compiler .debug .DebugOptions ;
39
39
import jdk .graal .compiler .debug .DebugOptions .PrintGraphTarget ;
40
40
import jdk .graal .compiler .debug .TTY ;
45
45
* Check that setting the dump path results in files ending up in the right directory with matching
46
46
* names.
47
47
*/
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 ;
49
54
50
55
public static Object snippet () {
51
56
return new String ("snippet" );
52
57
}
53
58
54
59
@ 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 () {
56
66
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 );
68
80
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
+ }
83
96
}
84
- }
85
97
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 );
88
103
}
89
104
}
90
105
@@ -99,6 +114,7 @@ private static List<Path> checkForFiles(Path directoryPath, String[] extensions)
99
114
for (Path filePath : stream ) {
100
115
result .add (filePath );
101
116
String fileName = filePath .getFileName ().toString ();
117
+ System .out .printf ("%s -> %,d bytes%n" , filePath , Files .size (filePath ));
102
118
for (int i = 0 ; i < extensions .length ; i ++) {
103
119
String extension = extensions [i ];
104
120
if (fileName .endsWith (extensions [i ])) {
0 commit comments