diff options
author | sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2007-11-09 22:49:28 +0000 |
---|---|---|
committer | sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2007-11-09 22:49:28 +0000 |
commit | b411202f9ff33a587558e2e836626bc7eb9db183 (patch) | |
tree | b2acf8b1b6c9fcaa93b31434236c6da8e282b59c /helgrind/tests/tc13_laog1.c | |
parent | 097e4fbcdbd0dd62fbeab09d4ab0077967c18852 (diff) | |
download | valgrind-b411202f9ff33a587558e2e836626bc7eb9db183.tar.gz |
Import thrcheck from the THRCHECK branch, and rename it Helgrind (with
permission of the existing Helgrind authors).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7116 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'helgrind/tests/tc13_laog1.c')
-rw-r--r-- | helgrind/tests/tc13_laog1.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/helgrind/tests/tc13_laog1.c b/helgrind/tests/tc13_laog1.c new file mode 100644 index 000000000..e42ca985f --- /dev/null +++ b/helgrind/tests/tc13_laog1.c @@ -0,0 +1,33 @@ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +/* The simplest possible test that triggers a lock order acquisition + error. */ + +int main ( void ) +{ + int r; + pthread_mutex_t mx1, mx2; + r = pthread_mutex_init( &mx1, NULL ); assert(r==0); + r = pthread_mutex_init( &mx2, NULL ); assert(r==0); + + r = pthread_mutex_lock( &mx1 ); assert(r==0); + r = pthread_mutex_lock( &mx2 ); assert(r==0); + + r = pthread_mutex_unlock( &mx1 ); assert(r==0); + r = pthread_mutex_unlock( &mx2 ); assert(r==0); + + r = pthread_mutex_lock( &mx2 ); assert(r==0); /* error */ + r = pthread_mutex_lock( &mx1 ); assert(r==0); + + r = pthread_mutex_unlock( &mx1 ); assert(r==0); + r = pthread_mutex_unlock( &mx2 ); assert(r==0); + + r = pthread_mutex_destroy( &mx1 ); + r = pthread_mutex_destroy( &mx2 ); + + return 0; +} |