From b09d6dbc9cf0ac1ac1c373eb61672e5f8faa2474 Mon Sep 17 00:00:00 2001 From: Simon Hughes Date: Fri, 17 Jun 2016 14:11:48 +0100 Subject: [PATCH] cfstore flash-journal integration sync mode test fixes. --- .../storage/TESTS/cfstore/add_del/add_del.cpp | 5 +++-- .../storage/TESTS/cfstore/close/close.cpp | 14 ++++++++----- .../storage/TESTS/cfstore/create/create.cpp | 4 ++-- .../TESTS/cfstore/example2/example2.cpp | 3 ++- features/storage/TESTS/cfstore/find/find.cpp | 13 ++++++------ .../storage/TESTS/cfstore/find2/find2.cpp | 13 +++++++++--- .../storage/TESTS/cfstore/flash/flash.cpp | 4 ++-- .../storage/TESTS/cfstore/flush/flush.cpp | 20 +++++++++---------- .../storage/TESTS/cfstore/flush2/flush2.cpp | 4 ++-- features/storage/TESTS/cfstore/init/init.cpp | 14 ++++++------- features/storage/TESTS/cfstore/misc/misc.cpp | 18 +++++++++-------- features/storage/TESTS/cfstore/open/open.cpp | 7 ++++--- features/storage/TESTS/cfstore/read/read.cpp | 4 ++-- .../storage/TESTS/cfstore/write/write.cpp | 2 +- .../cfstore/source/configuration_store.c | 5 ++--- 15 files changed, 72 insertions(+), 58 deletions(-) diff --git a/features/storage/TESTS/cfstore/add_del/add_del.cpp b/features/storage/TESTS/cfstore/add_del/add_del.cpp index 01d9e64682..1f7d4a23d5 100644 --- a/features/storage/TESTS/cfstore/add_del/add_del.cpp +++ b/features/storage/TESTS/cfstore/add_del/add_del.cpp @@ -168,7 +168,8 @@ static control_t cfstore_add_del_test_01_end(const size_t call_count) hkey = NULL; } /* 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); 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); @@ -326,7 +327,7 @@ static control_t cfstore_add_del_test_04(const size_t call_count) (void) call_count; /*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_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); return CaseNext; } diff --git a/features/storage/TESTS/cfstore/close/close.cpp b/features/storage/TESTS/cfstore/close/close.cpp index 0a61511272..e2e5cca588 100644 --- a/features/storage/TESTS/cfstore/close/close.cpp +++ b/features/storage/TESTS/cfstore/close/close.cpp @@ -45,7 +45,7 @@ using namespace utest::v1; static control_t cfstore_close_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -184,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); 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 */ flags.read = true; @@ -193,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); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_close_utest_msg_g); 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 */ ret = drv->Read(hkey2, read_buf, &len); @@ -213,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); 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 */ ret = drv->Delete(hkey2); @@ -269,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); 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(); CFSTORE_TEST_UTEST_MESSAGE(cfstore_close_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__); diff --git a/features/storage/TESTS/cfstore/create/create.cpp b/features/storage/TESTS/cfstore/create/create.cpp index 8284bba237..0b7b0c2e2d 100644 --- a/features/storage/TESTS/cfstore/create/create.cpp +++ b/features/storage/TESTS/cfstore/create/create.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_create_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -709,7 +709,7 @@ static control_t cfstore_create_test_06_end(const size_t call_count) ret32 = drv->Uninitialize(); CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__); - TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g); + TEST_ASSERT_MESSAGE(ret32 >= ARM_DRIVER_OK, cfstore_create_utest_msg_g); return CaseNext; } diff --git a/features/storage/TESTS/cfstore/example2/example2.cpp b/features/storage/TESTS/cfstore/example2/example2.cpp index bebcacd4f5..c43b533411 100644 --- a/features/storage/TESTS/cfstore/example2/example2.cpp +++ b/features/storage/TESTS/cfstore/example2/example2.cpp @@ -273,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); 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); diff --git a/features/storage/TESTS/cfstore/find/find.cpp b/features/storage/TESTS/cfstore/find/find.cpp index 3de35bec8f..9259975773 100644 --- a/features/storage/TESTS/cfstore/find/find.cpp +++ b/features/storage/TESTS/cfstore/find/find.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_find_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_DBGLOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -131,7 +131,7 @@ static control_t cfstore_find_test_01(const size_t call_count) (void) call_count; /*todo: implement test */ 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); return CaseNext; } @@ -164,7 +164,7 @@ static control_t cfstore_find_test_02(const size_t call_count) (void) call_count; /*todo: implement test */ 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); return CaseNext; } @@ -238,7 +238,8 @@ static control_t cfstore_find_test_03_end(const size_t call_count) } 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); drv->Close(next); node++; @@ -274,7 +275,7 @@ static control_t cfstore_find_test_04(const size_t call_count) (void) call_count; /*todo: implement test */ 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); return CaseNext; } @@ -391,7 +392,7 @@ static control_t cfstore_find_test_05_end(const size_t call_count) ret32 = drv->Uninitialize(); 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; } diff --git a/features/storage/TESTS/cfstore/find2/find2.cpp b/features/storage/TESTS/cfstore/find2/find2.cpp index daf852e4b8..43c0680711 100644 --- a/features/storage/TESTS/cfstore/find2/find2.cpp +++ b/features/storage/TESTS/cfstore/find2/find2.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_find2_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -104,6 +104,12 @@ UVISOR_BOX_NAMESPACE("com.arm.mbed.cfstore.test.find2.box1"); UVISOR_BOX_CONFIG(cfstore_find2_box1, UVISOR_BOX_STACK_SIZE); #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; void cfstore_find2_callback(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *client_context, ARM_CFSTORE_HANDLE handle) @@ -258,14 +264,15 @@ static control_t cfstore_find2_test_02(const size_t call_count) 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__); 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; } 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); } diff --git a/features/storage/TESTS/cfstore/flash/flash.cpp b/features/storage/TESTS/cfstore/flash/flash.cpp index c1d15a71ea..28a2837656 100644 --- a/features/storage/TESTS/cfstore/flash/flash.cpp +++ b/features/storage/TESTS/cfstore/flash/flash.cpp @@ -51,7 +51,7 @@ using namespace utest::v1; static control_t cfstore_flash_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -512,7 +512,7 @@ void cfstore_flash_fsm_write_on_entry(void* context) /* check the key_name read from flash is correct */ blob = (cfstore_flash_data_blob_t*) ctx->area_0_head; 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 */ value++; memcpy((void*) &blob->data[CFSTORE_TEST_DATA_KEYNAME_SIZE], (const void*) &value, sizeof(uint8_t)); diff --git a/features/storage/TESTS/cfstore/flush/flush.cpp b/features/storage/TESTS/cfstore/flush/flush.cpp index fa3b835592..5edcb8d723 100644 --- a/features/storage/TESTS/cfstore/flush/flush.cpp +++ b/features/storage/TESTS/cfstore/flush/flush.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_flush_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -140,7 +140,6 @@ static int32_t cfstore_flush_test_01_x86_sync(void) int32_t ret = ARM_DRIVER_ERROR; ARM_CFSTORE_DRIVER* drv = &cfstore_driver; - CFSTORE_LOG("cfstore_flush_test_01: Start%s", "\r\n"); ret = drv->Initialize(NULL, NULL); if(ret != ARM_DRIVER_OK){ CFSTORE_ERRLOG("%s:Initialize() call failed (ret=%" PRId32 ").\r\n", __func__, ret); @@ -156,11 +155,6 @@ static int32_t cfstore_flush_test_01_x86_sync(void) goto 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; } #endif /* TARGET_LIKE_X86_LINUX_NATIVE */ @@ -395,7 +389,8 @@ static void cfstore_flush_fsm_flush_on_entry(void* context) 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); 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 { /*read the value, increment by 1 and write value back */ len = CFSTORE_KEY_NAME_MAX_LENGTH+1; @@ -404,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); 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 */ ++ivalue; snprintf(value, CFSTORE_KEY_NAME_MAX_LENGTH+1, "%" PRId32 "", ivalue); @@ -417,7 +413,8 @@ static void cfstore_flush_fsm_flush_on_entry(void* context) 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); 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; } @@ -437,7 +434,8 @@ static void cfstore_flush_fsm_flushing(void* context) TEST_ASSERT_MESSAGE(ctx->status >= ARM_DRIVER_OK, cfstore_flush_utest_msg_g); /* only change state if 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); } return; diff --git a/features/storage/TESTS/cfstore/flush2/flush2.cpp b/features/storage/TESTS/cfstore/flush2/flush2.cpp index 132f5c38c2..ee98c54752 100644 --- a/features/storage/TESTS/cfstore/flush2/flush2.cpp +++ b/features/storage/TESTS/cfstore/flush2/flush2.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_flush2_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -283,7 +283,7 @@ static control_t cfstore_flush2_test_02(const size_t call_count) (void) call_count; //todo: implement test 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); return CaseNext; } diff --git a/features/storage/TESTS/cfstore/init/init.cpp b/features/storage/TESTS/cfstore/init/init.cpp index b65412c11d..649eef8223 100644 --- a/features/storage/TESTS/cfstore/init/init.cpp +++ b/features/storage/TESTS/cfstore/init/init.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_init_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -123,24 +123,24 @@ static void cfstore_init_test_01(cfstore_init_ctx_t* ctx) int32_t ret; (void) ctx; - CFSTORE_LOG("INITIALIZING%s", "\r\n"); + CFSTORE_DBGLOG("INITIALIZING%s", "\r\n"); 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); 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(); 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); - CFSTORE_LOG("UNINITIALIZING%s", "\r\n"); + CFSTORE_DBGLOG("UNINITIALIZING%s", "\r\n"); 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); TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_init_utest_msg_g); - CFSTORE_LOG("***************%s", "\r\n"); - CFSTORE_LOG("*** SUCCESS ***%s", "\r\n"); - CFSTORE_LOG("***************%s", "\r\n"); + CFSTORE_DBGLOG("***************%s", "\r\n"); + CFSTORE_DBGLOG("*** SUCCESS ***%s", "\r\n"); + CFSTORE_DBGLOG("***************%s", "\r\n"); return; } diff --git a/features/storage/TESTS/cfstore/misc/misc.cpp b/features/storage/TESTS/cfstore/misc/misc.cpp index 001a778497..506aace5b9 100644 --- a/features/storage/TESTS/cfstore/misc/misc.cpp +++ b/features/storage/TESTS/cfstore/misc/misc.cpp @@ -45,7 +45,7 @@ using namespace utest::v1; static control_t cfstore_misc_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -222,14 +222,14 @@ static control_t cfstore_misc_test_02(const size_t call_count) memset(&caps, 0, sizeof(caps)); caps = drv->GetCapabilities(); -#ifdef STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS - /* sync mode */ - printf("%s:sync mode: caps.asynchronous_ops =%" PRIu32 "\n", __func__, caps.asynchronous_ops); +#if defined STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS && defined STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==0 + /* sync mode i.e. STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==0 */ + 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__); TEST_ASSERT_MESSAGE(caps.asynchronous_ops == false, cfstore_misc_utest_msg_g); #else - /* async mode */ - printf("%s:async mode: caps.asynchronous_ops =%" PRIu32 "\n", __func__, caps.asynchronous_ops); + /* async mode i.e. STORAGE_DRIVER_CONFIG_HARDWARE_MTD_ASYNC_OPS==1 */ + 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__); TEST_ASSERT_MESSAGE(caps.asynchronous_ops == true, cfstore_misc_utest_msg_g); #endif @@ -293,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)); 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); 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); @@ -344,7 +345,8 @@ static control_t cfstore_misc_test_04_end(const size_t call_count) 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); 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); 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); diff --git a/features/storage/TESTS/cfstore/open/open.cpp b/features/storage/TESTS/cfstore/open/open.cpp index 5e31e84b7e..a48902ea71 100644 --- a/features/storage/TESTS/cfstore/open/open.cpp +++ b/features/storage/TESTS/cfstore/open/open.cpp @@ -45,7 +45,7 @@ using namespace utest::v1; static control_t cfstore_open_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -183,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); 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); 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); @@ -198,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__); 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); 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); @@ -460,6 +460,7 @@ static control_t cfstore_open_test_05_end(const size_t call_count) CFSTORE_FENTRYLOG("%s:entered\n", __func__); (void) call_count; + (void) pos_str; /* suppress warning in release build*/ /* create bad keyname strings with invalid character code at start of keyname */ node = cfstore_open_kv_name_ascii_table; diff --git a/features/storage/TESTS/cfstore/read/read.cpp b/features/storage/TESTS/cfstore/read/read.cpp index 75ee73b9ed..739c802e03 100644 --- a/features/storage/TESTS/cfstore/read/read.cpp +++ b/features/storage/TESTS/cfstore/read/read.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_read_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } @@ -215,7 +215,7 @@ static control_t cfstore_read_test_02_end(const size_t call_count) (void) call_count; /*todo: implement test */ 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); return CaseNext; } diff --git a/features/storage/TESTS/cfstore/write/write.cpp b/features/storage/TESTS/cfstore/write/write.cpp index 816dc4c72a..d928099923 100644 --- a/features/storage/TESTS/cfstore/write/write.cpp +++ b/features/storage/TESTS/cfstore/write/write.cpp @@ -44,7 +44,7 @@ using namespace utest::v1; static control_t cfstore_write_test_00(const size_t call_count) { (void) call_count; - printf("Not implemented for ARM toolchain\n"); + CFSTORE_LOG("Not implemented for ARM toolchain\n"); return CaseNext; } diff --git a/features/storage/cfstore/source/configuration_store.c b/features/storage/cfstore/source/configuration_store.c index 49088f2af7..e0bd68bbc3 100644 --- a/features/storage/cfstore/source/configuration_store.c +++ b/features/storage/cfstore/source/configuration_store.c @@ -46,7 +46,7 @@ #ifdef CFSTORE_DEBUG 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_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 @@ -2003,7 +2003,6 @@ static int32_t cfstore_flash_init(void) cfstore_ctx_t* ctx = cfstore_ctx_get(); 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->expected_blob_size = 0; ctx->fsm.event = cfstore_fsm_event_max; @@ -2524,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); } 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; } }