From 2e1ac7cd0937fb7b12ff790d7b7d280cc919f485 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Mon, 10 Feb 2025 16:33:48 +0100 Subject: [PATCH] [ci][linux] build unit tests using gtest from apt Signed-off-by: Vitalii Koshura --- .github/workflows/linux.yml | 7 ++++++- 3rdParty/buildLinuxDependencies.sh | 10 +--------- tests/unit-tests/CMakeLists.txt | 5 +---- tests/unit-tests/lib/CMakeLists.txt | 2 +- tests/unit-tests/sched/CMakeLists.txt | 2 +- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cea0cc49cb5..09144259b26 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -57,6 +57,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: | @@ -132,7 +137,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') diff --git a/3rdParty/buildLinuxDependencies.sh b/3rdParty/buildLinuxDependencies.sh index 382e90250a1..fbdd6ae99f8 100755 --- a/3rdParty/buildLinuxDependencies.sh +++ b/3rdParty/buildLinuxDependencies.sh @@ -51,7 +51,6 @@ ROOTDIR=$(pwd) cache_dir="" doclean="" wxoption="" -gtest_only="" build_config="Release" while [[ $# -gt 0 ]]; do key="$1" @@ -70,9 +69,6 @@ while [[ $# -gt 0 ]]; do --disable-webview) wxoption="--disable-webview ${wxoption} " ;; - --gtest-only) - gtest_only="yes" - ;; *) echo "unrecognized option $key" ;; @@ -139,11 +135,7 @@ fi wx_ver="3.2.0" #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 diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 7fbc12c7354..bfaf4e9114d 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -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 @@ -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) diff --git a/tests/unit-tests/lib/CMakeLists.txt b/tests/unit-tests/lib/CMakeLists.txt index d681555765d..22ed03674b7 100644 --- a/tests/unit-tests/lib/CMakeLists.txt +++ b/tests/unit-tests/lib/CMakeLists.txt @@ -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) diff --git a/tests/unit-tests/sched/CMakeLists.txt b/tests/unit-tests/sched/CMakeLists.txt index bb15e0376d2..68d99042d70 100644 --- a/tests/unit-tests/sched/CMakeLists.txt +++ b/tests/unit-tests/sched/CMakeLists.txt @@ -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)