Merge pull request #371 from simonqhughes/master

cfstore flash-journal integration
Bogdan Marinescu 2016-06-20 15:49:38 +03:00 committed by GitHub
commit 45eb849329
26 changed files with 450 additions and 350 deletions

View File

@ -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));
@ -171,7 +168,8 @@ static control_t cfstore_add_del_test_01_end(const size_t call_count)
hkey = NULL; hkey = NULL;
} }
/* check that the KV has been deleted */ /* check that the KV has been deleted */
printf("LOG: WARNING: About to look for non-existent key (key_name=%s) (which will generate internal trace reporting errors if debug trace enabled).\n", cfstore_add_del_test_07_data[0].key_name); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("LOG: WARNING: About to look for non-existent key (key_name=%s) (which will generate internal trace reporting errors if debug trace enabled).\n", cfstore_add_del_test_07_data[0].key_name);
ret = cfstore_test_kv_is_found(cfstore_add_del_test_07_data[0].key_name, &bfound); ret = cfstore_test_kv_is_found(cfstore_add_del_test_07_data[0].key_name, &bfound);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error failed to delete a key (ret=%" 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_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND, cfstore_add_del_utest_msg_g); TEST_ASSERT_MESSAGE(ret == ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND, cfstore_add_del_utest_msg_g);
@ -217,7 +215,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 +226,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 +243,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 +285,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 */
@ -327,7 +327,7 @@ static control_t cfstore_add_del_test_04(const size_t call_count)
(void) call_count; (void) call_count;
/*todo: implement test */ /*todo: implement test */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_add_del_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__);
CFSTORE_LOG("%s: WARN: requires implementation\n", __func__); CFSTORE_DBGLOG("%s: WARN: requires implementation\n", __func__);
TEST_ASSERT_MESSAGE(true, cfstore_add_del_utest_msg_g); TEST_ASSERT_MESSAGE(true, cfstore_add_del_utest_msg_g);
return CaseNext; return CaseNext;
} }

View File

@ -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"
@ -48,7 +45,7 @@ using namespace utest::v1;
static control_t cfstore_close_test_00(const size_t call_count) static control_t cfstore_close_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }
@ -187,7 +184,8 @@ static control_t cfstore_close_test_01_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%d)\n", __func__, node->key_name, node->value, (int) len, (int) ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%d)\n", __func__, node->key_name, node->value, (int) len, (int) ret);
TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_close_utest_msg_g); TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_close_utest_msg_g);
printf("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
/* step 03: Now open second handle while keeping first handle open */ /* step 03: Now open second handle while keeping first handle open */
flags.read = true; flags.read = true;
@ -196,7 +194,8 @@ static control_t cfstore_close_test_01_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to open node (key_name=\"%s\", value=\"%s\")(ret=%" PRId32 ")\n", __func__, node->key_name, node->value, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to open node (key_name=\"%s\", value=\"%s\")(ret=%" PRId32 ")\n", __func__, node->key_name, node->value, ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_close_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_close_utest_msg_g);
len = strlen(node->value) + 1; len = strlen(node->value) + 1;
printf("Opened KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Opened KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
/* step 04 */ /* step 04 */
ret = drv->Read(hkey2, read_buf, &len); ret = drv->Read(hkey2, read_buf, &len);
@ -216,7 +215,8 @@ static control_t cfstore_close_test_01_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%" PRId32 ")\n", __func__, node->key_name, node->value, (int) len, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%" PRId32 ")\n", __func__, node->key_name, node->value, (int) len, ret);
TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_close_utest_msg_g); TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_close_utest_msg_g);
printf("Wrote KV successfully with new data (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Wrote KV successfully with new data (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
/* step 06 delete hkey2 */ /* step 06 delete hkey2 */
ret = drv->Delete(hkey2); ret = drv->Delete(hkey2);
@ -272,7 +272,8 @@ static control_t cfstore_close_test_01_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%" PRId32 ")\n", __func__, node->key_name, node->value, (int) len, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%" PRId32 ")\n", __func__, node->key_name, node->value, (int) len, ret);
TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_close_utest_msg_g); TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_close_utest_msg_g);
printf("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
ret = drv->Uninitialize(); ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_create_test_00(const size_t call_count) static control_t cfstore_create_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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__);
@ -706,7 +709,7 @@ static control_t cfstore_create_test_06_end(const size_t call_count)
ret32 = drv->Uninitialize(); ret32 = drv->Uninitialize();
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(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g); TEST_ASSERT_MESSAGE(ret32 >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
return CaseNext; return CaseNext;
} }

