Skip to content

Commit 6ce4a46

Browse files
henrikbrixandersencarlescufi
authored andcommitted
tests: drivers: can: canfd: add capabilities test
Test that the CAN controller supports getting the supported capabilities. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent ced2126 commit 6ce4a46

File tree

1 file changed

+15
-0
lines changed
  • tests/drivers/can/canfd/src

1 file changed

+15
-0
lines changed

tests/drivers/can/canfd/src/main.c

+15
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,20 @@ static void send_receive(const struct zcan_filter *filter1,
339339
can_remove_rx_filter(can_dev, filter_id_2);
340340
}
341341

342+
/**
343+
* @brief Test getting the CAN controller capabilities.
344+
*/
345+
static void test_get_capabilities(void)
346+
{
347+
can_mode_t cap;
348+
int err;
349+
350+
err = can_get_capabilities(can_dev, &cap);
351+
zassert_equal(err, 0, "failed to get CAN capabilities (err %d)", err);
352+
zassert_not_equal(cap & (CAN_MODE_LOOPBACK | CAN_MODE_FD), 0,
353+
"CAN-FD loopback mode not supported");
354+
}
355+
342356
/**
343357
* @brief Test configuring the CAN controller for loopback mode.
344358
*
@@ -388,6 +402,7 @@ void test_main(void)
388402
zassert_true(device_is_ready(can_dev), "CAN device not ready");
389403

390404
ztest_test_suite(canfd_driver,
405+
ztest_unit_test(test_get_capabilities),
391406
ztest_unit_test(test_set_loopback),
392407
ztest_unit_test(test_send_receive_classic),
393408
ztest_unit_test(test_send_receive_fd),

0 commit comments

Comments
 (0)