Add check-failmalloc.sh to test OOM conditions.
[platform/upstream/libexif.git] / .travis.yml
1 # Travis CI configuration file
2
3 sudo: false
4
5 language: c
6
7 git:
8   depth: 1
9
10 # Install autopoint on Ubuntu (needed for gettext)
11 addons:
12   apt:
13     packages:
14     - autopoint
15
16 env:
17   # More configurations are configured in the matrix section
18   matrix:
19     - CONFIG=normal
20     - CONFIG=c90
21     - CONFIG=stackprotect
22   global:
23     - MAKEFLAGS='-j 2'
24
25 compiler:
26   - clang
27   - gcc
28
29 os:
30   - linux
31   - osx
32
33 matrix:
34   include:
35   - os: linux
36     addons:
37       apt:
38         sources:
39           - llvm-toolchain-trusty-6.0
40           - ubuntu-toolchain-r-test
41         packages:
42           - autopoint
43           - clang-6.0
44     compiler: clang
45     env:
46       - CONFIG=clang6
47   - os: linux
48     addons:
49       apt:
50         sources:
51           - ubuntu-toolchain-r-test
52         packages:
53           - autopoint
54           - g++-8
55     compiler: gcc
56     env:
57       - CONFIG=gcc8
58   - os: linux
59     addons:
60       apt:
61         sources:
62           - llvm-toolchain-trusty-6.0
63           - ubuntu-toolchain-r-test
64         packages:
65           - autopoint
66           - clang-6.0
67           - libtool
68     compiler: clang
69     # Required for -fsanitize=undefined
70     # see https://github.com/travis-ci/travis-ci/issues/9033
71     sudo: required
72     env:
73       - CONFIG=sanitize
74   - os: linux
75     addons:
76       apt:
77         packages:
78           - autopoint
79           - libpopt-dev
80           - subversion
81     compiler: gcc
82     cache:
83       directories:
84         - $HOME/failmalloc
85     env:
86       - CONFIG=coverage
87
88 install:
89   - |
90     if [ "$CONFIG" = "coverage" ] ; then
91       set -e
92       pip install --user cpp-coveralls
93       cd "$HOME"
94       git clone --depth=1 https://github.com/libexif/libexif-testsuite.git
95       cd libexif-testsuite
96       mkdir src
97       ln -s "$TRAVIS_BUILD_DIR" src/libexif
98       ./build-config.sh
99       autoreconf -sivf
100       cd "$HOME"
101       # Failmalloc for improved test coverage
102       if [ ! -e "$HOME/failmalloc/lib/libfailmalloc.so.0" ] ; then
103         curl -fsSORL https://download.savannah.nongnu.org/releases/failmalloc/failmalloc-1.0.tar.gz
104         tar xaf failmalloc-1.0.tar.gz
105         cd failmalloc-1.0
106         sed -i -e 's/\(__malloc_initialize_hook\)/volatile \1/' failmalloc.c
107         ./configure --prefix="$HOME/failmalloc"
108         make
109         make install
110       fi
111       cd "$TRAVIS_BUILD_DIR"
112     fi
113
114 script:
115   # Ensure brew gettext is in the PATH so autopoint is found on OS X
116   - PATH="$PATH:/usr/local/opt/gettext/bin" autoreconf -sivf
117   - if [ "$CONFIG" = "normal" ] ; then CFLAGS='-Wall -Wextra -O3'; fi
118   - if [ "$CONFIG" = "c90" ] ; then CFLAGS='-std=iso9899:1990 -D_XOPEN_SOURCE=500 -Wall -Wextra -O3'; fi
119   - if [ "$CONFIG" = "stackprotect" ] ; then CFLAGS='-g -O0 -fstack-protector-all'; fi
120   - if [ "$CONFIG" = "clang6" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=clang-6.0; fi
121   - if [ "$CONFIG" = "gcc8" ] ; then CFLAGS='-Wall -Wextra -O3'; export export CC=gcc-8; fi
122   - if [ "$CONFIG" = "sanitize" ] ; then CFLAGS='-g -Wall -Wextra -fsanitize=address -fsanitize=undefined'; export CC=clang-6.0; fi
123   - if [ "$CONFIG" = "coverage" ] ; then cd "$HOME"/libexif-testsuite; CFLAGS=--coverage; CONFIGURE_OPTS="LDFLAGS=--coverage --with-failmalloc=$HOME/failmalloc/lib" ; fi
124   - ./configure --prefix="${HOME}"/install CFLAGS="$CFLAGS" $CONFIGURE_OPTS || { tail -300 config.log; false; }
125   - make V=1
126   - make V=1 check || { tail -300 test*/test-suite.log; false; }
127   - make V=1 install
128   - if [ "$CONFIG" = "coverage" ] ; then cd "$TRAVIS_BUILD_DIR"; fi
129
130 after_success:
131   - if [ "$CONFIG" = "coverage" ] ; then coveralls --build-root libexif --exclude test --exclude contrib --gcov-options '\-lp'; fi