--- /dev/null
+/* 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:
+ */
--- /dev/null
+
+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)
--- /dev/null
+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