test_connection: add regression test for 1-byte packet handling
This commit is contained in:
parent
440382da57
commit
aedb139e38
1 changed files with 19 additions and 1 deletions
|
|
@ -388,6 +388,8 @@ int main(void)
|
|||
ASSERT_STATE(expected_state, conn);
|
||||
|
||||
// reset the transmitter
|
||||
LOG(LVL_INFO, ">>> Transmitter restart test");
|
||||
|
||||
connection_restart_tx(&conn);
|
||||
expected_state.next_packet_index = 0;
|
||||
|
||||
|
|
@ -421,6 +423,8 @@ int main(void)
|
|||
ASSERT_EQUAL_UINT(7, payload[1]);
|
||||
|
||||
// enqueue 10 more packets to test the sequence number overflow.
|
||||
LOG(LVL_INFO, ">>> Testing sequence number overflow");
|
||||
|
||||
for(size_t i = 0; i < 10; i++) {
|
||||
payload_len = 201;
|
||||
static_payload[0] = i;
|
||||
|
|
@ -463,7 +467,7 @@ int main(void)
|
|||
|
||||
ASSERT_STATE(expected_state, conn);
|
||||
|
||||
LOG(LVL_INFO, "Queue overflow test:");
|
||||
LOG(LVL_INFO, ">>> Queue overflow test:");
|
||||
|
||||
// nothing has been acknowledged so far, so we have 11 packets in the queue.
|
||||
// It must be possible to add 4 more packets, but the 5th must fail.
|
||||
|
|
@ -506,6 +510,20 @@ int main(void)
|
|||
|
||||
ASSERT_STATE(expected_state, conn);
|
||||
|
||||
// Regression test: in the past, the program crashed if a packet with 1
|
||||
// byte was decoded and passed to the connection instance. This can only
|
||||
// happen due to decoder errors, because valid packets must contain at
|
||||
// least the CRC which is 2 bytes large already.
|
||||
LOG(LVL_INFO, ">>> Regression test: 1-byte packets must be handled correctly.");
|
||||
|
||||
// build corrupted packet
|
||||
packet_buf[0] = 0x23;
|
||||
packet_len = 1;
|
||||
|
||||
result_t result = connection_handle_packet(&conn, packet_buf, packet_len, &data_packet, &tx_req_rcvd);
|
||||
|
||||
ASSERT_RESULT(ERR_INTEGRITY, result);
|
||||
|
||||
// TODO: test connection close sequence
|
||||
|
||||
LOG(LVL_INFO, ">>> All assertions successful.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue