diff --git a/.travis.yml b/.travis.yml index cbd3963e..c1ab7dfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,13 @@ language: c cache: - pip + - ccache addons: apt: packages: - shellcheck - valgrind - - gcc - - clang - python-docutils - python3-pip - python3-setuptools @@ -19,6 +18,7 @@ addons: - meson - python3-pytest - libglib2.0-dev + - ccache install: test/travis-install.sh @@ -27,5 +27,17 @@ jobs: - name: Lint script: ./test/lint.sh install: skip - - name: Build + Test + - name: Build + Test (clang) + compiler: clang + script: test/travis-build.sh + - name: Build + Test (gcc) + compiler: gcc + script: test/travis-build.sh + - name: Build with sanitizer (undefined) + compiler: clang + env: SANITIZER=undefined + script: test/travis-build.sh + - name: Build with sanitizer (address) + compiler: clang + env: SANITIZER=address script: test/travis-build.sh diff --git a/test/build_test_all.sh b/test/build_test_all.sh new file mode 100755 index 00000000..c0432a61 --- /dev/null +++ b/test/build_test_all.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +CC=gcc test/travis-build.sh +CC=clang test/travis-build.sh +CC=clang SANITIZER=undefined test/travis-build.sh +CC=clang SANITIZER=address test/travis-build.sh diff --git a/test/travis-build.sh b/test/travis-build.sh index aa72cb2c..c2ff36f9 100755 --- a/test/travis-build.sh +++ b/test/travis-build.sh @@ -7,39 +7,31 @@ set -e export ASAN_OPTIONS="detect_leaks=0" export LSAN_OPTIONS="suppressions=${PWD}/test/lsan_suppress.txt" -export CC TEST_CMD="python3 -m pytest --maxfail=99 test/" +build_opts='-D werror=true' + +if [ -n "$SANITIZER" ]; then + build_type=$SANITIZER + build_opts="${build_opts} -D b_sanitize=${SANITIZER}" +else + build_type=$CC + export TEST_WITH_VALGRIND=true +fi + +# b_lundef=false is required to work around clang +# bug, cf. https://groups.google.com/forum/#!topic/mesonbuild/tgEdAXIIdC4 +if [[ "${CC}" == 'gcc-6' || "${CC}" =~ "clang" ]]; then + build_opts="${build_opts} -D b_lundef=false" +fi + # Standard build with Valgrind -for CC in gcc clang; do - ( - mkdir "build-${CC}"; cd "build-${CC}" - if [ "${CC}" == 'gcc-6' ]; then - build_opts='-D b_lundef=false' - else - build_opts='' - fi - # shellcheck disable=SC2086 - meson -D werror=true ${build_opts} ../ - ninja - - TEST_WITH_VALGRIND=true ${TEST_CMD} - ) -done -(cd "build-${CC}"; sudo ninja install) - -# Sanitized build -CC=clang -for san in undefined address; do - ( - mkdir "build-${san}" - cd "build-${san}" - # b_lundef=false is required to work around clang - # bug, cf. https://groups.google.com/forum/#!topic/mesonbuild/tgEdAXIIdC4 - meson -D b_sanitize=${san} -D b_lundef=false -D werror=true .. - ninja - ${TEST_CMD} - sudo ninja install - ) -done +mkdir "build-${build_type}" +cd "build-${build_type}" +#shellcheck disable=SC2086 +meson ${build_opts} .. +ninja + +${TEST_CMD} +sudo ninja install