From: Pawel Winogrodzki Date: Sat, 8 Jul 2017 00:28:37 +0000 (-0700) Subject: notification: Enable SECURED build of unit tests. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3968b9a84ac1e577feac2924980a0ffc6846f21;p=platform%2Fupstream%2Fiotivity.git notification: Enable SECURED build of unit tests. The notification consumer and provider tests didn't include the "SECURED" macros for builds with security turned on, even though it seems clear from the code, that it expected that macro to be present in some cases. Bug: https://jira.iotivity.org/browse/IOT-1583 Change-Id: I1166a60c2ad821a7d6002e22a8c9e8bda7321800 Signed-off-by: Pawel Winogrodzki Reviewed-on: https://gerrit.iotivity.org/gerrit/21329 Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai Reviewed-by: Phil Coval --- diff --git a/service/notification/unittest/NSConsumerTest.cpp b/service/notification/unittest/NSConsumerTest.cpp index 38cc2ab..34f2dfe 100644 --- a/service/notification/unittest/NSConsumerTest.cpp +++ b/service/notification/unittest/NSConsumerTest.cpp @@ -35,6 +35,8 @@ #include "NSProviderSimulator.h" #include "NSUnittestUtil.h" +#define DEFAULT_G_TIMEOUT 1000 + namespace { NSProviderSimulator g_providerSimul; @@ -43,9 +45,10 @@ namespace std::atomic_bool g_isStartedStack(false); /// Reasonable timeout is set to 1000 ms in unsecured mode. - unsigned int g_timeout = 1000; #ifdef SECURED - g_timeout = 2 * g_timeout; + unsigned int g_timeout = 2 * DEFAULT_G_TIMEOUT; +#else + unsigned int g_timeout = DEFAULT_G_TIMEOUT; #endif std::chrono::milliseconds g_waitForResponse(g_timeout); diff --git a/service/notification/unittest/NSProviderTest.cpp b/service/notification/unittest/NSProviderTest.cpp index 05e711e..382c88e 100644 --- a/service/notification/unittest/NSProviderTest.cpp +++ b/service/notification/unittest/NSProviderTest.cpp @@ -30,14 +30,17 @@ #include "NSUnittestUtil.h" #include "NSCommon.h" +#define DEFAULT_G_TIMEOUT 1000 + namespace { std::atomic_bool g_isStartedStack(false); /// Reasonable timeout is set to 1000 ms in unsecured mode - unsigned int g_timeout = 1000; #ifdef SECURED - g_timeout = 2 * g_timeout; + unsigned int g_timeout = 2 * DEFAULT_G_TIMEOUT; +#else + unsigned int g_timeout = DEFAULT_G_TIMEOUT; #endif std::chrono::milliseconds g_waitForResponse(g_timeout); @@ -235,9 +238,10 @@ TEST_F(NotificationProviderTest, ExpectCallbackWhenReceiveSubscribeRequestWithAc // maximum waiting time for subscription is 1.5 sec. // usually maximum time is 1 sec. (g_waitForResponse = 1 sec.) - unsigned int timeout = g_timeout * 1.5; #ifdef SECURED - timemout = 2 * timemout; + unsigned int timeout = g_timeout * 3; +#else + unsigned int timeout = g_timeout * 1.5; #endif std::chrono::milliseconds waitForSubscription(timeout); std::unique_lock< std::mutex > lock{ responseProviderSubLock }; diff --git a/service/notification/unittest/SConscript b/service/notification/unittest/SConscript index 70729cf..31f8df9 100644 --- a/service/notification/unittest/SConscript +++ b/service/notification/unittest/SConscript @@ -82,6 +82,7 @@ notification_test_env.PrependUnique(CPPPATH=[ if env.get('WITH_TCP') == True: notification_test_env.AppendUnique(CPPDEFINES=['WITH_TCP']) if env.get('SECURED') == '1': + notification_test_env.AppendUnique(CPPDEFINES=['SECURED']) notification_test_env.AppendUnique( LIBS=['mbedtls', 'mbedx509', 'mbedcrypto']) notification_test_env.AppendUnique(