On Tue, 11 Feb 2025 09:03:24 GMT, SendaoYan <s...@openjdk.org> wrote:

>> H all,
>> 
>> This PR add `/native` keyword in the test header for virtual thread tests. 
>> The `/native` keyword will make run the related tests by jtreg standalone 
>> more friendly.
>> 
>> I runed all the tests without -nativepath argument and find the fail tests. 
>> This will find all the virtual thread tests which missing '/native' flag.
>> 
>> 1. java/lang/management/ThreadMXBean/VirtualThreads.java#default
>> 
>> VirtualThreads.java:223 call "invoker()" in 
>> test/lib/jdk/test/lib/thread/VThreadPinner.java file, which will call the 
>> native function "call".
>> java/lang/management/ThreadMXBean/VirtualThreads.java#no-vmcontinuations run 
>> this test with VM option "-XX:-VMContinuations" and 
>> `assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for 
>> custom schedulers");` will make junit skip the 
>> 'testGetThreadInfoCarrierThread' unit test, so 
>> 'VirtualThreads.java#no-vmcontinuations' do not need '/native' keywork.
>> 
>> 2. java/lang/Thread/virtual/stress/PinALot.java
>> 
>> PinALot.java:58 call "invoker()" in 
>> test/lib/jdk/test/lib/thread/VThreadPinner.java file, which will call the 
>> native function "call".
>> 
>> 3. java/lang/Thread/virtual/SynchronizedNative.java
>> 
>> Call System.loadLibrary("SynchronizedNative") at line 85.
>> 
>> 4. Tests java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java, 
>> java/lang/Thread/virtual/ThreadAPI.java, 
>> java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java, 
>> java/lang/Thread/virtual/MonitorWaitNotify.java, 
>> java/lang/Thread/virtual/MonitorPinnedEvents.java, 
>> java/lang/Thread/virtual/MonitorEnterExit.java and other tests are similar 
>> to java/lang/Thread/virtual/stress/PinALot.java
>> 
>> 
>> - Why we need the '/native' keywork?
>> 
>> I usually run the tests through jtreg directively, rather than run the tests 
>> through make test. If I run the test which load the native shared library 
>> files and the test missing '/native' keyword but I forgot to pass the 
>> '-nativepath' argument to jtreg, or pass the incorrect '-nativepath' 
>> argument to jtreg, sometimes it will report timeouted after a long time, 
>> such as java/lang/Thread/virtual/JfrEvents.java. If we add the missing 
>> '/native' keywork, jtreg will report 'Error. Use -nativepath to specify the 
>> location of native code' right away. So add the missing '/native' keyword 
>> will make run the tests more friendly.
>> 
>> Change has been verified locally, test-fix, no risk.
>
> SendaoYan has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Remove the additional check for virtual thread of 
> test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java

912c1ab3 looks okay.

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

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23550#pullrequestreview-2608124096

Reply via email to