Skip to content

Commit

Permalink
tests: kernel: timer_behaviour shouldnt use fabs
Browse files Browse the repository at this point in the history
Currently the timer_behavior test uses fabs.
Since the C library functions being used in the kernel
is restricted in Rule A.4 in the Coding Standard
We should probably not use these functions in tests either.

Signed-off-by: Robin Kastberg <[email protected]>
  • Loading branch information
RobinKastberg authored and kartben committed Jan 14, 2025
1 parent 743fe63 commit 3f3c66f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/kernel/timer/timer_behavior/src/jitter_drift.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan
* CONFIG_TIMER_TEST_SAMPLES;
double time_diff_us = actual_time_us - expected_time_us
- expected_time_drift_us;
double time_diff_us_abs = time_diff_us >= 0.0 ? time_diff_us : -time_diff_us;

/* If max stddev is lower than a single clock cycle then round it up. */
uint32_t max_stddev = MAX(k_cyc_to_us_ceil32(1), CONFIG_TIMER_TEST_MAX_STDDEV);

Expand Down Expand Up @@ -333,7 +335,7 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan
"Standard deviation (in microseconds) outside expected bound");

/* Validate the timer drift (accuracy over time) is within a configurable bound */
zassert_true(fabs(time_diff_us) < CONFIG_TIMER_TEST_MAX_DRIFT,
zassert_true(time_diff_us_abs < CONFIG_TIMER_TEST_MAX_DRIFT,
"Drift (in microseconds) outside expected bound");
}

Expand Down

0 comments on commit 3f3c66f

Please sign in to comment.