From ddcd6dece9ef9c8700bc3f8f5dc7a5405fe55a70 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Thu, 7 Mar 2024 00:01:50 +0000 Subject: [PATCH] 8325532: serviceability/dcmd/compiler/PerfMapTest.java leaves created files in the /tmp dir. Reviewed-by: amenkov, kevinw, lmesnik, sspitsyn --- .../serviceability/dcmd/compiler/PerfMapTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/dcmd/compiler/PerfMapTest.java b/test/hotspot/jtreg/serviceability/dcmd/compiler/PerfMapTest.java index 95ae37c527f..6bbe62044d0 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/compiler/PerfMapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/compiler/PerfMapTest.java @@ -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 into @@ -104,5 +111,6 @@ public class PerfMapTest { String test_dir = System.getProperty("test.dir", "."); Path path = Paths.get("/tmp/perf-.map"); run(new JMXExecutor(), "Compiler.perfmap " + path.toString(), path); + Files.deleteIfExists(path); } }