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 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 from tools.scons.RunTest import *
27 # SConscript file for Local PKI google tests
28 srmtest_env = test_env.Clone()
29 src_dir = srmtest_env.get('SRC_DIR')
30 target_os = srmtest_env.get('TARGET_OS')
31 rd_mode = srmtest_env.get('RD_MODE')
33 ######################################################################
35 ######################################################################
36 with_upstream_libcoap = srmtest_env.get('WITH_UPSTREAM_LIBCOAP')
37 if with_upstream_libcoap == '1':
38 # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
39 srmtest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
41 # For bring up purposes only, the forked version will live here.
42 srmtest_env.AppendUnique(CPPPATH = ['../../connectivity/lib/libcoap-4.1.1/include'])
44 srmtest_env.PrependUnique(CPPPATH = [
45 '../../../c_common/oic_malloc/include',
46 '../../connectivity/inc',
47 '../../connectivity/inc/pkix',
48 '../../connectivity/api',
49 '../../connectivity/external/inc',
50 '../include/internal',
51 '../../logger/include',
53 '../../stack/include',
54 '../../stack/include/internal',
55 '../../../oc_logger/include',
56 '../provisioning/include',
60 srmtest_env.AppendUnique(LIBPATH = [srmtest_env.get('BUILD_DIR')])
61 srmtest_env.PrependUnique(LIBS = ['ocsrm',
64 'connectivity_abstraction',
67 if srmtest_env.get('SECURED') == '1':
68 srmtest_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto'])
70 if srmtest_env.get('LOGGING') == '1':
71 srmtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
73 if srmtest_env.get('MULTIPLE_OWNER') == '1':
74 srmtest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
76 if target_os == 'windows':
77 srmtest_env.AppendUnique(LIBS = ['octbstack_static', 'sqlite3'])
79 # TODO: Implement feature check.
80 srmtest_env.AppendUnique(CPPDEFINES = ['HAVE_LOCALTIME_R'])
81 srmtest_env.AppendUnique(LIBS = ['octbstack'])
83 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
84 srmtest_env.PrependUnique(LIBS = ['resource_directory', 'oc'])
86 srmtest_env.AppendUnique(LIBS = ['timer'])
88 ######################################################################
89 # Source files and Targets
90 ######################################################################
91 unittest = srmtest_env.Program('unittest', ['aclresourcetest.cpp',
92 'amaclresourcetest.cpp',
96 'securityresourcemanager.cpp',
97 'credentialresource.cpp',
99 'iotvticalendartest.cpp',
103 'directpairingtest.cpp',
104 'crlresourcetest.cpp'])
106 Alias("test", [unittest])
108 unittest_src_dir = os.path.join(src_dir, 'resource', 'csdk', 'security', 'unittest') + os.sep
109 unittest_build_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'resource', 'csdk', 'security', 'unittest')
110 unittest_build_dir = os.path.normpath(unittest_build_dir) + os.sep
112 srmtest_env.AppendUnique(CPPDEFINES = ['SECURITY_BUILD_UNITTEST_DIR='+unittest_build_dir.encode('string_escape').replace("\\", "\\\\")])
114 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
115 unittest_src_dir + 'oic_unittest.json'))
116 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
117 unittest_src_dir + 'oic_unittest_acl1.json'))
118 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
119 unittest_src_dir + 'oic_unittest_default_acl.json'))
120 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
121 unittest_src_dir + 'oic_svr_db.json'))
123 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
124 unittest_src_dir + 'oic_unittest.dat'))
125 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
126 unittest_src_dir + 'oic_unittest_acl1.dat'))
127 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
128 unittest_src_dir + 'oic_unittest_default_acl.dat'))
129 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
130 unittest_src_dir + 'oic_svr_db_prov.dat'))
131 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
132 unittest_src_dir + 'oic_svr_db.dat'))
134 srmtest_env.AppendTarget('test')
135 if srmtest_env.get('TEST') == '1':
136 if target_os in ['linux', 'windows']:
137 out_dir = srmtest_env.get('BUILD_DIR')
138 result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
139 if not os.path.isdir(result_dir):
140 os.makedirs(result_dir)
141 srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
142 srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
143 run_test(srmtest_env,'ut','resource/csdk/security/unittest/unittest')