summaryrefslogtreecommitdiff
path: root/mac/sar/test/unit_test/ecos/src/msdu-timeout.c
blob: 641071fb0092cc2ed60aefae2a5eefd0a9f45adb (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
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/sar/test/unit_test/ecos/src/msdu-timeout.c
 * \brief   Test the msdu expiration. 
 * \ingroup mac_sar
 *
 */
#include "common/std.h"

#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_arch.h>


#include "lib/test.h"
#include "mac/sar/sar.h"
#include "mac/common/ntb.h"

#include "mac/sar/inc/sar_context.h"

bool expired;

bool tx_msdu_expiration (sar_t *ctx, sar_msdu_t * msdu);

/**
 * Segmentation process for the SAR module.
 * 
 * \param  ctx  the sar context
 * \param  msdu  the msdu to process
 */
void segmentation_run (sar_t *ctx, sar_msdu_t *msdu);

void
seg_done (void *user_data, u8 *buffer)
{
    expired = true;
}

int
main (void)
{
    test_t test;
    sar_t *sar;
    mac_config_t mac_config;
    sar_msdu_t msdu_exp;
    sar_msdu_t msdu;

    test_init (test, 0, NULL);
    sar = blk_alloc ();

    mac_ntb_init ((phy_t *)sar, &mac_config);
    sar_init_segmentation_data_cb (sar, seg_done);
    sar_init_segmentation_mme_cb (sar, seg_done);

    msdu_exp.ats_confounder = 0;
    msdu.ats_confounder = 26000000;
    msdu.mfs = blk_alloc ();
    msdu.mfs->common.mme = true;

    msdu_exp.mfs = msdu.mfs;

    expired = false;
    segmentation_run (sar, &msdu_exp);

    test_begin (test, "Expired")
    {
        test_fail_if (expired != true, "MSDU shall expire : Wrong expiration");
    }
    test_end;

    expired = false;
    msdu_exp.mfs->common.mme = false;
    segmentation_run (sar, &msdu_exp);

    test_begin (test, "Expired")
    {
        test_fail_if (expired != true, "MSDU shall expire : Wrong expiration");
    }
    test_end;


    test_begin (test, "No Expiration")
    {
        test_fail_if (tx_msdu_expiration (sar, &msdu) != false, "MSDU shall not expire");
    }
    test_end;


    blk_release (sar);
    blk_release (msdu.mfs);

    test_result (test);
    HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
    return test_nb_failed (test) == 0 ? 0 : 1;

}

u32
phy_date (phy_t * phy)
{
    return 25000000;
}