Skip to content

Commit

Permalink
FHSS unit tests: Fixed timestamp stub return value
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Aug 29, 2018
1 parent f43b3af commit 6ed53e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ static fhss_api_t *test_generate_fhss_api(void)
fhss_common_stub.fhss_struct.callbacks.change_channel = &mac_set_channel;
fhss_common_stub.fhss_struct.callbacks.read_mac_address = &mac_read_64bit_mac_address;
fhss_common_stub.fhss_struct.callbacks.read_tx_queue_size = &mac_read_tx_queue_sizes;
fhss_common_stub.fhss_struct.callbacks.read_timestamp = &mac_read_phy_timestamp;
fhss_common_stub.fhss_struct.callbacks.tx_poll = &mac_poll_tx_queue;
test_set_platform_api(&fhss_common_stub.fhss_struct.platform_functions);
fhss_ws_set_callbacks(&fhss_common_stub.fhss_struct);
Expand Down Expand Up @@ -469,24 +470,24 @@ bool test_fhss_ws_write_synch_info_callback()
return false;
}
fhss_platform_stub.remaining_slots_value = 100000;
fhss_common_stub.uint32_value = 1000000;
fhss_callbacks_stub.uint32_value = 1000000;
/* Test the UFSI field in synch info
* slot: | 0(200ms) | 1(200ms) | 2(200ms) | 3(200ms) |
* | ufsi(597ms) -> 1001599 |
* timestamps: written at 1000000us|TX at 1097000us|
*/
if ((fhss_common_stub.fhss_struct.fhss_api->write_synch_info(api, synch_info, sizeof(synch_info), DEFAULT_FRAME_TYPE, fhss_common_stub.uint32_value + 97000) != 0)
if ((fhss_common_stub.fhss_struct.fhss_api->write_synch_info(api, synch_info, sizeof(synch_info), DEFAULT_FRAME_TYPE, fhss_callbacks_stub.uint32_value + 97000) != 0)
|| (test_ufsi(&synch_info[11], 1001599) != true)) {
return false;
}
// Test when timestamp overflows
fhss_common_stub.uint32_value = 4294960000;
fhss_callbacks_stub.uint32_value = 4294960000;
/* Test the UFSI field in synch info
* slot: | 0(200ms) | 1(200ms) | 2(200ms) | 3(200ms) |
* | ufsi(597ms) -> 1001599 |
* timestamps: written at 4294960000us| TX at 89704us|
*/
if ((fhss_common_stub.fhss_struct.fhss_api->write_synch_info(api, synch_info, sizeof(synch_info), DEFAULT_FRAME_TYPE, fhss_common_stub.uint32_value + 97000) != 0)
if ((fhss_common_stub.fhss_struct.fhss_api->write_synch_info(api, synch_info, sizeof(synch_info), DEFAULT_FRAME_TYPE, fhss_callbacks_stub.uint32_value + 97000) != 0)
|| (test_ufsi(&synch_info[11], 1001599) != true)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/fhss_callbacks_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ uint32_t mac_read_phy_datarate(const fhss_api_t *fhss_api)

uint32_t mac_read_phy_timestamp(const fhss_api_t *fhss_api)
{
return 0;
return fhss_callbacks_stub.uint32_value;
}

int mac_set_channel(const fhss_api_t *fhss_api, uint8_t channel_number)
Expand Down
1 change: 1 addition & 0 deletions test/nanostack/unittest/stub/fhss_callbacks_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C" {
typedef struct {
uint8_t uint8_value;
int8_t int8_value;
uint32_t uint32_value;
uint8_t address[8];
} fhss_callbacks_stub_def;

Expand Down

0 comments on commit 6ed53e6

Please sign in to comment.