tests: drivers: can: api: add test for can_set_bitrate()

Add test for the can_set_bitrate() syscall.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-04-06 09:30:33 +02:00 committed by Marti Bolivar
parent d5f3f20edb
commit 77fa7709e4

View file

@ -15,6 +15,11 @@
* @}
*/
/**
* Test bitrate in bits/second.
*/
#define TEST_BITRATE 125000
/**
* @brief Test timeouts.
*/
@ -634,6 +639,17 @@ static void test_set_bitrate_too_high(void)
zassert_equal(err, -ENOTSUP, "too high bitrate accepted");
}
/**
* @brief Test setting bitrate.
*/
static void test_set_bitrate(void)
{
int err;
err = can_set_bitrate(can_dev, TEST_BITRATE, 0);
zassert_equal(err, 0, "failed to set bitrate");
}
/**
* @brief Test configuring the CAN controller for loopback mode.
*
@ -903,6 +919,7 @@ void test_main(void)
ztest_user_unit_test(test_get_core_clock),
ztest_unit_test(test_set_state_change_callback),
ztest_user_unit_test(test_set_bitrate_too_high),
ztest_user_unit_test(test_set_bitrate),
ztest_user_unit_test(test_set_loopback),
ztest_user_unit_test(test_send_and_forget),
ztest_unit_test(test_add_filter),