Imported Upstream version 1.1.1
[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 import os
22 import os.path
23
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 pki_test_env = gtest_env.Clone()
27 src_dir = pki_test_env.get('SRC_DIR')
28 build_dir = pki_test_env.get('BUILD_DIR')
29 target_os = pki_test_env.get('TARGET_OS')
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/asn1cert',
46                                 '../../../../../../extlibs/tinydtls',
47                                 '../../../../../../extlibs/tinydtls/ecc',
48                                 '../../../../../../extlibs/tinydtls/sha2'
49                 ])
50 if target_os not in ['windows']:
51     pki_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
52     pki_test_env.AppendUnique(LIBS = ['pthread'])
53 pki_test_env.AppendUnique(LIBPATH = [pki_test_env.get('BUILD_DIR')])
54
55 pki_test_env.AppendUnique(LIBS = ['octbstack'])
56 pki_test_env.AppendUnique(LIBS = ['CKManager'])
57 pki_test_env.AppendUnique(LIBS = ['asn1'])
58 pki_test_env.AppendUnique(LIBS = ['gtest'])
59 pki_test_env.AppendUnique(LIBS = ['gtest_main'])
60
61 if pki_test_env.get('SECURED') == '1':
62     pki_test_env.AppendUnique(LIBS = ['tinydtls'])
63
64 if not pki_test_env.get('RELEASE'):
65         pki_test_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
66
67 ######################################################################
68 # Source files and Targets
69 ######################################################################
70 unittest = pki_test_env.Program('unittest', ['pki_test.cpp',
71                                             'ckm_info_test.cpp',
72                                             'crl_generator_test.cpp',
73                                             'csr_generator_test.cpp'])
74
75 Alias("test", [unittest])
76
77
78
79 unittest_src_dir = src_dir + '/resource/csdk/security/provisioning/ck_manager/unittest/test_data/'
80
81 unittest_build_dir = os.path.join(build_dir, 'resource', 'csdk', 'security', 'provisioning', 'ck_manager', 'unittest')
82 unittest_build_dir = unittest_build_dir.encode('string_escape')
83 pki_test_env.AppendUnique(CPPDEFINES = ['SECURITY_BUILD_UNITTEST_DIR='+unittest_build_dir])
84 pki_test_env.Alias("install", pki_test_env.Install( unittest_build_dir, [ unittest_src_dir + '01.der',
85                                                                 unittest_src_dir + 'cacert.der',
86                                                                 unittest_src_dir + 'capub.der',
87                                                                 unittest_src_dir + 'cert_chain.dat',
88                                                                 unittest_src_dir + 'chain.der',
89                                                                 unittest_src_dir + 'CKMInfo.dat' ]))
90
91 pki_test_env.AppendTarget('test')
92 if pki_test_env.get('TEST') == '1':
93         if target_os in ['linux']:
94                 out_dir = pki_test_env.get('BUILD_DIR')
95                 result_dir = os.path.join(pki_test_env.get('BUILD_DIR'), 'test_out') + os.sep
96                 if not os.path.isdir(result_dir):
97                         os.makedirs(result_dir)
98                 pki_test_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
99                 pki_test_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
100                 ut = pki_test_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/ck_manager/unittest/unittest')
101 AlwaysBuild ('ut')
102