diff --git a/.github/workflows/ClangRelWithDebInfoAsan.yml b/.github/workflows/ClangRelWithDebInfoAsan.yml index 812f698..51db22b 100644 --- a/.github/workflows/ClangRelWithDebInfoAsan.yml +++ b/.github/workflows/ClangRelWithDebInfoAsan.yml @@ -64,9 +64,9 @@ jobs: run: | cmake "$GITHUB_WORKSPACE" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DENABLE_TESTING=ON \ + -DNODESETLOADER_ENABLE_TESTING=ON \ -DBUILD_SHARED_LIBS=ON \ - -DENABLE_ASAN=ON .. + -DNODESETLOADER_ENABLE_ASAN=ON .. - name: Build shell: bash diff --git a/.github/workflows/GccDebugMemcheck.yml b/.github/workflows/GccDebugMemcheck.yml index 739dcd6..aaeb490 100644 --- a/.github/workflows/GccDebugMemcheck.yml +++ b/.github/workflows/GccDebugMemcheck.yml @@ -97,10 +97,10 @@ jobs: run: | cmake "$GITHUB_WORKSPACE" \ -DCMAKE_BUILD_TYPE=Debug \ - -DENABLE_TESTING=ON \ + -DNODESETLOADER_ENABLE_TESTING=ON \ -DBUILD_SHARED_LIBS=ON \ - -DENABLE_DATATYPEIMPORT_TEST=ON \ - -DCALC_COVERAGE=ON \ + -DNODESETLOADER_ENABLE_DATATYPEIMPORT_TEST=ON \ + -DNODESETLOADER_CALC_COVERAGE=ON \ .. - name: Build diff --git a/.github/workflows/GccIntegrationTest.yml b/.github/workflows/GccIntegrationTest.yml index 8e2b012..3375346 100644 --- a/.github/workflows/GccIntegrationTest.yml +++ b/.github/workflows/GccIntegrationTest.yml @@ -92,9 +92,9 @@ jobs: run: | cmake "$GITHUB_WORKSPACE" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DENABLE_TESTING=ON \ + -DNODESETLOADER_ENABLE_TESTING=ON \ -DBUILD_SHARED_LIBS=ON \ - -DENABLE_INTEGRATION_TEST=ON \ + -DNODESETLOADER_ENABLE_INTEGRATION_TEST=ON \ .. - name: Build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 463162f..18a8850 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -38,7 +38,7 @@ jobs: run: | cd ./nodesetLoader && cmake "-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake-conan/conan_provider.cmake" -DCMAKE_BUILD_TYPE=Debug ` -DUA_NAMESPACE_ZERO=FULL ` - -DENABLE_TESTING=ON . && ` + -DNODESETLOADER_ENABLE_TESTING=ON . && ` cmake --build . - name: Test diff --git a/CMakeLists.txt b/CMakeLists.txt index ae0bddc..b437647 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,46 +6,55 @@ include(GNUInstallDirs) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -option(ENABLE_TESTING "enable tests" off) -option(ENABLE_EXAMPLES "enable examples" on) -option(ENABLE_BACKEND_STDOUT "backend for stdout" on) -option(ENABLE_ASAN "build with address sanitizer enabled" off) -option(ENABLE_INTEGRATION_TEST "run detailled tests to compare address spaces" off) -option(ENABLE_BUILD_INTO_OPEN62541 "make nodesetLoader part of the open62541 library" off) -option(ENABLE_DATATYPEIMPORT_TEST "run tests for importing datatypes" off) -option(CALC_COVERAGE "calculate code coverage" off) +option(NODESETLOADER_ENABLE_TESTING "enable tests" off) +option(NODESETLOADER_ENABLE_EXAMPLES "enable examples" on) +option(NODESETLOADER_ENABLE_BACKEND_STDOUT "backend for stdout" on) +option(NODESETLOADER_ENABLE_ASAN "build with address sanitizer enabled" off) +option(NODESETLOADER_ENABLE_INTEGRATION_TEST "run detailled tests to compare address spaces" off) +option(NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541 "make nodesetLoader part of the open62541 library" off) +option(NODESETLOADER_ENABLE_DATATYPEIMPORT_TEST "run tests for importing datatypes" off) +option(NODESETLOADER_CALC_COVERAGE "calculate code coverage" off) + +# deprecated options without project prefix +if(DEFINED ENABLE_BACKEND_STDOUT) + message(WARNING "ENABLE_BACKEND_STDOUT is deprecated. Use NODESETLOADER_ENABLE_BACKEND_STDOUT instead.") + set(NODESETLOADER_ENABLE_BACKEND_STDOUT ${ENABLE_BACKEND_STDOUT} CACHE BOOL "backend for stdout" FORCE) +endif() +if(DEFINED ENABLE_BUILD_INTO_OPEN62541) + message(WARNING "ENABLE_BUILD_INTO_OPEN62541 is deprecated. Use NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541 instead.") + set(NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541 ${ENABLE_BUILD_INTO_OPEN62541} CACHE BOOL "make nodesetLoader part of the open62541 library" FORCE) +endif() # TODO: Include integration tests after support for XML Data # Encoding has been added to the open62541 >= 1.3.2. # Currently, the integration tests will fail for # open62541 v1.3.2 and disable successful CI build. -set(ENABLE_INTEGRATION_TEST off) - -if(${ENABLE_BUILD_INTO_OPEN62541}) +set(NODESETLOADER_ENABLE_INTEGRATION_TEST off) +if(${NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541}) # Disble code coverage, since this will be covered within open62541 - set(CALC_COVERAGE off) + set(NODESETLOADER_CALC_COVERAGE off) # TODO: Enable nodesetLoader tests within open62541 test suite - set(ENABLE_TESTING off) + set(NODESETLOADER_ENABLE_TESTING off) # TODO: Enable nodesetLoader examples within open62541 - set(ENABLE_EXAMPLES off) + set(NODESETLOADER_ENABLE_EXAMPLES off) - set(ENABLE_BACKEND_STDOUT off) + set(NODESETLOADER_ENABLE_BACKEND_STDOUT off) endif() # LibXML2 is always required find_package(LibXml2 REQUIRED QUIET) -add_library(coverageLib INTERFACE) +add_library(NodesetLoaderCoverage INTERFACE) -if(NOT ${ENABLE_BUILD_INTO_OPEN62541}) +if(NOT ${NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541}) # open62541 ia always required. # But we need to avoid a cyclic dependency if the loader is built into open62541. find_package(open62541 REQUIRED) - if(${CALC_COVERAGE}) + if(${NODESETLOADER_CALC_COVERAGE}) #link against this library to gather coverage info #set(GCOV_COMPILE_OPTIONS -g -O0 -fno-inline -fno-inline-small-functions -fno-default-inline -fprofile-arcs -ftest-coverage) @@ -56,12 +65,12 @@ if(NOT ${ENABLE_BUILD_INTO_OPEN62541}) # compiling and -lgcov when linking #add_compile_options(--coverage -O0) #add_link_options(--coverage) - target_compile_options(coverageLib INTERFACE + target_compile_options(NodesetLoaderCoverage INTERFACE -O0 # no optimization -g # generate debug info --coverage # sets all required flags) ) - target_link_libraries(coverageLib INTERFACE --coverage) + target_link_libraries(NodesetLoaderCoverage INTERFACE --coverage) endif() if(MSVC) @@ -90,7 +99,7 @@ if(NOT ${ENABLE_BUILD_INTO_OPEN62541}) endif() endif() -if(${ENABLE_BUILD_INTO_OPEN62541}) +if(${NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541}) # Examples for the ${OPEN62541_VERSION} string are: # v1.2 # v1.2.3 @@ -175,7 +184,7 @@ else() endif() endif() -if(${ENABLE_TESTING}) +if(${NODESETLOADER_ENABLE_TESTING}) find_package(Check REQUIRED) if(NOT CHECK_LIBRARIES) set(CHECK_LIBRARIES Check::check) @@ -236,7 +245,7 @@ set(NODESETLOADER_PRIVATE_HEADERS ${NODESETLOADER_BACKEND_PRIVATE_HEADERS} CACHE INTERNAL "") -if(NOT ${ENABLE_BUILD_INTO_OPEN62541}) +if(NOT ${NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541}) add_library(NodesetLoader ${NODESETLOADER_SOURCES}) target_include_directories(NodesetLoader @@ -246,27 +255,27 @@ if(NOT ${ENABLE_BUILD_INTO_OPEN62541}) target_link_libraries(NodesetLoader PRIVATE ${NODESETLOADER_DEPS_LIBS}) target_link_libraries(NodesetLoader PRIVATE open62541::open62541) - if(${CALC_COVERAGE}) - target_link_libraries(NodesetLoader PUBLIC coverageLib) + if(${NODESETLOADER_CALC_COVERAGE}) + target_link_libraries(NodesetLoader PUBLIC NodesetLoaderCoverage) endif() target_compile_options(NodesetLoader PRIVATE ${C_COMPILE_DEFS}) set_target_properties(NodesetLoader PROPERTIES C_VISIBILITY_PRESET hidden) - if(${ENABLE_ASAN}) + if(${NODESETLOADER_ENABLE_ASAN}) target_link_libraries(NodesetLoader INTERFACE "-g -fno-omit-frame-pointer -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp -fsanitize=leak -fsanitize=undefined") endif() endif() -if(${ENABLE_TESTING}) +if(${NODESETLOADER_ENABLE_TESTING}) add_subdirectory(tests) endif() -if(${CALC_COVERAGE}) +if(${NODESETLOADER_CALC_COVERAGE}) add_subdirectory(coverage) endif() #install -if(NOT ${CALC_COVERAGE} AND NOT ${ENABLE_BUILD_INTO_OPEN62541}) +if(NOT ${NODESETLOADER_CALC_COVERAGE} AND NOT ${NODESETLOADER_ENABLE_BUILD_INTO_OPEN62541}) set_target_properties(NodesetLoader PROPERTIES PUBLIC_HEADER "${NODESETLOADER_PUBLIC_HEADERS}") install(TARGETS NodesetLoader diff --git a/backends/CMakeLists.txt b/backends/CMakeLists.txt index 4fd1a3a..a1d0319 100644 --- a/backends/CMakeLists.txt +++ b/backends/CMakeLists.txt @@ -6,7 +6,7 @@ set(NODESETLOADER_BACKEND_DEPS_LIBS "") set(NODESETLOADER_BACKEND_PUBLIC_HEADERS "") set(NODESETLOADER_BACKEND_PRIVATE_HEADERS "") -if(${ENABLE_BACKEND_STDOUT}) +if(${NODESETLOADER_ENABLE_BACKEND_STDOUT}) add_subdirectory(stdout) endif() diff --git a/backends/open62541/CMakeLists.txt b/backends/open62541/CMakeLists.txt index b58ce84..8c0512f 100644 --- a/backends/open62541/CMakeLists.txt +++ b/backends/open62541/CMakeLists.txt @@ -32,9 +32,9 @@ set(NODESETLOADER_BACKEND_OPEN62541_PRIVATE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/RefServiceImpl.h PARENT_SCOPE) -if(${ENABLE_TESTING}) +if(${NODESETLOADER_ENABLE_TESTING}) add_subdirectory(tests) endif() -if(${ENABLE_EXAMPLES}) +if(${NODESETLOADER_ENABLE_EXAMPLES}) add_subdirectory(examples) endif() diff --git a/backends/open62541/src/import.c b/backends/open62541/src/import.c index 5197a1d..5e59fda 100644 --- a/backends/open62541/src/import.c +++ b/backends/open62541/src/import.c @@ -410,6 +410,8 @@ addNodeImpl(AddNodeContext *context, NL_Node *node) { res = handleViewNode((const NL_ViewNode *)node, &id, &parentId, &parentReferenceId, <, &qn, &description, server); break; + default: + addedNodeStatus = UA_STATUSCODE_BADNOTIMPLEMENTED; } // If a node was not added to the server due to an error, we add such a node diff --git a/backends/open62541/tests/CMakeLists.txt b/backends/open62541/tests/CMakeLists.txt index f0555f9..fbeb263 100644 --- a/backends/open62541/tests/CMakeLists.txt +++ b/backends/open62541/tests/CMakeLists.txt @@ -160,10 +160,10 @@ add_test(NAME issue_266_Test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND issue_266 ${CMAKE_CURRENT_SOURCE_DIR}/issue266_TestData.NodeSet2.xml) -if(${ENABLE_DATATYPEIMPORT_TEST}) +if(${NODESETLOADER_ENABLE_DATATYPEIMPORT_TEST}) add_subdirectory(dataTypeImport) endif() -if(${ENABLE_INTEGRATION_TEST}) +if(${NODESETLOADER_ENABLE_INTEGRATION_TEST}) add_subdirectory(integration) endif() diff --git a/backends/stdout/CMakeLists.txt b/backends/stdout/CMakeLists.txt index 7a530f4..5332c23 100644 --- a/backends/stdout/CMakeLists.txt +++ b/backends/stdout/CMakeLists.txt @@ -1,3 +1,3 @@ -if(${ENABLE_EXAMPLES}) +if(${NODESETLOADER_ENABLE_EXAMPLES}) add_subdirectory(examples) endif() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f8ccbc7..28eb7dd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,21 +2,21 @@ add_executable(sort sort.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/Sort.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/Node.c) target_include_directories(sort PRIVATE ${CHECK_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_SOURCE_DIR}/../include) -target_link_libraries(sort PRIVATE ${CHECK_LIBRARIES} ${PTHREAD_LIB} coverageLib open62541::open62541) +target_link_libraries(sort PRIVATE ${CHECK_LIBRARIES} ${PTHREAD_LIB} NodesetLoaderCoverage open62541::open62541) add_test(NAME sort_Test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND sort ${CMAKE_CURRENT_LIST_DIR}) add_executable(nodeContainer NodeContainer.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/Node.c) target_include_directories(nodeContainer PRIVATE ${CHECK_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include ${CMAKE_CURRENT_SOURCE_DIR}/../src) -target_link_libraries(nodeContainer PRIVATE ${CHECK_LIBRARIES} ${PTHREAD_LIB} coverageLib open62541::open62541) +target_link_libraries(nodeContainer PRIVATE ${CHECK_LIBRARIES} ${PTHREAD_LIB} NodesetLoaderCoverage open62541::open62541) add_test(NAME nodeContainer_Test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND nodeContainer ${CMAKE_CURRENT_LIST_DIR}) add_executable(allocator allocator.c ${CMAKE_CURRENT_SOURCE_DIR}/../src/CharAllocator.c) target_include_directories(allocator PRIVATE ${CHECK_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../src) -target_link_libraries(allocator PRIVATE ${CHECK_LIBRARIES} ${PTHREAD_LIB} coverageLib open62541::open62541) +target_link_libraries(allocator PRIVATE ${CHECK_LIBRARIES} ${PTHREAD_LIB} NodesetLoaderCoverage open62541::open62541) add_test(NAME allocatorTest WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND allocator ${CMAKE_CURRENT_LIST_DIR}) add_executable(parser parser.c) -target_link_libraries(parser PRIVATE NodesetLoader ${CHECK_LIBRARIES} ${PTHREAD_LIB} coverageLib open62541::open62541) +target_link_libraries(parser PRIVATE NodesetLoader ${CHECK_LIBRARIES} ${PTHREAD_LIB} NodesetLoaderCoverage open62541::open62541) target_include_directories(parser PRIVATE ${CHECK_INCLUDE_DIR}) add_test(NAME parser_Test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}