[libvirt] [PATCH V2] maint: add sanitizers to the build process

2017-06-01 Thread claudioandre . br
From: Claudio André 

Sanitizers are based on compile-time instrumentation. They are available
in gcc and clang for a range of supported operation systems and
platforms. More info at: https://github.com/google/sanitizers

The address sanitizer finds bugs related to addressing memory: use after
free, heap buffer overflow, stack buffer overflow, memory leaks, ...
The undefined behavior sanitizer detects situations not prescribed by the
language specification: bound violations, data overflows, ...

The llvm.org states that Sanitizers have found thousands of bugs everywhere.
Sanitizers running during CI can prevent bugs from taking up residence. They
are helper tools to maintain bugs out.
---
* Harmless (the new flags are disabled by default)
* Real example of it working:
Direct leak of 1432 byte(s) in 1 object(s) allocated from:
#0 0x4cea00 in calloc 
/home/ben/development/llvm/3.5/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:56:3
#1 0x2b0459e834a6 in virAlloc 
/home/travis/build/claudioandre/libvirt/src/util/viralloc.c:144:24
#2 0x2b045a010af4 in virDomainDefNew 
/home/travis/build/claudioandre/libvirt/src/conf/domain_conf.c:2923:9
#3 0x2b045a010af4 in virDomainDefParseXML 
/home/travis/build/claudioandre/libvirt/src/conf/domain_conf.c:16923
#4 0x2b045a0106a1 in virDomainDefParseNode 
/home/travis/build/claudioandre/libvirt/src/conf/domain_conf.c:18764:11
#5 0x2b045a0105ba in virDomainDefParse 
/home/travis/build/claudioandre/libvirt/src/conf/domain_conf.c:18708:15
#6 0x4ec396 in testCompareMemLock 
/home/travis/build/claudioandre/libvirt/tests/qemumemlocktest.c:45:17
#7 0x4ede56 in virTestRun 
/home/travis/build/claudioandre/libvirt/tests/testutils.c:180:11
#8 0x4ec194 in mymain 
/home/travis/build/claudioandre/libvirt/tests/qemumemlocktest.c:119:5
#9 0x4f0f9c in virTestMain 
/home/travis/build/claudioandre/libvirt/tests/testutils.c:1019:11
#10 0x2b045b221f44 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

 m4/virt-compile-warnings.m4 | 35 +--
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 768a5c8..269f14d 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -166,12 +166,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
   wantwarn="$wantwarn -Wno-format"
 fi
 
-# This should be < 256 really. Currently we're down to 4096,
-# but using 1024 bytes sized buffers (mostly for virStrerror)
-# stops us from going down further
-gl_WARN_ADD(["-Wframe-larger-than=4096"], [STRICT_FRAME_LIMIT_CFLAGS])
-gl_WARN_ADD(["-Wframe-larger-than=25600"], [RELAXED_FRAME_LIMIT_CFLAGS])
-
 # Extra special flags
 dnl -fstack-protector stuff passes gl_WARN_ADD with gcc
 dnl on Mingw32, but fails when actually used
@@ -259,4 +253,33 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
   AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP_EQUAL_EXPR], 1,
 [Define to 1 if gcc -Wlogical-op reports false positive 'or' equal 
expr])
 fi
+
+dnl Check for support for Sanitizers
+dnl Check for -fsanitize=address and -fsanitize=undefined support
+LIBVIRT_ARG_ENABLE([ASAN], [build with address sanitizer support], [no])
+SAN_CFLAGS=
+
+AS_IF([test "x$enable_asan" = "xyes"], [
+gl_COMPILER_OPTION_IF([-fsanitize=address -fno-omit-frame-pointer], [
+SAN_CFLAGS="-fsanitize=address"
+])
+])
+
+LIBVIRT_ARG_ENABLE([UBSAN], [build with undefined behavior sanitizer 
support], [no])
+AS_IF([test "x$enable_ubsan" = "xyes"], [
+gl_COMPILER_OPTION_IF([-fsanitize=undefined -fno-omit-frame-pointer], [
+SAN_CFLAGS="$SAN_CFLAGS -fsanitize=undefined"
+])
+])
+
+AS_IF([ test -n "${SAN_CFLAGS}"], [
+gl_AS_VAR_APPEND([WARN_CFLAGS], [" $SAN_CFLAGS 
-fno-omit-frame-pointer"])
+gl_AS_VAR_APPEND([LDFLAGS], [" $SAN_CFLAGS -ldl"])
+],[
+# This should be < 256 really. Currently we're down to 4096,
+# but using 1024 bytes sized buffers (mostly for virStrerror)
+# stops us from going down further
+gl_WARN_ADD(["-Wframe-larger-than=4096"], [STRICT_FRAME_LIMIT_CFLAGS])
+gl_WARN_ADD(["-Wframe-larger-than=25600"], 
[RELAXED_FRAME_LIMIT_CFLAGS])
+])
 ])
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH V3] CI: also run tests using updated distro(s)

