diff options
author | Craig Hesling <hesling@chromium.org> | 2021-07-26 19:19:28 -0400 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-27 21:59:25 +0000 |
commit | c1d7b514a13a1c794fefdaeac2cc23e2b7be50b4 (patch) | |
tree | 3a45ff14e358153c6def00a5be27c9874c9c1d5d /test | |
parent | c7e06191a4042367afe69293a0650234864ec697 (diff) | |
download | chrome-ec-c1d7b514a13a1c794fefdaeac2cc23e2b7be50b4.tar.gz |
test/stm32f_rtc: Allow real rtc delay to be early
The current check for if the RTC delay is within 1ms, only accounts
for actual delays that exceed 500ms.
This doesn't seem right, since you would rather wake up early than late.
This change allows the RTC delay to be early or late by the tolerance
window.
I have also tightened the tolerance window to +/- 500us.
BRANCH=none
BUG=b:194720920
TEST=# Repeat the following test 10 times
./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc
TEST=# Disable CONFIG_LOW_POWER_IDLE
# Repeat the following test 10 times
./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc
TEST=# Disable CONFIG_LOW_POWER_IDLE and comment out idle loop "wfi"
# instruction.
# Repeat the following test 10 times
./test/run_device_tests.py --board bloonchipper --tests stm32f_rtc
Signed-off-by: Craig Hesling <hesling@chromium.org>
Change-Id: I68505c4011d9e12d54ed2630975a5b3be42ba6f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3055119
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/stm32f_rtc.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/stm32f_rtc.c b/test/stm32f_rtc.c index 4a09085e4f..f2731ad9d3 100644 --- a/test/stm32f_rtc.c +++ b/test/stm32f_rtc.c @@ -10,6 +10,12 @@ static uint32_t rtc_fired; static struct rtc_time_reg rtc_irq; static const int rtc_delay_ms = 500; +/* + * We will be testing that the RTC interrupt timestamp occurs + * within +/- delay_tol_us (tolerance) of the above rtc_delay_ms. + */ +static const int delay_tol_us = MSEC / 2; + /* Override default RTC interrupt handler */ void __rtc_alarm_irq(void) { @@ -21,7 +27,6 @@ test_static int test_rtc_alarm(void) { struct rtc_time_reg rtc; uint32_t rtc_diff_us; - uint32_t rtc_diff_ms; const int delay_us = rtc_delay_ms * MSEC; set_rtc_alarm(0, delay_us, &rtc, 0); @@ -33,13 +38,17 @@ test_static int test_rtc_alarm(void) rtc_diff_us = get_rtc_diff(&rtc, &rtc_irq); - ccprintf("rtc_diff_us: %d\n", rtc_diff_us); + ccprintf("Target delay was %dus\n", delay_us); + ccprintf("Actual delay was %dus\n", rtc_diff_us); + ccprintf("The delays are expected to be within +/- %dus\n", MSEC / 2); - /* Assume we'll always fire within 1 ms. May need to be adjusted if + /* Assume we'll always fire within 500us. May need to be adjusted if * this doesn't hold. + * + * delay_us-delay_tol_us < rtc_diff_us < delay_us+delay_tol_us */ - rtc_diff_ms = rtc_diff_us / MSEC; - TEST_EQ(rtc_diff_ms, rtc_delay_ms, "%d"); + TEST_LT(delay_us - delay_tol_us, rtc_diff_us, "%dus"); + TEST_LT(rtc_diff_us, delay_us + delay_tol_us, "%dus"); return EC_SUCCESS; } |