From b95d7f9afee22b203cbd4e701a9d40714bc15559 Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Mon, 22 Aug 2016 13:26:23 +0900 Subject: [PATCH] Fix unittest of things manager to wait a certain time to discover resources findCandidateResources can have the third parameter which is a waitTime for discovering resources. If it is not specified, it acts like findResource. It means, once any resource is discovered, it is immediately called, which makes the test case failed if wrong resource is discovered. To resolve this issue, we wait until a right resource id discovered. Change-Id: Ib3d6f5595c955c8565d031d5fd2faf2ee904abe5 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/10703 Reviewed-by: Jaehong Jo Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- service/things-manager/unittests/ThingsManagerTest.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/service/things-manager/unittests/ThingsManagerTest.cpp b/service/things-manager/unittests/ThingsManagerTest.cpp index cdb3334..53812ff 100755 --- a/service/things-manager/unittests/ThingsManagerTest.cpp +++ b/service/things-manager/unittests/ThingsManagerTest.cpp @@ -944,10 +944,12 @@ void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResou lights.push_back((hostAddress + resourceURI)); g_light = (*rsrc); + cv2.notify_all(); } else { configurationResource = (*rsrc); + cv2.notify_all(); } } cv2.notify_all(); @@ -1601,7 +1603,7 @@ TEST_F(ThingsManagerTest, testGetConfigurations) vector types; types.push_back("oic.wk.con"); - result = groupMgr->findCandidateResources(types, &foundResources); + result = groupMgr->findCandidateResources(types, &foundResources, 3); std::mutex blocker; std::unique_lock < std::mutex > lock(blocker); @@ -1625,7 +1627,7 @@ TEST_F(ThingsManagerTest, testGetConfigurationsEmptyConfiguration) vector types; types.push_back("oic.wk.con"); - result = groupMgr->findCandidateResources(types, &foundResources); + result = groupMgr->findCandidateResources(types, &foundResources, 3); std::mutex blocker; std::unique_lock < std::mutex > lock(blocker); @@ -1704,7 +1706,7 @@ TEST_F(ThingsManagerTest, testUpdateConfiguration) vector types; types.push_back("oic.wk.con"); - result = groupMgr->findCandidateResources(types, &foundResources); + result = groupMgr->findCandidateResources(types, &foundResources, 3); std::mutex blocker2; std::unique_lock < std::mutex > lock2(blocker2); @@ -1728,7 +1730,7 @@ TEST_F(ThingsManagerTest, testUpdateConfigurationEmptyConfiguration) vector types; types.push_back("oic.wk.con"); - result = groupMgr->findCandidateResources(types, &foundResources); + result = groupMgr->findCandidateResources(types, &foundResources, 3); std::mutex blocker2; std::unique_lock < std::mutex > lock2(blocker2); @@ -1772,7 +1774,7 @@ TEST_F(ThingsManagerTest, testReboot) vector types; types.push_back("oic.wk.mnt"); - result = groupMgr->findCandidateResources(types, &foundResources); + result = groupMgr->findCandidateResources(types, &foundResources, 3); std::mutex blocker; std::unique_lock < std::mutex > lock(blocker); @@ -1809,7 +1811,7 @@ TEST_F(ThingsManagerTest, testFactoryReset) vector types; types.push_back("oic.wk.mnt"); - result = groupMgr->findCandidateResources(types, &foundResources); + result = groupMgr->findCandidateResources(types, &foundResources, 3); std::mutex blocker; std::unique_lock < std::mutex > lock(blocker); -- 2.7.4