int32_t cfstore_flush3_start(void) { int32_t status = ARM_DRIVER_OK; int32_t cfsStatus; ARM_CFSTORE_DRIVER *cfstoreDriver = &cfstore_driver; ARM_CFSTORE_CAPABILITIES caps; CFSTORE_DBGLOG("%s:IN\n", __func__); /* Initialize configuration store */ cfsStatus = cfstoreDriver->Initialize(NULL, NULL); if(cfsStatus < ARM_DRIVER_OK){ CFSTORE_DBGLOG("CFStore Initialization failed (err %lu)\n", cfsStatus); return ARM_DRIVER_ERROR; } /* Get capabilities */ memset(&caps, 0, sizeof(caps)); caps = cfstoreDriver->GetCapabilities(); if(caps.asynchronous_ops == true){ CFSTORE_DBGLOG("%s:Please configure CFstore to work in synchronous mode. This can be change in config.json file.\n", __func__); status = ARM_DRIVER_ERROR; goto out; } CFSTORE_DBGLOG("%s:OUT: returning ARM_DRIVER_OK\n", __func__); return ARM_DRIVER_OK; /* init succeeded */ out: /* init failed */ (void) cfstore_flush3_end(); CFSTORE_DBGLOG("%s:OUT: status=%d\n", __func__, (int) status); return status; }
/** @brief basic Flush() test * * @return on success returns CaseNext to continue to next test case, otherwise will assert on errors. */ int32_t cfstore_flush_test_01_x86_sync(void) { int32_t ret = ARM_DRIVER_ERROR; ARM_CFSTORE_DRIVER* drv = &cfstore_driver; ret = drv->Initialize(NULL, NULL); if(ret != ARM_DRIVER_OK){ CFSTORE_ERRLOG("%s:Initialize() call failed (ret=%d).\r\n", __func__, (int) ret); goto out0; } ret = drv->Flush(); if(ret != ARM_DRIVER_OK){ CFSTORE_ERRLOG("%s:Flush() call failed (ret=%d).\r\n", __func__, (int) ret); } ret = drv->Uninitialize(); if(ret != ARM_DRIVER_OK){ CFSTORE_ERRLOG("%s:Initialize() call failed to Uninitialise(ret=%d).\r\n", __func__, (int) ret); goto out0; } out0: return ret; }
/* @brief simple flush test */ static control_t cfstore_flush3_test_02(const size_t call_count) { int32_t cfsStatus = ARM_DRIVER_ERROR; ARM_CFSTORE_KEYDESC kdesc; ARM_CFSTORE_FMODE flags; ARM_CFSTORE_SIZE len = strlen("key0"); ARM_CFSTORE_HANDLE_INIT(hkey); ARM_CFSTORE_DRIVER* drv = &cfstore_driver; (void) call_count; memset(&kdesc, 0, sizeof(kdesc)); memset(&flags, 0, sizeof(flags)); CFSTORE_DBGLOG("%s:Initialize()\n", __func__); cfsStatus = drv->Initialize(NULL, NULL); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:Create()\n", __func__); cfsStatus = drv->Create("key0", len, &kdesc, hkey); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); len = strlen("some-value"); CFSTORE_DBGLOG("%s:Write()\n", __func__); cfsStatus = drv->Write(hkey, "some-value", &len); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:Close()\n", __func__); cfsStatus = drv->Close(hkey); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:Flush()\n", __func__); cfsStatus = drv->Flush(); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:Open()\n", __func__); cfsStatus = drv->Open("key0", flags, hkey); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:Delete()\n", __func__); cfsStatus = drv->Delete(hkey); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:Close()\n", __func__); cfsStatus = drv->Close(hkey); /////// <--- cfsStatus = ARM_CFSTORE_DRIVER_ERROR_PREEXISTING_KEY CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); CFSTORE_DBGLOG("%s:got status = %d\n", __func__, (int) cfsStatus); CFSTORE_DBGLOG("%s:Uninitialize()\n", __func__); cfsStatus = drv->Uninitialize(); CFSTORE_TEST_UTEST_MESSAGE(cfstore_flush3_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error:%d:cfsStatus=%d", __func__, __LINE__, (int) cfsStatus); TEST_ASSERT_MESSAGE(cfsStatus >= ARM_DRIVER_OK, cfstore_flush3_utest_msg_g); return CaseNext; }