summaryrefslogtreecommitdiff
path: root/cesar/bsu/test/utest/tests.h
blob: ff59576c093445e726257ad536af720f355fb3f9 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef bsu_test_utest_tests_h
#define bsu_test_utest_tests_h
/* Cesar project {{{
 *
 * Copyright (C) 2010 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    bsu/test/utest/tests.h
 * \brief   Test environment.
 * \ingroup bsu
 */
#include "lib/test.h"
#include "bsu/bsu.h"
#include "lib/test.h"
#include "mac/common/store.h"
#include "mac/common/config.h"
#include "mac/pbproc/pbproc.h"
#include "mac/sar/sar.h"
#include "bsu/beacon/beacon.h"

struct bsu_test_ca_t
{
    /* Beacon periods computed for the CA.  */
    ca_beacon_period_t beacon_periods[CA_BEACON_PERIOD_NB];
    /* Number of beacon periods. */
    uint nb_beacon_periods;
};
typedef struct bsu_test_ca_t bsu_test_ca_t;

struct bsu_test_phy_t
{
    /** Phy date. */
    u32 phy_date;
};
typedef struct bsu_test_phy_t bsu_test_phy_t;

struct bsu_test_sar_t
{
    /** Beacon sent. */
    pb_beacon_t *beacon;
    /** MFS used. */
    mfs_tx_t *mfs;
    /** BTO and BPSTO address. */
    void *bto_bpsto;
};
typedef struct bsu_test_sar_t bsu_test_sar_t;

struct bsu_test_ul_t
{
    /** Beacon sent. */
    pb_beacon_t *beacon;
    /** BSU beacon params. */
    bsu_params_t *bparams;
};
typedef struct bsu_test_ul_t bsu_test_ul_t;

struct bsu_test_t
{
    /** Mac config. */
    mac_config_t mac_config;
    /** Mac store. */
    mac_store_t *mac_store;
    /** Channel Access context. */
    bsu_test_ca_t ca;
    /** Phy simulated context.  */
    bsu_test_phy_t phy;
    /** Sar context. */
    bsu_test_sar_t sar;
    /** Upper layer context. */
    bsu_test_ul_t ul;
    /** BSU. */
    bsu_t *bsu;
    /** Hal timer. */
    hal_timer_t *timer;
};
typedef struct bsu_test_t bsu_test_t;

BEGIN_DECLS

/**
 * Initialise the upper layer stub to INVALID_PTR.
 * \param  ctx  the test module context.
 */
void
bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx);

/**
 * Initialise the test unit.
 * \param  ctx  the tests context.
 */
void
bsu_test_init (bsu_test_t *ctx);

/**
 * Uninitialise the test unit.
 * \param  ctx  the tests context.
 */
void
bsu_test_uninit (bsu_test_t *ctx);

/**
 * Create a beacon.
 * \param  beacon structure to fill.
 *
 * Creates a beacon with 2 regions, 2 non persistent allocations, 2 Persistent
 * allocations.
 */
void
bsu_test_create_beacon (bsu_test_t *ctx, bsu_beacon_t *beacon);

/**
 * Verify the data present in the generated beacon are equal to the one in the
 * bsu beacon.
 * \param  t  test context.
 * \param  ctx  the bsu_test context.
 * \param  beacon  the bsu data beacon.
 * \param  phy_beacon  the beacon generated by the bsu.
 * \param  type  the beacon type.
 *
 * \Warn  the TEI in the phy_beacon is compared with the TEI in the mac
 * config.
 */
void
bsu_test_beacon_check_generation (test_t t, bsu_test_t *ctx,
                                  bsu_beacon_t *beacon,
                                  pb_beacon_t *phy_beacon,
                                  bsu_beacon_type_t type);

/**
 * Verify the read data corresponds to the one provided to generate the
 * beacon.
 * \param  t  test context.
 * \param  ctx  the bsu_test context.
 * \param  beacon  the bsu data beacon.
 * \param  sched  the schedules filled with the data in the real beacon.
 */
void
bsu_test_beacon_check_read (test_t t, bsu_test_t *ctx, bsu_beacon_t *beacon,
                            bsu_avln_t *sched);

/**
 * Fill the station AVLN object with test values.
 * \param  ctx  the bsu_test context.
 * \param  avln   the AVLN object to fill.
 */
void
bsu_test_avln_create (bsu_test_t *ctx, bsu_avln_t *avln);

END_DECLS

#endif /* bsu_test_utest_tests_h */