The CDSSpec checker's benchmarks
[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 int x;
16
17 static void task(void * param) {
18         a=steal(q);
19         if (a == ABORT) {
20                 printf("Steal NULL\n");
21         } else {
22                 printf("Steal %d\n", a);
23         }
24         
25         x=steal(q);
26         if (x == ABORT) {
27                 printf("Steal NULL\n");
28         } else {
29                 printf("Steal %d\n", x);
30         }
31 }
32
33 int user_main(int argc, char **argv)
34 {
35         /** @Entry */
36         thrd_t t;
37         q=create();
38         thrd_create(&t, task, 0);
39         push(q, 1);
40         printf("Push 1\n");
41         push(q, 2);
42         printf("Push 2\n");
43         push(q, 4);
44         printf("Push 4\n");
45         b=take(q);
46         if (b == EMPTY) {
47                 printf("Take NULL\n");
48         } else {
49                 printf("Take %d\n", b);
50         }
51         c=take(q);
52         if (c == EMPTY) {
53                 printf("Take NULL\n");
54         } else {
55                 printf("Take %d\n", c);
56         }
57         thrd_join(t);
58 /*
59         bool correct=true;
60         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
61                 correct=false;
62         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
63                 correct=false;
64         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
65                 correct=false;
66         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
67                 correct=false;
68         if (!correct)
69                 printf("a=%d b=%d c=%d\n",a,b,c);
70                 */
71         //MODEL_ASSERT(correct);
72
73         return 0;
74 }