2017-05-31 Thread claudioandre . br
From: Claudio André 

It is possible to test libvirt using other distros in Travis via Docker;
including (but not limited to) Fedora and Ubuntu.
---
https://travis-ci.org/claudioandre/libvirt/builds/237995646

 .travis.yml| 19 ++---
 tests/travis-ci.sh | 80 ++
 2 files changed, 89 insertions(+), 10 deletions(-)
 create mode 100755 tests/travis-ci.sh

diff --git a/.travis.yml b/.travis.yml
index 5a3e765..e4d4888 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
 sudo: false
 language: c
 dist: precise
-compiler:
-  - gcc
 cache: ccache
 addons:
   apt:
@@ -62,15 +60,14 @@ git:
 before_install:
   - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install gnutls 
libgcrypt yajl gettext rpcgen ; fi
 
-# the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
-before_script:
-  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh
 script:
-  - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+  - tests/travis-ci.sh
 
 # Environments here are run in addition to the main environment defined above
 matrix:
   include:
+- compiler: gcc
+  dist: precise
 - compiler: clang
   dist: precise
 - compiler: clang
@@ -79,10 +76,12 @@ matrix:
   dist: trusty
 - compiler: clang
   os: osx
-  script:
-# many unit tests fail & so does syntax-check, so skip for now
-# one day we must fix it though
-- make -j3
+- services: docker
+  env: IMAGE=ubuntu:17.04 CC=gcc
+  dist: trusty
+- services: docker
+  env: IMAGE=ubuntu:17.04 CC=clang
+  dist: trusty
 
 after_failure:
   - echo 
''
diff --git a/tests/travis-ci.sh b/tests/travis-ci.sh
new file mode 100755
index 000..e63d509
--- /dev/null
+++ b/tests/travis-ci.sh
@@ -0,0 +1,80 @@
+#!/bin/bash -e
+
+function do_Install_Dependencies(){
+echo
+echo '-- Installing Dependencies --'
+
+if [[ $DISTRO = "ubuntu:17.04" ]]; then
+apt-get update -qq
+apt-get -y -qq install \
+build-essential git clang autoconf libtool libcmpicppimpl0 gettext 
\
+xsltproc autopoint libxml2-dev libncurses5-dev libreadline-dev \
+zlib1g-dev libgnutls28-dev libgcrypt11-dev libavahi-client-dev 
libsasl2-dev \
+libxen-dev lvm2 libgcrypt11-dev libparted0-dev libdevmapper-dev 
uuid-dev \
+libudev-dev libpciaccess-dev libcap-ng-dev libnl-3-dev 
libnl-route-3-dev \
+libyajl-dev libpcap0.8-dev libnuma-dev libnetcf-dev libaudit-dev \
+libxml2-utils libapparmor-dev dnsmasq-base librbd-dev 
w3c-markup-validator kmod > /dev/null
+else
+echo "Please, change 'tests/travis-ci.sh' to add the needed 
dependencies for $DISTRO."
+exit 1
+fi
+}
+
+
+function do_Show_Info(){
+echo
+echo '-- Environment --'
+echo "Running on Docker: $DISTRO"
+id
+uname -a
+
+if [[ -n $CC ]]; then
+echo
+echo '-- Compiler in use --'
+"$CC" --version
+fi
+
+echo -en 'travis_fold:start:printenv\r'
+echo '-- Environment Variables --'
+printenv
+echo -en 'travis_fold:end:printenv\r'
+}
+
+
+# --- Build and Test libvirt ---
+
+if [[ -n $IMAGE ]]; then
+# Run docker using the selected image; then build and test
+docker run --privileged --cap-add=ALL -v /lib/modules:/lib/modules \
+  -v "$(pwd)":/cwd -e CC=$CC -e DISTRO=$IMAGE "$IMAGE" sh -e -c " \
+cd /cwd; \
+tests/travis-ci.sh"
+exit $?
+fi
+
+if [[ -n $DISTRO ]]; then
+do_Install_Dependencies
+do_Show_Info
+fi
+
+# Build and test
+if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
+echo -en 'travis_fold:start:autogen\r'
+echo '-- Running ./autogen.sh --'
+# The custom PATH is just to pick up OS-X homebrew
+PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh
+echo -en 'travis_fold:end:autogen\r'
+
+# many unit tests fail & so does syntax-check, so skip for now
+# one day we must fix it though
+make -j3
+else
+echo -en 'travis_fold:start:autogen\r'
+echo '-- Running ./autogen.sh --'
+./autogen.sh
+echo -en 'travis_fold:end:autogen\r'
+
+VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+fi
+
+exit $?
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH V2] CI: also run tests using updated distro(s)

