summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/test/bridgedma-proto/src/bridgedma-init-test.c
blob: aec478f7efcf4623e53ba12d65bbe618239a9c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    bridgedma-init-test.c
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_arch.h>

#include "common/std.h"
#include "common/defs/ethernet.h"

#include "lib/test.h"
#include "lib/list.h"
#include "lib/read_word.h"
#include "lib/bitstream.h"

#include "hal/phy/inc/bridgedma.h"
#include "hal/phy/inc/bridgedma_proto.h"

#include "mac/common/pb.h"

#include <string.h>
#include <stdio.h>
#include <cyg/infra/diag.h>

#define START_OFFSET 128

cyg_thread  my_test_thread;
cyg_handle_t my_test_thread_handle;
u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];

phy_bridgedma_t *bridgedma_ctx;

/* WARNING: callback are not possible to test inside UNIT TEST */
bool _bridgedma_segmentation_cb(void *data, u32 status)
{
}

/* WARNING: callback are not possible to test inside UNIT TEST */
void _bridgedma_deffered_cb(void *data)
{
}

void bridgedma_init_test_case(test_t t)
{
    int user_data;

    test_case_begin(t, "init");

    test_begin(t, "init")
    {
        bridgedma_ctx = NULL;
        bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
        test_fail_unless(
            (bridgedma_ctx != NULL)
            && (bridgedma_ctx->job_first == NULL)
            && (bridgedma_ctx->job_current == NULL)
            && (bridgedma_ctx->job_last == NULL)            
            && (bridgedma_ctx->user_data == &user_data)
            && (bridgedma_ctx->bridgedma_cb == _bridgedma_segmentation_cb)
            && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
            && !bridgedma_ctx->status.running
            && bridgedma_ctx->status.stop
        );
    } test_end;
    return;
}

void
test_thread_process (cyg_addrword_t data)
{
    test_t *test;

    test = (test_t *) data;
    
    bridgedma_init_test_case (*test);
    phy_bridgedma_uninit (bridgedma_ctx);

    test_result (*test);

#ifndef __sparc__
    HAL_PLATFORM_EXIT (test_nb_failed (*test) == 0 ? 0 : 1);
#endif
}

int
main (void)
{
    test_t test;

    test_init (test, 0, NULL);

    // Create the thread.
    cyg_thread_create( 9,
                      &test_thread_process,
                      (cyg_addrword_t) &test,
                      "TEST_THREAD",
                      my_test_thread_stack,
                      CYGNUM_HAL_STACK_SIZE_TYPICAL,
                      &my_test_thread_handle,
                      &my_test_thread);
    cyg_thread_resume (my_test_thread_handle);

    return 0;
}