Debian Codegraph @

tests/CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 3 — not the installed (fully patched) source.
3 Debian patches touch this file
1 #
2 # Copyright 2024 Staysail Systems, Inc. <[email protected]>
3 # Copyright 2018 Capitar IT Group BV <[email protected]>
4 # Copyright (c) 2012 Martin Sustrik All rights reserved.
5 # Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
6 # Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
7 # Copyright 2016 Franklin "Snaipe" Mathieu <[email protected]>
8 #
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"),
11 # to deal in the Software without restriction, including without limitation
12 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 # and/or sell copies of the Software, and to permit persons to whom
14 # the Software is furnished to do so, subject to the following conditions:
15 #
16 # The above copyright notice and this permission notice shall be included
17 # in all copies or substantial portions of the Software.
18 #
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 # IN THE SOFTWARE.
26 #
27
28 # Build unit tests.
29
30 # Note that tests which depend on internal (not public) APIs are not
31 # enabled unless a static library is built. This is because on some
32 # systems (e.g. Windows) we do not expose symbols that are not in the
33 # public API. (When CMake learns more about using mapfiles to suppress
34 # symbol visibility we will do this even more, to protect the namespace
35 # of the user.)
36
37 include_directories(AFTER SYSTEM ${PROJECT_SOURCE_DIR}/src)
38
39 # convey.c needs its own link to pthreads.
40 if (NOT WIN32)
41 find_package(Threads)
42 set(THRLIB Threads::Threads)
43 endif ()
44
45 if (NNG_TESTS)
46
47 nng_check_sym(nl_langinfo langinfo.h NNG_HAVE_LANGINFO)
48 if (NOT NNG_SANITIZER STREQUAL "none")
49 set(TIMEOUT_FACTOR 2)
50 else ()
51 set(TIMEOUT_FACTOR 1)
52 endif ()
53 set(NNG_TEST_PORT 13000)
54 macro(add_nng_test NAME TIMEOUT)
55 add_executable(${NAME} ${NAME}.c convey.c)
56 target_link_libraries(${NAME} nng_testing ${THRLIB})
57 add_test(NAME nng.${NAME} COMMAND ${NAME} -v -p TEST_PORT=${NNG_TEST_PORT})
58 math(EXPR TIMEOUT ${TIMEOUT}*${TIMEOUT_FACTOR})
59 set_tests_properties(nng.${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
60 math(EXPR NNG_TEST_PORT "${NNG_TEST_PORT}+20")
61 endmacro(add_nng_test)
62
63 # Compatibility tests are only added if all of the legacy protocols
64 # are present. It's not worth trying to figure out which of these
65 # should work and which shouldn't.
66 macro(add_nng_compat_test NAME TIMEOUT)
67 add_executable(${NAME} ${NAME}.c compat_testutil.c)
68 target_link_libraries(${NAME} nng_testing)
69 target_include_directories(${NAME} PRIVATE
70 ${PROJECT_SOURCE_DIR}/src/compat
71 ${PROJECT_SOURCE_DIR}/include)
72 add_test(NAME nng.${NAME} COMMAND ${NAME} ${NNG_TEST_PORT})
73 set_tests_properties(nng.${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
74 math(EXPR NNG_TEST_PORT "${NNG_TEST_PORT}+20")
75 endmacro(add_nng_compat_test)
76
77 macro(add_nng_cpp_test NAME TIMEOUT)
78 if (NOT NNG_ENABLE_COVERAGE)
79 enable_language(CXX)
80 add_executable(${NAME} ${NAME}.cc)
81 target_link_libraries(${NAME} nng_testing)
82 add_test(NAME nng.${NAME} COMMAND ${NAME} ${TEST_PORT})
83 set_tests_properties(nng.${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
84 math(EXPR TEST_PORT "${NNG_TEST_PORT}+20")
85 endif ()
86 endmacro(add_nng_cpp_test)
87
88 macro(add_nng_test1 NAME TIMEOUT COND1)
89 if (${COND1})
90 add_nng_test(${NAME} ${TIMEOUT})
91 else ()
92 message(STATUS "Test ${NAME} disabled (unconfigured)")
93 endif ()
94 endmacro()
95
96 macro(add_nng_test2 NAME TIMEOUT COND1 COND2)
97 if (${COND1} AND ${COND2})
98 add_nng_test(${NAME} ${TIMEOUT})
99 else ()
100 message(STATUS "Test ${NAME} disabled (unconfigured)")
101 endif ()
102 endmacro()
103
104 macro(add_nng_test3 NAME TIMEOUT COND1 COND2 COND3)
105 if (${COND1} AND ${COND2} AND ${COND3})
106 add_nng_test(${NAME} ${TIMEOUT} ON)
107 else ()
108 message(STATUS "Test ${NAME} disabled (unconfigured)")
109 endif ()
110 endmacro()
111
112 else ()
113 macro(add_nng_test NAME TIMEOUT)
114 endmacro(add_nng_test)
115 macro(add_nng_compat_test NAME TIMEOUT)
116 endmacro(add_nng_compat_test)
117 macro(add_nng_cpp_test NAME TIMEOUT)
118 endmacro(add_nng_cpp_test)
119 macro(add_nng_test1 NAME TIMEOUT COND1)
120 endmacro(add_nng_test1)
121 macro(add_nng_test2 NAME TIMEOUT COND1 COND2)
122 endmacro(add_nng_test2)
123 macro(add_nng_test3 NAME TIMEOUT COND1 COND2 COND3)
124 endmacro(add_nng_test3)
125 endif ()
126
127 add_nng_test(device 5)
128 add_nng_test(files 5)
129 add_nng_test1(httpclient 60 NNG_SUPP_HTTP)
130 add_nng_test1(httpserver 30 NNG_SUPP_HTTP)
131 add_nng_test(inproc 5)
132 add_nng_test(ipc 5)
133 add_nng_test(ipcsupp 10)
134 add_nng_test(multistress 60)
135 add_nng_test(nonblock 60)
136 add_nng_test(options 5)
137 add_nng_test(pipe 5)
138 add_nng_test(pollfd 5)
139 add_nng_test(scalability 20 ON)
140 add_nng_test(synch 5)
141 add_nng_test(tls 60)
142 add_nng_test(tcpsupp 10)
143 add_nng_test(tcp 180)
144 add_nng_test(tcp6 60)
145 add_nng_test(ws 30)
146 add_nng_test(wss 30)
147 add_nng_test1(zt 60 NNG_TRANSPORT_ZEROTIER)
148
149 add_nng_test(reqctx 5)
150 add_nng_test(reqstress 60)
151
152 # compatibility tests
153 # We only support these if ALL the legacy protocols are supported. This
154 # is because we don't want to make modifications to partially enable some
155 # of these tests. Folks minimizing the library probably don't care too
156 # much about these anyway.
157 if (NNG_ENABLE_COMPAT)
158 add_nng_compat_test(compat_block 10)
159 add_nng_compat_test(compat_bug777 10)
160 add_nng_compat_test(compat_bus 10)
161 add_nng_compat_test(compat_cmsg 10)
162 add_nng_compat_test(compat_msg 10)
163 add_nng_compat_test(compat_iovec 10)
164 add_nng_compat_test(compat_device 10)
165 add_nng_compat_test(compat_pair 10)
166 add_nng_compat_test(compat_pipeline 10)
167 add_nng_compat_test(compat_poll 10)
168 add_nng_compat_test(compat_reqrep 10)
169 add_nng_compat_test(compat_survey 10)
170 add_nng_compat_test(compat_reqttl 10)
171 add_nng_compat_test(compat_shutdown 10)
172 add_nng_compat_test(compat_surveyttl 10)
173
174 # These are special tests for compat mode, not inherited from the
175 # legacy libnanomsg suite.
176 add_nng_test(compat_options 5)
177 endif()
178
179 # c++ tests
180 add_nng_cpp_test(cplusplus_pair 5)