Skip to content

Commit 674fd64

Browse files
Raffael Rostagnohenrikbrixandersen
authored andcommitted
tests: drivers: counter: Configurable ticks tolerance
Make ticks tolerance configurable for chips which need a more relaxed value for testcase which assesses count precision. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent 1d2f012 commit 674fd64

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/drivers/counter/counter_basic_api/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,13 @@ config TEST_DRIVER_COUNTER_MCUX_LPC_RTC_HIGHRES
77
help
88
tests the nxp_lpc_rtc_highres compatible driver
99

10+
config TEST_DRIVER_COUNTER_TOLERANCE
11+
int "Counter ticks tolerance (%)"
12+
default 10
13+
help
14+
Error tolerance used in counter driver tests.
15+
A number of ticks is estimated and counter is tested against systimer,
16+
to verify accuracy. Tolerance is a percentage of deviation allowed for
17+
the number of expected ticks.
18+
1019
source "Kconfig.zephyr"

tests/drivers/counter/counter_basic_api/src/test_counter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,8 @@ static void test_valid_function_without_alarm(const struct device *dev)
744744
ticks_expected = counter_us_to_ticks(dev, wait_for_us);
745745
}
746746

747-
/* Set 10% or 2 ticks tolerance, whichever is greater */
748-
ticks_tol = ticks_expected / 10;
747+
/* Set percentage or 2 ticks tolerance, whichever is greater */
748+
ticks_tol = (ticks_expected * CONFIG_TEST_DRIVER_COUNTER_TOLERANCE) / 100;
749749
ticks_tol = ticks_tol < 2 ? 2 : ticks_tol;
750750

751751
err = counter_start(dev);

0 commit comments

Comments
 (0)