2017-05-31 Thread claudioandre . br
From: Claudio André 

It is possible to test libvirt using other distros in Travis via Docker;
including (but not limited to) Fedora and Ubuntu.
---
See it in action at https://travis-ci.org/claudioandre/libvirt/builds/237687907 

 .travis.yml| 23 ++
 tests/travis-ci.sh | 70 ++
 2 files changed, 83 insertions(+), 10 deletions(-)
 create mode 100755 tests/travis-ci.sh

diff --git a/.travis.yml b/.travis.yml
index 5a3e765..3ed2093 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
 sudo: false
 language: c
 dist: precise
-compiler:
-  - gcc
 cache: ccache
 addons:
   apt:
@@ -62,15 +60,14 @@ git:
 before_install:
   - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install gnutls 
libgcrypt yajl gettext rpcgen ; fi
 
-# the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
-before_script:
-  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh
 script:
-  - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+  - tests/travis-ci.sh
 
 # Environments here are run in addition to the main environment defined above
 matrix:
   include:
+- compiler: gcc
+  dist: precise
 - compiler: clang
   dist: precise
 - compiler: clang
@@ -79,10 +76,16 @@ matrix:
   dist: trusty
 - compiler: clang
   os: osx
-  script:
-# many unit tests fail & so does syntax-check, so skip for now
-# one day we must fix it though
-- make -j3
+- services: docker
+  env: IMAGE=ubuntu:17.04 CCO=gcc
+  dist: trusty
+- services: docker
+  env: IMAGE=ubuntu:17.04 CCO=clang
+  dist: trusty
+
+  allow_failures:
+- env: IMAGE=ubuntu:17.04 CCO=gcc
+- env: IMAGE=ubuntu:17.04 CCO=clang
 
 after_failure:
   - echo 
