diff options
| author | Jani Nikula <jani.nikula@intel.com> | 2025-06-09 12:40:46 +0300 | 
|---|---|---|
| committer | Jani Nikula <jani.nikula@intel.com> | 2025-06-09 12:40:46 +0300 | 
| commit | 34c55367af96f62e89221444f04487440ebc6487 (patch) | |
| tree | fdb36ba67d7dea09455b55037e26043b7e051ef9 /drivers/rtc/lib_test.c | |
| parent | 7247efca0dcbc8ac6147db9200ed1549c0662465 (diff) | |
| parent | 19272b37aa4f83ca52bdf9c16d5d81bdd1354494 (diff) | |
| download | linux-34c55367af96f62e89221444f04487440ebc6487.tar.xz | |
Merge drm/drm-next into drm-intel-next
Sync to v6.16-rc1, among other things to get the fixed size GENMASK_U*()
and BIT_U*() macros.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'drivers/rtc/lib_test.c')
| -rw-r--r-- | drivers/rtc/lib_test.c | 27 | 
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/rtc/lib_test.c b/drivers/rtc/lib_test.c index c30c759662e3..0eebad1fe2a0 100644 --- a/drivers/rtc/lib_test.c +++ b/drivers/rtc/lib_test.c @@ -6,8 +6,10 @@  /*   * Advance a date by one day.   */ -static void advance_date(int *year, int *month, int *mday, int *yday) +static void advance_date(int *year, int *month, int *mday, int *yday, int *wday)  { +	*wday = (*wday + 1) % 7; +  	if (*mday != rtc_month_days(*month - 1, *year)) {  		++*mday;  		++*yday; @@ -39,35 +41,38 @@ static void rtc_time64_to_tm_test_date_range(struct kunit *test, int years)  	 */  	time64_t total_secs = ((time64_t)years) / 400 * 146097 * 86400; -	int year	= 1970; +	int year	= 1900;  	int month	= 1;  	int mday	= 1;  	int yday	= 1; +	int wday	= 1; /* Jan 1st 1900 was a Monday */  	struct rtc_time result;  	time64_t secs; -	s64 days; +	const time64_t sec_offset = RTC_TIMESTAMP_BEGIN_1900 + ((1 * 60) + 2) * 60 + 3;  	for (secs = 0; secs <= total_secs; secs += 86400) { -		rtc_time64_to_tm(secs, &result); - -		days = div_s64(secs, 86400); +		rtc_time64_to_tm(secs + sec_offset, &result); -		#define FAIL_MSG "%d/%02d/%02d (%2d) : %lld", \ -			year, month, mday, yday, days +		#define FAIL_MSG "%d/%02d/%02d (%2d, %d) : %lld", \ +			year, month, mday, yday, wday, secs + sec_offset  		KUNIT_ASSERT_EQ_MSG(test, year - 1900, result.tm_year, FAIL_MSG);  		KUNIT_ASSERT_EQ_MSG(test, month - 1, result.tm_mon, FAIL_MSG);  		KUNIT_ASSERT_EQ_MSG(test, mday, result.tm_mday, FAIL_MSG);  		KUNIT_ASSERT_EQ_MSG(test, yday, result.tm_yday, FAIL_MSG); +		KUNIT_ASSERT_EQ_MSG(test, 1, result.tm_hour, FAIL_MSG); +		KUNIT_ASSERT_EQ_MSG(test, 2, result.tm_min, FAIL_MSG); +		KUNIT_ASSERT_EQ_MSG(test, 3, result.tm_sec, FAIL_MSG); +		KUNIT_ASSERT_EQ_MSG(test, wday, result.tm_wday, FAIL_MSG); -		advance_date(&year, &month, &mday, &yday); +		advance_date(&year, &month, &mday, &yday, &wday);  	}  }  /* - * Checks every day in a 160000 years interval starting on 1970-01-01 + * Checks every day in a 160000 years interval starting on 1900-01-01   * against the expected result.   */  static void rtc_time64_to_tm_test_date_range_160000(struct kunit *test) @@ -76,7 +81,7 @@ static void rtc_time64_to_tm_test_date_range_160000(struct kunit *test)  }  /* - * Checks every day in a 1000 years interval starting on 1970-01-01 + * Checks every day in a 1000 years interval starting on 1900-01-01   * against the expected result.   */  static void rtc_time64_to_tm_test_date_range_1000(struct kunit *test)  | 
