Skip to content

Commit 5d0f44e

Browse files
author
Jarkko Paso
committed
Unit tests: DH1CF channel function tests implemented
1 parent fbd5568 commit 5d0f44e

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

test/nanostack/unittest/service_libs/channel_functions/channelfunctest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,13 @@ TEST(channel_functions, test_tr51_calculate_hopping_sequence)
4848
{
4949
CHECK(test_tr51_calculate_hopping_sequence());
5050
}
51+
52+
TEST(channel_functions, test_dh1cf_get_uc_channel_index)
53+
{
54+
CHECK(test_dh1cf_get_uc_channel_index());
55+
}
56+
57+
TEST(channel_functions, test_dh1cf_get_bc_channel_index)
58+
{
59+
CHECK(test_dh1cf_get_bc_channel_index());
60+
}

test/nanostack/unittest/service_libs/channel_functions/test_channel_functions.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const int32_t test_HopSequenceTable [129] = { 4,93,31,84,55,3,116,123,
5454
77,48,100,51,14,21,94,23,
5555
22 };
5656

57+
5758
bool test_tr51_get_rand()
5859
{
5960
tr51_seed_rand(1);
@@ -143,3 +144,53 @@ bool test_tr51_calculate_hopping_sequence()
143144

144145
return true;
145146
}
147+
148+
bool test_dh1cf_get_uc_channel_index()
149+
{
150+
int32_t test_dh1cf_channel_table_1[10] = {19, 128, 3, 53, 79, 24, 68, 118, 7, 51};
151+
uint8_t mac_1[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x05, 0xf8};
152+
int i;
153+
// Test generating channel table for specific MAC addresses and slot numbers
154+
for (i=0; i<10; i++) {
155+
if (test_dh1cf_channel_table_1[i] != dh1cf_get_uc_channel_index(10738+i, mac_1, 129)) {
156+
return false;
157+
}
158+
}
159+
160+
int32_t test_dh1cf_channel_table_2[10] = {82, 47, 102, 83, 89, 5, 23, 121, 70, 98};
161+
uint8_t mac_2[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x06, 0x02};
162+
163+
for (i=0; i<10; i++) {
164+
if (test_dh1cf_channel_table_2[i] != dh1cf_get_uc_channel_index(16446+i, mac_2, 129)) {
165+
return false;
166+
}
167+
}
168+
return true;
169+
}
170+
171+
bool test_dh1cf_get_bc_channel_index()
172+
{
173+
int32_t test_dh1cf_channel_table_1[10] = {107, 46, 75, 88, 27, 23, 114, 86, 75, 115};
174+
int i;
175+
// Test generating channel table for specific broadcast schedule identifiers and slot numbers
176+
for (i=0; i<10; i++) {
177+
if (test_dh1cf_channel_table_1[i] != dh1cf_get_bc_channel_index(10738+i, 1, 129)) {
178+
return false;
179+
}
180+
}
181+
int32_t test_dh1cf_channel_table_2[10] = {112, 122, 121, 22, 54, 91, 116, 14, 102, 68};
182+
for (i=0; i<10; i++) {
183+
if (test_dh1cf_channel_table_2[i] != dh1cf_get_bc_channel_index(10738+i, 2, 129)) {
184+
return false;
185+
}
186+
}
187+
188+
int32_t test_dh1cf_channel_table_3[10] = {60, 96, 3, 120, 8, 109, 80, 42, 96, 91};
189+
for (i=0; i<10; i++) {
190+
if (test_dh1cf_channel_table_3[i] != dh1cf_get_bc_channel_index(10738+i, 100, 129)) {
191+
return false;
192+
}
193+
194+
}
195+
return true;
196+
}

test/nanostack/unittest/service_libs/channel_functions/test_channel_functions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ bool test_tr51_get_rand();
2727
bool test_tr51_calculate_channel_table();
2828
bool test_tr51_compute_cfd();
2929
bool test_tr51_calculate_hopping_sequence();
30+
bool test_dh1cf_get_uc_channel_index();
31+
bool test_dh1cf_get_bc_channel_index();
3032

3133
#ifdef __cplusplus
3234
}

0 commit comments

Comments
 (0)