notification: Enable SECURED build of unit tests.
authorPawel Winogrodzki <pawelwi@microsoft.com>
Sat, 8 Jul 2017 00:28:37 +0000 (17:28 -0700)
committerPhil Coval <philippe.coval@osg.samsung.com>
Tue, 11 Jul 2017 07:48:58 +0000 (07:48 +0000)
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 <pawelwi@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21329
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
service/notification/unittest/NSConsumerTest.cpp
service/notification/unittest/NSProviderTest.cpp
service/notification/unittest/SConscript

index 38cc2ab..34f2dfe 100644 (file)
@@ -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);
  
index 05e711e..382c88e 100644 (file)
 #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 };
index 70729cf..31f8df9 100644 (file)
@@ -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(