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')
29 rd_mode = srmtest_env.get('RD_MODE')
31 ######################################################################
33 ######################################################################
34 with_upstream_libcoap = srmtest_env.get('WITH_UPSTREAM_LIBCOAP')
35 if with_upstream_libcoap == '1':
36 # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
37 srmtest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
39 # For bring up purposes only, the forked version will live here.
40 srmtest_env.AppendUnique(CPPPATH = ['../../connectivity/lib/libcoap-4.1.1/include'])
42 srmtest_env.PrependUnique(CPPPATH = [
43 '../../../c_common/oic_malloc/include',
44 '../../connectivity/inc',
45 '../../connectivity/inc/pkix',
46 '../../connectivity/api',
47 '../../connectivity/external/inc',
48 '../include/internal',
49 '../../logger/include',
50 '../../stack/include',
51 '../../stack/include/internal',
52 '../../../oc_logger/include',
53 '../provisioning/include',
57 srmtest_env.AppendUnique(LIBPATH = [srmtest_env.get('BUILD_DIR')])
58 srmtest_env.PrependUnique(LIBS = ['ocsrm',
61 'connectivity_abstraction',
64 if srmtest_env.get('SECURED') == '1':
65 srmtest_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto'])
66 srmtest_env.AppendUnique(LIBS = ['tinydtls'])
68 if srmtest_env.get('LOGGING') == '1':
69 srmtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
71 if srmtest_env.get('MULTIPLE_OWNER') == '1':
72 srmtest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
74 if target_os == 'windows':
75 srmtest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
76 srmtest_env.AppendUnique(LIBS = ['advapi32', 'bcrypt', 'crypt32', 'kernel32', 'ws2_32', 'iphlpapi', 'octbstack_static'])
78 # TODO: Implement feature check.
79 srmtest_env.AppendUnique(CPPDEFINES = ['HAVE_LOCALTIME_R'])
80 srmtest_env.AppendUnique(LIBS = ['octbstack'])
82 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
83 srmtest_env.PrependUnique(LIBS = ['resource_directory'])
85 ######################################################################
86 # Source files and Targets
87 ######################################################################
88 unittest = srmtest_env.Program('unittest', ['aclresourcetest.cpp',
89 'amaclresourcetest.cpp',
93 'securityresourcemanager.cpp',
94 'credentialresource.cpp',
96 'iotvticalendartest.cpp',
98 'svcresourcetest.cpp',
100 'directpairingtest.cpp',
101 'crlresourcetest.cpp'])
103 Alias("test", [unittest])
105 unittest_src_dir = os.path.join(src_dir, 'resource', 'csdk', 'security', 'unittest') + os.sep
106 unittest_build_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'resource', 'csdk', 'security', 'unittest') + os.sep
108 srmtest_env.AppendUnique(CPPDEFINES = ['SECURITY_BUILD_UNITTEST_DIR='+unittest_build_dir.encode('string_escape')])
110 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
111 unittest_src_dir + 'oic_unittest.json'))
112 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
113 unittest_src_dir + 'oic_unittest_acl1.json'))
114 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
115 unittest_src_dir + 'oic_unittest_default_acl.json'))
116 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
117 unittest_src_dir + 'oic_svr_db.json'))
119 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
120 unittest_src_dir + 'oic_unittest.dat'))
121 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
122 unittest_src_dir + 'oic_unittest_acl1.dat'))
123 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
124 unittest_src_dir + 'oic_unittest_default_acl.dat'))
125 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
126 unittest_src_dir + 'oic_svr_db_prov.dat'))
127 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
128 unittest_src_dir + 'oic_svr_db.dat'))
130 srmtest_env.AppendTarget('test')
131 if srmtest_env.get('TEST') == '1':
132 if target_os in ['linux', 'windows']:
133 out_dir = srmtest_env.get('BUILD_DIR')
134 result_dir = os.path.join(srmtest_env.get('BUILD_DIR'), 'test_out') + os.sep
135 if not os.path.isdir(result_dir):
136 os.makedirs(result_dir)
137 srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
138 srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
139 from tools.scons.RunTest import *
140 run_test(srmtest_env,'ut','resource/csdk/security/unittest/unittest')