Skip to content

Commit 4635192

Browse files
ukleinekalexandrebelloni
authored andcommitted
rtc: test: Emit the seconds-since-1970 value instead of days-since-1970
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 <[email protected]> Signed-off-by: Alexandre Mergnat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent fe9f5f9 commit 4635192

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/rtc/lib_test.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ static void rtc_time64_to_tm_test_date_range(struct kunit *test, int years)
4646

4747
struct rtc_time result;
4848
time64_t secs;
49-
s64 days;
5049

5150
for (secs = 0; secs <= total_secs; secs += 86400) {
5251

5352
rtc_time64_to_tm(secs, &result);
5453

55-
days = div_s64(secs, 86400);
56-
5754
#define FAIL_MSG "%d/%02d/%02d (%2d) : %lld", \
58-
year, month, mday, yday, days
55+
year, month, mday, yday, secs
5956

6057
KUNIT_ASSERT_EQ_MSG(test, year - 1900, result.tm_year, FAIL_MSG);
6158
KUNIT_ASSERT_EQ_MSG(test, month - 1, result.tm_mon, FAIL_MSG);

0 commit comments

Comments
 (0)