fast.sh 947 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. PWD=$(cd `dirname $0`/.. && pwd)
  3. pushd $PWD
  4. echo "Run UTest in $(pwd)"
  5. IS_LINUX=yes
  6. uname -s|grep Darwin >/dev/null && IS_DARWIN=yes && IS_LINUX=no
  7. echo "IS_LINUX: $IS_LINUX, IS_DARWIN: $IS_DARWIN"
  8. echo "Clean gcda files"
  9. rm -f ./obj/*.gcda
  10. echo "Build and run utest"
  11. if [[ $IS_DARWIN == yes ]]; then
  12. make darwin-debug-gcov && ./obj/st_utest
  13. else
  14. make linux-debug-gcov && ./obj/st_utest
  15. fi
  16. ret=$?; if [[ 0 -ne $ret ]]; then echo "Make ST utest fail, ret=$ret"; exit $ret; fi
  17. echo "Generating coverage"
  18. mkdir -p coverage &&
  19. (cd obj && rm -f gtest-all.gcda gtest-all.gcno) &&
  20. (cd obj && rm -f *.c *.cpp gtest-fit && ln -sf ../*.c . && ln -sf ../utest/*.cpp && ln -sf ../utest/gtest-fit .) &&
  21. (cd obj && gcovr --gcov-exclude gtest --html --html-details -o ../coverage/st.html) &&
  22. (cd obj && rm -f *.c *.cpp gtest-fit) &&
  23. echo "Coverage report at coverage/st.html" &&
  24. open coverage/st.html
  25. popd
  26. echo "UTest done, restore $(pwd)"