Commit f197600c authored by Dan Mihai's avatar Dan Mihai

[IOT-2027] Linux: use static octbstack library for tests

Change-Id: I57f3afe1a23bf51d2acbae2bfe27fdd7fa53c1f7
Signed-off-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18823Reviewed-by: default avatarDave Thaler <dthaler@microsoft.com>
Reviewed-by: default avatarKevin Kane <kkane@microsoft.com>
Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
parent e2916b5b
......@@ -45,9 +45,6 @@ randomtest_env.PrependUnique(CPPPATH = ['../include'])
if target_os in ['linux']:
randomtest_env.AppendUnique(LIBS = ['m'])
#if randomtest_env.get('SECURED') == '1':
# randomtest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
if randomtest_env.get('LOGGING'):
randomtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
......
......@@ -158,7 +158,10 @@ if ca_os == 'android':
connectivity_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libconnectivity_abstraction.so'])
if connectivity_env.get('SECURED') == '1':
connectivity_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto'])
connectivity_env.AppendUnique(LIBS = ['mbedtls','mbedx509'])
# c_common calls into mbedcrypto.
connectivity_env.AppendUnique(LIBS = ['mbedcrypto'])
if ca_os in ['android', 'tizen', 'linux', 'yocto']:
connectivity_env.AppendUnique(LIBS = ['coap'])
......
......@@ -76,10 +76,11 @@ if not sptest_env.get('RELEASE'):
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 = ['octbstack_internal', 'sqlite3'])
sptest_env.AppendUnique(LIBS = ['sqlite3'])
else:
sptest_env.AppendUnique(LIBS = ['octbstack'])
if target_os in ['linux', 'tizen']:
sptest_env.ParseConfig('pkg-config --cflags --libs sqlite3')
......
......@@ -40,66 +40,71 @@ else:
srmtest_env.AppendUnique(CPPPATH = ['../../connectivity/lib/libcoap-4.1.1/include'])
srmtest_env.PrependUnique(CPPPATH = [
'../../../c_common/oic_malloc/include',
'../../connectivity/inc',
'../../connectivity/inc/pkix',
'../../connectivity/api',
'../../connectivity/external/inc',
'../include/internal',
'../../logger/include',
'../../include',
'../../stack/include',
'../../stack/include/internal',
'../../../oc_logger/include',
'../provisioning/include',
'../include'
])
srmtest_env.PrependUnique(LIBS = ['ocsrm',
'octbstack_internal',
'oc_logger_internal',
'connectivity_abstraction',
'coap'])
'../../../c_common/oic_malloc/include',
'../../connectivity/inc',
'../../connectivity/inc/pkix',
'../../connectivity/api',
'../../connectivity/external/inc',
'../include/internal',
'../../logger/include',
'../../include',
'../../stack/include',
'../../stack/include/internal',
'../../../oc_logger/include',
'../provisioning/include',
'../include'
])
srmtest_env.PrependUnique(LIBS = [
'octbstack_internal',
'ocsrm',
'oc_logger_internal',
'connectivity_abstraction',
'coap'])
if srmtest_env.get('SECURED') == '1':
srmtest_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto'])
if srmtest_env.get('LOGGING') == '1':
srmtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
srmtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
if srmtest_env.get('MULTIPLE_OWNER') == '1':
srmtest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
srmtest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
if target_os == 'windows':
srmtest_env.AppendUnique(LIBS = ['octbstack_internal', 'sqlite3'])
srmtest_env.AppendUnique(LIBS = ['sqlite3'])
else:
# TODO: Implement feature check.
srmtest_env.AppendUnique(CPPDEFINES = ['HAVE_LOCALTIME_R'])
srmtest_env.AppendUnique(LIBS = ['octbstack'])
# TODO: Implement feature check.
srmtest_env.AppendUnique(CPPDEFINES = ['HAVE_LOCALTIME_R'])
if target_os in ['linux', 'tizen']:
srmtest_env.ParseConfig('pkg-config --cflags --libs sqlite3')
######################################################################
# Source files and Targets
######################################################################
unittest = srmtest_env.Program('unittest', ['aclresourcetest.cpp',
'amaclresourcetest.cpp',
'pstatresource.cpp',
'doxmresource.cpp',
'policyengine.cpp',
'securityresourcemanager.cpp',
'credentialresource.cpp',
'srmutility.cpp',
'iotvticalendartest.cpp',
'base64tests.cpp',
'pbkdf2tests.cpp',
'srmtestcommon.cpp',
'directpairingtest.cpp',
'crlresourcetest.cpp'])
unittest = srmtest_env.Program('unittest', [
'aclresourcetest.cpp',
'amaclresourcetest.cpp',
'pstatresource.cpp',
'doxmresource.cpp',
'policyengine.cpp',
'securityresourcemanager.cpp',
'credentialresource.cpp',
'srmutility.cpp',
'iotvticalendartest.cpp',
'base64tests.cpp',
'pbkdf2tests.cpp',
'srmtestcommon.cpp',
'directpairingtest.cpp',
'crlresourcetest.cpp'
])
Alias("test", [unittest])
unittest_src_dir = os.path.join(src_dir, 'resource', 'csdk', 'security', 'unittest') + os.sep
unittest_build_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'resource', 'csdk', 'security', 'unittest')
unittest_build_dir = os.path.normpath(unittest_build_dir) + os.sep
unittest_build_dir = os.path.normpath(unittest_build_dir) + os.sep
srmtest_env.AppendUnique(CPPDEFINES = ['SECURITY_BUILD_UNITTEST_DIR='+unittest_build_dir.encode('string_escape').replace("\\", "\\\\")])
......@@ -125,11 +130,11 @@ srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
srmtest_env.AppendTarget('test')
if srmtest_env.get('TEST') == '1':
if target_os in ['linux', 'windows']:
out_dir = srmtest_env.get('BUILD_DIR')
result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
run_test(srmtest_env,'ut','resource/csdk/security/unittest/unittest')
if target_os in ['linux', 'windows']:
out_dir = srmtest_env.get('BUILD_DIR')
result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
run_test(srmtest_env,'ut','resource/csdk/security/unittest/unittest')
......@@ -98,6 +98,9 @@ if target_os in ['linux'] and liboctbstack_env.get('SIMULATOR', False):
if env.get('SECURED') == '1':
liboctbstack_env.AppendUnique(LIBS = ['mbedtls','mbedx509'])
# c_common calls into mbedcrypto.
liboctbstack_env.AppendUnique(LIBS = ['mbedcrypto'])
if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
......@@ -173,8 +176,6 @@ if target_os == 'android':
if env.get('LOGGING'):
liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
liboctbstack_env.Append(LIBS = ['c_common', 'mbedcrypto'])
if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
liboctbstack_env.Prepend(LIBS = ['routingmanager'])
......@@ -222,26 +223,19 @@ if 'SERVER' in rd_mode:
if target_os not in ['linux', 'tizen', 'windows']:
liboctbstack_src.append('#extlibs/sqlite3/sqlite3.c')
if target_os in ['linux']:
# Linux uses a Shared library because SCons chooses the shared library on Linux
# when only 'octbstack' is added to the LIBS.
# TODO: Switch Linux to use a Static library for testing like every other OS.
test_liboctbstack = liboctbstack_env.SharedLibrary('octbstack_internal', liboctbstack_src)
else:
test_liboctbstack = liboctbstack_env.StaticLibrary('octbstack_internal', liboctbstack_src)
octbstack_libs = Flatten(test_liboctbstack)
if target_os not in ['windows', 'msys_nt']:
static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
octbstack_libs += Flatten(static_liboctbstack)
internal_liboctbstack = liboctbstack_env.StaticLibrary('octbstack_internal', liboctbstack_src)
octbstack_libs = Flatten(internal_liboctbstack)
if target_os not in ['arduino','darwin','ios'] :
if target_os not in ['arduino', 'darwin', 'ios'] :
shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
octbstack_libs += Flatten(shared_liboctbstack)
liboctbstack_env.UserInstallTargetHeader('include/ocstack.h', 'resource', 'ocstack.h')
liboctbstack_env.UserInstallTargetHeader('include/ocpresence.h', 'resource', 'ocpresence.h')
if target_os not in ['windows', 'msys_nt']:
static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
octbstack_libs += Flatten(static_liboctbstack)
liboctbstack_env.InstallTarget(octbstack_libs, 'octbstack')
liboctbstack_env.UserInstallTargetLib(octbstack_libs, 'octbstack')
......
......@@ -50,11 +50,14 @@ stacktest_env.PrependUnique(LIBS = ['octbstack_internal',
'ocsrm',
'connectivity_abstraction',
'coap',
'mbedcrypto'])
])
if stacktest_env.get('SECURED') == '1':
stacktest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509'])
# c_common calls into mbedcrypto.
stacktest_env.AppendUnique(LIBS = ['mbedcrypto'])
if stacktest_env.get('LOGGING'):
stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
......
......@@ -34,72 +34,75 @@ with_mq = unittests_env.get('WITH_MQ')
# Build flags
######################################################################
unittests_env.PrependUnique(CPPPATH = [
'../include',
'../oc_logger/include',
'../csdk/include',
'../csdk/stack/include',
'../csdk/security/include',
'../csdk/stack/include/internal',
'../csdk/connectivity/api',
'../csdk/connectivity/external/inc',
'../csdk/ocsocket/include',
'../c_common/ocrandom/include',
'../csdk/logger/include',
'#extlibs/hippomocks/hippomocks',
])
'../include',
'../oc_logger/include',
'../csdk/include',
'../csdk/stack/include',
'../csdk/security/include',
'../csdk/stack/include/internal',
'../csdk/connectivity/api',
'../csdk/connectivity/external/inc',
'../csdk/ocsocket/include',
'../c_common/ocrandom/include',
'../csdk/logger/include',
'#extlibs/hippomocks/hippomocks',
])
if target_os in ['windows']:
unittests_env.AppendUnique(CPPPATH = ['#extlibs/boost/boost'])
unittests_env.AppendUnique(LIBS = ['sqlite3'])
# On Windows, octbstack_internal is a static LIB, that makes calls into static LIB ocsrm.
# On other platforms, octbstack_internal is a shared LIB, that includes static LIB ocsrm.
unittests_env.AppendUnique(LIBS = ['ocsrm'])
# Non-Windows platforms find the boost headers under /usr/include or similar path.
unittests_env.AppendUnique(CPPPATH = ['#extlibs/boost/boost'])
unittests_env.AppendUnique(LIBS = ['sqlite3'])
elif target_os in ['linux', 'tizen']:
unittests_env.ParseConfig('pkg-config --cflags --libs sqlite3')
unittests_env.PrependUnique(LIBS = [
'oc',
'octbstack_internal',
'oc_logger_internal',
'connectivity_abstraction',
'coap',
'mbedcrypto'])
'oc',
'octbstack_internal',
'ocsrm',
'oc_logger_internal',
'connectivity_abstraction',
'coap'])
if unittests_env.get('SECURED') == '1':
unittests_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509'])
unittests_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509'])
# c_common calls into mbedcrypto.
unittests_env.AppendUnique(LIBS = ['mbedcrypto'])
if unittests_env.get('LOGGING'):
unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
if unittests_env.get('WITH_CLOUD'):
unittests_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
unittests_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
######################################################################
# Source files and Targets
######################################################################
unittests_src = [
'ConstructResourceTest.cpp',
'OCPlatformTest.cpp',
'OCRepresentationTest.cpp',
'OCRepresentationEncodingTest.cpp',
'OCResourceTest.cpp',
'OCExceptionTest.cpp',
'OCResourceResponseTest.cpp',
'OCHeaderOptionTest.cpp'
]
# TODO: Fix errors in the following Windows tests.
'ConstructResourceTest.cpp',
'OCPlatformTest.cpp',
'OCRepresentationTest.cpp',
'OCRepresentationEncodingTest.cpp',
'OCResourceTest.cpp',
'OCExceptionTest.cpp',
'OCResourceResponseTest.cpp',
'OCHeaderOptionTest.cpp',
]
# TODO: IOT-2039: Fix errors in the following Windows tests.
if target_os in ['windows']:
if '12.0' == unittests_env['MSVC_VERSION']:
unittests_src.remove('OCPlatformTest.cpp')
unittests_src.remove('OCRepresentationEncodingTest.cpp')
unittests_src.remove('OCRepresentationTest.cpp')
unittests_src.remove('OCResourceTest.cpp')
if '12.0' == unittests_env['MSVC_VERSION']:
unittests_src.remove('OCPlatformTest.cpp')
unittests_src.remove('OCRepresentationEncodingTest.cpp')
unittests_src.remove('OCRepresentationTest.cpp')
unittests_src.remove('OCResourceTest.cpp')
if (('SUB' in with_mq) or ('PUB' in with_mq) or ('BROKER' in with_mq)):
unittests_src = unittests_src + ['OCMQResourceTest.cpp']
unittests_src = unittests_src + ['OCMQResourceTest.cpp']
if unittests_env.get('WITH_CLOUD'):
unittests_src = unittests_src + ['OCAccountManagerTest.cpp']
unittests_src = unittests_src + ['OCAccountManagerTest.cpp']
unittests = unittests_env.Program('unittests', unittests_src)
......@@ -107,18 +110,16 @@ Alias("unittests", [unittests])
unittests_env.AppendTarget('unittests')
if unittests_env.get('TEST') == '1':
if target_os in ['windows']:
unittests_env.AppendENVPath('PATH', unittests_env.get('BUILD_DIR'))
if target_os in ['linux', 'windows']:
run_test(unittests_env,
'resource_unittests_unittests.memcheck',
'resource/unittests/unittests',
unittests)
if target_os in ['windows']:
unittests_env.AppendENVPath('PATH', unittests_env.get('BUILD_DIR'))
if target_os in ['linux', 'windows']:
run_test(unittests_env,
'resource_unittests_unittests.memcheck',
'resource/unittests/unittests',
unittests)
src_dir = unittests_env.get('SRC_DIR')
svr_db_src_dir = os.path.join(src_dir, 'resource/examples/')
svr_db_build_dir = os.path.join(unittests_env.get('BUILD_DIR'), 'resource', 'unittests') + os.sep
unittests_env.Alias("install",
unittests_env.Install(svr_db_build_dir,
os.path.join(svr_db_src_dir,
'oic_svr_db_client.dat')))
unittests_env.Install(svr_db_build_dir, os.path.join(svr_db_src_dir, 'oic_svr_db_client.dat')))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment