Skip to content

Commit ddcd6de

Browse files
committedMar 7, 2024
8325532: serviceability/dcmd/compiler/PerfMapTest.java leaves created files in the /tmp dir.
Reviewed-by: amenkov, kevinw, lmesnik, sspitsyn
1 parent 3d37b28 commit ddcd6de

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎test/hotspot/jtreg/serviceability/dcmd/compiler/PerfMapTest.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ public void run(CommandExecutor executor, String cmd, Path path) {
6565
output.stderrShouldBeEmpty();
6666
output.stdoutShouldBeEmpty();
6767

68-
Assert.assertTrue(Files.exists(path), "File must exist: " + path);
68+
try {
69+
Assert.assertTrue(Files.exists(path), "File must exist: " + path);
70+
Assert.assertTrue(Files.size(path) > 0,
71+
"File must not be empty. Possible file permission issue: " + path);
72+
} catch (IOException e) {
73+
throw new RuntimeException(e);
74+
}
6975

7076
// Sanity check the file contents
7177
try {
@@ -79,10 +85,11 @@ public void run(CommandExecutor executor, String cmd, Path path) {
7985
}
8086

8187
@Test
82-
public void defaultMapFile() {
88+
public void defaultMapFile() throws IOException {
8389
final long pid = ProcessHandle.current().pid();
8490
final Path path = Paths.get(String.format("/tmp/perf-%d.map", pid));
8591
run(new JMXExecutor(), "Compiler.perfmap", path);
92+
Files.deleteIfExists(path);
8693
}
8794

8895
@Test
@@ -96,13 +103,14 @@ public void specifiedMapFile() {
96103
}
97104

98105
@Test
99-
public void specifiedDefaultMapFile() {
106+
public void specifiedDefaultMapFile() throws IOException {
100107
// This is a special case of specifiedMapFile() where the filename specified
101108
// is the same as the default filename as given in the help output. The dcmd
102109
// should treat this literally as the filename and not expand <pid> into
103110
// the actual PID of the process.
104111
String test_dir = System.getProperty("test.dir", ".");
105112
Path path = Paths.get("/tmp/perf-<pid>.map");
106113
run(new JMXExecutor(), "Compiler.perfmap " + path.toString(), path);
114+
Files.deleteIfExists(path);
107115
}
108116
}

0 commit comments

Comments
 (0)
Please sign in to comment.