On Wed, 23 Oct 2024 19:51:24 GMT, Rajan Halade <rhal...@openjdk.org> wrote:
>> The test sun/security/pkcs11/Provider/RequiredMechCheck.java extends >> sun/security/pkcs11/PKCS11Test.java, which sets up a PKCS11Provider >> configured with NSS config files located in the source tree directory >> (sun/security/pkcs11/nss) for the dependent tests to run properly. This test >> currently fails if that **pkcs11/nss** directory is made read-only because >> these config files are updated during the test execution. Files located in >> the source tree should not be modified when running tests. >> This PR updates the PKCS11Test to copy the NSS config files to the Jtreg >> scratch directory and configures the provider to use those files instead. > > test/jdk/sun/security/pkcs11/PKCS11Test.java line 526: > >> 524: String nss = "nss"; >> 525: Path nssDirSource = Path.of(base).resolve(nss); >> 526: String nssDirDestination = Path.of(".").resolve(nss).toString(); > > Using current directory here may be incorrect. Can this be changed to > `Path.of(System.getProperty("test.classes"), ".")` The "test.classes" directory contains the compiled classes according to [jtreg doc](https://openjdk.org/jtreg/tag-spec.html#testvars). Whereas, the current directory is the [Jtreg scratch](https://openjdk.org/jtreg/faq.html#scratch-directory) directory, which is the right place for the tests temporary files. Also, Jtreg will automatically clean this directory when the test begins. The scratch directory does seem like the best place to store these temporary configuration files. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21665#discussion_r1814568986