|
From: <sv...@va...> - 2010-03-07 10:46:51
|
Author: bart
Date: 2010-03-07 10:46:43 +0000 (Sun, 07 Mar 2010)
New Revision: 11069
Log:
Added a test program that triggers several happens-before usage errors.
Added:
trunk/drd/tests/annotate_hb_err.c
trunk/drd/tests/annotate_hb_err.stderr.exp
trunk/drd/tests/annotate_hb_err.vgtest
Added: trunk/drd/tests/annotate_hb_err.c
===================================================================
--- trunk/drd/tests/annotate_hb_err.c (rev 0)
+++ trunk/drd/tests/annotate_hb_err.c 2010-03-07 10:46:43 UTC (rev 11069)
@@ -0,0 +1,53 @@
+/* Test program that triggers several happens-before usage errors. */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+#include "unified_annotations.h"
+
+
+int main(int argc, char** argv)
+{
+ pthread_mutex_t m;
+ pthread_cond_t cv;
+ int i[64];
+
+ pthread_mutex_init(&m, NULL);
+ pthread_cond_init(&cv, NULL);
+
+ /* happens-after without preceding happens-before. */
+ ANNOTATE_HAPPENS_AFTER(&i);
+
+ /* happens-after on a mutex. */
+ ANNOTATE_HAPPENS_BEFORE(&m);
+
+ /* happens-after on a condition variable. */
+ ANNOTATE_HAPPENS_BEFORE(&cv);
+
+ /* condition variable operation on a h.b. annotated object. */
+ ANNOTATE_HAPPENS_BEFORE(&i);
+ pthread_cond_init((pthread_cond_t*)&i, NULL);
+
+ /* The sequence below is fine. */
+ ANNOTATE_HAPPENS_DONE(&i);
+ ANNOTATE_HAPPENS_BEFORE(&i);
+ ANNOTATE_HAPPENS_AFTER(&i);
+ ANNOTATE_HAPPENS_DONE(&i);
+ ANNOTATE_HAPPENS_BEFORE(&i);
+ ANNOTATE_HAPPENS_DONE(&i);
+
+ /* happens-before after happens-after without intervening happens-done. */
+ ANNOTATE_HAPPENS_BEFORE(&i);
+ ANNOTATE_HAPPENS_AFTER(&i);
+ ANNOTATE_HAPPENS_BEFORE(&i);
+
+ fprintf(stderr, "Done.\n");
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 2
+ * End:
+ */
Added: trunk/drd/tests/annotate_hb_err.stderr.exp
===================================================================
--- trunk/drd/tests/annotate_hb_err.stderr.exp (rev 0)
+++ trunk/drd/tests/annotate_hb_err.stderr.exp 2010-03-07 10:46:43 UTC (rev 11069)
@@ -0,0 +1,36 @@
+
+missing happens-before annotation
+ at 0x........: vgDrdCl_annotate_happens_after (drd.h:?)
+ by 0x........: main (annotate_hb_err.c:?)
+
+wrong type of synchronization object
+ at 0x........: vgDrdCl_annotate_happens_before (drd.h:?)
+ by 0x........: main (annotate_hb_err.c:?)
+mutex 0x........ was first observed at:
+ at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+ by 0x........: main (annotate_hb_err.c:?)
+
+wrong type of synchronization object
+ at 0x........: vgDrdCl_annotate_happens_before (drd.h:?)
+ by 0x........: main (annotate_hb_err.c:?)
+cond 0x........ was first observed at:
+ at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?)
+ by 0x........: main (annotate_hb_err.c:?)
+
+wrong type of synchronization object
+ at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?)
+ by 0x........: main (annotate_hb_err.c:?)
+order annotation 0x........ was first observed at:
+ at 0x........: vgDrdCl_annotate_happens_before (drd.h:?)
+ by 0x........: main (annotate_hb_err.c:?)
+
+happens-before after happens-after
+ at 0x........: vgDrdCl_annotate_happens_before (drd.h:?)
+ by 0x........: main (annotate_hb_err.c:?)
+order annotation 0x........ was first observed at:
+ at 0x........: vgDrdCl_annotate_happens_before (drd.h:?)
+ by 0x........: main (annotate_hb_err.c:?)
+
+Done.
+
+ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 0 from 0)
Added: trunk/drd/tests/annotate_hb_err.vgtest
===================================================================
--- trunk/drd/tests/annotate_hb_err.vgtest (rev 0)
+++ trunk/drd/tests/annotate_hb_err.vgtest 2010-03-07 10:46:43 UTC (rev 11069)
@@ -0,0 +1,4 @@
+prereq: test -e annotate_hb_err && ./supported_libpthread
+vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no
+prog: annotate_hb_err
+stderr_filter: filter_stderr_and_thread_no
|