[rtems-testing commit] Update coverity scripts to run against master
Joel Sherrill
joel at rtems.org
Sun Feb 5 01:33:50 UTC 2017
Module: rtems-testing
Branch: master
Commit: c8db44ba100cadaa40fb0b66956a9b2928b4fc39
Changeset: http://git.rtems.org/rtems-testing/commit/?id=c8db44ba100cadaa40fb0b66956a9b2928b4fc39
Author: Joel Sherrill <joel at rtems.org>
Date: Sat Feb 4 16:58:06 2017 -0600
Update coverity scripts to run against master
Add scripts to test newlib and rtems-tools as well as capture
the dummy Coverity model files. The website complains if you
have not filled in all the holes. Providing dummy values gives
us "completely configured" projects.
---
coverity/README | 15 ++--
coverity/do_coverity_newlib | 127 ++++++++++++++++++++++++++++
coverity/{do_coverity => do_coverity_rtems} | 92 +++++++++-----------
coverity/do_coverity_rtems-tools | 97 +++++++++++++++++++++
coverity/do_mail_coverity | 19 -----
coverity/rtems-coverity-model.c | 5 ++
coverity/rtems-newlib-model.c | 5 ++
coverity/rtems-tools-model.c | 5 ++
8 files changed, 287 insertions(+), 78 deletions(-)
diff --git a/coverity/README b/coverity/README
index d02069b..0793d53 100644
--- a/coverity/README
+++ b/coverity/README
@@ -2,25 +2,26 @@ 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.
+NOTE: Please edit the script to change the email address. :)
+
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/
+ + https://scan.coverity.com/
STATUS
======
-+ This script has a number of hard-coded variables that should probably
++ These scripts have 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.
+ bring it to the community in a way that is nice yet.
+
++ We need to decide whether to scan BSPs and tests.
--joel
-13 June 2010
+4 February 2017
diff --git a/coverity/do_coverity_newlib b/coverity/do_coverity_newlib
new file mode 100755
index 0000000..adf8f1b
--- /dev/null
+++ b/coverity/do_coverity_newlib
@@ -0,0 +1,127 @@
+#! /bin/sh
+#
+# This script automates running Coverity on newlib targeting RTEMS
+# and submitting the results.
+#
+# + https://scan.coverity.com/
+#
+# You have to have an account to view the results
+#
+
+#
+# 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 1
+check_fatal $? "Usage: TARGET"
+
+RTEMS_TARGET=$1
+
+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"
+
+# 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}-newlib
+check_fatal $? "Could not remove build directory"
+mkdir b-coverity-${RTEMS_TARGET}-newlib
+check_fatal $? "Could not cd into build directory"
+cd b-coverity-${RTEMS_TARGET}-newlib
+check_fatal $? "Could not cd into build directory"
+
+# iconv settings
+enable_iconv="--enable-newlib-iconv \
+ --enable-newlib-iconv-encodings=big5,cp775,cp850,cp852,cp855,\
+cp866,euc_jp,euc_kr,euc_tw,iso_8859_1,iso_8859_10,iso_8859_11,\
+iso_8859_13,iso_8859_14,iso_8859_15,iso_8859_2,iso_8859_3,\
+iso_8859_4,iso_8859_5,iso_8859_6,iso_8859_7,iso_8859_8,iso_8859_9,\
+iso_ir_111,koi8_r,koi8_ru,koi8_u,koi8_uni,ucs_2,ucs_2_internal,\
+ucs_2be,ucs_2le,ucs_4,ucs_4_internal,ucs_4be,ucs_4le,us_ascii,\
+utf_16,utf_16be,utf_16le,utf_8,win_1250,win_1251,win_1252,\
+win_1253,win_1254,win_1255,win_1256,win_1257,win_1258"
+
+pwd
+#
+# Configure newlib
+../newlib-cygwin/configure \
+ --disable-multilib \
+ ${enable_iconv} \
+ --enable-newlib-io-c99-formats \
+ --enable-threads \
+ --target=${RTEMS_TARGET} \
+ --prefix=/tmp/throw_me_away \
+ >c.log 2>&1
+check_fatal $? "could not configure newlib"
+
+# Build newlib
+cov-build --dir cov-int make >b.log 2>&1
+check_fatal $? "could not make newlib"
+
+# 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 newlib-coverity.tar.gz cov-int
+check_fatal $? "could not make newlib-coverity"
+
+curl --form token=BtR7PhfmMTP6Z3BnAU8tNw \
+ --form email=joel.sherrill at gmail.com \
+ --form file=@newlib-coverity.tar.gz \
+ --form version="Master" \
+ --form description="Master (${RTEMS_TARGET})" \
+ https://scan.coverity.com/builds?project=RTEMS-Newlib
+
+# Ran completed OK
+exit 0
diff --git a/coverity/do_coverity b/coverity/do_coverity_rtems
similarity index 50%
rename from coverity/do_coverity
rename to coverity/do_coverity_rtems
index bb144d3..4801ba0 100755
--- a/coverity/do_coverity
+++ b/coverity/do_coverity_rtems
@@ -19,14 +19,9 @@
# + 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
+RTEMS_BIN=/home/joel/rtems-work/tools/4.12/bin
+COVERITY=${HOME}/coverity/cov-analysis-linux64-8.7.0/
-do_mail="yes"
#
# Checks the status returned by executables and exits if it is non-zero.
@@ -40,6 +35,19 @@ check_fatal()
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"
@@ -55,31 +63,32 @@ 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
+# # 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++"
+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 -p b-coverity-${RTEMS_TARGET}/b-${RTEMS_TARGET}
-check_fatal $? "Could not make build directory"
-cd b-coverity-${RTEMS_TARGET}/b-${RTEMS_TARGET}
-check_fatal $? "Could not cd to 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} --enable-multilib \
- --disable-networking --disable-itron --disable-tests \
+$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 -e emit -o output make -C ${RTEMS_TARGET}/cpukit >b.log 2>&1
+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?
@@ -89,48 +98,27 @@ if [ $? -ne 1 ] ; then
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
+# 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" output/build.raw >/dev/null
+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
-# Construct the README that is needed in project.tgz
-cat <<EOF >README
-Joel Sherrill
-joel.sherrill at gmail.com
-RTEMS
-EOF
-
# Now create the tar file that Coverity wants
-tar czvf project.tgz README emit output
+tar czvf rtems-coverity.tar.gz cov-int
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 at www.rtems.org:/home/ftp/private/coverity/
-
-(2) Send email to Coverity to request a run. (e.g. do_mail_coverity)
-EOF
- fi
-fi
+curl --form token=ce5hazuV \
+ --form email=joel.sherrill at 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
diff --git a/coverity/do_coverity_rtems-tools b/coverity/do_coverity_rtems-tools
new file mode 100755
index 0000000..555ed33
--- /dev/null
+++ b/coverity/do_coverity_rtems-tools
@@ -0,0 +1,97 @@
+#! /bin/sh
+#
+# This script automates running Coverity on newlib targeting RTEMS
+# tools and submitting the results.
+#
+# + https://scan.coverity.com/
+#
+# You have to have an account to view the results
+#
+
+#
+# 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
+}
+
+type 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 -d tools
+check_fatal $? "Are you in the rtems-tools directory?"
+
+test -d tester
+check_fatal $? "Are you in the rtems-tools directory?"
+
+# 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"
+
+./waf distclean
+check_fatal $? "waf distclean failed"
+
+# Configure
+./waf configure >c.log 2>&1
+check_fatal $? "waf configure failed" >c.log 2>&1
+check_fatal $? "could not configure rtems-tools"
+
+# Build newlib
+cov-build --dir cov-int ./waf >b.log 2>&1
+check_fatal $? "could not make rtems-tools"
+
+# 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 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-tools-coverity.tar.gz cov-int
+check_fatal $? "could not make rtems-tools-coverity"
+
+curl --form token=zhfOCWF5jpcB-sGffpvKaQ \
+ --form email=joel.sherrill at gmail.com \
+ --form file=@rtems-tools-coverity.tar.gz \
+ --form version="Master" \
+ --form description="Master (${RTEMS_TARGET})" \
+ https://scan.coverity.com/builds?project=RTEMS-Tools
+
+# Ran completed OK
+exit 0
diff --git a/coverity/do_mail_coverity b/coverity/do_mail_coverity
deleted file mode 100755
index d557f53..0000000
--- a/coverity/do_mail_coverity
+++ /dev/null
@@ -1,19 +0,0 @@
-#! /bin/sh
-#
-# Request a coverity run for RTEMS
-#
-# Send an email to build at 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 at oarcorp.com;http://www.rtems.org/ftp/private/coverity/project.tgz
-EOF
-mail -u joel -r joel at oarcorp.com -s "RTEMS Coverity Run Request" build at submit.scan.coverity.com
-exit 0
diff --git a/coverity/rtems-coverity-model.c b/coverity/rtems-coverity-model.c
new file mode 100644
index 0000000..426b5d3
--- /dev/null
+++ b/coverity/rtems-coverity-model.c
@@ -0,0 +1,5 @@
+//
+// RTEMS currently does not have anything to model for Coverity.
+// Having a file makes them happy we have a fully configured project. :)
+//
+
diff --git a/coverity/rtems-newlib-model.c b/coverity/rtems-newlib-model.c
new file mode 100644
index 0000000..ed7473e
--- /dev/null
+++ b/coverity/rtems-newlib-model.c
@@ -0,0 +1,5 @@
+//
+// RTEMS-newlib currently does not have anything to model for Coverity.
+// Having a file makes them happy we have a fully configured project. :)
+//
+
diff --git a/coverity/rtems-tools-model.c b/coverity/rtems-tools-model.c
new file mode 100644
index 0000000..4664342
--- /dev/null
+++ b/coverity/rtems-tools-model.c
@@ -0,0 +1,5 @@
+//
+// RTEMS-tools currently does not have anything to model for Coverity.
+// Having a file makes them happy we have a fully configured project. :)
+//
+
More information about the vc
mailing list