RFR: 8353190: Use "/native" Run Option for TestAvailableProcessors Execution

Oleksii Sylichenko duke at openjdk.org
Tue Apr 22 19:36:44 UTC 2025


On Mon, 31 Mar 2025 03:17:20 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Currently, the test executes the program using `test.nativepath`, but it relies on path resolution. I propose following standard conventions in this case and running the test with the `/native` option instead.
>> 
>> With this change:
>> - Path resolution is no longer required.
>> - If `nativepath` is not specified at runtime, a standard error message will be printed to the console.
>> 
>> This improves consistency and simplifies the test execution process.
>> 
>> I kindly ask the original author of the test @swesonga and those who reviewed the original pull request  #17576 for this test to take a look at this PR: @jdksjolen and @dholmes
>
> test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java line 34:
> 
>> 32:  * @library /test/lib
>> 33:  * @compile GetAvailableProcessors.java
>> 34:  * @run testng/othervm/native --enable-native-access=ALL-UNNAMED TestAvailableProcessors
> 
> It is a good catch that this test needs to declare it needs the native image to have been built - though `native` is not listed as a valid sub-option for `testng`. 
> 
> Why do you need the `--enable-native-access` here?

Thank you for your remark. Indeed, you are right — the `--enable-native-access` option is not necessary here. I will remove it.

Although native is not listed as a valid sub-option for testng in the documentation, it is actually supported.

The class for the testng option, `com.sun.javatest.regtest.exec.TestNGAction`, inherits from `com.sun.javatest.regtest.exec.MainAction` and calls its init method, which enables support for the native option.

- TestNG action class:
    https://github.com/openjdk/jtreg/blob/f4f2843c876dc974750eabc8875de08e56bd3852/src/share/classes/com/sun/javatest/regtest/exec/TestNGAction.java#L50

- Call to parent init method:
    https://github.com/openjdk/jtreg/blob/f4f2843c876dc974750eabc8875de08e56bd3852/src/share/classes/com/sun/javatest/regtest/exec/TestNGAction.java#L86

- Parent `MainAction` class checking for the native option:
    https://github.com/openjdk/jtreg/blob/f4f2843c876dc974750eabc8875de08e56bd3852/src/share/classes/com/sun/javatest/regtest/exec/MainAction.java#L145

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23803#discussion_r2054736507


More information about the hotspot-runtime-dev mailing list