* [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
@ 2022-05-11 2:16 Li Wang
2022-05-11 8:44 ` Cyril Hrubis
0 siblings, 1 reply; 7+ messages in thread
From: Li Wang @ 2022-05-11 2:16 UTC (permalink / raw)
To: ltp; +Cc: Eirik Fuller
That possibly has time elapse between the two operations, especially
on VM we can't guarantee the time precisely equal, let's lose a few
seconds to make the test happy:
tst_test.c:1433: TINFO: Timeout per run is 0h 10m 00s
rtc02.c:66: TINFO: To set RTC date/time is: 2020-10-09 13:23:30
rtc02.c:80: TINFO: read RTC date/time is: 2020-10-09 13:23:31
rtc02.c:83: TFAIL: RTC SET TEST
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Eirik Fuller <efuller@redhat.com>
Cc: Cyril Hrubis <chrubis@suse.cz>
---
Notes:
V3:
I'm also fine to go with only use seconds for hour/min/sec comparsing.
But that quite no necessary since most of time delta is zero.
testcases/kernel/device-drivers/rtc/rtc02.c | 54 ++++++++++++++++++---
1 file changed, 48 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/device-drivers/rtc/rtc02.c b/testcases/kernel/device-drivers/rtc/rtc02.c
index 0705357bb..dbac11b85 100644
--- a/testcases/kernel/device-drivers/rtc/rtc02.c
+++ b/testcases/kernel/device-drivers/rtc/rtc02.c
@@ -40,12 +40,54 @@ static char *rtctime_to_str(struct rtc_time *tm)
static int rtc_tm_cmp(struct rtc_time *set_tm, struct rtc_time *read_tm)
{
- return !((set_tm->tm_sec == read_tm->tm_sec)
- && (set_tm->tm_min == read_tm->tm_min)
- && (set_tm->tm_hour == read_tm->tm_hour)
- && (set_tm->tm_mday == read_tm->tm_mday)
- && (set_tm->tm_mon == read_tm->tm_mon)
- && (set_tm->tm_year == read_tm->tm_year));
+ long delta, seconds1, seconds2;
+
+ if (set_tm->tm_year != read_tm->tm_year)
+ return 1;
+
+ if (set_tm->tm_mon != read_tm->tm_mon)
+ return 1;
+
+ if (set_tm->tm_mday != read_tm->tm_mday)
+ return 1;
+
+ /*
+ * Convert hour/min/sec into seconds to handle the normal
+ * and special situations:
+ * 1#
+ * set_tm: 2022-04-28 13:00:50
+ * read_tm: 2022-04-28 13:00:50
+ * 2#
+ * set_tm: 2022-04-28 13:00:50
+ * read_tm: 2022-04-28 13:00:51
+ * 3#
+ * set_tm: 2022-04-28 13:00:59
+ * read_tm: 2022-04-28 13:01:00
+ * 4#
+ * set_tm: 2022-04-28 13:59:59
+ * read_tm: 2022-04-28 14:00:00
+ *
+ * Note: as we have avoided testing around the zero
+ * clock, so it's impossible to hit situation 5#
+ * set_tm: 2022-04-28 23:59:59
+ * read_tm: 2022-04-29 00:00:00
+ */
+ if ((set_tm->tm_hour != read_tm->tm_hour)
+ || (set_tm->tm_min != read_tm->tm_min)
+ || (set_tm->tm_sec != read_tm->tm_sec)) {
+
+ seconds1 = (set_tm->tm_hour * 3600) + (set_tm->tm_min * 60) + set_tm->tm_sec;
+ seconds2 = (read_tm->tm_hour * 3600) + (read_tm->tm_min * 60) + read_tm->tm_sec;
+
+ delta = seconds2 - seconds1;
+
+ if (delta < 0 || delta > 3) {
+ tst_res(TFAIL, "seconds1 is %ld, seconds2 is %ld", seconds1, seconds2);
+ return 1;
+ }
+ }
+
+ return 0;
}
static void set_rtc_test(void)
--
2.31.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
2022-05-11 2:16 [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds Li Wang
@ 2022-05-11 8:44 ` Cyril Hrubis
2022-05-11 9:48 ` Li Wang
0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2022-05-11 8:44 UTC (permalink / raw)
To: Li Wang; +Cc: Eirik Fuller, ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
2022-05-11 8:44 ` Cyril Hrubis
@ 2022-05-11 9:48 ` Li Wang
2022-05-12 14:04 ` Eirik Fuller
0 siblings, 1 reply; 7+ messages in thread
From: Li Wang @ 2022-05-11 9:48 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: Eirik Fuller, LTP List
[-- Attachment #1.1: Type: text/plain, Size: 49 bytes --]
Pushed, thanks for review.
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 260 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
2022-05-11 9:48 ` Li Wang
@ 2022-05-12 14:04 ` Eirik Fuller
2022-05-12 14:11 ` Li Wang
2022-05-12 14:14 ` Cyril Hrubis
0 siblings, 2 replies; 7+ messages in thread
From: Eirik Fuller @ 2022-05-12 14:04 UTC (permalink / raw)
To: Li Wang; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 145 bytes --]
Sorry to chime in late, but do we care about crossing day, month, or year
boundaries? For example, what if we write 23:59:59 and read 00:00:01 ?
[-- Attachment #1.2: Type: text/html, Size: 181 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
2022-05-12 14:04 ` Eirik Fuller
@ 2022-05-12 14:11 ` Li Wang
2022-05-12 14:24 ` Eirik Fuller
2022-05-12 14:14 ` Cyril Hrubis
1 sibling, 1 reply; 7+ messages in thread
From: Li Wang @ 2022-05-12 14:11 UTC (permalink / raw)
To: Eirik Fuller; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 532 bytes --]
On Thu, May 12, 2022 at 10:05 PM Eirik Fuller <efuller@redhat.com> wrote:
> Sorry to chime in late, but do we care about crossing day, month, or year
> boundaries? For example, what if we write 23:59:59 and read 00:00:01 ?
>
Good question Eirik, actually we have avoided that zero clocks.
It's impossible to get time crossing day/month/year (or 00:00:xx)
in the clock unless a new bug is happening.
See:
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/device-drivers/rtc/rtc02.c#L107
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 1555 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
2022-05-12 14:04 ` Eirik Fuller
2022-05-12 14:11 ` Li Wang
@ 2022-05-12 14:14 ` Cyril Hrubis
1 sibling, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2022-05-12 14:14 UTC (permalink / raw)
To: Eirik Fuller; +Cc: LTP List
Hi!
> Sorry to chime in late, but do we care about crossing day, month, or year
> boundaries? For example, what if we write 23:59:59 and read 00:00:01 ?
As far as I can tell we avoid that by either adding or subscribing an
hour from the current date.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds
2022-05-12 14:11 ` Li Wang
@ 2022-05-12 14:24 ` Eirik Fuller
0 siblings, 0 replies; 7+ messages in thread
From: Eirik Fuller @ 2022-05-12 14:24 UTC (permalink / raw)
To: Li Wang; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 183 bytes --]
> It's impossible to get time crossing day/month/year (or 00:00:xx)
> in the clock unless a new bug is happening.
Yes, sorry, I should have read the code before replying :)
Thanks!
[-- Attachment #1.2: Type: text/html, Size: 495 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-05-12 14:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 2:16 [LTP] [PATCH v3] rtc02: loosen the compare precision with few seconds Li Wang
2022-05-11 8:44 ` Cyril Hrubis
2022-05-11 9:48 ` Li Wang
2022-05-12 14:04 ` Eirik Fuller
2022-05-12 14:11 ` Li Wang
2022-05-12 14:24 ` Eirik Fuller
2022-05-12 14:14 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.