a752c7ab
elopes
add first test an...
|
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/*
* Copyright (C) 2015 Oliver Hahm <oliver.hahm@inria.fr>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
*
* @file
*/
#include <errno.h>
#include <string.h>
#include "thread.h"
#include "tests-sixlowpan.h"
#include "embUnit.h"
#include "unittests-constants.h"
#include "net/sixlowpan.h"
#define NALP_0 (0x00) /* 00 00 00 00 */
#define NALP_1 (0x01) /* 00 00 00 01 */
#define NALP_2 (0x3F) /* 00 11 11 11 */
#define NALP_3 (0x20) /* 00 10 00 00 */
#define NALP_4 (0x2A) /* 00 10 10 10 */
#define NALP_5 (0x1E) /* 00 01 11 10 */
#define NO_NALP_0 (0xFF) /* 11 11 11 11 */
#define NO_NALP_1 (0xC0) /* 11 00 00 00 */
#define NO_NALP_2 (0x40) /* 01 00 00 00 */
#define NO_NALP_3 (0x80) /* 10 00 00 00 */
#define NO_NALP_4 (0xAA) /* 10 10 10 10 */
#define NO_NALP_5 (0xD4) /* 11 01 01 00 */
#define IPv6_DISP (0x41) /* 01 00 00 01 */
#define LOWPAN_HC1_DISP (0x42) /* 01 00 00 10 */
#define LOWPAN_BC0_DISP (0x50) /* 01 01 00 00 */
#define ESC_DISP (0x7F) /* 01 11 11 11 */
#define MESH_DISP (0xB3) /* 10 11 00 11 */
#define FRAG1_DISP (0xC5) /* 11 00 01 01 */
#define FRAGN_DISP (0xE5) /* 11 10 01 01 */
/* Test with 6LoWPAN dispatch byte indicating a none-LoWPAN frame (NALP = Not a
* LoWPAN frame)
* see https://tools.ietf.org/html/rfc4944#section-5.1
*/
static void test_sixlowpan_nalp_is_no_6lowpan_frame_0(void)
{
TEST_ASSERT(sixlowpan_nalp(NALP_0));
}
static void test_sixlowpan_nalp_is_no_6lowpan_frame_1(void)
{
TEST_ASSERT(sixlowpan_nalp(NALP_1));
}
static void test_sixlowpan_nalp_is_no_6lowpan_frame_2(void)
{
TEST_ASSERT(sixlowpan_nalp(NALP_2));
}
static void test_sixlowpan_nalp_is_no_6lowpan_frame_3(void)
{
TEST_ASSERT(sixlowpan_nalp(NALP_3));
}
static void test_sixlowpan_nalp_is_no_6lowpan_frame_4(void)
{
TEST_ASSERT(sixlowpan_nalp(NALP_4));
}
static void test_sixlowpan_nalp_is_no_6lowpan_frame_5(void)
{
TEST_ASSERT(sixlowpan_nalp(NALP_5));
}
/* Test with 6LoWPAN dispatch byte indicating some none-NALP value */
static void test_sixlowpan_nalp_is_6lowpan_frame_0(void)
{
TEST_ASSERT(!sixlowpan_nalp(NO_NALP_0));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_1(void)
{
TEST_ASSERT(!sixlowpan_nalp(NO_NALP_1));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_2(void)
{
TEST_ASSERT(!sixlowpan_nalp(NO_NALP_2));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_3(void)
{
TEST_ASSERT(!sixlowpan_nalp(NO_NALP_3));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_4(void)
{
TEST_ASSERT(!sixlowpan_nalp(NO_NALP_4));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_5(void)
{
TEST_ASSERT(!sixlowpan_nalp(NO_NALP_5));
}
/* Test with 6LoWPAN dispatch byte indicating a LoWPAN frame */
static void test_sixlowpan_nalp_is_6lowpan_frame_6(void)
{
TEST_ASSERT(!sixlowpan_nalp(IPv6_DISP));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_7(void)
{
TEST_ASSERT(!sixlowpan_nalp(LOWPAN_HC1_DISP));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_8(void)
{
TEST_ASSERT(!sixlowpan_nalp(LOWPAN_BC0_DISP));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_9(void)
{
TEST_ASSERT(!sixlowpan_nalp(ESC_DISP));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_10(void)
{
TEST_ASSERT(!sixlowpan_nalp(MESH_DISP));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_11(void)
{
TEST_ASSERT(!sixlowpan_nalp(FRAG1_DISP));
}
static void test_sixlowpan_nalp_is_6lowpan_frame_12(void)
{
TEST_ASSERT(!sixlowpan_nalp(FRAGN_DISP));
}
Test *test_sixlowpan_tests(void)
{
EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(test_sixlowpan_nalp_is_no_6lowpan_frame_0),
new_TestFixture(test_sixlowpan_nalp_is_no_6lowpan_frame_1),
new_TestFixture(test_sixlowpan_nalp_is_no_6lowpan_frame_2),
new_TestFixture(test_sixlowpan_nalp_is_no_6lowpan_frame_3),
new_TestFixture(test_sixlowpan_nalp_is_no_6lowpan_frame_4),
new_TestFixture(test_sixlowpan_nalp_is_no_6lowpan_frame_5),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_0),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_1),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_2),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_3),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_4),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_5),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_6),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_7),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_8),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_9),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_10),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_11),
new_TestFixture(test_sixlowpan_nalp_is_6lowpan_frame_12),
};
EMB_UNIT_TESTCALLER(test_sixlowpan_tests_caller, NULL, NULL, fixtures);
return (Test *)&test_sixlowpan_tests_caller;
}
void tests_sixlowpan(void)
{
TESTS_RUN(test_sixlowpan_tests());
}
/** @} */
|