unit_test.sh 843 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. cd `dirname $0`
  3. echo '-------build unit test----------'
  4. echo 'start a test http server'
  5. NODE=`which nodejs`
  6. if [ "$NODE" ]
  7. then
  8. echo ''
  9. else
  10. NODE=`which node`
  11. fi
  12. echo 'node binary path: ' $NODE
  13. server=`ps -ef | grep http_test_server | grep -v grep`
  14. echo "check server: " $server
  15. if [ "$server" ]
  16. then
  17. echo "server is on"
  18. else
  19. echo "server is off, start it"
  20. cd test/httpserver
  21. npm i
  22. nohup $NODE http_test_server.js &
  23. cd -
  24. fi
  25. MAKE=make
  26. if command -v python > /dev/null ; then
  27. MAKE="make -j $(python -c 'import multiprocessing as mp; print(int(mp.cpu_count()))')"
  28. fi
  29. echo $MAKE
  30. UT_BUILD_DIR=ut_build
  31. rm -rf $UT_BUILD_DIR
  32. mkdir $UT_BUILD_DIR
  33. cd $UT_BUILD_DIR
  34. cmake -DBUILD_FUNCTION_TESTS=OFF -DBUILD_UNIT_TESTS=ON -DENABLE_COVERAGE=ON ..
  35. $MAKE core_ut
  36. echo '------- run unit test -----------'
  37. ctest --verbose