Mercurial > hg > GearsTemplate
comparison src/parallel_execution/test/queue_test.c @ 182:57a11c15ff4c
Add queue_test
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Dec 2016 21:33:11 +0900 |
parents | |
children | 25db17f32ac2 |
comparison
equal
deleted
inserted
replaced
181:78b28c8ffff2 | 182:57a11c15ff4c |
---|---|
1 #include "../queue.h" | |
2 #include "../context.h" | |
3 #include "../origin_cs.h" | |
4 #include <assert.h> | |
5 | |
6 | |
7 __code queue_test1(struct Context* context, struct Task* task, struct Queue* queue) { | |
8 task->code = C_QueueTest1; | |
9 queue->next = C_QueueTest2; | |
10 queue->data = (union Data*)task; | |
11 goto meta(context, queue->queue->queue.put); | |
12 } | |
13 | |
14 __code queue_test1_stub(struct Context* context) { | |
15 Task* task = &ALLOCATE(context, Task)->Task; | |
16 struct Queue* queue = &(createSingleLinkedQueue(context)->queue); | |
17 assert(queue->queue->singleLinkedQueue.top == NULL); | |
18 assert(queue->queue->singleLinkedQueue.last == NULL); | |
19 context->data[D_Queue]->queue.queue = (union Data*)queue; | |
20 goto queue_test1(context, | |
21 task, | |
22 &context->data[D_Queue]->queue); | |
23 } | |
24 | |
25 __code queue_test2(struct Context* context, struct Task* task, struct Queue* queue) { | |
26 task->code = C_QueueTest2; | |
27 queue->next = C_QueueTest3; | |
28 queue->data = (union Data*)task; | |
29 goto meta(context, queue->queue->queue.put); | |
30 } | |
31 | |
32 __code queue_test2_stub(struct Context* context) { | |
33 assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1) | |
34 assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1) | |
35 Task* task = &ALLOCATE(context, Task)->Task; | |
36 goto queue_test2(context, | |
37 task, | |
38 &context->data[D_Queue]->queue->queue); | |
39 } | |
40 | |
41 __code queue_test3(struct Context* context, struct Queue* queue) { | |
42 queue->next = C_QueueTest4; | |
43 goto meta(context, queue->queue->take) | |
44 } | |
45 | |
46 __code queue_test3_stub(struct Context* context) { | |
47 assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest2) | |
48 assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1) | |
49 goto queue_test3(context, | |
50 &context->data[D_Queue]->queue); | |
51 } | |
52 | |
53 __code queue_test4(struct Context* context) { | |
54 goto meta(context, Exit); | |
55 } | |
56 | |
57 __code queue_test4_stub(struct Context* context) { | |
58 assert(((struct Task)context->data[D_Queue]->queue.queue.data)->code == C_QueueTest1) | |
59 assert(((struct Task)context->data[D_Queue]->queue.queue.last->data)->code == C_QueueTest2) | |
60 goto queue_test4(context, | |
61 &context->data[D_Queue]->queue->queue); | |
62 } | |
63 | |
64 int main(int argc, char const* argv[]) { | |
65 struct Context* main_context = NEW(struct Context); | |
66 initContext(main_context); | |
67 main_context->next = C_QueueTest1; | |
68 goto start_code(main_context); | |
69 } |