''
diff --git a/tests/travis-ci.sh b/tests/travis-ci.sh
new file mode 100755
index 000..07ec85d
--- /dev/null
+++ b/tests/travis-ci.sh
@@ -0,0 +1,70 @@
+#!/bin/bash -e
+
+function do_Install_Dependencies(){
+echo
+echo '-- Installing Dependencies --'
+
+apt-get update -qq
+apt-get -y -qq install \
+build-essential git clang autoconf libtool libcmpicppimpl0 gettext 
\
+xsltproc autopoint libxml2-dev libncurses5-dev libreadline-dev \
+zlib1g-dev libgnutls28-dev libgcrypt11-dev libavahi-client-dev 
libsasl2-dev \
+libxen-dev lvm2 libgcrypt11-dev libparted0-dev libdevmapper-dev 
uuid-dev \
+libudev-dev libpciaccess-dev libcap-ng-dev libnl-3-dev 
libnl-route-3-dev \
+libyajl-dev libpcap0.8-dev libnuma-dev libnetcf-dev libaudit-dev \
+libxml2-utils libapparmor-dev dnsmasq-base librbd-dev 
w3c-markup-validator kmod > /dev/null
+}
+
+
+function do_Show_Info(){
+echo
+echo '-- Environment --'
+echo "Running on Docker: $DISTRO"
+id
+uname -a
+}
+
+
+function do_Show_Compiler(){
+
+if [[ -n $CC ]]; then
+echo
+echo '-- Compiler in use --'
+"$CC" --version
+fi
+}
+
+
+# --- Build and Test libvirt ---
+
+if [[ -n $IMAGE ]]; then
+# Run docker using the selected image; then build and test
+docker run --privileged --cap-add=ALL -v /lib/modules:/lib/modules \
+  -v "$(pwd)":/cwd -e CC=$CCO -e DISTRO=$IMAGE "$IMAGE" sh -e -c " \
+cd /cwd; \
+tests/travis-ci.sh"
+exit $?
+fi
+
+if [[ -n $DISTRO ]]; then
+do_Show_Info
+do_Install_Dependencies
+do_Show_Compiler
+fi
+
+echo -en 'travis_fold:start:autogen\r'
+echo '-- Running ./autogen.sh --'
+# The custom PATH is just to pick up OS-X homebrew & its harmless on Linux
+PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh
+echo -en 'travis_fold:end:autogen\r'
+
+# Build and test
+if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
+# many unit tests fail & so does syntax-check, so skip for now
+# one day we must fix it though
+make -j3
+else
+VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+fi
+
+exit $?
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] maint: add sanitizers to the build process

2017-05-30 Thread claudioandre . br
From: Claudio André 

Sanitizers are based on compile-time instrumentation. They are available in gcc 
and clang for a range of supported operation systems and platforms. More info 
at: https://github.com/google/sanitizers

The address sanitizer finds bugs related to addressing memory: use after free, 
heap buffer overflow, stack buffer overflow, memory leaks, ...
The undefined behavior sanitizer detects situations not prescribed by the 
language specification: bound violations, data overflows, ...

The llvm.org states that Sanitizers have found thousands of bugs everywhere.
Sanitizers running during CI can prevent bugs from taking up residence. A 
helper tool to keep bugs out.
---
- I mean CI (in general) not only Travis;
- The functionality is not tied to CI; it is useful for local testing;
- A way to think about this (including the ongoing GSOC):
  - Phase 1: test with Sanitizers to achieve basic code sanity;
  - Phase 2: use fuzzing for stronger security & reliability;
- MISSING: should I add the flag to which Makefile.am? Or, what do you guys 
think about this?

 configure.ac |  2 ++
 m4/virt-compile-sanitizer.m4 | 51 
 2 files changed, 53 insertions(+)
 create mode 100644 m4/virt-compile-sanitizer.m4

diff --git a/configure.ac b/configure.ac
index 246f4e0..4334614 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,6 +237,7 @@ LIBVIRT_COMPILE_WARNINGS
 LIBVIRT_COMPILE_PIE
 LIBVIRT_LINKER_RELRO
 LIBVIRT_LINKER_NO_INDIRECT
+LIBVIRT_COMPILE_SANITIZER
 
 LIBVIRT_ARG_APPARMOR
 LIBVIRT_ARG_ATTR
@@ -1011,6 +1012,7 @@ AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Miscellaneous])
 AC_MSG_NOTICE([])
 LIBVIRT_RESULT_DEBUG
+LIBVIRT_RESULT_SANITIZER
 AC_MSG_NOTICE([   Use -Werror: $enable_werror])
 AC_MSG_NOTICE([ Warning Flags: $WARN_CFLAGS])
 LIBVIRT_RESULT_DTRACE
