Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6) |
Radek Krejci | 6c11eda | 2015-10-08 16:35:19 +0200 | [diff] [blame] | 2 | find_package(CMocka 1.0.0 REQUIRED) |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 3 | |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 4 | # list of all the tests |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame^] | 5 | set(tests test_io test_fd_comm) |
| 6 | |
| 7 | if (ENABLE_SSH AND ENABLE_TLS) |
| 8 | list(APPEND tests test_init_destroy_ssh_tls) |
| 9 | endif() |
| 10 | |
| 11 | if (ENABLE_SSH) |
| 12 | list(APPEND tests test_init_destroy_ssh) |
| 13 | endif() |
| 14 | |
| 15 | if (ENABLE_TLS) |
| 16 | list(APPEND tests test_init_destroy_tls) |
| 17 | endif() |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 18 | |
| 19 | foreach(test_name IN LISTS tests) |
| 20 | add_executable(${test_name} ${test_name}.c) |
| 21 | target_link_libraries(${test_name} ${CMOCKA_LIBRARIES} ${LIBYANG_LIBRARIES} netconf2) |
| 22 | add_test(${test_name} ${test_name}) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame^] | 23 | endforeach() |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 24 | |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame^] | 25 | if (ENABLE_VALGRIND_TESTS) |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 26 | find_program(valgrind_FOUND valgrind) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame^] | 27 | if (valgrind_FOUND) |
| 28 | foreach (test_name IN LISTS tests) |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 29 | add_test(${test_name}_valgrind valgrind --leak-check=full ${CMAKE_BINARY_DIR}/tests/${test_name}) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame^] | 30 | endforeach() |
| 31 | else (valgrind_FOUND) |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 32 | Message("-- valgrind executable not found! Disabling memory leaks tests") |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame^] | 33 | endif() |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 34 | endif() |
| 35 | |
| 36 | include_directories(${CMAKE_SOURCE_DIR}/src) |
Radek Krejci | e1a5867 | 2016-01-19 14:12:31 +0100 | [diff] [blame] | 37 | configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_SOURCE_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY) |