@@ -80,6 +80,7 @@ static const char *sd_testfile_path = "/sd/test.txt";
80
80
SDBlockDevice sd (MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
81
81
FATFileSystem fs (" sd" , &sd);
82
82
83
+ #define FSFAT_FOPEN_TEST_00 fsfat_fopen_test_00
83
84
#define FSFAT_FOPEN_TEST_01 fsfat_fopen_test_01
84
85
#define FSFAT_FOPEN_TEST_02 fsfat_fopen_test_02
85
86
#define FSFAT_FOPEN_TEST_03 fsfat_fopen_test_03
@@ -276,6 +277,26 @@ static int32_t fsfat_filepath_make_dirs(char *filepath, bool do_asserts)
276
277
return ret;
277
278
}
278
279
280
+ /* * @brief
281
+ * First and last test must format the SD card to FAT FS format:
282
+ * @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
283
+ */
284
+ control_t fsfat_fopen_test_00 (const size_t call_count)
285
+ {
286
+ FSFAT_FENTRYLOG (" %s:entered\n " , __func__);
287
+ (void ) call_count;
288
+ int32_t ret = -1 ;
289
+
290
+ fs.unmount ();
291
+ ret = fs.format (&sd);
292
+ FSFAT_TEST_UTEST_MESSAGE (fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE,
293
+ " %s:Error: failed to format sdcard (ret=%d)\n " , __func__, (int ) ret);
294
+ TEST_ASSERT_MESSAGE (ret == 0 , fsfat_fopen_utest_msg_g);
295
+ fs.mount (&sd);
296
+
297
+ return CaseNext;
298
+ }
299
+
279
300
280
301
/* FIX ME: errno not set correctly when error occurs. This indicates a problem with the implementation. */
281
302
@@ -1535,7 +1556,7 @@ control_t fsfat_fopen_test_16(const size_t call_count)
1535
1556
1536
1557
#else
1537
1558
1538
-
1559
+ # define FSFAT_FOPEN_TEST_00 fsfat_fopen_test_dummy
1539
1560
#define FSFAT_FOPEN_TEST_01 fsfat_fopen_test_dummy
1540
1561
#define FSFAT_FOPEN_TEST_02 fsfat_fopen_test_dummy
1541
1562
#define FSFAT_FOPEN_TEST_03 fsfat_fopen_test_dummy
@@ -1590,6 +1611,7 @@ utest::v1::status_t greentea_setup(const size_t number_of_cases)
1590
1611
Case cases[] = {
1591
1612
/* 1 2 3 4 5 6 7 */
1592
1613
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
1614
+ Case (" FSFAT_FOPEN_TEST_00: format sd card to FAT FS." , FSFAT_FOPEN_TEST_00),
1593
1615
Case (" FSFAT_FOPEN_TEST_01: fopen()/fwrite()/fclose() directories/file in multi-dir filepath." , FSFAT_FOPEN_TEST_01),
1594
1616
Case (" FSFAT_FOPEN_TEST_02: fopen(r) pre-existing file try to write it." , FSFAT_FOPEN_TEST_02),
1595
1617
Case (" FSFAT_FOPEN_TEST_03: fopen(w+) pre-existing file try to write it." , FSFAT_FOPEN_TEST_03),
0 commit comments