本文整理汇总了C++中ARM_CFSTORE_DRIVER类的典型用法代码示例。如果您正苦于以下问题:C++ ARM_CFSTORE_DRIVER类的具体用法?C++ ARM_CFSTORE_DRIVER怎么用?C++ ARM_CFSTORE_DRIVER使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ARM_CFSTORE_DRIVER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cfstore_flush3_start
int32_t cfstore_flush3_start(void)
{
int32_t status = ARM_DRIVER_OK;
int32_t cfsStatus;
ARM_CFSTORE_DRIVER *cfstoreDriver = &cfstore_driver;
ARM_CFSTORE_CAPABILITIES caps;
CFSTORE_DBGLOG("%s:IN\n", __func__);
/* Initialize configuration store */
cfsStatus = cfstoreDriver->Initialize(NULL, NULL);
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("CFStore Initialization failed (err %lu)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
/* Get capabilities */
memset(&caps, 0, sizeof(caps));
caps = cfstoreDriver->GetCapabilities();
if(caps.asynchronous_ops == true){
CFSTORE_DBGLOG("%s:Please configure CFstore to work in synchronous mode. This can be change in config.json file.\n", __func__);
status = ARM_DRIVER_ERROR;
goto out;
}
CFSTORE_DBGLOG("%s:OUT: returning ARM_DRIVER_OK\n", __func__);
return ARM_DRIVER_OK; /* init succeeded */
out:
/* init failed */
(void) cfstore_flush3_end();
CFSTORE_DBGLOG("%s:OUT: status=%d\n", __func__, (int) status);
return status;
}
示例2: cfstore_flash_set_test_01_end
/**
* @brief add ~50 KVs and store them in flash
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
static control_t cfstore_flash_set_test_01_end(const size_t call_count)
{
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_FMODE flags;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
memset(&flags, 0, sizeof(flags));
CFSTORE_LOG("caps.asynchronous_ops : %d\n", (int) caps.asynchronous_ops);
ret = cfstore_test_init_1();
if(ret < ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Error: failed to write data to falsh.", __func__);
}
ret = drv->Flush();
if(ret < ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Flush() call failed (ret=%d).\r\n", __func__, (int) ret);
}
#ifdef CFSTORE_DEBUG
ret = cfstore_test_dump();
if(ret < ARM_DRIVER_OK){
CFSTORE_ERRLOG("Error: failed to dump CFSTORE contents%s", "\n");
}
#endif /* CFSTORE_DEBUG */
ret = drv->Uninitialize();
if(ret < ARM_DRIVER_OK){
CFSTORE_ERRLOG("Error: failed to Uninitialize() CFSTORE%s", "\n");
}
return CaseNext;
}
示例3: cfstore_open_test_07_end
/** @brief test to call cfstore_open() with key_name that in includes
* illegal characters
* - a max-length string of random characters (legal and illegal)
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_open_test_07_end(const size_t call_count)
{
char kv_name[CFSTORE_KEY_NAME_MAX_LENGTH+1]; /* extra char for terminating null */
size_t i = 0;
int32_t ret = ARM_DRIVER_OK;
size_t name_len = CFSTORE_KEY_NAME_MAX_LENGTH;
ARM_CFSTORE_KEYDESC kdesc;
size_t buf_data_max = 0;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
/* create bad keyname strings with invalid character code at start of keyname */
buf_data_max = strlen(cfstore_open_ascii_illegal_buf_g);
name_len = CFSTORE_KEY_NAME_MAX_LENGTH;
memset(kv_name, 0, CFSTORE_KEY_NAME_MAX_LENGTH+1);
kdesc.drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE;
ret = cfstore_test_kv_name_gen(kv_name, name_len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: unable to generate kv_name.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK , cfstore_open_utest_msg_g);
/* pepper the illegal chars across the string*/
for(i++; i < buf_data_max; i++){
kv_name[rand() % (name_len+1)] = cfstore_open_ascii_illegal_buf_g[i];
}
ret = cfstore_test_create(kv_name, kv_name, &name_len, &kdesc);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: created KV in store when kv_name contains invalid characters (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret < ARM_DRIVER_OK, cfstore_open_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
return CaseNext;
}
示例4: cfstore_test_delete_all
/* @brief test utility function to delete all of the KVs in the cfstore
* @note this function expects cfstore to have been initialised with
* a call to ARM_CFSTORE_DRIVER::Initialize()
*/
int32_t cfstore_test_delete_all(void)
{
const char* key_name_query = "*";
char key_name[CFSTORE_KEY_NAME_MAX_LENGTH+1];
uint8_t len = CFSTORE_KEY_NAME_MAX_LENGTH+1;
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
ARM_CFSTORE_HANDLE_INIT(next);
ARM_CFSTORE_HANDLE_INIT(prev);
CFSTORE_FENTRYLOG("%s:entered.\r\n", __func__);
while((ret = drv->Find(key_name_query, prev, next)) == ARM_DRIVER_OK)
{
len = CFSTORE_KEY_NAME_MAX_LENGTH+1;
drv->GetKeyName(next, key_name, &len);
CFSTORE_TP(CFSTORE_TP_DELETE, "%s:deleting key_name=%s, len=%d\r\n", __func__, key_name, (int) len);
ret = drv->Delete(next);
if(ret < ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Error: failed to delete key_name=%s, len=%d\r\n", __func__, key_name, (int) len);
return ret;
}
CFSTORE_HANDLE_SWAP(prev, next);
}
if(ret == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND) {
/* as expected, no more keys have been found by the Find()*/
ret = ARM_DRIVER_OK;
}
CFSTORE_FENTRYLOG("%s:exiting (ret=%d).\r\n", __func__, (int) ret);
return ret;
}
示例5: cfstore_flush3_read_file
int32_t cfstore_flush3_read_file(const char *fileDir, size_t maxFilePathSize, const char *fileName, uint8_t *buff, size_t buffSize)
{
int32_t cfsStatus;
int32_t status = ARM_DRIVER_OK;
ARM_CFSTORE_DRIVER *cfstoreDriver = &cfstore_driver;
ARM_CFSTORE_FMODE flags;
ARM_CFSTORE_SIZE readCount = buffSize;
ARM_CFSTORE_HANDLE_INIT(hkey);
CFSTORE_DBGLOG("%s:IN. File name %s, buffer %p, buffsize %d\n", __func__, fileName, buff, buffSize);
CFSTORE_UNUSED_PARAM(fileDir);
CFSTORE_UNUSED_PARAM(maxFilePathSize);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Uninitialize Cfstore\n", __func__);
TEST_ASSERT_MESSAGE(cfstoreDriver != NULL, cfstore_flush3_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Invalid file name\n", __func__);
TEST_ASSERT_MESSAGE(fileName != NULL, cfstore_flush3_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Invalid buff\n", __func__);
TEST_ASSERT_MESSAGE(buff != NULL, cfstore_flush3_utest_msg_g);
memset(&flags, 0, sizeof(flags));
flags.read = true;
cfsStatus = cfstoreDriver->Open(fileName, flags, hkey);
if(cfsStatus == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND){
CFSTORE_DBGLOG("File (%s) not found (err %ld)\n", fileName, cfsStatus);
return ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND;
}
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Open failed (err %ld)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
cfsStatus = cfstoreDriver->Read(hkey, buff, &readCount);
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Read failed (err %ld)\n", cfsStatus);
status = ARM_DRIVER_ERROR;
goto out;
}
if(readCount < buffSize){
CFSTORE_DBGLOG("Read failed, amount is %zu while requested %zu\n", readCount, buffSize);
status = ARM_DRIVER_ERROR;
goto out;
}
out:
cfsStatus = cfstoreDriver->Close(hkey);
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Close failed (err %ld)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
CFSTORE_DBGLOG("%s:OUT: status=%d\n", __func__, (int) status);
return status;
}
示例6: cfstore_flush3_delete_file
int32_t cfstore_flush3_delete_file(const char *fileDir, size_t maxFilePathSize, const char *fileName)
{
int32_t cfsStatus;
int32_t status = ARM_DRIVER_OK;
ARM_CFSTORE_DRIVER *cfstoreDriver = &cfstore_driver;
ARM_CFSTORE_FMODE flags;
ARM_CFSTORE_HANDLE_INIT(hkey);
CFSTORE_DBGLOG("%s:IN. File name %s\n", __func__, fileName);
CFSTORE_UNUSED_PARAM(fileDir);
CFSTORE_UNUSED_PARAM(maxFilePathSize);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Uninitialize Cfstore\n", __func__);
TEST_ASSERT_MESSAGE(cfstoreDriver != NULL, cfstore_flush3_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Invalid file name\n", __func__);
TEST_ASSERT_MESSAGE(fileName != NULL, cfstore_flush3_utest_msg_g);
memset(&flags, 0, sizeof(flags));
flags.write = true;
cfsStatus = cfstoreDriver->Open(fileName, flags, hkey);
if (cfsStatus == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND) {
/* printf added: modification to original code supplied by Jenia Kogan. */
CFSTORE_DBGLOG("%s: cfsStatus == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND. returning success\n", __func__);
return ARM_DRIVER_OK;
}
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Open failed (err %ld)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
cfsStatus = cfstoreDriver->Delete(hkey);
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Failed deleting (%s) failed (err %ld)\n", fileName, cfsStatus);
status = ARM_DRIVER_ERROR;
goto out;
}
out:
cfsStatus = cfstoreDriver->Close(hkey);
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Close failed (err %ld)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
/* Flash-to-flash only on success */
if (status == ARM_DRIVER_OK) {
cfsStatus = cfstoreDriver->Flush();
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("Flush to flash failed (err %ld)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
}
CFSTORE_DBGLOG("%s:OUT: status=%d\n", __func__, (int) status);
return status;
}
示例7: cfstore_add_del_test_03_end
/** @brief
*
* This test case adds ~50 KVs, and then delete entries at the start,
* middle and end of list.
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_add_del_test_03_end(const size_t call_count)
{
bool bfound = false;
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_FMODE flags;
cfstore_kv_data_t *node;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
memset(&flags, 0, sizeof(flags));
ret = cfstore_test_init_1();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to initialise cfstore area with entries\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
/* delete some keys */
node = cfstore_add_del_test_08_data;
while(node->key_name != NULL)
{
CFSTORE_DBGLOG("%s:about to delete key (key_name=%s).\n", __func__, node->key_name);
cfstore_test_delete(node->key_name);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error failed to delete a key (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Deleted KV successfully (key_name=\"%s\")\n", node->key_name);
node++;
}
/* check the keys have been deleted */
node = cfstore_add_del_test_08_data;
while(node->key_name != NULL)
{
ret = cfstore_test_kv_is_found(node->key_name, &bfound);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to delete a key (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND, cfstore_add_del_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Test failed: found KV that was previously deleted (key_name=%s)\n", __func__, node->key_name);
TEST_ASSERT_MESSAGE(bfound == false, cfstore_add_del_utest_msg_g);
node++;
}
/* clean up by deleting all remaining KVs. this is not part of the test */
ret = cfstore_test_delete_all();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error failed to delete a all KVs (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to initialize CFSTORE (ret=%d)\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
return CaseNext;
}
示例8: cfstore_flush3_end
int32_t cfstore_flush3_end(void)
{
int32_t cfsStatus;
ARM_CFSTORE_DRIVER *cfstoreDriver = &cfstore_driver;
CFSTORE_DBGLOG("%s:IN\n", __func__);
cfsStatus = cfstoreDriver->Uninitialize();
if(cfsStatus < ARM_DRIVER_OK){
CFSTORE_DBGLOG("CFStore Finalization failed (err %ld)\n", cfsStatus);
return ARM_DRIVER_ERROR;
}
CFSTORE_DBGLOG("%s:OUT:returning ARM_DRIVER_OK\n", __func__);
return ARM_DRIVER_OK;
}
示例9: cfstore_open_test_04_end
/** @brief test to call cfstore_open() with a key_name string that exceeds
* the maximum length
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_open_test_04_end(const size_t call_count)
{
char kv_name_good[CFSTORE_KEY_NAME_MAX_LENGTH+1]; /* extra char for terminating null */
char kv_name_bad[CFSTORE_KEY_NAME_MAX_LENGTH+2];
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_SIZE len = 0;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
ARM_CFSTORE_KEYDESC kdesc;
ARM_CFSTORE_FMODE flags;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
memset(kv_name_good, 0, CFSTORE_KEY_NAME_MAX_LENGTH+1);
memset(kv_name_bad, 0, CFSTORE_KEY_NAME_MAX_LENGTH+2);
memset(&kdesc, 0, sizeof(kdesc));
/* dont set any flags to get default settings */
memset(&flags, 0, sizeof(flags));
len = CFSTORE_KEY_NAME_MAX_LENGTH;
ret = cfstore_test_kv_name_gen(kv_name_good, len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: unable to generate kv_name_good.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK , cfstore_open_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: kv_name_good is not the correct length (len=%d, expected=%d).\n", __func__, (int) strlen(kv_name_good), (int) len);
TEST_ASSERT_MESSAGE(strlen(kv_name_good) == CFSTORE_KEY_NAME_MAX_LENGTH, cfstore_open_utest_msg_g);
ret = cfstore_test_create(kv_name_good, kv_name_good, &len, &kdesc);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to create KV in store for kv_name_good(ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
len = CFSTORE_KEY_NAME_MAX_LENGTH+1;
ret = cfstore_test_kv_name_gen(kv_name_bad, len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: unable to generate kv_name_bad.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK , cfstore_open_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: kv_name_bad is not the correct length (len=%d, expected=%d).\n", __func__, (int) strlen(kv_name_bad), (int) len);
TEST_ASSERT_MESSAGE(strlen(kv_name_bad) == CFSTORE_KEY_NAME_MAX_LENGTH+1, cfstore_open_utest_msg_g);
memset(&kdesc, 0, sizeof(kdesc));
ret = cfstore_test_create(kv_name_bad, kv_name_bad, &len, &kdesc);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: created KV in store for kv_name_bad when should have failed(ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret < ARM_DRIVER_OK, cfstore_open_utest_msg_g);
ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
return CaseNext;
}
示例10: cfstore_add_del_test_02_end
/** @brief
*
* This test case adds a small number of KVs (~3), and then delete them.
* - add key(s)
* - delete key(s)
* - make sure can't find key in cfstore
* - loop over the above a number of times.
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_add_del_test_02_end(const size_t call_count)
{
bool bResult = true; // We'll do "&=" cumulative checking.
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_SIZE len = 0;
ARM_CFSTORE_KEYDESC kdesc;
cfstore_kv_data_t* node = NULL;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
memset(&kdesc, 0, sizeof(kdesc));
/* create */
kdesc.drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE;
node = cfstore_add_del_test_08_data;
while(node->key_name != NULL)
{
len = strlen(node->value);
ret = cfstore_test_create(node->key_name, (char*) node->value, &len, &kdesc);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to create kv (key_name=%s.\n", __func__, node->key_name);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
node++;
}
/* test delete all */
ret = cfstore_test_delete_all();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to delete all KVs.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
/* check there are no KVs present as expected */
node = cfstore_add_del_test_08_data;
while(node->key_name != NULL)
{
ret = cfstore_test_kv_is_found(node->key_name, &bResult);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: found key when should not be present.\n", __func__);
TEST_ASSERT_MESSAGE(ret == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND && bResult == false, cfstore_add_del_utest_msg_g);
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Found KV successfully (key_name=\"%s\")\n", node->key_name);
node++;
}
ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
return CaseNext;
}
示例11: cfstore_create_test_02_end
/**@brief
*
* Test case to create ~10 kvs. The amount of data store in the cfstore is as follows:
* - 10 kvs
* - kv name lengths are ~220 => ~ 2200 bytes
* - value blob length is 1x256, 2x256, 3x256, ... 10x256)) = 256(1+2+3+4+..10) = 256*10*11/2 = 14080
* - kv overhead = 8bytes/kv = 8 * 10 = 80bytes
* - total = (220*10)+256*10*11/2 10*8 = 143800 bytes
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_create_test_02_end(const size_t call_count)
{
int32_t ret;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
ret = cfstore_create_test_02_core(call_count);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: something went wrong (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
return CaseNext;
}
示例12: cfstore_add_del_test_01_end
/** @brief
*
* This test case does the following:
* - creates a KV.
* - deletes the KV.
* - checks that the deleted KV can no longer be found in the store.
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_add_del_test_01_end(const size_t call_count)
{
bool bfound = false;
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_SIZE len = 0;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
ARM_CFSTORE_KEYDESC kdesc;
ARM_CFSTORE_HANDLE_INIT(hkey);
ARM_CFSTORE_FMODE flags;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
memset(&kdesc, 0, sizeof(kdesc));
memset(&flags, 0, sizeof(flags));
kdesc.drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE;
len = strlen(cfstore_add_del_test_07_data[0].value);
ret = cfstore_test_create(cfstore_add_del_test_07_data[0].key_name, (char*) cfstore_add_del_test_07_data[0].value, &len, &kdesc);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to create KV in store (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
/* now delete KV*/
ret = drv->Open(cfstore_add_del_test_07_data[0].key_name, flags, hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to Open() (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
if(hkey != NULL){
ret = drv->Delete(hkey);
drv->Close(hkey);
hkey = NULL;
}
/* check that the KV has been deleted */
/* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("LOG: WARNING: About to look for non-existent key (key_name=%s) (which will generate internal trace reporting errors if debug trace enabled).\n", cfstore_add_del_test_07_data[0].key_name);
ret = cfstore_test_kv_is_found(cfstore_add_del_test_07_data[0].key_name, &bfound);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error failed to delete a key (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND, cfstore_add_del_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Test failed: found KV that was previously deleted (key_name=%s)\n", __func__, cfstore_add_del_test_07_data[0].key_name);
TEST_ASSERT_MESSAGE(bfound == false, cfstore_add_del_utest_msg_g);
ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
return CaseNext;
}
示例13: cfstore_create_test_04_end
/**@brief
*
* Test to create the 100 kvs to make the device run out of memory.
* The amount of data store in the cfstore is as follows:
* - total = (220*100)+256*100*101/2 100*8 = 1315600 = 1.315x10^6
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_create_test_04_end(const size_t call_count)
{
int32_t ret = ARM_DRIVER_ERROR;
uint32_t i = 0;
uint32_t bytes_stored = 0;
const uint32_t max_num_kvs_create = 100;
const size_t kv_name_min_len = CFSTORE_KEY_NAME_MAX_LENGTH - max_num_kvs_create;
const size_t kv_value_min_len = CFSTORE_TEST_BYTE_DATA_TABLE_SIZE;
const size_t max_value_buf_size = kv_value_min_len/8 * (max_num_kvs_create +1);
char* value_buf = NULL;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
CFSTORE_LOG("%s: cfstore_test_dump: dump here contents of CFSTORE so we know whats present\n", __func__);
ret = cfstore_test_dump();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: D.1.1 cfstore_test_dump failed (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
value_buf = (char*) malloc(max_value_buf_size);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: out of memory.\n", __func__);
TEST_ASSERT_MESSAGE(value_buf != NULL, cfstore_create_utest_msg_g);
for(i = 0; i < max_num_kvs_create; i++)
{
memset(value_buf, 0, max_value_buf_size);
ret = cfstore_create_kv_create(kv_name_min_len +i, CFSTORE_CREATE_KV_CREATE_NO_TAG, value_buf, kv_value_min_len/8 * (i+1));
bytes_stored += kv_name_min_len + i; /* kv_name */
bytes_stored += kv_value_min_len/8 * (i+1); /* kv value blob */
bytes_stored += 8; /* kv overhead */
if(ret == ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY){
CFSTORE_ERRLOG("Out of memory on %d-th KV, trying to allocate memory totalling %d.\n", (int) i, (int) bytes_stored);
break;
}
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Successfully stored %d-th KV bytes, totalling %d.\n", (int) i, (int) bytes_stored);
}
ret = cfstore_test_delete_all();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to delete_all() attributes to clean up after test (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
free(value_buf);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
return CaseNext;
}
示例14: cfstore_create_test_03_end
/**@brief
*
* Test to create the ~100 kvs to make the device run out of memory.
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_create_test_03_end(const size_t call_count)
{
int32_t i = 0;
int32_t ret;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
for(i = 0; i < 100; i++)
{
ret = cfstore_create_test_02_core(call_count);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: something went wrong (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Successfully completed create/destroy loop %d.\n", (int) i);
}
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
return CaseNext;
}
示例15: cfstore_test_delete
/* @brief test utility function to delete the cfstore key identified by key_name
* @note this function expects cfstore to have been initialised with
* a call to ARM_CFSTORE_DRIVER::Initialize()
*/
int32_t cfstore_test_delete(const char* key_name)
{
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
ARM_CFSTORE_HANDLE_INIT(hkey);
ARM_CFSTORE_FMODE flags;
CFSTORE_FENTRYLOG("%s:entered.\r\n", __func__);
memset(&flags, 0, sizeof(flags));
ret = drv->Open(key_name, flags, hkey);
if(ret < ARM_DRIVER_OK){
return ret;
}
if(hkey != NULL){
ret = drv->Delete(hkey);
drv->Close(hkey);
}
return ret;
}