]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Made these tests run successfully on Darwin.
authorBart Van Assche <bvanassche@acm.org>
Wed, 22 Jul 2009 18:02:03 +0000 (18:02 +0000)
committerBart Van Assche <bvanassche@acm.org>
Wed, 22 Jul 2009 18:02:03 +0000 (18:02 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10523

helgrind/tests/tc12_rwl_trivial.c
helgrind/tests/tc23_bogus_condwait.c
helgrind/tests/tc24_nonzero_sem.c

index 9dc8e84294cd219a0969edeed1699b3ffb89cccc..7cc4c163ae4e1ab3a0e2a060196a7c85d9e19063 100644 (file)
@@ -8,6 +8,12 @@
 #include <pthread.h>
 #include <assert.h>
 
+#ifdef __APPLE__
+#define OS_IS_DARWIN 1
+#else
+#define OS_IS_DARWIN 0
+#endif
+
 /* Do trivial stuff with a reader-writer lock. */
 
 int main ( void )
@@ -26,7 +32,7 @@ int main ( void )
   r = pthread_rwlock_unlock( &rwl );      assert(r == 0);
 
   /* this should fail - lock is unowned now */
-  r = pthread_rwlock_unlock( &rwl );      assert(r == 0);
+  r = pthread_rwlock_unlock( &rwl );      assert(OS_IS_DARWIN || r == 0);
 
   r = pthread_rwlock_destroy( &rwl );     assert(r == 0);
 
index a0fad5d5d757310d1e3be36ff0d948241a395e9f..b45ff0ad4d7e67301cdd63299df2e14be6928928 100644 (file)
@@ -7,6 +7,12 @@
 #include <unistd.h>
 #include <semaphore.h>
 
+#ifdef __APPLE__
+#define OS_IS_DARWIN 1
+#else
+#define OS_IS_DARWIN 0
+#endif
+
 pthread_mutex_t mx[4];
 pthread_cond_t cv;
 pthread_rwlock_t rwl;
@@ -56,7 +62,7 @@ int main ( void )
   r= pthread_cond_init(&cv, NULL); assert(!r);
   r= pthread_rwlock_init(&rwl, NULL); assert(!r);
 
-  r= sem_init( &quit_now, 0,0 ); assert(!r);
+  r= sem_init( &quit_now, 0,0 ); assert(OS_IS_DARWIN || !r);
 
   r= pthread_create( &grabber, NULL, grab_the_lock, NULL ); assert(!r);
   sleep(1); /* let the grabber get there first */
@@ -77,8 +83,8 @@ int main ( void )
   /* mx is held by someone else. */
   r= pthread_cond_wait(&cv, &mx[2] );
 
-  r= sem_post( &quit_now ); assert(!r);
-  r= sem_post( &quit_now ); assert(!r);
+  r= sem_post( &quit_now ); assert(OS_IS_DARWIN || !r);
+  r= sem_post( &quit_now ); assert(OS_IS_DARWIN || !r);
 
   r= pthread_join( my_rescuer, NULL ); assert(!r);
   r= pthread_join( grabber, NULL ); assert(!r);
index 01c23e811aa07e2f28673e0fefa40a1858739415..c6176a3a79689dae966bf44cada3efdca96b1926 100644 (file)
@@ -8,13 +8,19 @@
 #include <semaphore.h>
 #include <assert.h>
 
+#ifdef __APPLE__
+#define OS_IS_DARWIN 1
+#else
+#define OS_IS_DARWIN 0
+#endif
+
 #define N_THREADS 3
 
 void* child_fn ( void* semV )
 {
    int r;
    sem_t* sem = (sem_t*)semV;
-   r= sem_wait(sem); assert(!r);
+   r= sem_wait(sem); assert(OS_IS_DARWIN || !r);
    return NULL;
 }
 
@@ -24,7 +30,7 @@ int main ( void )
    sem_t sem;
    pthread_t child[N_THREADS];
 
-   r= sem_init(&sem, 0, N_THREADS); assert(!r);
+   r= sem_init(&sem, 0, N_THREADS); assert(OS_IS_DARWIN || !r);
 
    for (i = 0; i < N_THREADS; i++) {
       r= pthread_create( &child[i], NULL, child_fn, (void*)&sem );