Define _GNU_SOURCE on one place only.
[socket_wrapper.git] / tests / CMakeLists.txt
1 project(tests C)
2
3 include_directories(
4   ${CMAKE_BINARY_DIR}
5   ${CMAKE_CURRENT_SOURCE_DIR}
6   ${CMOCKA_INCLUDE_DIR}
7 )
8
9 set(TORTURE_LIBRARY torture)
10
11 # RFC862 echo server
12 add_executable(echo_srv echo_srv.c)
13 target_link_libraries(echo_srv ${SWRAP_REQUIRED_LIBRARIES})
14
15 add_library(${TORTURE_LIBRARY} STATIC torture.c)
16 target_link_libraries(${TORTURE_LIBRARY}
17     ${CMOCKA_LIBRARY}
18     ${SWRAP_REQUIRED_LIBRARIES})
19
20 set(SWRAP_TESTS
21     test_ioctl
22     test_echo_tcp_socket
23     test_echo_tcp_connect
24     test_echo_tcp_bind
25     test_echo_tcp_socket_options
26     test_echo_tcp_write_read
27     test_echo_tcp_writev_readv
28     test_echo_tcp_get_peer_sock_name
29     test_echo_udp_sendto_recvfrom
30     test_echo_udp_send_recv
31     test_echo_udp_sendmsg_recvmsg)
32
33 if (HAVE_STRUCT_MSGHDR_MSG_CONTROL)
34     set(SWRAP_TESTS ${SWRAP_TESTS} test_sendmsg_recvmsg_fd)
35 endif (HAVE_STRUCT_MSGHDR_MSG_CONTROL)
36
37 foreach(_SWRAP_TEST ${SWRAP_TESTS})
38     add_cmocka_test(${_SWRAP_TEST} ${_SWRAP_TEST}.c ${TORTURE_LIBRARY})
39
40     if (OSX)
41         set_property(
42             TEST
43                 ${_SWRAP_TEST}
44             PROPERTY
45                 ENVIRONMENT DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${SOCKET_WRAPPER_LOCATION})
46     else ()
47         set_property(
48             TEST
49                 ${_SWRAP_TEST}
50             PROPERTY
51                 ENVIRONMENT LD_PRELOAD=${SOCKET_WRAPPER_LOCATION})
52     endif()
53 endforeach()