@@ -238,6 +238,45 @@ ZTEST(canfd, test_canfd_get_capabilities)
238238 "CAN FD loopback mode not supported" );
239239}
240240
241+ /**
242+ * @brief Test sending CAN FD frame with too big payload.
243+ */
244+ ZTEST (canfd , test_send_fd_dlc_out_of_range )
245+ {
246+ struct can_frame frame = {
247+ .flags = CAN_FRAME_FDF | CAN_FRAME_BRS ,
248+ .id = TEST_CAN_STD_ID_1 ,
249+ .dlc = CANFD_MAX_DLC + 1U ,
250+ };
251+ int err ;
252+
253+ Z_TEST_SKIP_IFNDEF (CONFIG_RUNTIME_ERROR_CHECKS );
254+
255+ err = can_send (can_dev , & frame , TEST_SEND_TIMEOUT , NULL , NULL );
256+ zassert_equal (err , - EINVAL , "wrong error on sending invalid frame (err %d)" , err );
257+ }
258+
259+ /**
260+ * @brief Test error when CAN FD Error State Indicator (ESI) is send without FD format flag (FDF).
261+ *
262+ * CAN FD Error State Indicator (ESI) indicates that the transmitting node is
263+ * in error-passive state. Only valid in combination with CAN_FRAME_FDF.
264+ */
265+ ZTEST (canfd , test_send_fd_incorrect_esi )
266+ {
267+ struct can_frame frame = {
268+ .flags = CAN_FRAME_ESI ,
269+ .id = TEST_CAN_STD_ID_1 ,
270+ .dlc = 0 ,
271+ };
272+ int err ;
273+
274+ Z_TEST_SKIP_IFNDEF (CONFIG_RUNTIME_ERROR_CHECKS );
275+
276+ err = can_send (can_dev , & frame , TEST_SEND_TIMEOUT , NULL , NULL );
277+ zassert_equal (err , - ENOTSUP , "wrong error on sending invalid frame (err %d)" , err );
278+ }
279+
241280/**
242281 * @brief Test send/receive with standard (11-bit) CAN IDs and classic CAN frames.
243282 */
0 commit comments