Cygwin: testsuite: Update mutex tests for changed default mutex type

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.
This commit is contained in:
Jon Turney 2022-08-31 20:32:47 +01:00
parent 52983af631
commit 736618054c
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
4 changed files with 3 additions and 6 deletions

View File

@ -23,7 +23,7 @@ main()
{
assert(pthread_mutexattr_init(&mxAttr) == 0);
assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0);
assert(mxType == PTHREAD_MUTEX_ERRORCHECK);
assert(mxType == PTHREAD_MUTEX_NORMAL);
}
return 0;

View File

@ -2,7 +2,7 @@
* mutex7.c
*
* Test the default (type not set) mutex type.
* Should be the same as PTHREAD_MUTEX_ERRORCHECK.
* Should be the same as PTHREAD_MUTEX_NORMAL.
* Thread locks then trylocks mutex (attempted recursive lock).
* The thread should lock first time and EBUSY second time.
*
@ -25,7 +25,6 @@ void * locker(void * arg)
assert(pthread_mutex_trylock(&mutex) == EBUSY);
lockCount++;
assert(pthread_mutex_unlock(&mutex) == 0);
assert(pthread_mutex_unlock(&mutex) == EPERM);
return 0;
}

View File

@ -2,7 +2,7 @@
* mutex7d.c
*
* Test the default (type not set) mutex type.
* Should be the same as PTHREAD_MUTEX_ERRORCHECK.
* Should be the same as PTHREAD_MUTEX_NORMAL.
* Thread locks then trylocks mutex (attempted recursive lock).
* The thread should lock first time and EBUSY second time.
*
@ -25,7 +25,6 @@ void * locker(void * arg)
assert(pthread_mutex_trylock(&mutex) == EBUSY);
lockCount++;
assert(pthread_mutex_unlock(&mutex) == 0);
assert(pthread_mutex_unlock(&mutex) == EPERM);
return 0;
}

View File

@ -29,7 +29,6 @@ void * locker(void * arg)
assert(pthread_mutex_trylock(&mutex) == EBUSY);
lockCount++;
assert(pthread_mutex_unlock(&mutex) == 0);
assert(pthread_mutex_unlock(&mutex) == EPERM);
return (void *) 555;
}