Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / ck_manager / unittest / SConscript
1 # //******************************************************************
2 # //
3 # // Copyright 2015 Samsung Electronics 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 # SConscript file for Local PKI google tests
22
23 Import('env')
24
25 import os
26 import os.path
27 pki_test_env = env.Clone()
28
29 src_dir = pki_test_env.get('SRC_DIR')
30
31 ######################################################################
32 # Build flags
33 ######################################################################
34 pki_test_env.PrependUnique(CPPPATH = ['../include/',
35                                 '../include/internal',
36                                 '../../include',
37                                 '../../include/internal',
38                                 '../../../include',
39                                 '../../../include/internal',
40                                 '../../../../connectivity/inc',
41                                 '../../../../connectivity/api',
42                                 '../../../../logger/include',
43                                 '../../../../stack/include',
44                                 '../../../../../oc_logger/include',
45                                 '../../../../../../extlibs/gtest/gtest-1.7.0/include',
46                                 '../../../../../../extlibs/asn1cert',
47                                 '../../../../../../extlibs/tinydtls',
48                                 '../../../../../../extlibs/tinydtls/ecc',
49                                 '../../../../../../extlibs/tinydtls/sha2'
50                 ])
51 pki_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
52 pki_test_env.AppendUnique(LIBS = ['pthread'])
53 pki_test_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
54 pki_test_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
55
56 pki_test_env.AppendUnique(LIBS = ['octbstack'])
57 pki_test_env.AppendUnique(LIBS = ['CKManager'])
58 pki_test_env.AppendUnique(LIBS = ['asn1'])
59 pki_test_env.AppendUnique(LIBS = ['gtest'])
60 pki_test_env.AppendUnique(LIBS = ['gtest_main'])
61
62 if env.get('SECURED') == '1':
63     pki_test_env.AppendUnique(LIBS = ['tinydtls'])
64
65 if not env.get('RELEASE'):
66         pki_test_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
67
68 ######################################################################
69 # Source files and Targets
70 ######################################################################
71 unittest = pki_test_env.Program('unittest', ['pki_test.cpp'])
72
73 Alias("test", [unittest])
74
75
76
77 unittest_src_dir = src_dir + '/resource/csdk/security/provisioning/ck_manager/unittest/test_data/'
78 unittest_build_dir = env.get('BUILD_DIR') +'/resource/csdk/security/provisioning/ck_manager/unittest'
79
80 pki_test_env.Alias("install",env.Install( unittest_build_dir, [ unittest_src_dir + '01.der',
81                                                                 unittest_src_dir + 'cacert.der',
82                                                                 unittest_src_dir + 'capub.der',
83                                                                 unittest_src_dir + 'cert_chain.dat',
84                                                                 unittest_src_dir + 'chain.der',
85                                                                 unittest_src_dir + 'CKMInfo.dat' ]))
86
87 env.AppendTarget('test')
88 if env.get('TEST') == '1':
89         target_os = env.get('TARGET_OS')
90         if target_os == 'linux':
91                 out_dir = env.get('BUILD_DIR')
92                 result_dir = env.get('BUILD_DIR') + '/test_out/'
93                 if not os.path.isdir(result_dir):
94                         os.makedirs(result_dir)
95                 pki_test_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
96                 pki_test_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
97                 pki_test_env.AppendENVPath('LD_LIBRARY_PATH', [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
98                 ut = pki_test_env.Command ('ut', None, out_dir + '/resource/csdk/security/unittest/unittest')
99 AlwaysBuild ('ut')
100