[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250428-enable-rtc-v4-3-2b2f7e3f9349@baylibre.com>
Date: Mon, 28 Apr 2025 12:06:49 +0200
From: amergnat@...libre.com
To: Alexandre Belloni <alexandre.belloni@...tlin.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>
Cc: Uwe Kleine-König <u.kleine-koenig@...libre.com>,
linux-rtc@...r.kernel.org, linux-kernel@...r.kernel.org,
Alexandre Mergnat <amergnat@...libre.com>
Subject: [PATCH v4 3/5] rtc: test: Emit the seconds-since-1970 value
instead of days-since-1970
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
This is easier to handle because you can just consult date(1) to convert
between a seconds-since-1970 value and a date string:
$ date --utc -d @3661
Thu Jan 1 01:01:01 AM UTC 1970
$ date -d "Jan 1 12:00:00 AM UTC 1900" +%s
-2208988800
The intended side effect is that this prepares the test for dates before
1970. The division of a negative value by 86400 doesn't result in the
desired days-since-1970 value as e.g. secs=-82739 should map to days=-1.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...libre.com>
Signed-off-by: Alexandre Mergnat <amergnat@...libre.com>
---
drivers/rtc/lib_test.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/rtc/lib_test.c b/drivers/rtc/lib_test.c
index c30c759662e39b48e6fedd37073b656e0de1336b..c0faddc04c9bbcd421cbdc030c4a073056c6a9a6 100644
--- a/drivers/rtc/lib_test.c
+++ b/drivers/rtc/lib_test.c
@@ -46,16 +46,13 @@ static void rtc_time64_to_tm_test_date_range(struct kunit *test, int years)
struct rtc_time result;
time64_t secs;
- s64 days;
for (secs = 0; secs <= total_secs; secs += 86400) {
rtc_time64_to_tm(secs, &result);
- days = div_s64(secs, 86400);
-
#define FAIL_MSG "%d/%02d/%02d (%2d) : %lld", \
- year, month, mday, yday, days
+ year, month, mday, yday, secs
KUNIT_ASSERT_EQ_MSG(test, year - 1900, result.tm_year, FAIL_MSG);
KUNIT_ASSERT_EQ_MSG(test, month - 1, result.tm_mon, FAIL_MSG);
--
2.25.1
Powered by blists - more mailing lists