common-testhelper.parts 3.7 KB

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