#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-Import('env')
import os
import os.path
-stacktest_env = env.Clone()
+from tools.scons.RunTest import *
-src_dir = stacktest_env.get('SRC_DIR')
+Import('test_env')
+
+# SConscript file for Local PKI google tests
+stacktest_env = test_env.Clone()
+target_os = stacktest_env.get('TARGET_OS')
+rd_mode = stacktest_env.get('RD_MODE')
######################################################################
# Build flags
######################################################################
stacktest_env.PrependUnique(CPPPATH = [
- '../../ocsocket/include',
- '../../logger/include',
- '../../stack/include',
- '../../ocmalloc/include',
- '../../extlibs/cjson',
- '../../../oc_logger/include',
- '../../../../extlibs/gtest/gtest-1.7.0/include'
- ])
+ '../../security/include',
+ '../../ocsocket/include',
+ '../../logger/include',
+ '../../../c_common/ocrandom/include',
+ '../../include',
+ '../../stack/include',
+ '../../stack/include/internal',
+ '../../connectivity/api',
+ '../../connectivity/inc/pkix',
+ '../../connectivity/external/inc',
+ '../../../oc_logger/include',
+ ])
-stacktest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
-stacktest_env.AppendUnique(LIBS = ['-lpthread'])
-stacktest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-stacktest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
-stacktest_env.PrependUnique(LIBS = ['m',
- 'octbstack',
- 'oc_logger',
+stacktest_env.AppendUnique(LIBPATH = [stacktest_env.get('BUILD_DIR')])
+stacktest_env.PrependUnique(LIBS = ['octbstack_test',
+ 'ocsrm',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'])
+ 'coap'])
+if target_os != 'darwin':
+ stacktest_env.PrependUnique(LIBS = ['oc_logger'])
+
+if stacktest_env.get('SECURED') == '1':
+ stacktest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
+
+if stacktest_env.get('LOGGING'):
+ stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-if env.get('SECURED') == '1':
- stacktest_env.AppendUnique(LIBS = ['tinydtls'])
-stacktest_env.ParseConfig('pkg-config --libs glib-2.0');
+if target_os in ['msys_nt', 'windows']:
+ stacktest_env.PrependUnique(LIBS = ['sqlite3'])
+ stacktest_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
+else:
+ stacktest_env.PrependUnique(LIBS = ['m'])
-if env.get('LOGGING'):
- stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
+ stacktest_env.PrependUnique(LIBS = ['resource_directory'])
+stacktest_env.AppendUnique(LIBS = ['timer'])
######################################################################
# Source files and Targets
######################################################################
stacktests = stacktest_env.Program('stacktests', ['stacktests.cpp'])
+cbortests = stacktest_env.Program('cbortests', ['cbortests.cpp'])
-Alias("test", [stacktests])
+Alias("test", [stacktests, cbortests])
-env.AppendTarget('test')
-if env.get('TEST') == '1':
- target_os = env.get('TARGET_OS')
- if target_os == 'linux':
- out_dir = env.get('BUILD_DIR')
- result_dir = env.get('BUILD_DIR') + '/test_out/'
- if not os.path.isdir(result_dir):
- os.makedirs(result_dir)
- stacktest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
- stacktest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
- stacktest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
- ut = stacktest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_stack_test.memcheck ' + out_dir + 'resource/csdk/stack/test/stacktests')
- AlwaysBuild ('ut')
+stacktest_env.AppendTarget('test')
+if stacktest_env.get('TEST') == '1':
+ if target_os in ['linux', 'windows']:
+ run_test(stacktest_env,
+ 'resource_csdk_stack_test.memcheck',
+ 'resource/csdk/stack/test/stacktests')
+ run_test(stacktest_env,
+ 'resource_csdk_stack_test.memcheck',
+ 'resource/csdk/stack/test/cbortests')