blob: cfbf4228f327c151061cc54820f3d64cdf87f335 [file] [log] [blame]
Radek Krejcice24ab82015-10-08 15:37:02 +02001cmake_minimum_required(VERSION 2.6)
Radek Krejci6c11eda2015-10-08 16:35:19 +02002find_package(CMocka 1.0.0 REQUIRED)
Radek Krejcice24ab82015-10-08 15:37:02 +02003
Michal Vasko294d4c62016-02-01 10:10:27 +01004# list of all the tests
Michal Vasko061561f2016-02-08 15:36:22 +01005set(tests test_io test_fd_comm)
6
7if (ENABLE_SSH AND ENABLE_TLS)
8 list(APPEND tests test_init_destroy_ssh_tls)
9endif()
10
11if (ENABLE_SSH)
12 list(APPEND tests test_init_destroy_ssh)
13endif()
14
15if (ENABLE_TLS)
16 list(APPEND tests test_init_destroy_tls)
17endif()
Michal Vasko294d4c62016-02-01 10:10:27 +010018
19foreach(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 Vasko061561f2016-02-08 15:36:22 +010023endforeach()
Radek Krejcice24ab82015-10-08 15:37:02 +020024
Michal Vasko061561f2016-02-08 15:36:22 +010025if (ENABLE_VALGRIND_TESTS)
Michal Vasko294d4c62016-02-01 10:10:27 +010026 find_program(valgrind_FOUND valgrind)
Michal Vasko061561f2016-02-08 15:36:22 +010027 if (valgrind_FOUND)
28 foreach (test_name IN LISTS tests)
Michal Vasko294d4c62016-02-01 10:10:27 +010029 add_test(${test_name}_valgrind valgrind --leak-check=full ${CMAKE_BINARY_DIR}/tests/${test_name})
Michal Vasko061561f2016-02-08 15:36:22 +010030 endforeach()
31 else (valgrind_FOUND)
Michal Vasko294d4c62016-02-01 10:10:27 +010032 Message("-- valgrind executable not found! Disabling memory leaks tests")
Michal Vasko061561f2016-02-08 15:36:22 +010033 endif()
Radek Krejcice24ab82015-10-08 15:37:02 +020034endif()
35
36include_directories(${CMAKE_SOURCE_DIR}/src)
Radek Krejcie1a58672016-01-19 14:12:31 +010037configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_SOURCE_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY)