coverage.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. if [[ ! -f utest/gtest-fit/googletest/include/gtest/gtest.h ]]; then
  3. echo "No utest/gtest, please download from https://github.com/google/googletest/releases/tag/release-1.11.0"
  4. exit -1
  5. else
  6. echo "Check utest/gtest ok"
  7. fi
  8. if [[ $(gcovr --version >/dev/null && echo yes) != yes ]]; then
  9. echo "Please install gcovr"
  10. exit -1
  11. fi
  12. IS_LINUX=yes
  13. uname -s|grep Darwin >/dev/null && IS_DARWIN=yes && IS_LINUX=no
  14. echo "IS_LINUX: $IS_LINUX, IS_DARWIN: $IS_DARWIN"
  15. echo "Build and run utest"
  16. if [[ $IS_DARWIN == yes ]]; then
  17. make clean && make darwin-debug-gcov && ./obj/st_utest
  18. else
  19. make clean && make linux-debug-gcov && ./obj/st_utest
  20. fi
  21. echo "Generating coverage"
  22. mkdir -p coverage &&
  23. (cd obj && rm -f gtest-all.gcda gtest-all.gcno) &&
  24. (cd obj && rm -f *.c *.cpp gtest-fit && ln -sf ../*.c . && ln -sf ../utest/*.cpp && ln -sf ../utest/gtest-fit .) &&
  25. (cd obj && gcovr --gcov-exclude gtest --html --html-details -o ../coverage/st.html) &&
  26. (cd obj && rm -f *.c *.cpp gtest-fit) &&
  27. echo "Coverage report at coverage/st.html" &&
  28. open coverage/st.html