Skip to content

Commit ced2126

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

File tree

1 file changed

+14
-0
lines changed
  • tests/drivers/can/api/src

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,19 @@ static void test_get_core_clock(void)
598598
zassert_not_equal(rate, 0, "CAN core clock rate is 0");
599599
}
600600

601+
/**
602+
* @brief Test getting the CAN controller capabilities.
603+
*/
604+
static void test_get_capabilities(void)
605+
{
606+
can_mode_t cap;
607+
int err;
608+
609+
err = can_get_capabilities(can_dev, &cap);
610+
zassert_equal(err, 0, "failed to get CAN capabilities (err %d)", err);
611+
zassert_not_equal(cap & CAN_MODE_LOOPBACK, 0, "CAN loopback mode not supported");
612+
}
613+
601614
/**
602615
* @brief CAN state change callback.
603616
*/
@@ -1009,6 +1022,7 @@ void test_main(void)
10091022
/* Tests without callbacks can run in userspace */
10101023
ztest_test_suite(can_api_tests,
10111024
ztest_user_unit_test(test_get_core_clock),
1025+
ztest_user_unit_test(test_get_capabilities),
10121026
ztest_unit_test(test_set_state_change_callback),
10131027
ztest_user_unit_test(test_set_bitrate_too_high),
10141028
ztest_user_unit_test(test_set_bitrate),

0 commit comments

Comments
 (0)