tests: timer: validate K_TIMEOUT_ABS_SEC

Validate that `K_TIMEOUT_ABS_SEC` works the same way as the other
absolute timeout construction macros.

Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
Jordan Yates 2025-04-03 11:45:44 +10:00 committed by Benjamin Cabé
commit 7a6f0a4928

View file

@ -749,16 +749,22 @@ ZTEST_USER(timer_api, test_timeout_abs)
k_timeout_t t = K_TIMEOUT_ABS_TICKS(exp_ticks), t2;
uint64_t t0, t1;
/* Ensure second alignment for K_TIMEOUT_ABS_SEC */
zassert_true(exp_ms % MSEC_PER_SEC == 0);
/* Check the other generator macros to make sure they produce
* the same (whiteboxed) converted values
*/
t2 = K_TIMEOUT_ABS_SEC(exp_ms / MSEC_PER_SEC);
zassert_true(t2.ticks == t.ticks);
t2 = K_TIMEOUT_ABS_MS(exp_ms);
zassert_true(t2.ticks == t.ticks);
t2 = K_TIMEOUT_ABS_US(1000 * exp_ms);
t2 = K_TIMEOUT_ABS_US(USEC_PER_MSEC * exp_ms);
zassert_true(t2.ticks == t.ticks);
t2 = K_TIMEOUT_ABS_NS(1000 * 1000 * exp_ms);
t2 = K_TIMEOUT_ABS_NS(NSEC_PER_MSEC * exp_ms);
zassert_true(t2.ticks == t.ticks);
t2 = K_TIMEOUT_ABS_CYC(k_ms_to_cyc_ceil64(exp_ms));