@@ -35,6 +35,16 @@ static vfs_mount_t _test_spiffs_mount = {
3535 .private_data = & spiffs_desc ,
3636};
3737
38+ static void test_spiffs_teardown (void )
39+ {
40+ vfs_mount (& _test_spiffs_mount );
41+ vfs_unlink ("/test-spiffs/test.txt" );
42+ vfs_unlink ("/test-spiffs/test0.txt" );
43+ vfs_unlink ("/test-spiffs/test1.txt" );
44+ vfs_unlink ("/test-spiffs/a/test2.txt" );
45+ vfs_umount (& _test_spiffs_mount );
46+ }
47+
3848static void test_spiffs_mount_umount (void )
3949{
4050 int res ;
@@ -201,17 +211,13 @@ static void tests_spiffs_readdir(void)
201211 res = vfs_opendir (& dirp , "/test-spiffs" );
202212
203213 vfs_dirent_t entry ;
204- res = vfs_readdir (& dirp , & entry );
205- TEST_ASSERT (res == 1 );
206- TEST_ASSERT_EQUAL_STRING ("/test0.txt" , & (entry .d_name [0 ]));
207-
208- res = vfs_readdir (& dirp , & entry );
209- TEST_ASSERT (res == 1 );
210- TEST_ASSERT_EQUAL_STRING ("/test1.txt" , & (entry .d_name [0 ]));
211-
212- res = vfs_readdir (& dirp , & entry );
213- TEST_ASSERT (res == 1 );
214- TEST_ASSERT_EQUAL_STRING ("/a/test2.txt" , & (entry .d_name [0 ]));
214+ for (int i = 0 ; i < 3 ; i ++ ) {
215+ res = vfs_readdir (& dirp , & entry );
216+ TEST_ASSERT_EQUAL_INT (1 , res );
217+ TEST_ASSERT (strcmp ("/test0.txt" , & (entry .d_name [0 ])) == 0 ||
218+ strcmp ("/test1.txt" , & (entry .d_name [0 ])) == 0 ||
219+ strcmp ("/a/test2.txt" , & (entry .d_name [0 ])) == 0 );
220+ }
215221
216222 res = vfs_readdir (& dirp , & entry );
217223 TEST_ASSERT_EQUAL_INT (0 , res );
@@ -295,7 +301,7 @@ Test *tests_spiffs_tests(void)
295301 new_TestFixture (tests_spiffs_write2 ),
296302 };
297303
298- EMB_UNIT_TESTCALLER (spiffs_tests , NULL , NULL , fixtures );
304+ EMB_UNIT_TESTCALLER (spiffs_tests , NULL , test_spiffs_teardown , fixtures );
299305
300306 return (Test * )& spiffs_tests ;
301307}
0 commit comments