Bug 1308832 - improve scan-build script, r=franziskus
authorMartin Thomson <martin.thomson@gmail.com>
Fri, 07 Oct 2016 20:35:36 +1100
changeset 12692 ba8410f84629248e320faf28843735a26a74b9d2
parent 12691 908eaf36f66d3080a37b56313711032681450c3d
child 12693 19235044514fb03ba9ee3e3b8ccc82d90ef0ff3d
push id1646
push usermartin.thomson@gmail.com
push dateMon, 10 Oct 2016 04:48:43 +0000
reviewersfranziskus
bugs1308832
Bug 1308832 - improve scan-build script, r=franziskus
automation/taskcluster/scripts/build.sh
automation/taskcluster/scripts/run_scan_build.sh
automation/taskcluster/scripts/run_tests.sh
--- a/automation/taskcluster/scripts/build.sh
+++ b/automation/taskcluster/scripts/build.sh
@@ -1,12 +1,10 @@
 #!/usr/bin/env bash
 
-set -v -e -x
-
 source $(dirname $0)/tools.sh
 
 if [[ $(id -u) -eq 0 ]]; then
     # Set compiler.
     switch_compilers
 
     # Drop privileges by re-running this script.
     exec su worker $0
--- a/automation/taskcluster/scripts/run_scan_build.sh
+++ b/automation/taskcluster/scripts/run_scan_build.sh
@@ -1,51 +1,52 @@
 #!/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
 
     # Drop privileges by re-running this script.
     exec su worker $0 $@
 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
+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)
+# 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 \
+    )
 
-for i in "${scan[@]}"
-do
-   echo "cleaning $i ..."
-   find "$i" -name "*.OBJ" | xargs rm -fr
+# 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
--- a/automation/taskcluster/scripts/run_tests.sh
+++ b/automation/taskcluster/scripts/run_tests.sh
@@ -1,12 +1,10 @@
 #!/usr/bin/env bash
 
-set -v -e -x
-
 source $(dirname $0)/tools.sh
 
 if [ $(id -u) = 0 ]; then
     # Set compiler.
     switch_compilers
 
     # Stupid Docker.
     echo "127.0.0.1 localhost.localdomain" >> /etc/hosts