Skip to content

Commit c538bb6

Browse files
vcgomesTomasz Bursztyka
authored andcommitted
tests/zoap: Add test for payload size
Add a test for the available space for the payload, so the problem with the payload length doesn't regresses. Change-Id: Ifef541d8428947eb482729aa773a7e9ddd2b6f81 Signed-off-by: Vinicius Costa Gomes <[email protected]>
1 parent 909ad35 commit c538bb6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/net/zoap/src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ static int test_build_simple_pdu(void)
182182
goto done;
183183
}
184184

185+
if (buflen != (ZOAP_BUF_SIZE - 4 - strlen(token) - 2 - 1)) {
186+
/*
187+
* The remaining length will be the buffer size less
188+
* 4: basic CoAP header
189+
* strlen(token): token length
190+
* 2: options (content-format)
191+
* 1: payload marker (added by zoap_packet_get_payload())
192+
*/
193+
TC_PRINT("Invalid packet length\n");
194+
goto done;
195+
}
196+
185197
memcpy(appdata, payload, sizeof(payload));
186198

187199
r = zoap_packet_set_used(&pkt, sizeof(payload));

0 commit comments

Comments
 (0)