view 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
line wrap: on
line source

#include "../queue.h"
#include "../context.h"
#include "../origin_cs.h"
#include <assert.h>


__code queue_test1(struct Context* context, struct Task* task, struct Queue* queue) {
    task->code = C_QueueTest1;
    queue->next = C_QueueTest2;
    queue->data = (union Data*)task;
    goto meta(context, queue->queue->queue.put);
}

__code queue_test1_stub(struct Context* context) {
    Task* task = &ALLOCATE(context, Task)->Task;
    struct Queue* queue = &(createSingleLinkedQueue(context)->queue);
    assert(queue->queue->singleLinkedQueue.top == NULL);
    assert(queue->queue->singleLinkedQueue.last == NULL);
    context->data[D_Queue]->queue.queue = (union Data*)queue;
    goto queue_test1(context,
            task,
            &context->data[D_Queue]->queue);
}

__code queue_test2(struct Context* context, struct Task* task, struct Queue* queue) {
    task->code = C_QueueTest2;
    queue->next = C_QueueTest3;
    queue->data = (union Data*)task;
    goto meta(context, queue->queue->queue.put);
}

__code queue_test2_stub(struct Context* context) {
    assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1)
    assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1)
    Task* task = &ALLOCATE(context, Task)->Task;
    goto queue_test2(context,
            task,
            &context->data[D_Queue]->queue->queue);
}

__code queue_test3(struct Context* context, struct Queue* queue) {
    queue->next = C_QueueTest4;
    goto meta(context, queue->queue->take)
}

__code queue_test3_stub(struct Context* context) {
    assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest2)
    assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1)
    goto queue_test3(context,
            &context->data[D_Queue]->queue);
}

__code queue_test4(struct Context* context) {
    goto meta(context, Exit);
}

__code queue_test4_stub(struct Context* context) {
    assert(((struct Task)context->data[D_Queue]->queue.queue.data)->code == C_QueueTest1)
    assert(((struct Task)context->data[D_Queue]->queue.queue.last->data)->code == C_QueueTest2)
    goto queue_test4(context,
            &context->data[D_Queue]->queue->queue);
}

int main(int argc, char const* argv[]) {
    struct Context* main_context = NEW(struct Context);
    initContext(main_context);
    main_context->next = C_QueueTest1;
    goto start_code(main_context);
}