Skip to content
forked from BOINC/boinc

Commit

Permalink
Merge pull request BOINC#3107 from BOINC/cb_gtest_integration_ci
Browse files Browse the repository at this point in the history
Tests: add unit testing framework using googletest
  • Loading branch information
Uplinger authored May 2, 2019
2 parents 54ab49e + 1cff493 commit 8ad746e
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 41 deletions.
16 changes: 16 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
codecov:
notify:
require_ci_to_pass: yes

comment:
layout: "diff, files"
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: no # [yes :: must have a base report to post]
require_head: yes # [yes :: must have a head report to post]

# don't gather statistics for tets and external libraries
ignore:
- tests/.*
- zip/.*
- 3rdParty/.*
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ locale/*/*.flag
.libs/
svn_version.h

## code coverage
*.gcov
*.gcno
*.gcda

# list of executables
apps/1sec
apps/concat
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ matrix:
- build-tools-28.0.3
- android-28
- extra-google-m2repository
- extra-android-m2repository
- extra-android-m2repository
env: BOINC_TYPE=manager-android

before_install:
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then ( sudo apt-get -qq update ) fi
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then ( sudo apt-get install -y freeglut3-dev libxmu-dev libxi-dev libfcgi-dev libxss-dev libnotify-dev libxcb-util0-dev libsqlite3-dev libgtk2.0-dev libwebkitgtk-dev mingw-w64 binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 realpath p7zip-full ) fi
- if [[ "${TRAVIS_OS_NAME}" == "linux" && "${BOINC_TYPE}" == "unit-test" ]]; then ( sudo pip install codecov ) fi
- if [[ "${BOINC_TYPE}" == "integration-test" ]]; then ( sudo apt-get install ansible/trusty-backports; sudo service mysql stop; ) fi

before_script:
Expand All @@ -80,7 +81,7 @@ script:
- if [[ "${BOINC_TYPE}" == "apps-mingw" ]]; then ( cd lib && MINGW=x86_64-w64-mingw32 make -f Makefile.mingw wrapper ) fi
- if [[ "${BOINC_TYPE}" == "manager-osx" ]]; then ( ./3rdParty/buildMacDependencies.sh -q && ./mac_build/buildMacBOINC-CI.sh --no_shared_headers ) fi
- if [[ "${BOINC_TYPE}" == "manager-android" ]]; then ( cd android && ./buildAndroidBOINC-CI.sh --arch arm --silent && ./buildAndroidBOINC-CI.sh --arch arm64 --silent && ./buildAndroidBOINC-CI.sh --arch x86 --silent && ./buildAndroidBOINC-CI.sh --arch x86_64 --silent && cd BOINC && ./gradlew assemble -w && cd ../../ ) fi
- if [[ "${BOINC_TYPE}" == "unit-test" ]]; then ( /bin/true ) fi
- if [[ "${BOINC_TYPE}" == "unit-test" ]]; then ( ./3rdParty/buildLinuxDependencies.sh --gtest-only && ./configure --disable-client --disable-manager --enable-unit-tests CFLAGS="-g -O0" CXXFLAGS="-g -O0" && make && ./tests/executeUnitTests.sh --report-coverage ) fi
- if [[ "${BOINC_TYPE}" == "integration-test" ]]; then ( ./integration_test/executeTestSuite.sh ) fi

after_success:
Expand Down
67 changes: 67 additions & 0 deletions 3rdParty/buildGoogletestLinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# This file is part of BOINC.
# http://boinc.berkeley.edu
# Copyright (C) 2019 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.

# Script to build a googletest library for BOINC

# Usage:
# cd [path]/googletest-release-1.8.1/
# source path_to_this_script [--clean] [--prefix PATH]
#
# the --clean argument will force a full rebuild.
# if --prefix is given as absolute path the library is installed into there

doclean=""
debug_flag=""
lprefix=""
cmdline_prefix=""
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-clean|--clean)
doclean="yes"
;;
-prefix|--prefix)
lprefix="$2"
cmdline_prefix="--prefix=${lprefix}"
shift
;;
esac
shift # past argument or value
done

cd googletest
autoreconf -i -f
if [ $? -ne 0 ]; then cd ..; return 1; fi
./configure "${cmdline_prefix}"
if [ $? -ne 0 ]; then cd ..; return 1; fi
if [ "${doclean}" = "yes" ]; then
make clean
fi
make
if [ $? -ne 0 ]; then cd ..; return 1; fi

# make install is not supported so copy files manually
if [ "x${lprefix}" != "x" ]; then
mkdir -p ${lprefix}/lib ${lprefix}/include ${lprefix}/bin
(cp -r lib/.libs/*.a ${lprefix}/lib && cp -r include/gtest ${lprefix}/include && cp scripts/gtest-config ${lprefix}/bin)
if [ $? -ne 0 ]; then cd ..; return 1; fi
fi

cd ..
return 0
12 changes: 10 additions & 2 deletions 3rdParty/buildLinuxDependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This file is part of BOINC.
# http://boinc.berkeley.edu
# Copyright (C) 2017 University of California
# Copyright (C) 2019 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -51,6 +51,7 @@ ROOTDIR=$(pwd)
cache_dir=""
doclean=""
wxoption=""
gtest_only=""
build_config="Release"
while [[ $# -gt 0 ]]; do
key="$1"
Expand All @@ -69,6 +70,9 @@ while [[ $# -gt 0 ]]; do
--disable-webview)
wxoption="--disable-webview ${wxoption} "
;;
--gtest-only)
gtest_only="yes"
;;
*)
echo "unrecognized option $key"
;;
Expand Down Expand Up @@ -134,7 +138,11 @@ if [ "${doclean}" = "yes" ]; then
fi

#download_and_build $DIRNAME $FILENAME $DOWNLOADURL $BUILDSCRIPT
download_and_build "wxWidgets-3.0.2" "wxWidgets-3.0.2.tar.bz2" "https://sourceforge.net/projects/wxwindows/files/3.0.2/wxWidgets-3.0.2.tar.bz2" "${ROOTDIR}/3rdParty/buildWxLinux.sh ${wxoption}"
if [ "${gtest_only}" = "yes" ]; then
download_and_build "googletest-release-1.8.1" "release-1.8.1.tar.gz" "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" "${ROOTDIR}/3rdParty/buildGoogletestLinux.sh"
else
download_and_build "wxWidgets-3.0.2" "wxWidgets-3.0.2.tar.bz2" "https://sourceforge.net/projects/wxwindows/files/3.0.2/wxWidgets-3.0.2.tar.bz2" "${ROOTDIR}/3rdParty/buildWxLinux.sh ${wxoption}"
fi

# change back to root directory
cd ${ROOTDIR} || exit 1
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ svn_version.h: generate_svn_version.sh
# Add a stage target for staging a distribution

clean-generic:
rm -rf stage
rm -rf stage *.gcov

stage: all
if [ ! -d stage ] ; then mkdir stage ; fi
Expand Down
30 changes: 22 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ AC_ARG_ENABLE(apps,
[enable_apps=${enableval}],
[enable_apps=no])

AC_ARG_ENABLE(unit-tests,
AS_HELP_STRING([--enable-unit-tests],
[enable building the boinc unit tests]),
[enable_unit_tests=${enableval}],
[enable_unit_tests=no])

AC_ARG_ENABLE(pkg-libs,
AS_HELP_STRING([--enable-pkg-libs],
[Builds and installs components that would be present in a
Expand All @@ -139,8 +145,9 @@ AC_ARG_ENABLE(pkg-libs,
enable_manager=no
enable_install_headers=no
enable_static=no
enable_boinczip=yes
enable_apps=no
enable_boinczip=yes
enable_apps=no
enable_unit_tests=no
],
[])

Expand All @@ -156,8 +163,9 @@ AC_ARG_ENABLE(pkg-devel,
enable_client=no
enable_manager=no
enable_install_headers=yes
enable_boinczip=yes
enable_apps=no
enable_boinczip=yes
enable_apps=no
enable_unit_tests=no
],
[])

Expand All @@ -173,8 +181,9 @@ AC_ARG_ENABLE(pkg-client,
enable_client=yes
enable_manager=no
enable_install_headers=no
enable_boinczip=no
enable_apps=no
enable_boinczip=no
enable_apps=no
enable_unit_tests=no
],
[])

Expand All @@ -188,8 +197,9 @@ AC_ARG_ENABLE(pkg-manager,
enable_client=no
enable_manager=yes
enable_install_headers=no
enable_boinczip=no
enable_apps=no
enable_boinczip=no
enable_apps=no
enable_unit_tests=no
],
[])

Expand All @@ -213,6 +223,9 @@ fi
if test x$enable_apps = xyes ; then
configured_to_build="${configured_to_build} apps"
fi
if test x$enable_unit_tests = xyes ; then
configured_to_build="${configured_to_build} unit-tests"
fi

if test -z "${configured_to_build}" ; then
AC_MSG_ERROR([
Expand Down Expand Up @@ -1049,6 +1062,7 @@ AM_CONDITIONAL(ENABLE_MANAGER, [ test "x${ac_cv_have_wxwidgets}" = xyes -a "${en
AM_CONDITIONAL(ENABLE_LIBRARIES, [test "${enable_libraries}" = yes])
AM_CONDITIONAL(ENABLE_BOINCZIP, [test "${enable_boinczip}" = yes])
AM_CONDITIONAL(ENABLE_APPS, [test "${enable_apps}" = yes])
AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "${enable_unit_tests}" = yes])
AM_CONDITIONAL(ENABLE_BOINCCRYPT, [test "x${enable_server}" = xyes || test "x${enable_client}" = xyes ])
AM_CONDITIONAL(INSTALL_HEADERS, [test "${enable_install_headers}" = yes])
AM_CONDITIONAL(HAVE_CUDA_LIB, [test "${enable_client}" = yes -a -f ./coprocs/CUDA/posix/${boinc_platform}/libcudart.so])
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ $(LIBBOINC_FCGI_STATIC): libboinc_fcgi.la
$(LN) .libs/$(LIBBOINC_FCGI_STATIC) .

clean: clean-am
rm -f $(LIBBOINC_STATIC) $(LIBBOINC_CRYPT_STATIC) $(LIBBOINC_FCGI_STATIC)
rm -f $(LIBBOINC_STATIC) $(LIBBOINC_CRYPT_STATIC) $(LIBBOINC_FCGI_STATIC) *.gcno *.gcda *.gcov

endif
# end of "if ENABLE_LIBRARIES"
Expand Down
53 changes: 30 additions & 23 deletions m4/boinc_set_compile_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ AC_DEFUN([BOINC_SET_COMPILE_FLAGS],[
dnl This function sets the compiler flags depending upon options
dnl set on the configure command line.
AC_ARG_ENABLE(debug,
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[enable tracing and debugging flags for all components]),
[enable_debug="$enableval"],
[])
AC_ARG_ENABLE(optimize,
AC_ARG_ENABLE(optimize,
AS_HELP_STRING([--enable-optimize],
[enable optimization flags for all components]),
[enable_optimize="$enableval"],
[])
AC_ARG_ENABLE(generic-processor,
AC_ARG_ENABLE(generic-processor,
AS_HELP_STRING([--enable-generic-processor],
[build for a generic processor rather than a specific instruction set]),
[enable_generic_processor="$enableval"],
Expand All @@ -34,7 +34,7 @@ if test x${enable_debug} = xyes ; then
BOINC_CHECK_LDFLAG(-g)
CXXFLAGS="$CXXFLAGS -DDEBUG -D_DEBUG"
CFLAGS="$CFLAGS -DDEBUG -D_DEBUG"
fi
fi
if test x${enable_optimize} = xyes ; then
if test x${ac_cv_c_compiler_gnu} = xyes ; then
Expand All @@ -49,17 +49,17 @@ if test x${enable_optimize} = xyes ; then
BOINC_CHECK_CXXFLAG(-fast)
fi
BOINC_CHECK_CXXFLAG(-O3)
fi
fi
if test x${enable_generic_processor} = xyes ; then
case ${target} in
i*86-*-darwin*)
i*86-*-darwin*)
BOINC_CHECK_CFLAG(-march=pentium4)
BOINC_CHECK_CFLAG(-mtune=prescott)
BOINC_CHECK_CXXFLAG(-march=pentium4)
BOINC_CHECK_CXXFLAG(-mtune=prescott)
;;
i*86-*)
i*86-*)
dnl gcc
if test x${ac_cv_c_compiler_gnu} = xyes ; then
BOINC_CHECK_CFLAG(-march=i486)
Expand All @@ -78,43 +78,50 @@ if test x${enable_generic_processor} = xyes ; then
BOINC_CHECK_CXXFLAG(-3)
fi
;;
x86_64-*|amd64-*)
x86_64-*|amd64-*)
dnl gcc
if test x${ac_cv_c_compiler_gnu} = xyes ; then
BOINC_CHECK_CFLAG(-msse2)
BOINC_CHECK_CFLAG(-march=opteron)
BOINC_CHECK_CFLAG(-mtune=generic)
BOINC_CHECK_CFLAG(-msse2)
BOINC_CHECK_CFLAG(-march=opteron)
BOINC_CHECK_CFLAG(-mtune=generic)
else
BOINC_CHECK_CFLAG(-xarch=amd64)
BOINC_CHECK_CFLAG(-xarch=amd64)
fi
if test x${ac_cv_cxx_compiler_gnu} = xyes ; then
BOINC_CHECK_CXXFLAG(-msse2)
BOINC_CHECK_CXXFLAG(-march=opteron)
BOINC_CHECK_CXXFLAG(-mtune=generic)
BOINC_CHECK_CXXFLAG(-msse2)
BOINC_CHECK_CXXFLAG(-march=opteron)
BOINC_CHECK_CXXFLAG(-mtune=generic)
else
BOINC_CHECK_CXXFLAG(-xarch=amd64)
fi
;;
sparc-*)
dnl gcc
if test x${ac_cv_c_compiler_gnu} = xyes ; then
BOINC_CHECK_CFLAG(-march=v8)
BOINC_CHECK_CFLAG(-mcpu=v8)
BOINC_CHECK_CFLAG(-mtune=ultrasparc)
BOINC_CHECK_CFLAG(-march=v8)
BOINC_CHECK_CFLAG(-mcpu=v8)
BOINC_CHECK_CFLAG(-mtune=ultrasparc)
else
dnl Studio 10
BOINC_CHECK_CFLAG(-xarch=v8)
BOINC_CHECK_CFLAG(-xarch=v8)
fi
if test x${ac_cv_cxx_compiler_gnu} = xyes ; then
BOINC_CHECK_CXXFLAG(-march=v8)
BOINC_CHECK_CXXFLAG(-mcpu=v8)
BOINC_CHECK_CXXFLAG(-mtune=ultrasparc)
BOINC_CHECK_CXXFLAG(-march=v8)
BOINC_CHECK_CXXFLAG(-mcpu=v8)
BOINC_CHECK_CXXFLAG(-mtune=ultrasparc)
else
BOINC_CHECK_CXXFLAG(-xarch=v8)
BOINC_CHECK_CXXFLAG(-xarch=v8)
fi
;;
*)
;;
esac
fi
if test x${enable_unit_tests} = xyes ; then
BOINC_CHECK_CFLAG(--coverage)
BOINC_CHECK_CXXFLAG(--coverage)
LDFLAGS="$LDFLAGS --coverage"
fi
])
Loading

0 comments on commit 8ad746e

Please sign in to comment.