On Fri, 23 Feb 2024 21:55:15 GMT, Chris Plummer <[email protected]> wrote:
> PerfMapTest.java issues the Compiler.perfmap jcmd with a filename argument to
> write the perfmap to. It does this in 3 different modes. 2 of the modes
> result in a perfmap file being left in the tmp directory that is not removed
> after the test executes (and should be removed). The 3rd mode creates the
> perfmap file in the directory specified by the test.dir property, and is ok
> to leave the file there. I've added code to delete the /tmp files that are
> created.
>
> I did a bit of extra testing by hand. I created `/tmp/perf-<pid>.map` as
> root. As expected the Files.deleteIfExists() call threw an exception due to
> the lack of permissions to delete the file. However, I then realized the file
> had a size of 0, which means the test was not even doing a proper job of
> testing that the perfrmap jcmd was working. In other words, the test should
> have failed long before getting to the Files.deleteIfExists(), so I added a
> size check to make sure it fails when the file is not written to.
Ok, so I'm not going insane and really did witness what I described, but I
don't understand why. I create an empty file with root ownership:
$ ls -lat /tmp/perf-*
-rw-r--r-- 1 root root 0 Feb 28 19:35 /tmp/perf-<pid>.map
And I get:
test PerfMapTest.specifiedDefaultMapFile(): failure
java.lang.AssertionError: File must not be empty. Possible file permission
issue: /tmp/perf-<pid>.map expected [true] but found [false]
So my empty file check is being triggered. Also in the log I see:
test PerfMapTest.defaultMapFile(): success
Running DCMD 'Compiler.perfmap /tmp/perf-<pid>.map' through 'JMXExecutor'
[3.000s][warning][codecache] Failed to create /tmp/perf-<pid>.map for perf map
---------------- stdout ----------------
---------------- stderr ----------------
----------------------------------------
But this output is not being detected by:
OutputAnalyzer output = executor.execute(cmd);
output.stderrShouldBeEmpty();
output.stdoutShouldBeEmpty();
It looks like stdout and stderr are empty. To add to the confusion, at the end
of the test I see:
STDERR:
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file /tmp/perf-<pid>.map
due to Permission denied
This must be a testng issue. I don't deal with testng often, so I'm not sure
how it might be handling output differently. But clearly there is output on
stdout and/or stderr, and it is not detected.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17992#issuecomment-1969782466