Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: kernel: timer_behaviour shouldn't use fabs #83815

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RobinKastberg
Copy link
Contributor

@RobinKastberg RobinKastberg commented Jan 10, 2025

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 kernel tests either.

To reproduce

scripts/twister -p qemu_cortex_m0 -T tests/kernel/timer/timer_behavior/ -x CONFIG_MINIMAL_LIBC=y
[...]
/workdir/zephyr/tests/kernel/timer/timer_behavior/src/jitter_drift.c: In function 'do_test_using':
/workdir/zephyr/tests/kernel/timer/timer_behavior/src/jitter_drift.c:336:22: error: implicit declaration of function 'fabs'; did you mean 'labs'? [-Werror=implicit-function-declaration]
  336 |         zassert_true(fabs(time_diff_us) < CONFIG_TIMER_TEST_MAX_DRIFT,
[...]

I am unsure if this is the "correctest" solution, but since it is simple and makes the test work in strictly more cases I think it should be fine?

There are tests FORCING minimal libc on similar kernel tests, possibly to uncover similar issues. Should I add it to this test as well?

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 <robin.kastberg@iar.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants