@@ -169,13 +169,41 @@ void test_local_time_invalid_param()
169
169
TEST_ASSERT_EQUAL (false , _rtc_localtime (1 , NULL , RTC_4_YEAR_LEAP_YEAR_SUPPORT));
170
170
}
171
171
172
+ /* Test set_time() function called a few seconds apart.
173
+ *
174
+ * Given is set_time() function.
175
+ * When set_time() is used to set the system time two times.
176
+ * Then if the value returned from time() is always correct return true, otherwise return false.
177
+ */
178
+ #define NEW_TIME 15
179
+ void test_set_time_twice ()
180
+ {
181
+ time_t current_time;
182
+
183
+ /* Set the time to NEW_TIME and check it */
184
+ set_time (NEW_TIME);
185
+ current_time = time (NULL );
186
+ TEST_ASSERT_EQUAL (true , (current_time == NEW_TIME));
187
+
188
+ /* Wait 2 seconds */
189
+ wait_ms (2000 );
190
+
191
+ /* set the time to NEW_TIME again and check it */
192
+ set_time (NEW_TIME);
193
+ current_time = time (NULL );
194
+ TEST_ASSERT_EQUAL (true , (current_time == NEW_TIME));
195
+ }
196
+
172
197
Case cases[] = {
173
198
Case (" test is leap year - RTC leap years full support" , test_is_leap_year<RTC_FULL_LEAP_YEAR_SUPPORT>),
174
199
Case (" test is leap year - RTC leap years partial support" , test_is_leap_year<RTC_4_YEAR_LEAP_YEAR_SUPPORT>),
175
200
Case (" test make time boundary values - RTC leap years full support" , test_mk_time_boundary<RTC_FULL_LEAP_YEAR_SUPPORT>),
176
201
Case (" test make time boundary values - RTC leap years partial support" , test_mk_time_boundary<RTC_4_YEAR_LEAP_YEAR_SUPPORT>),
177
202
Case (" test make time - invalid param" , test_mk_time_invalid_param),
178
203
Case (" test local time - invalid param" , test_local_time_invalid_param),
204
+ #if DEVICE_RTC || DEVICE_LPTICKER
205
+ Case (" test set_time twice" , test_set_time_twice),
206
+ #endif
179
207
};
180
208
181
209
utest::v1::status_t greentea_test_setup (const size_t number_of_cases)
0 commit comments