Skip to content

Commit e725b4c

Browse files
committed
RTC time conversion test - reduce number of tested years in order to reduce test execution time.
For each of the following years test example time of the first and last day of each month: - first - 1970 - example not leap year (not divisible by 4) - example leap year (divisible by 4 and by 100 and by 400) - example leap year (divisible by 4 and not by 100) - example not leap year (divisible by 4 and by 100) - last fully supported - 2105 Test execution time on K64F is now ~39 sec.
1 parent af9e073 commit e725b4c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

TESTS/host_tests/rtc_calc_auto.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ class RTC_time_calc_test(BaseHostTest):
4747

4848
edge_date = datetime.datetime(2100, 2, 28, 0, 0, 0)
4949

50-
years = [1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980,
51-
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
52-
2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106]
50+
# Test the following years:
51+
# - first - 1970
52+
# - example not leap year (not divisible by 4)
53+
# - example leap year (divisible by 4 and by 100 and by 400)
54+
# - example leap year (divisible by 4 and not by 100)
55+
# - example not leap year (divisible by 4 and by 100)
56+
# - last fully supported - 2105
57+
years = [1970, 1971, 2000, 2096, 2100, 2105]
5358
year_id = 0
5459

5560

@@ -123,16 +128,13 @@ def _verify_timestamp(self, key, value, timestamp):
123128
self.date += datetime.timedelta(days = 1)
124129
if (self.date.month == 1):
125130
self.year_id += 1
131+
if (len(self.years) == self.year_id):
132+
# All years were processed, no need to calc next date
133+
return
126134
self.date = self.date.replace(year = self.years[self.year_id])
127135
self.date = self.date.replace(day = 1, minute = 0, second = 0)
128136
self.first = not self.first
129137

130138
def setup(self):
131139
self.register_callback('timestamp', self._verify_timestamp)
132140
self.register_callback('leap_year_setup', self._set_leap_year_support)
133-
134-
def result(self):
135-
return self.__result
136-
137-
def teardown(self):
138-
pass

TESTS/mbed_hal/rtc_time_conv/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ void test_case_mktime_localtime()
8383
char _value[128] =
8484
{ };
8585

86-
size_t years[] = {70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
87-
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
88-
199, 200, 201, 202, 203, 204, 205};
86+
size_t years[] = {70, 71, 100, 196, 200, 205};
8987

9088
/* Inform host part of the test about tested RTC type. */
9189
greentea_send_kv("leap_year_setup", rtc_leap_year_support);

0 commit comments

Comments
 (0)