• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1############################################################################
2# Copyright 2016-2017 Intel Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15############################################################################
16Import('*')
17env.PartName('common-testhelper')
18
19src_files = Pattern(
20    src_dir='.', includes=['*-testhelper.cc'], excludes=[],
21    recursive=False).files()
22inc_files = Pattern(
23    src_dir='.', includes=['*-testhelper.h'], excludes=[],
24    recursive=False).files()
25epid11_src_files = Pattern(
26    src_dir='1.1', includes=['*-testhelper.cc'], excludes=[],
27    recursive=False).files()
28epid11_inc_files = Pattern(
29    src_dir='1.1', includes=['*-testhelper.h'], excludes=[],
30    recursive=False).files()
31test_data_files = Pattern(
32    src_dir='testdata', includes=['*'], excludes=[], recursive=True)
33epid11_test_data_files = Pattern(
34    src_dir='1.1/testdata', includes=['*'], excludes=[], recursive=True)
35
36# unit tests
37utest_files = Pattern(
38    src_dir='.', includes=['*-test.cc'], excludes=[], recursive=True).files()
39
40if 'use_tss' in env['MODE']:
41    env.Append(CPPDEFINES=['TPM_TSS'])
42
43if 'install_package' in env['MODE']:
44    env.InstallTopLevel(src_files, sub_dir='epid/${PART_SHORT_NAME}')
45    env.InstallTopLevel(inc_files, sub_dir='epid/${PART_SHORT_NAME}')
46    env.InstallTopLevel(
47        utest_files, sub_dir='epid/${PART_SHORT_NAME}/unittests')
48    env.InstallTopLevel(
49        test_data_files, sub_dir='epid/${PART_SHORT_NAME}/testdata')
50
51    env.InstallTopLevel(
52        epid11_src_files, sub_dir='epid/${PART_SHORT_NAME}/1.1')
53    env.InstallTopLevel(
54        epid11_inc_files, sub_dir='epid/${PART_SHORT_NAME}/1.1')
55    env.InstallTopLevel(
56        epid11_test_data_files, sub_dir='epid/${PART_SHORT_NAME}/1.1/testdata')
57
58    parts_file = ['common-testhelper.parts']
59    env.InstallTopLevel(parts_file, sub_dir='epid/${PART_SHORT_NAME}')
60    makefile = ['Makefile']
61    env.InstallTopLevel(makefile, sub_dir='epid/${PART_SHORT_NAME}')
62else:
63    env.DependsOn([
64        Component('common'),
65    ])
66
67    env.Append(CPPPATH='#')
68
69    testenv = env.Clone()
70
71    outputs = env.Library('${PART_NAME}', src_files + epid11_src_files)
72    env.Sdk(outputs)
73
74    testenv['UNIT_TEST_TARGET_NAME'] = "${PART_NAME}-${UNIT_TEST_TARGET}"
75    testenv.UnitTest(
76        "utest",
77        utest_files,
78        command_args=[
79            '--gtest_color=yes',
80            '--gtest_print_time=1',
81            '--gtest_output=xml',
82            '--gtest_filter=**',
83        ],
84        make_pdb=(env.isConfigBasedOn('debug')),
85        depends=[Component('gtest'), Component('common-testhelper')],
86        INSTALL_BIN='${INSTALL_TEST_BIN}')
87