-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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: timer_behavior: Tweak expected std deviation #74939
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
/* 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); | ||
|
||
TC_PRINT("timer clock rate %d, kernel tick rate %d\n", | ||
sys_clock_hw_cycles_per_sec(), CONFIG_SYS_CLOCK_TICKS_PER_SEC); | ||
|
@@ -283,7 +285,7 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan | |
", \"CONFIG_SYS_CLOCK_TICKS_PER_SEC\":%d" | ||
", \"CONFIG_TIMER_TEST_PERIOD\":%d" | ||
", \"CONFIG_TIMER_TEST_SAMPLES\":%d" | ||
", \"CONFIG_TIMER_TEST_MAX_STDDEV\":%d" | ||
", \"MAX STD DEV\":%d" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same recording output change should be in pytest/test_timer.py as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the record name is different now ? |
||
"}\n", | ||
mechanism, | ||
CONFIG_TIMER_TEST_SAMPLES - periodic_rollovers, periodic_rollovers, | ||
|
@@ -304,7 +306,7 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan | |
CONFIG_SYS_CLOCK_TICKS_PER_SEC, | ||
CONFIG_TIMER_TEST_PERIOD, | ||
CONFIG_TIMER_TEST_SAMPLES, | ||
CONFIG_TIMER_TEST_MAX_STDDEV | ||
max_stddev | ||
); | ||
|
||
/* Validate the maximum/minimum timer period is off by no more than 10% */ | ||
|
@@ -323,10 +325,11 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan | |
"Longest timer period too long (off by more than expected %d%)", | ||
CONFIG_TIMER_TEST_PERIOD_MAX_DRIFT_PERCENT); | ||
|
||
|
||
/* Validate the timer deviation (precision/jitter of the timer) is within a configurable | ||
* bound | ||
*/ | ||
zassert_true(stddev_us < (double)CONFIG_TIMER_TEST_MAX_STDDEV, | ||
zassert_true(stddev_us < (double)max_stddev, | ||
"Standard deviation (in microseconds) outside expected bound"); | ||
|
||
/* Validate the timer drift (accuracy over time) is within a configurable bound */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming whine: many platforms have cycle rates > 1MHz, making this value a zero. Giving it a name that looks and sounds like "cycles per microsecond" is likely to end up in a divide-by-zero as the code evolves. It's used as a clamp, so e.g. "
min_cyc = ...; /* Minimum possible cycles that can be measured */
' might be better?