tests/zoap: Adds test for the length of payload on the RX side
This unit test verifies that zoap_packet_get_payload() returns the expected size for received packets. Jira: ZEP-1662 Change-Id: Ibe011959f4d6593f4f20f0f5901c9033c76c9518 Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
parent
346edff2ca
commit
45fe87a425
1 changed files with 13 additions and 2 deletions
|
@ -348,8 +348,8 @@ static int test_parse_simple_pdu(void)
|
|||
struct net_buf *buf, *frag;
|
||||
struct zoap_option options[16];
|
||||
uint8_t ver, type, code, tkl;
|
||||
const uint8_t *token;
|
||||
uint16_t id;
|
||||
const uint8_t *token, *payload;
|
||||
uint16_t id, len;
|
||||
int result = TC_FAIL;
|
||||
int r, count = 16;
|
||||
|
||||
|
@ -442,6 +442,17 @@ static int test_parse_simple_pdu(void)
|
|||
goto done;
|
||||
}
|
||||
|
||||
payload = zoap_packet_get_payload(&pkt, &len);
|
||||
if (!payload || !len) {
|
||||
TC_PRINT("There should be a payload in the packet\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (len != (strlen("payload") + 1)) {
|
||||
TC_PRINT("Invalid payload in the packet\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = TC_PASS;
|
||||
|
||||
done:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue