code_coverage.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #! /bin/bash
  2. #
  3. # Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
  4. #
  5. # This file is part of Embedded Proto.
  6. #
  7. # Embedded Proto is open source software: you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License as published
  9. # by the Free Software Foundation, version 3 of the license.
  10. #
  11. # Embedded Proto is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Embedded Proto. If not, see <https://www.gnu.org/licenses/>.
  18. #
  19. # For commercial and closed source application please visit:
  20. # <https://EmbeddedProto.com/license/>.
  21. #
  22. # Embedded AMS B.V.
  23. # Info:
  24. # info at EmbeddedProto dot com
  25. #
  26. # Postal address:
  27. # Johan Huizingalaan 763a
  28. # 1066 VH, Amsterdam
  29. # the Netherlands
  30. #
  31. ./build/test/test_EmbeddedProto --gtest_output="xml:build/test/test_details.xml"
  32. if [ $# -eq 0 ]; then
  33. # No arguments provided, execte the analyisis for sonar qube.
  34. rm -rf ./code_coverage_report/*
  35. mkdir -p code_coverage_report
  36. cd code_coverage_report
  37. # Run gcov on the static source files.
  38. gcov ../test/*.cpp --object-directory ../build/test/CMakeFiles/test_EmbeddedProto.dir/test/
  39. gcov ../src/*.cpp --object-directory ../build/test/CMakeFiles/test_EmbeddedProto.dir/src/
  40. cd -
  41. else
  42. # Pass commands
  43. case "$1" in
  44. -l|--local)
  45. # Run the code coverage for local machine analysis
  46. rm -rf ./code_coverage_report/*
  47. lcov --directory ./build/test --capture --output-file ./code_coverage_report/total_code_coverage.info -rc lcov_branch_coverage=1
  48. lcov --remove ./code_coverage_report/total_code_coverage.info $PWD'/external/googletest/*' '/usr/include/*' -o ./code_coverage_report/filtered_code_coverage.info
  49. genhtml ./code_coverage_report/filtered_code_coverage.info --branch-coverage --output-directory ./code_coverage_report
  50. ;;
  51. *)
  52. ;;
  53. esac
  54. fi