8325532: serviceability/dcmd/compiler/PerfMapTest.java leaves created files in the /tmp dir.

Reviewed-by: amenkov, kevinw, lmesnik, sspitsyn
This commit is contained in:
Chris Plummer 2024-03-07 00:01:50 +00:00
parent 3d37b28642
commit ddcd6dece9

@ -65,7 +65,13 @@ public class PerfMapTest {
output.stderrShouldBeEmpty();
output.stdoutShouldBeEmpty();
Assert.assertTrue(Files.exists(path), "File must exist: " + path);
try {
Assert.assertTrue(Files.exists(path), "File must exist: " + path);
Assert.assertTrue(Files.size(path) > 0,
"File must not be empty. Possible file permission issue: " + path);
} catch (IOException e) {
throw new RuntimeException(e);
}
// Sanity check the file contents
try {
@ -79,10 +85,11 @@ public class PerfMapTest {
}
@Test
public void defaultMapFile() {
public void defaultMapFile() throws IOException {
final long pid = ProcessHandle.current().pid();
final Path path = Paths.get(String.format("/tmp/perf-%d.map", pid));
run(new JMXExecutor(), "Compiler.perfmap", path);
Files.deleteIfExists(path);
}
@Test
@ -96,7 +103,7 @@ public class PerfMapTest {
}
@Test
public void specifiedDefaultMapFile() {
public void specifiedDefaultMapFile() throws IOException {
// This is a special case of specifiedMapFile() where the filename specified
// is the same as the default filename as given in the help output. The dcmd
// should treat this literally as the filename and not expand <pid> into
@ -104,5 +111,6 @@ public class PerfMapTest {
String test_dir = System.getProperty("test.dir", ".");
Path path = Paths.get("/tmp/perf-<pid>.map");
run(new JMXExecutor(), "Compiler.perfmap " + path.toString(), path);
Files.deleteIfExists(path);
}
}