diff --git a/tests/drivers/rtc/rtc_api/src/test_alarm.c b/tests/drivers/rtc/rtc_api/src/test_alarm.c index dc224c9e465..c78f327513d 100644 --- a/tests/drivers/rtc/rtc_api/src/test_alarm.c +++ b/tests/drivers/rtc/rtc_api/src/test_alarm.c @@ -37,7 +37,7 @@ ZTEST(rtc_api, test_alarm) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_set_time(rtc, i, 0, NULL); - zassert_true(ret == 0, "Failed to clear alarm time"); + zassert_ok(ret, "Failed to clear alarm time"); } /* Disable alarm callback */ @@ -52,7 +52,7 @@ ZTEST(rtc_api, test_alarm) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_get_supported_fields(rtc, i, &alarm_time_mask_supported); - zassert_true(ret == 0, "Failed to get supported alarm fields"); + zassert_ok(ret, "Failed to get supported alarm fields"); /* Skip test if alarm does not support the minute and hour fields */ if (((RTC_ALARM_TIME_MASK_MINUTE & alarm_time_mask_supported) == 0) || @@ -69,23 +69,23 @@ ZTEST(rtc_api, test_alarm) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_set_time(rtc, i, alarm_time_mask_set, &alarm_time_set); - zassert_true(ret == 0, "Failed to set alarm time"); + zassert_ok(ret, "Failed to set alarm time"); } /* Validate alarm time */ for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_get_time(rtc, i, &alarm_time_mask_get, &alarm_time_get); - zassert_true(ret == 0, "Failed to set alarm time"); + zassert_ok(ret, "Failed to set alarm time"); - zassert_true(alarm_time_mask_get == alarm_time_mask_set, - "Incorrect alarm time mask"); + zassert_equal(alarm_time_mask_get, alarm_time_mask_set, + "Incorrect alarm time mask"); - zassert_true(alarm_time_get.tm_min == alarm_time_get.tm_min, - "Incorrect alarm time minute field"); + zassert_equal(alarm_time_get.tm_min, alarm_time_get.tm_min, + "Incorrect alarm time minute field"); - zassert_true(alarm_time_get.tm_hour == alarm_time_get.tm_hour, - "Incorrect alarm time hour field"); + zassert_equal(alarm_time_get.tm_hour, alarm_time_get.tm_hour, + "Incorrect alarm time hour field"); } /* Initialize RTC time to set */ @@ -100,7 +100,7 @@ ZTEST(rtc_api, test_alarm) /* Set RTC time */ ret = rtc_set_time(rtc, &time_set); - zassert_true(ret == 0, "Failed to set time"); + zassert_ok(ret, "Failed to set time"); /* Clear alarm pending status */ for (uint16_t i = 0; i < alarms_count; i++) { @@ -116,7 +116,7 @@ ZTEST(rtc_api, test_alarm) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_is_pending(rtc, i); - zassert_true(ret == 0, "Alarm should not be pending"); + zassert_ok(ret, "Alarm should not be pending"); } /* Wait for alarm to trigger */ @@ -126,7 +126,7 @@ ZTEST(rtc_api, test_alarm) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_is_pending(rtc, i); - zassert_true(ret == 1, "Alarm should be pending"); + zassert_equal(ret, 1, "Alarm should be pending"); } } @@ -134,7 +134,7 @@ ZTEST(rtc_api, test_alarm) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_set_time(rtc, i, 0, NULL); - zassert_true(ret == 0, "Failed to disable alarm"); + zassert_ok(ret, "Failed to disable alarm"); ret = rtc_alarm_is_pending(rtc, i); diff --git a/tests/drivers/rtc/rtc_api/src/test_alarm_callback.c b/tests/drivers/rtc/rtc_api/src/test_alarm_callback.c index 9dfa73eaace..c0eedd67e80 100644 --- a/tests/drivers/rtc/rtc_api/src/test_alarm_callback.c +++ b/tests/drivers/rtc/rtc_api/src/test_alarm_callback.c @@ -54,14 +54,14 @@ ZTEST(rtc_api, test_alarm_callback) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_set_callback(rtc, i, NULL, NULL); - zassert_true(ret == 0, "Failed to clear and disable alarm"); + zassert_ok(ret, "Failed to clear and disable alarm"); } /* Validate alarms supported fields */ for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_get_supported_fields(rtc, i, &alarm_time_mask_supported); - zassert_true(ret == 0, "Failed to get supported alarm fields"); + zassert_ok(ret, "Failed to get supported alarm fields"); /* Skip test if alarm does not support the minute and hour fields */ if (((RTC_ALARM_TIME_MASK_MINUTE & alarm_time_mask_supported) == 0) || @@ -78,7 +78,7 @@ ZTEST(rtc_api, test_alarm_callback) for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_set_time(rtc, i, alarm_time_mask_set, &alarm_time_set); - zassert_true(ret == 0, "Failed to set alarm time"); + zassert_ok(ret, "Failed to set alarm time"); } /* Initialize RTC time to set */ @@ -92,7 +92,7 @@ ZTEST(rtc_api, test_alarm_callback) /* Set RTC time */ ret = rtc_set_time(rtc, &time_set); - zassert_true(ret == 0, "Failed to set time"); + zassert_ok(ret, "Failed to set time"); /* Clear alarm pending status */ for (uint16_t i = 0; i < alarms_count; i++) { @@ -113,7 +113,7 @@ ZTEST(rtc_api, test_alarm_callback) &callback_user_data_even); } - zassert_true(ret == 0, "Failed to set alarm callback"); + zassert_ok(ret, "Failed to set alarm callback"); } for (uint8_t i = 0; i < 2; i++) { @@ -128,10 +128,10 @@ ZTEST(rtc_api, test_alarm_callback) callback_called_mask_status_odd = atomic_get(&callback_called_mask_odd); callback_called_mask_status_even = atomic_get(&callback_called_mask_even); - zassert_true(callback_called_mask_status_odd == 0, - "Alarm callback called prematurely"); - zassert_true(callback_called_mask_status_even == 0, - "Alarm callback called prematurely"); + zassert_equal(callback_called_mask_status_odd, 0, + "Alarm callback called prematurely"); + zassert_equal(callback_called_mask_status_even, 0, + "Alarm callback called prematurely"); /* Wait for alarm to trigger */ k_sleep(K_SECONDS(RTC_TEST_ALARM_TEST_CALLED_DELAY)); @@ -142,25 +142,25 @@ ZTEST(rtc_api, test_alarm_callback) (i % 2) ? atomic_test_bit(&callback_called_mask_odd, i) : atomic_test_bit(&callback_called_mask_even, i); - zassert_true(callback_called_status == true, - "Alarm callback should have been called"); + zassert_equal(callback_called_status, true, + "Alarm callback should have been called"); } /* Reset RTC time */ ret = rtc_set_time(rtc, &time_set); - zassert_true(ret == 0, "Failed to set time"); + zassert_ok(ret, "Failed to set time"); } /* Disable and clear alarms */ for (uint16_t i = 0; i < alarms_count; i++) { ret = rtc_alarm_set_callback(rtc, i, NULL, NULL); - zassert_true(ret == 0, "Failed to disable alarm callback"); + zassert_ok(ret, "Failed to disable alarm callback"); ret = rtc_alarm_set_time(rtc, i, 0, NULL); - zassert_true(ret == 0, "Failed to disable alarm"); + zassert_ok(ret, "Failed to disable alarm"); ret = rtc_alarm_is_pending(rtc, i); diff --git a/tests/drivers/rtc/rtc_api/src/test_calibrate.c b/tests/drivers/rtc/rtc_api/src/test_calibrate.c index 381f003ee0b..f0d89dc7973 100644 --- a/tests/drivers/rtc/rtc_api/src/test_calibrate.c +++ b/tests/drivers/rtc/rtc_api/src/test_calibrate.c @@ -28,12 +28,12 @@ static int test_set_get_calibration(int32_t calibrate_set) } /* Validate calibration was set */ - zassert_true(ret == 0, "Failed to set calibration"); + zassert_ok(ret, "Failed to set calibration"); ret = rtc_get_calibration(rtc, &calibrate_get); /* Validate calibration was gotten */ - zassert_true(ret == 0, "Failed to get calibration"); + zassert_ok(ret, "Failed to get calibration"); /* Print comparison between set and get values */ printk("Calibrate (set,get): %i, %i\n", calibrate_set, calibrate_get); @@ -51,12 +51,12 @@ ZTEST(rtc_api, test_set_get_calibration) ret = rtc_set_calibration(rtc, 0); /* Validate calibration was set */ - zassert_true(ret == 0, "Failed to set calibration"); + zassert_ok(ret, "Failed to set calibration"); ret = rtc_get_calibration(rtc, &calibrate_get); /* Validate calibration was gotten */ - zassert_true(ret == 0, "Failed to get calibration"); + zassert_ok(ret, "Failed to get calibration"); /* Validate edge values (0 already tested) */ test_set_get_calibration(1); diff --git a/tests/drivers/rtc/rtc_api/src/test_time.c b/tests/drivers/rtc/rtc_api/src/test_time.c index 832502d954b..5b8573e5919 100644 --- a/tests/drivers/rtc/rtc_api/src/test_time.c +++ b/tests/drivers/rtc/rtc_api/src/test_time.c @@ -29,10 +29,10 @@ ZTEST(rtc_api, test_set_get_time) memset(&datetime_get, 0xFF, sizeof(datetime_get)); - zassert_true(rtc_set_time(rtc, &datetime_set) == 0, "Failed to set time"); + zassert_equal(rtc_set_time(rtc, &datetime_set), 0, "Failed to set time"); - zassert_true(rtc_get_time(rtc, &datetime_get) == 0, - "Failed to get time using rtc_time_get()"); + zassert_equal(rtc_get_time(rtc, &datetime_get), 0, + "Failed to get time using rtc_time_get()"); zassert_true((datetime_get.tm_sec > -1) && (datetime_get.tm_sec < 60), "Invalid tm_sec"); @@ -55,7 +55,7 @@ ZTEST(rtc_api, test_set_get_time) zassert_true((datetime_get.tm_yday > -2) && (datetime_get.tm_yday < 366), "Invalid tm_yday"); - zassert_true((datetime_get.tm_isdst == -1), "Invalid tm_isdst"); + zassert_equal(datetime_get.tm_isdst, -1, "Invalid tm_isdst"); zassert_true((datetime_get.tm_nsec > -1) && (datetime_get.tm_yday < 1000000000), "Invalid tm_yday"); diff --git a/tests/drivers/rtc/rtc_api/src/test_time_incrementing.c b/tests/drivers/rtc/rtc_api/src/test_time_incrementing.c index b1680f2eca7..a5fccd9471b 100644 --- a/tests/drivers/rtc/rtc_api/src/test_time_incrementing.c +++ b/tests/drivers/rtc/rtc_api/src/test_time_incrementing.c @@ -29,11 +29,11 @@ ZTEST(rtc_api, test_time_counting) gmtime_r(&timer_set, (struct tm *)(&datetime_set)); - zassert_true(rtc_set_time(rtc, &datetime_set) == 0, "Failed to set time"); + zassert_equal(rtc_set_time(rtc, &datetime_set), 0, "Failed to set time"); for (i = 0; i < RTC_TEST_TIME_COUNTING_POLL_LIMIT; i++) { /* Get time */ - zassert_true(rtc_get_time(rtc, &datetime_get) == 0, "Failed to get time"); + zassert_equal(rtc_get_time(rtc, &datetime_get), 0, "Failed to get time"); timer_get = timeutil_timegm((struct tm *)(&datetime_get)); diff --git a/tests/drivers/rtc/rtc_api/src/test_update_callback.c b/tests/drivers/rtc/rtc_api/src/test_update_callback.c index d20ddb9eaea..6cddd3b045e 100644 --- a/tests/drivers/rtc/rtc_api/src/test_update_callback.c +++ b/tests/drivers/rtc/rtc_api/src/test_update_callback.c @@ -29,7 +29,7 @@ ZTEST(rtc_api, test_update_callback) ret = rtc_update_set_callback(rtc, NULL, NULL); - zassert_true(ret == 0, "Failed to clear and disable update callback"); + zassert_ok(ret, "Failed to clear and disable update callback"); atomic_set(&callback_called_counter, 0); @@ -37,11 +37,11 @@ ZTEST(rtc_api, test_update_callback) counter = atomic_get(&callback_called_counter); - zassert_true(counter == 0, "Update callback should not have been called"); + zassert_equal(counter, 0, "Update callback should not have been called"); ret = rtc_update_set_callback(rtc, test_rtc_update_callback_handler, &test_user_data); - zassert_true(ret == 0, "Failed to set and enable update callback"); + zassert_ok(ret, "Failed to set and enable update callback"); k_msleep(10000); @@ -51,5 +51,5 @@ ZTEST(rtc_api, test_update_callback) zassert_true(counter < 12 && counter > 8, "Invalid update callback called counter"); - zassert_true(address == ((uint32_t)(&test_user_data)), "Incorrect user data"); + zassert_equal(address, (uint32_t)(&test_user_data), "Incorrect user data"); } diff --git a/tests/drivers/rtc/rtc_api_helpers/src/test_rtc_time_to_tm.c b/tests/drivers/rtc/rtc_api_helpers/src/test_rtc_time_to_tm.c index bba11d79c94..93b1d3f09ea 100644 --- a/tests/drivers/rtc/rtc_api_helpers/src/test_rtc_time_to_tm.c +++ b/tests/drivers/rtc/rtc_api_helpers/src/test_rtc_time_to_tm.c @@ -10,32 +10,32 @@ ZTEST(rtc_api_helpers, test_validate_rtc_time_compat_with_tm) { - zassert(offsetof(struct rtc_time, tm_sec) == offsetof(struct tm, tm_sec), - "Offset of tm_sec in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_sec), offsetof(struct tm, tm_sec), + "Offset of tm_sec in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_min) == offsetof(struct tm, tm_min), - "Offset of tm_min in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_min), offsetof(struct tm, tm_min), + "Offset of tm_min in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_hour) == offsetof(struct tm, tm_hour), - "Offset of tm_hour in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_hour), offsetof(struct tm, tm_hour), + "Offset of tm_hour in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_mday) == offsetof(struct tm, tm_mday), - "Offset of tm_mday in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_mday), offsetof(struct tm, tm_mday), + "Offset of tm_mday in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_mon) == offsetof(struct tm, tm_mon), - "Offset of tm_mon in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_mon), offsetof(struct tm, tm_mon), + "Offset of tm_mon in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_year) == offsetof(struct tm, tm_year), - "Offset of tm_year in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_year), offsetof(struct tm, tm_year), + "Offset of tm_year in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_wday) == offsetof(struct tm, tm_wday), - "Offset of tm_wday in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_wday), offsetof(struct tm, tm_wday), + "Offset of tm_wday in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_yday) == offsetof(struct tm, tm_yday), - "Offset of tm_yday in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_yday), offsetof(struct tm, tm_yday), + "Offset of tm_yday in struct rtc_time does not match struct tm"); - zassert(offsetof(struct rtc_time, tm_isdst) == offsetof(struct tm, tm_isdst), - "Offset of tm_isdts in struct rtc_time does not match struct tm"); + zassert_equal(offsetof(struct rtc_time, tm_isdst), offsetof(struct tm, tm_isdst), + "Offset of tm_isdts in struct rtc_time does not match struct tm"); } ZTEST(rtc_api_helpers, test_validate_rtc_time_to_tm)