Skip to content

Commit

Permalink
Bug 1308832 - improve scan-build script, r=franziskus
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 0ce28f70ac29a355486b489da2ac5a02ccc2726e
  • Loading branch information
martinthomson committed Oct 7, 2016
1 parent e692d7c commit 243c3ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
2 changes: 0 additions & 2 deletions automation/taskcluster/scripts/build.sh
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

set -v -e -x

source $(dirname $0)/tools.sh

if [[ $(id -u) -eq 0 ]]; then
Expand Down
47 changes: 24 additions & 23 deletions automation/taskcluster/scripts/run_scan_build.sh
@@ -1,9 +1,8 @@
#!/usr/bin/env bash

set -v -e -x
source $(dirname $0)/tools.sh

if [ $(id -u) = 0 ]; then
source $(dirname $0)/tools.sh

# Set compiler.
switch_compilers
Expand All @@ -14,38 +13,40 @@ fi

# Clone NSPR if needed.
if [ ! -d "nspr" ]; then
hg clone https://hg.mozilla.org/projects/nspr
hg_clone https://hg.mozilla.org/projects/nspr nspr default
fi

# Build.
cd nss && make nss_build_all

# we run scan-build on these folders
declare -a scan=("lib/ssl" "lib/freebl" "lib/util")
# corresponds to the number of errors that are expected in the |scan| folder
declare -a ignore=(0 0 0)

for i in "${scan[@]}"
do
echo "cleaning $i ..."
find "$i" -name "*.OBJ" | xargs rm -fr
cd nss
make nss_build_all

# What we want to scan.
# key: directory to scan
# value: number of errors expected in that directory
declare -A scan=( \
[lib/ssl]=0 \
[lib/freebl]=0 \
[lib/util]=0 \
)

# remove .OBJ directories to force a rebuild of just the select few
for i in "${!scan[@]}"; do
find "$i" -name "*.OBJ" -exec rm -rf {} \+
done

# run scan-build
scan-build -o /home/worker/artifacts/ make nss_build_all && cd ..
# run scan-build (only building affected directories)
scan-build -o /home/worker/artifacts make nss_build_all && cd ..

# print errors we found
set +v +x
STATUS=0
for i in "${!scan[@]}"
do
n=$(grep -Rn "${scan[i]}" /home/worker/artifacts/*/report-*.html | wc -l)
if [ $n -ne ${ignore[$i]} ]; then
for i in "${!scan[@]}"; do
n=$(grep -Rn "$i" /home/worker/artifacts/*/report-*.html | wc -l)
if [ $n -ne ${scan[$i]} ]; then
STATUS=1
echo "$(date '+%T') WARNING - TEST-UNEXPECTED-FAIL: ${scan[$i]} contains $n scan-build errors"
echo "$(date '+%T') WARNING - TEST-UNEXPECTED-FAIL: $i contains $n scan-build errors"
elif [ $n -ne 0 ]; then
echo "$(date '+%T') WARNING - TEST-UNEXPECTED-FAIL: ${scan[$i]} contains $n scan-build errors (nonfatal!)"
echo "$(date '+%T') WARNING - TEST-EXPECTED-FAIL: $i contains $n scan-build errors"
fi

done
exit $STATUS
2 changes: 0 additions & 2 deletions automation/taskcluster/scripts/run_tests.sh
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

set -v -e -x

source $(dirname $0)/tools.sh

if [ $(id -u) = 0 ]; then
Expand Down

0 comments on commit 243c3ba

Please sign in to comment.