blob: c44f99c045206d0f505f9493dadc342b6fec4280 [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
5set(tests test_io test_fd_comm)
6
7foreach(test_name IN LISTS tests)
8 add_executable(${test_name} ${test_name}.c)
9 target_link_libraries(${test_name} ${CMOCKA_LIBRARIES} ${LIBYANG_LIBRARIES} netconf2)
10 add_test(${test_name} ${test_name})
11endforeach(test_name)
Radek Krejcice24ab82015-10-08 15:37:02 +020012
13if(ENABLE_VALGRIND_TESTS)
Michal Vasko294d4c62016-02-01 10:10:27 +010014 find_program(valgrind_FOUND valgrind)
15 if(valgrind_FOUND)
16 foreach(test_name IN LISTS tests)
17 add_test(${test_name}_valgrind valgrind --leak-check=full ${CMAKE_BINARY_DIR}/tests/${test_name})
18 endforeach(test_name)
19 else(valgrind_FOUND)
20 Message("-- valgrind executable not found! Disabling memory leaks tests")
21 endif(valgrind_FOUND)
Radek Krejcice24ab82015-10-08 15:37:02 +020022endif()
23
24include_directories(${CMAKE_SOURCE_DIR}/src)
Radek Krejcie1a58672016-01-19 14:12:31 +010025configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_SOURCE_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY)