tests: drivers: can: move tests for too high bitrates to API test suite
Move the tests for setting a too high bitrate from the CAN timing tests to the CAN API tests as these are validating basic API behavior. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
8ccccbbb88
commit
fa00a73e76
|
@ -392,6 +392,32 @@ ZTEST_USER(canfd, test_set_timing_data_min)
|
|||
zassert_equal(err, 0, "failed to start CAN controller (err %d)", err);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test setting a too high data phase bitrate.
|
||||
*/
|
||||
ZTEST_USER(canfd, test_set_bitrate_too_high)
|
||||
{
|
||||
uint32_t max = 8000000U;
|
||||
int expected = -EINVAL;
|
||||
int err;
|
||||
|
||||
err = can_get_max_bitrate(can_dev, &max);
|
||||
if (err != -ENOSYS) {
|
||||
zassert_equal(err, 0, "failed to get max bitrate (err %d)", err);
|
||||
zassert_not_equal(max, 0, "max bitrate is 0");
|
||||
expected = -ENOTSUP;
|
||||
}
|
||||
|
||||
err = can_stop(can_dev);
|
||||
zassert_equal(err, 0, "failed to stop CAN controller (err %d)", err);
|
||||
|
||||
err = can_set_bitrate_data(can_dev, max + 1);
|
||||
zassert_equal(err, expected, "too high data phase bitrate accepted");
|
||||
|
||||
err = can_start(can_dev);
|
||||
zassert_equal(err, 0, "failed to start CAN controller (err %d)", err);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test that the maximum timing values for the data phase can be set.
|
||||
*/
|
||||
|
|
|
@ -502,22 +502,22 @@ ZTEST_USER(can_classic, test_bitrate_limits)
|
|||
*/
|
||||
ZTEST_USER(can_classic, test_set_bitrate_too_high)
|
||||
{
|
||||
uint32_t max = 0U;
|
||||
uint32_t max = 1000000U;
|
||||
int expected = -EINVAL;
|
||||
int err;
|
||||
|
||||
err = can_get_max_bitrate(can_dev, &max);
|
||||
if (err == -ENOSYS) {
|
||||
ztest_test_skip();
|
||||
if (err != -ENOSYS) {
|
||||
zassert_equal(err, 0, "failed to get max bitrate (err %d)", err);
|
||||
zassert_not_equal(max, 0, "max bitrate is 0");
|
||||
expected = -ENOTSUP;
|
||||
}
|
||||
|
||||
zassert_equal(err, 0, "failed to get max bitrate (err %d)", err);
|
||||
zassert_not_equal(max, 0, "max bitrate is 0");
|
||||
|
||||
err = can_stop(can_dev);
|
||||
zassert_equal(err, 0, "failed to stop CAN controller (err %d)", err);
|
||||
|
||||
err = can_set_bitrate(can_dev, max + 1);
|
||||
zassert_equal(err, -ENOTSUP, "too high bitrate accepted");
|
||||
zassert_equal(err, expected, "too high bitrate accepted");
|
||||
|
||||
err = can_start(can_dev);
|
||||
zassert_equal(err, 0, "failed to start CAN controller (err %d)", err);
|
||||
|
|
|
@ -50,8 +50,6 @@ static const struct can_timing_test can_timing_tests[] = {
|
|||
{ 125000, 800, false },
|
||||
/** Valid bitrate, invalid sample point. */
|
||||
{ 125000, 1000, true },
|
||||
/** Invalid classic/arbitration bitrate, valid sample point. */
|
||||
{ 1000000 + 1, 750, true },
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -67,8 +65,6 @@ static const struct can_timing_test can_timing_data_tests[] = {
|
|||
{ 500000, 800, false },
|
||||
/** Valid bitrate, invalid sample point. */
|
||||
{ 500000, 1000, true },
|
||||
/** Invalid CAN FD bitrate, valid sample point. */
|
||||
{ 8000000 + 1, 750, true },
|
||||
};
|
||||
#endif /* CONFIG_CAN_FD_MODE */
|
||||
|
||||
|
|
Loading…
Reference in a new issue