mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
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:
parent
297a71f418
commit
b1d6b660cb
53
drd/tests/annotate_hb_err.c
Normal file
53
drd/tests/annotate_hb_err.c
Normal 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:
|
||||
*/
|
||||
36
drd/tests/annotate_hb_err.stderr.exp
Normal file
36
drd/tests/annotate_hb_err.stderr.exp
Normal 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)
|
||||
4
drd/tests/annotate_hb_err.vgtest
Normal file
4
drd/tests/annotate_hb_err.vgtest
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user