common-testhelper.parts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. ############################################################################
  16. Import('*')
  17. env.PartName('common-testhelper')
  18. src_files = Pattern(
  19. src_dir='.', includes=['*-testhelper.cc'], excludes=[],
  20. recursive=False).files()
  21. inc_files = Pattern(
  22. src_dir='.', includes=['*-testhelper.h'], excludes=[],
  23. recursive=False).files()
  24. epid11_src_files = Pattern(
  25. src_dir='1.1', includes=['*-testhelper.cc'], excludes=[],
  26. recursive=False).files()
  27. epid11_inc_files = Pattern(
  28. src_dir='1.1', includes=['*-testhelper.h'], excludes=[],
  29. recursive=False).files()
  30. test_data_files = Pattern(
  31. src_dir='testdata', includes=['*'], excludes=[], recursive=True)
  32. epid11_test_data_files = Pattern(
  33. src_dir='1.1/testdata', includes=['*'], excludes=[], recursive=True)
  34. # unit tests
  35. utest_files = Pattern(
  36. src_dir='.', includes=['*-test.cc'], excludes=[], recursive=True).files()
  37. if 'use_tss' in env['MODE']:
  38. env.Append(CPPDEFINES=['TPM_TSS'])
  39. if 'install_package' in env['MODE']:
  40. env.InstallTopLevel(src_files, sub_dir='epid/${PART_SHORT_NAME}')
  41. env.InstallTopLevel(inc_files, sub_dir='epid/${PART_SHORT_NAME}')
  42. env.InstallTopLevel(
  43. utest_files, sub_dir='epid/${PART_SHORT_NAME}/unittests')
  44. env.InstallTopLevel(
  45. test_data_files, sub_dir='epid/${PART_SHORT_NAME}/testdata')
  46. env.InstallTopLevel(
  47. epid11_src_files, sub_dir='epid/${PART_SHORT_NAME}/1.1')
  48. env.InstallTopLevel(
  49. epid11_inc_files, sub_dir='epid/${PART_SHORT_NAME}/1.1')
  50. env.InstallTopLevel(
  51. epid11_test_data_files, sub_dir='epid/${PART_SHORT_NAME}/1.1/testdata')
  52. parts_file = ['common-testhelper.parts']
  53. env.InstallTopLevel(parts_file, sub_dir='epid/${PART_SHORT_NAME}')
  54. makefile = ['Makefile']
  55. env.InstallTopLevel(makefile, sub_dir='epid/${PART_SHORT_NAME}')
  56. else:
  57. env.DependsOn([
  58. Component('common'),
  59. ])
  60. env.Append(CPPPATH='#')
  61. testenv = env.Clone()
  62. outputs = env.Library('${PART_NAME}', src_files + epid11_src_files)
  63. env.Sdk(outputs)
  64. testenv['UNIT_TEST_TARGET_NAME'] = "${PART_NAME}-${UNIT_TEST_TARGET}"
  65. testenv.UnitTest(
  66. "utest",
  67. utest_files,
  68. command_args=[
  69. '--gtest_color=yes',
  70. '--gtest_print_time=1',
  71. '--gtest_output=xml',
  72. '--gtest_filter=**',
  73. ],
  74. make_pdb=(env.isConfigBasedOn('debug')),
  75. depends=[Component('gtest'), Component('common-testhelper')],
  76. INSTALL_BIN='${INSTALL_TEST_BIN}')