From adecb3e2a934caf0ea6be1ea5ad752c7877570be Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Wed, 7 Oct 2015 15:10:58 +0900 Subject: [PATCH] Update the things manager code not to produce warning messages in compilation It is shown that most of warning messages are produced by an existance of unused parameters in a function. Not to produce the warning message, I make the unused parameters being commented. Additionally, fix potential defects in things manager with CID 65806, 81664, 81560, 82257. Change-Id: Ie460630d0dc3306087b87b2dd5bb314b1844bc1b Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/3681 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- resource/csdk/stack/src/oicgroup.c | 21 +- .../linux/configuration/bootstrapserver.cpp | 2 +- .../sampleapp/linux/configuration/con-client.cpp | 11 +- .../sampleapp/linux/configuration/con-server.cpp | 4 +- .../sampleapp/linux/groupaction/bookmark.cpp | 4 +- .../sampleapp/linux/groupaction/groupserver.cpp | 10 +- .../sampleapp/linux/groupaction/lightserver.cpp | 2 +- service/things-manager/sdk/src/GroupManager.cpp | 4 +- .../things-manager/sdk/src/ThingsConfiguration.cpp | 4 +- .../things-manager/sdk/src/ThingsMaintenance.cpp | 4 +- .../things-manager/unittests/ThingsManagerTest.cpp | 591 +++++++++++---------- 11 files changed, 351 insertions(+), 306 deletions(-) mode change 100644 => 100755 service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp mode change 100644 => 100755 service/things-manager/sampleapp/linux/configuration/con-server.cpp mode change 100644 => 100755 service/things-manager/sampleapp/linux/groupaction/bookmark.cpp mode change 100644 => 100755 service/things-manager/sampleapp/linux/groupaction/groupserver.cpp mode change 100644 => 100755 service/things-manager/sampleapp/linux/groupaction/lightserver.cpp mode change 100644 => 100755 service/things-manager/sdk/src/GroupManager.cpp mode change 100644 => 100755 service/things-manager/sdk/src/ThingsConfiguration.cpp mode change 100644 => 100755 service/things-manager/sdk/src/ThingsMaintenance.cpp mode change 100644 => 100755 service/things-manager/unittests/ThingsManagerTest.cpp diff --git a/resource/csdk/stack/src/oicgroup.c b/resource/csdk/stack/src/oicgroup.c index cbce32f..864cced 100755 --- a/resource/csdk/stack/src/oicgroup.c +++ b/resource/csdk/stack/src/oicgroup.c @@ -220,6 +220,9 @@ void RemoveScheduledResource(ScheduledResourceInfo **head, if (del == NULL) { +#ifndef WITH_ARDUINO + pthread_mutex_unlock(&lock); +#endif return; } @@ -536,7 +539,7 @@ OCStackResult ExtractKeyValueFromRequest(OCEntityHandlerRequest *ehRequest, { OCStackResult result = OC_STACK_OK; - char *actionSetStr; + char *actionSetStr = NULL; if( NULL == ehRequest->payload ) { @@ -1319,21 +1322,29 @@ OCStackResult BuildCollectionGroupActionCBORResponse( OC_LOG(INFO, TAG, "Building New Call Info."); memset(schedule, 0, sizeof(ScheduledResourceInfo)); - +#ifndef WITH_ARDUINO + pthread_mutex_lock(&lock); +#endif schedule->resource = resource; schedule->actionset = actionset; schedule->ehRequest = (OCServerRequest*) ehRequest->requestHandle; - +#ifndef WITH_ARDUINO + pthread_mutex_unlock(&lock); +#endif if (delay > 0) { OC_LOG_V(INFO, TAG, "delay_time is %lf seconds.", actionset->timesteps); - +#ifndef WITH_ARDUINO + pthread_mutex_lock(&lock); +#endif schedule->time = registerTimer(delay, &schedule->timer_id, &DoScheduledGroupAction); - +#ifndef WITH_ARDUINO + pthread_mutex_unlock(&lock); +#endif AddScheduledResource(&scheduleResourceList, schedule); stackRet = OC_STACK_OK; diff --git a/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp b/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp old mode 100644 new mode 100755 index 0b2f4f2..5ae9782 --- a/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp +++ b/service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp @@ -81,7 +81,7 @@ public: } } - void setBootstrapRepresentation(OCRepresentation& rep) + void setBootstrapRepresentation(OCRepresentation& /*rep*/) { // Not allowed } diff --git a/service/things-manager/sampleapp/linux/configuration/con-client.cpp b/service/things-manager/sampleapp/linux/configuration/con-client.cpp index 6bc0e04..b924733 100755 --- a/service/things-manager/sampleapp/linux/configuration/con-client.cpp +++ b/service/things-manager/sampleapp/linux/configuration/con-client.cpp @@ -70,7 +70,7 @@ void timeCheck(int timeSec) pthread_mutex_unlock(&mutex_lock); } -void onReboot(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onReboot(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { pthread_mutex_lock(&mutex_lock); isWaiting = 0; @@ -85,8 +85,7 @@ void onReboot(const HeaderOptions& headerOptions, const OCRepresentation& rep, c std::cout << "\t\tReboot:" << rep.getValue< std::string >("value") << std::endl; } -void onFactoryReset(const HeaderOptions& headerOptions, const OCRepresentation& rep, - const int eCode) +void onFactoryReset(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { pthread_mutex_lock(&mutex_lock); isWaiting = 0; @@ -101,7 +100,7 @@ void onFactoryReset(const HeaderOptions& headerOptions, const OCRepresentation& std::cout << "\t\tFactoryReset:" << rep.getValue< std::string >("value") << std::endl; } -void onUpdate(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onUpdate(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { pthread_mutex_lock(&mutex_lock); isWaiting = 0; @@ -126,7 +125,7 @@ void onUpdate(const HeaderOptions& headerOptions, const OCRepresentation& rep, c std::cout << "\t\tRegion:" << rep.getValue< std::string >("r") << std::endl; } -void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { pthread_mutex_lock(&mutex_lock); isWaiting = 0; @@ -277,7 +276,7 @@ void onFoundCandidateResource(std::vector< std::shared_ptr< OCResource > > resou pthread_mutex_unlock(&mutex_lock); } -int main(int argc, char* argv[]) +int main() { std::string str_steps; diff --git a/service/things-manager/sampleapp/linux/configuration/con-server.cpp b/service/things-manager/sampleapp/linux/configuration/con-server.cpp old mode 100644 new mode 100755 index 0a67a09..60dc232 --- a/service/things-manager/sampleapp/linux/configuration/con-server.cpp +++ b/service/things-manager/sampleapp/linux/configuration/con-server.cpp @@ -217,7 +217,7 @@ OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceReques } // callback handler on GET request -void onBootstrap(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onBootstrap(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { pthread_mutex_lock(&mutex_lock); isWaiting = 0; @@ -238,7 +238,7 @@ void onBootstrap(const HeaderOptions& headerOptions, const OCRepresentation& rep defaultRegion = rep.getValue< std::string >("r"); defaultCurrency = rep.getValue< std::string >("c"); - std::cout << "\DeviceName : " << defaultDeviceName << std::endl; + std::cout << "\tDeviceName : " << defaultDeviceName << std::endl; std::cout << "\tLocation : " << defaultLocation << std::endl; std::cout << "\tLocationName : " << defaultLocationName << std::endl; std::cout << "\tCurrency : " << defaultCurrency << std::endl; diff --git a/service/things-manager/sampleapp/linux/groupaction/bookmark.cpp b/service/things-manager/sampleapp/linux/groupaction/bookmark.cpp old mode 100644 new mode 100755 index bd7493b..18d1127 --- a/service/things-manager/sampleapp/linux/groupaction/bookmark.cpp +++ b/service/things-manager/sampleapp/linux/groupaction/bookmark.cpp @@ -139,7 +139,7 @@ public: } } - void setRepresentation(OCRepresentation& rep) + void setRepresentation(OCRepresentation& /*rep*/) { // AttributeMap attributeMap = rep.getAttributeMap(); // if(rep.getValue("level", m_pressure) == true) @@ -169,7 +169,7 @@ public: // Create the instance of the resource class (in this case instance of class 'BookmarkResource'). BookmarkResource myBookmarkResource; -void* ObserveHandler(void *param) +void* ObserveHandler(void* /*param*/) { while (startedThread) { diff --git a/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp b/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp old mode 100644 new mode 100755 index ae57bc8..753c6f7 --- a/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp +++ b/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp @@ -134,7 +134,7 @@ void foundResource(std::shared_ptr resource) } } -void onGet(const HeaderOptions& opt, const OCRepresentation &rep, +void onGet(const HeaderOptions& /*opt*/, const OCRepresentation &/*rep*/, const int eCode) { cout << "\nonGet" << endl; @@ -144,7 +144,7 @@ void onGet(const HeaderOptions& opt, const OCRepresentation &rep, cout << "\tInvalid parameter." << endl; } -void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, +void onPut(const HeaderOptions& /*opt*/, const OCRepresentation &/*rep*/, const int eCode) { cout << "\nonPut" << endl; @@ -154,8 +154,8 @@ void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, cout << "\tInvalid parameter." << endl; } -void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, - const int eCode) +void onPost(const HeaderOptions& /*opt*/, const OCRepresentation &rep, + const int /*eCode*/) { printf("\nonPost\n"); @@ -259,7 +259,7 @@ void CancelRecursive_allBulbOn() groupMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost); } -void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, +void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& rep, const int& eCode, const int& sequenceNumber) { if (eCode == OC_STACK_OK) diff --git a/service/things-manager/sampleapp/linux/groupaction/lightserver.cpp b/service/things-manager/sampleapp/linux/groupaction/lightserver.cpp old mode 100644 new mode 100755 index dc3566b..45ae0f0 --- a/service/things-manager/sampleapp/linux/groupaction/lightserver.cpp +++ b/service/things-manager/sampleapp/linux/groupaction/lightserver.cpp @@ -291,7 +291,7 @@ void * handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pReq return NULL; } -int main(int argc, char* argv[]) +int main() { // Create PlatformConfig object PlatformConfig cfg diff --git a/service/things-manager/sdk/src/GroupManager.cpp b/service/things-manager/sdk/src/GroupManager.cpp old mode 100644 new mode 100755 index cac79df..6249e31 --- a/service/things-manager/sdk/src/GroupManager.cpp +++ b/service/things-manager/sdk/src/GroupManager.cpp @@ -277,7 +277,7 @@ std::map< std::string, CollectionPresenceCallback > presenceCallbacks; // Callback to presence void GroupManager::collectionPresenceHandler(OCStackResult result, const unsigned int nonce, - const std::string& hostAddress, std::string host, std::string uri) + const std::string& /*hostAddress*/, std::string host, std::string uri) { std::cout << "uri : " << uri << std::endl; std::cout << "host : " << host << std::endl; @@ -385,7 +385,7 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep, } } -void GroupManager::onGetForPresence(const HeaderOptions& headerOptions, +void GroupManager::onGetForPresence(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode, CollectionPresenceCallback callback) { if (eCode == OC_STACK_OK) diff --git a/service/things-manager/sdk/src/ThingsConfiguration.cpp b/service/things-manager/sdk/src/ThingsConfiguration.cpp old mode 100644 new mode 100755 index d148b29..e1aef9b --- a/service/things-manager/sdk/src/ThingsConfiguration.cpp +++ b/service/things-manager/sdk/src/ThingsConfiguration.cpp @@ -199,8 +199,8 @@ namespace OIC return newUri; } - void ThingsConfiguration::onDeleteActionSet(const HeaderOptions& headerOptions, - const OCRepresentation& rep, const int eCode, std::string conf) + void ThingsConfiguration::onDeleteActionSet(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& /*rep*/, const int /*eCode*/, std::string conf) { std::shared_ptr < OCResource > resource = getResource(conf); diff --git a/service/things-manager/sdk/src/ThingsMaintenance.cpp b/service/things-manager/sdk/src/ThingsMaintenance.cpp old mode 100644 new mode 100755 index bf3361e..7255911 --- a/service/things-manager/sdk/src/ThingsMaintenance.cpp +++ b/service/things-manager/sdk/src/ThingsMaintenance.cpp @@ -315,8 +315,8 @@ namespace OIC } } - void ThingsMaintenance::onDeleteGroupAction(const HeaderOptions& headerOptions, - const OCRepresentation& rep, const int eCode, std::string mnt) + void ThingsMaintenance::onDeleteGroupAction(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& /*rep*/, const int eCode, std::string mnt) { if (eCode != OC_STACK_OK) { diff --git a/service/things-manager/unittests/ThingsManagerTest.cpp b/service/things-manager/unittests/ThingsManagerTest.cpp old mode 100644 new mode 100755 index eae2666..8e960ea --- a/service/things-manager/unittests/ThingsManagerTest.cpp +++ b/service/things-manager/unittests/ThingsManagerTest.cpp @@ -57,12 +57,12 @@ std::string defaultCurrency = "Seoul, Korea"; OCResourceHandle resourceHandle; OCResourceHandle foundResourceHandle; -std::shared_ptr g_resource; -std::shared_ptr g_room_resource; -std::shared_ptr g_light; -std::shared_ptr configurationResource; -std::vector lights; -std::vector resourceHandleVector; +std::shared_ptr< OCResource > g_resource; +std::shared_ptr< OCResource > g_room_resource; +std::shared_ptr< OCResource > g_light; +std::shared_ptr< OCResource > configurationResource; +std::vector< string > lights; +std::vector< OCResourceHandle > resourceHandleVector; GroupManager *groupMgr = new GroupManager(); ConfigurationResource *myConfigurationResource; @@ -86,193 +86,192 @@ typedef std::function< OCRepresentation(void) > getFunc; void *ChangeLightRepresentation(void *param); void *handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pRequest); - /****** Light Resource [Required to gtestcases of GroupManager APIs] ******/ class LightResource { - public: - std::string m_power; - std::string testing; - std::string m_lightUri; - OCResourceHandle m_resourceHandle; - OCRepresentation m_lightRep; +public: + std::string m_power; + std::string testing; + std::string m_lightUri; + OCResourceHandle m_resourceHandle; + OCRepresentation m_lightRep; - public: - LightResource() : +public: + LightResource() : m_power("on"), m_lightUri("/a/light"), m_resourceHandle(0) - { - m_lightRep.setUri(m_lightUri); - m_lightRep.setValue("power", m_power); - } + { + m_lightRep.setUri(m_lightUri); + m_lightRep.setValue("power", m_power); + } - void createResource() - { - std::string resourceURI = m_lightUri; - std::string resourceTypeName = "core.light"; - std::string resourceInterface = DEFAULT_INTERFACE; - EntityHandler cb = std::bind(&LightResource::entityHandler, this, PH::_1); + void createResource() + { + std::string resourceURI = m_lightUri; + std::string resourceTypeName = "core.light"; + std::string resourceInterface = DEFAULT_INTERFACE; + EntityHandler cb = std::bind(&LightResource::entityHandler, this, PH::_1); - OCStackResult result = OCPlatform::registerResource(m_resourceHandle, resourceURI, - resourceTypeName, resourceInterface, cb, OC_DISCOVERABLE | OC_OBSERVABLE); + OCStackResult result = OCPlatform::registerResource(m_resourceHandle, resourceURI, + resourceTypeName, resourceInterface, cb, OC_DISCOVERABLE | OC_OBSERVABLE); - if (OC_STACK_OK != result) - { - printf("\nLightResource : OC_STACK_OK != result..."); - } - else - { - cv2.notify_all(); - std::mutex blocker; - std::condition_variable cv; - std::unique_lock < std::mutex > lock(blocker); - cv.wait(lock); - } + if (OC_STACK_OK != result) + { + printf("\nLightResource : OC_STACK_OK != result..."); } - - OCResourceHandle getHandle() + else { - return m_resourceHandle; + cv2.notify_all(); + std::mutex blocker; + std::condition_variable cv; + std::unique_lock < std::mutex > lock(blocker); + cv.wait(lock); } + } + + OCResourceHandle getHandle() + { + return m_resourceHandle; + } - void put(OCRepresentation &rep) + void put(OCRepresentation &rep) + { + try { - try + std::string test; + if (rep.getValue < std::string > ("power", test)) { - std::string test; - if (rep.getValue("power", test)) - { - cout << "\t\t\t\t" << "power: " << test << endl; - } - else - { - cout << "\t\t\t\t" << "power not found in the representation" << endl; - } + cout << "\t\t\t\t" << "power: " << test << endl; } - catch (exception &e) + else { - cout << e.what() << endl; + cout << "\t\t\t\t" << "power not found in the representation" << endl; } } - - OCRepresentation post(OCRepresentation &rep) + catch (exception &e) { - put(rep); - return get(); + cout << e.what() << endl; } + } - OCRepresentation get() - { - m_lightRep.setValue("power", m_power); + OCRepresentation post(OCRepresentation &rep) + { + put(rep); + return get(); + } - return m_lightRep; - } + OCRepresentation get() + { + m_lightRep.setValue("power", m_power); + + return m_lightRep; + } - void addType(const std::string &type) const + void addType(const std::string &type) const + { + OCStackResult result = OCPlatform::bindTypeToResource(m_resourceHandle, type); + if (OC_STACK_OK != result) { - OCStackResult result = OCPlatform::bindTypeToResource(m_resourceHandle, type); - if (OC_STACK_OK != result) - { - cout << "Binding TypeName to Resource was unsuccessful\n"; - } + cout << "Binding TypeName to Resource was unsuccessful\n"; } + } - void addInterface(const std::string &interface) const + void addInterface(const std::string &interface) const + { + OCStackResult result = OCPlatform::bindInterfaceToResource(m_resourceHandle, interface); + if (OC_STACK_OK != result) { - OCStackResult result = OCPlatform::bindInterfaceToResource(m_resourceHandle, interface); - if (OC_STACK_OK != result) - { - cout << "Binding TypeName to Resource was unsuccessful\n"; - } + cout << "Binding TypeName to Resource was unsuccessful\n"; } + } - private: - OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request) +private: + OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request) + { + cout << "\tIn Server CPP entity handler:\n"; + OCEntityHandlerResult ehResult = OC_EH_ERROR; + if (request) { - cout << "\tIn Server CPP entity handler:\n"; - OCEntityHandlerResult ehResult = OC_EH_ERROR; - if (request) + std::string requestType = request->getRequestType(); + int requestFlag = request->getRequestHandlerFlag(); + + if (requestFlag & RequestHandlerFlag::RequestFlag) { - std::string requestType = request->getRequestType(); - int requestFlag = request->getRequestHandlerFlag(); + cout << "\t\trequestFlag : Request\n"; + auto pResponse = std::make_shared< OC::OCResourceResponse >(); + pResponse->setRequestHandle(request->getRequestHandle()); + pResponse->setResourceHandle(request->getResourceHandle()); - if (requestFlag & RequestHandlerFlag::RequestFlag) + if (requestType == "GET") { - cout << "\t\trequestFlag : Request\n"; - auto pResponse = std::make_shared< OC::OCResourceResponse >(); - pResponse->setRequestHandle(request->getRequestHandle()); - pResponse->setResourceHandle(request->getResourceHandle()); - - if (requestType == "GET") + cout << "\t\t\trequestType : GET\n"; + if (isSlowResponse) { - cout << "\t\t\trequestType : GET\n"; - if (isSlowResponse) + static int startedThread = 0; + if (!startedThread) { - static int startedThread = 0; - if (!startedThread) - { - std::thread t(handleSlowResponse, (void *) this, request); - startedThread = 1; - t.detach(); - } - ehResult = OC_EH_SLOW; - } - else - { - pResponse->setErrorCode(200); - pResponse->setResponseResult(OC_EH_OK); - pResponse->setResourceRepresentation(get()); - if (OC_STACK_OK == OCPlatform::sendResponse(pResponse)) - { - ehResult = OC_EH_OK; - } + std::thread t(handleSlowResponse, (void *) this, request); + startedThread = 1; + t.detach(); } + ehResult = OC_EH_SLOW; } - else if (requestType == "PUT") + else { - cout << "\t\t\trequestType : PUT\n"; - OCRepresentation rep = request->getResourceRepresentation(); - put(rep); pResponse->setErrorCode(200); pResponse->setResponseResult(OC_EH_OK); - pResponse->setResourceRepresentation(rep); + pResponse->setResourceRepresentation(get()); if (OC_STACK_OK == OCPlatform::sendResponse(pResponse)) { ehResult = OC_EH_OK; } } - else if (requestType == "POST") + } + else if (requestType == "PUT") + { + cout << "\t\t\trequestType : PUT\n"; + OCRepresentation rep = request->getResourceRepresentation(); + put(rep); + pResponse->setErrorCode(200); + pResponse->setResponseResult(OC_EH_OK); + pResponse->setResourceRepresentation(rep); + if (OC_STACK_OK == OCPlatform::sendResponse(pResponse)) { - cout << "\t\t\trequestType : POST\n"; + ehResult = OC_EH_OK; + } + } + else if (requestType == "POST") + { + cout << "\t\t\trequestType : POST\n"; - OCRepresentation rep = request->getResourceRepresentation(); - OCRepresentation rep_post = post(rep); + OCRepresentation rep = request->getResourceRepresentation(); + OCRepresentation rep_post = post(rep); - pResponse->setResourceRepresentation(rep_post); - pResponse->setErrorCode(200); - if (rep_post.hasAttribute("createduri")) - { - pResponse->setResponseResult(OC_EH_RESOURCE_CREATED); - pResponse->setNewResourceUri( - rep_post.getValue< std::string >("createduri")); - } - - if (OC_STACK_OK == OCPlatform::sendResponse(pResponse)) - { - ehResult = OC_EH_OK; - } + pResponse->setResourceRepresentation(rep_post); + pResponse->setErrorCode(200); + if (rep_post.hasAttribute("createduri")) + { + pResponse->setResponseResult(OC_EH_RESOURCE_CREATED); + pResponse->setNewResourceUri( + rep_post.getValue < std::string > ("createduri")); } - else if (requestType == "DELETE") + + if (OC_STACK_OK == OCPlatform::sendResponse(pResponse)) { + ehResult = OC_EH_OK; } } + else if (requestType == "DELETE") + { + } } - else - { - std::cout << "Request invalid" << std::endl; - } - return ehResult; } + else + { + std::cout << "Request invalid" << std::endl; + } + return ehResult; + } }; void *handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pRequest) @@ -305,8 +304,8 @@ void ConfigurationResource::createResources(ResourceEntityHandler callback) } OCStackResult result = registerResource(m_configurationHandle, m_configurationUri, - m_configurationTypes[0], m_configurationInterfaces[0], callback, - OC_DISCOVERABLE | OC_OBSERVABLE); + m_configurationTypes[0], m_configurationInterfaces[0], callback, + OC_DISCOVERABLE | OC_OBSERVABLE); if (OC_STACK_OK != result) { @@ -381,7 +380,6 @@ void ConfigurationResource::factoryReset() m_region = defaultRegion; } - /****** FactorySet Resource ******/ FactorySetResource::FactorySetResource() @@ -393,7 +391,9 @@ FactorySetResource::FactorySetResource() m_configurationRep.setResourceTypes(m_configurationTypes); } -FactorySetResource::~FactorySetResource() {} +FactorySetResource::~FactorySetResource() +{ +} void FactorySetResource::createResources(ResourceEntityHandler callback) { @@ -406,8 +406,8 @@ void FactorySetResource::createResources(ResourceEntityHandler callback) } OCStackResult result = registerResource(m_configurationHandle, m_configurationUri, - m_configurationTypes[0], m_configurationInterfaces[0], callback, - OC_DISCOVERABLE | OC_OBSERVABLE); + m_configurationTypes[0], m_configurationInterfaces[0], callback, + OC_DISCOVERABLE | OC_OBSERVABLE); if (OC_STACK_OK != result) { @@ -475,7 +475,6 @@ std::string FactorySetResource::getUri() return m_configurationUri; } - /****** Maintenance Resource ********/ void MaintenanceResource::createResources(ResourceEntityHandler callback) @@ -489,8 +488,8 @@ void MaintenanceResource::createResources(ResourceEntityHandler callback) } OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri, - m_maintenanceTypes[0], m_maintenanceInterfaces[0], callback, - OC_DISCOVERABLE | OC_OBSERVABLE); + m_maintenanceTypes[0], m_maintenanceInterfaces[0], callback, + OC_DISCOVERABLE | OC_OBSERVABLE); if (OC_STACK_OK != result) { @@ -498,9 +497,9 @@ void MaintenanceResource::createResources(ResourceEntityHandler callback) } thread exec( - std::function< void(int second) >( - std::bind(&MaintenanceResource::maintenanceMonitor, this, - std::placeholders::_1)), 10); + std::function< void(int second) >( + std::bind(&MaintenanceResource::maintenanceMonitor, this, + std::placeholders::_1)), 10); exec.detach(); cv3.notify_all(); std::mutex blocker; @@ -580,12 +579,11 @@ getFunc getGetFunction(std::string uri) if (uri == myConfigurationResource->getUri()) { res = std::bind(&ConfigurationResource::getConfigurationRepresentation, - myConfigurationResource); + myConfigurationResource); } else if (uri == myMaintenanceResource->getUri()) { - res = std::bind(&MaintenanceResource::getMaintenanceRepresentation, - myMaintenanceResource); + res = std::bind(&MaintenanceResource::getMaintenanceRepresentation, myMaintenanceResource); } return res; } @@ -597,12 +595,12 @@ putFunc getPutFunction(std::string uri) if (uri == myConfigurationResource->getUri()) { res = std::bind(&ConfigurationResource::setConfigurationRepresentation, - myConfigurationResource, std::placeholders::_1); + myConfigurationResource, std::placeholders::_1); } else if (uri == myMaintenanceResource->getUri()) { - res = std::bind(&MaintenanceResource::setMaintenanceRepresentation, - myMaintenanceResource, std::placeholders::_1); + res = std::bind(&MaintenanceResource::setMaintenanceRepresentation, myMaintenanceResource, + std::placeholders::_1); } return res; } @@ -710,62 +708,61 @@ OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceReques return ehResult; } - /****** BootStrap Resource [Required for doBootstrap API of ThingsConfiguration class] ******/ class BootstrapResource { - public: - std::string m_bootstrapUri; - std::vector< std::string > m_bootstrapTypes; - std::vector< std::string > m_bootstrapInterfaces; - OCResourceHandle m_bootstrapHandle; - OCRepresentation m_bootstrapRep; +public: + std::string m_bootstrapUri; + std::vector< std::string > m_bootstrapTypes; + std::vector< std::string > m_bootstrapInterfaces; + OCResourceHandle m_bootstrapHandle; + OCRepresentation m_bootstrapRep; + +public: + BootstrapResource() + { + m_bootstrapUri = "/bootstrap"; + m_bootstrapTypes.push_back("bootstrap"); + m_bootstrapInterfaces.push_back(DEFAULT_INTERFACE); + m_bootstrapRep.setUri(m_bootstrapUri); + m_bootstrapRep.setResourceTypes(m_bootstrapTypes); + m_bootstrapRep.setResourceInterfaces(m_bootstrapInterfaces); + m_bootstrapHandle = NULL; + } + void createResources() + { + using namespace OC::OCPlatform; + OCStackResult result = registerResource(m_bootstrapHandle, m_bootstrapUri, + m_bootstrapTypes[0], m_bootstrapInterfaces[0], entityHandlerBootstrap, + OC_DISCOVERABLE | OC_OBSERVABLE); - public: - BootstrapResource() + if (OC_STACK_OK != result) { - m_bootstrapUri = "/bootstrap"; - m_bootstrapTypes.push_back("bootstrap"); - m_bootstrapInterfaces.push_back(DEFAULT_INTERFACE); - m_bootstrapRep.setUri(m_bootstrapUri); - m_bootstrapRep.setResourceTypes(m_bootstrapTypes); - m_bootstrapRep.setResourceInterfaces(m_bootstrapInterfaces); - m_bootstrapHandle = NULL; + cout << "Resource creation (room) was unsuccessful\n"; } - void createResources() - { - using namespace OC::OCPlatform; - OCStackResult result = registerResource(m_bootstrapHandle, m_bootstrapUri, - m_bootstrapTypes[0], m_bootstrapInterfaces[0], entityHandlerBootstrap, - OC_DISCOVERABLE | OC_OBSERVABLE); - - if (OC_STACK_OK != result) - { - cout << "Resource creation (room) was unsuccessful\n"; - } - cv5.notify_all(); - std::mutex blocker; - std::condition_variable cv; - std::unique_lock < std::mutex > lock(blocker); - cv.wait(lock); - } + cv5.notify_all(); + std::mutex blocker; + std::condition_variable cv; + std::unique_lock < std::mutex > lock(blocker); + cv.wait(lock); + } - void setBootstrapRepresentation(OCRepresentation &rep) - { - } + void setBootstrapRepresentation(OCRepresentation& /*rep*/) + { + } - OCRepresentation getBootstrapRepresentation() - { - m_bootstrapRep.setValue< std::string >("n", defaultDeviceName); - m_bootstrapRep.setValue< std::string >("loc", defaultLocation); - m_bootstrapRep.setValue< std::string >("locn", defaultLocationName); - m_bootstrapRep.setValue< std::string >("c", defaultCurrency); - m_bootstrapRep.setValue< std::string >("r", defaultRegion); + OCRepresentation getBootstrapRepresentation() + { + m_bootstrapRep.setValue < std::string > ("n", defaultDeviceName); + m_bootstrapRep.setValue < std::string > ("loc", defaultLocation); + m_bootstrapRep.setValue < std::string > ("locn", defaultLocationName); + m_bootstrapRep.setValue < std::string > ("c", defaultCurrency); + m_bootstrapRep.setValue < std::string > ("r", defaultRegion); - return m_bootstrapRep; - } + return m_bootstrapRep; + } }; BootstrapResource myBootstrapResource; @@ -850,68 +847,86 @@ OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest return ehResult; } - /****** gtest class ******/ class ThingsManagerTest: public TestWithMock { - public : - void Proceed() - { - cond.notify_all(); - } +public: + void Proceed() + { + cond.notify_all(); + } - void Wait(int waitingTime = DEFAULT_WAITING_TIME_IN_MILLIS) - { - std::unique_lock< std::mutex > lock { mutex }; - cond.wait_for(lock, std::chrono::milliseconds { waitingTime }); - } + void Wait(int waitingTime = DEFAULT_WAITING_TIME_IN_MILLIS) + { + std::unique_lock < std::mutex > lock + { mutex }; + cond.wait_for(lock, std::chrono::milliseconds + { waitingTime }); + } - protected: - void SetUp() - { - TestWithMock::SetUp(); - } +protected: + void SetUp() + { + TestWithMock::SetUp(); + } - void TearDown() - { - TestWithMock::TearDown(); - } + void TearDown() + { + TestWithMock::TearDown(); + } - private: - std::condition_variable cond; - std::mutex mutex; +private: + std::condition_variable cond; + std::mutex mutex; }; //Callbacks -void onUpdate(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode) {} +void onUpdate(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) +{ +} -void onGetBootstrapInformation(const HeaderOptions &headerOptions, const OCRepresentation &rep, - const int eCode) {} +void onGetBootstrapInformation(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& /*rep*/, const int /*eCode*/) +{ +} -void onReboot(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode) {} +void onReboot(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) +{ +} -void onFactoryReset(const HeaderOptions &headerOptions, const OCRepresentation &rep, - const int eCode) {} +void onFactoryReset(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) +{ +} -void onGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode) {} +void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) +{ +} -void onPut(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode) {} +void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) +{ +} -void onPost(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode) {} +void onPost(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) +{ +} -void foundResources(std::vector > listOfResource) +void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResource) { - for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end(); - ++rsrc) + for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end(); ++rsrc) { std::string resourceURI = (*rsrc)->uri(); std::string hostAddress = (*rsrc)->host(); if (resourceURI == "/a/light") { - result = OCPlatform::registerResource( - foundResourceHandle, (*rsrc)); + result = OCPlatform::registerResource(foundResourceHandle, (*rsrc)); if (result == OC_STACK_OK) { OCPlatform::bindResource(resourceHandle, foundResourceHandle); @@ -933,7 +948,7 @@ void foundResources(std::vector > listOfResource cv2.notify_all(); } -void foundGroupResource(std::shared_ptr resource) +void foundGroupResource(std::shared_ptr< OCResource > resource) { std::string resourceURI; resourceURI = resource->uri(); @@ -951,9 +966,9 @@ void foundGroupResource(std::shared_ptr resource) //This test case is to create the lightserver , BootstrapServer & configuration sever TEST_F(ThingsManagerTest, testCreateResources) { - PlatformConfig cfg { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos }; + PlatformConfig cfg + { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos}; OCPlatform::Configure(cfg); - bool actual = true; LightResource myLight; std::thread t1(&LightResource::createResource, &myLight); @@ -970,7 +985,7 @@ TEST_F(ThingsManagerTest, testCreateResources) myConfigurationResource = new ConfigurationResource(); std::thread t3(&ConfigurationResource::createResources, myConfigurationResource, - &entityHandlerForResource); + &entityHandlerForResource); t3.detach(); std::mutex blocker3; @@ -979,7 +994,7 @@ TEST_F(ThingsManagerTest, testCreateResources) myMaintenanceResource = new MaintenanceResource(); std::thread t4(&MaintenanceResource::createResources, myMaintenanceResource, - &entityHandlerForResource); + &entityHandlerForResource); t4.detach(); std::mutex blocker4; @@ -988,7 +1003,7 @@ TEST_F(ThingsManagerTest, testCreateResources) myFactorySetResource = new FactorySetResource(); std::thread t5(&FactorySetResource::createResources, myFactorySetResource, - &entityHandlerForResource); + &entityHandlerForResource); t5.detach(); std::mutex blocker5; @@ -996,8 +1011,8 @@ TEST_F(ThingsManagerTest, testCreateResources) cv4.wait(lock5); myMaintenanceResource->factoryReset = std::function < void() - > (std::bind(&ConfigurationResource::factoryReset, - myConfigurationResource)); + > (std::bind(&ConfigurationResource::factoryReset, + myConfigurationResource)); } //Check findCandidateResources @@ -1009,7 +1024,7 @@ TEST_F(ThingsManagerTest, testFindCandidateResources) string resourceInterface = BATCH_INTERFACE; OCStackResult res = OCPlatform::registerResource(resourceHandle, resourceURI, - resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE); + resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE); if ( res != OC_STACK_OK ) { @@ -1047,6 +1062,7 @@ TEST_F(ThingsManagerTest, testFindCandidateResourcesEmptyResourceType) vector types; result = instance->findCandidateResources(types, &foundResources); EXPECT_TRUE(result == OC_STACK_ERROR); + delete instance; } //Find Candidate Resource when Callback is null @@ -1057,22 +1073,21 @@ TEST_F(ThingsManagerTest, testFindCandidateResourcesNullCallback) types.push_back("core.light"); result = instance->findCandidateResources(types, NULL); EXPECT_TRUE(result == OC_STACK_ERROR); + delete instance; } //test bind resource to group TEST_F(ThingsManagerTest, testBindResourceToGroup) { GroupManager *instance = new GroupManager(); - OCResourceHandle groupHandle = NULL; - OCResourceHandle foundHandle = NULL; OCResourceHandle rHandle = NULL; string resourceURI = "/core/room-large"; - string resourceTypeName = "core.room-large"; + string resourceTypeName = "core.room-large"; string resourceInterface = BATCH_INTERFACE; OCStackResult res = OCPlatform::registerResource(rHandle, resourceURI, - resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE); + resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE); if ( res != OC_STACK_OK ) { @@ -1082,7 +1097,6 @@ TEST_F(ThingsManagerTest, testBindResourceToGroup) OCPlatform::bindInterfaceToResource(rHandle, GROUP_INTERFACE); OCPlatform::bindInterfaceToResource(rHandle, DEFAULT_INTERFACE); - std::string query = OC_RSRVD_WELL_KNOWN_URI; query.append("?rt="); query.append(resourceTypeName); @@ -1096,6 +1110,7 @@ TEST_F(ThingsManagerTest, testBindResourceToGroup) result = instance->bindResourceToGroup (resourceHandle, g_room_resource, rHandle); EXPECT_TRUE(result == OC_STACK_OK); + delete instance; } //Add actionset @@ -1106,7 +1121,8 @@ TEST_F(ThingsManagerTest, testAddActionSetAllBulbOff) allBulbOff->actionsetName = "AllBulbOff"; mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1178,7 +1194,8 @@ TEST_F(ThingsManagerTest, testAddActionSetAllBulbOn) allBulbON->actionsetName = "AllBulbOn"; mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1194,7 +1211,7 @@ TEST_F(ThingsManagerTest, testAddActionSetAllBulbOn) } if (g_resource) { - result = groupMgr->addActionSet(g_resource, allBulbON, onPut); + result = groupMgr->addActionSet(g_resource, allBulbON, onPut); Wait(); EXPECT_TRUE(result == OC_STACK_OK); result = 0; @@ -1222,7 +1239,7 @@ TEST_F(ThingsManagerTest, testAddActionSetAllBulbOnResourceNull) allBulbON->listOfAction.push_back(action); } - result = groupMgr->addActionSet(NULL, allBulbON, onPut); + result = groupMgr->addActionSet(NULL, allBulbON, onPut); Wait(); EXPECT_TRUE(result == OC_STACK_ERROR); result = 0; @@ -1235,7 +1252,7 @@ TEST_F(ThingsManagerTest, testAddActionSetAllBulbOnActionSetNull) { if (g_resource) { - result = groupMgr->addActionSet(g_resource, NULL, onPut); + result = groupMgr->addActionSet(g_resource, NULL, onPut); Wait(); EXPECT_TRUE(result == OC_STACK_ERROR); result = 0; @@ -1250,7 +1267,8 @@ TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOn) allBulbON->actionsetName = "AllBulbOn1"; mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1266,14 +1284,15 @@ TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOn) } if (g_resource) { - result = groupMgr->addActionSet(g_resource, allBulbON, onPut); + result = groupMgr->addActionSet(g_resource, allBulbON, onPut); Wait(); EXPECT_TRUE(result == OC_STACK_OK); result = 0; } mocks.ExpectCallFunc(onPost). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); if (g_resource) { @@ -1297,7 +1316,8 @@ TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOnResourceNull) TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOff) { mocks.ExpectCallFunc(onPost). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); if (g_resource) { @@ -1326,7 +1346,8 @@ TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelay) allBulbON->setDelay(1); mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1347,7 +1368,8 @@ TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelay) } mocks.ExpectCallFunc(onPost). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); if (g_resource) { @@ -1366,7 +1388,8 @@ TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayEqulasZero) allBulbON->actionsetName = "AllBulbOnDelay"; mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1403,7 +1426,8 @@ TEST_F(ThingsManagerTest, testExcecuteActionSetWithInvalidDelay) allBulbON->actionsetName = "AllBulbOnDelay"; mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1441,7 +1465,8 @@ TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayWithResourceNull) allBulbON->setDelay(5); mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { @@ -1470,7 +1495,8 @@ TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayWithResourceNull) TEST_F(ThingsManagerTest, testCancelActionSet) { mocks.ExpectCallFunc(onPost). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); if (g_resource) { @@ -1494,7 +1520,8 @@ TEST_F(ThingsManagerTest, testCancelActionSetResourceNull) TEST_F(ThingsManagerTest, testDeleteActionSet) { mocks.ExpectCallFunc(onPut). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); if (g_resource) { @@ -1518,11 +1545,12 @@ TEST_F(ThingsManagerTest, testDeleteActionSetResourceNull) TEST_F(ThingsManagerTest, testGetActionSet) { mocks.ExpectCallFunc(onPost). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); if (g_resource) { - result = groupMgr->getActionSet(g_resource, "AllBulbOn", &onPost); + result = groupMgr->getActionSet(g_resource, "AllBulbOn", &onPost); Wait(); EXPECT_TRUE(result == OC_STACK_OK); result = 0; @@ -1532,7 +1560,7 @@ TEST_F(ThingsManagerTest, testGetActionSet) //Get ActionSet on NULL Resource TEST_F(ThingsManagerTest, testGetActionSetResourceNull) { - result = groupMgr->getActionSet(NULL, "AllBulbOn", &onPost); + result = groupMgr->getActionSet(NULL, "AllBulbOn", &onPost); Wait(); EXPECT_TRUE(result == OC_STACK_ERROR); result = 0; @@ -1549,7 +1577,8 @@ TEST_F(ThingsManagerTest, testGetConfigurations) configurations.push_back(name); mocks.ExpectCallFunc(onGet). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); vector types; types.push_back("oic.wk.con"); @@ -1622,7 +1651,8 @@ TEST_F(ThingsManagerTest, testDoBootstrap) ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance(); mocks.ExpectCallFunc(onGetBootstrapInformation). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); result = g_thingsConf->doBootstrap(&onGetBootstrapInformation); Wait(); EXPECT_TRUE(result == OC_STACK_OK); @@ -1651,7 +1681,8 @@ TEST_F(ThingsManagerTest, testUpdateConfiguration) configurations.insert(std::make_pair(name, value)); mocks.ExpectCallFunc(onUpdate). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); vector types; types.push_back("oic.wk.con"); @@ -1663,7 +1694,8 @@ TEST_F(ThingsManagerTest, testUpdateConfiguration) if (result == OC_STACK_OK) { - result = g_thingsConf->updateConfigurations(configurationResource, configurations, &onUpdate); + result = g_thingsConf->updateConfigurations(configurationResource, configurations, + &onUpdate); Wait(); EXPECT_TRUE(result == OC_STACK_OK); result = 0; @@ -1686,7 +1718,8 @@ TEST_F(ThingsManagerTest, testUpdateConfigurationEmptyConfiguration) if (result == OC_STACK_OK) { - result = g_thingsConf->updateConfigurations(configurationResource, configurations, &onUpdate); + result = g_thingsConf->updateConfigurations(configurationResource, configurations, + &onUpdate); Wait(); EXPECT_TRUE(result == OC_STACK_ERROR); result = 0; @@ -1716,7 +1749,8 @@ TEST_F(ThingsManagerTest, testReboot) ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance(); mocks.ExpectCallFunc(onReboot). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); vector types; types.push_back("oic.wk.mnt"); @@ -1752,7 +1786,8 @@ TEST_F(ThingsManagerTest, testFactoryReset) ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance(); mocks.ExpectCallFunc(onFactoryReset). - Do([this](const HeaderOptions & headerOptions, const OCRepresentation & rep, const int eCode) { Proceed(); }); + Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/, + const int /*eCode*/) { Proceed();}); vector types; types.push_back("oic.wk.mnt"); -- 2.7.4