Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
219 lines (194 sloc) 7.93 KB
# Test configuration for Travis CI. See <https://travis-ci.org/>.
language: cpp
branches:
except:
- gh-pages
matrix:
include:
- os: osx
compiler: clang
- os: linux
dist: xenial
compiler: clang
- os: linux
dist: xenial
addons:
apt:
packages:
- g++-5
- g++-5-multilib
sources: &sources
- ubuntu-toolchain-r-test
env:
- COMPILERS="CC=gcc-5 && CXX=g++-5"
- os: linux
dist: xenial
addons:
apt:
packages:
- g++-6
- g++-6-multilib
sources: &sources
- ubuntu-toolchain-r-test
env:
- COMPILERS="CC=gcc-6 && CXX=g++-6"
- os: linux
dist: xenial
addons:
apt:
packages:
- g++-7
- g++-7-multilib
sources: &sources
- ubuntu-toolchain-r-test
env:
- COMPILERS="CC=gcc-7 && CXX=g++-7"
- os: linux
dist: xenial
addons:
apt:
packages:
- g++-8
- g++-8-multilib
sources: &sources
- ubuntu-toolchain-r-test
env:
- COMPILERS="CC=gcc-8 && CXX=g++-8"
- os: linux
dist: xenial
addons:
apt:
packages:
- mingw-w64
env:
- COMPILERS="CC=x86_64-w64-mingw32-gcc-posix && CXX=x86_64-w64-mingw32-g++-posix"
env:
global:
- CXXFLAGS="-O3 -Wall -Wextra -Werror -pedantic -Wno-missing-braces"
- CFLAGS="-O3 -Wall -Wextra -Werror -pedantic -Wno-missing-braces"
- SANITIZER_FLAGS="-O1 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
before_install:
# Overwrite default CC and CXX
- eval "${COMPILERS}"
install:
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]
then
sudo apt-get install -y g++-multilib make cmake ninja-build cppcheck doxygen \
doxygen-latex help2man graphviz libqt4-dev qt4-qmake valgrind
fi
script:
- |
if [ "$CXX" = "x86_64-w64-mingw32-g++-posix" ]
then
# 1) Test MinGW/GCC compilation
mkdir build
cd build
cmake .. -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_C_FLAGS="$CFLAGS -Wno-format" \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON
make -j4 VERBOSE=1
elif [ "${TRAVIS_OS_NAME}" = "linux" ]
then
# 1) Build using GNU make
mkdir build
cd build
cmake .. -DBUILD_EXAMPLES=ON \
-DBUILD_TESTS=ON \
-DBUILD_DOC=ON \
-DCMAKE_INSTALL_PREFIX=$(pwd)
make -j4 VERBOSE=1
make doc >/dev/null
make install
# 2) Test printing primes and prime k-tuplets
if [ "$(./primesieve 1e8 -p | md5sum | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p2 | md5sum | cut -f1 -d' ')" != "5076d235d5b03389034ec107227eab98" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p3 | md5sum | cut -f1 -d' ')" != "1b40d7e67868ccc857df11c3e0f7e0f5" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p4 | md5sum | cut -f1 -d' ')" != "b998d7cdbeae6623cdecba1b921cb2e1" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p5 | md5sum | cut -f1 -d' ')" != "1ec7d5704d7399caf43667090b5bf836" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p6 | md5sum | cut -f1 -d' ')" != "0fb813d345c94cf2012588d1f71328b5" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p | md5sum | cut -f1 -d' ')" != "5fbe254a97ad3bbc07c224908c9d59b2" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p2 | md5sum | cut -f1 -d' ')" != "7a7a770c1841a17a9a63b92b7b6532b9" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p3 | md5sum | cut -f1 -d' ')" != "72323b08c62ad8342f7331e3d6d45a64" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p4 | md5sum | cut -f1 -d' ')" != "c2b0818499f77aa35681db3826caf3f6" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p5 | md5sum | cut -f1 -d' ')" != "11b50e4f75899891a62465f6d68fb76e" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p6 | md5sum | cut -f1 -d' ')" != "5a0bc83fdef0bb116d60f356adfde52f" ]; then exit 1; fi
# 3) Build primesieve GUI app using Qt
cd ..
rm -rf build
cd src/gui
qmake QMAKE_CXX=$CXX QMAKE_CC=$CC
make -j4
# 4) Build using ninja
cd ../..
mkdir build
cd build
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_EXAMPLES=ON \
-DBUILD_TESTS=ON \
-DBUILD_DOC=ON
ninja -v
ninja doc >/dev/null
# 5) Run test suite
ninja test
test/cpu_info
# 6) Test using valgrind
valgrind --error-exitcode=1 ./primesieve 1e10
valgrind --error-exitcode=1 ./primesieve 1e9 --nth-prime
valgrind --error-exitcode=1 ./primesieve 1e13 --dist=1e9 --size=32 --print=6
# 7) Test using cppcheck
cd ..
rm -rf build
cppcheck . -q \
--error-exitcode=1 \
-iexamples/cpp/prev_prime.cpp \
-iexamples/cpp/primesieve_iterator.cpp \
-itest/move_primesieve_iterator.cpp \
-itest/next_prime1.cpp \
-itest/prev_prime1.cpp
# 8) Test 32-bit
mkdir build
cd build
cmake .. -DCMAKE_C_FLAGS="$CFLAGS -m32 -Wno-long-long" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS -m32 -Wno-long-long" \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON
make -j4 VERBOSE=1
make test
elif [ "${TRAVIS_OS_NAME}" = "osx" ]
then
# 1) Build using GNU make
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="$SANITIZER_FLAGS" \
-DCMAKE_C_FLAGS="$SANITIZER_FLAGS" \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_EXAMPLES=ON \
-DBUILD_TESTS=ON
make -j4 VERBOSE=1
# 2) Run test suite (using sanitizers)
make test
# 3) Run primesieve (using sanitizers)
./primesieve 1e10
./primesieve 1e9 --nth-prime
./primesieve 1e13 --dist=1e9 --size=32 --print=6
# 4) Test printing primes and prime k-tuplets
if [ "$(./primesieve 1e8 -p | md5 | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p2 | md5 | cut -f1 -d' ')" != "5076d235d5b03389034ec107227eab98" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p3 | md5 | cut -f1 -d' ')" != "1b40d7e67868ccc857df11c3e0f7e0f5" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p4 | md5 | cut -f1 -d' ')" != "b998d7cdbeae6623cdecba1b921cb2e1" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p5 | md5 | cut -f1 -d' ')" != "1ec7d5704d7399caf43667090b5bf836" ]; then exit 1; fi
if [ "$(./primesieve 1e8 -p6 | md5 | cut -f1 -d' ')" != "0fb813d345c94cf2012588d1f71328b5" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p | md5 | cut -f1 -d' ')" != "5fbe254a97ad3bbc07c224908c9d59b2" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p2 | md5 | cut -f1 -d' ')" != "7a7a770c1841a17a9a63b92b7b6532b9" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p3 | md5 | cut -f1 -d' ')" != "72323b08c62ad8342f7331e3d6d45a64" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p4 | md5 | cut -f1 -d' ')" != "c2b0818499f77aa35681db3826caf3f6" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p5 | md5 | cut -f1 -d' ')" != "11b50e4f75899891a62465f6d68fb76e" ]; then exit 1; fi
if [ "$(./primesieve 1e10 -d1e8 -p6 | md5 | cut -f1 -d' ')" != "5a0bc83fdef0bb116d60f356adfde52f" ]; then exit 1; fi
fi
You can’t perform that action at this time.