5 ${CMAKE_CURRENT_SOURCE_DIR}
6 ${CMAKE_SOURCE_DIR}/src
10 set(TORTURE_LIBRARY torture)
12 # A simple DNS server for testing
13 add_executable(dns_srv dns_srv.c)
14 target_compile_options(dns_srv PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
15 target_link_libraries(dns_srv ${RWRAP_REQUIRED_LIBRARIES})
17 add_executable(test_real_res_query test_real_res_query.c)
18 target_compile_options(test_real_res_query PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
19 target_link_libraries(test_real_res_query ${RWRAP_REQUIRED_LIBRARIES} ${CMOCKA_LIBRARY})
21 configure_file(fake_hosts.in ${CMAKE_CURRENT_BINARY_DIR}/fake_hosts @ONLY)
23 add_library(${TORTURE_LIBRARY} STATIC torture.c)
24 target_compile_options(${TORTURE_LIBRARY} PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
25 target_link_libraries(${TORTURE_LIBRARY}
27 ${SWRAP_REQUIRED_LIBRARIES})
30 set(TESTSUITE_LIBRARIES ${RWRAP_REQUIRED_LIBRARIES} ${CMOCKA_LIBRARY})
35 set(PRELOAD_LIBS ${RESOLV_WRAPPER_LOCATION})
37 # Some tests require socket_wrapper as well.
38 find_package(socket_wrapper REQUIRED)
40 # On Solaris the socket functions are compiled into libresolv.so so we can't preload
41 # socket_wrapper. Only faking will work!
42 if (HAVE_LIBRESOLV AND SOCKET_WRAPPER_LIBRARY AND NOT SOLARIS)
43 set(RWRAP_TESTS ${RWRAP_TESTS} test_res_query_search)
44 set(PRELOAD_LIBS ${RESOLV_WRAPPER_LOCATION}:${SOCKET_WRAPPER_LIBRARY})
47 foreach(_RWRAP_TEST ${RWRAP_TESTS})
48 add_cmocka_test(${_RWRAP_TEST} ${_RWRAP_TEST}.c ${TORTURE_LIBRARY} ${TESTSUITE_LIBRARIES})
55 ENVIRONMENT DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${PRELOAD_LIBS})
61 ENVIRONMENT LD_PRELOAD=${PRELOAD_LIBS})
65 add_cmocka_test(test_dns_fake test_dns_fake.c ${TORTURE_LIBRARY} ${TESTSUITE_LIBRARIES})
71 ENVIRONMENT DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${PRELOAD_LIBS};RESOLV_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/fake_hosts)
77 ENVIRONMENT LD_PRELOAD=${PRELOAD_LIBS};RESOLV_WRAPPER_HOSTS=${CMAKE_CURRENT_BINARY_DIR}/fake_hosts)