View File

@ -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;
} }

View File

@ -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;
} }
@ -275,7 +273,8 @@ static control_t cfstore_example2_test_01(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_example2_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Read() returned unexpected string (%s) where nulls have been converted to '=' chars\n", __func__, readBuf); CFSTORE_TEST_UTEST_MESSAGE(cfstore_example2_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Read() returned unexpected string (%s) where nulls have been converted to '=' chars\n", __func__, readBuf);
TEST_ASSERT_MESSAGE(strncmp(readBuf, "Grumpy man=man=", (PvStrLen(value) + 1)) == 0, cfstore_example2_utest_msg_g); TEST_ASSERT_MESSAGE(strncmp(readBuf, "Grumpy man=man=", (PvStrLen(value) + 1)) == 0, cfstore_example2_utest_msg_g);
CFSTORE_LOG("Success: New value of KV (%s) value blob (with nulls converted to '=') = (%s)\n", key, readBuf); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Success: New value of KV (%s) value blob (with nulls converted to '=') = (%s)\n", key, readBuf);
drv->Close(updatedKeyH); drv->Close(updatedKeyH);

View File

@ -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;
} }

View File

@ -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
}; };

View File

@ -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;
} }

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_find_test_00(const size_t call_count) static control_t cfstore_find_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_DBGLOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }
@ -133,7 +131,7 @@ static control_t cfstore_find_test_01(const size_t call_count)
(void) call_count; (void) call_count;
/*todo: implement test */ /*todo: implement test */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__);
CFSTORE_LOG("%s: WARN: requires implementation\n", __func__); CFSTORE_DBGLOG("%s: WARN: requires implementation\n", __func__);
TEST_ASSERT_MESSAGE(true, cfstore_find_utest_msg_g); TEST_ASSERT_MESSAGE(true, cfstore_find_utest_msg_g);
return CaseNext; return CaseNext;
} }
@ -166,7 +164,7 @@ static control_t cfstore_find_test_02(const size_t call_count)
(void) call_count; (void) call_count;
/*todo: implement test */ /*todo: implement test */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__);
CFSTORE_LOG("%s: WARN: requires implementation\n", __func__); CFSTORE_DBGLOG("%s: WARN: requires implementation\n", __func__);
TEST_ASSERT_MESSAGE(true, cfstore_find_utest_msg_g); TEST_ASSERT_MESSAGE(true, cfstore_find_utest_msg_g);
return CaseNext; return CaseNext;
} }
@ -240,7 +238,8 @@ static control_t cfstore_find_test_03_end(const size_t call_count)
} }
read_buf[len] = '\0'; read_buf[len] = '\0';
printf("Successfully found KV and read value data (key_name=\"%s\", value=\"%s\")\r\n", node->key_name, read_buf); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Successfully found KV and read value data (key_name=\"%s\", value=\"%s\")\r\n", node->key_name, read_buf);
memset(read_buf, 0, len); memset(read_buf, 0, len);
drv->Close(next); drv->Close(next);
node++; node++;
@ -276,7 +275,7 @@ static control_t cfstore_find_test_04(const size_t call_count)
(void) call_count; (void) call_count;
/*todo: implement test */ /*todo: implement test */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__);
CFSTORE_LOG("%s: WARN: requires implementation\n", __func__); CFSTORE_DBGLOG("%s: WARN: requires implementation\n", __func__);
TEST_ASSERT_MESSAGE(true, cfstore_find_utest_msg_g); TEST_ASSERT_MESSAGE(true, cfstore_find_utest_msg_g);
return CaseNext; return CaseNext;
} }
@ -393,7 +392,7 @@ static control_t cfstore_find_test_05_end(const size_t call_count)
ret32 = drv->Uninitialize(); ret32 = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_find_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_find_utest_msg_g); TEST_ASSERT_MESSAGE(ret32 >= ARM_DRIVER_OK, cfstore_find_utest_msg_g);
return CaseNext; return CaseNext;
} }

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_find2_test_00(const size_t call_count) static control_t cfstore_find2_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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,14 @@ 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 */
#ifdef CFSTORE_DEBUG
#define CFSTORE_FIND2_GREENTEA_TIMEOUT_S 360
#else
#define CFSTORE_FIND2_GREENTEA_TIMEOUT_S 60
#endif
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 +124,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;
} }
@ -265,14 +264,15 @@ static control_t cfstore_find2_test_02(const size_t call_count)
rc = cfstore_driver.Write(hkey, value, &length); rc = cfstore_driver.Write(hkey, value, &length);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_find2_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%sError: failed to write key\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_find2_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%sError: failed to write key\n", __func__);
TEST_ASSERT_MESSAGE(rc >= ARM_DRIVER_OK, cfstore_find2_utest_msg_g); TEST_ASSERT_MESSAGE(rc >= ARM_DRIVER_OK, cfstore_find2_utest_msg_g);
printf("Success!\n"); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("Success!%s", "\n");
} }
return CaseNext; return CaseNext;
} }
utest::v1::status_t greentea_setup(const size_t number_of_cases) utest::v1::status_t greentea_setup(const size_t number_of_cases)
{ {
GREENTEA_SETUP(400, "default_auto"); GREENTEA_SETUP(CFSTORE_FIND2_GREENTEA_TIMEOUT_S, "default_auto");
return greentea_test_setup_handler(number_of_cases); return greentea_test_setup_handler(number_of_cases);
} }

