Skip to content

Commit 95c4633

Browse files
groeckalexandrebelloni
authored andcommitted
rtc: test: Split rtc unit test into slow and normal speed test
On slow systems, the rtc unit test may result in soft lockups and/or generate messages such as # rtc_time64_to_tm_test_date_range: Test should be marked slow (runtime: 34.253230015s) # rtc_time64_to_tm_test_date_range: pass:1 fail:0 skip:0 total:1 The test covers a date range of 160,000 years, resulting in the long runtime. Unit tests running for more than 1 second are supposed to be marked as slow. Just marking the test as slow would prevent it from running when slow tests are disabled, which would not be desirable. At the same time, the current test range of 160,000 years seems to be of limited value. Split the test into two parts, one covering a range of 1,000 years and the other covering the current range of 160,000 years. Mark the 160,000 year test as slow to be able to separate it from the faster test. Signed-off-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 7918a22 commit 95c4633

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

drivers/rtc/lib_test.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ static void advance_date(int *year, int *month, int *mday, int *yday)
2727
}
2828

2929
/*
30-
* Checks every day in a 160000 years interval starting on 1970-01-01
30+
* Check every day in specified number of years interval starting on 1970-01-01
3131
* against the expected result.
3232
*/
33-
static void rtc_time64_to_tm_test_date_range(struct kunit *test)
33+
static void rtc_time64_to_tm_test_date_range(struct kunit *test, int years)
3434
{
3535
/*
36-
* 160000 years = (160000 / 400) * 400 years
37-
* = (160000 / 400) * 146097 days
38-
* = (160000 / 400) * 146097 * 86400 seconds
36+
* years = (years / 400) * 400 years
37+
* = (years / 400) * 146097 days
38+
* = (years / 400) * 146097 * 86400 seconds
3939
*/
40-
time64_t total_secs = ((time64_t) 160000) / 400 * 146097 * 86400;
40+
time64_t total_secs = ((time64_t)years) / 400 * 146097 * 86400;
4141

4242
int year = 1970;
4343
int month = 1;
@@ -66,8 +66,27 @@ static void rtc_time64_to_tm_test_date_range(struct kunit *test)
6666
}
6767
}
6868

69+
/*
70+
* Checks every day in a 160000 years interval starting on 1970-01-01
71+
* against the expected result.
72+
*/
73+
static void rtc_time64_to_tm_test_date_range_160000(struct kunit *test)
74+
{
75+
rtc_time64_to_tm_test_date_range(test, 160000);
76+
}
77+
78+
/*
79+
* Checks every day in a 1000 years interval starting on 1970-01-01
80+
* against the expected result.
81+
*/
82+
static void rtc_time64_to_tm_test_date_range_1000(struct kunit *test)
83+
{
84+
rtc_time64_to_tm_test_date_range(test, 1000);
85+
}
86+
6987
static struct kunit_case rtc_lib_test_cases[] = {
70-
KUNIT_CASE(rtc_time64_to_tm_test_date_range),
88+
KUNIT_CASE(rtc_time64_to_tm_test_date_range_1000),
89+
KUNIT_CASE_SLOW(rtc_time64_to_tm_test_date_range_160000),
7190
{}
7291
};
7392

0 commit comments

Comments
 (0)