CMakeLists.txt 22 KB

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