|
From: <sv...@va...> - 2008-09-27 12:26:25
|
Author: bart
Date: 2008-09-27 13:26:17 +0100 (Sat, 27 Sep 2008)
New Revision: 8635
Log:
Added the pth_cancel_locked test.
Added:
trunk/drd/tests/pth_cancel_locked.c
trunk/drd/tests/pth_cancel_locked.stderr.exp
trunk/drd/tests/pth_cancel_locked.vgtest
Modified:
trunk/drd/tests/
trunk/drd/tests/Makefile.am
Property changes on: trunk/drd/tests
___________________________________________________________________
Name: svn:ignore
- *.stderr.diff*
*.stderr.out
*.stdout.diff*
*.stdout.out
.deps
Makefile
Makefile.in
atomic_var
drd_bitmap_test
fp_race
hg01_all_ok
hg02_deadlock
hg03_inherit
hg04_race
hg05_race2
hg06_readshared
hold_lock
linuxthreads_det
matinv
memory_allocation
new_delete
omp_matinv
omp_prime
pth_barrier
pth_barrier_reinit
pth_broadcast
pth_cond_race
pth_create_chain
pth_detached
pth_detached_sem
pth_inconsistent_cond_wait
pth_spinlock
qt4_mutex
qt4_rwlock
qt4_semaphore
recursive_mutex
rwlock_race
rwlock_test
sem_as_mutex
sigalrm
tc01_simple_race
tc02_simple_tls
tc03_re_excl
tc04_free_lock
tc05_simple_race
tc06_two_races
tc07_hbl1
tc08_hbl2
tc09_bad_unlock
tc10_rec_lock
tc11_XCHG
tc12_rwl_trivial
tc13_laog1
tc15_laog_lockdel
tc16_byterace
tc17_sembar
tc18_semabuse
tc19_shadowmem
tc20_verifywrap
tc21_pthonce
tc22_exit_w_lock
tc23_bogus_condwait
tc24_nonzero_sem
trylock
+ *.stderr.diff*
*.stderr.out
*.stdout.diff*
*.stdout.out
.deps
atomic_var
drd_bitmap_test
fp_race
hg01_all_ok
hg02_deadlock
hg03_inherit
hg04_race
hg05_race2
hg06_readshared
hold_lock
linuxthreads_det
Makefile
Makefile.in
matinv
memory_allocation
new_delete
omp_matinv
omp_prime
pth_barrier
pth_barrier_reinit
pth_broadcast
pth_cancel_locked
pth_cond_race
pth_create_chain
pth_detached
pth_detached_sem
pth_inconsistent_cond_wait
pth_spinlock
qt4_mutex
qt4_rwlock
qt4_semaphore
recursive_mutex
rwlock_race
rwlock_test
sem_as_mutex
sigalrm
tc01_simple_race
tc02_simple_tls
tc03_re_excl
tc04_free_lock
tc05_simple_race
tc06_two_races
tc07_hbl1
tc08_hbl2
tc09_bad_unlock
tc10_rec_lock
tc11_XCHG
tc12_rwl_trivial
tc13_laog1
tc15_laog_lockdel
tc16_byterace
tc17_sembar
tc18_semabuse
tc19_shadowmem
tc20_verifywrap
tc21_pthonce
tc22_exit_w_lock
tc23_bogus_condwait
tc24_nonzero_sem
trylock
vg_regtest.tmp*
Modified: trunk/drd/tests/Makefile.am
===================================================================
--- trunk/drd/tests/Makefile.am 2008-09-22 09:17:03 UTC (rev 8634)
+++ trunk/drd/tests/Makefile.am 2008-09-27 12:26:17 UTC (rev 8635)
@@ -74,6 +74,8 @@
pth_barrier_reinit.vgtest \
pth_broadcast.stderr.exp \
pth_broadcast.vgtest \
+ pth_cancel_locked.stderr.exp \
+ pth_cancel_locked.vgtest \
pth_cond_race.stderr.exp \
pth_cond_race.vgtest \
pth_cond_race2.stderr.exp \
@@ -203,6 +205,7 @@
pth_barrier \
pth_barrier_reinit \
pth_broadcast \
+ pth_cancel_locked \
pth_cond_race \
pth_create_chain \
pth_detached \
@@ -299,6 +302,9 @@
pth_broadcast_SOURCES = pth_broadcast.c
pth_broadcast_LDADD = -lpthread
+pth_cancel_locked_SOURCES = pth_cancel_locked.c
+pth_cancel_locked_LDADD = -lpthread
+
pth_cond_race_SOURCES = pth_cond_race.c
pth_cond_race_LDADD = -lpthread
Added: trunk/drd/tests/pth_cancel_locked.c
===================================================================
--- trunk/drd/tests/pth_cancel_locked.c (rev 0)
+++ trunk/drd/tests/pth_cancel_locked.c 2008-09-27 12:26:17 UTC (rev 8635)
@@ -0,0 +1,51 @@
+/** Cancel a thread that holds a lock on a mutex. */
+
+
+#include <assert.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+pthread_cond_t s_cond;
+pthread_mutex_t s_mutex1;
+pthread_mutex_t s_mutex2;
+
+
+static void* thread(void* arg)
+{
+ /* Lock s_mutex2. */
+ pthread_mutex_lock(&s_mutex2);
+ /* Inform the main thread that s_mutex2 has been locked, and wait for pthread_cancel(). */
+ pthread_mutex_lock(&s_mutex1);
+ pthread_cond_signal(&s_cond);
+ pthread_cond_wait(&s_cond, &s_mutex1);
+ return 0;
+}
+
+int main(int argc, char** argv)
+{
+ pthread_t tid;
+
+ /* Initialize synchronization objects. */
+ pthread_cond_init(&s_cond, 0);
+ pthread_mutex_init(&s_mutex1, 0);
+ pthread_mutex_init(&s_mutex2, 0);
+
+ /* Create thread. */
+ pthread_mutex_lock(&s_mutex1);
+ pthread_create(&tid, 0, &thread, 0);
+
+ /* Wait until the created thread has locked s_mutex2. */
+ pthread_cond_wait(&s_cond, &s_mutex1);
+ pthread_mutex_unlock(&s_mutex1);
+
+ /* Cancel the created thread. */
+ pthread_cancel(tid);
+
+ /* Join the created thread. */
+ pthread_join(tid, 0);
+
+ fprintf(stderr, "Test finished.\n");
+
+ return 0;
+}
Added: trunk/drd/tests/pth_cancel_locked.stderr.exp
===================================================================
--- trunk/drd/tests/pth_cancel_locked.stderr.exp (rev 0)
+++ trunk/drd/tests/pth_cancel_locked.stderr.exp 2008-09-27 12:26:17 UTC (rev 8635)
@@ -0,0 +1,10 @@
+
+Mutex still locked at thread exit: mutex 0x........, recursion count 1, owner 2.
+ at 0x........: pthread_join (drd_pthread_intercepts.c:?)
+ by 0x........: main (pth_cancel_locked.c:?)
+mutex 0x........ was first observed at:
+ at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+ by 0x........: main (pth_cancel_locked.c:?)
+Test finished.
+
+ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Added: trunk/drd/tests/pth_cancel_locked.vgtest
===================================================================
--- trunk/drd/tests/pth_cancel_locked.vgtest (rev 0)
+++ trunk/drd/tests/pth_cancel_locked.vgtest 2008-09-27 12:26:17 UTC (rev 8635)
@@ -0,0 +1,2 @@
+prereq: ./supported_libpthread
+prog: pth_cancel_locked
|