1 # //******************************************************************
3 # // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # // Licensed under the Apache License, Version 2.0 (the "License");
8 # // you may not use this file except in compliance with the License.
9 # // You may obtain a copy of the License at
11 # // http://www.apache.org/licenses/LICENSE-2.0
13 # // Unless required by applicable law or agreed to in writing, software
14 # // distributed under the License is distributed on an "AS IS" BASIS,
15 # // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # // See the License for the specific language governing permissions and
17 # // limitations under the License.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 srmtest_env = gtest_env.Clone()
27 src_dir = srmtest_env.get('SRC_DIR')
28 target_os = srmtest_env.get('TARGET_OS')
30 ######################################################################
32 ######################################################################
33 srmtest_env.PrependUnique(CPPPATH = [
34 '../../../c_common/oic_malloc/include',
35 '../../connectivity/inc',
36 '../../connectivity/api',
37 '../../connectivity/external/inc',
38 '../../connectivity/lib/libcoap-4.1.1',
39 '../include/internal',
40 '../../logger/include',
41 '../../stack/include',
42 '../../stack/include/internal',
43 '../../../oc_logger/include',
44 '../../../../extlibs/cjson/',
45 '../provisioning/include',
49 srmtest_env.AppendUnique(LIBPATH = [srmtest_env.get('BUILD_DIR')])
50 srmtest_env.PrependUnique(LIBS = ['ocsrm',
53 'connectivity_abstraction',
56 if srmtest_env.get('SECURED') == '1':
57 srmtest_env.AppendUnique(LIBS = ['tinydtls', 'timer'])
59 if srmtest_env.get('LOGGING') == '1':
60 srmtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
62 if target_os == 'windows':
63 srmtest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
64 srmtest_env.AppendUnique(LIBS = ['advapi32', 'kernel32', 'ws2_32', 'iphlpapi'])
66 # TODO: Implement feature check.
67 srmtest_env.AppendUnique(CPPDEFINES = ['HAVE_LOCALTIME_R'])
69 ######################################################################
70 # Source files and Targets
71 ######################################################################
72 unittest = srmtest_env.Program('unittest', ['aclresourcetest.cpp',
73 'amaclresourcetest.cpp',
77 'securityresourcemanager.cpp',
78 'credentialresource.cpp',
80 'iotvticalendartest.cpp',
82 'svcresourcetest.cpp',
84 'directpairingtest.cpp',
85 'crlresourcetest.cpp'])
87 Alias("test", [unittest])
89 unittest_src_dir = os.path.join(src_dir, 'resource', 'csdk', 'security', 'unittest') + os.sep
90 unittest_build_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'resource', 'csdk', 'security', 'unittest') + os.sep
92 srmtest_env.AppendUnique(CPPDEFINES = ['SECURITY_BUILD_UNITTEST_DIR='+unittest_build_dir.encode('string_escape')])
94 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
95 unittest_src_dir + 'oic_unittest.json'))
96 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
97 unittest_src_dir + 'oic_unittest_acl1.json'))
98 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
99 unittest_src_dir + 'oic_unittest_default_acl.json'))
100 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
101 unittest_src_dir + 'oic_svr_db.json'))
103 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
104 unittest_src_dir + 'oic_unittest.dat'))
105 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
106 unittest_src_dir + 'oic_unittest_acl1.dat'))
107 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
108 unittest_src_dir + 'oic_unittest_default_acl.dat'))
109 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
110 unittest_src_dir + 'oic_svr_db_prov.dat'))
111 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
112 unittest_src_dir + 'oic_svr_db.dat'))
114 srmtest_env.AppendTarget('test')
115 if srmtest_env.get('TEST') == '1':
116 if target_os in ['linux', 'windows']:
117 out_dir = srmtest_env.get('BUILD_DIR')
118 result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
119 if not os.path.isdir(result_dir):
120 os.makedirs(result_dir)
121 srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
122 srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
123 srmtest_env.AppendENVPath('PATH', [os.path.join(out_dir, 'resource', 'csdk')])
124 from tools.scons.RunTest import *
125 run_test(srmtest_env,'ut','resource/csdk/security/unittest/unittest')