Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/test/queue_test.c @ 214:da8ca04eb4f3
Add extern initContext to queue_test
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 06 Jan 2017 05:51:23 +0900 |
parents | 9e5c504adc21 |
children | 6578c5c274ba |
rev | line source |
---|---|
182 | 1 #include "../queue.h" |
2 #include "../context.h" | |
3 #include "../origin_cs.h" | |
4 #include <assert.h> | |
5 | |
214
da8ca04eb4f3
Add extern initContext to queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
213
diff
changeset
|
6 extern __code initContext(struct Context* context); |
182 | 7 |
209 | 8 __code queueTest1(struct Context* context, struct Task* task, struct Queue* queue) { |
9 task->code = C_queueTest1; | |
10 queue->next = C_queueTest2; | |
182 | 11 queue->data = (union Data*)task; |
203 | 12 goto meta(context, queue->queue->Queue.put); |
182 | 13 } |
14 | |
209 | 15 __code queueTest1_stub(struct Context* context) { |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
16 Queue* queue = &createSingleLinkedQueue(context)->Queue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
17 context->data[D_Queue]->Queue.queue = (union Data*)queue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
18 SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
19 assert(singleLinkedQueue->top == NULL); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
20 assert(singleLinkedQueue->last == NULL); |
182 | 21 Task* task = &ALLOCATE(context, Task)->Task; |
209 | 22 goto queueTest1(context, |
182 | 23 task, |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
24 &context->data[D_Queue]->Queue); |
182 | 25 } |
26 | |
209 | 27 __code queueTest2(struct Context* context, struct Task* task, struct Queue* queue) { |
28 task->code = C_queueTest2; | |
29 queue->next = C_queueTest3; | |
182 | 30 queue->data = (union Data*)task; |
203 | 31 goto meta(context, queue->queue->Queue.put); |
182 | 32 } |
33 | |
209 | 34 __code queueTest2_stub(struct Context* context) { |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
35 SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
36 assert(((struct Task*)singleLinkedQueue->top->data)->code == C_queueTest1); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
37 assert(((struct Task*)singleLinkedQueue->last->data)->code == C_queueTest1); |
182 | 38 Task* task = &ALLOCATE(context, Task)->Task; |
209 | 39 goto queueTest2(context, |
182 | 40 task, |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
41 &context->data[D_Queue]->Queue); |
182 | 42 } |
43 | |
209 | 44 __code queueTest3(struct Context* context, struct Queue* queue) { |
45 queue->next = C_queueTest4; | |
203 | 46 goto meta(context, queue->queue->Queue.take); |
182 | 47 } |
48 | |
209 | 49 __code queueTest3_stub(struct Context* context) { |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
50 SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
51 assert(((struct Task*)singleLinkedQueue->top->data)->code == C_queueTest1); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
52 assert(((struct Task*)singleLinkedQueue->last->data)->code == C_queueTest2); |
209 | 53 goto queueTest3(context, |
203 | 54 &context->data[D_Queue]->Queue); |
182 | 55 } |
56 | |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
57 __code queueTest4(struct Context* context) { |
213
9e5c504adc21
Add goto exit to queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
212
diff
changeset
|
58 goto meta(context, C_exit_code); |
182 | 59 } |
60 | |
209 | 61 __code queueTest4_stub(struct Context* context) { |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
62 SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
63 assert(((struct Task*)context->data[D_Queue]->Queue.data)->code == C_queueTest1); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
64 assert(((struct Task*)singleLinkedQueue->top->data)->code == C_queueTest2); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
65 assert(((struct Task*)singleLinkedQueue->last->data)->code == C_queueTest2); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
66 goto queueTest4(context); |
182 | 67 } |
68 | |
69 int main(int argc, char const* argv[]) { | |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
70 Context* main_context = NEW(struct Context); |
182 | 71 initContext(main_context); |
209 | 72 main_context->next = C_queueTest1; |
182 | 73 goto start_code(main_context); |
74 } |