tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

run_scan_build.sh (1362B)


      1 #!/usr/bin/env bash
      2 
      3 source $(dirname "$0")/tools.sh
      4 
      5 cp -a "${VCS_PATH}/nss" "${VCS_PATH}/nspr" .
      6 cd nspr
      7 if [[ -f ../nss/nspr.patch && "$ALLOW_NSPR_PATCH" == "1" ]]; then
      8  cat ../nss/nspr.patch | patch -p1
      9 fi
     10 cd ..
     11 
     12 # Build.
     13 cd nss
     14 make nss_build_all
     15 
     16 # What we want to scan.
     17 # key: directory to scan
     18 # value: number of errors expected in that directory
     19 declare -A scan=( \
     20        [lib/base]=0 \
     21        [lib/certdb]=0 \
     22        [lib/certhigh]=0 \
     23        [lib/ckfw]=0 \
     24        [lib/crmf]=0 \
     25        [lib/cryptohi]=0 \
     26        [lib/dev]=0 \
     27        [lib/freebl]=0 \
     28        [lib/nss]=0 \
     29        [lib/ssl]=0 \
     30        [lib/util]=0 \
     31    )
     32 
     33 # remove .OBJ directories to force a rebuild of just the select few
     34 for i in "${!scan[@]}"; do
     35   find "$i" -name "*.OBJ" -exec rm -rf {} \+
     36 done
     37 
     38 # run scan-build (only building affected directories)
     39 scan-build -o /builds/worker/artifacts --use-cc=$CC --use-c++=$CCC make nss_build_all
     40 STATUS=$?
     41 cd ..
     42 
     43 # print errors we found
     44 set +v +x
     45 for i in "${!scan[@]}"; do
     46   n=$(grep -Rn "$i" /builds/worker/artifacts/*/report-*.html | wc -l)
     47   if [ $n -ne ${scan[$i]} ]; then
     48     STATUS=1
     49     echo "$(date '+%T') WARNING - TEST-UNEXPECTED-FAIL: $i contains $n scan-build errors"
     50   elif [ $n -ne 0 ]; then
     51     echo "$(date '+%T') WARNING - TEST-EXPECTED-FAIL: $i contains $n scan-build errors"
     52   fi
     53 done
     54 exit $STATUS