CMakeLists.txt 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. # Load CMake Packages
  2. find_package(Check REQUIRED)
  3. set(LIBS ${CHECK_LIBRARIES} ${open62541_LIBRARIES})
  4. if(NOT WIN32 AND NOT APPLE)
  5. list(APPEND LIBS subunit)
  6. endif()
  7. include_directories(${CHECK_INCLUDE_DIR})
  8. #find_package(Threads REQUIRED)
  9. if(NOT MSVC AND UA_ENABLE_UNIT_TESTS_MEMCHECK)
  10. find_package(Valgrind REQUIRED)
  11. endif()
  12. if(CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD")
  13. link_directories(/usr/local/lib)
  14. add_definitions(-Wno-gnu-zero-variadic-macro-arguments)
  15. endif()
  16. if(APPLE)
  17. # CLang on Apple complains about many cases like this:
  18. # /Users/travis/build/open62541/open62541/tests/check_chunking.c:148:22: warning: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'intmax_t' (aka 'long') [-Wsign-conversion]
  19. # ck_assert_int_eq(counter,9); //10 chunks allocated - callback called 4 times
  20. add_definitions(-Wno-sign-conversion)
  21. endif()
  22. get_property(open62541_BUILD_INCLUDE_DIRS TARGET open62541 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
  23. include_directories(${open62541_BUILD_INCLUDE_DIRS})
  24. # ua_server_internal.h
  25. include_directories("${PROJECT_SOURCE_DIR}/src")
  26. include_directories("${PROJECT_SOURCE_DIR}/src/server")
  27. # testing_clock.h
  28. include_directories("${CMAKE_CURRENT_SOURCE_DIR}/testing-plugins")
  29. # #include <src_generated/<...>.h>
  30. include_directories("${PROJECT_BINARY_DIR}")
  31. include_directories("${PROJECT_BINARY_DIR}/../plugins")
  32. if(UA_ENABLE_ENCRYPTION)
  33. # mbedtls includes
  34. include_directories(${MBEDTLS_INCLUDE_DIRS})
  35. endif()
  36. add_definitions(-DUA_sleep_ms=UA_comboSleep)
  37. #############################
  38. # Compiled binaries folders #
  39. #############################
  40. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/tests)
  41. if (MSVC)
  42. set(TESTS_BINARY_DIR ${CMAKE_BINARY_DIR}/bin/tests/${CMAKE_BUILD_TYPE})
  43. else()
  44. set(TESTS_BINARY_DIR ${CMAKE_BINARY_DIR}/bin/tests)
  45. endif()
  46. # Use different plugins for testing
  47. set(test_plugin_sources ${PROJECT_SOURCE_DIR}/arch/network_tcp.c
  48. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_clock.c
  49. ${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.c
  50. ${PROJECT_SOURCE_DIR}/plugins/ua_config_default.c
  51. ${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.c
  52. ${PROJECT_SOURCE_DIR}/plugins/ua_pki_default.c
  53. ${PROJECT_SOURCE_DIR}/plugins/ua_nodestore_ziptree.c
  54. ${PROJECT_SOURCE_DIR}/plugins/ua_nodestore_hashmap.c
  55. ${PROJECT_SOURCE_DIR}/plugins/securityPolicies/ua_securitypolicy_none.c
  56. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_policy.c
  57. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_networklayers.c
  58. )
  59. if(UA_ENABLE_HISTORIZING)
  60. set(test_plugin_sources ${test_plugin_sources}
  61. ${PROJECT_SOURCE_DIR}/plugins/historydata/ua_history_data_backend_memory.c
  62. ${PROJECT_SOURCE_DIR}/plugins/historydata/ua_history_data_gathering_default.c
  63. ${PROJECT_SOURCE_DIR}/plugins/historydata/ua_history_database_default.c)
  64. endif()
  65. if(UA_ENABLE_ENCRYPTION)
  66. list(APPEND test_plugin_sources
  67. ${PROJECT_SOURCE_DIR}/plugins/securityPolicies/securitypolicy_mbedtls_common.c
  68. ${PROJECT_SOURCE_DIR}/plugins/securityPolicies/ua_securitypolicy_basic128rsa15.c
  69. ${PROJECT_SOURCE_DIR}/plugins/securityPolicies/ua_securitypolicy_basic256.c
  70. ${PROJECT_SOURCE_DIR}/plugins/securityPolicies/ua_securitypolicy_basic256sha256.c)
  71. endif()
  72. add_library(open62541-testplugins OBJECT ${test_plugin_sources} ${PROJECT_SOURCE_DIR}/arch/${UA_ARCHITECTURE}/ua_architecture_functions.c)
  73. add_dependencies(open62541-testplugins open62541)
  74. target_compile_definitions(open62541-testplugins PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
  75. if(NOT MSVC)
  76. add_definitions(-Wno-deprecated-declarations)
  77. endif()
  78. # Workaround some clang warnings in the uni tests
  79. if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang"))
  80. add_definitions(-Wno-sign-conversion)
  81. endif()
  82. # Unit Test Definition Macro
  83. # For now we need to disable the libc freeres. See https://github.com/open62541/open62541/pull/1003#issuecomment-315045143
  84. # This also requires to disable the phtread cache with no-nptl-pthread-stackcache
  85. set(VALGRIND_FLAGS --quiet --trace-children=yes --leak-check=full --run-libc-freeres=no --sim-hints=no-nptl-pthread-stackcache --track-fds=yes)
  86. macro(add_test_valgrind TEST_NAME)
  87. if(UA_ENABLE_UNIT_TESTS_MEMCHECK)
  88. if(MSVC)
  89. add_test(${TEST_NAME} drmemory -batch -exit_code_if_errors 1 -results_to_stderr -summary -- ${ARGN})
  90. else()
  91. set(VALGRIND_LOG ${TESTS_BINARY_DIR}/${TEST_NAME}.log)
  92. set(VALGRIND_CMD valgrind --error-exitcode=1 --suppressions=${PROJECT_SOURCE_DIR}/tools/valgrind_suppressions.supp ${VALGRIND_FLAGS} --log-file=${VALGRIND_LOG} ${ARGN})
  93. add_test(${TEST_NAME} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/valgrind_check_error.py ${VALGRIND_LOG} ${VALGRIND_CMD})
  94. endif()
  95. else()
  96. add_test(${TEST_NAME} ${ARGN})
  97. endif()
  98. if(UA_BUILD_FUZZING_CORPUS)
  99. target_sources(check_${TEST_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/tests/fuzz/ua_debug_dump_pkgs_file.c)
  100. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/corpus/${TEST_NAME})
  101. target_compile_definitions(check_${TEST_NAME} PRIVATE UA_CORPUS_OUTPUT_DIR="${PROJECT_BINARY_DIR}/corpus/${TEST_NAME}")
  102. endif()
  103. endmacro()
  104. macro(add_test_no_valgrind TEST_NAME)
  105. if(NOT UA_ENABLE_UNIT_TESTS_MEMCHECK)
  106. add_test(${TEST_NAME} ${ARGN})
  107. endif()
  108. if(UA_BUILD_FUZZING_CORPUS)
  109. target_sources(check_${TEST_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/tests/fuzz/ua_debug_dump_pkgs_file.c)
  110. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/corpus/${TEST_NAME})
  111. target_compile_definitions(check_${TEST_NAME} PRIVATE UA_CORPUS_OUTPUT_DIR="${PROJECT_BINARY_DIR}/corpus/${TEST_NAME}")
  112. endif()
  113. endmacro()
  114. add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
  115. # the unit test are built directly on the open62541 object files. so they can
  116. # access symbols that are hidden/not exported to the shared library
  117. add_executable(check_types_builtin check_types_builtin.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  118. target_link_libraries(check_types_builtin ${LIBS})
  119. add_test_valgrind(types_builtin ${TESTS_BINARY_DIR}/check_types_builtin)
  120. if(UA_ENABLE_JSON_ENCODING)
  121. add_executable(check_types_builtin_json check_types_builtin_json.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  122. target_link_libraries(check_types_builtin_json ${LIBS})
  123. add_test_valgrind(types_builtin_json ${TESTS_BINARY_DIR}/check_types_builtin_json)
  124. if(UA_ENABLE_PUBSUB)
  125. add_executable(check_pubsub_encoding_json pubsub/check_pubsub_encoding_json.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  126. target_link_libraries(check_pubsub_encoding_json ${LIBS})
  127. add_test_valgrind(pubsub_encoding_json ${TESTS_BINARY_DIR}/check_pubsub_encoding_json)
  128. add_executable(check_pubsub_publish_json pubsub/check_pubsub_publish_json.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  129. target_link_libraries(check_pubsub_publish_json ${LIBS})
  130. add_test_valgrind(pubsub_publish_json ${TESTS_BINARY_DIR}/check_pubsub_publish_json)
  131. endif()
  132. endif()
  133. add_executable(check_types_memory check_types_memory.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  134. target_link_libraries(check_types_memory ${LIBS})
  135. add_test_valgrind(types_memory ${TESTS_BINARY_DIR}/check_types_memory)
  136. add_executable(check_types_range check_types_range.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  137. target_link_libraries(check_types_range ${LIBS})
  138. add_test_valgrind(types_range ${TESTS_BINARY_DIR}/check_types_range)
  139. add_executable(check_types_custom check_types_custom.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  140. target_link_libraries(check_types_custom ${LIBS})
  141. add_test_valgrind(types_custom ${TESTS_BINARY_DIR}/check_types_custom)
  142. add_executable(check_chunking check_chunking.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  143. target_link_libraries(check_chunking ${LIBS})
  144. add_test_valgrind(chunking ${TESTS_BINARY_DIR}/check_chunking)
  145. add_executable(check_utils check_utils.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  146. target_link_libraries(check_utils ${LIBS})
  147. add_test_valgrind(utils ${TESTS_BINARY_DIR}/check_utils)
  148. add_executable(check_securechannel check_securechannel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  149. target_link_libraries(check_securechannel ${LIBS})
  150. add_test_valgrind(securechannel ${TESTS_BINARY_DIR}/check_securechannel)
  151. add_executable(check_timer check_timer.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  152. target_link_libraries(check_timer ${LIBS})
  153. add_test_valgrind(timer ${TESTS_BINARY_DIR}/check_timer)
  154. # Test Server
  155. add_executable(check_accesscontrol server/check_accesscontrol.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  156. target_link_libraries(check_accesscontrol ${LIBS})
  157. add_test_valgrind(accesscontrol ${TESTS_BINARY_DIR}/check_accesscontrol)
  158. add_executable(check_services_view server/check_services_view.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  159. target_link_libraries(check_services_view ${LIBS})
  160. add_test_valgrind(services_view ${TESTS_BINARY_DIR}/check_services_view)
  161. add_executable(check_services_attributes server/check_services_attributes.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  162. target_link_libraries(check_services_attributes ${LIBS})
  163. add_test_valgrind(services_attributes ${TESTS_BINARY_DIR}/check_services_attributes)
  164. add_executable(check_services_nodemanagement server/check_services_nodemanagement.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  165. target_link_libraries(check_services_nodemanagement ${LIBS})
  166. add_test_valgrind(services_nodemanagement ${TESTS_BINARY_DIR}/check_services_nodemanagement)
  167. add_executable(check_server_callbacks server/check_server_callbacks.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  168. target_link_libraries(check_server_callbacks ${LIBS})
  169. add_test_valgrind(server_callbacks ${TESTS_BINARY_DIR}/check_server_callbacks)
  170. if (UA_MULTITHREADING EQUAL 100)
  171. add_executable(check_mt_addVariableNode multithreading/check_mt_addVariableNode.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  172. target_link_libraries(check_mt_addVariableNode ${LIBS})
  173. add_test_valgrind(mt_addVariableNode ${TESTS_BINARY_DIR}/check_mt_addVariableNode)
  174. add_executable(check_mt_addVariableTypeNode multithreading/check_mt_addVariableTypeNode.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  175. target_link_libraries(check_mt_addVariableTypeNode ${LIBS})
  176. add_test_valgrind(mt_addVariableTypeNode ${TESTS_BINARY_DIR}/check_mt_addVariableTypeNode)
  177. add_executable(check_mt_addObjectNode multithreading/check_mt_addObjectNode.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  178. target_link_libraries(check_mt_addObjectNode ${LIBS})
  179. add_test_valgrind(mt_addObjectNode ${TESTS_BINARY_DIR}/check_mt_addObjectNode)
  180. add_executable(check_mt_readValueAttribute multithreading/check_mt_readValueAttribute.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  181. target_link_libraries(check_mt_readValueAttribute ${LIBS})
  182. add_test_valgrind(mt_readValueAttribute ${TESTS_BINARY_DIR}/check_mt_readValueAttribute)
  183. add_executable(check_mt_writeValueAttribute multithreading/check_mt_writeValueAttribute.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  184. target_link_libraries(check_mt_writeValueAttribute ${LIBS})
  185. add_test_valgrind(mt_writeValueAttribute ${TESTS_BINARY_DIR}/check_mt_readWriteDelete)
  186. add_executable(check_mt_readWriteDelete multithreading/check_mt_readWriteDelete.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  187. target_link_libraries(check_mt_readWriteDelete ${LIBS})
  188. add_test_valgrind(mt_readWriteDelete ${TESTS_BINARY_DIR}/check_mt_readWriteDelete)
  189. add_executable(check_mt_readWriteDeleteCallback multithreading/check_mt_readWriteDeleteCallback.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  190. target_link_libraries(check_mt_readWriteDeleteCallback ${LIBS})
  191. add_test_valgrind(mt_readWriteDeleteCallback ${TESTS_BINARY_DIR}/check_mt_readWriteDeleteCallback)
  192. add_executable(check_mt_addDeleteObject multithreading/check_mt_addDeleteObject.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  193. target_link_libraries(check_mt_addDeleteObject ${LIBS})
  194. add_test_valgrind(mt_addDeleteObject ${TESTS_BINARY_DIR}/check_mt_addDeleteObject)
  195. add_executable(check_server_asyncop server/check_server_asyncop.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  196. target_link_libraries(check_server_asyncop ${LIBS})
  197. add_test_valgrind(server_asyncop ${TESTS_BINARY_DIR}/check_server_asyncop)
  198. endif()
  199. add_executable(check_services_call server/check_services_call.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  200. target_link_libraries(check_services_call ${LIBS})
  201. add_test_valgrind(services_call ${TESTS_BINARY_DIR}/check_services_call)
  202. add_executable(check_services_subscriptions server/check_services_subscriptions.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  203. target_link_libraries(check_services_subscriptions ${LIBS})
  204. add_test_valgrind(services_subscriptions ${TESTS_BINARY_DIR}/check_services_subscriptions)
  205. add_executable(check_monitoreditem_filter server/check_monitoreditem_filter.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  206. target_link_libraries(check_monitoreditem_filter ${LIBS})
  207. add_test_valgrind(monitoreditem_filter ${TESTS_BINARY_DIR}/check_monitoreditem_filter)
  208. add_executable(check_subscription_events server/check_subscription_events.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  209. target_link_libraries(check_subscription_events ${LIBS})
  210. add_test_valgrind(subscription_events ${TESTS_BINARY_DIR}/check_subscription_events)
  211. add_executable(check_nodestore server/check_nodestore.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  212. target_link_libraries(check_nodestore ${LIBS})
  213. add_test_valgrind(nodestore ${TESTS_BINARY_DIR}/check_nodestore)
  214. if(UA_ENABLE_HISTORIZING)
  215. add_executable(check_server_historical_data server/check_server_historical_data.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  216. target_link_libraries(check_server_historical_data ${LIBS})
  217. add_test_valgrind(server_historical_data ${TESTS_BINARY_DIR}/check_server_historical_data)
  218. endif()
  219. add_executable(check_session server/check_session.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  220. target_link_libraries(check_session ${LIBS})
  221. add_test_valgrind(session ${TESTS_BINARY_DIR}/check_session)
  222. add_executable(check_server server/check_server.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  223. target_link_libraries(check_server ${LIBS})
  224. add_test_valgrind(server ${TESTS_BINARY_DIR}/check_server)
  225. add_executable(check_server_jobs server/check_server_jobs.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  226. target_link_libraries(check_server_jobs ${LIBS})
  227. add_test_valgrind(server_jobs ${TESTS_BINARY_DIR}/check_server_jobs)
  228. add_executable(check_server_userspace server/check_server_userspace.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  229. target_link_libraries(check_server_userspace ${LIBS})
  230. add_test_valgrind(server_userspace ${TESTS_BINARY_DIR}/check_server_userspace)
  231. add_executable(check_node_inheritance server/check_node_inheritance.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  232. target_link_libraries(check_node_inheritance ${LIBS})
  233. add_test_valgrind(node_inheritance ${TESTS_BINARY_DIR}/check_node_inheritance)
  234. add_executable(check_local_monitored_item server/check_local_monitored_item.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  235. target_link_libraries(check_local_monitored_item ${LIBS})
  236. add_test_valgrind(local_monitored_item ${TESTS_BINARY_DIR}/check_local_monitored_item)
  237. if(UA_ENABLE_DISCOVERY)
  238. add_executable(check_discovery server/check_discovery.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  239. target_link_libraries(check_discovery ${LIBS})
  240. add_test_valgrind(discovery ${TESTS_BINARY_DIR}/check_discovery)
  241. endif()
  242. if(UA_ENABLE_PUBSUB)
  243. add_executable(check_pubsub_encoding pubsub/check_pubsub_encoding.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  244. target_link_libraries(check_pubsub_encoding ${LIBS})
  245. add_test_valgrind(pubsub_encoding ${TESTS_BINARY_DIR}/check_pubsub_encoding)
  246. add_executable(check_pubsub_pds pubsub/check_pubsub_pds.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  247. target_link_libraries(check_pubsub_pds ${LIBS})
  248. add_test_valgrind(pubsub_pds ${TESTS_BINARY_DIR}/check_pubsub_pds)
  249. add_executable(check_pubsub_connection_udp pubsub/check_pubsub_connection_udp.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  250. target_link_libraries(check_pubsub_connection_udp ${LIBS})
  251. add_test_valgrind(pubsub_connection_udp ${TESTS_BINARY_DIR}/check_pubsub_connection_udp)
  252. add_executable(check_pubsub_publish pubsub/check_pubsub_publish.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  253. target_link_libraries(check_pubsub_publish ${LIBS})
  254. add_test_valgrind(pubsub_publish ${TESTS_BINARY_DIR}/check_pubsub_publish)
  255. add_executable(check_pubsub_publish_uadp pubsub/check_pubsub_publish_uadp.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  256. target_link_libraries(check_pubsub_publish_uadp ${LIBS})
  257. add_test_valgrind(pubsub_publish ${TESTS_BINARY_DIR}/check_pubsub_publish_uadp)
  258. #Link libraries for executing subscriber unit test
  259. add_executable(check_pubsub_subscribe pubsub/check_pubsub_subscribe.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  260. target_link_libraries(check_pubsub_subscribe ${LIBS})
  261. add_executable(check_pubsub_publishspeed pubsub/check_pubsub_publishspeed.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  262. target_link_libraries(check_pubsub_publishspeed ${LIBS})
  263. add_test_valgrind(pubsub_publishspeed ${TESTS_BINARY_DIR}/check_pubsub_publish)
  264. add_executable(check_pubsub_config_freeze pubsub/check_pubsub_config_freeze.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  265. target_link_libraries(check_pubsub_config_freeze ${LIBS})
  266. add_test_valgrind(check_pubsub_config_freeze ${TESTS_BINARY_DIR}/check_pubsub_config_freeze)
  267. add_executable(check_pubsub_multiple_layer pubsub/check_pubsub_multiple_layer.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  268. target_link_libraries(check_pubsub_multiple_layer ${LIBS})
  269. add_test_valgrind(pubsub_multiple_layer ${TESTS_BINARY_DIR}/check_pubsub_multiple_layer)
  270. if(UA_ENABLE_PUBSUB_INFORMATIONMODEL)
  271. add_executable(check_pubsub_informationmodel pubsub/check_pubsub_informationmodel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  272. target_link_libraries(check_pubsub_informationmodel ${LIBS})
  273. add_test(check_pubsub_informationmodel ${TESTS_BINARY_DIR}/check_pubsub_informationmodel)
  274. if(UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS)
  275. add_executable(check_pubsub_informationmodel_methods pubsub/check_pubsub_informationmodel_methods.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  276. target_link_libraries(check_pubsub_informationmodel_methods ${LIBS})
  277. add_test(check_pubsub_informationmodel_methods ${TESTS_BINARY_DIR}/check_pubsub_informationmodel_methods)
  278. endif()
  279. endif()
  280. if(UA_ENABLE_PUBSUB_MQTT)
  281. if(NOT WIN32)
  282. add_executable(check_pubsub_connection_mqtt pubsub/check_pubsub_connection_mqtt.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  283. target_link_libraries(check_pubsub_connection_mqtt ${LIBS})
  284. add_test_valgrind(pubsub_connection_mqtt ${TESTS_BINARY_DIR}/check_pubsub_connection_mqtt)
  285. endif()
  286. endif()
  287. endif()
  288. add_executable(check_server_readspeed server/check_server_readspeed.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  289. target_link_libraries(check_server_readspeed ${LIBS})
  290. add_test_no_valgrind(server_readspeed ${TESTS_BINARY_DIR}/check_server_readspeed)
  291. add_executable(check_server_speed_addnodes server/check_server_speed_addnodes.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  292. target_link_libraries(check_server_speed_addnodes ${LIBS})
  293. add_test_no_valgrind(server_speed_addnodes ${TESTS_BINARY_DIR}/check_server_speed_addnodes)
  294. if(UA_ENABLE_SUBSCRIPTIONS)
  295. add_executable(check_server_monitoringspeed server/check_server_monitoringspeed.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  296. target_link_libraries(check_server_monitoringspeed ${LIBS})
  297. add_test_no_valgrind(server_monitoringspeed ${TESTS_BINARY_DIR}/check_server_monitoringspeed)
  298. endif()
  299. if(UA_ENABLE_ASYNCOPERATIONS)
  300. add_executable(check_server_asyncop server/check_server_asyncop.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  301. target_link_libraries(check_server_asyncop ${LIBS})
  302. add_test_valgrind(server_asyncop ${TESTS_BINARY_DIR}/check_server_asyncop)
  303. endif()
  304. # Test Client
  305. add_executable(check_client client/check_client.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  306. target_link_libraries(check_client ${LIBS})
  307. add_test_valgrind(client ${TESTS_BINARY_DIR}/check_client)
  308. add_executable(check_client_securechannel client/check_client_securechannel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  309. target_link_libraries(check_client_securechannel ${LIBS})
  310. add_test_valgrind(client_securechannel ${TESTS_BINARY_DIR}/check_client_securechannel)
  311. add_executable(check_client_async client/check_client_async.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  312. target_link_libraries(check_client_async ${LIBS})
  313. add_test_valgrind(client_async ${TESTS_BINARY_DIR}/check_client_async)
  314. add_executable(check_client_async_connect client/check_client_async_connect.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  315. target_link_libraries(check_client_async_connect ${LIBS})
  316. add_test_valgrind(client_async_connect ${TESTS_BINARY_DIR}/check_client_async_connect)
  317. add_executable(check_client_subscriptions client/check_client_subscriptions.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  318. target_link_libraries(check_client_subscriptions ${LIBS})
  319. add_test_valgrind(client_subscriptions ${TESTS_BINARY_DIR}/check_client_subscriptions)
  320. add_executable(check_client_highlevel client/check_client_highlevel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  321. target_link_libraries(check_client_highlevel ${LIBS})
  322. add_test_valgrind(client_highlevel ${TESTS_BINARY_DIR}/check_client_highlevel)
  323. if(UA_ENABLE_HISTORIZING)
  324. add_executable(check_client_historical_data client/check_client_historical_data.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  325. target_link_libraries(check_client_historical_data ${LIBS})
  326. add_test_valgrind(client_historical_data ${TESTS_BINARY_DIR}/check_client_historical_data)
  327. endif()
  328. # Test Encryption
  329. if(UA_ENABLE_ENCRYPTION)
  330. add_executable(check_encryption_basic128rsa15 encryption/check_encryption_basic128rsa15.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  331. target_link_libraries(check_encryption_basic128rsa15 ${LIBS})
  332. add_test_valgrind(encryption_basic128rsa15 ${TESTS_BINARY_DIR}/check_encryption_basic128rsa15)
  333. add_executable(check_encryption_basic256sha256 encryption/check_encryption_basic256sha256.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  334. target_link_libraries(check_encryption_basic256sha256 ${LIBS})
  335. add_test_valgrind(encryption_basic256sha256 ${TESTS_BINARY_DIR}/check_encryption_basic256sha256)
  336. endif()
  337. # Tests for Nodeset Compiler
  338. add_subdirectory(nodeset-compiler)