run.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. # Automatic exit on any error
  3. set -e
  4. if [ "$1" == "--help" ] || [ "$1" == "-h" ] ; then
  5. echo Options:
  6. echo
  7. echo ' -t, --test Testng mode: run but do not submit'
  8. echo ' -h, --help Display this help'
  9. exit 0
  10. fi
  11. if [ "$1" == "-t" ] || [ "$1" == "--test" ]; then
  12. TESTING=1
  13. echo Testing mode
  14. else
  15. if [ "$COV_TOKEN" == "" ] ; then
  16. echo "Error: COV_TOKEN env var is not set"
  17. exit 1
  18. fi
  19. fi
  20. if [ `whoami` == "root" ] ; then
  21. SUDO=
  22. else
  23. SUDO=sudo
  24. fi
  25. if ! [ -f tests/coverity-scan/packages.txt ] ; then
  26. echo You need to run this from pjproject root directory
  27. exit 1
  28. fi
  29. mkdir -p tmp
  30. # Get PJ version and branch name
  31. cat << EOF > getversion.mak
  32. include version.mak
  33. all:
  34. @echo \$(PJ_VERSION)
  35. EOF
  36. export MQUIET='--quiet'
  37. export PJ_VERSION=`make -f getversion.mak`
  38. export GIT_BRANCH=`git branch --show-current`
  39. echo PJSIP version $PJ_VERSION on $GIT_BRANCH
  40. echo
  41. echo ===============================
  42. echo Installing packages
  43. echo ===============================
  44. $SUDO apt update -y
  45. cat tests/coverity-scan/packages.txt | xargs $SUDO apt-get -y -qq install
  46. echo
  47. echo ===============================
  48. echo Download Coverity
  49. echo ===============================
  50. pushd tmp
  51. if ! [ -d cov-analysis-linux64 ] ; then
  52. if ! [ -f cov-analysis-linux64.tar.gz ] ; then
  53. wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=${COV_TOKEN}&project=PJSIP" -O cov-analysis-linux64.tar.gz
  54. fi
  55. mkdir cov-analysis-linux64
  56. tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
  57. fi
  58. cd cov-analysis-linux64/bin
  59. export PATH=$PATH:`pwd`
  60. popd
  61. echo
  62. echo ===============================
  63. echo Building SILK
  64. echo ===============================
  65. pushd tmp
  66. if ! [ -f silk-src-1.0.9.zip ] ; then
  67. wget -q https://github.com/pjsip/third_party_libs/raw/main/silk-src-1.0.9.zip
  68. fi
  69. unzip -o -qq silk-src-1.0.9.zip
  70. cd silk-1.0.9/sources/SILK_SDK_SRC_FLP_v1.0.9
  71. make $MQUIET
  72. export SILK_DIR=`pwd`
  73. popd
  74. echo
  75. echo ===============================
  76. echo Configure
  77. echo ===============================
  78. ./configure --with-silk=$SILK_DIR | tee configure.out
  79. echo configure output is in configure.out
  80. echo
  81. echo Configuring config_site.h
  82. pushd pjlib/include/pj
  83. cp -f config_site_test.h config_site.h
  84. cat << EOF >> config_site.h
  85. /* Enable additional features (by tests/coverity-scan/run.sh) */
  86. #define PJ_HAS_IPV6 1
  87. #define PJ_HAS_SSL_SOCK 1
  88. #define PJ_TIMER_DEBUG 0
  89. #define PJ_TODO(x)
  90. #define PJMEDIA_HAS_VIDEO 1
  91. #define PJMEDIA_RTCP_STAT_HAS_IPDV 1
  92. #define PJMEDIA_HAS_RTCP_XR 1
  93. #define PJMEDIA_STREAM_ENABLE_XR 1
  94. #define PJMEDIA_SRTP_HAS_DTLS 1
  95. #define PJMEDIA_SRTP_HAS_AES_CM_192 1
  96. #define PJMEDIA_SRTP_HAS_AES_GCM_256 1
  97. #define PJMEDIA_SRTP_HAS_AES_GCM_128 1
  98. #define PJMEDIA_STREAM_ENABLE_KA 2
  99. #define PJSIP_CHECK_VIA_SENT_BY 1
  100. EOF
  101. popd
  102. echo
  103. echo config_site.h:
  104. echo ----------------------------------------
  105. cat pjlib/include/pj/config_site.h
  106. echo
  107. echo
  108. echo ===============================
  109. echo Build PJPROJECT
  110. echo ===============================
  111. echo make dep clean..
  112. make $MQUIET dep clean
  113. rm -rf cov-int
  114. cov-build --dir cov-int make $MQUIET
  115. echo
  116. echo ===============================
  117. echo Submit scan
  118. echo ===============================
  119. rm -f tmp/cov-int.bz2
  120. tar caf tmp/cov-int.bz2 cov-int
  121. if [ "$TESTING" == "1" ] ; then
  122. echo Testing mode, showing curl command:
  123. CURL="echo curl"
  124. SAFE_COV_TOKEN=`echo $COV_TOKEN | sed 's/[a-zA-Z]/*/g'`
  125. else
  126. CURL="curl"
  127. SAFE_COV_TOKEN=$COV_TOKEN
  128. fi
  129. $CURL --form token=${SAFE_COV_TOKEN} --form email=bennylp@pjsip.org --form file=@tmp/cov-int.bz2 \
  130. --form version=\"$PJ_VERSION@$GIT_BRANCH\" --form description=- \
  131. https://scan.coverity.com/builds?project=PJSIP
  132. exit 0
  133. echo swig bindings
  134. cd pjsip-apps/src/swig && make $MQUIET