-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: posix: test_realtime: improve test reliability
Previously posix_apis.test_realtime was failing (very) frequently in CI, and in particular, when running on Qemu, POSIX, or SMP targets. We are using CLOCK_REALTIME for this test, which incurs an additional syscall overhead above CLOCK_MONOTONIC. The act of sleeping itself also incurs a syscall overhead. The latency from one iteration to the next of the internal loop is a bit of a random process due to scheduler or clock noise (although the noise itself is still bounded). In order to make this test robust against such noise, assert only on the average time from one iteration to the next, rather than the instantaneous time. Rather than calculating a sample mean, use a running average (aka Cumulative Moving Average) to save some bytes. Report results, including low and high watermarks before asserting that the average iteration time within expected range. ============================================================== START - test_realtime I: n: 20, sleep: 100, margin: 10, lo: 110, avg: 110, hi: 110 PASS - test_realtime in 2.198 seconds ============================================================== Expect to see the low and high watermarks change more on Qemu and POSIX platforms when running several jobs in parallel with twister (such as in CI). Signed-off-by: Christopher Friedt <cfriedt@meta.com>
- Loading branch information
1 parent
95a22b1
commit 67a74e4
Showing
2 changed files
with
200 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2023, Meta | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Options specific to clock.c / test_realtime | ||
|
||
config TEST_CLOCK_RT_ITERATIONS | ||
int "Number of iterations to check clock_gettime() reliability" | ||
range 10 100 | ||
default 20 | ||
help | ||
This option is specific to posix_apis.test_realtime in clock.c | ||
|
||
config TEST_CLOCK_RT_SLEEP_MS | ||
int "Time to sleep between iterations in milliseconds" | ||
range 50 1000 | ||
default 100 | ||
help | ||
This option is specific to posix_apis.test_realtime in clock.c | ||
|
||
config TEST_CLOCK_RT_ERROR_MS | ||
int "Maximum overshoot (error) in milliseconds" | ||
range 10 500 | ||
default 10 | ||
help | ||
This option is specific to posix_apis.test_realtime in clock.c | ||
|
||
source "Kconfig.zephyr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters