view src/parallel_execution/test/queue_test.c @ 205:1b15f02ec713

Fix queue test
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 20 Dec 2016 16:54:42 +0900
parents 57a88b2ae3b3
children b6ffdd99e525
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_queue_test1;
    queue->next = C_queue_test2;
    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.queue);
}

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

__code queue_test2_stub(struct Context* context) {
    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_queue_test4;
    goto meta(context, queue->queue->Queue.take);
}

__code queue_test3_stub(struct Context* context) {
    goto queue_test3(context,
            &context->data[D_Queue]->Queue);
}

__code queue_test4(struct Context* context, struct Queue* queue) {
    goto meta(context, C_queue_test4 /*Exit*/ );
}

__code queue_test4_stub(struct Context* context) {
//    assert(((struct Task)context->data[D_Queue]->queue.queue.data)->code == C_queue_test1)
//    assert(((struct Task)context->data[D_Queue]->queue.queue.last->data)->code == C_queue_test2)
    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_queue_test1;
    goto start_code(main_context);
}