Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR to close #29 missing can isotp wait tx done flag to trigger a timeout #32

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Author

@muehlke muehlke Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added ENV_TpFree(srv); because for the test it is necessary that no server responds to the request so that we can get the desired timeout on the ISOTP socket. Because of the timeout error, the value of ret is <0, which was not the case before the flag was set on the socket.


// 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);
}