Author: sewardj
Date: 2007-11-30 11:22:35 +0000 (Fri, 30 Nov 2007)
New Revision: 7254

Log:
Add a test case for semaphores with nonzero initial values.

Added:
   trunk/helgrind/tests/tc24_nonzero_sem.c
   trunk/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64
   trunk/helgrind/tests/tc24_nonzero_sem.stdout.exp
   trunk/helgrind/tests/tc24_nonzero_sem.vgtest
Modified:
   trunk/helgrind/tests/Makefile.am


Modified: trunk/helgrind/tests/Makefile.am
===================================================================
--- trunk/helgrind/tests/Makefile.am    2007-11-30 11:11:02 UTC (rev 7253)
+++ trunk/helgrind/tests/Makefile.am    2007-11-30 11:22:35 UTC (rev 7254)
@@ -81,7 +81,9 @@
                tc22_exit_w_lock.stderr.exp-glibc25-x86 \
        tc23_bogus_condwait.vgtest tc23_bogus_condwait.stdout.exp \
                tc23_bogus_condwait.stderr.exp-glibc25-amd64 \
-               tc23_bogus_condwait.stderr.exp-glibc25-x86
+               tc23_bogus_condwait.stderr.exp-glibc25-x86 \
+       tc24_nonzero_sem.vgtest tc24_nonzero_sem.stdout.exp \
+               tc24_nonzero_sem.stderr.exp-glibc25-amd64
 
 check_PROGRAMS = \
        hg01_all_ok \
@@ -112,7 +114,8 @@
        tc20_verifywrap \
        tc21_pthonce \
        tc22_exit_w_lock \
-       tc23_bogus_condwait
+       tc23_bogus_condwait \
+       tc24_nonzero_sem
 
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include \
                 -I$(top_srcdir)/coregrind -I$(top_builddir)/include \

Added: trunk/helgrind/tests/tc24_nonzero_sem.c
===================================================================
--- trunk/helgrind/tests/tc24_nonzero_sem.c                             (rev 0)
+++ trunk/helgrind/tests/tc24_nonzero_sem.c     2007-11-30 11:22:35 UTC (rev 
7254)
@@ -0,0 +1,41 @@
+
+/* Check that Helgrind does not complain about semaphores with a
+   nonzero initial value, when said semaphores are correctly used.
+   Also useful for generating VCG of simple semaphore activity, for
+   inspection. */
+
+#include <pthread.h>
+#include <semaphore.h>
+#include <assert.h>
+
+#define N_THREADS 3
+
+void* child_fn ( void* semV )
+{
+   int r;
+   sem_t* sem = (sem_t*)semV;
+   r= sem_wait(sem); assert(!r);
+   return NULL;
+}
+
+int main ( void )
+{
+   int r, i;
+   sem_t sem;
+   pthread_t child[N_THREADS];
+
+   r= sem_init(&sem, 0, N_THREADS); assert(!r);
+
+   for (i = 0; i < N_THREADS; i++) {
+      r= pthread_create( &child[i], NULL, child_fn, (void*)&sem );
+      assert(!r);
+   }
+
+   for (i = 0; i < N_THREADS; i++) {
+      r= pthread_join( child[i], NULL );
+      assert(!r);
+   }
+
+   sem_destroy(&sem);
+   return 0;
+}

Added: trunk/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64
===================================================================
--- trunk/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64              
                (rev 0)
+++ trunk/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64      
2007-11-30 11:22:35 UTC (rev 7254)
@@ -0,0 +1,3 @@
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Added: trunk/helgrind/tests/tc24_nonzero_sem.stdout.exp
===================================================================

Added: trunk/helgrind/tests/tc24_nonzero_sem.vgtest
===================================================================
--- trunk/helgrind/tests/tc24_nonzero_sem.vgtest                                
(rev 0)
+++ trunk/helgrind/tests/tc24_nonzero_sem.vgtest        2007-11-30 11:22:35 UTC 
(rev 7254)
@@ -0,0 +1,2 @@
+prog: tc24_nonzero_sem
+vgopts: --hg-sanity-flags=111111


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to