CMakeLists.txt 23 KB

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