mirror of https://github.com/ARMmbed/mbed-os.git
Fix fopen test build error due to #include <sys/stat.h>, which is not present.
parent
5c7fdc13c7
commit
1b562cc2fe
|
@ -139,9 +139,9 @@ SDFileSystem sd(p11, p12, p13, p14, "sd");
|
||||||
|
|
||||||
#ifdef FSFAT_SDCARD_INSTALLED
|
#ifdef FSFAT_SDCARD_INSTALLED
|
||||||
|
|
||||||
#define FAT_FN_TEST_00 fsfat_test_00
|
#define FSFAT_BASIC_TEST_00 fsfat_basic_test_00
|
||||||
#define FAT_FN_TEST_01 fsfat_test_01
|
#define FSFAT_BASIC_TEST_01 fsfat_basic_test_01
|
||||||
#define FAT_FN_TEST_02 fsfat_test_02
|
#define FSFAT_BASIC_TEST_02 fsfat_basic_test_02
|
||||||
|
|
||||||
|
|
||||||
#define FSFAT_BASIC_MSG_BUF_SIZE 256
|
#define FSFAT_BASIC_MSG_BUF_SIZE 256
|
||||||
|
@ -168,7 +168,7 @@ static char fsfat_basic_msg_g[FSFAT_BASIC_MSG_BUF_SIZE];
|
||||||
*
|
*
|
||||||
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
||||||
*/
|
*/
|
||||||
static control_t fsfat_test_00() {
|
static control_t fsfat_basic_test_00() {
|
||||||
|
|
||||||
uint8_t data_written[FSFAT_BASIC_DATA_SIZE] = { 0 };
|
uint8_t data_written[FSFAT_BASIC_DATA_SIZE] = { 0 };
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
@ -219,7 +219,7 @@ extern int errno;
|
||||||
*
|
*
|
||||||
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
||||||
*/
|
*/
|
||||||
static control_t fsfat_test_01() {
|
static control_t fsfat_basic_test_01() {
|
||||||
FILE *fp, *fp1;
|
FILE *fp, *fp1;
|
||||||
int i, j;
|
int i, j;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -234,6 +234,9 @@ static control_t fsfat_test_01() {
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
putc (i, fp);
|
putc (i, fp);
|
||||||
}
|
}
|
||||||
|
/* FIXME: freopen() should open the specified file closing the first stream. As can be seen from the
|
||||||
|
* code below, the old file descriptor fp can still be used, and this should not happen.
|
||||||
|
*/
|
||||||
fp1 = freopen (sd_file_path, "r", fp);
|
fp1 = freopen (sd_file_path, "r", fp);
|
||||||
TEST_ASSERT_MESSAGE(fp1 == fp, "Error: cannot open file for reading");
|
TEST_ASSERT_MESSAGE(fp1 == fp, "Error: cannot open file for reading");
|
||||||
|
|
||||||
|
@ -279,7 +282,7 @@ static control_t fsfat_test_01() {
|
||||||
*
|
*
|
||||||
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
||||||
*/
|
*/
|
||||||
static control_t fsfat_test_02() {
|
static control_t fsfat_basic_test_02() {
|
||||||
static const char hello[] = "Hello, world.\n";
|
static const char hello[] = "Hello, world.\n";
|
||||||
static const char replace[] = "Hewwo, world.\n";
|
static const char replace[] = "Hewwo, world.\n";
|
||||||
static const size_t replace_from = 2, replace_to = 4;
|
static const size_t replace_from = 2, replace_to = 4;
|
||||||
|
@ -397,19 +400,21 @@ static control_t fsfat_test_02() {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define FAT_FN_TEST_00 fsfat_test_dummy
|
#define FSFAT_BASIC_TEST_00 fsfat_basic_test_dummy
|
||||||
#define FAT_FN_TEST_01 fsfat_test_dummy
|
#define FSFAT_BASIC_TEST_01 fsfat_basic_test_dummy
|
||||||
#define FAT_FN_TEST_02 fsfat_test_dummy
|
#define FSFAT_BASIC_TEST_02 fsfat_basic_test_dummy
|
||||||
|
|
||||||
/** @brief fsfat_test_dummy Dummy test case for testing when platform doesnt have an SDCard installed.
|
/** @brief fsfat_basic_test_dummy Dummy test case for testing when platform doesnt have an SDCard installed.
|
||||||
*
|
*
|
||||||
* @return success always
|
* @return success always
|
||||||
*/
|
*/
|
||||||
static control_t fsfat_test_dummy() {
|
static control_t fsfat_basic_test_dummy()
|
||||||
|
{
|
||||||
|
printf("Null test\n");
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* FSFAT_SDCARD_INSTALLED */
|
||||||
|
|
||||||
utest::v1::status_t greentea_setup(const size_t number_of_cases)
|
utest::v1::status_t greentea_setup(const size_t number_of_cases)
|
||||||
{
|
{
|
||||||
|
@ -421,10 +426,10 @@ utest::v1::status_t greentea_setup(const size_t number_of_cases)
|
||||||
Case cases[] = {
|
Case cases[] = {
|
||||||
/* 1 2 3 4 5 6 7 */
|
/* 1 2 3 4 5 6 7 */
|
||||||
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
||||||
Case("FSFAT_test_00: fopen()/fgetc()/fprintf()/fclose() test.", FAT_FN_TEST_00),
|
Case("FSFAT_test_00: fopen()/fgetc()/fprintf()/fclose() test.", FSFAT_BASIC_TEST_00),
|
||||||
Case("FSFAT_test_01: fopen()/fseek()/fclose() test.", FAT_FN_TEST_01)
|
Case("FSFAT_test_01: fopen()/fseek()/fclose() test.", FSFAT_BASIC_TEST_01)
|
||||||
/* WARNING: Test case not working but currently not required for PAL support
|
/* WARNING: Test case not working but currently not required for PAL support
|
||||||
* Case("FSFAT_test_02: fopen()/fgets()/fputs()/ftell()/rewind()/remove() test.", FAT_FN_TEST_02) */
|
* Case("FSFAT_test_02: fopen()/fgets()/fputs()/ftell()/rewind()/remove() test.", FSFAT_BASIC_TEST_02) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include <stdlib.h> /*rand()*/
|
#include <stdlib.h> /*rand()*/
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
|
@ -56,8 +55,6 @@ SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||||
#elif defined(TARGET_K64F) || defined(TARGET_K66F)
|
#elif defined(TARGET_K64F) || defined(TARGET_K66F)
|
||||||
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
|
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
|
||||||
/* #define FSFAT_SDCARD_INSTALLED */
|
/* #define FSFAT_SDCARD_INSTALLED */
|
||||||
/* todo: remove */
|
|
||||||
#define FSFAT_SDCARD_INSTALLED
|
|
||||||
|
|
||||||
#elif defined(TARGET_K22F)
|
#elif defined(TARGET_K22F)
|
||||||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||||
|
@ -128,6 +125,16 @@ SDFileSystem sd(p11, p12, p13, p14, "sd");
|
||||||
#endif
|
#endif
|
||||||
/// @endcond
|
/// @endcond
|
||||||
|
|
||||||
|
#ifdef FSFAT_SDCARD_INSTALLED
|
||||||
|
|
||||||
|
#define FSFAT_FOPEN_TEST_01 fsfat_fopen_test_01
|
||||||
|
#define FSFAT_FOPEN_TEST_02 fsfat_fopen_test_02
|
||||||
|
#define FSFAT_FOPEN_TEST_03 fsfat_fopen_test_03
|
||||||
|
#define FSFAT_FOPEN_TEST_04 fsfat_fopen_test_04
|
||||||
|
#define FSFAT_FOPEN_TEST_05 fsfat_fopen_test_05
|
||||||
|
#define FSFAT_FOPEN_TEST_06 fsfat_fopen_test_06
|
||||||
|
#define FSFAT_FOPEN_TEST_07 fsfat_fopen_test_07
|
||||||
|
|
||||||
|
|
||||||
/* support functions */
|
/* support functions */
|
||||||
|
|
||||||
|
@ -165,7 +172,7 @@ static fsfat_kv_data_t fsfat_fopen_test_01_kv_data[] = {
|
||||||
*
|
*
|
||||||
* @return On success, this returns the number of components in the filepath Returns number of compoee
|
* @return On success, this returns the number of components in the filepath Returns number of compoee
|
||||||
*/
|
*/
|
||||||
int32_t fsfat_filepath_split(char* filepath, char* parts[], uint32_t num)
|
static int32_t fsfat_filepath_split(char* filepath, char* parts[], uint32_t num)
|
||||||
{
|
{
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
|
@ -231,7 +238,7 @@ int32_t fsfat_filepath_remove_all(char* filepath)
|
||||||
*
|
*
|
||||||
* @return On success, this returns 0, otherwise < 0 is returned;
|
* @return On success, this returns 0, otherwise < 0 is returned;
|
||||||
*/
|
*/
|
||||||
int32_t fsfat_filepath_make_dirs(char* filepath)
|
static int32_t fsfat_filepath_make_dirs(char* filepath)
|
||||||
{
|
{
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t num_parts = 0;
|
int32_t num_parts = 0;
|
||||||
|
@ -284,7 +291,7 @@ int32_t fsfat_filepath_make_dirs(char* filepath)
|
||||||
*
|
*
|
||||||
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
||||||
*/
|
*/
|
||||||
control_t fsfat_fopen_test_01(const size_t call_count)
|
static control_t fsfat_fopen_test_01(const size_t call_count)
|
||||||
{
|
{
|
||||||
char* read_buf;
|
char* read_buf;
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
@ -799,6 +806,29 @@ control_t fsfat_fopen_test_07(const size_t call_count)
|
||||||
|
|
||||||
#endif // NOT_DEFINED
|
#endif // NOT_DEFINED
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define FSFAT_FOPEN_TEST_01 fsfat_fopen_test_dummy
|
||||||
|
#define FSFAT_FOPEN_TEST_02 fsfat_fopen_test_dummy
|
||||||
|
#define FSFAT_FOPEN_TEST_03 fsfat_fopen_test_dummy
|
||||||
|
#define FSFAT_FOPEN_TEST_04 fsfat_fopen_test_dummy
|
||||||
|
#define FSFAT_FOPEN_TEST_05 fsfat_fopen_test_dummy
|
||||||
|
#define FSFAT_FOPEN_TEST_06 fsfat_fopen_test_dummy
|
||||||
|
#define FSFAT_FOPEN_TEST_07 fsfat_fopen_test_dummy
|
||||||
|
|
||||||
|
/** @brief fsfat_fopen_test_dummy Dummy test case for testing when platform doesnt have an SDCard installed.
|
||||||
|
*
|
||||||
|
* @return success always
|
||||||
|
*/
|
||||||
|
static control_t fsfat_fopen_test_dummy()
|
||||||
|
{
|
||||||
|
printf("Null test\n");
|
||||||
|
return CaseNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FSFAT_SDCARD_INSTALLED */
|
||||||
|
|
||||||
|
|
||||||
/// @cond FSFAT_DOXYGEN_DISABLE
|
/// @cond FSFAT_DOXYGEN_DISABLE
|
||||||
utest::v1::status_t greentea_setup(const size_t number_of_cases)
|
utest::v1::status_t greentea_setup(const size_t number_of_cases)
|
||||||
{
|
{
|
||||||
|
@ -809,15 +839,15 @@ utest::v1::status_t greentea_setup(const size_t number_of_cases)
|
||||||
Case cases[] = {
|
Case cases[] = {
|
||||||
/* 1 2 3 4 5 6 7 */
|
/* 1 2 3 4 5 6 7 */
|
||||||
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
||||||
Case("FOPEN_test_01", fsfat_fopen_test_01)
|
Case("FOPEN_test_01", FSFAT_FOPEN_TEST_01)
|
||||||
|
|
||||||
#ifdef NOT_DEFINED
|
#ifdef NOT_DEFINED
|
||||||
Case("FOPEN_test_02", fsfat_fopen_test_02),
|
Case("FOPEN_test_02", FSFAT_FOPEN_TEST_02),
|
||||||
Case("FOPEN_test_03", fsfat_fopen_test_03),
|
Case("FOPEN_test_03", FSFAT_FOPEN_TEST_03),
|
||||||
Case("FOPEN_test_04", fsfat_fopen_test_04),
|
Case("FOPEN_test_04", FSFAT_FOPEN_TEST_04),
|
||||||
Case("FOPEN_test_05", fsfat_fopen_test_05),
|
Case("FOPEN_test_05", FSFAT_FOPEN_TEST_05),
|
||||||
Case("FOPEN_test_06", fsfat_fopen_test_06),
|
Case("FOPEN_test_06", FSFAT_FOPEN_TEST_06),
|
||||||
Case("FOPEN_test_07", fsfat_fopen_test_07),
|
Case("FOPEN_test_07", FSFAT_FOPEN_TEST_07),
|
||||||
#endif // NOT_DEFINED
|
#endif // NOT_DEFINED
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue