Skip to content

Commit

Permalink
test(test_tp_compliance.c): add test for flow control frame timeout o…
Browse files Browse the repository at this point in the history
…n a client ISOTP socket with no responding server

With this test it can be assured that by having set the CAN_ISOTP_WAIT_TX_DONE flag on an ISOTP socket a communication error will be raised after trying to send a multi-frame request to an UDS server that will not send a FC frame within 1s.
  • Loading branch information
muehlke committed Jun 14, 2024
1 parent d16fe94 commit ddb42ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/test_tp_compliance.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,31 @@ void TestISOTPSendRecvMaxLen(void **state) {
assert_memory_equal(UDSTpGetRecvBuf(srv, NULL), MSG, sizeof(MSG));
}

void TestISOTPFlowControlFrameTimeout(void **state) {
if (!IsISOTP()) {
skip();
}

// killing server so that no response is sent to client
ENV_TpFree(srv);

// sending multiframe to wait for Flow Control frame
// which will not arrive since no server is running
const uint8_t MSG[] = {1, 2, 3, 4, 5, 6, 7, 8};
ssize_t ret = UDSTpSend(client, MSG, sizeof(MSG), NULL);

// failure is expected as the elapsed 1s timeout raises an error on the ISOTP socket
assert_true(ret < 0);
}

int main() {
const struct CMUnitTest tests[] = {
// cmocka_unit_test_setup_teardown(TestSendRecv, setup, teardown),
cmocka_unit_test_setup_teardown(TestSendRecvFunctional, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPSendLargestSingleFrame, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPSendLargerThanSingleFrameFails, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPSendRecvMaxLen, setup, teardown),
cmocka_unit_test_setup_teardown(TestISOTPFlowControlFrameTimeout, setup, teardown),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}

0 comments on commit ddb42ce

Please sign in to comment.