summaryrefslogtreecommitdiff
path: root/coverity
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-06-13 15:07:28 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-06-13 15:07:28 +0000
commitb3586a44bd9c4a2c19c3932638998ee0e3b5ba69 (patch)
tree6e710917e0a7bad2104663c12d2cda9990e83629 /coverity
parent2662a06e8d743c60e8c2419242652eedf505d7c9 (diff)
2010-06-13 Joel Sherrill <joel.sherrilL@OARcorp.com>
* ChangeLog, Makefile, README, do_coverity, do_mail_coverity: New files.
Diffstat (limited to 'coverity')
-rw-r--r--coverity/ChangeLog4
-rw-r--r--coverity/Makefile20
-rw-r--r--coverity/README30
-rwxr-xr-xcoverity/do_coverity138
-rwxr-xr-xcoverity/do_mail_coverity19
5 files changed, 211 insertions, 0 deletions
diff --git a/coverity/ChangeLog b/coverity/ChangeLog
new file mode 100644
index 0000000..b7793dd
--- /dev/null
+++ b/coverity/ChangeLog
@@ -0,0 +1,4 @@
+2010-06-13 Joel Sherrill <joel.sherrilL@OARcorp.com>
+
+ * ChangeLog, Makefile, README, do_coverity, do_mail_coverity: New files.
+
diff --git a/coverity/Makefile b/coverity/Makefile
new file mode 100644
index 0000000..b22533e
--- /dev/null
+++ b/coverity/Makefile
@@ -0,0 +1,20 @@
+#
+# $Id$
+#
+
+INSTALL_DIR=../bin
+SCRIPTS=do_coverity do_mail_coverity
+
+all: prep ${SCRIPTS} install
+
+prep:
+ test -d ${INSTALL_DIR} || mkdir ${INSTALL_DIR}
+
+clean:
+
+install:
+ for i in ${SCRIPTS} ; do \
+ cp $${i} ${INSTALL_DIR}/$${i} ; \
+ chmod +x ${INSTALL_DIR}/$${i} ; \
+ done
+
diff --git a/coverity/README b/coverity/README
new file mode 100644
index 0000000..934ca41
--- /dev/null
+++ b/coverity/README
@@ -0,0 +1,30 @@
+#
+# $Id$
+#
+
+This directory contains scripts which assist in running Coverity
+on RTEMS and submitting them to the Coverity builder. You have
+to have an account to view the results of the run.
+
+Coverity is a closed source static code analyser which can detect a variety
+of programming errors.
+
+ + Instructions: http://scan.coverity.com/self-build/
+ + Results: http://scan2.coverity.com:9104/
+
+STATUS
+======
++ This script has a number of hard-coded variables that should probably
+ be passed in on the command line.
+
++ There are likely errors it does not detect. So far, it looks like
+ a lot can go wrong. :)
+
++ I do not know how to grab the information on a Coverity issue and
+ bring it to the community in a way that is nice yet. I don't care
+ whether this is automated or not because we don't have many issues.
+ But when we file PRs on Coverity issues, people need to see the report.
+
+--joel
+13 June 2010
+
diff --git a/coverity/do_coverity b/coverity/do_coverity
new file mode 100755
index 0000000..9a1fba3
--- /dev/null
+++ b/coverity/do_coverity
@@ -0,0 +1,138 @@
+#! /bin/sh
+#
+# This script automates running Coverity on RTEMS and submitting
+# the results.
+#
+# + Instructions: http://scan.coverity.com/self-build/
+# + Results: http://scan2.coverity.com:9104/
+#
+# You have to have an account to view the results
+#
+# NOTE:
+# + You have to be joel to run and submit official results.
+# + build.raw is very important if something goes wrong
+#
+# $Id$
+#
+
+#
+# TODO:
+# + parse arguments for some of the hard-coded items.
+# + better instructions on setup. Where to download, etc.
+#
+
+RTEMS_BIN=/opt/rtems-4.11/bin
+COVERITY=${HOME}/prevent-linux-2.4.6
+RTEMS_TARGET=sparc-rtems4.11
+RTEMS_BSP=sis
+#RTEMS_TARGET=i386-rtems4.11
+#RTEMS_BSP=pc386
+
+do_mail="yes"
+
+#
+# Checks the status returned by executables and exits if it is non-zero.
+#
+check_fatal()
+{
+ if [ $1 -ne 0 ] ; then
+ shift
+ echo "ERROR: $*" >&2
+ exit 1
+ fi
+}
+
+type ${RTEMS_TARGET}-gcc
+check_fatal $? "gcc not in path"
+
+test -d ${COVERITY}
+check_fatal $? "Coverity path not right"
+
+test -d ${COVERITY}/bin
+check_fatal $? "${COVERITY}/bin does not exist"
+
+test ${LOGNAME} = "joel"
+check_fatal $? "For now, Coverity must be run by joel"
+
+# Prepend Coverity to our PATH
+export PATH=${COVERITY}/bin:$PATH
+
+# Configure Coverity for this target compiler
+rm -rf ${COVERITY}/config/coverity_config.xml
+rm -rf ${COVERITY}/config/gcc-config-? ${COVERITY}/config/g++-config-?
+
+cov-configure -co ${RTEMS_BIN}/${RTEMS_TARGET}-gcc
+check_fatal $? "could not coverity configure GCC"
+cov-configure -co ${RTEMS_BIN}/${RTEMS_TARGET}-g++
+check_fatal $? "could not coverity configure g++"
+
+# Clean build directory and start over
+rm -rf b-coverity-${RTEMS_TARGET}
+check_fatal $? "Could not remove build directory"
+mkdir -p b-${RTEMS_TARGET}/b-coverity-${RTEMS_TARGET}
+check_fatal $? "Could not make build directory"
+cd b-${RTEMS_TARGET}/b-coverity-${RTEMS_TARGET}
+check_fatal $? "Could not cd to build directory"
+
+# Configure RTEMS
+$r/configure --target=${RTEMS_TARGET} --enable-multilib \
+ --disable-networking --disable-itron --disable-tests \
+ --enable-rtemsbsp=${RTEMS_BSP} >c.log 2>&1
+check_fatal $? "could not configure RTEMS"
+
+# Build RTEMS
+cov-build -e emit -o output make -C ${RTEMS_TARGET}/cpukit >b.log 2>&1
+check_fatal $? "could not make RTEMS"
+
+# Did we have problems loading the Coverity dynamic library?
+grep -i "ERROR: ld.so:.*" b.log >/dev/null
+if [ $? -ne 1 ] ; then
+ check_fatal 1 "Looks like you have dynamic library issues with Coverity."
+fi
+
+# Did Coverity report something bad?
+grep -i cata output/build.raw >/dev/null
+if [ $? -ne 1 ] ; then
+ check_fatal 1 "Catastrophic failures reported by coverity."
+fi
+
+# Did Coverity report that it had no results?
+grep -i "No files were emitted" output/build.raw >/dev/null
+if [ $? -ne 1 ] ; then
+ check_fatal 1 "No output from Coverity. Something went wrong."
+fi
+
+# Construct the README that is needed in project.tgz
+cat <<EOF >README
+Joel Sherrill
+joel.sherrill@gmail.com
+RTEMS
+EOF
+
+# Now create the tar file that Coverity wants
+tar czvf project.tgz README emit output
+check_fatal $? "could not make project.tgz"
+
+# If running inside OAR and RTEMS lab, then you will be able to
+# copy the results file to the ftp site and submit it to Coverity.
+if [ ${do_mail} = "yes" ] ; then
+ if [ -d /home/ftp/private/coverity ] ; then
+ echo "Placing project.tgz on RTEMS ftp site."
+ cp project.tgz /home/ftp/private/coverity/
+ echo "Emailing analysis request to Coverity."
+ do_mail_coverity
+ else
+ # There are unfortunately some by hand steps
+ cat <<EOF
+You do not have NFS access to the RTEMS.org ftp site. So you will have
+to copy the project.tgz and email Coverity by hand.
+
+(1) scp */project.tgz joel@www.rtems.org:/home/ftp/private/coverity/
+
+(2) Send email to Coverity to request a run. (e.g. do_mail_coverity)
+EOF
+ fi
+fi
+
+# Ran completed OK
+exit 0
diff --git a/coverity/do_mail_coverity b/coverity/do_mail_coverity
new file mode 100755
index 0000000..0d87150
--- /dev/null
+++ b/coverity/do_mail_coverity
@@ -0,0 +1,19 @@
+#! /bin/sh
+#
+# Request a coverity run for RTEMS
+#
+# Send an email to build@submit.scan.coverity.com with the following contents:
+#
+# VERSION;PROJECT;PASSWORD;MAILOPT;URL
+#
+# VERSION: The only supported version is v1 as described in this text.
+# PROJECT: The name of your project, as registered with Scan.
+# PASSWORD: The password for build submissions for your project,
+# as arranged with the Scan admin staff
+# MAILOPT: Either MAIL, NOMAIL, or an email address.
+
+cat <<EOF |
+v1;RTEMS;ce5hazuV;joel@oarcorp.com.com;http://www.rtems.org/ftp/private/coverity/project.tgz
+EOF
+mail -u joel -r joel@oarcorp.com -s "RTEMS Coverity Run Request" build@submit.scan.coverity.com
+exit 0