Added a test program that triggers several happens-before usage errors.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11069
This commit is contained in:
Bart Van Assche 2010-03-07 10:46:43 +00:00
parent 297a71f418
commit b1d6b660cb
3 changed files with 93 additions and 0 deletions

View File

@ -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:
*/

View File

@ -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)

View File

@ -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