Skip to content

Commit

Permalink
FHSS unit tests: Test tx conditions and tx done callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Apr 9, 2018
1 parent baaec35 commit 04449e8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.c
Expand Up @@ -291,6 +291,21 @@ bool test_fhss_ws_check_tx_conditions_callback()
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, DEFAULT_IS_BC_DEST, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != true) {
return false;
}
// Test on fixed channel
enable_fhss_struct();
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, DEFAULT_IS_BC_DEST, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != true) {
return false;
}
// Test broadcast destination on unicast channel
fhss_common_stub.fhss_struct.ws->fhss_configuration.ws_channel_function = WS_TR51CF;
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, true, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != false) {
return false;
}
// Test broadcast destination on broadcast channel
fhss_common_stub.fhss_struct.ws->is_on_bc_channel = true;
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, true, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != true) {
return false;
}

return true;
}
Expand All @@ -315,6 +330,8 @@ bool test_fhss_ws_data_tx_done_callback()
fhss_common_stub.fhss_struct.fhss_api->data_tx_done(api, DEFAULT_WAITING_ACK, DEFAULT_TX_COMPLETED, DEFAULT_HANDLE);
// Test when FHSS struct can be found
enable_fhss_struct();
fhss_common_stub.fhss_struct.fhss_state = FHSS_SYNCHRONIZED;
fhss_common_stub.fhss_struct.ws->fhss_configuration.ws_channel_function = WS_TR51CF;
fhss_common_stub.fhss_struct.fhss_api->data_tx_done(api, DEFAULT_WAITING_ACK, DEFAULT_TX_COMPLETED, DEFAULT_HANDLE);

return true;
Expand Down Expand Up @@ -525,15 +542,20 @@ bool test_fhss_ws_set_parent()
broadcast_timing_info_t bc_timing_info;
memset(&bc_timing_info, 0, sizeof(broadcast_timing_info_t));
fhss_api_t *api = test_generate_fhss_api();
fhss_common_stub.fhss_struct.ws->fhss_configuration.ws_channel_function = WS_TR51CF;


// Test without WS enabled FHSS
fhss_structure_t fake_fhss_structure;
memset(&fake_fhss_structure, 0, sizeof(fhss_structure_t));
if (-1 != fhss_ws_set_parent(&fake_fhss_structure, dest_address, &bc_timing_info)) {
return false;
}
// Test on fixed channel
if (0 != fhss_ws_set_parent(&fhss_common_stub.fhss_struct, dest_address, &bc_timing_info)) {
return false;
}
// Test success
fhss_common_stub.fhss_struct.ws->fhss_configuration.ws_channel_function = WS_TR51CF;
bc_timing_info.broadcast_channel_function = WS_TR51CF;
bc_timing_info.broadcast_dwell_interval = 250;
bc_timing_info.broadcast_interval = 1000;
Expand Down

0 comments on commit 04449e8

Please sign in to comment.