summaryrefslogtreecommitdiff
path: root/cppcheck
diff options
context:
space:
mode:
authorMaarten Hoes <hoes.maarten@gmail.com>2015-01-21 14:13:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-01-23 20:29:29 +0000
commitec1c1ddcc8eb03b71e8e69c5c2644a4d80947730 (patch)
tree41d2531635a288c0ec9bcdabfdd43b7ec35b5b8d /cppcheck
parent52626df964a70fbdfb485f189814d072c1ae4631 (diff)
redirect output to file, mail it to list on error if mailx is present.
Change-Id: I4e6829cab888376290541adc2a4e03270cabd8ce Reviewed-on: https://gerrit.libreoffice.org/14074 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cppcheck')
-rwxr-xr-xcppcheck/cppcheck-report.sh65
1 files changed, 58 insertions, 7 deletions
diff --git a/cppcheck/cppcheck-report.sh b/cppcheck/cppcheck-report.sh
index fc9ea324..f0187705 100755
--- a/cppcheck/cppcheck-report.sh
+++ b/cppcheck/cppcheck-report.sh
@@ -10,6 +10,13 @@
[ "$DEBUG" ] && set -xv
+# save stdout and stderr
+exec 3>&1 4>&2 >/tmp/foo.log 2>&1
+
+# redirect to log file
+exec > /tmp/cppcheck-report.log
+exec 2>&1
+
#
# Functions
#
@@ -18,7 +25,9 @@ die()
{
[ "$DEBUG" ] && set -xv
- echo "Error:" "$@" >&2
+ MESSAGE="$@"
+ echo "Error:" "${MESSAGE?}" >&2
+ mail_failure "${MESSAGE?}"
exit -1;
}
@@ -108,7 +117,6 @@ get_commit_cppcheck()
popd > /dev/null || die "Failed to change directory out of ${CPPCHECK_DIR?}"
}
-
upload_report()
{
[ "$DEBUG" ] && set -xv
@@ -118,16 +126,57 @@ upload_report()
scp -r "${HTML_DIR?}"/* upload@dev-builds.libreoffice.org:"${UPLOAD_DIR?}"/ || die "Failed to upload report to ${UPLOAD_DIR?}"
}
+mail_success()
+{
+ [ "$DEBUG" ] && set -xv
-#
-# Main
-#
+ which mailx >/dev/null 2>&1
+ if [ "$?" = "0" ] ; then
+
+mailx -s "CppCheck Report update" "${MAILTO?}" <<EOF
+
+A new cppcheck report is available at : http://dev-builds.libreoffice.org/cppcheck_reports/master/
+
+This job was run at `date +%Y-%d-%m_%H:%M:%S` with user `whoami` at host `cat /etc/hostname` as $MY_NAME
+
+EOF
+
+ fi
+}
+mail_failure()
+{
+ [ "$DEBUG" ] && set -xv
+ MESSAGE="$@"
+
+ if [ -f /tmp/cppcheck-report.log ] ; then
+ cp -f /tmp/cppcheck-report.log ~/cppcheck-report.log
+ rm -f ~/cppcheck-report.log.gz
+ gzip ~/cppcheck-report.log
+ fi
+
+ which mailx >/dev/null 2>&1
+ if [ "$?" = "0" ] ; then
+
+mailx -s "CppCheck Report: Failure" "${MAILTO?}" <<EOF
+`uuencode /home/buildslave/cppcheck-report.log.gz /home/buildslave/cppcheck-report.log.gz`
+
+The cppcheck job failed with message: "${MESSAGE?}"
+
+This job was run at `date +%Y-%d-%m_%H:%M:%S` with user `whoami` at host `cat /etc/hostname` as $MY_NAME
+
+EOF
+
+ fi
+}
usage()
{
[ "$DEBUG" ] && set -xv
+ # restore stdout and stderr
+ exec 1>&3 2>&4
+
echo >&2 "Usage: lcov-report.sh -s [DIRECTORY] -w [DIRECTORY]
-s source code directory
-w html (www) directory
@@ -150,7 +199,9 @@ DATA_DIR=/tmp
CPPCHECK_GIT_URL="git://github.com/danmar/cppcheck.git"
LO_GIT_URL="git://anongit.freedesktop.org/libreoffice/core.git"
UPLOAD_DIR=/srv/www/dev-builds.libreoffice.org/cppcheck_reports/master
-
+MAILTO=libreoffice@lists.freedesktop.org
+MY_NAME=`dirname $0`
+MESSAGE=
while getopts ":s:w:c:" opt ; do
case "$opt" in
@@ -177,4 +228,4 @@ get_commit_lo
build_cppcheck
run_cppcheck
upload_report
-
+mail_success