diff --git a/m4/virt-compile-sanitizer.m4 b/m4/virt-compile-sanitizer.m4
new file mode 100644
index 000..a7cac31
--- /dev/null
+++ b/m4/virt-compile-sanitizer.m4
@@ -0,0 +1,51 @@
+dnl
+dnl Check for support for Sanitizers
+dnl Check for -fsanitize=address and -fsanitize=undefined support
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library.  If not, see
+dnl .
+dnl
+
+AC_DEFUN([LIBVIRT_COMPILE_SANITIZER],[
+LIBVIRT_ARG_ENABLE([ASAN], [Build with address sanitizer support], [no])
+LIBVIRT_ARG_ENABLE([UBSAN], [Build with undefined behavior sanitizer 
support], [no])
+
+SAN_CFLAGS=
+SAN_LDFLAGS=
+
+AS_IF([test "x$enable_asan" = "xyes"], [
+gl_COMPILER_OPTION_IF([-fsanitize=address -fno-omit-frame-pointer], [
+SAN_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
+SAN_LDFLAGS="-fsanitize=address"
+])
+
+AC_SUBST([SAN_CFLAGS])
+AC_SUBST([SAN_LDFLAGS])
+])
+
+AS_IF([test "x$enable_ubsan" = "xyes"], [
+gl_COMPILER_OPTION_IF([-fsanitize=undefined -fno-omit-frame-pointer], [
+SAN_CFLAGS="$SAN_CFLAGS -fsanitize=undefined 
-fno-omit-frame-pointer"
+SAN_LDFLAGS="$SAN_LDFLAGS -fsanitize=undefined"
+])
+
+AC_SUBST([SAN_CFLAGS])
+AC_SUBST([SAN_LDFLAGS])
+])
+])
+
+AC_DEFUN([LIBVIRT_RESULT_SANITIZER], [
+  AC_MSG_NOTICE([  ASan: $enable_asan])
+  AC_MSG_NOTICE([ UBSan: $enable_ubsan])
+])
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] CI: also run tests using updated distro(s)

2017-05-28 Thread claudioandre . br
From: Claudio André 

It is possible to test libvirt using other distros in Travis via Docker; 
including (but not limited to) Fedora and Ubuntu.
---
Notes:
* see it working at: https://travis-ci.org/claudioandre/libvirt/builds/237015534
* now, I introduced an error: 
https://travis-ci.org/claudioandre/libvirt/builds/237018298
* I'm using Ubuntu 17.04 because I need to pick something. Could be Xenial 
and/or Fedora and/or ...;

* One test is failing in Ubuntu 17.04 in Travis. The error log says:
  -
TEST: virkmodtest
  Failed to get config
!... 4   FAIL
FAIL virkmodtest (exit status: 1)
  -
* Since it is failing, I used the 'allow_failures'.

 .travis.yml| 19 +---
 tests/travis-ci.sh | 64 ++
 2 files changed, 75 insertions(+), 8 deletions(-)
 create mode 100755 tests/travis-ci.sh

diff --git a/.travis.yml b/.travis.yml
index 5a3e765..7b73761 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -62,11 +62,8 @@ git:
 before_install:
   - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install gnutls 
libgcrypt yajl gettext rpcgen ; fi
 
-# the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
-before_script:
-  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh
 script:
-  - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+  - tests/travis-ci.sh
 
 # Environments here are run in addition to the main environment defined above
 matrix:
@@ -79,10 +76,16 @@ matrix:
   dist: trusty
 - compiler: clang
   os: osx
-  script:
-# many unit tests fail & so does syntax-check, so skip for now
-# one day we must fix it though
-- make -j3
+- services: docker
+  env: IMAGE=ubuntu:17.04 CCO=gcc
+  dist: trusty
+- services: docker
+  env: IMAGE=ubuntu:17.04 CCO=clang
+  dist: trusty
+
+  allow_failures:
+- env: IMAGE=ubuntu:17.04 CCO=gcc
+- env: IMAGE=ubuntu:17.04 CCO=clang
 
 after_failure:
   - echo 
