From c8db44ba100cadaa40fb0b66956a9b2928b4fc39 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sat, 4 Feb 2017 16:58:06 -0600 Subject: 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 | 136 --------------------------------------- coverity/do_coverity_newlib | 127 ++++++++++++++++++++++++++++++++++++ coverity/do_coverity_rtems | 124 +++++++++++++++++++++++++++++++++++ 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 ++ 9 files changed, 371 insertions(+), 162 deletions(-) delete mode 100755 coverity/do_coverity create mode 100755 coverity/do_coverity_newlib create mode 100755 coverity/do_coverity_rtems create mode 100755 coverity/do_coverity_rtems-tools delete mode 100755 coverity/do_mail_coverity create mode 100644 coverity/rtems-coverity-model.c create mode 100644 coverity/rtems-newlib-model.c create mode 100644 coverity/rtems-tools-model.c 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 b/coverity/do_coverity deleted file mode 100755 index bb144d3..0000000 --- a/coverity/do_coverity +++ /dev/null @@ -1,136 +0,0 @@ -#! /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=/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-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" - -# 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 <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 <&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@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_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 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@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@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 <