View File

@ -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>
@ -47,7 +51,7 @@ using namespace utest::v1;
static control_t cfstore_flash_test_00(const size_t call_count) static control_t cfstore_flash_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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,8 +140,8 @@ 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
char cfstore_flash_utest_msg_g[CFSTORE_FLASH_UTEST_MSG_BUF_SIZE]; char cfstore_flash_utest_msg_g[CFSTORE_FLASH_UTEST_MSG_BUF_SIZE];
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
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);
@ -505,7 +512,7 @@ void cfstore_flash_fsm_write_on_entry(void* context)
/* check the key_name read from flash is correct */ /* check the key_name read from flash is correct */
blob = (cfstore_flash_data_blob_t*) ctx->area_0_head; blob = (cfstore_flash_data_blob_t*) ctx->area_0_head;
value = (uint8_t) blob->data[CFSTORE_TEST_DATA_KEYNAME_SIZE]; value = (uint8_t) blob->data[CFSTORE_TEST_DATA_KEYNAME_SIZE];
printf("INFO: value read from flash = %u\r\n", value); CFSTORE_DBGLOG("INFO: value read from flash = %u\r\n", value);
/* update the value */ /* update the value */
value++; value++;
memcpy((void*) &blob->data[CFSTORE_TEST_DATA_KEYNAME_SIZE], (const void*) &value, sizeof(uint8_t)); memcpy((void*) &blob->data[CFSTORE_TEST_DATA_KEYNAME_SIZE], (const void*) &value, sizeof(uint8_t));
@ -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
}; };

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_flush_test_00(const size_t call_count) static control_t cfstore_flush_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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"
@ -146,7 +140,6 @@ static int32_t cfstore_flush_test_01_x86_sync(void)
int32_t ret = ARM_DRIVER_ERROR; int32_t ret = ARM_DRIVER_ERROR;
ARM_CFSTORE_DRIVER* drv = &cfstore_driver; ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
CFSTORE_LOG("cfstore_flush_test_01: Start%s", "\r\n");
ret = drv->Initialize(NULL, NULL); ret = drv->Initialize(NULL, NULL);
if(ret != ARM_DRIVER_OK){ if(ret != ARM_DRIVER_OK){
CFSTORE_ERRLOG("%s:Initialize() call failed (ret=%" PRId32 ").\r\n", __func__, ret); CFSTORE_ERRLOG("%s:Initialize() call failed (ret=%" PRId32 ").\r\n", __func__, ret);
@ -162,11 +155,6 @@ static int32_t cfstore_flush_test_01_x86_sync(void)
goto out0; goto out0;
} }
out0: out0:
if(ret == ARM_DRIVER_OK){
CFSTORE_LOG("cfstore_flush_test_01: End: Success%s", "\r\n");
} else {
CFSTORE_LOG("cfstore_flush_test_01: End: Failed%s", "\r\n");
}
return ret; return ret;
} }
#endif /* TARGET_LIKE_X86_LINUX_NATIVE */ #endif /* TARGET_LIKE_X86_LINUX_NATIVE */
@ -401,7 +389,8 @@ static void cfstore_flush_fsm_flush_on_entry(void* context)
ret = drv->Flush(); ret = drv->Flush();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_FLUSH_UTEST_MSG_BUF_SIZE, "%s:Error: failed to flush data to cfstore flash (ret=%" PRId32 ").\r\n", __func__, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_FLUSH_UTEST_MSG_BUF_SIZE, "%s:Error: failed to flush data to cfstore flash (ret=%" PRId32 ").\r\n", __func__, ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g);
CFSTORE_LOG("FLUSH: Success pending for new KV creation (name=%s, value=%s)\n", cfstore_flush_test_02_kv_data->key_name, cfstore_flush_test_02_kv_data->value) /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("FLUSH: Success pending for new KV creation (name=%s, value=%s)\n", cfstore_flush_test_02_kv_data->key_name, cfstore_flush_test_02_kv_data->value);
} else { } else {
/*read the value, increment by 1 and write value back */ /*read the value, increment by 1 and write value back */
len = CFSTORE_KEY_NAME_MAX_LENGTH+1; len = CFSTORE_KEY_NAME_MAX_LENGTH+1;
@ -410,7 +399,8 @@ static void cfstore_flush_fsm_flush_on_entry(void* context)
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g);
ivalue = atoi(value); ivalue = atoi(value);
CFSTORE_LOG("FLUSH: Read KV from flash (name=%s, value=%" PRId32 ")\n", cfstore_flush_test_02_kv_data->key_name, ivalue); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("FLUSH: Read KV from flash (name=%s, value=%" PRId32 ")\n", cfstore_flush_test_02_kv_data->key_name, ivalue);
/* increment value */ /* increment value */
++ivalue; ++ivalue;
snprintf(value, CFSTORE_KEY_NAME_MAX_LENGTH+1, "%" PRId32 "", ivalue); snprintf(value, CFSTORE_KEY_NAME_MAX_LENGTH+1, "%" PRId32 "", ivalue);
@ -423,7 +413,8 @@ static void cfstore_flush_fsm_flush_on_entry(void* context)
ret = drv->Flush(); ret = drv->Flush();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_FLUSH_UTEST_MSG_BUF_SIZE, "%s:Error: failed to flush data to cfstore flash (ret=%" PRId32 ").\r\n", __func__, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_FLUSH_UTEST_MSG_BUF_SIZE, "%s:Error: failed to flush data to cfstore flash (ret=%" PRId32 ").\r\n", __func__, ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g);
CFSTORE_LOG("FLUSH: Success pending for new KV value to flash (name=%s, value=%" PRId32 ")\n", cfstore_flush_test_02_kv_data->key_name, ivalue); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("FLUSH: Success pending for new KV value to flash (name=%s, value=%" PRId32 ")\n", cfstore_flush_test_02_kv_data->key_name, ivalue);
} }
return; return;
} }
@ -443,7 +434,8 @@ static void cfstore_flush_fsm_flushing(void* context)
TEST_ASSERT_MESSAGE(ctx->status >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g); TEST_ASSERT_MESSAGE(ctx->status >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g);
/* only change state if status >= 0*/ /* only change state if status >= 0*/
if(ctx->status >= 0){ if(ctx->status >= 0){
CFSTORE_LOG("FLUSH: Successfully flushed data to flash.%s", "\n"); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("FLUSH: Successfully flushed data to flash.%s", "\n");
cfstore_flush_fsm_state_set(&ctx->fsm, cfstore_flush_fsm_state_uninitializing, ctx); cfstore_flush_fsm_state_set(&ctx->fsm, cfstore_flush_fsm_state_uninitializing, ctx);
} }
return; return;
@ -595,8 +587,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;
} }

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_flush2_test_00(const size_t call_count) static control_t cfstore_flush2_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }
@ -285,7 +283,7 @@ static control_t cfstore_flush2_test_02(const size_t call_count)
(void) call_count; (void) call_count;
//todo: implement test //todo: implement test
CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__);
CFSTORE_LOG("%s: WARN: requires implementation\n", __func__); CFSTORE_DBGLOG("%s: WARN: requires implementation\n", __func__);
TEST_ASSERT_MESSAGE(true, cfstore_flush_utest_msg_g); TEST_ASSERT_MESSAGE(true, cfstore_flush_utest_msg_g);
return CaseNext; return CaseNext;
} }

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_init_test_00(const size_t call_count) static control_t cfstore_init_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }
@ -125,24 +123,24 @@ static void cfstore_init_test_01(cfstore_init_ctx_t* ctx)
int32_t ret; int32_t ret;
(void) ctx; (void) ctx;
CFSTORE_LOG("INITIALIZING%s", "\r\n"); CFSTORE_DBGLOG("INITIALIZING%s", "\r\n");
ret = cfstore_drv->Initialize(NULL, NULL); ret = cfstore_drv->Initialize(NULL, NULL);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Initialize() should return ret >= 0 for async/synch modes(ret=%ld)\r\n", __func__, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Initialize() should return ret >= 0 for async/synch modes(ret=%ld)\r\n", __func__, ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g);
CFSTORE_LOG("FLUSHING1%s", "\r\n"); CFSTORE_DBGLOG("FLUSHING1%s", "\r\n");
ret = cfstore_drv->Flush(); ret = cfstore_drv->Flush();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Flush() failed (ret=%ld)\r\n", __func__, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Flush() failed (ret=%ld)\r\n", __func__, ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g);
CFSTORE_LOG("UNINITIALIZING%s", "\r\n"); CFSTORE_DBGLOG("UNINITIALIZING%s", "\r\n");
ret = cfstore_drv->Uninitialize(); ret = cfstore_drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() should return ret >= 0 for synch mode(ret=%ld)\r\n", __func__, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_init_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() should return ret >= 0 for synch mode(ret=%ld)\r\n", __func__, ret);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g);
CFSTORE_LOG("***************%s", "\r\n"); CFSTORE_DBGLOG("***************%s", "\r\n");
CFSTORE_LOG("*** SUCCESS ***%s", "\r\n"); CFSTORE_DBGLOG("*** SUCCESS ***%s", "\r\n");
CFSTORE_LOG("***************%s", "\r\n"); CFSTORE_DBGLOG("***************%s", "\r\n");
return; return;
} }

