Sat, 16 Apr 2022 14:47:27 +0200
migrate tree tests to gtest
universe@510 | 1 | # Transitional support for CTest written tests |
universe@391 | 2 | message(CHECK_START "Searching for CUnit test framework") |
universe@390 | 3 | |
universe@391 | 4 | find_path(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h) |
universe@391 | 5 | find_library(CUNIT_LIBRARY NAMES cunit libcunit cunitlib) |
universe@391 | 6 | include(FindPackageHandleStandardArgs) |
universe@391 | 7 | find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR) |
universe@391 | 8 | |
universe@510 | 9 | if (CUNIT_FOUND) |
universe@391 | 10 | message(CHECK_PASS "found: compiling tests.") |
universe@391 | 11 | set(TESTS |
universe@413 | 12 | test_list |
universe@391 | 13 | ) |
universe@391 | 14 | |
universe@510 | 15 | foreach (test ${TESTS}) |
universe@510 | 16 | add_executable(${test} ${test}.c) |
universe@391 | 17 | target_link_libraries(${test} PRIVATE ucx_static ${CUNIT_LIBRARY}) |
universe@395 | 18 | target_include_directories(${test} PRIVATE ${CUNIT_INCLUDE_DIR}) |
universe@391 | 19 | add_test(NAME ${test} COMMAND ${test} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") |
universe@510 | 20 | endforeach () |
universe@510 | 21 | else () |
universe@510 | 22 | message(CHECK_FAIL "not found: CUnit tests will not be available.") |
universe@510 | 23 | endif () |
universe@510 | 24 | |
universe@510 | 25 | # Load Google Test Framework |
universe@510 | 26 | set(CMAKE_CXX_STANDARD 11) |
universe@510 | 27 | |
universe@510 | 28 | include(FetchContent) |
universe@510 | 29 | FetchContent_Declare( |
universe@510 | 30 | googletest |
universe@510 | 31 | GIT_REPOSITORY https://github.com/google/googletest.git |
universe@510 | 32 | GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release 1.11.0 |
universe@510 | 33 | ) |
universe@510 | 34 | # For Windows: Prevent overriding the parent project's compiler/linker settings |
universe@510 | 35 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
universe@510 | 36 | FetchContent_MakeAvailable(googletest) |
universe@510 | 37 | include(GoogleTest) |
universe@510 | 38 | message(STATUS "Google Test made available") |
universe@510 | 39 | |
universe@512 | 40 | add_executable(ucxtest |
universe@512 | 41 | test_allocator.cpp |
universe@515 | 42 | test_tree.cpp |
universe@512 | 43 | selftest.cpp |
universe@510 | 44 | ) |
universe@512 | 45 | target_link_libraries(ucxtest PRIVATE ucx_static gtest_main) |
universe@512 | 46 | gtest_discover_tests(ucxtest) |