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