From: Jihun Ha Date: Mon, 22 Aug 2016 04:26:23 +0000 (+0900) Subject: Fix unittest of things manager to wait a certain time to discover resources X-Git-Tag: 1.2.0+RC1~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b95d7f9afee22b203cbd4e701a9d40714bc15559;p=platform%2Fupstream%2Fiotivity.git 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 --- 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);