Skip to content

Commit 8d57429

Browse files
committed
tests-mbed_hal-rtc_time: alocate required test data on stack
This is fix for issue 8368. Test is causing some problems on `REALTEK_RTL8195AM` and `ARM` compiler. There is some kind of memory issue. Probably there is not enough memory space for global data provided by the test. Data definitions have been moved into test function body so, they will land on stack. With this fix the test works on `REALTEK_RTL8195AM/ARM`.
1 parent 06dffda commit 8d57429

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

TESTS/mbed_hal/rtc_time/main.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,6 @@ typedef struct {
7979
bool result;
8080
} test_mk_time_struct;
8181

82-
/* Array which contains data to test boundary values for the RTC devices which handles correctly leap years in
83-
* whole range (1970 - 2106).
84-
* Expected range: the 1st of January 1970 at 00:00:00 (seconds: 0) to the 7th of February 2106 at 06:28:15 (seconds: UINT_MAX).
85-
*/
86-
test_mk_time_struct test_mk_time_arr_full[] = {
87-
{{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00
88-
{{ 59, 59, 23, 31, 11, 59, 0, 0, 0 }, (time_t) 0, false }, // invalid lower bound - the 31st of December 1969 at 23:59:59
89-
90-
{{ 15, 28, 6, 7, 1, 206, 0, 0, 0 }, (time_t)(UINT_MAX), true }, // valid upper bound - the 7th of February 2106 at 06:28:15
91-
{{ 16, 28, 6, 7, 1, 206, 0, 0, 0 }, (time_t) 0, false }, // invalid upper bound - the 7th of February 2106 at 06:28:16
92-
};
93-
94-
/* Array which contains data to test boundary values for the RTC devices which does not handle correctly leap years in
95-
* whole range (1970 - 2106). On this platforms we will be one day off after 28.02.2100 since 2100 year will be
96-
* incorrectly treated as a leap year.
97-
* Expected range: the 1st of January 1970 at 00:00:00 (seconds: 0) to the 6th of February 2106 at 06:28:15 (seconds: UINT_MAX).
98-
*/
99-
test_mk_time_struct test_mk_time_arr_partial[] = {
100-
{{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00
101-
{{ 59, 59, 23, 31, 11, 59, 0, 0, 0 }, (time_t) 0, false }, // invalid lower bound - the 31st of December 1969 at 23:59:59
102-
103-
{{ 15, 28, 6, 6, 1, 206, 0, 0, 0 }, (time_t)(UINT_MAX), true }, // valid upper bound - the 6th of February 2106 at 06:28:15
104-
{{ 16, 28, 6, 6, 1, 206, 0, 0, 0 }, (time_t) 0, false }, // invalid upper bound - the 6th of February 2106 at 06:28:16
105-
};
106-
10782
/* Test boundary values for _rtc_maketime().
10883
*
10984
* Note: This test case is designed for both types of RTC devices:
@@ -120,6 +95,31 @@ void test_mk_time_boundary()
12095
{
12196
test_mk_time_struct *pTestCases;
12297

98+
/* Array which contains data to test boundary values for the RTC devices which handles correctly leap years in
99+
* whole range (1970 - 2106).
100+
* Expected range: the 1st of January 1970 at 00:00:00 (seconds: 0) to the 7th of February 2106 at 06:28:15 (seconds: UINT_MAX).
101+
*/
102+
test_mk_time_struct test_mk_time_arr_full[] = {
103+
{{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00
104+
{{ 59, 59, 23, 31, 11, 59, 0, 0, 0 }, (time_t) 0, false }, // invalid lower bound - the 31st of December 1969 at 23:59:59
105+
106+
{{ 15, 28, 6, 7, 1, 206, 0, 0, 0 }, (time_t)(UINT_MAX), true }, // valid upper bound - the 7th of February 2106 at 06:28:15
107+
{{ 16, 28, 6, 7, 1, 206, 0, 0, 0 }, (time_t) 0, false }, // invalid upper bound - the 7th of February 2106 at 06:28:16
108+
};
109+
110+
/* Array which contains data to test boundary values for the RTC devices which does not handle correctly leap years in
111+
* whole range (1970 - 2106). On this platforms we will be one day off after 28.02.2100 since 2100 year will be
112+
* incorrectly treated as a leap year.
113+
* Expected range: the 1st of January 1970 at 00:00:00 (seconds: 0) to the 6th of February 2106 at 06:28:15 (seconds: UINT_MAX).
114+
*/
115+
test_mk_time_struct test_mk_time_arr_partial[] = {
116+
{{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00
117+
{{ 59, 59, 23, 31, 11, 59, 0, 0, 0 }, (time_t) 0, false }, // invalid lower bound - the 31st of December 1969 at 23:59:59
118+
119+
{{ 15, 28, 6, 6, 1, 206, 0, 0, 0 }, (time_t)(UINT_MAX), true }, // valid upper bound - the 6th of February 2106 at 06:28:15
120+
{{ 16, 28, 6, 6, 1, 206, 0, 0, 0 }, (time_t) 0, false }, // invalid upper bound - the 6th of February 2106 at 06:28:16
121+
};
122+
123123
/* Select array with test cases. */
124124
if (rtc_leap_year_support == RTC_FULL_LEAP_YEAR_SUPPORT) {
125125
pTestCases = test_mk_time_arr_full;

0 commit comments

Comments
 (0)