Date: Sun, 5 May 2013 12:21:23 +0000 (UTC) From: Ulrich Spoerlein <uqs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r250268 - user/uqs/scan-world Message-ID: <201305051221.r45CLNv3068659@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: uqs Date: Sun May 5 12:21:22 2013 New Revision: 250268 URL: http://svnweb.freebsd.org/changeset/base/250268 Log: Add scripts for the Clang Static Analyzer runs at http://scan.freebsd.your.org/freebsd-head Added: user/uqs/scan-world/ user/uqs/scan-world/scan-world (contents, props changed) user/uqs/scan-world/scan-world-cron (contents, props changed) Added: user/uqs/scan-world/scan-world ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/uqs/scan-world/scan-world Sun May 5 12:21:22 2013 (r250268) @@ -0,0 +1,166 @@ +#!/bin/sh + +DRY= +SRCDIR=/data/src/freebsd-head +DEST=/data/scan-build +RELEASE=Release +MYFLAGS="__MAKE_CONF=/dev/null -m $SRCDIR/share/mk -DWITHOUT_PROFILE -DMODULES_WITH_WORLD" +MYFLAGS="$MYFLAGS -DWITHOUT_CLANG -DWITHOUT_LLVM -DWITH_HESIOD -DWITH_GPIO -DWITH_IDEA -DWITH_BSD_GREP -DWITH_ICONV -DWITH_OFED" +DATE=`date "+%Y-%m-%d"` +ARCH=`uname -p` + +LOCK=/tmp/scan.lock +trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15 +if ! shlock -p $$ -f ${LOCK}; then + echo "Locked by `cat ${LOCK}`, running too long? Please fix ..." >&2 + exit 1 +fi + +do_scan() +{ + local dir noclean output + dir=$1; shift + noclean=$1; shift + output=$1; shift + if [ -z "$DRY" ]; then + mkdir -p $output || exit 1 + if [ -z "$noclean" ]; then + make -j2 $MYFLAGS clean + make -j2 $MYFLAGS obj + fi + echo "-=-> scanning $dir at `date "+%Y-%m-%d %H:%M:%S"`" + /usr/bin/time -l \ + env CCC_ANALYZER_CHECKER_DEADCODE=0 \ + /data/src/llvm/$RELEASE/bin/scan-build \ + --use-cc /usr/obj$SRCDIR/tmp/usr/bin/cc \ + --use-c++ /usr/obj$SRCDIR/tmp/usr/bin/c++ \ + -k -o $output make -j4 $MYFLAGS "$@" + rmdir $output 2>/dev/null + else + echo "$dir -> $output" + fi +} + +recurse_dirs() +{ + local prefix noclean dir subdirs srcpath limit depth + limit=2 + prefix=$1; shift + noclean=$1; shift + set -- $* + for dir in $*; do + srcpath=$prefix/$dir + srcpath=${srcpath#/} + # only recurse, if 'make -n' returns exactly one line machting + # /^for entry in/, as then there's nothing to do here, but there are subdirs + ( + cd $dir + depth=`echo "/$srcpath" |tr -Cd /` + # pattern was found, and number of lines==1 + #echo $depth "${#depth}" "$limit" + if [ "${#depth}" -le "$limit" ] && \ + # grab MK_foo settings from head, not /usr/share/mk + make $MYFLAGS -n | awk '/for entry in/{found=1} END{if(found) exit NR-1; else exit 1}'; then + subdirs=`make $MYFLAGS -V SUBDIR` + recurse_dirs "$srcpath" "$noclean" `echo $subdirs` + else + do_scan "$srcpath" "$noclean" $DEST/${SRCDIR##*/}/$(echo $srcpath|tr / .) + fi + ) + done +} + +echo "-=-> scan-world started at `date "+%Y-%m-%d %H:%M:%S"`" + +if [ -z "$DRY" ]; then + cd /data/src/llvm +#./configure --enable-optimized --disable-assertions --disable-docs --enable-targets=host \ +# --with-c-include-dirs=/usr/obj$SRCDIR/tmp/usr/include \ +# --with-cxx-include-root=/usr/obj$SRCDIR/tmp/usr/include + gmake update + + echo "-=-> Building LLVM" + if ! gmake -j4; then + if ! gmake; then + echo "Error building LLVM, bailing out" 2>&1 + exit 1 + fi + fi + # Omit the dead store checker, too many positives to be useful + cp -p ./tools/clang/tools/scan-build/scan-build ./tools/clang/tools/scan-build/scanview.css \ + ./tools/clang/tools/scan-build/sorttable.js $RELEASE/bin +# && \ +# sed -i.bak -e '/check-dead-stores/d' -e '/check-idempotent-operations/d' \ +# -e '/check-objc-self-init/d' $RELEASE/bin/scan-build + # Turn off chatty/verbose progress output + cp -p ./tools/clang/tools/scan-build/ccc-analyzer $RELEASE/bin && \ + ln -sf ccc-analyzer $RELEASE/bin/c++-analyzer +# && \ +# sed -i.bak -e '/analyzer-display-progress/d' $RELEASE/bin/ccc-analyzer + echo "-=-> Updating source in $SRCDIR" + cd $SRCDIR && svn up + if [ $? != 0 ]; then + echo "Error during bootstrap" >&2 + exit 1 + fi +fi + +cd $SRCDIR || exit 1 + +if [ -z "$DRY" ]; then + echo "-=-> Populating .OBJDIR" + # make sure .OBJDIR is something else than $PWD + make $MYFLAGS obj >/dev/null + temp=`make $MYFLAGS -V .OBJDIR` + [ -n "$temp" ] && [ "$temp" != ".." ] && [ "$temp" != "$PWD" ] && echo "Removing $temp dir" && rm -rf $temp + + echo "-=-> Preparing build" + make $MYFLAGS _worldtmp _legacy _bootstrap-tools _cleanobj _obj _build-tools _cross-tools _includes _libraries _depend + if [ $? != 0 ]; then + echo "Error during bootstrap" >&2 + exit 1 + fi +fi + +# Need to have includes, as we hardcode clang for it, so no cleaning +echo "-=-> Building everything" +do_scan "$SRCDIR" "noclean" $DEST/${SRCDIR##*/}/WORLD -DNO_CLEAN -DNO_MODULES everything + +echo "-=-> Building everything (again, individually)" +recurse_dirs "" "" lib libexec bin games cddl gnu kerberos5 sbin secure sys usr.bin usr.sbin +( + for srcpath in cddl/usr.sbin/plockstat usr.bin/setchannel; do + cd $SRCDIR/$srcpath + do_scan "$srcpath" "" $DEST/${SRCDIR##*/}/$(echo $srcpath|tr / .) + done +) + +echo "-=-> Building GENERIC kernel" +do_scan "$SRCDIR" "noclean" $DEST/${SRCDIR##*/}/SYS.GENERIC -DNO_MODULES -DNO_CLEAN KERNCONF=GENERIC buildkernel + +echo "-=-> Building LINT kernel" +make -C sys/$ARCH/conf LINT +do_scan "$SRCDIR" "noclean" $DEST/${SRCDIR##*/}/SYS.LINT -DNO_MODULES -DNO_CLEAN KERNCONF=LINT buildkernel + +echo "-=-> scan-world finished at `date "+%Y-%m-%d %H:%M:%S"`" + +if [ -z "$DRY" ]; then + cd $DEST/${SRCDIR##*/} || exit 1 + + echo "-=-> Renaming output dirs" + find . -type d -name "${DATE}-[1-9]" -prune -exec sh -c 'd={}; mv "$d" "${d%-[1-9]}-'$ARCH'"' \; + + echo "-=-> Linking to LATEST" + rm -rf LATEST + mkdir LATEST + find * -type d -name "${DATE}-$ARCH" -prune -exec sh -c 'd={}; ln -s "../$d" "LATEST/`dirname $d`"' \; + + echo "-=-> Before compression" + df -k . + find . -not -name \*.gz -not -name \*.log -not -name README.html -not -name HEADER.html -type f -exec gzip -9n {} \; + echo "-=-> After compression" + df -k . + fdupes-hardlink . >/dev/null + echo "-=-> After deduping" + df -k . +fi Added: user/uqs/scan-world/scan-world-cron ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/uqs/scan-world/scan-world-cron Sun May 5 12:21:22 2013 (r250268) @@ -0,0 +1,29 @@ +#!/bin/sh + +today="`date +%Y-%m-%d`" +buildlog="$today-`uname -p`.log" + +cd /data/scan-build/freebsd-head && scan-world >$buildlog 2>&1 + +if [ $? != 0 ]; then + echo "Error during scan-world" >&2 + tail -100 $buildlog | mail -s"scan-world error" uqs@spoerlein.net + exit 1 +fi + +count=`egrep '^scan-build: [0-9]+ bugs found\.' $buildlog | awk '{sum+=$2} END{print sum}'` +notfound=`egrep -c 'No such file or directory' $buildlog` +dontknow=`egrep -c 'don.t know how to make' $buildlog` + +if [ -z "$count" ] || [ ! "$count" -gt 0 ]; then + echo "Error during scan-world, no bugs found" >&2 + tail -100 $buildlog | mail -s"scan-world error" uqs@spoerlein.net + exit 1 +fi + +[ -n "$count" ] && echo "<div id=\"left\">$today</div><div id=\"center\">$count potential bugs found</div><div id=\"clear\"></div>" >> HEADER.html + +( echo "Updated #FreeBSD and #llvm #clang scan-build results at http://scan.freebsd.your.org/freebsd-head claiming $count bugs found" + echo "notfound=$notfound dontknow=$dontknow date=$today" + df -m /data/scan-build +) | mail -s"`hostname` finished scan-world" uqs@spoerlein.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305051221.r45CLNv3068659>