summaryrefslogtreecommitdiffstats
path: root/coverity/do_coverity_rtems
diff options
context:
space:
mode:
Diffstat (limited to 'coverity/do_coverity_rtems')
-rwxr-xr-xcoverity/do_coverity_rtems124
1 files changed, 124 insertions, 0 deletions
diff --git a/coverity/do_coverity_rtems b/coverity/do_coverity_rtems
new file mode 100755
index 0000000..4801ba0
--- /dev/null
+++ b/coverity/do_coverity_rtems
@@ -0,0 +1,124 @@
+#! /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
+#
+
+#
+# TODO:
+# + parse arguments for some of the hard-coded items.
+# + better instructions on setup. Where to download, etc.
+#
+
+RTEMS_BIN=/home/joel/rtems-work/tools/4.12/bin
+COVERITY=${HOME}/coverity/cov-analysis-linux64-8.7.0/
+
+
+#
+# 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
+}
+
+echo $#
+test $# -eq 2
+check_fatal $? "Usage: TARGET BSP"
+
+RTEMS_TARGET=$1
+RTEMS_BSP=$2
+
+case ${RTEMS_BSP} in
+ erc32) SMP="" ;;
+ leon3) SMP="--enable-smp" ;;
+ *) echo "How to run coverity on ${RTEMS_BSP}" ; exit 1
+esac
+
+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 --gcc
+check_fatal $? "could not coverity configure gcc"
+
+cov-configure --comptype gcc --compiler ${RTEMS_TARGET}-gcc --template
+check_fatal $? "could not coverity configure gcc"
+
+# Clean build directory and start over
+rm -rf b-coverity-${RTEMS_TARGET}
+check_fatal $? "Could not remove build directory"
+mkdir b-coverity-${RTEMS_TARGET}
+check_fatal $? "Could not cd into build directory"
+cd b-coverity-${RTEMS_TARGET}
+check_fatal $? "Could not cd into build directory"
+
+# Configure RTEMS
+$r/configure --target=${RTEMS_TARGET} \
+ ${SMP} --disable-networking --disable-tests \
+ --enable-rtemsbsp=${RTEMS_BSP} >c.log 2>&1
+check_fatal $? "could not configure RTEMS"
+
+# Build RTEMS
+cov-build --dir cov-int make >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 cov-int/build-log.txt >/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" cov-int/build-log.txt >/dev/null
+if [ $? -ne 1 ] ; then
+ check_fatal 1 "No output from Coverity. Something went wrong."
+fi
+
+# Now create the tar file that Coverity wants
+tar czvf rtems-coverity.tar.gz cov-int
+check_fatal $? "could not make project.tgz"
+
+curl --form token=ce5hazuV \
+ --form email=joel.sherrill@gmail.com \
+ --form file=@rtems-coverity.tar.gz \
+ --form version="4.11.99.0" \
+ --form description="Master (${RTEMS_BSP})" \
+ https://scan.coverity.com/builds?project=RTEMS
+
+# Ran completed OK
+exit 0