From dfa3101d86ed327181bb3f1e948351467a36e024 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Thu, 11 May 2023 11:52:14 -0400 Subject: [PATCH] tests: lib: c_lib: add a test for clock() Add a test for the ISO C `clock()` function, which has been present since C89. Signed-off-by: Chris Friedt --- tests/lib/c_lib/src/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/lib/c_lib/src/main.c b/tests/lib/c_lib/src/main.c index f5365d493ea8723..31e53b319f2ec64 100644 --- a/tests/lib/c_lib/src/main.c +++ b/tests/lib/c_lib/src/main.c @@ -1229,3 +1229,14 @@ ZTEST(test_c_lib, test_exit) k_thread_abort(tid); zassert_equal(a, 0, "exit failed"); } + +ZTEST(test_c_lib, test_clock) +{ + clock_t then; + clock_t now; + + then = clock(); + k_usleep(USEC_PER_SEC); + now = clock(); + zassert_true(now > then); +}