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 <sebastian.glab@nordicsemi.no>
diff --git a/tests/drivers/can/api/src/classic.c b/tests/drivers/can/api/src/classic.c
index b762137..c3e8501 100644
--- a/tests/drivers/can/api/src/classic.c
+++ b/tests/drivers/can/api/src/classic.c
@@ -616,6 +616,19 @@
}
/**
+ * @brief Test adding filter without callback.
+ */
+ZTEST(can_classic, test_add_filter_without_callback)
+{
+ int err;
+
+ Z_TEST_SKIP_IFNDEF(CONFIG_RUNTIME_ERROR_CHECKS);
+
+ err = can_add_rx_filter(can_dev, NULL, NULL, &test_std_filter_1);
+ zassert_equal(err, -EINVAL, "added filter with NULL callback");
+}
+
+/**
* @brief Test adding an invalid CAN RX filter.
*
* @param dev Pointer to the device structure for the driver instance.