''
diff --git a/tests/travis-ci.sh b/tests/travis-ci.sh
new file mode 100755
index 000..d115564
--- /dev/null
+++ b/tests/travis-ci.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -e
+
+function do_Install_Dependencies(){
+echo
+echo '-- Installing Dependencies --'
+
+apt-get update -qq
+apt-get -y -qq install \
+build-essential git clang autoconf libtool libcmpicppimpl0 gettext 
\
+xsltproc autopoint libxml2-dev libncurses5-dev libreadline-dev \
+zlib1g-dev libgnutls28-dev libgcrypt11-dev libavahi-client-dev 
libsasl2-dev \
+libxen-dev lvm2 libgcrypt11-dev libparted0-dev libdevmapper-dev 
uuid-dev \
+libudev-dev libpciaccess-dev libcap-ng-dev libnl-3-dev 
libnl-route-3-dev \
+libyajl-dev libpcap0.8-dev libnuma-dev libnetcf-dev libaudit-dev \
+libxml2-utils libapparmor-dev dnsmasq-base librbd-dev 
w3c-markup-validator
+}
+
+
+function do_Show_Info(){
+echo
+echo '-- Environment --'
+echo "Running on Docker: $DISTRO"
+}
+
+
+function do_Show_Compiler(){
+
+if [[ -n $CC ]]; then
+echo
+echo '-- Compiler in use --'
+"$CC" --version
+fi
+}
+
+
+# --- Build and Test libvirt ---
+
+if [[ -n $IMAGE ]]; then
+# Run docker using the selected image; then build and test
+docker run -v "$(pwd)":/cwd -e CC=$CCO -e DISTRO=$IMAGE "$IMAGE" sh -e -c 
" \
+cd /cwd; \
+tests/travis-ci.sh"
+exit $?
+fi
+
+if [[ -n $DISTRO ]]; then
+do_Show_Info
+do_Install_Dependencies
+do_Show_Compiler
+fi
+
+# The custom PATH is just to pick up OS-X homebrew & its harmless on Linux
+PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
+
+# Build and test
+if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
+# many unit tests fail & so does syntax-check, so skip for now
+# one day we must fix it though
+make -j3
+else
+VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+fi
+
+exit $?
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] CI: show the log in case of failure

2017-05-24 Thread claudioandre . br
From: Claudio André 

Disclosure the content of the 'test-suite.log' file (if available) in case of 
failures inside Travis-CI. This is needed to understand what happened and to 
provide hints about the proper fix (if applicable).
---
 .travis.yml | 8 
 1 file changed, 8 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 266..5a3e765 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -83,3 +83,11 @@ matrix:
 # many unit tests fail & so does syntax-check, so skip for now
 # one day we must fix it though
 - make -j3
+
+after_failure:
+  - echo 
''
+  - 'if [ -f $(pwd)/tests/test-suite.log ]; then
+cat $(pwd)/tests/test-suite.log;
+else
+echo "=== NO LOG FILE FOUND ===";
+fi'
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 1/1] CI: add code coverage analysis

2017-05-24 Thread claudioandre . br
From: Claudio André 

It builds the code coverage report and uploads the coverage data to a web 
service in order to allow to track libvirt's code coverage over time.
---
 .travis.yml | 11 ++-
 README.md   |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 266..24b8d6c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,6 +39,7 @@ addons:
   - dnsmasq-base
   - librbd-dev
   - w3c-dtd-xhtml
+  - lcov
 
 notifications:
   irc:
@@ -64,7 +65,8 @@ before_install:
 
 # the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
 before_script:
-  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh
+  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" 
./autogen.sh "$COVERAGE"
+  - gem install coveralls-lcov
 script:
   - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
 
@@ -77,9 +79,16 @@ matrix:
   dist: trusty
 - compiler: gcc
   dist: trusty
+  env: COVERAGE="--enable-test-coverage"
 - compiler: clang
   os: osx
   script:
 # many unit tests fail & so does syntax-check, so skip for now
 # one day we must fix it though
 - make -j3
+
+after_success:
+  - 'if [ -n "${COVERAGE}" ]; then
+make -j3 cov;
+coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage/libvirt.info;
+fi'
diff --git a/README.md b/README.md
index 1035bcf..021f71b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
 [![Build 
Status](https://travis-ci.org/libvirt/libvirt.svg)](https://travis-ci.org/libvirt/libvirt)
+[![Coverage 
Status](https://coveralls.io/repos/github/libvirt/libvirt/badge.svg)](https://coveralls.io/github/libvirt/libvirt)
 
 Libvirt API for virtualization
 ==
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 0/1] Enable code coverage on CI

2017-05-24 Thread claudioandre . br
From: Claudio André 

***  ***
NOTE: In order to add links to demonstrate it working, I'm using a cover letter 
for only 1 patch. Sorry about this!

It is possible to see how it behaves, just access:
- https://gist.github.com/claudioandre/60b262ff8c110133c0a94d5f0ce2362c
- https://coveralls.io/builds/11681156


Claudio André (1):
  CI: add code coverage analysis

 .travis.yml | 11 ++-
 README.md   |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list