Skip to content

Commit dbc8eaa

Browse files
nordic-seglaescolar
authored andcommitted
tests: drivers: can: api: Add negative test for can_add_rx_filter()
Check that error is reported when CAN filter is added without callback function. Signed-off-by: Sebastian Głąb <[email protected]>
1 parent f087f52 commit dbc8eaa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/drivers/can/api/src/classic.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,19 @@ ZTEST(can_classic, test_add_filter)
615615
can_remove_rx_filter(can_dev, filter_id);
616616
}
617617

618+
/**
619+
* @brief Test adding filter without callback.
620+
*/
621+
ZTEST(can_classic, test_add_filter_without_callback)
622+
{
623+
int err;
624+
625+
Z_TEST_SKIP_IFNDEF(CONFIG_RUNTIME_ERROR_CHECKS);
626+
627+
err = can_add_rx_filter(can_dev, NULL, NULL, &test_std_filter_1);
628+
zassert_equal(err, -EINVAL, "added filter with NULL callback");
629+
}
630+
618631
/**
619632
* @brief Test adding an invalid CAN RX filter.
620633
*

0 commit comments

Comments
 (0)