Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6) |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 2 | |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 3 | # list of all the tests |
Radek Krejci | 2e32e39 | 2017-05-26 13:25:46 +0200 | [diff] [blame] | 4 | set(tests test_io test_fd_comm test_init_destroy_client test_init_destroy_server test_time test_client_thread) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 5 | |
Michal Vasko | 8f0c028 | 2016-02-29 10:17:14 +0100 | [diff] [blame] | 6 | if (ENABLE_SSH OR ENABLE_TLS) |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 7 | list(APPEND tests test_server_thread) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 8 | endif() |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 9 | |
| 10 | foreach(test_name IN LISTS tests) |
| 11 | add_executable(${test_name} ${test_name}.c) |
| 12 | target_link_libraries(${test_name} ${CMOCKA_LIBRARIES} ${LIBYANG_LIBRARIES} netconf2) |
| 13 | add_test(${test_name} ${test_name}) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 14 | endforeach() |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 15 | |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 16 | if (ENABLE_VALGRIND_TESTS) |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 17 | find_program(valgrind_FOUND valgrind) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 18 | if (valgrind_FOUND) |
| 19 | foreach (test_name IN LISTS tests) |
Radek Krejci | 16c94f6 | 2017-05-26 10:53:30 +0200 | [diff] [blame] | 20 | add_test(${test_name}_valgrind valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 --suppressions=${PROJECT_SOURCE_DIR}/tests/ld.supp ${CMAKE_BINARY_DIR}/tests/${test_name}) |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 21 | endforeach() |
| 22 | else (valgrind_FOUND) |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame] | 23 | Message("-- valgrind executable not found! Disabling memory leaks tests") |
Michal Vasko | 061561f | 2016-02-08 15:36:22 +0100 | [diff] [blame] | 24 | endif() |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 25 | endif() |
| 26 | |
| 27 | include_directories(${CMAKE_SOURCE_DIR}/src) |
Radek Krejci | e1a5867 | 2016-01-19 14:12:31 +0100 | [diff] [blame] | 28 | configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_SOURCE_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY) |