]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added regression test for ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() and
authorBart Van Assche <bvanassche@acm.org>
Tue, 11 Aug 2009 15:00:54 +0000 (15:00 +0000)
committerBart Van Assche <bvanassche@acm.org>
Tue, 11 Aug 2009 15:00:54 +0000 (15:00 +0000)
ANNOTATE_IGNORE_READS_AND_WRITES_END().

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10779

drd/tests/Makefile.am
drd/tests/annotate_ignore_rw.c [new file with mode: 0644]
drd/tests/annotate_ignore_rw.stderr.exp [new file with mode: 0644]
drd/tests/annotate_ignore_rw.vgtest [new file with mode: 0644]
drd/tests/annotate_ignore_rw2.stderr.exp [new file with mode: 0644]
drd/tests/annotate_ignore_rw2.vgtest [new file with mode: 0644]

index e31611c2c118c2ab295bee6373a2b60486a2b49f..96b8b3844ebfb72f77d4f6f159b2e8607e4cd934 100644 (file)
@@ -25,6 +25,8 @@ EXTRA_DIST =                                        \
        annotate_rwlock.vgtest                      \
        annotate_ignore_read.stderr.exp             \
        annotate_ignore_read.vgtest                 \
+       annotate_ignore_rw.stderr.exp               \
+       annotate_ignore_rw.vgtest                   \
        annotate_trace_memory.stderr.exp            \
        annotate_trace_memory.vgtest                \
        atomic_var.stderr.exp                       \
@@ -238,6 +240,7 @@ EXTRA_DIST =                                        \
 
 
 check_PROGRAMS =      \
+  annotate_ignore_rw  \
   custom_alloc        \
   fp_race             \
   hold_lock           \
diff --git a/drd/tests/annotate_ignore_rw.c b/drd/tests/annotate_ignore_rw.c
new file mode 100644 (file)
index 0000000..9efe1fb
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test program for the annotations that suppress both reads and writes. */
+
+#include <assert.h>  /* assert() */
+#include <pthread.h>
+#include <stdio.h>   /* EOF */
+#include <unistd.h>  /* getopt() */
+#include "../../drd/drd.h"
+
+static int s_a;
+static int s_b;
+
+static void* thread_func(void* arg)
+{
+  /* Read s_a and modify s_b. */
+  s_b = s_a;
+
+  return NULL;
+}
+
+int main(int argc, char** argv)
+{
+  int optchar;
+  int ign_rw = 1;
+  pthread_t tid;
+  
+  while ((optchar = getopt(argc, argv, "r")) != EOF)
+  {
+    switch (optchar)
+    {
+    case 'r':
+      ign_rw = 0;
+      break;
+    default:
+      assert(0);
+    }
+  }
+
+  pthread_create(&tid, 0, thread_func, 0);
+  if (ign_rw)
+    ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN();
+  /* Read s_b and modify s_a. */
+  s_a = s_b;
+  if (ign_rw)
+    ANNOTATE_IGNORE_READS_AND_WRITES_END();
+  pthread_join(tid, 0);
+
+  fprintf(stderr, "Finished.\n");
+
+  return 0;
+}
diff --git a/drd/tests/annotate_ignore_rw.stderr.exp b/drd/tests/annotate_ignore_rw.stderr.exp
new file mode 100644 (file)
index 0000000..a7089bb
--- /dev/null
@@ -0,0 +1,4 @@
+
+Finished.
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/drd/tests/annotate_ignore_rw.vgtest b/drd/tests/annotate_ignore_rw.vgtest
new file mode 100644 (file)
index 0000000..cee4289
--- /dev/null
@@ -0,0 +1,4 @@
+prereq: ./supported_libpthread
+vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no
+prog: annotate_ignore_rw
+stderr_filter: filter_stderr
diff --git a/drd/tests/annotate_ignore_rw2.stderr.exp b/drd/tests/annotate_ignore_rw2.stderr.exp
new file mode 100644 (file)
index 0000000..c27119a
--- /dev/null
@@ -0,0 +1,13 @@
+
+Conflicting load by thread 1 at 0x........ size 4
+   at 0x........: main (annotate_ignore_rw.c:?)
+Location 0x........ is 0 bytes inside local var "s_b"
+declared at annotate_ignore_rw.c:10, in frame #? of thread 1
+
+Conflicting store by thread 1 at 0x........ size 4
+   at 0x........: main (annotate_ignore_rw.c:?)
+Location 0x........ is 0 bytes inside local var "s_a"
+declared at annotate_ignore_rw.c:9, in frame #? of thread 1
+Finished.
+
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
diff --git a/drd/tests/annotate_ignore_rw2.vgtest b/drd/tests/annotate_ignore_rw2.vgtest
new file mode 100644 (file)
index 0000000..dec0575
--- /dev/null
@@ -0,0 +1,5 @@
+prereq: ./supported_libpthread
+vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no
+prog: annotate_ignore_rw
+args: -r
+stderr_filter: filter_stderr