File tree Expand file tree Collapse file tree 1 file changed +8
-31
lines changed
testing/testsuites/kernel/fs/cases Expand file tree Collapse file tree 1 file changed +8
-31
lines changed Original file line number Diff line number Diff line change @@ -88,18 +88,9 @@ void test_nuttx_fs_stat01(FAR void **state)
8888
8989 struct tm * tm_1 = NULL ;
9090 struct tm * tm_2 = NULL ;
91- int year1 ;
92- int year2 ;
93- int month1 ;
94- int month2 ;
95- int day1 ;
96- int day2 ;
97- int hour1 ;
98- int hour2 ;
99- int min1 ;
100- int min2 ;
10191 time_t t_1 ;
10292 time_t t_2 ;
93+ time_t t_diff ;
10394 struct fs_testsuites_state_s * test_state ;
10495
10596 test_state = (struct fs_testsuites_state_s * )* state ;
@@ -127,14 +118,6 @@ void test_nuttx_fs_stat01(FAR void **state)
127118 tm_1 = gmtime (& t_1 );
128119 assert_non_null (tm_1 );
129120
130- /* set time */
131-
132- year1 = tm_1 -> tm_year ;
133- month1 = tm_1 -> tm_mon ;
134- day1 = tm_1 -> tm_mday ;
135- hour1 = tm_1 -> tm_hour ;
136- min1 = tm_1 -> tm_min ;
137-
138121 /* get file info */
139122
140123 ret = stat (TEST_FILE , & file_s );
@@ -144,23 +127,17 @@ void test_nuttx_fs_stat01(FAR void **state)
144127
145128 t_2 = file_s .st_mtime ;
146129 tm_2 = gmtime (& t_2 );
147-
148130 assert_non_null (tm_2 );
149131
150- /* set time */
132+ /* compare time */
133+
134+ t_diff = t_2 - t_1 ;
135+
136+ /* tolerance for 30s for worst case */
151137
152- year2 = tm_2 -> tm_year ;
153- month2 = tm_2 -> tm_mon ;
154- day2 = tm_2 -> tm_mday ;
155- hour2 = tm_2 -> tm_hour ;
156- min2 = tm_2 -> tm_min ;
138+ assert_int_in_range (t_diff , -30 , 30 );
157139
158- /* compare time and size */
140+ /* compare size */
159141
160- assert_int_equal (year1 , year2 );
161- assert_int_equal (month1 , month2 );
162- assert_int_equal (day1 , day2 );
163- assert_int_equal (hour1 , hour2 );
164- assert_int_equal (min1 , min2 );
165142 assert_int_equal (file_s .st_size , BUF_SIZE );
166143}
You can’t perform that action at this time.
0 commit comments