Skip to content

Commit

Permalink
Updating unit tests
Browse files Browse the repository at this point in the history
Updating unit test in response to the change in the link ADR related
APIs.
  • Loading branch information
Hasnain Virk committed Feb 14, 2019
1 parent 726eff9 commit a14acfa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp
Expand Up @@ -181,6 +181,10 @@ TEST_F(Test_LoRaPHYAU915, link_ADR_request)
uint8_t nb_rep_out = 0;
uint8_t nb_bytes_parsed = 0;

uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4};
params.payload = payload;
params.payload_size = 5;

LoRaPHY_stub::uint8_value = 1;
LoRaPHY_stub::ch_mask_value = 6;
LoRaPHY_stub::adr_parse_count = 2;
Expand Down
4 changes: 4 additions & 0 deletions UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp
Expand Up @@ -206,6 +206,10 @@ TEST_F(Test_LoRaPHYCN470, link_ADR_request)
uint8_t nb_rep_out = 0;
uint8_t nb_bytes_parsed = 0;

uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4};
params.payload = payload;
params.payload_size = 5;

LoRaPHY_stub::uint8_value = 1;
LoRaPHY_stub::ch_mask_value = 6;
LoRaPHY_stub::adr_parse_count = 2;
Expand Down
Expand Up @@ -177,15 +177,22 @@ TEST_F(Test_LoRaPHYUS915, tx_config)

TEST_F(Test_LoRaPHYUS915, link_ADR_request)
{
uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4};
adr_req_params_t params;
memset(&params, 0, sizeof(params));
int8_t dr_out = 0;
int8_t tx_power_out = 0;
uint8_t nb_rep_out = 0;
uint8_t nb_bytes_parsed = 0;

EXPECT_TRUE(0 == object->link_ADR_request(&params, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed));
params.payload = payload;
params.payload_size = 4;

uint8_t status = object->link_ADR_request(&params, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed);

EXPECT_TRUE(0 == nb_bytes_parsed);

params.payload_size = 5;
LoRaPHY_stub::uint8_value = 1;
LoRaPHY_stub::ch_mask_value = 6;
LoRaPHY_stub::adr_parse_count = 2;
Expand Down
4 changes: 4 additions & 0 deletions UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp
Expand Up @@ -494,6 +494,10 @@ TEST_F(Test_LoRaWANStack, handle_rx)
ind.buffer = ind_buf;
ind.buffer_size = 150;
ind.type = MCPS_UNCONFIRMED;
ind.port = 15;
ind.is_data_recvd = true;
ind.fpending_status = false;
LoRaMac_stub::dev_class_value = CLASS_A;
radio._ev->rx_done(NULL, 0, 0, 0);

//data == NULL || LENGTH == 0 (2 cases)
Expand Down
3 changes: 3 additions & 0 deletions UNITTESTS/stubs/LoRaPHY_stub.cpp
Expand Up @@ -151,9 +151,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
}

uint8_t LoRaPHY::parse_link_ADR_req(const uint8_t *payload,
uint8_t payload_size,
link_adr_params_t *params)
{
params->ch_mask_ctrl = LoRaPHY_stub::ch_mask_value;
params->channel_mask = 0;
params->datarate = 0;

if (LoRaPHY_stub::adr_parse_count) {
return --LoRaPHY_stub::adr_parse_count;
Expand Down

0 comments on commit a14acfa

Please sign in to comment.