add testcases
[model-checker-benchmarks.git] / chase-lev-deque-bugfix / testcase1.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <stdio.h>
4 #include <threads.h>
5 #include <stdatomic.h>
6
7 #include "model-assert.h"
8
9 #include "deque.h"
10
11 Deque *q;
12 int a;
13 int b;
14 int c;
15
16 atomic_int x[2];
17
18 static void task(void * param) {
19         a=steal(q);
20         printf("a=%d\n", a);
21         if (a != EMPTY && a != ABORT)
22                 atomic_load_explicit(&x[a], memory_order_relaxed);
23 }
24
25 int user_main(int argc, char **argv)
26 {
27         thrd_t t;
28         atomic_store_explicit(&x[0], 0,  memory_order_relaxed);
29         atomic_store_explicit(&x[1], 0,  memory_order_relaxed);
30         q=create_size(4);
31         thrd_create(&t, task, 0);
32         //atomic_store_explicit(&x[1], 37,  memory_order_relaxed);
33         push(q, 1);
34         //push(q, 4);
35         //b=take(q);
36         //c=take(q);
37         thrd_join(t);
38
39 /*
40         bool correct=true;
41         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
42                 correct=false;
43         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
44                 correct=false;
45         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
46                 correct=false;
47         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
48                 correct=false;
49         //if (!correct)
50                 printf("a=%d b=%d c=%d\n",a,b,c);
51         MODEL_ASSERT(correct);
52         */
53
54         return 0;
55 }