CMakeLists.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. # Load CMake Packages
  2. find_package(Check REQUIRED)
  3. set(LIBS ${CHECK_LIBRARIES} ${open62541_LIBRARIES})
  4. include_directories(${CHECK_INCLUDE_DIRS})
  5. find_package(Threads REQUIRED)
  6. if(NOT MSVC AND UA_ENABLE_UNIT_TESTS_MEMCHECK)
  7. find_package(Valgrind REQUIRED)
  8. endif()
  9. include_directories(${PROJECT_SOURCE_DIR}/include)
  10. include_directories(${PROJECT_SOURCE_DIR}/deps)
  11. include_directories(${PROJECT_SOURCE_DIR}/src)
  12. include_directories(${PROJECT_SOURCE_DIR}/src/server)
  13. include_directories(${PROJECT_SOURCE_DIR}/src/pubsub)
  14. include_directories(${PROJECT_SOURCE_DIR}/plugins)
  15. include_directories(${PROJECT_BINARY_DIR}/src_generated)
  16. include_directories(${PROJECT_SOURCE_DIR}/tests/testing-plugins)
  17. add_definitions(-DUA_sleep_ms=UA_comboSleep)
  18. #############################
  19. # Compiled binaries folders #
  20. #############################
  21. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/tests)
  22. if (MSVC)
  23. set(TESTS_BINARY_DIR ${CMAKE_BINARY_DIR}/bin/tests/${CMAKE_BUILD_TYPE})
  24. else()
  25. set(TESTS_BINARY_DIR ${CMAKE_BINARY_DIR}/bin/tests)
  26. endif()
  27. # Use different plugins for testing
  28. set(test_plugin_sources ${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.c
  29. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_clock.c
  30. ${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.c
  31. ${PROJECT_SOURCE_DIR}/plugins/ua_config_default.c
  32. ${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.c
  33. ${PROJECT_SOURCE_DIR}/plugins/ua_pki_certificate.c
  34. ${PROJECT_SOURCE_DIR}/plugins/ua_nodestore_default.c
  35. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_clock.c
  36. ${PROJECT_SOURCE_DIR}/plugins/ua_securitypolicy_none.c
  37. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_policy.c
  38. ${PROJECT_SOURCE_DIR}/tests/testing-plugins/testing_networklayers.c
  39. )
  40. if(UA_ENABLE_ENCRYPTION)
  41. set(test_plugin_sources ${test_plugin_sources}
  42. ${PROJECT_SOURCE_DIR}/plugins/ua_securitypolicy_basic128rsa15.c)
  43. set(test_plugin_sources ${test_plugin_sources}
  44. ${PROJECT_SOURCE_DIR}/plugins/ua_securitypolicy_basic256sha256.c)
  45. endif()
  46. add_library(open62541-testplugins OBJECT ${test_plugin_sources})
  47. add_dependencies(open62541-testplugins open62541)
  48. target_compile_definitions(open62541-testplugins PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
  49. if(NOT MSVC)
  50. add_definitions(-Wno-deprecated-declarations)
  51. endif()
  52. # Workaround some clang warnings in the uni tests
  53. if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang"))
  54. add_definitions(-Wno-sign-conversion)
  55. endif()
  56. # Unit Test Definition Macro
  57. # For now we need to disable the libc freeres. See https://github.com/open62541/open62541/pull/1003#issuecomment-315045143
  58. # This also requires to disable the phtread cache with no-nptl-pthread-stackcache
  59. set(VALGRIND_FLAGS --quiet --trace-children=yes --leak-check=full --run-libc-freeres=no --sim-hints=no-nptl-pthread-stackcache --track-fds=yes)
  60. macro(add_test_valgrind TEST_NAME)
  61. if(UA_ENABLE_UNIT_TESTS_MEMCHECK)
  62. if(MSVC)
  63. add_test(${TEST_NAME} drmemory -batch -exit_code_if_errors 1 -results_to_stderr -summary -- ${ARGN})
  64. else()
  65. set(VALGRIND_LOG ${TESTS_BINARY_DIR}/${TEST_NAME}.log)
  66. set(VALGRIND_CMD valgrind --error-exitcode=1 --suppressions=${PROJECT_SOURCE_DIR}/tools/valgrind_suppressions.supp ${VALGRIND_FLAGS} --log-file=${VALGRIND_LOG} ${ARGN})
  67. add_test(${TEST_NAME} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/valgrind_check_error.py ${VALGRIND_LOG} ${VALGRIND_CMD})
  68. endif()
  69. else()
  70. add_test(${TEST_NAME} ${ARGN})
  71. endif()
  72. if (UA_BUILD_FUZZING_CORPUS)
  73. target_sources(check_${TEST_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/tests/fuzz/ua_debug_dump_pkgs_file.c)
  74. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/corpus/${TEST_NAME})
  75. target_compile_definitions(check_${TEST_NAME} PRIVATE UA_CORPUS_OUTPUT_DIR="${PROJECT_BINARY_DIR}/corpus/${TEST_NAME}")
  76. endif()
  77. endmacro()
  78. add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
  79. # the unit test are built directly on the open62541 object files. so they can
  80. # access symbols that are hidden/not exported to the shared library
  81. add_executable(check_types_builtin check_types_builtin.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  82. target_link_libraries(check_types_builtin ${LIBS})
  83. add_test_valgrind(types_builtin ${TESTS_BINARY_DIR}/check_types_builtin)
  84. add_executable(check_types_memory check_types_memory.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  85. target_link_libraries(check_types_memory ${LIBS})
  86. add_test_valgrind(types_memory ${TESTS_BINARY_DIR}/check_types_memory)
  87. add_executable(check_types_range check_types_range.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  88. target_link_libraries(check_types_range ${LIBS})
  89. add_test_valgrind(types_range ${TESTS_BINARY_DIR}/check_types_range)
  90. add_executable(check_types_custom check_types_custom.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  91. target_link_libraries(check_types_custom ${LIBS})
  92. add_test_valgrind(types_custom ${TESTS_BINARY_DIR}/check_types_custom)
  93. add_executable(check_chunking check_chunking.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  94. target_link_libraries(check_chunking ${LIBS})
  95. add_test_valgrind(chunking ${TESTS_BINARY_DIR}/check_chunking)
  96. add_executable(check_utils check_utils.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  97. target_link_libraries(check_utils ${LIBS})
  98. add_test_valgrind(utils ${TESTS_BINARY_DIR}/check_utils)
  99. add_executable(check_securechannel check_securechannel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  100. target_link_libraries(check_securechannel ${LIBS})
  101. add_test_valgrind(securechannel ${TESTS_BINARY_DIR}/check_securechannel)
  102. # Test Server
  103. add_executable(check_accesscontrol server/check_accesscontrol.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  104. target_link_libraries(check_accesscontrol ${LIBS})
  105. add_test_valgrind(accesscontrol ${TESTS_BINARY_DIR}/check_accesscontrol)
  106. add_executable(check_services_view server/check_services_view.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  107. target_link_libraries(check_services_view ${LIBS})
  108. add_test_valgrind(services_view ${TESTS_BINARY_DIR}/check_services_view)
  109. add_executable(check_services_attributes server/check_services_attributes.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  110. target_link_libraries(check_services_attributes ${LIBS})
  111. add_test_valgrind(services_attributes ${TESTS_BINARY_DIR}/check_services_attributes)
  112. add_executable(check_services_nodemanagement server/check_services_nodemanagement.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  113. target_link_libraries(check_services_nodemanagement ${LIBS})
  114. add_test_valgrind(services_nodemanagement ${TESTS_BINARY_DIR}/check_services_nodemanagement)
  115. add_executable(check_services_subscriptions server/check_services_subscriptions.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  116. target_link_libraries(check_services_subscriptions ${LIBS})
  117. add_test_valgrind(services_subscriptions ${TESTS_BINARY_DIR}/check_services_subscriptions)
  118. add_executable(check_monitoreditem_filter server/check_monitoreditem_filter.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  119. target_link_libraries(check_monitoreditem_filter ${LIBS})
  120. add_test_valgrind(monitoreditem_filter ${TESTS_BINARY_DIR}/check_monitoreditem_filter)
  121. add_executable(check_nodestore server/check_nodestore.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  122. target_link_libraries(check_nodestore ${LIBS})
  123. add_test_valgrind(nodestore ${TESTS_BINARY_DIR}/check_nodestore)
  124. add_executable(check_session server/check_session.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  125. target_link_libraries(check_session ${LIBS})
  126. add_test_valgrind(session ${TESTS_BINARY_DIR}/check_session)
  127. add_executable(check_server_jobs server/check_server_jobs.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  128. target_link_libraries(check_server_jobs ${LIBS})
  129. add_test_valgrind(server_jobs ${TESTS_BINARY_DIR}/check_server_jobs)
  130. add_executable(check_server_userspace server/check_server_userspace.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  131. target_link_libraries(check_server_userspace ${LIBS})
  132. add_test_valgrind(server_userspace ${TESTS_BINARY_DIR}/check_server_userspace)
  133. add_executable(check_node_inheritance server/check_node_inheritance.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  134. target_link_libraries(check_node_inheritance ${LIBS})
  135. add_test_valgrind(node_inheritance ${TESTS_BINARY_DIR}/check_node_inheritance)
  136. if(UA_ENABLE_DISCOVERY)
  137. add_executable(check_discovery server/check_discovery.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  138. target_link_libraries(check_discovery ${LIBS})
  139. add_test_valgrind(discovery ${TESTS_BINARY_DIR}/check_discovery)
  140. endif()
  141. if(UA_ENABLE_PUBSUB)
  142. add_executable(check_pubsub_encoding pubsub/check_pubsub_encoding.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  143. target_link_libraries(check_pubsub_encoding ${LIBS})
  144. add_test_valgrind(pubsub_encoding ${TESTS_BINARY_DIR}/check_pubsub_encoding)
  145. add_executable(check_pubsub_connection_udp pubsub/check_pubsub_connection_udp.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  146. target_link_libraries(check_pubsub_connection_udp ${LIBS})
  147. add_test(NAME check_pubsub_connection_udp COMMAND check_pubsub_connection_udp)
  148. add_executable(check_pubsub_pds pubsub/check_pubsub_pds.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  149. target_link_libraries(check_pubsub_pds ${LIBS})
  150. add_test(check_pubsub_pds ${TESTS_BINARY_DIR}/check_pubsub_pds)
  151. add_executable(check_pubsub_publish pubsub/check_pubsub_publish.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-plugins>)
  152. target_link_libraries(check_pubsub_publish ${LIBS})
  153. add_test(check_pubsub_publish ${TESTS_BINARY_DIR}/check_pubsub_publish)
  154. endif()
  155. add_executable(check_server_readspeed server/check_server_readspeed.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  156. target_link_libraries(check_server_readspeed ${LIBS})
  157. add_test_valgrind(server_readspeed ${TESTS_BINARY_DIR}/check_server_readspeed)
  158. # Test Client
  159. add_executable(check_client client/check_client.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  160. target_link_libraries(check_client ${LIBS})
  161. add_test_valgrind(client ${TESTS_BINARY_DIR}/check_client)
  162. add_executable(check_client_securechannel client/check_client_securechannel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  163. target_link_libraries(check_client_securechannel ${LIBS})
  164. add_test_valgrind(client_securechannel ${TESTS_BINARY_DIR}/check_client_securechannel)
  165. add_executable(check_client_async client/check_client_async.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  166. target_link_libraries(check_client_async ${LIBS})
  167. add_test_valgrind(client_async ${TESTS_BINARY_DIR}/check_client_async)
  168. add_executable(check_client_subscriptions client/check_client_subscriptions.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  169. target_link_libraries(check_client_subscriptions ${LIBS})
  170. add_test_valgrind(client_subscriptions ${TESTS_BINARY_DIR}/check_client_subscriptions)
  171. add_executable(check_client_highlevel client/check_client_highlevel.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  172. target_link_libraries(check_client_highlevel ${LIBS})
  173. add_test_valgrind(client_highlevel ${TESTS_BINARY_DIR}/check_client_highlevel)
  174. # Test Encryption
  175. if(UA_ENABLE_ENCRYPTION)
  176. add_executable(check_encryption_basic128rsa15 encryption/check_encryption_basic128rsa15.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  177. target_link_libraries(check_encryption_basic128rsa15 ${LIBS})
  178. add_test_valgrind(encryption_basic128rsa15 ${TESTS_BINARY_DIR}/check_encryption_basic128rsa15)
  179. add_executable(check_encryption_basic256sha256 encryption/check_encryption_basic256sha256.c $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  180. target_link_libraries(check_encryption_basic256sha256 ${LIBS})
  181. add_test_valgrind(encryption_basic256sha256 ${TESTS_BINARY_DIR}/check_encryption_basic256sha256)
  182. endif()
  183. #############################
  184. # #
  185. # Test for Nodeset Compiler #
  186. # #
  187. #############################
  188. # can only be tested if UA_ENABLE_FULL_NS0
  189. if (UA_ENABLE_FULL_NS0)
  190. file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated/tests")
  191. # Generate types for DI namespace
  192. set(UA_TYPES_OUT "ua_types_di")
  193. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c
  194. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.h
  195. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_handling.h
  196. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_encoding_binary.h
  197. PRE_BUILD
  198. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  199. --namespace=2
  200. --type-csv=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv
  201. --type-bsd=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd
  202. --no-builtin
  203. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}
  204. DEPENDS ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  205. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv
  206. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd)
  207. add_custom_target(open62541-generator-tests-types-di DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c)
  208. # Generate types for ADI namespace
  209. set(UA_TYPES_OUT "ua_types_adi")
  210. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c
  211. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.h
  212. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_handling.h
  213. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_encoding_binary.h
  214. PRE_BUILD
  215. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  216. --namespace=3
  217. --type-csv=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/OpcUaAdiModel.csv
  218. --type-bsd=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.Types.bsd
  219. --no-builtin
  220. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}
  221. DEPENDS ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  222. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/OpcUaAdiModel.csv
  223. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.Types.bsd)
  224. add_custom_target(open62541-generator-tests-types-adi DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c)
  225. # generate DI namespace
  226. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c
  227. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.h
  228. PRE_BUILD
  229. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  230. --internal-headers
  231. --types-array=UA_TYPES
  232. --types-array=UA_TYPES_DI
  233. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  234. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  235. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di
  236. DEPENDS ${UA_NAMESPACE0_XML}
  237. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  238. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  239. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  240. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  241. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  242. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  243. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  244. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  245. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  246. )
  247. add_custom_target(open62541-generator-tests-ns-di DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c)
  248. add_dependencies(open62541-generator-tests-ns-di open62541-generator-tests-types-di)
  249. # generate ADI namespace which is using DI
  250. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.c
  251. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.h
  252. PRE_BUILD
  253. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  254. --internal-headers
  255. --types-array=UA_TYPES
  256. --types-array=UA_TYPES_DI
  257. --types-array=UA_TYPES_ADI
  258. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  259. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  260. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.NodeSet2.xml
  261. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi
  262. DEPENDS ${UA_NAMESPACE0_XML}
  263. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  264. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  265. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  266. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  267. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  268. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  269. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  270. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  271. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  272. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.NodeSet2.xml
  273. )
  274. add_custom_target(open62541-generator-tests-ns-adi DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.c)
  275. add_dependencies(open62541-generator-tests-ns-adi open62541-generator-tests-types-adi open62541-generator-tests-ns-di)
  276. # generate PLCopen namespace which is using DI
  277. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.c
  278. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.h
  279. PRE_BUILD
  280. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  281. --internal-headers
  282. --types-array=UA_TYPES
  283. --types-array=UA_TYPES_DI
  284. # PLCopen has no specific type definition, thus use the default UA_TYPES to ignore it
  285. --types-array=UA_TYPES
  286. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  287. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  288. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml
  289. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc
  290. DEPENDS ${UA_NAMESPACE0_XML}
  291. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  292. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  293. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  294. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  295. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  296. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  297. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  298. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  299. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml
  300. )
  301. add_custom_target(open62541-generator-tests-ns-plc DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.c)
  302. add_dependencies(open62541-generator-tests-ns-plc open62541-generator-tests-ns-di)
  303. add_executable(check_nodeset_compiler_adi
  304. server/check_nodeset_compiler_adi.c
  305. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_types_di_generated.c
  306. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c
  307. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_types_adi_generated.c
  308. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.c
  309. $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  310. add_dependencies(check_nodeset_compiler_adi open62541-generator-tests-ns-adi)
  311. target_link_libraries(check_nodeset_compiler_adi ${LIBS})
  312. add_test_valgrind(nodeset_compiler_adi ${TESTS_BINARY_DIR}/check_nodeset_compiler_adi)
  313. add_executable(check_nodeset_compiler_plc
  314. server/check_nodeset_compiler_plc.c
  315. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_types_di_generated.c
  316. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c
  317. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.c
  318. $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  319. add_dependencies(check_nodeset_compiler_plc open62541-generator-tests-ns-plc)
  320. target_link_libraries(check_nodeset_compiler_plc ${LIBS})
  321. add_test_valgrind(nodeset_compiler_plc ${TESTS_BINARY_DIR}/check_nodeset_compiler_plc)
  322. endif()