[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] scripts: Add a script to build and submit to coverity.



From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

The submission requires a token and email address, which must be
registered as a project admin with the Coverity system. Nonetheless
this is a convenient place to keep it.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Took Andy script and:

- Wrote commit message.
- Generalised the settings handling.
- Added code to call the various steps based on the command line.
- Refactored construction of the curl command line (mainly in order to
  quote the email address).
- Clone mini-os before build.
- Make the upload stage unconditionally to the upload, but not that it
  still isn't in the default set of actions.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
ijc: Maybe we can think of a way to add this to osstest while still
keeping the coverity token private?
---
 scripts/coverity-build.sh | 108 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100755 scripts/coverity-build.sh

diff --git a/scripts/coverity-build.sh b/scripts/coverity-build.sh
new file mode 100755
index 0000000..91defed
--- /dev/null
+++ b/scripts/coverity-build.sh
@@ -0,0 +1,108 @@
+#!/bin/bash -e
+#
+# Copyright 2015 Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
+#
+# WARNING: This script will blow away any changes in your git working
+# directory. It should probably be run in a dedicated checkout.
+#
+# Requires the coverity tools (e.g. cov-build) to be in $PATH.
+#
+# Set $COV_EMAIL and $COV_TOKEN to credentials, otherwise it will
+# prompt for them.
+#
+# ./scripts/coverity-build.sh <steps>
+#
+# By default <steps> is to do all the prep and build, but not to upload.
+#
+
+function checktools ()
+{
+    if ! command -v cov-build ; then
+        echo "Coverity tools (cov-build, ...) must be in \$PATH"
+        exit 1
+    fi
+}
+function hardclean ()
+{
+    echo "Cleaning working tree"
+    git reset --hard
+    make distclean -j8
+}
+
+function update ()
+{
+    echo "Pulling latest staging"
+    git fetch --all
+    git checkout master
+    git pull --ff
+    git checkout staging
+    git pull --ff
+}
+
+function softclean ()
+{
+    echo "Removing any remaining junk"
+    git clean -dxf
+}
+
+function vars ()
+{
+    export COV_HEAD=$(git rev-parse HEAD)
+    export COV_TARBALL="xen-coverity-$COV_HEAD.tgz"
+    export COV_VERSION="Xen-$(make -C xen xenversion --no-print-directory)"
+}
+
+function prebuild ()
+{
+    echo "Running the pre-build"
+
+    ./configure
+    make -C tools/firmware/etherboot all -j4
+    make mini-os-dir
+}
+
+function build ()
+{
+    echo "Starting Coverity build from $(pwd)"
+
+    cov-build --dir cov-int make -C extras/mini-os/
+    cov-build --dir cov-int make xen tools -j4
+    tar czvf $COV_TARBALL cov-int
+}
+
+function upload ()
+{
+    if [ -z "$COV_EMAIL" ] ; then
+       read -p "Email: " COV_EMAIL
+    fi
+    if [ -z "$COV_TOKEN" ] ; then
+       read -p "Form token: " COV_TOKEN
+    fi
+
+    declare -a curl_args
+    curl_args+=("--form" "token=$COV_TOKEN")
+    curl_args+=("--form" "email=$COV_EMAIL")
+    curl_args+=("--form" "file=@$COV_TARBALL")
+    curl_args+=("--form" "version=$COV_VERSION")
+    curl_args+=("--form" "description=$COV_HEAD")
+    curl_args+=("https://scan.coverity.com/builds?project=XenProject";)
+
+    echo "Uploading... curl ${curl_args[@]}"
+    echo curl "${curl_args[@]}" | tee cov-upload.log
+}
+
+function all ()
+{
+    checktools
+    hardclean
+    softclean
+    update
+    softclean
+    vars
+    prebuild
+    build
+}
+
+for cmd in ${@:-all} ; do
+    eval $cmd
+done
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.