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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../queue.h"
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include "../context.h"
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "../origin_cs.h"
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <assert.h>
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
8 __code queueTest1(struct Context* context, struct Task* task, struct Queue* queue) {
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
9 task->code = C_queueTest1;
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
10 queue->next = C_queueTest2;
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 queue->data = (union Data*)task;
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
12 goto meta(context, queue->queue->Queue.put);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 Task* task = &ALLOCATE(context, Task)->Task;
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
22 goto queueTest1(context,
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
27 __code queueTest2(struct Context* context, struct Task* task, struct Queue* queue) {
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
28 task->code = C_queueTest2;
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
29 queue->next = C_queueTest3;
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 queue->data = (union Data*)task;
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
31 goto meta(context, queue->queue->Queue.put);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 Task* task = &ALLOCATE(context, Task)->Task;
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
39 goto queueTest2(context,
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
44 __code queueTest3(struct Context* context, struct Queue* queue) {
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
45 queue->next = C_queueTest4;
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
46 goto meta(context, queue->queue->Queue.take);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
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
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
53 goto queueTest3(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
54 &context->data[D_Queue]->Queue);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 initContext(main_context);
209
5708390a9d88 fix compile errors
mir3636
parents: 208
diff changeset
72 main_context->next = C_queueTest1;
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 goto start_code(main_context);
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }