tests: libc: thrd: use timespec_from_timeout()
Use `timespec_from_timeout(K_MSEC(msec), &ts)` instead of leaning on lazily-crafted timespecs with invalid tv_nsec fields. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
a17497162e
commit
ec62630950
@ -10,6 +10,7 @@
|
||||
#include <threads.h>
|
||||
|
||||
#include <zephyr/sys_clock.h>
|
||||
#include <zephyr/sys/timeutil.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
static thrd_t thr;
|
||||
@ -32,7 +33,7 @@ ZTEST(libc_thrd, test_thrd_sleep)
|
||||
zassert_equal(thrd_success, thrd_sleep(&duration, &duration));
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(delay_ms); ++i) {
|
||||
duration = (struct timespec){.tv_nsec = delay_ms[i] * NSEC_PER_MSEC};
|
||||
timespec_from_timeout(K_MSEC(delay_ms[i]), &duration);
|
||||
remaining = (struct timespec){.tv_sec = 4242, .tv_nsec = 4242};
|
||||
|
||||
printk("sleeping %d ms\n", delay_ms[i]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user