Test rx an empty CAN messages.
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Fri, 3 Jan 2014 18:21:18 +0000 (13:21 -0500)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Fri, 3 Jan 2014 18:21:18 +0000 (13:21 -0500)
src/isotp/isotp.c
tests/test_receive.c

index 67a5df1..e233d38 100644 (file)
@@ -56,6 +56,9 @@ IsoTpMessage isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
             return message;
         }
     } else if(handle->type == ISOTP_HANDLE_SENDING) {
+        // TODO this will need to be tested when we add multi-frame support,
+        // which is when it'll be necessary to pass in CAN messages to SENDING
+        // handles.
         if(handle->send_handle.receiving_arbitration_id != arbitration_id) {
             if(shims->log != NULL) {
                 shims->log("The arb ID 0x%x doesn't match the expected tx continuation ID 0x%x",
index d8c2392..95afb94 100644 (file)
@@ -25,6 +25,16 @@ extern uint8_t last_message_sent_payload_size;
 
 extern void setup();
 
+START_TEST (test_receive_empty_can_message)
+{
+    const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0};
+    fail_if(HANDLE.completed);
+    IsoTpMessage message = isotp_receive_can_frame(&SHIMS, &HANDLE, 0x100, data, 0);
+    fail_if(message.completed);
+    fail_if(message_was_received);
+}
+END_TEST
+
 START_TEST (test_receive_wrong_id)
 {
     const uint8_t data[CAN_MESSAGE_BYTE_SIZE] = {0};
@@ -79,6 +89,7 @@ Suite* testSuite(void) {
     tcase_add_test(tc_core, test_receive_bad_pci);
     tcase_add_test(tc_core, test_receive_single_frame);
     tcase_add_test(tc_core, test_receive_single_frame_empty_payload);
+    tcase_add_test(tc_core, test_receive_empty_can_message);
     suite_add_tcase(s, tc_core);
 
     return s;