#! /bin/sh t=__wt.$$ a=__wt.$$.a b=__wt.$$.b trap 'rm -rf $a $b $t' 0 1 2 3 13 15 # Find the top-level WiredTiger directory and move to there. top=`git rev-parse --show-toplevel` && cd $top || exit 1 echo "$0: running scan-build in $PWD" # Clang isn't installed in any standard place, find a binary we can use. # If the caller gives us $SCANBUILD, check for $SCANCOMPILER and default # to "clang". scan="$SCANBUILD" test -z "$scan" || compiler="${SCANCOMPILER:-clang}" if test -z "$scan" && test -x /usr/bin/clang && test -x /usr/bin/scan-build; then compiler="/usr/bin/clang" scan="/usr/bin/scan-build" fi if test -z "$scan"; then echo "$0: no clang compiler and scan-build programs found" echo "$0: set \$SCANCOMPILER=/path/clang and \$SCANBUILD=/path/scan-build to continue" exit 1 fi echo "$0: compiler: $compiler" echo "$0: scan-build: $scan" # Remove old reports. rm -rf clangScanBuildReports && mkdir clangScanBuildReports sh autogen.sh > /dev/null || exit 1 args="-o clangScanBuildReports" args="$args --use-cc=$compiler" args="$args -disable-checker core.NullDereference" $scan $args ./configure 'CFLAGS=-g' \ --disable-shared --enable-diagnostic --enable-strict > /dev/null $scan $args make -j 8 wt 1>/dev/null 2>$t make -j 8 distclean > /dev/null grep 'No bugs found' $t > /dev/null && exit 0 # Compare the set of errors/warnings and exit success when they're expected. # clang-scan outputs errors/warnings with a leading file path followed by a # colon, followed by the string "error:" or "warning:". cat dist/s_clang-scan.diff | egrep '^[a-z\./].*error: |^[a-z\./].*warning: ' | sed -e 's/:.*:.*://' | sort > $a cat $t | egrep '^[a-z\./].*error: |^[a-z\./].*warning: ' | sed -e 's/:.*:.*://' | sort > $b diff $a $b > /dev/null && exit 0 echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" echo 'scan-build output differs from expected:' echo '<<<<<<<<<< Expected >>>>>>>>>> Current' echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" diff dist/s_clang-scan.diff $t exit 1