Skip to content

Commit a1d8b3d

Browse files
author
Jarkko Paso
committed
FHSS unit tests: Fixed tr51 tests
1 parent 7e622b3 commit a1d8b3d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ bool test_tr51_get_uc_channel_index()
8686
int i;
8787
uint16_t number_of_channels = 129;
8888
int32_t channel;
89+
int16_t channel_table[number_of_channels];
8990
int32_t test_table[number_of_channels];
9091
uint8_t mac[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x05, 0xf8};
92+
93+
tr51_init_channel_table(channel_table, number_of_channels);
9194
for (i=0; i<number_of_channels; i++) {
92-
test_table[i] = channel = tr51_get_uc_channel_index(i, mac, number_of_channels, NULL);
95+
test_table[i] = channel = tr51_get_uc_channel_index(channel_table, i, mac, number_of_channels, NULL);
9396
// Not sure yet which one is correct since there might be bug in spec
9497
// if (channel != test_HopSequenceTable[i]) {
9598
if (channel != test_HopSequenceTable2[i]) {
@@ -114,7 +117,7 @@ bool test_tr51_get_uc_channel_index()
114117
uint32_t excluded_channels[8] = {0x40100401, 0x10040100, 0x04010040, 0, 0, 0, 0, 0};
115118
uint16_t number_of_excluded_channels = 10;
116119
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);
120+
test_table[i] = channel = tr51_get_uc_channel_index(channel_table, i, mac, number_of_channels, excluded_channels);
118121
// Shouldn't find channel from excluded channels
119122
if (channel_on_the_list(excluded_channels, channel)) {
120123
return false;
@@ -137,8 +140,10 @@ bool test_tr51_get_bc_channel_index()
137140
int32_t channel;
138141
uint16_t bsi = 100;
139142
int32_t test_table[number_of_channels];
143+
int16_t channel_table[number_of_channels];
144+
tr51_init_channel_table(channel_table, number_of_channels);
140145
for (int i=0; i<number_of_channels; i++) {
141-
test_table[i] = channel = tr51_get_bc_channel_index(i, bsi, number_of_channels, NULL);
146+
test_table[i] = channel = tr51_get_bc_channel_index(channel_table, i, bsi, number_of_channels, NULL);
142147
if (channel != test_HopSequenceTable3[i]) {
143148
return false;
144149
}

test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,11 @@ bool test_fhss_ws_enable()
179179
return false;
180180
}
181181
// Test success
182-
nsdynmemlib_stub.returnCounter = 1;
182+
nsdynmemlib_stub.returnCounter = 2;
183183
if (fhss_ws_enable(&fhss_api, &fhss_configuration, &fhss_timer) == NULL) {
184184
return false;
185185
}
186+
free(fhss_common_stub.fhss_struct.ws->tr51_channel_table);
186187
free(fhss_common_stub.fhss_struct.ws);
187188
return true;
188189
}

test/nanostack/unittest/stub/channel_functions_stub.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ int32_t dh1cf_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t n
3030
return 2;
3131
}
3232

33-
int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels)
33+
int tr51_init_channel_table(int16_t *channel_table, int16_t number_of_channels)
34+
{
35+
return 0;
36+
}
37+
38+
int32_t tr51_get_uc_channel_index(int16_t *channel_table, uint16_t slot_number, uint8_t *mac, int16_t number_of_channels)
3439
{
3540
channel_functions_stub.uint8_value = slot_number;
3641
return 3;
3742
}
3843

39-
int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels)
44+
int32_t tr51_get_bc_channel_index(int16_t *channel_table, uint16_t slot_number, uint16_t bsi, int16_t number_of_channels)
4045
{
4146
return 4;
4247
}

0 commit comments

Comments
 (0)