On Fri, 13 Dec 2024 10:10:16 GMT, Taizo Kurashige <d...@openjdk.org> wrote:
>> To resolve java/io/File/GetXSpace.java failure, I fix libGetXSpace.c to use >> Cygwin’s `df` to get the size for comparison if the test target drive is a >> CD-ROM drive. >> >> As described in JDK-8343342, GetDiskSpaceInformationW can't get information >> about the size of the CD-ROM drive. >> GetDiskFreeSpaceExW can also get information about the size of the CD-ROM >> drive. However, because GetDiskFreeSpaceExW is called by the >> File.get-X-Space methods, it seems more reasonable to compare the size got >> by other way than GetDiskFreeSpaceExW as a test. For this reason, I use >> Cygwin's `df`. >> In JDK-8298619, GetDiskSpaceInformationW was adopted instead of `df` because >> the size got by File.get-X-Space methods may not match the size got by `df` >> when per-user quotas are used. I don't think this problem applies to CD-ROM >> drive, so I think we can use Cygwin's `df` for CD-ROM drive. >> >> After fix, I ran a test on Windows Server 2019 where drive C is a normal >> local disk, drive D is an unmounted iso CD-ROM drive, and drive F is an iso >> mounted CD-ROM drive and confirmed that it passes. >> >> I think this fix may also resolves the similar failure reported at >> https://github.com/openjdk/jdk/pull/12397#issuecomment-1705164515. >> >> Thanks > > Taizo Kurashige has updated the pull request incrementally with two > additional commits since the last revision: > > - Fix getCDDriveSpace() > - Fix macro for unix This patch applied to your version 2d3a658c fixes the test for both a physical CD drive (empty or with disc inserted) and a mounted ISO file: --- a/test/jdk/java/io/File/GetXSpace.java +++ b/test/jdk/java/io/File/GetXSpace.java @@ -412,12 +412,11 @@ public static void main(String[] args) throws Exception { private static native boolean isCDDrive(String root); - private static void getCDDriveSpace(String root, long[] sizes) throws IOException { - String cmd = "df -k -P " + root; + private static void getCDDriveSpace(String root, long[] sizes) + throws IOException { + String[] cmd = new String[] {"df", "-k", "-P", root}; + Process p = Runtime.getRuntime().exec(cmd); StringBuilder sb = new StringBuilder(); - ProcessBuilder pb = new ProcessBuilder("bash", "-c", cmd);; - pb.redirectErrorStream(true); - Process p = pb.start(); try (BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()))) { String s; Please note that after today I will be on holiday break until January 6, 2025. ------------- PR Comment: https://git.openjdk.org/jdk/pull/21799#issuecomment-2557880965