Skip to content

Commit

Permalink
Merge pull request #6069 from BOINC/vko_use_gtest_from_apt
Browse files Browse the repository at this point in the history
[ci][linux] build unit tests using gtest from apt
  • Loading branch information
AenBleidd authored Feb 11, 2025
2 parents 0bbd737 + 2e1ac7c commit 29f2e86
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ jobs:
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Install dependencies for unit testing
if: success() && matrix.type == 'unit-test'
run: |
sudo apt-get install -y libgtest-dev
- name: Install dependencies for integration testing
if: success() && matrix.type == 'integration-test'
run: |
Expand Down Expand Up @@ -141,7 +146,7 @@ jobs:

- name: Configure server for unit testing
if: success() && matrix.type == 'unit-test'
run: ./3rdParty/buildLinuxDependencies.sh --gtest-only && ./configure --disable-client --disable-manager --enable-unit-tests CFLAGS="-g -O0" CXXFLAGS="-g -O0"
run: ./configure --disable-client --disable-manager --enable-unit-tests CFLAGS="-g -O0" CXXFLAGS="-g -O0"

- name: Make
if: success() && ! contains(matrix.type, 'integration-test') && ! endsWith(matrix.type, 'cmake') && ! endsWith(matrix.type, 'arm64')
Expand Down
10 changes: 1 addition & 9 deletions 3rdParty/buildLinuxDependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ ROOTDIR=$(pwd)
cache_dir=""
doclean=""
wxoption=""
gtest_only=""
build_config="Release"
while [[ $# -gt 0 ]]; do
key="$1"
Expand All @@ -70,9 +69,6 @@ while [[ $# -gt 0 ]]; do
--disable-webview)
wxoption="--disable-webview ${wxoption} "
;;
--gtest-only)
gtest_only="yes"
;;
*)
echo "unrecognized option $key"
;;
Expand Down Expand Up @@ -139,11 +135,7 @@ fi

wx_ver="3.2.6"
#download_and_build $DIRNAME $FILENAME $DOWNLOADURL $BUILDSCRIPT
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-$wx_ver" "wxWidgets-$wx_ver.tar.bz2" "https://github.com/wxWidgets/wxWidgets/releases/download/v$wx_ver/wxWidgets-$wx_ver.tar.bz2" "${ROOTDIR}/3rdParty/buildWxLinux.sh ${wxoption}"
fi
download_and_build "wxWidgets-$wx_ver" "wxWidgets-$wx_ver.tar.bz2" "https://github.com/wxWidgets/wxWidgets/releases/download/v$wx_ver/wxWidgets-$wx_ver.tar.bz2" "${ROOTDIR}/3rdParty/buildWxLinux.sh ${wxoption}"

# change back to root directory
cd ${ROOTDIR} || exit 1
5 changes: 1 addition & 4 deletions tests/unit-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set (CMAKE_CXX_FLAGS "-g -Wall -Wextra -Werror --coverage")


find_package(Threads REQUIRED)
find_package(GTest REQUIRED)

# There is no easy way to interface with the autotools driven build system in boinc
# so the paths below are hardcoded and are mainly suited for building on Travis CI
Expand All @@ -24,10 +25,6 @@ include_directories("/usr/include/mariadb/mysql")
include_directories("/usr/include/mysql")


find_library(GTEST_MAIN_LIB libgtest_main.a PATHS ${PROJECT_SOURCE_DIR}/../../3rdParty/buildCache/linux/lib NO_DEFAULT_PATH)
message(STATUS "gtest_main_lib: ${GTEST_MAIN_LIB}")
find_library(GTEST_LIB gtest PATHS ${PROJECT_SOURCE_DIR}/../../3rdParty/buildCache/linux/lib NO_DEFAULT_PATH)
message(STATUS "gtest_lib: ${GTEST_LIB}")
find_library(SCHED_LIB libsched.a PATHS ${PROJECT_SOURCE_DIR}/../../sched NO_DEFAULT_PATH)
find_library(BOINC_CRYPT_LIB libboinc_crypt.a PATHS ${PROJECT_SOURCE_DIR}/../../lib NO_DEFAULT_PATH)
find_library(BOINC_LIB libboinc.a PATHS ${PROJECT_SOURCE_DIR}/../../lib NO_DEFAULT_PATH)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ file(GLOB SRCS *.cpp)

add_executable(test_lib ${SRCS})

TARGET_LINK_LIBRARIES(test_lib "${GTEST_LIB}" "${SCHED_LIB}" "${BOINC_CRYPT_LIB}" "${BOINC_LIB}" "${GTEST_MAIN_LIB}" pthread)
TARGET_LINK_LIBRARIES(test_lib "${SCHED_LIB}" "${BOINC_CRYPT_LIB}" "${BOINC_LIB}" pthread GTest::gtest GTest::gtest_main)

add_test(NAME test_lib COMMAND test_lib)
2 changes: 1 addition & 1 deletion tests/unit-tests/sched/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ add_executable(test_sched ${SRCS})

TARGET_COMPILE_OPTIONS(test_sched PUBLIC ${MYSQL_CFLAGS})

TARGET_LINK_LIBRARIES(test_sched "${GTEST_LIB}" "${SCHED_LIB}" "${BOINC_CRYPT_LIB}" "${BOINC_LIB}" ${MYSQL_LIB} "${GTEST_MAIN_LIB}" pthread)
TARGET_LINK_LIBRARIES(test_sched "${SCHED_LIB}" "${BOINC_CRYPT_LIB}" "${BOINC_LIB}" ${MYSQL_LIB} pthread GTest::gtest GTest::gtest_main)

add_test(NAME test_sched COMMAND test_sched)

0 comments on commit 29f2e86

Please sign in to comment.