selftests/rtc: continuously read RTC in a loop for 30s
authorMateusz Jończyk <mat.jonczyk@o2.pl>
Sat, 19 Feb 2022 07:27:13 +0000 (08:27 +0100)
committerShuah Khan <skhan@linuxfoundation.org>
Sat, 26 Feb 2022 00:00:51 +0000 (17:00 -0700)
commit2aaa36e95ea586ad23edfcc1d474e8b735a4d1c3
treea44a3c4d906f2e3e2006a6717a4e94f6c971bcdb
parent1900be289b598b2c553b3add13e491c0bb8a8550
selftests/rtc: continuously read RTC in a loop for 30s

Some problems with reading the RTC time may happen rarely, for example
while the RTC is updating. So read the RTC many times to catch these
problems. For example, a previous attempt for my
commit ea6fa4961aab ("rtc: mc146818-lib: fix RTC presence check")
was incorrect and would have triggered this selftest.

To avoid the risk of damaging the hardware, wait 11ms before consecutive
reads.

In rtc_time_to_timestamp I copied values manually instead of casting -
just to be on the safe side. The 11ms wait period was chosen so that it is
not a divisor of 1000ms.

Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/rtc/rtctest.c
tools/testing/selftests/rtc/settings