blob: 26ce14c502b434f309a32ec72dae41f7365b275b [file] [log] [blame]
Radek Krejcice24ab82015-10-08 15:37:02 +02001cmake_minimum_required(VERSION 2.6)
Radek Krejcice24ab82015-10-08 15:37:02 +02002
Michal Vasko294d4c62016-02-01 10:10:27 +01003# list of all the tests
Radek Krejci2e32e392017-05-26 13:25:46 +02004set(tests test_io test_fd_comm test_init_destroy_client test_init_destroy_server test_time test_client_thread)
Michal Vasko061561f2016-02-08 15:36:22 +01005
Michal Vasko8f0c0282016-02-29 10:17:14 +01006if (ENABLE_SSH OR ENABLE_TLS)
Michal Vaskoa7b8ca52016-03-01 12:09:29 +01007 list(APPEND tests test_server_thread)
Michal Vasko061561f2016-02-08 15:36:22 +01008endif()
Michal Vasko294d4c62016-02-01 10:10:27 +01009
10foreach(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 Vasko061561f2016-02-08 15:36:22 +010014endforeach()
Radek Krejcice24ab82015-10-08 15:37:02 +020015
Michal Vasko061561f2016-02-08 15:36:22 +010016if (ENABLE_VALGRIND_TESTS)
Michal Vasko294d4c62016-02-01 10:10:27 +010017 find_program(valgrind_FOUND valgrind)
Michal Vasko061561f2016-02-08 15:36:22 +010018 if (valgrind_FOUND)
19 foreach (test_name IN LISTS tests)
Radek Krejci16c94f62017-05-26 10:53:30 +020020 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 Vasko061561f2016-02-08 15:36:22 +010021 endforeach()
22 else (valgrind_FOUND)
Michal Vasko294d4c62016-02-01 10:10:27 +010023 Message("-- valgrind executable not found! Disabling memory leaks tests")
Michal Vasko061561f2016-02-08 15:36:22 +010024 endif()
Radek Krejcice24ab82015-10-08 15:37:02 +020025endif()
26
27include_directories(${CMAKE_SOURCE_DIR}/src)
Radek Krejcie1a58672016-01-19 14:12:31 +010028configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_SOURCE_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY)