Skip to content

Commit 77fa770

Browse files
henrikbrixandersenmbolivar-nordic
authored andcommitted
tests: drivers: can: api: add test for can_set_bitrate()
Add test for the can_set_bitrate() syscall. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent d5f3f20 commit 77fa770

File tree

1 file changed

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

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
* @}
1616
*/
1717

18+
/**
19+
* Test bitrate in bits/second.
20+
*/
21+
#define TEST_BITRATE 125000
22+
1823
/**
1924
* @brief Test timeouts.
2025
*/
@@ -634,6 +639,17 @@ static void test_set_bitrate_too_high(void)
634639
zassert_equal(err, -ENOTSUP, "too high bitrate accepted");
635640
}
636641

642+
/**
643+
* @brief Test setting bitrate.
644+
*/
645+
static void test_set_bitrate(void)
646+
{
647+
int err;
648+
649+
err = can_set_bitrate(can_dev, TEST_BITRATE, 0);
650+
zassert_equal(err, 0, "failed to set bitrate");
651+
}
652+
637653
/**
638654
* @brief Test configuring the CAN controller for loopback mode.
639655
*
@@ -903,6 +919,7 @@ void test_main(void)
903919
ztest_user_unit_test(test_get_core_clock),
904920
ztest_unit_test(test_set_state_change_callback),
905921
ztest_user_unit_test(test_set_bitrate_too_high),
922+
ztest_user_unit_test(test_set_bitrate),
906923
ztest_user_unit_test(test_set_loopback),
907924
ztest_user_unit_test(test_send_and_forget),
908925
ztest_unit_test(test_add_filter),

0 commit comments

Comments
 (0)