summaryrefslogtreecommitdiff
path: root/tests/mutex4.c
diff options
context:
space:
mode:
authorrpj <rpj>2011-05-06 02:11:50 +0000
committerrpj <rpj>2011-05-06 02:11:50 +0000
commit2fe8aba6a8a4ce09f353f34881c77f93a9c01ca3 (patch)
treefd7f179b1abaa525ec55e34bef23b12f8fd89021 /tests/mutex4.c
parent941d7cf87c60b55342b51e0b0fcd748589b76167 (diff)
Robust mutexes merged from devel branchpost_merge_with_ROBUST_MUTEXES
Diffstat (limited to 'tests/mutex4.c')
-rw-r--r--tests/mutex4.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/tests/mutex4.c b/tests/mutex4.c
index b728722..6d36e0a 100644
--- a/tests/mutex4.c
+++ b/tests/mutex4.c
@@ -65,35 +65,31 @@ main()
assert(pthread_mutexattr_init(&ma) == 0);
+ BEGIN_MUTEX_STALLED_ROBUST(ma)
+
wasHere = 0;
assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_DEFAULT) == 0);
assert(pthread_mutex_init(&mutex1, &ma) == 0);
assert(pthread_mutex_lock(&mutex1) == 0);
- /*
- * NORMAL (fast) mutexes don't check ownership.
- */
- assert(pthread_create(&t, NULL, unlocker, (void *)(size_t)0) == 0);
+ assert(pthread_create(&t, NULL, unlocker, (void *)(size_t)(IS_ROBUST?EPERM:0)) == 0);
assert(pthread_join(t, NULL) == 0);
- assert(pthread_mutex_unlock(&mutex1) == EPERM);
+ assert(pthread_mutex_unlock(&mutex1) == 0);
assert(wasHere == 2);
wasHere = 0;
assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_NORMAL) == 0);
assert(pthread_mutex_init(&mutex1, &ma) == 0);
assert(pthread_mutex_lock(&mutex1) == 0);
- /*
- * NORMAL (fast) mutexes don't check ownership.
- */
- assert(pthread_create(&t, NULL, unlocker, (void *) 0) == 0);
+ assert(pthread_create(&t, NULL, unlocker, (void *)(size_t)(IS_ROBUST?EPERM:0)) == 0);
assert(pthread_join(t, NULL) == 0);
- assert(pthread_mutex_unlock(&mutex1) == EPERM);
+ assert(pthread_mutex_unlock(&mutex1) == 0);
assert(wasHere == 2);
wasHere = 0;
assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0);
assert(pthread_mutex_init(&mutex1, &ma) == 0);
assert(pthread_mutex_lock(&mutex1) == 0);
- assert(pthread_create(&t, NULL, unlocker, (void *) EPERM) == 0);
+ assert(pthread_create(&t, NULL, unlocker, (void *)(size_t) EPERM) == 0);
assert(pthread_join(t, NULL) == 0);
assert(pthread_mutex_unlock(&mutex1) == 0);
assert(wasHere == 2);
@@ -102,10 +98,12 @@ main()
assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE) == 0);
assert(pthread_mutex_init(&mutex1, &ma) == 0);
assert(pthread_mutex_lock(&mutex1) == 0);
- assert(pthread_create(&t, NULL, unlocker, (void *) EPERM) == 0);
+ assert(pthread_create(&t, NULL, unlocker, (void *)(size_t) EPERM) == 0);
assert(pthread_join(t, NULL) == 0);
assert(pthread_mutex_unlock(&mutex1) == 0);
assert(wasHere == 2);
+ END_MUTEX_STALLED_ROBUST(ma)
+
return 0;
}