View File

@ -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"
@ -48,7 +45,7 @@ using namespace utest::v1;
static control_t cfstore_misc_test_00(const size_t call_count) static control_t cfstore_misc_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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,17 +221,15 @@ 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 #if defined STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS && defined STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==0
/* sync mode */ /* sync mode i.e. STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==0 */
printf("%s:sync mode: caps.asynchronous_ops =%" PRIu32 "\n", __func__, caps.asynchronous_ops); CFSTORE_DBGLOG("%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__);
TEST_ASSERT_MESSAGE(caps.asynchronous_ops == false, cfstore_misc_utest_msg_g); TEST_ASSERT_MESSAGE(caps.asynchronous_ops == false, cfstore_misc_utest_msg_g);
#else #else
/* async mode */ /* async mode i.e. STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==1 */
printf("%s:async mode: caps.asynchronous_ops =%" PRIu32 "\n", __func__, caps.asynchronous_ops); CFSTORE_DBGLOG("%s:async 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 != true but system built for async 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 != true but system built for async operation.\r\n", __func__);
TEST_ASSERT_MESSAGE(caps.asynchronous_ops == true, cfstore_misc_utest_msg_g); TEST_ASSERT_MESSAGE(caps.asynchronous_ops == true, cfstore_misc_utest_msg_g);
#endif #endif
@ -297,7 +293,8 @@ static control_t cfstore_misc_test_03_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to GetKeyName() (key_name (expected)=\"%s\", key_name (returned)=\"%s\", value=\"%s\"), len return=%d, len expected=%d\r\n", __func__, node->key_name, key_name_buf, node->value, (int) key_name_len, (int) strlen(node->key_name)); CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to GetKeyName() (key_name (expected)=\"%s\", key_name (returned)=\"%s\", value=\"%s\"), len return=%d, len expected=%d\r\n", __func__, node->key_name, key_name_buf, node->value, (int) key_name_len, (int) strlen(node->key_name));
TEST_ASSERT_MESSAGE(key_name_len == strlen(node->key_name)+1, cfstore_misc_utest_msg_g); TEST_ASSERT_MESSAGE(key_name_len == strlen(node->key_name)+1, cfstore_misc_utest_msg_g);
CFSTORE_LOG("GetKeyName() successfully reported key_name (key_name=\"%s\")\r\n", key_name_buf); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("GetKeyName() successfully reported key_name (key_name=\"%s\")\r\n", key_name_buf);
ret = drv->Close(hkey); ret = drv->Close(hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to close key (key_name=\"%s\", value=\"%s\")\r\n", __func__, node->key_name, node->value); CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to close key (key_name=\"%s\", value=\"%s\")\r\n", __func__, node->key_name, node->value);
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_misc_utest_msg_g); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_misc_utest_msg_g);
@ -348,7 +345,8 @@ static control_t cfstore_misc_test_04_end(const size_t call_count)
drv->GetValueLen(hkey, &len); drv->GetValueLen(hkey, &len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Errro: GetValueLen() retrieve incorrect length of value blob(expected=%d, returned=%d)\r\n", __func__, (int) strlen(node->value), (int) len); CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Errro: GetValueLen() retrieve incorrect length of value blob(expected=%d, returned=%d)\r\n", __func__, (int) strlen(node->value), (int) len);
TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_misc_utest_msg_g); TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_misc_utest_msg_g);
CFSTORE_LOG("GetValueLen() successfully reported correct value blob length%s", "\r\n"); /* revert to CFSTORE_LOG if more trace required */
CFSTORE_DBGLOG("GetValueLen() successfully reported correct value blob length%s", "\r\n");
ret = drv->Close(hkey); ret = drv->Close(hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to close key (key_name=\"%s\", value=\"%s\")\r\n", __func__, node->key_name, node->value); CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Failed to close key (key_name=\"%s\", value=\"%s\")\r\n", __func__, node->key_name, node->value);

View File

@ -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"
@ -48,7 +45,7 @@ using namespace utest::v1;
static control_t cfstore_open_test_00(const size_t call_count) static control_t cfstore_open_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }
@ -185,7 +183,7 @@ static control_t cfstore_open_test_01_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%" PRId32 ")\n", __func__, node->key_name, node->value, (int) len, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write full value data (key_name=\"%s\", value=\"%s\"), len=%d, (ret=%" PRId32 ")\n", __func__, node->key_name, node->value, (int) len, ret);
TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_open_utest_msg_g); TEST_ASSERT_MESSAGE(len == strlen(node->value), cfstore_open_utest_msg_g);
printf("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value); CFSTORE_DBGLOG("Created KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
ret = drv->Close(hkey); ret = drv->Close(hkey);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to close handle (ret=%" PRId32 ")\n", __func__, ret); CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to close handle (ret=%" PRId32 ")\n", __func__, 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);
@ -200,7 +198,7 @@ static control_t cfstore_open_test_01_end(const size_t call_count)
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to allocated read buffer \n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to allocated read buffer \n", __func__);
TEST_ASSERT_MESSAGE(read_buf != NULL, cfstore_open_utest_msg_g); TEST_ASSERT_MESSAGE(read_buf != NULL, cfstore_open_utest_msg_g);
printf("Opened KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value); CFSTORE_DBGLOG("Opened KV successfully (key_name=\"%s\", value=\"%s\")\n", node->key_name, node->value);
memset(read_buf, 0, len); memset(read_buf, 0, len);
ret = drv->Read(hkey, read_buf, &len); ret = drv->Read(hkey, read_buf, &len);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write key (key_name=\"%s\", value=\"%s\")\n", __func__, node->key_name, node->value); CFSTORE_TEST_UTEST_MESSAGE(cfstore_open_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to write key (key_name=\"%s\", value=\"%s\")\n", __func__, node->key_name, node->value);
@ -462,6 +460,7 @@ static control_t cfstore_open_test_05_end(const size_t call_count)
CFSTORE_FENTRYLOG("%s:entered\n", __func__); CFSTORE_FENTRYLOG("%s:entered\n", __func__);
(void) call_count; (void) call_count;
(void) pos_str; /* suppress warning in release build*/
/* create bad keyname strings with invalid character code at start of keyname */ /* create bad keyname strings with invalid character code at start of keyname */
node = cfstore_open_kv_name_ascii_table; node = cfstore_open_kv_name_ascii_table;
@ -535,7 +534,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 +546,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;

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_read_test_00(const size_t call_count) static control_t cfstore_read_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }
@ -217,7 +215,7 @@ static control_t cfstore_read_test_02_end(const size_t call_count)
(void) call_count; (void) call_count;
/*todo: implement test */ /*todo: implement test */
CFSTORE_TEST_UTEST_MESSAGE(cfstore_read_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__); CFSTORE_TEST_UTEST_MESSAGE(cfstore_read_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Warn: Not implemented\n", __func__);
CFSTORE_LOG("%s: WARN: requires implementation\n", __func__); CFSTORE_DBGLOG("%s: WARN: requires implementation\n", __func__);
TEST_ASSERT_MESSAGE(true, cfstore_read_utest_msg_g); TEST_ASSERT_MESSAGE(true, cfstore_read_utest_msg_g);
return CaseNext; return CaseNext;
} }

