本文整理汇总了C++中ARM_CFSTORE_DRIVER::Uninitialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ARM_CFSTORE_DRIVER::Uninitialize方法的具体用法?C++ ARM_CFSTORE_DRIVER::Uninitialize怎么用?C++ ARM_CFSTORE_DRIVER::Uninitialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARM_CFSTORE_DRIVER
的用法示例。
在下文中一共展示了ARM_CFSTORE_DRIVER::Uninitialize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
/** @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;
}
示例2: memset
/**
* @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: memset
/** @brief test to write many times to an open KV to test data is appended
* sequentially to the end of the value blob
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_write_test_01_end(const size_t call_count)
{
char read_buf[CFSTORE_KEY_NAME_MAX_LENGTH+1];
uint32_t i = 0;
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_DBGLOG("%s:entered\n", __func__);
(void) call_count;
memset(read_buf, 0, CFSTORE_KEY_NAME_MAX_LENGTH+1);
memset(&kdesc, 0, sizeof(kdesc));
memset(&flags, 0, sizeof(flags));
/* create an empty KV of the required length */
kdesc.drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE;
len = strlen(cfstore_write_test_01_kv_data[0].value);
ret = cfstore_test_create(cfstore_write_test_01_kv_data[0].key_name, "one", &len, &kdesc);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to create new KV (key_name=%s, ret=%d).\n", __func__, cfstore_write_test_01_kv_data[0].key_name, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
/* now open the newly created key and write repeated to created the string */
flags.write = true;
ret = drv->Open(cfstore_write_test_01_kv_data[0].key_name, flags, hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to open node (key_name=\"%s\", value=\"%s\")(ret=%d)\n", __func__, cfstore_write_test_01_kv_data[0].key_name, cfstore_write_test_01_kv_data[0].value, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
for(i = 0; i < strlen(cfstore_write_test_01_kv_data[0].value); i++)
{
len = 1;
ret = drv->Write(hkey, &cfstore_write_test_01_kv_data[0].value[i], &len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Write failed for char (\'%c\') (ret=%d)\n", __func__, cfstore_write_test_01_kv_data[0].value[i], (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
}
/* check that the value created in the key is as expected*/
len = CFSTORE_KEY_NAME_MAX_LENGTH+1;
ret = drv->Read(hkey, read_buf, &len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Read failed (ret=%d)\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
/* check node key_names are identical */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: KV value (%s) is not as expected (%s).\n", __func__, read_buf, cfstore_write_test_01_kv_data[0].value);
TEST_ASSERT_MESSAGE(strncmp(read_buf, cfstore_write_test_01_kv_data[0].value, strlen(cfstore_write_test_01_kv_data[0].value)) == 0, cfstore_write_utest_msg_g);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Close() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(drv->Close(hkey) >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
cfstore_test_delete_all();
ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
return CaseNext;
}
示例4: memset
/** @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;
}
示例5: failed
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;
}
示例6: memset
/** @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;
}
示例7: wrong
/**@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;
}
示例8: failed
/**@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;
}
示例9: malloc
/**
* @brief Support function for test cases 05
*
* Create enough KV's to consume the whole of available memory
*/
int32_t cfstore_create_test_05_core(const size_t call_count)
{
int32_t ret = ARM_DRIVER_ERROR;
uint32_t i = 0;
const uint32_t max_num_kvs_create = 200;
const size_t kv_name_tag_len = 3;
const size_t kv_name_min_len = 10;
const size_t kv_value_min_len = CFSTORE_TEST_BYTE_DATA_TABLE_SIZE;
const size_t max_value_buf_size = kv_value_min_len/64 * (max_num_kvs_create+1);
char kv_name_tag_buf[kv_name_tag_len+1];
char* value_buf = NULL;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
/* Initialize() */
cfstore_utest_default_start(call_count);
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);
snprintf(kv_name_tag_buf, kv_name_tag_len+1, "%0d", (int) i);
ret = cfstore_create_kv_create(kv_name_min_len, kv_name_tag_buf, value_buf, kv_value_min_len/64 * (i+1));
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.\n", __func__);
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 ret;
}
示例10: failed
/** @brief basic Flush() test
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
int32_t cfstore_flush_test_01_x86_sync(void)
{
int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
ret = drv->Initialize(NULL, NULL);
if(ret != ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Initialize() call failed (ret=%d).\r\n", __func__, (int) ret);
goto out0;
}
ret = drv->Flush();
if(ret != ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Flush() call failed (ret=%d).\r\n", __func__, (int) ret);
}
ret = drv->Uninitialize();
if(ret != ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Initialize() call failed to Uninitialise(ret=%d).\r\n", __func__, (int) ret);
goto out0;
}
out0:
return ret;
}
示例11: while
/** @brief
*
* Test that key names with non-matching braces etc do no get created.
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_create_test_06_end(const size_t call_count)
{
bool ret = false;
int32_t ret32 = ARM_DRIVER_ERROR;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
cfstore_create_key_name_validate_t* node = cfstore_create_test_06_data;
(void) call_count;
while(node->key_name != NULL)
{
ret = cfstore_create_key_name_validate(node->key_name, node->f_allowed);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: test failed (ret=%d, key_name=%s, f_allowed=%d)\n", __func__, (int) ret, node->key_name, (int) node->f_allowed);
TEST_ASSERT_MESSAGE(ret == true, cfstore_create_utest_msg_g);
node++;
}
ret32 = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret32 >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
return CaseNext;
}
示例12: strlen
/* @brief simple flush test */
static control_t cfstore_flush3_test_02(const size_t call_count)
{
int32_t cfsStatus = ARM_DRIVER_ERROR;
ARM_CFSTORE_KEYDESC kdesc;
ARM_CFSTORE_FMODE flags;
ARM_CFSTORE_SIZE len = strlen("key0");
ARM_CFSTORE_HANDLE_INIT(hkey);
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
(void) call_count;
memset(&kdesc, 0, sizeof(kdesc));
memset(&flags, 0, sizeof(flags));
CFSTORE_DBGLOG("%s:Initialize()\n", __func__);
cfsStatus = drv->Initialize(NULL, NULL);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:Create()\n", __func__);
cfsStatus = drv->Create("key0", len, &kdesc, hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
len = strlen("some-value");
CFSTORE_DBGLOG("%s:Write()\n", __func__);
cfsStatus = drv->Write(hkey, "some-value", &len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:Close()\n", __func__);
cfsStatus = drv->Close(hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:Flush()\n", __func__);
cfsStatus = drv->Flush();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:Open()\n", __func__);
cfsStatus = drv->Open("key0", flags, hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:Delete()\n", __func__);
cfsStatus = drv->Delete(hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:Close()\n", __func__);
cfsStatus = drv->Close(hkey); /////// <--- cfsStatus = ARM_CFSTORE_DRIVER_ERROR_PREEXISTING_KEY
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
CFSTORE_DBGLOG("%s:got status = %d\n", __func__, (int) cfsStatus);
CFSTORE_DBGLOG("%s:Uninitialize()\n", __func__);
cfsStatus = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus);
TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g);
return CaseNext;
}
示例13: memset
/** @brief Test case to change the value blob size of pre-existing
* key in a way that causes the memory area to realloc-ed,
*
* The test is a modified version of cfstore_create_test_01_end which
* - creates KVs,
* - mallocs a memory object on the heap
* - increases the size of one of the existing KVs, causing the
* internal memory area to be realloc-ed.
*
* In detail, the test does the following:
* 1. creates a cfstore with ~10 entries. This causes the configuration
* store to realloc() heap memory for KV storage.
* 2. mallocs a memory object on heap.
* 3. for a mid-cfstore entry, double the value blob size. This will cause the
* cfstore memory area to be realloced.
* 4. check all the cfstore entries can be read correctly and their
* data agrees with the data supplied upon creation.
* 5. shrink the mid-entry value blob size to be ~half the initial size.
* check all the cfstore entries can be read correctly and their
* data agrees with the data supplied upon creation.
*
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
*/
control_t cfstore_create_test_07_end(const size_t call_count)
{
int32_t ret = ARM_DRIVER_ERROR;
void *test_buf1 = NULL;
ARM_CFSTORE_FMODE flags;
cfstore_kv_data_t* node = NULL;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count;
memset(&flags, 0, sizeof(flags));
/* step 1 */
ret = cfstore_test_create_table(cfstore_create_test_01_data_step_01);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to add cfstore_create_test_01_data_head (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
/* step 2 */
test_buf1 = malloc(CFSTORE_CREATE_MALLOC_SIZE);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to allocate memory (test_buf1=%p)\n", __func__, test_buf1);
TEST_ASSERT_MESSAGE(test_buf1 != NULL, cfstore_create_utest_msg_g);
/* step 3. find cfstore_create_test_01_data[0] and grow the KV MID_ENTRY_01 to MID_ENTRY_02 */
ret = cfstore_create_test_KV_change(&cfstore_create_test_01_data[0], &cfstore_create_test_01_data[1]);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to increase size of KV (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
/* step 4. Now check that the KVs are all present and correct */
node = cfstore_create_test_01_data_step_02;
while(node->key_name != NULL)
{
ret = cfstore_test_check_node_correct(node);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:node (key_name=\"%s\", value=\"%s\") not correct in cfstore\n", __func__, node->key_name, node->value);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
node++;
}
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("KV successfully increased in size and other KVs remained unchanged.%s", "\n");
/* Shrink the KV from KV MID_ENTRY_02 to MID_ENTRY_03 */
ret = cfstore_create_test_KV_change(&cfstore_create_test_01_data[1], &cfstore_create_test_01_data[2]);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to decrease size of KV (ret=%d).\n", __func__, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
/* Step 5. Now check that the KVs are all present and correct */
node = cfstore_create_test_01_data_step_03;
while(node->key_name != NULL)
{
ret = cfstore_test_check_node_correct(node);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:node (key_name=\"%s\", value=\"%s\") not correct in cfstore\n", __func__, node->key_name, node->value);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
node++;
}
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("KV successfully decreased in size and other KVs remained unchanged.%s", "\n");
/* Delete the KV */
ret = cfstore_test_delete(cfstore_create_test_01_data[2].key_name);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:failed to delete node(key_name=\"%s\")\n", __func__, node->key_name);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
/* Now check that the KVs are all present and correct */
node = cfstore_create_test_01_data_step_04;
while(node->key_name != NULL)
{
ret = cfstore_test_check_node_correct(node);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:node (key_name=\"%s\", value=\"%s\") not correct in cfstore\n", __func__, node->key_name, node->value);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
node++;
}
free(test_buf1);
ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
return CaseNext;
}
示例14: while
//.........这里部分代码省略.........
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);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: kv_name incorrect length (len=%d, expected= %d).\n", __func__, (int) strlen(kv_name), (int) name_len);
TEST_ASSERT_MESSAGE(strlen(kv_name) == name_len, cfstore_open_utest_msg_g);
/* overwrite a char at the pos start, mid, end of the kv_name with an ascii char code (both illegal and legal)*/
switch(pos)
{
case cfstore_open_kv_name_pos_start:
kv_name[0] = (char) j;
break;
case cfstore_open_kv_name_pos_mid:
/* create bad keyname strings with invalid character code in the middle of keyname */
kv_name[name_len/2] = (char) j;
break;
case cfstore_open_kv_name_pos_end:
/* create bad keyname strings with invalid character code at end of keyname */
kv_name[name_len-1] = (char) j;
break;
default:
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: unexpected value of pos (pos=%d).\n", __func__, (int) pos);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
break;
}
#ifdef CFSTORE_DEBUG
/* processing only required when debug trace enabled */
switch(pos)
{
case cfstore_open_kv_name_pos_start:
pos_str = "start";
break;
case cfstore_open_kv_name_pos_mid:
pos_str = "middle";
break;
case cfstore_open_kv_name_pos_end:
pos_str = "end";
break;
default:
break;
}
#endif
ret = cfstore_test_create(kv_name, kv_name, &name_len, &kdesc);
/* special cases */
switch(j)
{
case 0 :
case 46 :
switch(pos)
{
/* for code = 0 (null terminator). permitted at mid and end of string */
/* for code = 46 ('.'). permitted at mid and end of string but not at start */
case cfstore_open_kv_name_pos_start:
f_allowed = false;
break;
case cfstore_open_kv_name_pos_mid:
case cfstore_open_kv_name_pos_end:
default:
f_allowed = true;
break;
}
break;
default:
f_allowed = node->f_allowed;
break;
}
if(f_allowed == true)
{
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to create KV in store when kv_name contains valid characters (code=%d, ret=%d).\n", __func__, (int) j, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Successfully created a KV with valid keyname containing ascii character code %d (%c) at the %s of the keyname.\n", (int) j, (int) j, pos_str);
CFSTORE_LOG("%c", '.');
ret = cfstore_test_delete(kv_name);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to delete KV previously created (code=%d, ret=%d).\n", __func__, (int) j, (int) ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
}
else
{ /*node->f_allowed == false => not allowed to create kv name with ascii code */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: created KV in store when kv_name contains an invalid character (code=%d, ret=%d).\n", __func__, (int) j, (int) ret);
TEST_ASSERT_MESSAGE(ret < ARM_DRIVER_OK, cfstore_open_utest_msg_g);
/* revert CFSTORE_LOG for more trace */
CFSTORE_DBGLOG("Successfully failed to create a KV with an invalid keyname containing ascii character code %d at the %s of the keyname.\n", (int) j, pos_str);
CFSTORE_LOG("%c", '.');
}
}
}
node++;
}
CFSTORE_LOG("%c", '\n');
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;
}