aboutsummaryrefslogtreecommitdiff
path: root/helgrind/tests
diff options
context:
space:
mode:
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2007-11-30 11:22:35 +0000
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2007-11-30 11:22:35 +0000
commit006f29fff130edea9cab1ac977296260cb212bbd (patch)
treeb62a95dcb18a69f93d8eb6efb5947282ca175c18 /helgrind/tests
parent11e352f44852ea8fd5e3f65bf424528040ab7e0f (diff)
downloadvalgrind-006f29fff130edea9cab1ac977296260cb212bbd.tar.gz
Add a test case for semaphores with nonzero initial values.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7254 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'helgrind/tests')
-rw-r--r--helgrind/tests/Makefile.am7
-rw-r--r--helgrind/tests/tc24_nonzero_sem.c41
-rw-r--r--helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd643
-rw-r--r--helgrind/tests/tc24_nonzero_sem.stdout.exp0
-rw-r--r--helgrind/tests/tc24_nonzero_sem.vgtest2
5 files changed, 51 insertions, 2 deletions
diff --git a/helgrind/tests/Makefile.am b/helgrind/tests/Makefile.am
index ac84a9672..dac727c3a 100644
--- a/helgrind/tests/Makefile.am
+++ b/helgrind/tests/Makefile.am
@@ -81,7 +81,9 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
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 @@ check_PROGRAMS = \
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 \
diff --git a/helgrind/tests/tc24_nonzero_sem.c b/helgrind/tests/tc24_nonzero_sem.c
new file mode 100644
index 000000000..01c23e811
--- /dev/null
+++ b/helgrind/tests/tc24_nonzero_sem.c
@@ -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;
+}
diff --git a/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64 b/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64
new file mode 100644
index 000000000..d18786f80
--- /dev/null
+++ b/helgrind/tests/tc24_nonzero_sem.stderr.exp-glibc25-amd64
@@ -0,0 +1,3 @@
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/helgrind/tests/tc24_nonzero_sem.stdout.exp b/helgrind/tests/tc24_nonzero_sem.stdout.exp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/helgrind/tests/tc24_nonzero_sem.stdout.exp
diff --git a/helgrind/tests/tc24_nonzero_sem.vgtest b/helgrind/tests/tc24_nonzero_sem.vgtest
new file mode 100644
index 000000000..1a43121eb
--- /dev/null
+++ b/helgrind/tests/tc24_nonzero_sem.vgtest
@@ -0,0 +1,2 @@
+prog: tc24_nonzero_sem
+vgopts: --hg-sanity-flags=111111