View File

@ -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"
@ -47,7 +44,7 @@ using namespace utest::v1;
static control_t cfstore_write_test_00(const size_t call_count) static control_t cfstore_write_test_00(const size_t call_count)
{ {
(void) call_count; (void) call_count;
printf("Not implemented for ARM toolchain\n"); CFSTORE_LOG("Not implemented for ARM toolchain\n");
return CaseNext; return CaseNext;
} }
@ -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;
} }

View File

@ -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

View File

@ -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
}
}
}

View File

@ -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*/

View File

@ -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 */

View File

@ -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;

View File

@ -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()
@ -257,6 +298,7 @@ int32_t cfstore_test_create_table(const cfstore_kv_data_t* table)
cfstore_kv_data_t* node = NULL; cfstore_kv_data_t* node = NULL;
ARM_CFSTORE_KEYDESC kdesc; ARM_CFSTORE_KEYDESC kdesc;
(void) node; /* suppresses warning when building release */
CFSTORE_FENTRYLOG("%s:entered.\r\n", __func__); CFSTORE_FENTRYLOG("%s:entered.\r\n", __func__);
memset(&kdesc, 0, sizeof(kdesc)); memset(&kdesc, 0, sizeof(kdesc));
kdesc.drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE; kdesc.drl = ARM_RETENTION_WHILE_DEVICE_ACTIVE;
@ -421,7 +463,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++;
} }

