Sat, 16 Apr 2022 08:59:51 +0200
do not use macro for suite name
510
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
1 | # Transitional support for CTest written tests |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
2 | message(CHECK_START "Searching for CUnit test framework") |
390
d345541018fa
starts ucx 3.0 development
Mike Becker <universe@uap-core.de>
parents:
375
diff
changeset
|
3 | |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
4 | find_path(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h) |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
5 | find_library(CUNIT_LIBRARY NAMES cunit libcunit cunitlib) |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
6 | include(FindPackageHandleStandardArgs) |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
7 | find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR) |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
8 | |
510
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
9 | if (CUNIT_FOUND) |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
10 | message(CHECK_PASS "found: compiling tests.") |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
11 | set(TESTS |
413
0f4aa9fc75d9
perform array and list tests in the same test binary (use the same assertions, later)
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
12 | test_list |
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
413
diff
changeset
|
13 | test_tree |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
14 | ) |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
15 | |
510
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
16 | foreach (test ${TESTS}) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
17 | add_executable(${test} ${test}.c) |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
18 | target_link_libraries(${test} PRIVATE ucx_static ${CUNIT_LIBRARY}) |
395
dc1bfe5ffd38
fixes missing CUnit include dir
Mike Becker <universe@uap-core.de>
parents:
391
diff
changeset
|
19 | target_include_directories(${test} PRIVATE ${CUNIT_INCLUDE_DIR}) |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
20 | add_test(NAME ${test} COMMAND ${test} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") |
510
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
21 | endforeach () |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
22 | else () |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
23 | message(CHECK_FAIL "not found: CUnit tests will not be available.") |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
24 | endif () |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
25 | |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
26 | # Load Google Test Framework |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
27 | set(CMAKE_CXX_STANDARD 11) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
28 | |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
29 | include(FetchContent) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
30 | FetchContent_Declare( |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
31 | googletest |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
32 | GIT_REPOSITORY https://github.com/google/googletest.git |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
33 | GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release 1.11.0 |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
34 | ) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
35 | # For Windows: Prevent overriding the parent project's compiler/linker settings |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
36 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
37 | FetchContent_MakeAvailable(googletest) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
38 | include(GoogleTest) |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
39 | message(STATUS "Google Test made available") |
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
40 | |
512
096d206b63f9
compile only one single binary for tests
Mike Becker <universe@uap-core.de>
parents:
511
diff
changeset
|
41 | add_executable(ucxtest |
096d206b63f9
compile only one single binary for tests
Mike Becker <universe@uap-core.de>
parents:
511
diff
changeset
|
42 | test_allocator.cpp |
096d206b63f9
compile only one single binary for tests
Mike Becker <universe@uap-core.de>
parents:
511
diff
changeset
|
43 | selftest.cpp |
510
133ac0f8f3fc
add googletest framework
Mike Becker <universe@uap-core.de>
parents:
427
diff
changeset
|
44 | ) |
512
096d206b63f9
compile only one single binary for tests
Mike Becker <universe@uap-core.de>
parents:
511
diff
changeset
|
45 | target_link_libraries(ucxtest PRIVATE ucx_static gtest_main) |
096d206b63f9
compile only one single binary for tests
Mike Becker <universe@uap-core.de>
parents:
511
diff
changeset
|
46 | gtest_discover_tests(ucxtest) |