diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-02-15 20:54:25 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-02-15 20:54:25 +0000 |
commit | b2f05465748e7e1c0105776a1e0ceda7f7a599b0 (patch) | |
tree | b547b7407e236dbe2f799bc27cee32d3306bc0b5 /nptl/tst-mutex3.c | |
parent | c3bb9ee1bc384edeec9ca991f58c162b167a558f (diff) | |
download | glibc-b2f05465748e7e1c0105776a1e0ceda7f7a599b0.tar.gz glibc-b2f05465748e7e1c0105776a1e0ceda7f7a599b0.tar.xz glibc-b2f05465748e7e1c0105776a1e0ceda7f7a599b0.zip |
Update.
* tst-mutex2.c: Tests of trylock and unlock with ERROR mutexes.
Diffstat (limited to 'nptl/tst-mutex3.c')
-rw-r--r-- | nptl/tst-mutex3.c | 95 |
1 files changed, 92 insertions, 3 deletions
diff --git a/nptl/tst-mutex3.c b/nptl/tst-mutex3.c index c45637b5cf..8e57924ba6 100644 --- a/nptl/tst-mutex3.c +++ b/nptl/tst-mutex3.c @@ -24,12 +24,25 @@ static pthread_mutex_t m; +static pthread_barrier_t b; static void * tf (void *arg) { - int e = pthread_mutex_trylock (&m); + int e = pthread_mutex_unlock (&m); + if (e == 0) + { + puts ("1st mutex_unlock in child succeeded"); + exit (1); + } + if (e != EPERM) + { + puts ("1st mutex_unlock in child didn't return EPERM"); + exit (1); + } + + e = pthread_mutex_trylock (&m); if (e == 0) { puts ("mutex_trylock in second thread succeeded"); @@ -41,6 +54,44 @@ tf (void *arg) exit (1); } + e = pthread_barrier_wait (&b); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait failed"); + exit (1); + } + + e = pthread_barrier_wait (&b); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait failed"); + exit (1); + } + + e = pthread_mutex_unlock (&m); + if (e == 0) + { + puts ("2nd mutex_unlock in child succeeded"); + exit (1); + } + if (e != EPERM) + { + puts ("2nd mutex_unlock in child didn't return EPERM"); + exit (1); + } + + if (pthread_mutex_trylock (&m) != 0) + { + puts ("2nd mutex_trylock in second thread failed"); + exit (1); + } + + if (pthread_mutex_unlock (&m) != 0) + { + puts ("3rd mutex_unlock in second thread failed"); + exit (1); + } + return NULL; } @@ -68,6 +119,12 @@ do_test (void) return 1; } + if (pthread_barrier_init (&b, NULL, 2) != 0) + { + puts ("barrier_init failed"); + return 1; + } + if (pthread_mutex_lock (&m) != 0) { puts ("mutex_lock failed"); @@ -105,9 +162,10 @@ do_test (void) return 1; } - if (pthread_join (th, NULL) != 0) + int e = pthread_barrier_wait (&b); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) { - puts ("join failed"); + puts ("barrier_wait failed"); return 1; } @@ -117,6 +175,37 @@ do_test (void) return 1; } + e = pthread_mutex_unlock (&m); + if (e == 0) + { + puts ("4th mutex_unlock succeeded"); + return 1; + } + if (e != EPERM) + { + puts ("4th mutex_unlock didn't return EPERM"); + return 1; + } + + e = pthread_barrier_wait (&b); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait failed"); + return 1; + } + + if (pthread_join (th, NULL) != 0) + { + puts ("join failed"); + return 1; + } + + if (pthread_barrier_destroy (&b) != 0) + { + puts ("barrier_destroy failed"); + return 1; + } + if (pthread_mutex_destroy (&m) != 0) { puts ("mutex_destroy failed"); |