Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / security / unittest / SConscript
1 # //******************************************************************
2 # //
3 # // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 # //
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 # //
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
10 # //
11 # //      http://www.apache.org/licenses/LICENSE-2.0
12 # //
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.
18 # //
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #
21
22 Import('env')
23 import os
24 import os.path
25 srmtest_env = env.Clone()
26
27 src_dir = srmtest_env.get('SRC_DIR')
28
29 ######################################################################
30 # Build flags
31 ######################################################################
32 srmtest_env.PrependUnique(CPPPATH = [
33         '../../ocmalloc/include',
34                 '../../connectivity/inc',
35                 '../../connectivity/api',
36                 '../../connectivity/external/inc',
37                 '../../connectivity/lib/libcoap-4.1.1',
38                 '../include',
39                 '../include/internal',
40                 '../../logger/include',
41                 '../../ocmalloc/include',
42                 '../../stack/include',
43                 '../../stack/include/internal',
44                 '../../../oc_logger/include',
45                 '../../../../extlibs/gtest/gtest-1.7.0/include',
46                 '../../../../extlibs/cjson/',
47 #               '../../../../extlibs/tinydtls/',
48                 '../include'
49                 ])
50 srmtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
51 srmtest_env.AppendUnique(LIBS = ['-lpthread'])
52 srmtest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
53 srmtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
54 srmtest_env.PrependUnique(LIBS = ['ocsrm',
55                                     'octbstack',
56                                     'oc_logger',
57                                     'connectivity_abstraction',
58                                     'coap',
59                                     'gtest',
60                                     'gtest_main'])
61
62 if env.get('SECURED') == '1':
63     srmtest_env.AppendUnique(LIBS = ['tinydtls'])
64
65 if not env.get('RELEASE'):
66         srmtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
67
68 ######################################################################
69 # Source files and Targets
70 ######################################################################
71 unittest = srmtest_env.Program('unittest', ['aclresourcetest.cpp',
72                                             'pstatresource.cpp',
73                                             'doxmresource.cpp',
74                                             'policyengine.cpp',
75                                             'securityresourcemanager.cpp',
76                                             'credentialresource.cpp',
77                                             'srmutility.cpp',
78                                             'base64tests.cpp'])
79
80 Alias("test", [unittest])
81
82 unittest_src_dir = src_dir + '/resource/csdk/security/unittest/'
83 unittest_build_dir = env.get('BUILD_DIR') +'/resource/csdk/security/unittest'
84
85 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
86     unittest_src_dir + 'oic_unittest.json'))
87 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
88     unittest_src_dir + 'oic_unittest_acl1.json'))
89 srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
90     unittest_src_dir + 'oic_unittest_default_acl.json'))
91
92 env.AppendTarget('test')
93 if env.get('TEST') == '1':
94         target_os = env.get('TARGET_OS')
95         if target_os == 'linux':
96                 out_dir = env.get('BUILD_DIR')
97                 result_dir = env.get('BUILD_DIR') + '/test_out/'
98                 if not os.path.isdir(result_dir):
99                         os.makedirs(result_dir)
100                 srmtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
101                 srmtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
102                 srmtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
103                 ut = srmtest_env.Command ('ut', None, out_dir + '/resource/csdk/security/unittest/unittest')
104                 AlwaysBuild ('ut')
105