View File

@ -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

View File

@ -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>
@ -45,14 +46,14 @@
#ifdef CFSTORE_DEBUG #ifdef CFSTORE_DEBUG
uint32_t cfstore_optDebug_g = 1; uint32_t cfstore_optDebug_g = 1;
uint32_t cfstore_optLogLevel_g = CFSTORE_LOG_NONE; /*CFSTORE_LOG_NONE|CFSTORE_LOG_ERR|CFSTORE_LOG_DEBUG|CFSTORE_LOG_FENTRY */ uint32_t cfstore_optLogLevel_g = CFSTORE_LOG_NONE; /*CFSTORE_LOG_NONE|CFSTORE_LOG_ERR|CFSTORE_LOG_DEBUG|CFSTORE_LOG_FENTRY */
uint32_t cfstore_optLogTracepoint_g = CFSTORE_TP_NONE; /*CFSTORE_TP_NONE|CFSTORE_TP_CLOSE|CFSTORE_TP_CREATE|CFSTORE_TP_DELETE|CFSTORE_TP_FILE|CFSTORE_TP_FIND|CFSTORE_TP_FLUSH|CFSTORE_TP_INIT|CFSTORE_TP_OPEN|CFSTORE_TP_READ|CFSTORE_TP_WRITE|CFSTORE_TP_VERBOSE1|CFSTORE_TP_VERBOSE2|CFSTORE_TP_VERBOSE3|CFSTORE_TP_FENTRY */ uint32_t cfstore_optLogTracepoint_g = CFSTORE_TP_NONE; /*CFSTORE_TP_NONE|CFSTORE_TP_CLOSE|CFSTORE_TP_CREATE|CFSTORE_TP_DELETE|CFSTORE_TP_FILE|CFSTORE_TP_FIND|CFSTORE_TP_FLUSH|CFSTORE_TP_INIT|CFSTORE_TP_OPEN|CFSTORE_TP_READ|CFSTORE_TP_WRITE|CFSTORE_TP_VERBOSE1|CFSTORE_TP_VERBOSE2|CFSTORE_TP_VERBOSE3|CFSTORE_TP_FENTRY; */
#endif #endif
/* /*
* 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);
@ -2002,7 +2003,6 @@ static int32_t cfstore_flash_init(void)
cfstore_ctx_t* ctx = cfstore_ctx_get(); cfstore_ctx_t* ctx = cfstore_ctx_get();
CFSTORE_FENTRYLOG("%s:entered: \n", __func__); CFSTORE_FENTRYLOG("%s:entered: \n", __func__);
CFSTORE_FENTRYLOG("%s:: CFSTORE_CONFIG_BACKEND_FLASH_ENABLED=%d\n", __func__, (int) CFSTORE_CONFIG_BACKEND_FLASH_ENABLED);
ctx->cmd_code = (FlashJournal_OpCode_t)((int) FLASH_JOURNAL_OPCODE_RESET+1); ctx->cmd_code = (FlashJournal_OpCode_t)((int) FLASH_JOURNAL_OPCODE_RESET+1);
ctx->expected_blob_size = 0; ctx->expected_blob_size = 0;
ctx->fsm.event = cfstore_fsm_event_max; ctx->fsm.event = cfstore_fsm_event_max;
@ -2523,7 +2523,7 @@ static int32_t cfstore_validate_key_name_ex(const char* key_name, const char* pe
pos = cfstore_validate_pos_next_brace(pos); pos = cfstore_validate_pos_next_brace(pos);
} }
if(brace_count != 0){ if(brace_count != 0){
CFSTORE_ERRLOG("%s: Unmatched brace found in key_name (count=%" PRId32 ".\n", __func__, brace_count); CFSTORE_ERRLOG("%s: Unmatched brace found in key_name (count=%d.\n", __func__, brace_count);
return ARM_CFSTORE_DRIVER_ERROR_INVALID_KEY_NAME; return ARM_CFSTORE_DRIVER_ERROR_INVALID_KEY_NAME;
} }
} }
@ -2970,14 +2970,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 +3721,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 +3757,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;