Skip to content

Commit e49c7cb

Browse files
author
Daniel Kroening
authored
Merge pull request #303 from danpoe/concurrency-regression-tests
Two concurrency regression tests for cbmc
2 parents 92bb662 + 27854b4 commit e49c7cb

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <pthread.h>
2+
#include <assert.h>
3+
4+
int *v;
5+
int g;
6+
7+
void *thread1(void * arg)
8+
{
9+
v = &g;
10+
}
11+
12+
void *thread2(void *arg)
13+
{
14+
assert(v == &g);
15+
*v = 1;
16+
}
17+
18+
int main()
19+
{
20+
pthread_t t1, t2;
21+
22+
pthread_create(&t1, 0, thread1, 0);
23+
pthread_join(t1, 0);
24+
25+
pthread_create(&t2, 0, thread2, 0);
26+
pthread_join(t2, 0);
27+
28+
assert(v == &g);
29+
assert(*v == 1);
30+
31+
return 0;
32+
}
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <pthread.h>
2+
#include <assert.h>
3+
4+
void *thread(void *arg)
5+
{
6+
int *i = (int *)arg;
7+
*i = 1;
8+
}
9+
10+
int main(void)
11+
{
12+
int x;
13+
x = 0;
14+
15+
pthread_t t;
16+
17+
pthread_create(&t, NULL, thread, &x);
18+
pthread_join(t, NULL);
19+
20+
assert(x == 1);
21+
22+
return 0;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc-concurrency/struct_and_array1/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void *foo1(void *arg1)
2222
void *foo2(void *arg2)
2323
{
2424
st.y = 1;
25-
my_array[2]=2;
25+
my_array[2]=1;
2626
done2 = 1;
2727
}
2828

0 commit comments

Comments
 (0)