diff --git a/.github/workflows/solaris.yml b/.github/workflows/solaris.yml new file mode 100644 index 00000000..d30d67ce --- /dev/null +++ b/.github/workflows/solaris.yml @@ -0,0 +1,47 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT +name: Solaris + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + name: "Solaris Build and Test" + env: + DIST: SOLARIS + BUILD_TYPE: "cmake" + CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=DEBUG -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCMAKE_VERBOSE_MAKEFILE=ON" + CMAKE_TEST_FLAGS: "-DCMAKE_PREFIX_PATH=/usr/local/ -DCARES_BUILD_TESTS=ON -DCMAKE_CXX_FLAGS=-DGTEST_HAS_PTHREAD=0" + TEST_FILTER: "--gtest_filter=-*Live*" + steps: + - uses: actions/checkout@v4 + - name: Solaris Build and Test + id: solaris + uses: vmactions/solaris-vm@v1 + with: + envs: 'DIST BUILD_TYPE CMAKE_FLAGS CMAKE_TEST_FLAGS TEST_FILTER CXXFLAGS' + usesh: true + # package list: http://pkg.oracle.com/solaris/release/en/catalog.shtml + prepare: | + pkg install -v --no-refresh cmake gcc pkg-config gnu-make git + # We have to jump through a lot of hoops with google test. + # - We need to max out at v1.13.x because this solaris VM is old and + # only has cmake 3.9 + # - We have to compile google test ourselves because it isn't available. + # - We have to forcibly compile google test without threading because + # solaris throws an exception for some unknown reason. + # - The forcible threading disablement doesn't appear to propagate to + # proper cflags with compiling c-ares tests so we need to set a + # CXX flag to let google test know it was compiled without threading. + run: | + git clone --depth=1 -b v1.13.x https://github.com/google/googletest googletest + cd googletest + cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_GMOCK=ON -DINSTALL_GTEST=ON -Dgtest_disable_pthreads=ON -DCMAKE_VERBOSE_MAKEFILE=ON . + gmake + gmake install + cd .. + ./ci/build.sh + ./ci/test.sh diff --git a/ci/build.sh b/ci/build.sh index ffd0881d..eb764d12 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT -set -e +set -e -x OS="" if [ "$TRAVIS_OS_NAME" != "" ]; then @@ -30,9 +30,11 @@ if [ "$BUILD_TYPE" = "autotools" -o "$BUILD_TYPE" = "coverage" ]; then $SCAN_WRAP make else # Use cmake for everything else + mkdir cmakebld + cd cmakebld if [ "$DIST" = "iOS" ] ; then CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_OSX_SYSROOT=${SYSROOT}" fi - $SCAN_WRAP cmake ${CMAKE_FLAGS} ${CMAKE_TEST_FLAGS} -Bcmakebld . - $SCAN_WRAP cmake --build cmakebld + $SCAN_WRAP cmake ${CMAKE_FLAGS} ${CMAKE_TEST_FLAGS} .. + $SCAN_WRAP cmake --build . fi diff --git a/ci/distcheck.sh b/ci/distcheck.sh index 39f4db9a..e8b820eb 100755 --- a/ci/distcheck.sh +++ b/ci/distcheck.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT -set -e +set -e -x OS="" if [ "$TRAVIS_OS_NAME" != "" ]; then diff --git a/ci/test.sh b/ci/test.sh index 761a0d8f..9429cbf5 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT -set -e +set -e -x # Travis on MacOS uses CloudFlare's DNS (1.1.1.1/1.0.0.1) which rejects ANY requests. # Also, LiveSearchTXT is known to fail on Cirrus-CI on some MacOS hosts, we don't get diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e397d6e1..8bed6018 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,8 +9,12 @@ ENDIF () find_package(Threads) find_package(GTest REQUIRED) -IF (NOT TARGET GTest::gmock) - Message(FATAL_ERROR "GoogleTest found but the GMock component was not found") +IF (CMAKE_VERSION VERSION_LESS "3.23.0") + Message("GoogleTest found, cmake version too old to verify GMock, look for errors...") +ELSE () + IF (NOT TARGET GTest::gmock) + Message(FATAL_ERROR "GoogleTest found but the GMock component was not found") + ENDIF() ENDIF() # create target to access and use internal cares library @@ -36,8 +40,15 @@ include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) add_executable(arestest ${TESTSOURCES} ${TESTHEADERS}) target_include_directories(arestest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(arestest PRIVATE caresinternal GTest::gmock) - +IF (CMAKE_VERSION VERSION_LESS "3.23.0") + FIND_LIBRARY(LIBGMOCK NAMES gmock PATHS ${GTEST_ROOT} PATH_SUFFIXES lib) + IF (LIBGMOCK-NOTFOUND) + MESSAGE(FATAL_ERROR "Could not find Gmock") + ENDIF () + target_link_libraries(arestest PRIVATE caresinternal GTest::GTest ${LIBGMOCK}) +ELSE () + target_link_libraries(arestest PRIVATE caresinternal GTest::gmock) +ENDIF() target_compile_definitions(arestest PRIVATE CARES_NO_DEPRECATED) IF (CARES_BUILD_CONTAINER_TESTS)