[IOT-2014] linker changes for connectivity_abstraction
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / unittest / SConscript
index 653df64..fbdb5fd 100644 (file)
 
 import os
 import os.path
+from tools.scons.RunTest import run_test
+
+Import('test_env')
 
 # SConscript file for Local PKI google tests
-gtest_env = SConscript('#extlibs/gtest/SConscript')
-sptest_env = gtest_env.Clone()
+sptest_env = test_env.Clone()
 src_dir = sptest_env.get('SRC_DIR')
 target_os = sptest_env.get('TARGET_OS')
+rd_mode = sptest_env.get('RD_MODE')
 
 ######################################################################
 # Build flags
 ######################################################################
 with_upstream_libcoap = sptest_env.get('WITH_UPSTREAM_LIBCOAP')
 if with_upstream_libcoap == '1':
-       # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
        sptest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
 else:
-       # For bring up purposes only, the forked version will live here.
        sptest_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
 
 sptest_env.PrependUnique(CPPPATH = [
                '../include',
                '../../include',
                '../include/internal',
-               '../../../stack/include',
+               '../../../include',
                '../../../ocrandom/include',
                '../../../logger/include',
                '../../../stack/include',
@@ -51,42 +52,38 @@ sptest_env.PrependUnique(CPPPATH = [
                '../../../security/provisioning/include/internal',
                '../../../../oc_logger/include',
                '../include/oxm',
-               '../../../../../extlibs/tinydtls',
-               '../../../../../extlibs/cjson',
                '../../../../../extlibs/base64',
                '../../../connectivity/inc',
                '../../../connectivity/inc/pkix',
                '../../../connectivity/common/inc',
-               '../../../connectivity/api',
-               '../../../../../extlibs/tinydtls'
+               '../../../connectivity/api'
                ])
-sptest_env.AppendUnique(LIBPATH = [sptest_env.get('BUILD_DIR')])
-sptest_env.PrependUnique(LIBS = [   'ocpmapi',
+
+sptest_env.PrependUnique(LIBS = [   'ocpmapi_internal',
                                     'oc',
+                                    'octbstack_internal',
                                     'ocsrm',
-                                    'octbstack',
-                                    'oc_logger',
-                                    'connectivity_abstraction',
+                                    'routingmanager',
+                                    'oc_logger_internal',
+                                    'connectivity_abstraction_internal',
                                     'coap'])
 
 if sptest_env.get('SECURED') == '1':
-    sptest_env.AppendUnique(LIBS = ['timer'])
-    sptest_env.AppendUnique(LIBS = ['tinydtls'])
-
-if sptest_env.get('DTLS_WITH_X509') == '1':
-       sptest_env.AppendUnique(LIBS = ['CKManager'])
-       sptest_env.AppendUnique(LIBS = ['asn1'])
-
-if sptest_env.get('WITH_TCP') == True:
-       sptest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
+    sptest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
 
 if not sptest_env.get('RELEASE'):
        sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
+if sptest_env.get('MULTIPLE_OWNER') == '1':
+       sptest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
+
+sptest_env.AppendUnique(LIBS = ['octbstack_internal'])
+
 if target_os in ['msys_nt', 'windows']:
-    sptest_env.AppendUnique(LIBS = ['ws2_32',
-                                    'advapi32',
-                                    'iphlpapi'])
+    sptest_env.AppendUnique(LIBS = ['sqlite3'])
+else:
+    if target_os in ['linux', 'tizen']:
+        sptest_env.ParseConfig('pkg-config --cflags --libs sqlite3 gobject-2.0 gio-2.0 glib-2.0')
 
 ######################################################################
 # Source files and Targets
@@ -111,7 +108,8 @@ if target_os not in ['windows']:
 Alias("test", [unittest])
 
 sptest_env.AppendTarget('test')
-if sptest_env.get('TEST') == '1':
+# TODO: fix test for all supported configurations
+if sptest_env.get('TEST') == '1' and sptest_env.get('SECURED') != '1':
        if target_os in ['linux', 'windows']:
                out_dir = sptest_env.get('BUILD_DIR')
                result_dir = os.path.join(sptest_env.get('BUILD_DIR'), 'test_out') + os.sep
@@ -120,6 +118,6 @@ if sptest_env.get('TEST') == '1':
                sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
                sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
                sptest_env.AppendENVPath('PATH', sptest_env.get('BUILD_DIR'))
-               ut = sptest_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/unittest/unittest')
-               AlwaysBuild ('ut')
-
+               run_test(sptest_env,
+                                'resource_csdk_security_provisioning_unittest.memcheck',
+                                'resource/csdk/security/provisioning/unittest/unittest')