Despite our efforts, sometimes the async cancellation gets deferred.
Notice this by calling pthread_testcancel(), and then try to work out if
async cancellation was ever successful by checking if all threads ran
for the full expected time, or if some were stopped early.
Also, increase the time we allow for the async cancellation to get
delivered to 30 seconds.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
These tests async thread cancellation of a thread that doesn't have any
cancellation points.
Unfortunately, since 2b165a45 the async cancellation silently fails when
the thread is inside the kernel function Sleep(), so it just exits
normally after 10 seconds. (See the commentary in pthread::cancel() in
thread.cc, where it checks if the target thread is inside the kernel,
and silently converts the cancellation into a deferred one)
Work around this by busy-waiting rather than Sleep()ing for 10 seconds.
This is still somewhat fragile: the async cancel could still fail, if it
happens to occur while we're inside the kernel function that time()
calls.
v2:
Do nothing more efficiently
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Since commit 4b51e4c1, we return the actual thread priority, not what we
originally stored in the thread attributes.
Windows only supports 7 thread priority levels, which we map onto the 32
required by POSIX. So, only a subset of values will be returned exactly
by by pthread_getschedparam() after pthread_setschedparam().
Adjust tests priority1, priority2 and inherit1 so they only check for
round-tripping priority values which can be exactly represented.
For CI, this needs to handle process priority class "below normal
priority" as well.
Also check that the range of priority values is at least 32, as required
by POSIX.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Default mutex type is PTHREAD_MUTEX_NORMAL.
Attempting to unlock an unowned mutex of that type is specified as
undefined behaviour, not returning EPERM.
mutex7e verfies that attempting to unlock an unowned mutex of type
PTHREAD_MUTEX_ERRORCHECK returns EPERM.
* readme: Document running portions of the test suite (Thanks Egor!).
* winsup.api/pthread/mainthreadexits.c: New file, derived from
Thomas Pfaff's test cases.
* winsup.api/pthread/threadidafterfork.c: Ditto.