summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>2010-03-07 19:59:35 +0000
committerbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>2010-03-07 19:59:35 +0000
commitb43825e01fa6a6145e31f1b18cb07d9891907fca (patch)
treecc71698c2e81e55a2ad1d8bfb9b1a10b3deac463
parent9b4180924f1d0ef6106ec4eadd14ea1caf5ab65e (diff)
Added yet another regression test.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11076 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r--drd/tests/Makefile.am3
-rw-r--r--drd/tests/annotate_hb_race.c50
-rw-r--r--drd/tests/annotate_hb_race.stderr.exp9
-rw-r--r--drd/tests/annotate_hb_race.vgtest4
4 files changed, 66 insertions, 0 deletions
diff --git a/drd/tests/Makefile.am b/drd/tests/Makefile.am
index 3bc989eb..4ca923cb 100644
--- a/drd/tests/Makefile.am
+++ b/drd/tests/Makefile.am
@@ -16,6 +16,8 @@ noinst_HEADERS = \
EXTRA_DIST = \
annotate_hb_err.stderr.exp \
annotate_hb_err.vgtest \
+ annotate_hb_race.stderr.exp \
+ annotate_hb_race.vgtest \
annotate_hbefore.stderr.exp \
annotate_hbefore.vgtest \
annotate_order_1.stderr.exp \
@@ -249,6 +251,7 @@ EXTRA_DIST = \
check_PROGRAMS = \
annotate_hb_err \
+ annotate_hb_race \
annotate_ignore_rw \
annotate_ignore_write \
annotate_publish_hg \
diff --git a/drd/tests/annotate_hb_race.c b/drd/tests/annotate_hb_race.c
new file mode 100644
index 00000000..76c3a948
--- /dev/null
+++ b/drd/tests/annotate_hb_race.c
@@ -0,0 +1,50 @@
+/*
+ * Test program with happens-before / happens-after annotations that triggers
+ * a data race. The data race will only be reported if happens-after
+ * annotations that occur in different threads are not totally ordered. Or:
+ * this is a test for the implementation of ordering annotations.
+ */
+
+
+#include <stdio.h>
+#include <pthread.h>
+#include "unified_annotations.h"
+
+
+static int s_i;
+
+
+static void* thread_func(void* arg)
+{
+ int i;
+
+ ANNOTATE_HAPPENS_AFTER(&s_i);
+ i = s_i;
+ ANNOTATE_HAPPENS_AFTER(&s_i);
+ *(int*)arg = i;
+ return NULL;
+}
+
+int main(int argc, char** argv)
+{
+ pthread_t tid[2];
+ int result[2];
+
+ ANNOTATE_HAPPENS_BEFORE(&s_i);
+ pthread_create(&tid[0], 0, thread_func, &result[0]);
+ pthread_create(&tid[1], 0, thread_func, &result[1]);
+ s_i = 1;
+
+ pthread_join(tid[0], NULL);
+ pthread_join(tid[1], NULL);
+
+ fprintf(stderr, "Done.\n");
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 2
+ * End:
+ */
diff --git a/drd/tests/annotate_hb_race.stderr.exp b/drd/tests/annotate_hb_race.stderr.exp
new file mode 100644
index 00000000..7f28cdf4
--- /dev/null
+++ b/drd/tests/annotate_hb_race.stderr.exp
@@ -0,0 +1,9 @@
+
+Conflicting store by thread x at 0x........ size 4
+ at 0x........: main (annotate_hb_race.c:?)
+Location 0x........ is 0 bytes inside local var "s_i"
+declared at annotate_hb_race.c:14, in frame #? of thread x
+
+Done.
+
+ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
diff --git a/drd/tests/annotate_hb_race.vgtest b/drd/tests/annotate_hb_race.vgtest
new file mode 100644
index 00000000..88f46087
--- /dev/null
+++ b/drd/tests/annotate_hb_race.vgtest
@@ -0,0 +1,4 @@
+prereq: test -e annotate_hb_race && ./supported_libpthread
+vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no
+prog: annotate_hb_race
+stderr_filter: filter_stderr_and_thread_no