Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit a88590f

Browse files
author
Jarkko Paso
committed
FHSS unit tests: Test tr51cf with excluded channels
1 parent 3c9356a commit a88590f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ const int32_t test_HopSequenceTable3[129] = { 124, 114, 65, 104, 33, 20, 118,
7171
102, 10, 91, 76, 117, 61, 81, 13,
7272
46 };
7373

74+
static bool channel_on_the_list(uint16_t *list, uint16_t list_size, int32_t channel)
75+
{
76+
for (int i=0; i<list_size; i++) {
77+
if (list[i] == channel) {
78+
return true;
79+
}
80+
}
81+
return false;
82+
}
83+
7484
bool test_tr51_get_uc_channel_index()
7585
{
7686
int i;
@@ -99,6 +109,25 @@ bool test_tr51_get_uc_channel_index()
99109
}
100110
k=0;
101111
}
112+
// Test with excluded channels
113+
int l=0;
114+
uint16_t excluded_channels[10] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90};
115+
uint16_t number_of_excluded_channels = 10;
116+
for (i=0; i<number_of_channels-number_of_excluded_channels; i++) {
117+
test_table[i] = channel = tr51_get_uc_channel_index(i, mac, number_of_channels, excluded_channels, number_of_excluded_channels);
118+
// Shouldn't find channel from excluded channels
119+
if (channel_on_the_list(excluded_channels, number_of_excluded_channels, channel)) {
120+
return false;
121+
}
122+
// Test against channel sequence
123+
while (channel_on_the_list(excluded_channels, number_of_excluded_channels, test_HopSequenceTable2[l])) {
124+
l++;
125+
}
126+
if (channel != test_HopSequenceTable2[l]) {
127+
return false;
128+
}
129+
l++;
130+
}
102131

103132
return true;
104133
}

0 commit comments

Comments
 (0)