mirror of https://github.com/ARMmbed/mbed-os.git
cfstore flash integration changes for supporting storage flash sync/async mode configuration.
parent
bd4bfce7a2
commit
fec7b6694c
|
@ -20,18 +20,16 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
#include "mbed-drivers/mbed.h"
|
||||||
#include <mbed-drivers/mbed.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
||||||
#include "uvisor-lib/uvisor-lib.h"
|
#include "uvisor-lib/uvisor-lib.h"
|
||||||
#include "cfstore_uvisor.h"
|
#include "cfstore_uvisor.h"
|
||||||
|
@ -77,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -123,9 +118,12 @@ static cfstore_kv_data_t cfstore_add_del_test_07_data[] = {
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_add_del_test_00(const size_t call_count)
|
static control_t cfstore_add_del_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
|
ret = cfstore_test_startup();
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", caps.asynchronous_ops);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +147,6 @@ static control_t cfstore_add_del_test_01_end(const size_t call_count)
|
||||||
|
|
||||||
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
|
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("cfstore_add_del_test_07: Start%s", "\n");
|
|
||||||
memset(&kdesc, 0, sizeof(kdesc));
|
memset(&kdesc, 0, sizeof(kdesc));
|
||||||
memset(&flags, 0, sizeof(flags));
|
memset(&flags, 0, sizeof(flags));
|
||||||
|
|
||||||
|
@ -217,7 +214,6 @@ static control_t cfstore_add_del_test_02_end(const size_t call_count)
|
||||||
|
|
||||||
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
|
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("%s: Start\n", __func__);
|
|
||||||
memset(&kdesc, 0, sizeof(kdesc));
|
memset(&kdesc, 0, sizeof(kdesc));
|
||||||
|
|
||||||
/* create */
|
/* create */
|
||||||
|
@ -229,7 +225,8 @@ static control_t cfstore_add_del_test_02_end(const size_t call_count)
|
||||||
ret = cfstore_test_create(node->key_name, (char*) node->value, &len, &kdesc);
|
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);
|
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);
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
|
||||||
CFSTORE_LOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
|
||||||
node++;
|
node++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +242,8 @@ static control_t cfstore_add_del_test_02_end(const size_t call_count)
|
||||||
ret = cfstore_test_kv_is_found(node->key_name, &bResult);
|
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__);
|
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);
|
TEST_ASSERT_MESSAGE(ret == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND && bResult == false, cfstore_add_del_utest_msg_g);
|
||||||
CFSTORE_LOG("Found KV successfully (key_name=\"%s\")\n", node->key_name);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Found KV successfully (key_name=\"%s\")\n", node->key_name);
|
||||||
node++;
|
node++;
|
||||||
}
|
}
|
||||||
ret = drv->Uninitialize();
|
ret = drv->Uninitialize();
|
||||||
|
@ -286,7 +284,8 @@ static control_t cfstore_add_del_test_03_end(const size_t call_count)
|
||||||
cfstore_test_delete(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=%" PRId32 ").\n", __func__, ret);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error failed to delete a key (ret=%" PRId32 ").\n", __func__, ret);
|
||||||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_add_del_utest_msg_g);
|
||||||
CFSTORE_LOG("Deleted KV successfully (key_name=\"%s\")\n", node->key_name);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Deleted KV successfully (key_name=\"%s\")\n", node->key_name);
|
||||||
node++;
|
node++;
|
||||||
}
|
}
|
||||||
/* check the keys have been deleted */
|
/* check the keys have been deleted */
|
||||||
|
|
|
@ -21,15 +21,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,13 +75,10 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
|
@ -120,9 +114,12 @@ static cfstore_kv_data_t cfstore_close_test_01_kv_data[] = {
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_close_test_00(const size_t call_count)
|
static control_t cfstore_close_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
|
ret = cfstore_test_startup();
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", caps.asynchronous_ops);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_close_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -314,8 +308,12 @@ out1:
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_create_test_00(const size_t call_count)
|
static control_t cfstore_create_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +366,8 @@ static control_t cfstore_create_test_01_end(const size_t call_count)
|
||||||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
||||||
node++;
|
node++;
|
||||||
}
|
}
|
||||||
CFSTORE_LOG("KV successfully increased in size and other KVs remained unchanged.%s", "\n");
|
/* 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 */
|
/* 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]);
|
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=%" PRId32 ").\n", __func__, ret);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to decrease size of KV (ret=%" PRId32 ").\n", __func__, ret);
|
||||||
|
@ -383,7 +382,8 @@ static control_t cfstore_create_test_01_end(const size_t call_count)
|
||||||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
||||||
node++;
|
node++;
|
||||||
}
|
}
|
||||||
CFSTORE_LOG("KV successfully decreased in size and other KVs remained unchanged.%s", "\n");
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("KV successfully decreased in size and other KVs remained unchanged.%s", "\n");
|
||||||
|
|
||||||
/* Delete the KV */
|
/* Delete the KV */
|
||||||
ret = cfstore_test_delete(cfstore_create_test_01_data[2].key_name);
|
ret = cfstore_test_delete(cfstore_create_test_01_data[2].key_name);
|
||||||
|
@ -486,7 +486,8 @@ static control_t cfstore_create_test_03_end(const size_t call_count)
|
||||||
ret = cfstore_create_test_02_core(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=%" PRId32 ").\n", __func__, ret);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: something went wrong (ret=%" PRId32 ").\n", __func__, ret);
|
||||||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
||||||
CFSTORE_LOG("Successfully completed create/destroy loop %" PRId32 ".\n", i);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Successfully completed create/destroy loop %" PRId32 ".\n", i);
|
||||||
}
|
}
|
||||||
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
|
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);
|
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
|
||||||
|
@ -531,10 +532,11 @@ static control_t cfstore_create_test_04_end(const size_t call_count)
|
||||||
bytes_stored += kv_value_min_len/8 * (i+1); /* kv value blob */
|
bytes_stored += kv_value_min_len/8 * (i+1); /* kv value blob */
|
||||||
bytes_stored += 8; /* kv overhead */
|
bytes_stored += 8; /* kv overhead */
|
||||||
if(ret == ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY){
|
if(ret == ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY){
|
||||||
CFSTORE_LOG("Out of memory on %" PRId32 "-th KV, trying to allocate memory totalling %" PRIu32 ".\n", i, bytes_stored);
|
CFSTORE_ERRLOG("Out of memory on %" PRId32 "-th KV, trying to allocate memory totalling %" PRIu32 ".\n", i, bytes_stored);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CFSTORE_LOG("Successfully stored %" PRId32 "-th KV bytes, totalling %" PRIu32 ".\n", i, bytes_stored);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Successfully stored %" PRId32 "-th KV bytes, totalling %" PRIu32 ".\n", i, bytes_stored);
|
||||||
}
|
}
|
||||||
ret = cfstore_test_delete_all();
|
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=%" PRId32 ").\n", __func__, ret);
|
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=%" PRId32 ").\n", __func__, ret);
|
||||||
|
@ -585,10 +587,11 @@ static control_t cfstore_create_test_05_end(const size_t call_count)
|
||||||
bytes_stored += kv_value_min_len/64 * (i+1); /* kv value blob */
|
bytes_stored += kv_value_min_len/64 * (i+1); /* kv value blob */
|
||||||
bytes_stored += 8; /* kv overhead */
|
bytes_stored += 8; /* kv overhead */
|
||||||
if(ret == ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY){
|
if(ret == ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY){
|
||||||
CFSTORE_LOG("Out of memory on %" PRId32 "-th KV, trying to allocate memory totalling %" PRIu32 ".\n", i, bytes_stored);
|
CFSTORE_ERRLOG("Out of memory on %" PRId32 "-th KV, trying to allocate memory totalling %" PRIu32 ".\n", i, bytes_stored);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CFSTORE_LOG("Successfully stored %" PRId32 "-th KV bytes, totalling %" PRIu32 ".\n", i, bytes_stored);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Successfully stored %" PRId32 "-th KV bytes, totalling %" PRIu32 ".\n", i, bytes_stored);
|
||||||
}
|
}
|
||||||
ret = cfstore_test_delete_all();
|
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__);
|
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__);
|
||||||
|
|
|
@ -55,15 +55,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -112,14 +109,14 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
||||||
/* when built as Configuration-Store example, include greentea support otherwise omit */
|
/* when built as Configuration-Store example, include greentea support otherwise omit */
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
||||||
#else // YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
#else // YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
||||||
// map utest types for building as stand alone example
|
// map utest types for building as stand alone example
|
||||||
#define control_t void
|
#define control_t void
|
||||||
|
@ -127,7 +124,14 @@ int main()
|
||||||
#endif // YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
#endif // YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
#include "flash_journal_strategy_sequential.h"
|
||||||
|
#include "flash_journal.h"
|
||||||
|
#include "Driver_Common.h"
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_CONFIG_UVISOR
|
#ifdef YOTTA_CFG_CONFIG_UVISOR
|
||||||
#include "uvisor-lib/uvisor-lib.h"
|
#include "uvisor-lib/uvisor-lib.h"
|
||||||
#endif /* YOTTA_CFG_CONFIG_UVISOR */
|
#endif /* YOTTA_CFG_CONFIG_UVISOR */
|
||||||
|
@ -136,8 +140,6 @@ int main()
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE1_VERSION_STRING
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -254,6 +256,31 @@ ARM_CFSTORE_DRIVER *cfstore_drv = &cfstore_driver;
|
||||||
static void cfstore_ex_fms_update(cfstore_example1_ctx_t* ctx);
|
static void cfstore_ex_fms_update(cfstore_example1_ctx_t* ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/* @brief test startup code to reset flash
|
||||||
|
*/
|
||||||
|
int32_t cfstore_test_startup(void)
|
||||||
|
{
|
||||||
|
ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
|
||||||
|
CFSTORE_EX1_LOG("INITIALIZING: caps.asynchronous_ops=%d\n", (int) caps.asynchronous_ops);
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
FlashJournal_t jrnl;
|
||||||
|
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
||||||
|
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);
|
||||||
|
|
||||||
|
ret = FlashJournal_initialize(&jrnl, drv, &FLASH_JOURNAL_STRATEGY_SEQUENTIAL, NULL);
|
||||||
|
CFSTORE_EX1_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_initialize() failed (ret=%d)\r\n", __func__, (int) ret);
|
||||||
|
|
||||||
|
ret = FlashJournal_reset(&jrnl);
|
||||||
|
CFSTORE_EX1_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_reset() failed (ret=%d)\r\n", __func__, (int) ret);
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
|
return ARM_DRIVER_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void cfstore_ex_callback(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *client_context, ARM_CFSTORE_HANDLE handle)
|
static void cfstore_ex_callback(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *client_context, ARM_CFSTORE_HANDLE handle)
|
||||||
{
|
{
|
||||||
(void) handle;
|
(void) handle;
|
||||||
|
@ -768,6 +795,7 @@ static void cfstore_ex_fms_update(cfstore_example1_ctx_t* ctx)
|
||||||
|
|
||||||
static control_t cfstore_example1_app_start(const size_t call_count)
|
static control_t cfstore_example1_app_start(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
cfstore_example1_ctx_t* ctx = &cfstore_example1_ctx_g;
|
cfstore_example1_ctx_t* ctx = &cfstore_example1_ctx_g;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
|
@ -780,7 +808,6 @@ static control_t cfstore_example1_app_start(const size_t call_count)
|
||||||
ctx->callback_status = ARM_DRIVER_ERROR;
|
ctx->callback_status = ARM_DRIVER_ERROR;
|
||||||
ctx->state = CFSTORE_EX_STATE_INITIALIZING;
|
ctx->state = CFSTORE_EX_STATE_INITIALIZING;
|
||||||
ctx->caps = cfstore_drv->GetCapabilities();
|
ctx->caps = cfstore_drv->GetCapabilities();
|
||||||
CFSTORE_EX1_LOG("%s:INITIALIZING: caps.asynchronous_ops=%lu\n", __func__, ctx->caps.asynchronous_ops);
|
|
||||||
cfstore_ex_fms_update(ctx);
|
cfstore_ex_fms_update(ctx);
|
||||||
|
|
||||||
/* main application worker loop */
|
/* main application worker loop */
|
||||||
|
@ -809,8 +836,11 @@ static control_t cfstore_example1_app_start(const size_t call_count)
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_example1_test_00(const size_t call_count)
|
static control_t cfstore_example1_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_EX1_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
|
||||||
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_EX1_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,15 +35,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -93,15 +90,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -126,8 +120,12 @@ static char cfstore_example2_utest_msg_g[CFSTORE_UTEST_MSG_BUF_SIZE];
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_example2_test_00(const size_t call_count)
|
static control_t cfstore_example2_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_example2_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_example2_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,15 +50,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -108,9 +105,7 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE3_VERSION_STRING
|
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE3_VERSION_STRING
|
||||||
/* when built as Configuration-Store example, include greentea support otherwise omit */
|
/* when built as Configuration-Store example, include greentea support otherwise omit */
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
|
@ -123,7 +118,8 @@ int main()
|
||||||
#endif // YOTTA_CONFIGURATION_STORE_EXAMPLE3_VERSION_STRING
|
#endif // YOTTA_CONFIGURATION_STORE_EXAMPLE3_VERSION_STRING
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "cfstore_test.h"
|
||||||
|
#include "configuration_store.h"
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_CONFIG_UVISOR
|
#ifdef YOTTA_CFG_CONFIG_UVISOR
|
||||||
#include "uvisor-lib/uvisor-lib.h"
|
#include "uvisor-lib/uvisor-lib.h"
|
||||||
|
@ -336,8 +332,11 @@ static control_t cfstore_example3_app_start(const size_t call_count)
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_example3_test_00(const size_t call_count)
|
static control_t cfstore_example3_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_EX1_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_EX1_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -136,6 +130,7 @@ static const PvKeyValue_t testDataKeyValue[] = {
|
||||||
|
|
||||||
static control_t cfstore_example4_test_00(const size_t call_count)
|
static control_t cfstore_example4_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
ARM_CFSTORE_CAPABILITIES caps;;
|
ARM_CFSTORE_CAPABILITIES caps;;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
|
@ -149,6 +144,9 @@ static control_t cfstore_example4_test_00(const size_t call_count)
|
||||||
CFSTORE_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
|
CFSTORE_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_example4_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_example4_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,9 +244,9 @@ Case cases[] = {
|
||||||
/* 1 2 3 4 5 6 7 */
|
/* 1 2 3 4 5 6 7 */
|
||||||
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
||||||
Case("EXAMPLE4_test_00", cfstore_example4_test_00),
|
Case("EXAMPLE4_test_00", cfstore_example4_test_00),
|
||||||
#if defined YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS && YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS == 0
|
#if defined STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS && STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==0
|
||||||
Case("EXAMPLE4_test_01", cfstore_example4_test_01),
|
Case("EXAMPLE4_test_01", cfstore_example4_test_01),
|
||||||
#endif // YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS
|
#endif // STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,15 +49,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -106,10 +103,7 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
|
|
||||||
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE5_VERSION_STRING
|
#ifndef YOTTA_CONFIGURATION_STORE_EXAMPLE5_VERSION_STRING
|
||||||
|
@ -124,7 +118,13 @@ int main()
|
||||||
#endif // YOTTA_CONFIGURATION_STORE_EXAMPLE5_VERSION_STRING
|
#endif // YOTTA_CONFIGURATION_STORE_EXAMPLE5_VERSION_STRING
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
#include "flash_journal_strategy_sequential.h"
|
||||||
|
#include "flash_journal.h"
|
||||||
|
#include "Driver_Common.h"
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -203,6 +203,30 @@ extern ARM_CFSTORE_DRIVER cfstore_driver;
|
||||||
ARM_CFSTORE_DRIVER *cfstore_drv = &cfstore_driver;
|
ARM_CFSTORE_DRIVER *cfstore_drv = &cfstore_driver;
|
||||||
|
|
||||||
|
|
||||||
|
/* @brief test startup code to reset flash
|
||||||
|
*/
|
||||||
|
int32_t cfstore_test_startup(void)
|
||||||
|
{
|
||||||
|
ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
|
||||||
|
CFSTORE_EX5_LOG("INITIALIZING: caps.asynchronous_ops=%d\n", (int) caps.asynchronous_ops);
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
FlashJournal_t jrnl;
|
||||||
|
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
||||||
|
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);
|
||||||
|
|
||||||
|
ret = FlashJournal_initialize(&jrnl, drv, &FLASH_JOURNAL_STRATEGY_SEQUENTIAL, NULL);
|
||||||
|
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_initialize() failed (ret=%d)\r\n", __func__, (int) ret);
|
||||||
|
|
||||||
|
ret = FlashJournal_reset(&jrnl);
|
||||||
|
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_reset() failed (ret=%d)\r\n", __func__, (int) ret);
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
|
return ARM_DRIVER_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void cfstore_ex5_test_01(cfstore_EXAMPLE5_ctx_t* ctx)
|
static void cfstore_ex5_test_01(cfstore_EXAMPLE5_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
@ -234,13 +258,11 @@ static void cfstore_ex5_test_01(cfstore_EXAMPLE5_ctx_t* ctx)
|
||||||
ret = cfstore_drv->Flush();
|
ret = cfstore_drv->Flush();
|
||||||
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Flush() failed (ret=%ld)\r\n", __func__, ret);
|
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Flush() failed (ret=%ld)\r\n", __func__, ret);
|
||||||
|
|
||||||
/* commenting out the 2nd flush() means the test works.*/
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
//CFSTORE_EX5_LOG("FLUSHING2%s", "\r\n");
|
/* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED => flash storage support present.
|
||||||
//ret = cfstore_drv->Flush();
|
* if this was not the case (i.e. cfstore running SRAM in memory mode) then
|
||||||
//CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Flush() failed (ret=%ld)\r\n", __func__, ret);
|
* we dont compile in the Uninitialize()/Initialize() as the
|
||||||
|
* Uninitialize() clears the sram */
|
||||||
/* todo: re-instate when Flush() really persists to flash on mbedOSv3+++.
|
|
||||||
* currently in the supported sram version Uninitialize() clears the sram
|
|
||||||
CFSTORE_EX5_LOG("UNINITIALIZING1%s", "\r\n");
|
CFSTORE_EX5_LOG("UNINITIALIZING1%s", "\r\n");
|
||||||
ret = cfstore_drv->Uninitialize();
|
ret = cfstore_drv->Uninitialize();
|
||||||
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Uninitialize() should return ret >= 0 for synch mode(ret=%ld)\r\n", __func__, ret);
|
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Uninitialize() should return ret >= 0 for synch mode(ret=%ld)\r\n", __func__, ret);
|
||||||
|
@ -248,7 +270,7 @@ static void cfstore_ex5_test_01(cfstore_EXAMPLE5_ctx_t* ctx)
|
||||||
CFSTORE_EX5_LOG("INITIALIZING2%s", "\r\n");
|
CFSTORE_EX5_LOG("INITIALIZING2%s", "\r\n");
|
||||||
ret = cfstore_drv->Initialize(NULL, NULL);
|
ret = cfstore_drv->Initialize(NULL, NULL);
|
||||||
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Initialize() should return ret >= 0 for async/synch modes(ret=%ld)\r\n", __func__, ret);
|
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: Initialize() should return ret >= 0 for async/synch modes(ret=%ld)\r\n", __func__, ret);
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
CFSTORE_EX5_LOG("OPENING%s", "\r\n");
|
CFSTORE_EX5_LOG("OPENING%s", "\r\n");
|
||||||
memset(&ctx->flags, 0, sizeof(ctx->flags));
|
memset(&ctx->flags, 0, sizeof(ctx->flags));
|
||||||
|
@ -291,6 +313,7 @@ static void cfstore_ex5_test_01(cfstore_EXAMPLE5_ctx_t* ctx)
|
||||||
|
|
||||||
static control_t cfstore_EXAMPLE5_app_start(const size_t call_count)
|
static control_t cfstore_EXAMPLE5_app_start(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
cfstore_EXAMPLE5_ctx_t* ctx = &cfstore_EXAMPLE5_ctx_g;
|
cfstore_EXAMPLE5_ctx_t* ctx = &cfstore_EXAMPLE5_ctx_g;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
|
@ -307,6 +330,8 @@ static control_t cfstore_EXAMPLE5_app_start(const size_t call_count)
|
||||||
CFSTORE_EX5_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
|
CFSTORE_EX5_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= ARM_DRIVER_OK, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
cfstore_ex5_test_01(ctx);
|
cfstore_ex5_test_01(ctx);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -115,8 +109,12 @@ UVISOR_BOX_CONFIG(cfstore_find_box1, UVISOR_BOX_STACK_SIZE);
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_find_test_00(const size_t call_count)
|
static control_t cfstore_find_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_find_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -110,13 +104,8 @@ UVISOR_BOX_NAMESPACE("com.arm.mbed.cfstore.test.find2.box1");
|
||||||
UVISOR_BOX_CONFIG(cfstore_find2_box1, UVISOR_BOX_STACK_SIZE);
|
UVISOR_BOX_CONFIG(cfstore_find2_box1, UVISOR_BOX_STACK_SIZE);
|
||||||
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
||||||
|
|
||||||
|
|
||||||
extern ARM_CFSTORE_DRIVER cfstore_driver;
|
extern ARM_CFSTORE_DRIVER cfstore_driver;
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#define CFSTORE_FIND_MBED_HOSTTEST_TIMEOUT 60
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void cfstore_find2_callback(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *client_context, ARM_CFSTORE_HANDLE handle)
|
void cfstore_find2_callback(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *client_context, ARM_CFSTORE_HANDLE handle)
|
||||||
{
|
{
|
||||||
(void) status;
|
(void) status;
|
||||||
|
@ -129,8 +118,12 @@ void cfstore_find2_callback(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *c
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_find2_test_00(const size_t call_count)
|
static control_t cfstore_find2_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find2_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_find2_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,23 +20,27 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
||||||
#include "uvisor-lib/uvisor-lib.h"
|
#include "uvisor-lib/uvisor-lib.h"
|
||||||
#include "cfstore_uvisor.h"
|
#include "cfstore_uvisor.h"
|
||||||
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
#include "flash_journal_strategy_sequential.h"
|
||||||
|
#include "flash_journal.h"
|
||||||
|
#include "Driver_Common.h"
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -77,18 +81,21 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
|
||||||
#include <flash-journal-strategy-sequential/flash_journal_strategy_sequential.h>
|
|
||||||
#include <flash-journal/flash_journal.h>
|
|
||||||
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
#include "flash_journal_strategy_sequential.h"
|
||||||
|
#include "flash_journal.h"
|
||||||
|
#include "Driver_Common.h"
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
||||||
#include "uvisor-lib/uvisor-lib.h"
|
#include "uvisor-lib/uvisor-lib.h"
|
||||||
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
||||||
|
@ -133,7 +140,7 @@ UVISOR_BOX_CONFIG(cfstore_flash_box1, UVISOR_BOX_STACK_SIZE);
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
char cfstore_flash_utest_msg_g[CFSTORE_FLASH_UTEST_MSG_BUF_SIZE];
|
char cfstore_flash_utest_msg_g[CFSTORE_FLASH_UTEST_MSG_BUF_SIZE];
|
||||||
uint16_t cfstore_flash_mtd_async_ops_g = 0;
|
uint16_t cfstore_flash_mtd_async_ops_g = 0;
|
||||||
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
||||||
|
@ -703,9 +710,14 @@ static control_t cfstore_flash_journal_async_test_01(void)
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_flash_test_00(const size_t call_count)
|
static control_t cfstore_flash_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
#ifdef YOTTA_CFG_CFSTORE_BACKEND_SRAM
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flash_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flash_utest_msg_g);
|
||||||
|
|
||||||
|
#ifndef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
CFSTORE_LOG("INITIALIZING: BACKEND=SRAM. Skipping flash test%s", "\n");
|
CFSTORE_LOG("INITIALIZING: BACKEND=SRAM. Skipping flash test%s", "\n");
|
||||||
#endif
|
#endif
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
|
@ -714,7 +726,7 @@ static control_t cfstore_flash_test_00(const size_t call_count)
|
||||||
/* Specify all your test cases here */
|
/* Specify all your test cases here */
|
||||||
Case cases[] = {
|
Case cases[] = {
|
||||||
Case("flash_journal_async_test_00", cfstore_flash_test_00),
|
Case("flash_journal_async_test_00", cfstore_flash_test_00),
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
Case("flash_journal_async_test_01", cfstore_flash_journal_async_test_01),
|
Case("flash_journal_async_test_01", cfstore_flash_journal_async_test_01),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -595,8 +589,12 @@ static control_t cfstore_flush_test_02_k64f(void)
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_flush_test_00(const size_t call_count)
|
static control_t cfstore_flush_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,14 +75,11 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
|
@ -168,8 +162,12 @@ static void cfstore_flush_ctx_init(cfstore_flush_ctx_t* ctx)
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_flush2_test_00(const size_t call_count)
|
static control_t cfstore_flush2_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -77,15 +74,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -115,8 +109,12 @@ ARM_CFSTORE_DRIVER *cfstore_drv = &cfstore_driver;
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_init_test_00(const size_t call_count)
|
static control_t cfstore_init_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -79,16 +76,13 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -120,8 +114,12 @@ UVISOR_SET_MODE_ACL(UVISOR_ENABLED, cfstore_acl_uvisor_box_misc_g);
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_misc_test_00(const size_t call_count)
|
static control_t cfstore_misc_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_misc_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,10 +221,8 @@ static control_t cfstore_misc_test_02(const size_t call_count)
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
memset(&caps, 0, sizeof(caps));
|
memset(&caps, 0, sizeof(caps));
|
||||||
caps = drv->GetCapabilities();
|
caps = drv->GetCapabilities();
|
||||||
//CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Capabilities() failed to return asynchronous_ops == false.\r\n", __func__);
|
|
||||||
//TEST_ASSERT_MESSAGE(caps.asynchronous_ops == false, cfstore_misc_utest_msg_g);
|
|
||||||
|
|
||||||
#ifdef YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS
|
#ifdef STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS
|
||||||
/* sync mode */
|
/* sync mode */
|
||||||
printf("%s:sync mode: caps.asynchronous_ops =%" PRIu32 "\n", __func__, caps.asynchronous_ops);
|
printf("%s:sync mode: caps.asynchronous_ops =%" PRIu32 "\n", __func__, caps.asynchronous_ops);
|
||||||
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: GetCapabilities() reported caps.asynchronous_ops != false but system built for sync operation.\r\n", __func__);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: GetCapabilities() reported caps.asynchronous_ops != false but system built for sync operation.\r\n", __func__);
|
||||||
|
|
|
@ -21,15 +21,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -135,8 +129,12 @@ static cfstore_kv_data_t cfstore_open_test_01_kv_data[] = {
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_open_test_00(const size_t call_count)
|
static control_t cfstore_open_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +533,9 @@ static control_t cfstore_open_test_05_end(const size_t call_count)
|
||||||
{
|
{
|
||||||
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=%" PRId32 ", ret=%" PRId32 ").\n", __func__, j, ret);
|
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=%" PRId32 ", ret=%" PRId32 ").\n", __func__, j, ret);
|
||||||
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
|
||||||
CFSTORE_LOG("Successfully created a KV with valid keyname containing ascii character code %" PRIu32 " (%c) at the %s of the keyname.\n", j, (int) j, pos_str);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Successfully created a KV with valid keyname containing ascii character code %" PRIu32 " (%c) at the %s of the keyname.\n", j, (int) j, pos_str);
|
||||||
|
CFSTORE_LOG("%c", '.');
|
||||||
|
|
||||||
ret = cfstore_test_delete(kv_name);
|
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=%" PRId32 ", ret=%" PRId32 ").\n", __func__, j, ret);
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to delete KV previously created (code=%" PRId32 ", ret=%" PRId32 ").\n", __func__, j, ret);
|
||||||
|
@ -545,13 +545,16 @@ static control_t cfstore_open_test_05_end(const size_t call_count)
|
||||||
{ /*node->f_allowed == false => not allowed to create kv name with ascii code */
|
{ /*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=%" PRId32 ", ret=%" PRId32 ").\n", __func__, j, ret);
|
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=%" PRId32 ", ret=%" PRId32 ").\n", __func__, j, ret);
|
||||||
TEST_ASSERT_MESSAGE(ret < ARM_DRIVER_OK, cfstore_open_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret < ARM_DRIVER_OK, cfstore_open_utest_msg_g);
|
||||||
CFSTORE_LOG("Successfully failed to create a KV with an invalid keyname containing ascii character code %" PRId32 " at the %s of the keyname.\n", j, pos_str);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Successfully failed to create a KV with an invalid keyname containing ascii character code %" PRId32 " at the %s of the keyname.\n", j, pos_str);
|
||||||
|
CFSTORE_LOG("%c", '.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node++;
|
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__);
|
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);
|
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_open_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -119,8 +113,12 @@ static cfstore_kv_data_t cfstore_read_test_01_kv_data[] = {
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_read_test_00(const size_t call_count)
|
static control_t cfstore_read_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_read_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_read_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
#if defined __MBED__ && ! defined TOOLCHAIN_GCC_ARM
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -78,15 +75,12 @@ int main()
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "Driver_Common.h"
|
#include "Driver_Common.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
@ -125,8 +119,12 @@ static cfstore_kv_data_t cfstore_write_test_01_kv_data[] = {
|
||||||
/* report whether built/configured for flash sync or async mode */
|
/* report whether built/configured for flash sync or async mode */
|
||||||
static control_t cfstore_write_test_00(const size_t call_count)
|
static control_t cfstore_write_test_00(const size_t call_count)
|
||||||
{
|
{
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%lu\n", cfstore_driver.GetCapabilities().asynchronous_ops);
|
ret = cfstore_test_startup();
|
||||||
|
CFSTORE_TEST_UTEST_MESSAGE(cfstore_write_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to perform test startup (ret=%d).\n", __func__, (int) ret);
|
||||||
|
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_write_utest_msg_g);
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,16 +102,11 @@ typedef struct _ARM_CFSTORE_STATUS {
|
||||||
*
|
*
|
||||||
* CFSTORE_HANDLE_BUFSIZE
|
* CFSTORE_HANDLE_BUFSIZE
|
||||||
* size of the buffer owned and supplied by client to CFSTORE to hold internal
|
* size of the buffer owned and supplied by client to CFSTORE to hold internal
|
||||||
* data structures, referenced by the key handle. Note this can change on
|
* data structures, referenced by the key handle.
|
||||||
* different platforms depending on the sizeof types.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define CFSTORE_KEY_NAME_MAX_LENGTH 220
|
#define CFSTORE_KEY_NAME_MAX_LENGTH 220
|
||||||
#define CFSTORE_VALUE_SIZE_MAX (1<<26)
|
#define CFSTORE_VALUE_SIZE_MAX (1<<26)
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
#define CFSTORE_HANDLE_BUFSIZE 24
|
#define CFSTORE_HANDLE_BUFSIZE 24
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_X86_LINUX_NATIVE
|
#ifdef TARGET_LIKE_X86_LINUX_NATIVE
|
||||||
#define CFSTORE_HANDLE_BUFSIZE 40
|
#define CFSTORE_HANDLE_BUFSIZE 40
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "configuration-store",
|
||||||
|
"config": {
|
||||||
|
"storage_disable": {
|
||||||
|
"help": "Configuration parameter to disable flash storage if present. Default = 0, implying that by default flash storage is used if present.",
|
||||||
|
"macro_name": "CFSTORE_STORAGE_DISABLE",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,6 @@
|
||||||
/*
|
/*
|
||||||
* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
* = 1 >1 build with the flash
|
* = 1 >1 build with the flash
|
||||||
* CFSTORE_CONFIG_BACKEND_SRAM_ENABLED
|
|
||||||
* CFSTORE_CONFIG_BACKEND_UVISOR_ENABLED
|
* CFSTORE_CONFIG_BACKEND_UVISOR_ENABLED
|
||||||
* CFSTORE_CONFIG_MBED_OS_VERSION
|
* CFSTORE_CONFIG_MBED_OS_VERSION
|
||||||
* 3 => mbedosV3
|
* 3 => mbedosV3
|
||||||
|
@ -18,8 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* default values */
|
/* default values */
|
||||||
#define CFSTORE_CONFIG_BACKEND_FLASH_ENABLED 1
|
|
||||||
#define CFSTORE_CONFIG_BACKEND_SRAM_ENABLED 0
|
|
||||||
#define CFSTORE_CONFIG_BACKEND_UVISOR_ENABLED 0
|
#define CFSTORE_CONFIG_BACKEND_UVISOR_ENABLED 0
|
||||||
#define CFSTORE_CONFIG_MBED_OS_VERSION 3
|
#define CFSTORE_CONFIG_MBED_OS_VERSION 3
|
||||||
|
|
||||||
|
@ -38,23 +35,25 @@
|
||||||
#ifdef __MBED__
|
#ifdef __MBED__
|
||||||
#undef CFSTORE_CONFIG_MBED_OS_VERSION
|
#undef CFSTORE_CONFIG_MBED_OS_VERSION
|
||||||
#define CFSTORE_CONFIG_MBED_OS_VERSION 4
|
#define CFSTORE_CONFIG_MBED_OS_VERSION 4
|
||||||
/* currently build only sram version (port flash-journal later) */
|
|
||||||
|
|
||||||
#define YOTTA_CFG_CFSTORE_BACKEND_SRAM
|
|
||||||
|
|
||||||
/* define the symbol that yotta would define for the k64f target */
|
|
||||||
#define TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
|
|
||||||
/* at present time building for sram so set yotta symbol for sync mode i.e. async_ops = 0*/
|
/* at present time building for sram so set yotta symbol for sync mode i.e. async_ops = 0*/
|
||||||
#define YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS 0
|
#define YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS 0
|
||||||
#endif /* __MBED__ */
|
#endif /* __MBED__ */
|
||||||
|
|
||||||
#if defined YOTTA_CFG_CFSTORE_BACKEND_SRAM
|
/* DEVICE_STORAGE
|
||||||
#undef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
* defined by the mbed configuration system if a target supports flash storage
|
||||||
#define CFSTORE_CONFIG_BACKEND_FLASH_ENABLED 0
|
* back-end. See targets.json for target flash support.
|
||||||
#undef CFSTORE_CONFIG_BACKEND_SRAM_ENABLED
|
* - If a target supports storage then by default cfstore will persist KVs to
|
||||||
#define CFSTORE_CONFIG_BACKEND_SRAM_ENABLED 1
|
* storage.
|
||||||
#endif /* YOTTA_CFG_CFSTORE_BACKEND_SRAM */
|
* - If a target does not support storage then (by default) cfstore will store KVs
|
||||||
|
* in SRAM only (i.e. operate in SRAM in-memory mode).
|
||||||
|
*
|
||||||
|
* CFSTORE_STORAGE_DISABLE
|
||||||
|
* Disable use of storage support (if present)
|
||||||
|
*/
|
||||||
|
#if defined DEVICE_STORAGE && CFSTORE_STORAGE_DISABLE==0
|
||||||
|
#define CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /*__CFSTORE_CONFIG_H*/
|
#endif /*__CFSTORE_CONFIG_H*/
|
||||||
|
|
|
@ -109,7 +109,7 @@ do
|
||||||
#define CFSTORE_ASSERT(_x) do { } while(0)
|
#define CFSTORE_ASSERT(_x) do { } while(0)
|
||||||
#define CFSTORE_INLINE inline
|
#define CFSTORE_INLINE inline
|
||||||
#define CFSTORE_DBGLOG(_fmt, ...) do { } while(0)
|
#define CFSTORE_DBGLOG(_fmt, ...) do { } while(0)
|
||||||
#define CFSTORE_ERRLOG(_fmt, ...) do { printf(_fmt, __VA_ARGS__); } while(0)
|
#define CFSTORE_ERRLOG(_fmt, ...) do { } while(0)
|
||||||
#define CFSTORE_FENTRYLOG(_fmt, ...) do { } while(0)
|
#define CFSTORE_FENTRYLOG(_fmt, ...) do { } while(0)
|
||||||
#define CFSTORE_TP(_tp, _fmt, ...) do { } while(0)
|
#define CFSTORE_TP(_tp, _fmt, ...) do { } while(0)
|
||||||
#endif /* CFSTORE_DEBUG */
|
#endif /* CFSTORE_DEBUG */
|
||||||
|
|
|
@ -33,16 +33,16 @@
|
||||||
#ifndef _NO_FNMATCH
|
#ifndef _NO_FNMATCH
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
|
static char sccsid[] = "@(#)cfstore_fnmatch.c 8.2 (Berkeley) 4/16/94";
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
/* In order to support ARM toolchain, this have been removed from the original
|
/* In order to support ARM toolchain, this have been removed from the original
|
||||||
* fnmatch.c from newlib.
|
* cfstore_fnmatch.c from newlib.
|
||||||
* #include <sys/cdefs.h>
|
* #include <sys/cdefs.h>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
|
* Function cfstore_fnmatch() as specified in POSIX 1003.2-1992, section B.6.
|
||||||
* Compares a filename or pathname to a pattern.
|
* Compares a filename or pathname to a pattern.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
/* code copied from the original fnmatch.h */
|
/* code copied from the original cfstore_fnmatch.h */
|
||||||
|
|
||||||
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
|
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
|
||||||
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
|
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
|
||||||
|
@ -157,10 +157,7 @@ int __collate_range_cmp (c1, c2)
|
||||||
|
|
||||||
static int rangematch(const char *, char, int, char **);
|
static int rangematch(const char *, char, int, char **);
|
||||||
|
|
||||||
int
|
int cfstore_fnmatch(const char *pattern, const char *string, int flags)
|
||||||
fnmatch(pattern, string, flags)
|
|
||||||
const char *pattern, *string;
|
|
||||||
int flags;
|
|
||||||
{
|
{
|
||||||
const char *stringstart;
|
const char *stringstart;
|
||||||
char *newp;
|
char *newp;
|
||||||
|
@ -210,7 +207,7 @@ fnmatch(pattern, string, flags)
|
||||||
|
|
||||||
/* General case, use recursion. */
|
/* General case, use recursion. */
|
||||||
while ((test = *string) != EOS) {
|
while ((test = *string) != EOS) {
|
||||||
if (!fnmatch(pattern, string, flags & ~FNM_PERIOD))
|
if (!cfstore_fnmatch(pattern, string, flags & ~FNM_PERIOD))
|
||||||
return (0);
|
return (0);
|
||||||
if (test == '/' && flags & FNM_PATHNAME)
|
if (test == '/' && flags & FNM_PATHNAME)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,10 +17,18 @@
|
||||||
*
|
*
|
||||||
* test support code implementation file.
|
* test support code implementation file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cfstore_config.h"
|
#include "cfstore_config.h"
|
||||||
#include "cfstore_debug.h"
|
#include "cfstore_debug.h"
|
||||||
#include "cfstore_test.h"
|
#include "cfstore_test.h"
|
||||||
#include <configuration_store.h>
|
#include "configuration_store.h"
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
#include "flash_journal_strategy_sequential.h"
|
||||||
|
#include "flash_journal.h"
|
||||||
|
#include "Driver_Common.h"
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -105,6 +113,39 @@ const char* cfstore_test_opcode_str[] =
|
||||||
"CFSTORE_OPCODE_WRITE",
|
"CFSTORE_OPCODE_WRITE",
|
||||||
"CFSTORE_OPCODE_MAX"
|
"CFSTORE_OPCODE_MAX"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* @brief test startup code to reset flash
|
||||||
|
*/
|
||||||
|
int32_t cfstore_test_startup(void)
|
||||||
|
{
|
||||||
|
ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
|
||||||
|
CFSTORE_LOG("INITIALIZING: caps.asynchronous_ops=%d\n", (int) caps.asynchronous_ops);
|
||||||
|
|
||||||
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
|
||||||
|
int32_t ret = ARM_DRIVER_ERROR;
|
||||||
|
FlashJournal_t jrnl;
|
||||||
|
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
||||||
|
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);
|
||||||
|
|
||||||
|
ret = FlashJournal_initialize(&jrnl, drv, &FLASH_JOURNAL_STRATEGY_SEQUENTIAL, NULL);
|
||||||
|
if(ret < JOURNAL_STATUS_OK){
|
||||||
|
CFSTORE_ERRLOG("%s:Error: failed to initialize flash journaling layer (ret=%d)\n", __func__, (int) ret);
|
||||||
|
return ARM_DRIVER_ERROR;
|
||||||
|
}
|
||||||
|
ret = FlashJournal_reset(&jrnl);
|
||||||
|
if(ret < JOURNAL_STATUS_OK){
|
||||||
|
CFSTORE_ERRLOG("%s:Error: failed to reset flash journal (ret=%" PRId32 ")\n", __func__, ret);
|
||||||
|
return ARM_DRIVER_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
|
return ARM_DRIVER_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @brief test utility function to check a node appears correctly in the cfstore
|
/* @brief test utility function to check a node appears correctly in the cfstore
|
||||||
* @note this function expects cfstore to have been initialised with
|
* @note this function expects cfstore to have been initialised with
|
||||||
* a call to ARM_CFSTORE_DRIVER::Initialize()
|
* a call to ARM_CFSTORE_DRIVER::Initialize()
|
||||||
|
@ -421,7 +462,8 @@ int32_t cfstore_test_init_1(void)
|
||||||
drv->Close(hkey);
|
drv->Close(hkey);
|
||||||
return ARM_DRIVER_ERROR;
|
return ARM_DRIVER_ERROR;
|
||||||
}
|
}
|
||||||
CFSTORE_LOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\r\n", key_name_buf, read_buf);
|
/* revert CFSTORE_LOG for more trace */
|
||||||
|
CFSTORE_DBGLOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\r\n", key_name_buf, read_buf);
|
||||||
drv->Close(hkey);
|
drv->Close(hkey);
|
||||||
node++;
|
node++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "configuration_store.h"
|
||||||
|
|
||||||
/* Defines */
|
/* Defines */
|
||||||
#define CFSTORE_INIT_1_TABLE_HEAD { "a", ""}
|
#define CFSTORE_INIT_1_TABLE_HEAD { "a", ""}
|
||||||
|
@ -75,6 +75,7 @@ int32_t cfstore_test_init_1(void);
|
||||||
int32_t cfstore_test_kv_is_found(const char* key_name, bool* bfound);
|
int32_t cfstore_test_kv_is_found(const char* key_name, bool* bfound);
|
||||||
int32_t cfstore_test_kv_name_gen(char* name, const size_t len);
|
int32_t cfstore_test_kv_name_gen(char* name, const size_t len);
|
||||||
int32_t cfstore_test_read(const char* key_name, char* data, size_t* len);
|
int32_t cfstore_test_read(const char* key_name, char* data, size_t* len);
|
||||||
|
int32_t cfstore_test_startup(void);
|
||||||
int32_t cfstore_test_write(const char* key_name, const char* data, size_t* len);
|
int32_t cfstore_test_write(const char* key_name, const char* data, size_t* len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -16,24 +16,25 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cfstore_fnmatch.h>
|
#include "cfstore_config.h"
|
||||||
|
#include "cfstore_debug.h"
|
||||||
|
#include "cfstore_list.h"
|
||||||
|
#include "cfstore_fnmatch.h"
|
||||||
|
#include "configuration_store.h"
|
||||||
|
|
||||||
#if defined CFSTORE_CONFIG_MBED_OS_VERSION && CFSTORE_CONFIG_MBED_OS_VERSION == 3
|
#if defined CFSTORE_CONFIG_MBED_OS_VERSION && CFSTORE_CONFIG_MBED_OS_VERSION == 3
|
||||||
#include <core-util/critical.h>
|
#include <core-util/critical.h>
|
||||||
#endif /* CFSTORE_CONFIG_MBED_OS_VERSION == 3 */
|
#endif /* CFSTORE_CONFIG_MBED_OS_VERSION == 3 */
|
||||||
#include "cfstore_config.h"
|
|
||||||
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
#ifdef YOTTA_CFG_CFSTORE_UVISOR
|
||||||
#include "uvisor-lib/uvisor-lib.h"
|
#include "uvisor-lib/uvisor-lib.h"
|
||||||
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
#endif /* YOTTA_CFG_CFSTORE_UVISOR */
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
|
||||||
#include <flash-journal-strategy-sequential/flash_journal_strategy_sequential.h>
|
|
||||||
#include <flash-journal/flash_journal.h>
|
|
||||||
#include <Driver_Common.h>
|
|
||||||
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
|
||||||
|
|
||||||
#include "cfstore_debug.h"
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
#include "cfstore_list.h"
|
#include "flash_journal_strategy_sequential.h"
|
||||||
#include "configuration-store/configuration_store.h"
|
#include "flash_journal.h"
|
||||||
|
#include "Driver_Common.h"
|
||||||
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -52,7 +53,7 @@ uint32_t cfstore_optLogTracepoint_g = CFSTORE_TP_NONE; /*CFSTORE_TP_NONE|CFSTORE
|
||||||
/*
|
/*
|
||||||
* Externs
|
* Externs
|
||||||
*/
|
*/
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
|
||||||
ARM_DRIVER_STORAGE *cfstore_storage_drv = &ARM_Driver_Storage_(0);
|
ARM_DRIVER_STORAGE *cfstore_storage_drv = &ARM_Driver_Storage_(0);
|
||||||
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
@ -193,7 +194,7 @@ typedef struct cfstore_fsm_t
|
||||||
|
|
||||||
|
|
||||||
#ifdef CFSTORE_DEBUG
|
#ifdef CFSTORE_DEBUG
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
/* strings used for debug trace */
|
/* strings used for debug trace */
|
||||||
static const char* cfstore_flash_opcode_str[] =
|
static const char* cfstore_flash_opcode_str[] =
|
||||||
{
|
{
|
||||||
|
@ -234,7 +235,7 @@ static const char* cfstore_flash_event_str[] =
|
||||||
/*
|
/*
|
||||||
* Forward decl
|
* Forward decl
|
||||||
*/
|
*/
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
static int32_t cfstore_fsm_state_handle_event(cfstore_fsm_t* fsm, cfstore_fsm_event_t event, void* context);
|
static int32_t cfstore_fsm_state_handle_event(cfstore_fsm_t* fsm, cfstore_fsm_event_t event, void* context);
|
||||||
static int32_t cfstore_fsm_state_set(cfstore_fsm_t* fsm, cfstore_fsm_state_t new_state, void* ctx);
|
static int32_t cfstore_fsm_state_set(cfstore_fsm_t* fsm, cfstore_fsm_state_t new_state, void* ctx);
|
||||||
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
@ -384,7 +385,7 @@ typedef struct cfstore_ctx_t
|
||||||
uint32_t area_dirty_flag : 1;
|
uint32_t area_dirty_flag : 1;
|
||||||
uint32_t f_reserved0 : 30;
|
uint32_t f_reserved0 : 30;
|
||||||
|
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
/* flash journal related data */
|
/* flash journal related data */
|
||||||
FlashJournal_t jrnl;
|
FlashJournal_t jrnl;
|
||||||
FlashJournal_Info_t info;
|
FlashJournal_Info_t info;
|
||||||
|
@ -439,11 +440,11 @@ typedef struct cfstore_flash_journal_error_code_node
|
||||||
/*
|
/*
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
#ifndef YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS
|
#ifndef STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS
|
||||||
static ARM_CFSTORE_CAPABILITIES cfstore_caps_g = { .asynchronous_ops = 1, .uvisor_support_enabled = 0 };
|
static ARM_CFSTORE_CAPABILITIES cfstore_caps_g = { .asynchronous_ops = 1, .uvisor_support_enabled = 0 };
|
||||||
#else
|
#else
|
||||||
static ARM_CFSTORE_CAPABILITIES cfstore_caps_g = { .asynchronous_ops = YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS, .uvisor_support_enabled = 0 };
|
static ARM_CFSTORE_CAPABILITIES cfstore_caps_g = { .asynchronous_ops = STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS, .uvisor_support_enabled = 0 };
|
||||||
#endif /* YOTTA_CFG_CONFIG_HARDWARE_MTD_ASYNC_OPS */
|
#endif /* STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS */
|
||||||
|
|
||||||
static const ARM_DRIVER_VERSION cfstore_driver_version_g = { .api = ARM_CFSTORE_API_VERSION, .drv = ARM_CFSTORE_DRV_VERSION };
|
static const ARM_DRIVER_VERSION cfstore_driver_version_g = { .api = ARM_CFSTORE_API_VERSION, .drv = ARM_CFSTORE_DRV_VERSION };
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ static ARM_CFSTORE_SIZE cfstore_ctx_get_area_len(void)
|
||||||
static inline uint32_t cfstore_ctx_get_program_unit(cfstore_ctx_t* ctx)
|
static inline uint32_t cfstore_ctx_get_program_unit(cfstore_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
CFSTORE_ASSERT(ctx!= NULL);
|
CFSTORE_ASSERT(ctx!= NULL);
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
return ctx->info.program_unit;
|
return ctx->info.program_unit;
|
||||||
#else
|
#else
|
||||||
/* the program unit is 1 so byte aligned when no flash backend present */
|
/* the program unit is 1 so byte aligned when no flash backend present */
|
||||||
|
@ -729,10 +730,45 @@ void *cfstore_realloc(void *ptr, ARM_CFSTORE_SIZE size)
|
||||||
|
|
||||||
#endif /* CFSTORE_YOTTA_CFG_CFSTORE_SRAM_ADDR */
|
#endif /* CFSTORE_YOTTA_CFG_CFSTORE_SRAM_ADDR */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TARGET_LIKE_X86_LINUX_NATIVE
|
||||||
|
static inline void cfstore_critical_section_init(CFSTORE_LOCK* lock){ *lock = 0; }
|
||||||
|
static inline void cfstore_critical_section_lock(CFSTORE_LOCK* lock, const char* tag){ (void) tag; __sync_fetch_and_add(lock, 1); }
|
||||||
|
static inline void cfstore_critical_section_unlock(CFSTORE_LOCK* lock, const char* tag){(void) tag; __sync_fetch_and_sub(lock, 1); }
|
||||||
|
|
||||||
|
static CFSTORE_INLINE int32_t cfstore_hkvt_refcount_dec(cfstore_area_hkvt_t* hkvt, uint8_t *refcount)
|
||||||
|
{
|
||||||
|
cfstore_area_header_t *hdr = (cfstore_area_header_t*) hkvt->head;
|
||||||
|
uint32_t __refcount;
|
||||||
|
|
||||||
|
__refcount =__sync_fetch_and_sub(&hdr->refcount, 1);
|
||||||
|
if(refcount) *refcount = __refcount;
|
||||||
|
return ARM_DRIVER_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CFSTORE_INLINE int32_t cfstore_hkvt_refcount_inc(cfstore_area_hkvt_t* hkvt, uint8_t *refcount)
|
||||||
|
{
|
||||||
|
int32_t ret = ARM_CFSTORE_DRIVER_ERROR_HANDLE_COUNT_MAX;
|
||||||
|
uint32_t __refcount;
|
||||||
|
cfstore_area_header_t *hdr = (cfstore_area_header_t*) hkvt->head;
|
||||||
|
|
||||||
|
if( (__refcount = __sync_fetch_and_add(&hdr->refcount, 1)) < CFSTORE_LOCK_REFCOUNT_MAX) {
|
||||||
|
if(refcount) *refcount = __refcount;
|
||||||
|
ret = ARM_DRIVER_OK;
|
||||||
|
} else {
|
||||||
|
/* maximum count reach, back down and return error*/
|
||||||
|
__sync_fetch_and_sub(&hdr->refcount, 1);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Platform Specific Function Implementations
|
* Platform Specific Function Implementations
|
||||||
*/
|
*/
|
||||||
#ifdef TARGET_LIKE_FRDM_K64F_GCC
|
|
||||||
static inline void cfstore_critical_section_init(CFSTORE_LOCK* lock){ *lock = 0; }
|
static inline void cfstore_critical_section_init(CFSTORE_LOCK* lock){ *lock = 0; }
|
||||||
static inline void cfstore_critical_section_unlock(CFSTORE_LOCK* lock, const char* tag)
|
static inline void cfstore_critical_section_unlock(CFSTORE_LOCK* lock, const char* tag)
|
||||||
{
|
{
|
||||||
|
@ -780,39 +816,6 @@ static CFSTORE_INLINE int32_t cfstore_hkvt_refcount_inc(cfstore_area_hkvt_t* hkv
|
||||||
/* todo: put mbedosv3++ critical section exit here */
|
/* todo: put mbedosv3++ critical section exit here */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* TARGET_LIKE_FRDM_K64F_GCC */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_LIKE_X86_LINUX_NATIVE
|
|
||||||
static inline void cfstore_critical_section_init(CFSTORE_LOCK* lock){ *lock = 0; }
|
|
||||||
static inline void cfstore_critical_section_lock(CFSTORE_LOCK* lock, const char* tag){ (void) tag; __sync_fetch_and_add(lock, 1); }
|
|
||||||
static inline void cfstore_critical_section_unlock(CFSTORE_LOCK* lock, const char* tag){(void) tag; __sync_fetch_and_sub(lock, 1); }
|
|
||||||
|
|
||||||
static CFSTORE_INLINE int32_t cfstore_hkvt_refcount_dec(cfstore_area_hkvt_t* hkvt, uint8_t *refcount)
|
|
||||||
{
|
|
||||||
cfstore_area_header_t *hdr = (cfstore_area_header_t*) hkvt->head;
|
|
||||||
uint32_t __refcount;
|
|
||||||
|
|
||||||
__refcount =__sync_fetch_and_sub(&hdr->refcount, 1);
|
|
||||||
if(refcount) *refcount = __refcount;
|
|
||||||
return ARM_DRIVER_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CFSTORE_INLINE int32_t cfstore_hkvt_refcount_inc(cfstore_area_hkvt_t* hkvt, uint8_t *refcount)
|
|
||||||
{
|
|
||||||
int32_t ret = ARM_CFSTORE_DRIVER_ERROR_HANDLE_COUNT_MAX;
|
|
||||||
uint32_t __refcount;
|
|
||||||
cfstore_area_header_t *hdr = (cfstore_area_header_t*) hkvt->head;
|
|
||||||
|
|
||||||
if( (__refcount = __sync_fetch_and_add(&hdr->refcount, 1)) < CFSTORE_LOCK_REFCOUNT_MAX) {
|
|
||||||
if(refcount) *refcount = __refcount;
|
|
||||||
ret = ARM_DRIVER_OK;
|
|
||||||
} else {
|
|
||||||
/* maximum count reach, back down and return error*/
|
|
||||||
__sync_fetch_and_sub(&hdr->refcount, 1);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TARGET_LIKE_X86_LINUX_NATIVE */
|
#endif /* TARGET_LIKE_X86_LINUX_NATIVE */
|
||||||
|
|
||||||
|
@ -1336,7 +1339,7 @@ static int32_t cfstore_flash_set_tail(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* flash helper functions
|
* flash helper functions
|
||||||
|
@ -1615,8 +1618,6 @@ static int32_t cfstore_fsm_reading(void* context)
|
||||||
memset(&ctx->info, 0, sizeof(ctx->info));
|
memset(&ctx->info, 0, sizeof(ctx->info));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* clear info data */
|
|
||||||
memset(&ctx->info, 0, sizeof(ctx->info));
|
|
||||||
ret = cfstore_fsm_state_set(&ctx->fsm, cfstore_fsm_state_ready, ctx);
|
ret = cfstore_fsm_state_set(&ctx->fsm, cfstore_fsm_state_ready, ctx);
|
||||||
if(ret < ARM_DRIVER_OK){
|
if(ret < ARM_DRIVER_OK){
|
||||||
CFSTORE_ERRLOG("%s:Error: cfstore_fsm_state_set() failed (ret=%" PRId32 ")\n", __func__, ret);
|
CFSTORE_ERRLOG("%s:Error: cfstore_fsm_state_set() failed (ret=%" PRId32 ")\n", __func__, ret);
|
||||||
|
@ -2970,14 +2971,14 @@ static int32_t cfstore_find_ex(const char* key_name_query, cfstore_area_hkvt_t *
|
||||||
next_key_len = cfstore_hkvt_get_key_len(next);
|
next_key_len = cfstore_hkvt_get_key_len(next);
|
||||||
next_key_len++;
|
next_key_len++;
|
||||||
cfstore_get_key_name_ex(next, key_name, &next_key_len);
|
cfstore_get_key_name_ex(next, key_name, &next_key_len);
|
||||||
ret = fnmatch(key_name_query, key_name, 0);
|
ret = cfstore_fnmatch(key_name_query, key_name, 0);
|
||||||
if(ret == 0){
|
if(ret == 0){
|
||||||
/* found the entry in the store. return handle */
|
/* found the entry in the store. return handle */
|
||||||
CFSTORE_TP(CFSTORE_TP_FIND, "%s:Found matching key (key_name_query = \"%s\", next->key = \"%s\"),next_key_len=%d\n", __func__, key_name_query, key_name, (int) next_key_len);
|
CFSTORE_TP(CFSTORE_TP_FIND, "%s:Found matching key (key_name_query = \"%s\", next->key = \"%s\"),next_key_len=%d\n", __func__, key_name_query, key_name, (int) next_key_len);
|
||||||
cfstore_hkvt_dump(next, __func__);
|
cfstore_hkvt_dump(next, __func__);
|
||||||
return ARM_DRIVER_OK;
|
return ARM_DRIVER_OK;
|
||||||
} else if(ret != CFSTORE_FNM_NOMATCH){
|
} else if(ret != CFSTORE_FNM_NOMATCH){
|
||||||
CFSTORE_ERRLOG("%s:Error: fnmatch() error (ret=%" PRId32 ").\n", __func__, ret);
|
CFSTORE_ERRLOG("%s:Error: cfstore_fnmatch() error (ret=%" PRId32 ").\n", __func__, ret);
|
||||||
return ARM_DRIVER_ERROR;
|
return ARM_DRIVER_ERROR;
|
||||||
}
|
}
|
||||||
/* CFSTORE_FNM_NOMATCH => get the next hkvt if any */
|
/* CFSTORE_FNM_NOMATCH => get the next hkvt if any */
|
||||||
|
@ -3721,7 +3722,7 @@ static int32_t cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void* client_co
|
||||||
{
|
{
|
||||||
int ret = ARM_DRIVER_ERROR;
|
int ret = ARM_DRIVER_ERROR;
|
||||||
cfstore_ctx_t* ctx = cfstore_ctx_get();
|
cfstore_ctx_t* ctx = cfstore_ctx_get();
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
ARM_STORAGE_CAPABILITIES storage_caps;
|
ARM_STORAGE_CAPABILITIES storage_caps;
|
||||||
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */
|
||||||
|
|
||||||
|
@ -3757,8 +3758,7 @@ static int32_t cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void* client_co
|
||||||
ctx->power_state = ARM_POWER_FULL;
|
ctx->power_state = ARM_POWER_FULL;
|
||||||
ctx->status = ARM_DRIVER_OK;
|
ctx->status = ARM_DRIVER_OK;
|
||||||
|
|
||||||
#if defined CFSTORE_CONFIG_BACKEND_FLASH_ENABLED && CFSTORE_CONFIG_BACKEND_FLASH_ENABLED == 1
|
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
|
||||||
// todo: put in cfstore_flash_init() ?
|
|
||||||
/* set the cfstore async flag according to the storage driver mode */
|
/* set the cfstore async flag according to the storage driver mode */
|
||||||
storage_caps = cfstore_storage_drv->GetCapabilities();
|
storage_caps = cfstore_storage_drv->GetCapabilities();
|
||||||
cfstore_caps_g.asynchronous_ops = storage_caps.asynchronous_ops;
|
cfstore_caps_g.asynchronous_ops = storage_caps.asynchronous_ops;
|
||||||
|
|
Loading…
Reference in New Issue