mirror of https://github.com/ARMmbed/mbed-os.git
minor edits to fopen test.
parent
df099b8567
commit
a35919afbe
|
@ -275,12 +275,12 @@ int32_t fsfat_filepath_make_dirs(char* filepath)
|
|||
/* FIX ME: errno not set correctly when error occurs. This indicates a problem with the implementation. */
|
||||
|
||||
/** @brief
|
||||
* Basic open test which does the following:
|
||||
* - creates KV with default rw perms and writes some data to the value blob.
|
||||
* - closes the newly created KV.
|
||||
* - opens the KV with the default permissions (r-only)
|
||||
* - reads the KV data and checks its the same as the previously created data.
|
||||
* - closes the opened key
|
||||
* Basic fopen test which does the following:
|
||||
* - creates file and writes some data to the value blob.
|
||||
* - closes the newly created file.
|
||||
* - opens the file (r-only)
|
||||
* - reads the file data and checks its the same as the previously created data.
|
||||
* - closes the opened file
|
||||
*
|
||||
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
||||
*/
|
||||
|
@ -355,7 +355,6 @@ control_t fsfat_fopen_test_01(const size_t call_count)
|
|||
return CaseNext;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NOT_DEFINED
|
||||
|
||||
static fsfat_kv_data_t fsfat_fopen_test_02_data[] = {
|
||||
|
@ -397,7 +396,7 @@ control_t fsfat_fopen_test_02(const size_t call_count)
|
|||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, fsfat_fopen_utest_msg_g);
|
||||
|
||||
/* by default, owner of key opens with read-only permissions*/
|
||||
ret = drv->Open(fsfat_fopen_test_02_data[0].key_name, flags, hkey);
|
||||
ret = fopen(fsfat_fopen_test_02_data[0].key_name, "w+");
|
||||
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: failed to open node (filename=\"%s\")(ret=%d)\n", __func__, fsfat_fopen_test_02_data[0].key_name, (int) ret);
|
||||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, fsfat_fopen_utest_msg_g);
|
||||
|
||||
|
@ -416,6 +415,8 @@ control_t fsfat_fopen_test_02(const size_t call_count)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief test to open() a pre-existing key and try to write it, which should succeed
|
||||
* because the key was opened read-write permissions explicitly
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
}while(0);
|
||||
|
||||
#define noFSFAT_DEBUG
|
||||
// todo: remove next line
|
||||
#define FSFAT_DEBUG
|
||||
|
||||
#ifdef FSFAT_DEBUG
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
|
||||
#ifdef FSFAT_DEBUG
|
||||
uint32_t fsfat_optDebug_g = 1;
|
||||
// todo: re-instate uint32_t fsfat_optLogLevel_g = FSFAT_LOG_NONE; /*FSFAT_LOG_NONE|FSFAT_LOG_ERR|FSFAT_LOG_DEBUG|FSFAT_LOG_FENTRY */
|
||||
uint32_t fsfat_optLogLevel_g = FSFAT_LOG_FENTRY; /*FSFAT_LOG_NONE|FSFAT_LOG_ERR|FSFAT_LOG_DEBUG|FSFAT_LOG_FENTRY */
|
||||
uint32_t fsfat_optLogLevel_g = FSFAT_LOG_NONE; /*FSFAT_LOG_NONE|FSFAT_LOG_ERR|FSFAT_LOG_DEBUG|FSFAT_LOG_FENTRY */
|
||||
#endif
|
||||
|
||||
/* ruler for measuring text strings */
|
||||
|
@ -363,39 +362,39 @@ int32_t fsfat_test_delete_all(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
//#endif // NOT_DEFINED
|
||||
|
||||
/* @brief test utility function to create a KV in the cfstore
|
||||
* @note this function expects cfstore to have been initialised with
|
||||
* a call to ARM_FSFAT_DRIVER::Initialize()
|
||||
|
||||
/* @brief test utility function to create a file
|
||||
*/
|
||||
int32_t fsfat_test_create(const char* key_name, const char* data, ARM_FSFAT_SIZE* len, ARM_FSFAT_KEYDESC* kdesc)
|
||||
int32_t fsfat_test_create(const char* filename, const char* data, size_t* len)
|
||||
{
|
||||
int32_t ret = ARM_DRIVER_ERROR;
|
||||
ARM_FSFAT_SIZE value_len = 0;
|
||||
ARM_FSFAT_DRIVER* drv = &fsfat_driver;
|
||||
ARM_FSFAT_HANDLE_INIT(hkey);
|
||||
int32_t ret = -1;
|
||||
size_t value_len = 0;
|
||||
|
||||
FSFAT_FENTRYLOG("%s:entered.\r\n", __func__);
|
||||
value_len = *len;
|
||||
kdesc->drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE;
|
||||
ret = drv->Create(key_name, value_len, kdesc, hkey);
|
||||
ret = fopen(filename, value_len, kdesc, hkey);
|
||||
if(ret < ARM_DRIVER_OK){
|
||||
return ret;
|
||||
}
|
||||
value_len = *len;
|
||||
ret = drv->Write(hkey, data, &value_len);
|
||||
ret = fwrite(hkey, data, &value_len);
|
||||
if(ret < ARM_DRIVER_OK){
|
||||
drv->Close(hkey);
|
||||
flose(hkey);
|
||||
return ret;
|
||||
}
|
||||
if(value_len != *len){
|
||||
drv->Close(hkey);
|
||||
fclose(hkey);
|
||||
return ARM_DRIVER_ERROR;
|
||||
}
|
||||
drv->Close(hkey);
|
||||
flose(hkey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//#ifdef NOT_DEFINED
|
||||
|
||||
/* @brief test utility function to create KVs from the supplied table
|
||||
* @note this function expects cfstore to have been initialised with
|
||||
* a call to ARM_FSFAT_DRIVER::Initialize()
|
||||
|
|
Loading…
Reference in New Issue