utest.parts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # pylint:disable=I0011,W0401,W0614,C0103,E0602
  2. ############################################################################
  3. # Copyright 2017 Intel Corporation
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. ############################################################################
  17. """Build configuration for unit test of minimal library.
  18. """
  19. Import('*')
  20. env.PartName('utest')
  21. env.DependsOn([Component(env.subst('${PART_PARENT_NAME}'),
  22. requires=REQ.EXISTS|REQ.DEFAULT),
  23. Component('gtest'),
  24. Component('common-testhelper'),
  25. Component('verifier')])
  26. utest_files = Pattern(src_dir='.',
  27. includes=['*-test.cc',
  28. '*-testhelper.cc'],
  29. recursive=True).files()
  30. env.Append(CPPPATH='#')
  31. env['UNIT_TEST_TARGET_NAME'] = "${PART_PARENT_NAME}-${UNIT_TEST_TARGET}"
  32. shlib = []
  33. if 'shared' in env['MODE']:
  34. if env['TARGET_OS'] == 'win32':
  35. dependent_shlib = env.subst("${{DEPENDS.{0}.SDKBIN}}"
  36. .format(env.subst("${PART_PARENT_NAME}")))
  37. shlib = env.CCopy("${INSTALL_TEST_BIN}", dependent_shlib)
  38. else:
  39. dependent_shlib = env.subst("${{DEPENDS.{0}.SDKLIB}}"
  40. .format(env.subst("${PART_PARENT_NAME}")))
  41. shlib = env.CCopy("${INSTALL_LIB}", dependent_shlib)
  42. utest = env.UnitTest('${PART_SHORT_NAME}',
  43. utest_files,
  44. command_args=[
  45. '--gtest_filter=**',
  46. '--gtest_color=yes',
  47. '--gtest_print_time=1',
  48. '--gtest_output=xml',
  49. #'--gtest_break_on_failure',
  50. #'--gtest_catch_exceptions=0',
  51. ],
  52. data_src=[],
  53. make_pdb=(env.isConfigBasedOn('debug')),
  54. INSTALL_BIN='${INSTALL_TEST_BIN}'
  55. )
  56. Depends(utest, shlib)