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: Chris Friedt <[email protected]>
  • Loading branch information
cfriedt committed May 11, 2023
1 parent 6644b4c commit dfa3101
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 @@ -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);
}

0 comments on commit dfa3101

Please sign in to comment.