Skip to content

Commit

Permalink
tests: lib: c_lib: add a test for clock()
Browse files Browse the repository at this point in the history
Add a test for the ISO C `clock()` function, which has been
present since C89.

Signed-off-by: Christopher Friedt <[email protected]>
  • Loading branch information
cfriedt committed Aug 1, 2023
1 parent 84d5f6e commit c0c3b78
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/lib/c_lib/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,3 +1236,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_sleep(K_TICKS(1));
now = clock();
zassert_true(now > then);
}

0 comments on commit c0c3b78

Please sign in to comment.