diff --git a/.azure/templates/build-test.yml b/.azure/templates/build-test.yml
index 5caec2bc7d..d6076685d8 100644
--- a/.azure/templates/build-test.yml
+++ b/.azure/templates/build-test.yml
@@ -30,15 +30,15 @@ steps:
echo "###vso[task.setvariable variable=pip_cache;]${HOME}/.cache/pip"
echo "###vso[task.setvariable variable=PATH;]$(python3 -m site --user-base)/bin:${PATH}"
echo "###vso[task.setvariable variable=build_tool_options;]-j 4"
- sudo apt-get install -y clang clang-tools clang-tidy
+ sudo apt install -y clang clang-tools clang-tidy
condition: eq(variables['Agent.OS'], 'Linux')
name: setup_linux
- bash: |
+ set -e -x
+ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
echo "###vso[task.setvariable variable=pip_cache;]${HOME}/Library/Caches/pip"
echo "###vso[task.setvariable variable=PATH;]$(python3 -m site --user-base)/bin:${PATH}"
echo "###vso[task.setvariable variable=build_tool_options;]-j 4"
- sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
- brew install bison
condition: eq(variables['Agent.OS'], 'Darwin')
name: setup_macos
# Use PowerShell rather than Bash to ensure Windows-style paths
@@ -62,8 +62,6 @@ steps:
} else {
Write-Host "###vso[task.setvariable variable=build_tool_options;]-j 4"
}
- # On purpose do not install bison on windows to test the fallback to the parser.y in tree.
- # choco install winflexbison3
condition: eq(variables['Agent.OS'], 'Windows_NT')
name: setup_windows
- task: Cache@2
@@ -71,7 +69,6 @@ steps:
key: pip | 2 | $(Agent.OS)
path: $(pip_cache)
name: cache_pip
- - template: /.azure/templates/install-conan.yml
- bash: |
set -e -x
python -m pip install pip wheel setuptools --user --upgrade
@@ -90,6 +87,7 @@ steps:
iceoryx
mkdir iceoryx/build
cd iceoryx/build
+ [[ "${AGENT_OS}" == 'Darwin' ]] && BUILD_TOOL_OPTIONS="-j 4"
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_BUILD_SHARED_LIBS=on \
-DCMAKE_INSTALL_PREFIX=install \
@@ -101,10 +99,15 @@ steps:
set -e -x
mkdir build
cd build
- conan install -b missing -pr:b ${BUILD_PROFILE} -pr:h ${HOST_PROFILE} -s build_type=${BUILD_TYPE} ../${CONANFILE:-conanfile.txt}
+ prefix_path="${BUILD_SOURCESDIRECTORY}/iceoryx/build/install"
+ if [[ "${AGENT_OS}" == 'Darwin' ]] ; then
+ prefix_path="${prefix_path}:`brew --prefix openssl`"
+ # Azure sometimes adds a spurious ' to BUILD_TOOL_OPTIONS
+ BUILD_TOOL_OPTIONS="-j 4"
+ fi
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=install \
- -DCMAKE_PREFIX_PATH="${BUILD_SOURCESDIRECTORY}/iceoryx/build/install" \
+ -DCMAKE_PREFIX_PATH="${prefix_path//:/;}" \
-DANALYZER=${ANALYZER:-off} \
-DSANITIZER=${SANITIZER:-none} \
-DENABLE_SSL=${SSL:-on} \
@@ -142,11 +145,13 @@ steps:
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" "${INSTALLPREFIX}/share/CycloneDDS/examples/helloworld"
cmake --build . --config ${BUILD_TYPE} -- ${BUILD_TOOL_OPTIONS}
+ condition: ne(variables['testing'], 'off')
name: test
displayName: Test
- bash: |
set -e -x
cd build
+ [[ "${AGENT_OS}" == 'Darwin' ]] && BUILD_TOOL_OPTIONS="-j 4"
cmake --build . --config ${BUILD_TYPE} --target gcov -- ${BUILD_TOOL_OPTIONS}
gcovr --exclude '.*/tests/.*' --root "${BUILD_SOURCESDIRECTORY}" --json "$(System.DefaultWorkingDirectory)/coverage-$(Agent.JobName).json"
name: generate_code_coverage
diff --git a/.azure/templates/install-conan.yml b/.azure/templates/install-conan.yml
deleted file mode 100644
index 4eb38cdb47..0000000000
--- a/.azure/templates/install-conan.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Copyright(c) 2021 ZettaScale Technology and others
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v. 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
-# v. 1.0 which is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
-#
-
-steps:
- - bash: |
- echo "###vso[task.setvariable variable=conan_cache;]${HOME}/.conan/data"
- condition: ne(variables['Agent.OS'], 'Windows_NT')
- name: set_conan_cache_unix
- - pwsh: |
- Write-Host "###vso[task.setvariable variable=conan_cache;]${env:USERPROFILE}\\.conan\\data"
- # Set CONAN_BASH_PATH to avoid having to build msys2 for Conan packages.
- Write-Host "###vso[task.setvariable variable=CONAN_BASH_PATH;]C:\\msys64\\usr\\bin\\bash.exe"
- condition: eq(variables['Agent.OS'], 'Windows_NT')
- name: set_conan_cache_windows
- # Caching
- - task: Cache@2
- inputs:
- key: conan | 4 | $(Agent.OS) | $(arch) | $(cc) | $(build_type)
- path: $(conan_cache)
- name: cache_conan
- - bash: |
- set -e
- pip install "conan==1.59.0" --user
- # Derive build profile architechture from system architecture.
- case "${AGENT_OSARCHITECTURE}" in
- X86) build_arch=x86 ;;
- X64) build_arch=x86_64 ;;
- ARM) build_arch=armv8 ;;
- esac
- # Export Conan profile names for convenience.
- # * Build platform: Platform on which the compilation tools will run.
- # * Host platform: Platform on which the generated binaries will run.
- #
- # https://docs.conan.io/en/latest/systems_cross_building/cross_building.html
- echo "###vso[task.setvariable variable=build_profile;]${build_arch}"
- echo "###vso[task.setvariable variable=host_profile;]${ARCH}"
- # Automatically detect the build profile. Make sure CC and CXX
- # environment variables are set correctly on Microsoft Windows if a
- # different compiler than Visual Studio is desired.
- conan profile new ${build_arch} --detect
- [[ "$(conan profile get settings.compiler ${build_arch})" != "gcc" ]] || \
- conan profile update settings.compiler.libcxx=libstdc++11 ${build_arch}
- [[ "$(conan profile get settings.compiler ${build_arch})" != "Visual Studio" ]] || \
- [[ "${TOOLSET}" = "" ]] || \
- conan profile update settings.compiler.toolset=${TOOLSET} ${build_arch}
- # Generate a host profile if the architectures diverge.
- if [ "${ARCH}" != "${build_arch}" ]; then
- conan profile new ${ARCH} --detect
- conan profile update settings.arch=${ARCH} ${ARCH}
- conan profile update settings.arch_build=${ARCH} ${ARCH}
- [[ "$(conan profile get settings.compiler ${ARCH})" != "gcc" ]] || \
- conan profile update settings.compiler.libcxx=libstdc++11 ${ARCH}
- [[ "$(conan profile get settings.compiler ${build_arch})" != "Visual Studio" ]] || \
- [[ "${TOOLSET}" = "" ]] || \
- conan profile update settings.compiler.toolset=${TOOLSET} ${ARCH}
- fi
- name: install_conan
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 837d982c81..33aa9420a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
cmake_minimum_required(VERSION 3.16)
-project(CycloneDDS VERSION 0.10.3 LANGUAGES C)
+project(CycloneDDS VERSION 0.10.4 LANGUAGES C)
# Set a default build type if none was specified
set(default_build_type "RelWithDebInfo")
@@ -72,33 +72,6 @@ if(APPLE)
endif()
endif()
-# Conan
-if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
- include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
- if(APPLE)
- # By default Conan strips all RPATHs (see conanbuildinfo.cmake), which
- # causes tests to fail as the executables cannot find the library target.
- # By setting KEEP_RPATHS, Conan does not set CMAKE_SKIP_RPATH and the
- # resulting binaries still have the RPATH information. This is fine because
- # CMake will strip the build RPATH information in the install step.
- #
- # NOTE:
- # Conan's default approach is to use the "imports" feature, which copies
- # all the dependencies into the bin directory. Of course, this doesn't work
- # quite that well for libraries generated in this Project (see Conan
- # documentation).
- #
- # See the links below for more information.
- # https://github.com/conan-io/conan/issues/337
- # https://docs.conan.io/en/latest/howtos/manage_shared_libraries/rpaths.html
- # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
- conan_basic_setup(KEEP_RPATHS)
- else()
- conan_basic_setup()
- endif()
- conan_define_targets()
-endif()
-
# Set reasonably strict warning options for clang, gcc, msvc
# Enable coloured ouput if Ninja is used for building
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
@@ -227,9 +200,9 @@ endif()
find_package(codecov)
set(MEMORYCHECK_COMMAND_OPTIONS "--track-origins=yes --leak-check=full --trace-children=yes --child-silent-after-fork=yes --xml=yes --xml-file=TestResultValgrind_%p.xml --tool=memcheck --show-reachable=yes --leak-resolution=high")
-# By default building the testing tree is enabled by including CTest, but
-# since not everybody has CUnit, and because it is not strictly required to
-# build the product itself, switch to off by default.
+# Tests (integrated with CTest) are not built by default: not only are they not useful to
+# most people, building the test suite also forces exporting way more symbols from the
+# library so we can actually build the tests.
option(BUILD_TESTING "Build the testing tree." OFF)
# Include the tests for idlc. These tests use the idl compiler (C back-end) to
diff --git a/README.md b/README.md
index f50d45e6f1..4f65558542 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ while True:
sleep(rng.exponential())
```
-Today DDS is also popular in robotics and autonomous vehicles because those really depend on high-throuhgput, low-latency control systems without introducing a single point of failure by having a message broker in the middle.
+Today DDS is also popular in robotics and autonomous vehicles because those really depend on high-throughput, low-latency control systems without introducing a single point of failure by having a message broker in the middle.
Indeed, it is by far the most used and the default middleware choice in ROS 2.
It is used to transfer commands, sensor data and even video and point clouds between components.
@@ -99,7 +99,7 @@ With references to the individual OMG specifications, the following is available
- [DDS XTypes](https://www.omg.org/spec/DDS-XTypes/1.3/PDF) - the structural type system (some [caveats](docs/dev/xtypes_relnotes.md) here)
- [DDSI-RTPS](https://www.omg.org/spec/DDSI-RTPS/2.5/PDF) - the interoperable network protocol
-The network stack in Cyclone DDS has been around for over a decade in one form or another and has proven itself in many systems, including large, high-availability ones and systems where interoperation with other implementations was needed.
+The network stack in Cyclone DDS has been around for over a decade in one form or another and has proven itself in many systems, including large, high-availability ones and systems where interoperatibility with other implementations was needed.
This repository provides the core of Cyclone DDS including its C API, the [OMG C++](https://github.com/eclipse-cyclonedds/cyclonedds-cxx) and the [Python](https://github.com/eclipse-cyclonedds/cyclonedds-python) language bindings are in sibling repositories.
@@ -134,7 +134,7 @@ Depending on whether you want to develop applications using Cyclone DDS or contr
There are some configuration options specified using CMake defines in addition to the standard options like `CMAKE_BUILD_TYPE`:
* `-DBUILD_EXAMPLES=ON`: to build the included examples
-* `-DBUILD_TESTING=ON`: to build the test suite (this requires [CUnit](http://cunit.sourceforge.net/), see [Contributing to Eclipse Cyclone DDS](#contributing-to-eclipse-cyclone-dds) below for more information)
+* `-DBUILD_TESTING=ON`: to build the test suite (forces exporting all symbols from the library)
* `-DBUILD_IDLC=NO`: to disable building the IDL compiler (affects building examples, tests and `ddsperf`)
* `-DBUILD_DDSPERF=NO`: to disable building the [`ddsperf`](https://github.com/eclipse-cyclonedds/cyclonedds/tree/master/src/tools/ddsperf) tool for performance measurement
* `-DENABLE_SSL=NO`: to not look for OpenSSL, remove TLS/TCP support and avoid building the plugins that implement authentication and encryption (default is `AUTO` to enable them if OpenSSL is found)
@@ -189,7 +189,7 @@ Note that the default build type is a release build with debug information inclu
We very much welcome all contributions to the project, whether that is questions, examples, bug
fixes, enhancements or improvements to the documentation, or anything else really.
-When considering contributing code, it might be good to know that build configurations for Azure pipelines are present in the repository and that there is a test suite using CTest and CUnit that can be built locally if desired.
+When considering contributing code, it might be good to know that build configurations for Azure pipelines are present in the repository and that there is a test suite built using a simple testing framework and CTest that can be built locally if desired.
To build it, set the cmake variable `BUILD_TESTING` to on when configuring, e.g.:
$ cd build
@@ -197,17 +197,6 @@ To build it, set the cmake variable `BUILD_TESTING` to on when configuring, e.g.
$ cmake --build .
$ ctest
-Such a build requires the presence of [CUnit](http://cunit.sourceforge.net/).
-You can install this yourself, or you can choose to instead rely on the [Conan](https://conan.io) packaging system that the CI build infrastructure also uses.
-In that case, install Conan and do:
-
- $ conan install .. --build missing
-
-in the build directory prior to running cmake.
-
-For Windows, depending on the generator, you might also need to add switches to select the architecture and build type, e.g., `conan install -s arch=x86_64 -s build_type=Debug ..`
-This will automatically download and/or build CUnit (and, at the moment, OpenSSL).
-
## Documentation
The [documentation](https://cyclonedds.io/docs) is still rather limited and some parts of it are still only available in the form of text files in the `docs` directory.
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 3eea09d95f..ee6f38816b 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -52,12 +52,13 @@ jobs:
topic_discovery: off
idlc_testing: off # temporary dislabled because of passing -t option to idlc in this test for recursive types
cc: gcc-10
- 'Ubuntu 18.04 LTS with GCC 7 (Debug, x86_64)':
- image: ubuntu-18.04
- conanfile: conanfile102.txt
- cc: gcc-7
- 'Ubuntu 20.04 LTS with Clang 10 (Debug, x86_64)':
- image: ubuntu-20.04
+ 'Ubuntu 22.04 LTS with GCC 10 (Debug, x86_64, no tests)':
+ image: ubuntu-22.04
+ cc: gcc-10
+ testing: off
+ idlc_xtests: off
+ 'Ubuntu 22.04 LTS with Clang 12 (Debug, x86_64)':
+ image: ubuntu-22.04
analyzer: on
sanitizer: address,undefined
cc: clang-10
@@ -88,10 +89,19 @@ jobs:
sanitizer: undefined
cc: clang
coverage: on
- 'Windows 2019 with Visual Studio 2019 (Visual Studio 2017, Debug, x86)':
+ 'macOS 12 with gcc 12 (Debug, analyzer, x86_64)':
+ image: macOS-12
+ sanitizer: undefined
+ deadline_update_skip: on
+ cc: gcc-12
+ analyzer: on
+ # 32-bit Windows: without SSL/security because Chocolateley only provides 64-bit OpenSSL
+ 'Windows 2019 with Visual Studio 2019 (Visual Studio 2017, Debug, x86, no security)':
arch: x86
image: windows-2019
- idlc_testing: off
+ ssl: off
+ security: off
+ idlc_xtests: off
generator: 'Visual Studio 16 2019'
toolset: v141
'Windows 2019 with Visual Studio 2019 (Debug, x86_64)':
diff --git a/cmake/Modules/CUnit.cmake b/cmake/Modules/CUnit.cmake
index 601887c8c2..8b5e49a4d5 100644
--- a/cmake/Modules/CUnit.cmake
+++ b/cmake/Modules/CUnit.cmake
@@ -9,7 +9,6 @@
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
-find_package(CUnit REQUIRED)
set(CUNIT_DIR "${CMAKE_CURRENT_LIST_DIR}/CUnit")
@@ -227,14 +226,6 @@ function(set_test_library_paths TEST_NAME)
endfunction()
function(add_cunit_executable TARGET)
- # Retrieve location of shared libary, which is need to extend the PATH
- # environment variable on Microsoft Windows, so that the operating
- # system can locate the .dll that it was linked against.
- # On macOS, this mechanism is used to set the DYLD_LIBRARY_PATH.
- get_target_property(CUNIT_LIBRARY_TYPE CUnit TYPE)
- get_target_property(CUNIT_IMPORTED_LOCATION CUnit IMPORTED_LOCATION)
- get_filename_component(CUNIT_LIBRARY_DIR "${CUNIT_IMPORTED_LOCATION}" PATH)
-
set(decls)
set(defns)
set(sources)
@@ -322,8 +313,7 @@ function(add_cunit_executable TARGET)
add_executable(
${TARGET} "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c" ${sources})
- target_link_libraries(${TARGET} PRIVATE CUnit)
- target_include_directories(${TARGET} PRIVATE "${CUNIT_DIR}/include")
+ target_link_libraries(${TARGET} PRIVATE CycloneDDS::ucunit)
if(MSVC)
target_compile_definitions(${TARGET} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
diff --git a/cmake/Modules/CUnit/src/main.c.in b/cmake/Modules/CUnit/src/main.c.in
index 37bd1363e9..c7b4746739 100644
--- a/cmake/Modules/CUnit/src/main.c.in
+++ b/cmake/Modules/CUnit/src/main.c.in
@@ -22,20 +22,10 @@
static struct {
bool print_help;
- bool automated;
- bool junit;
- const char *results;
- CU_BasicRunMode mode;
- CU_ErrorAction error_action;
const char *suite;
const char *test;
} opts = {
false,
- false,
- false,
- NULL,
- CU_BRM_NORMAL,
- CUEA_IGNORE,
"*",
"*"
};
@@ -88,11 +78,7 @@ static void help(const char *name)
printf("Usage: %s [OPTIONS]\n", name);
printf("\n");
printf("Possible options:\n");
- printf(" -a run in automated mode\n");
- printf(" -f fail fast\n");
printf(" -h display this help and exit\n");
- printf(" -j junit format results \n");
- printf(" -r FILENAME results file for automated run\n");
printf(" -s PATTERN run only tests in suites matching pattern\n");
printf(" -t PATTERN run only test matching pattern\n");
printf("\n");
@@ -109,24 +95,9 @@ static int parse_options(int argc, char *argv[])
for (int i = 1; err == 0 && i < argc; i++) {
switch ((argv[i][0] == '-') ? argv[i][1] : 0) {
- case 'a':
- opts.automated = true;
- break;
- case 'f':
- opts.error_action = CUEA_FAIL;
- break;
case 'h':
opts.print_help = true;
break;
- case 'j':
- opts.junit = true;
- break;
- case 'r':
- if((i+1) < argc){
- opts.results = argv[++i];
- break;
- }
- /* FALLS THROUGH */
case 's':
if ((i+1) < argc) {
opts.suite = argv[++i];
@@ -205,27 +176,7 @@ int main(int argc, char *argv[])
/* CMake will expand the macro below to register all suites and tests. */
@defns@
- CU_set_error_action(opts.error_action);
-
- if (opts.automated) {
- if (opts.results != NULL) {
- CU_set_output_filename(opts.results);
- }
-
-#if defined(HAVE_ENABLE_JUNIT_XML)
- if (opts.junit) {
- CU_automated_enable_junit_xml(CU_TRUE);
- } else
-#endif
- {
- CU_list_tests_to_file();
- }
- CU_automated_run_tests();
- } else {
- CU_set_fail_on_inactive(0);
- CU_basic_set_mode(opts.mode);
- CU_basic_run_tests();
- }
+ CU_basic_run_tests();
if (CU_get_error() != CUE_SUCCESS) {
ret = EX_SOFTWARE;
diff --git a/cmake/Modules/FindCUnit.cmake b/cmake/Modules/FindCUnit.cmake
deleted file mode 100644
index 5925ab481f..0000000000
--- a/cmake/Modules/FindCUnit.cmake
+++ /dev/null
@@ -1,120 +0,0 @@
-#
-# Copyright(c) 2006 to 2021 ZettaScale Technology and others
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v. 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
-# v. 1.0 which is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
-#
-find_package(CUnit CONFIG QUIET)
-if(CUnit_FOUND)
- message(STATUS "Found CUnit via Config file: ${CUnit_DIR}")
- set(CUNIT_FOUND ${CUnit_FOUND})
-else()
- set(CUNIT_HEADER "CUnit/CUnit.h")
-
- if(CONAN_INCLUDE_DIRS)
- find_path(CUNIT_INCLUDE_DIR ${CUNIT_HEADER} HINTS ${CONAN_INCLUDE_DIRS})
- else()
- find_path(CUNIT_INCLUDE_DIR ${CUNIT_HEADER})
- endif()
-
- mark_as_advanced(CUNIT_INCLUDE_DIR)
-
- if(CUNIT_INCLUDE_DIR AND EXISTS "${CUNIT_INCLUDE_DIR}/${CUNIT_HEADER}")
- set(PATTERN "^#define CU_VERSION \"([0-9]+)\\.([0-9]+)\\-([0-9]+)\"$")
- file(STRINGS "${CUNIT_INCLUDE_DIR}/${CUNIT_HEADER}" CUNIT_H REGEX "${PATTERN}")
-
- string(REGEX REPLACE "${PATTERN}" "\\1" CUNIT_VERSION_MAJOR "${CUNIT_H}")
- string(REGEX REPLACE "${PATTERN}" "\\2" CUNIT_VERSION_MINOR "${CUNIT_H}")
- string(REGEX REPLACE "${PATTERN}" "\\3" CUNIT_VERSION_PATCH "${CUNIT_H}")
-
- set(CUNIT_VERSION "${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}-${CUNIT_VERSION_PATCH}")
- endif()
-
- if(CONAN_LIB_DIRS_CUNIT)
- # CUnit package in ConanCenter contains a cunit.dll.lib on Windows if
- # shared=True. Probably a bug not to simply name it cunit.lib, but strip
- # the last extension from each library and use it as input.
- foreach(path ${CONAN_LIBS_CUNIT})
- get_filename_component(name "${path}" NAME)
- # NAME_WLE mode for get_filename_component available since CMake >= 3.14
- string(REGEX REPLACE "\.[^\.]+$" "" name_wle "${name}")
- list(APPEND names ${name_wle})
- endforeach()
- find_library(CUNIT_LIBRARY NAMES cunit ${names} HINTS ${CONAN_LIB_DIRS_CUNIT})
- else()
- find_library(CUNIT_LIBRARY NAMES cunit)
- endif()
-endif()
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(
- CUnit
- REQUIRED_VARS
- CUNIT_LIBRARY CUNIT_INCLUDE_DIR
- VERSION_VAR
- CUNIT_VERSION)
-
-if(CUNIT_FOUND)
- set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
- set(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
-
- if(WIN32)
- get_filename_component(CUNIT_LIBRARY_DIR "${CUNIT_LIBRARY}}" PATH)
- get_filename_component(CUNIT_BASENAME "${CUNIT_LIBRARY}}" NAME_WE)
- get_filename_component(CUNIT_PREFIX "${CUNIT_LIBRARY_DIR}" PATH)
-
- if(CONAN_LIB_DIRS_CUNIT)
- # CUnit package in ConanCenter shipped cunit-1.dll on Windows with
- # shared=True. Probably a bug. Especially since the other file was named
- # cunit.dll.lib.
- set(_expr "${CUNIT_PREFIX}/${CUNIT_BASENAME}*${CMAKE_SHARED_LIBRARY_SUFFIX}")
- file(GLOB_RECURSE _paths FALSE "${_expr}")
- foreach(_path "${CMAKE_SHARED_LIBRARY_PREFIX}${CUNIT_BASENAME}" ${_paths})
- get_filename_component(_name "${_path}" NAME)
- string(REGEX REPLACE "\.[^\.]+$" "" _name_wle "${_name}")
- find_program(
- CUNIT_DLL
- "${_name_wle}${CMAKE_SHARED_LIBRARY_SUFFIX}"
- HINTS
- "${CUNIT_PREFIX}"
- PATH_SUFFIXES
- bin
- NO_DEFAULT_PATH)
- if(CUNIT_DLL)
- break()
- endif()
- endforeach()
- endif()
-
- mark_as_advanced(CUNIT_DLL)
-
- # IMPORTANT:
- # Providing a .dll file as the value for IMPORTED_LOCATION can only be
- # done for "SHARED" libraries, otherwise the location of the .dll will be
- # passed to linker, causing it to fail.
- if(CUNIT_DLL)
- add_library(CUnit SHARED IMPORTED)
- set_target_properties(
- CUnit PROPERTIES IMPORTED_IMPLIB "${CUNIT_LIBRARY}")
- set_target_properties(
- CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_DLL}")
- else()
- add_library(CUnit STATIC IMPORTED)
- set_target_properties(
- CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_LIBRARY}")
- endif()
- else()
- add_library(CUnit UNKNOWN IMPORTED)
- set_target_properties(
- CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_LIBRARY}")
- endif()
-
- set_target_properties(
- CUnit PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUNIT_INCLUDE_DIR}")
-endif()
-
diff --git a/conanfile.txt b/conanfile.txt
deleted file mode 100644
index 68f020213e..0000000000
--- a/conanfile.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-[requires]
-cunit/2.1-3
-openssl/1.1.1j
-
-[generators]
-cmake
-
-[options]
-cunit:shared=True
diff --git a/conanfile102.txt b/conanfile102.txt
deleted file mode 100644
index 8fc9cedcdf..0000000000
--- a/conanfile102.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-[requires]
-cunit/2.1-3
-openssl/1.0.2u
-
-[generators]
-cmake
-
-[options]
-cunit:shared=True
diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md
index c1b0bf160a..4e69526eca 100644
--- a/docs/dev/debugging.md
+++ b/docs/dev/debugging.md
@@ -53,27 +53,13 @@ $ apt-get install gcc-8 g++-8 clang-6.0 bison
su - travis
```
-5. Install The [Conan C/C++ Package Manager](https://conan.io).
-
- ```
-$ pip install conan --upgrade --user
-$ conan user
-```
-
-6. Add the required repositories.
-
- ```
-$ conan remote add atolab https://api.bintray.com/conan/atolab/public-conan
-$ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
-```
-
-7. Clone the git repository.
+5. Clone the git repository.
```
$ git clone https://github.com/eclipse-cyclonedds/cyclonedds.git
```
-8. Build the project and run the tests.
+6. Build the project and run the tests.
> By default CMake and Conan will choose *gcc*. To switch to *clang*, set the
> CC and CXX environment variables to clang and clang++ respectively.
@@ -83,7 +69,6 @@ $ export CC=gcc-8
$ export CXX=g++-8
$ cd cyclonedds
$ mkdir build
-$ conan install ..
$ cmake -DBUILD_TESTING=on ../src
$ cmake --build .
$ ctest -T test
diff --git a/docs/manual/options.md b/docs/manual/options.md
index c15df11959..4d9fbb1dae 100644
--- a/docs/manual/options.md
+++ b/docs/manual/options.md
@@ -480,7 +480,7 @@ The default value is: "default".
### //CycloneDDS/Domain/Internal
-Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AckDelay](#cycloneddsdomaininternalackdelay), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [BurstSize](#cycloneddsdomaininternalburstsize), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsidirectmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SocketReceiveBufferSize](#cycloneddsdomaininternalsocketreceivebuffersize), [SocketSendBufferSize](#cycloneddsdomaininternalsocketsendbuffersize), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriteBatch](#cycloneddsdomaininternalwritebatch), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
+Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AckDelay](#cycloneddsdomaininternalackdelay), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [BurstSize](#cycloneddsdomaininternalburstsize), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsidirectmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SocketReceiveBufferSize](#cycloneddsdomaininternalsocketreceivebuffersize), [SocketSendBufferSize](#cycloneddsdomaininternalsocketsendbuffersize), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
The Internal elements deal with a variety of settings that evolving and that are not necessarily fully supported. For the vast majority of the Internal settings, the functionality per-se is supported, but the right to change the way the options control the functionality is reserved. This includes renaming or moving options.
@@ -1039,14 +1039,6 @@ The unit must be specified explicitly. Recognised units: B (bytes), kB & KiB (2^
The default value is: "1 kB".
-#### //CycloneDDS/Domain/Internal/WriteBatch
-Boolean
-
-This element enables the batching of write operations. By default each write operation writes through the write cache and out onto the transport. Enabling write batching causes multiple small write operations to be aggregated within the write cache into a single larger write. This gives greater throughput at the expense of latency. Currently there is no mechanism for the write cache to automatically flush itself, so that if write batching is enabled, the application may have to use the dds\_write\_flush function to ensure that all samples are written.
-
-The default value is: "false".
-
-
#### //CycloneDDS/Domain/Internal/WriterLingerDuration
Number-with-unit
@@ -1864,11 +1856,11 @@ The categorisation of tracing output is incomplete and hence most of the verbosi
The default value is: "none".
-
+
-
+
diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc
index 41730b9e3d..1b437bb995 100644
--- a/etc/cyclonedds.rnc
+++ b/etc/cyclonedds.rnc
@@ -737,12 +737,6 @@ CycloneDDS configuration""" ] ]
}?
}?
& [ a:documentation [ xml:lang="en" """
-
This element enables the batching of write operations. By default each write operation writes through the write cache and out onto the transport. Enabling write batching causes multiple small write operations to be aggregated within the write cache into a single larger write. This gives greater throughput at the expense of latency. Currently there is no mechanism for the write cache to automatically flush itself, so that if write batching is enabled, the application may have to use the dds_write_flush function to ensure that all samples are written.
-The default value is: "false".
""" ] ]
- element WriteBatch {
- xsd:boolean
- }?
- & [ a:documentation [ xml:lang="en" """
This setting controls the maximum duration for which actual deletion of a reliable writer with unacknowledged data in its history will be postponed to provide proper reliable transmission.
The unit must be specified explicitly. Recognised units: ns, us, ms, s, min, hr, day.
The default value is: "1 s".
""" ] ]
@@ -1296,11 +1290,11 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==
}
# generated from ddsi_config.h[87da706bc9c463a87326e87b311d8291d5761d43]
# generated from ddsi_cfgunits.h[fc550f1620aa20dcd9244ef4e24299d5001efbb4]
-# generated from ddsi_cfgelems.h[c54fbee60d780fadc6ebc3c738c5d2c5051e689a]
+# generated from ddsi_cfgelems.h[a294ec068e0de39ae662e4709f6ed3226a2412f2]
# generated from ddsi_config.c[98486715ac072b7b3cc3a449d55676be1218c98c]
# generated from _confgen.h[01ffa8a2e53b2309451756861466551cfe28c8ce]
# generated from _confgen.c[13cd40932d695abae1470202a42c18dc4d09ea84]
# generated from generate_rnc.c[a2ec6e48d33ac14a320c8ec3f320028a737920e0]
# generated from generate_md.c[a61b6a9649d18afeca4c73b5784f36989d7994e0]
# generated from generate_xsd.c[45064e8869b3c00573057d7c8f02d20f04b40e16]
-# generated from generate_defconfig.c[eec9ab7b2d053e68500799b693d089e84153a37b]
+# generated from generate_defconfig.c[421f8c9fd9bbfe320f985463dbe8f09c849ed166]
diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd
index 03da5c990d..971a13e8ba 100644
--- a/etc/cyclonedds.xsd
+++ b/etc/cyclonedds.xsd
@@ -596,7 +596,6 @@ CycloneDDS configuration
-
@@ -1130,13 +1129,6 @@ CycloneDDS configuration
<p>The default value is: "1 kB".</p>
-
-
-
-<p>This element enables the batching of write operations. By default each write operation writes through the write cache and out onto the transport. Enabling write batching causes multiple small write operations to be aggregated within the write cache into a single larger write. This gives greater throughput at the expense of latency. Currently there is no mechanism for the write cache to automatically flush itself, so that if write batching is enabled, the application may have to use the dds_write_flush function to ensure that all samples are written.</p>
-<p>The default value is: "false".</p>
-
-
@@ -1968,11 +1960,11 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==<br>
-
+
-
+
diff --git a/examples/shm_throughput/shmpublisher.c b/examples/shm_throughput/shmpublisher.c
index e96a61d14c..c27d2f413a 100644
--- a/examples/shm_throughput/shmpublisher.c
+++ b/examples/shm_throughput/shmpublisher.c
@@ -202,9 +202,6 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
if (participant < 0)
DDS_FATAL("dds_create_participant: %s\n", dds_strretcode(-participant));
- /* Enable write batching */
- dds_write_set_batch (true);
-
/* A topic is created for our sample type on the domain participant. */
switch (payloadSize)
{
@@ -282,6 +279,7 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
dds_qset_durability(dwQos, DDS_DURABILITY_VOLATILE);
dds_qset_liveliness(dwQos, DDS_LIVELINESS_AUTOMATIC, DDS_SECS(1));
dds_qset_resource_limits (dwQos, MAX_SAMPLES, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
+ dds_qset_writer_batching(dwQos, true);
*writer = dds_create_writer (publisher, topic, dwQos, NULL);
if (*writer < 0)
DDS_FATAL("dds_create_writer: %s\n", dds_strretcode(-*writer));
diff --git a/examples/throughput/publisher.c b/examples/throughput/publisher.c
index 284870bade..ca5c14cd81 100644
--- a/examples/throughput/publisher.c
+++ b/examples/throughput/publisher.c
@@ -147,9 +147,6 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
if (participant < 0)
DDS_FATAL("dds_create_participant: %s\n", dds_strretcode(-participant));
- /* Enable write batching */
- dds_write_set_batch (true);
-
/* A topic is created for our sample type on the domain participant. */
topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
if (topic < 0)
@@ -169,6 +166,7 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
dds_qset_reliability (dwQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
dds_qset_history (dwQos, DDS_HISTORY_KEEP_ALL, 0);
dds_qset_resource_limits (dwQos, MAX_SAMPLES, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
+ dds_qset_writer_batching (dwQos, true);
*writer = dds_create_writer (publisher, topic, dwQos, NULL);
if (*writer < 0)
DDS_FATAL("dds_create_writer: %s\n", dds_strretcode(-*writer));
diff --git a/package.xml b/package.xml
index fe39ebc2ae..0620fece6d 100644
--- a/package.xml
+++ b/package.xml
@@ -2,7 +2,7 @@
cyclonedds
- 0.10.3
+ 0.10.4
Eclipse Cyclone DDS is a very performant and robust open-source DDS implementation. Cyclone DDS is developed completely in the open as an Eclipse IoT project.
Eclipse Foundation, Inc.
Eclipse Public License 2.0
@@ -20,7 +20,6 @@
iceoryx_binding_c
iceoryx_posh
iceoryx_hoofs
- libcunit-dev
doxygen
python3-breathe
diff --git a/ports/freertos-posix/README.md b/ports/freertos-posix/README.md
index f812374607..7978acb22f 100644
--- a/ports/freertos-posix/README.md
+++ b/ports/freertos-posix/README.md
@@ -58,23 +58,7 @@ cmake --build . --target install
```
mkdir build
cd build
-conan install -s arch=x86 ..
-```
-
-> For actual cross-compilation environments the instructions above will not
-> install the correct packages. Even when e.g. Clang instead of GCC was used
-> to build the simulator, the mismatch between Conan and CMake will break the
-> build. To install the correct packages for the target, specify the required
-> settings e.g. when the simulator was built using Clang 7.0, use
-> `conan install -s arch=x86 -s compiler=clang -s compiler.version=7.0 ..`.
-> If packages are not yet available for the target, as is usually the case
-> with actual embedded targets, export the path to the toolchain file in the
-> `CONAN_CMAKE_TOOLCHAIN_FILE` environment variable and add the `-b` flag to
-> build the packages.
-
-2. Build Eclipse Cyclone DDS.
- ```
-$ cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/file -DWITH_FREERTOS=on ../src
+cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/file -DWITH_FREERTOS=on ../src
```
> Examples (and tests) can be executed like usual. The simulator provides a
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fa08094a89..a0edd71a46 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -94,6 +94,9 @@ if(NOT ENABLE_SECURITY)
message(STATUS "Building without OMG DDS Security support")
endif()
+if(BUILD_TESTING)
+ add_subdirectory(ucunit)
+endif()
add_subdirectory(tools)
add_subdirectory(ddsrt)
if(BUILD_IDLC)
diff --git a/src/core/ddsc/include/dds/dds.h b/src/core/ddsc/include/dds/dds.h
index 97647d6e75..c188f1da00 100644
--- a/src/core/ddsc/include/dds/dds.h
+++ b/src/core/ddsc/include/dds/dds.h
@@ -930,6 +930,11 @@ dds_get_listener(dds_entity_t entity, dds_listener_t * listener);
* attached, this operation will replace it with the new one. In other
* words, all related callbacks are replaced (possibly with NULL).
*
+ * A call to this operation will immediately invoke any listener callbacks for
+ * which the corresponding status flag is set. It may cause spurious invocations,
+ * including multiple invocations for one listener. For most cases this is unlikely,
+ * but for the DATA_ON_READERS listeners it is quite likely, though not certain.
+ *
* When listener parameter is NULL, all listener callbacks that were possibly
* set on the Entity will be removed.
*
diff --git a/src/core/ddsc/include/dds/ddsc/dds_public_impl.h b/src/core/ddsc/include/dds/ddsc/dds_public_impl.h
index 5fc45d33bc..80a591ff18 100644
--- a/src/core/ddsc/include/dds/ddsc/dds_public_impl.h
+++ b/src/core/ddsc/include/dds/ddsc/dds_public_impl.h
@@ -342,7 +342,7 @@ dds_typeid_kind_t;
*
* @param[in] enable Enables or disables write batching for all writers.
*/
-DDS_EXPORT void dds_write_set_batch (bool enable);
+DDS_DEPRECATED_EXPORT void dds_write_set_batch (bool enable);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsc/include/dds/ddsc/dds_public_qos.h b/src/core/ddsc/include/dds/ddsc/dds_public_qos.h
index 22e0552255..fef01d9cf3 100644
--- a/src/core/ddsc/include/dds/ddsc/dds_public_qos.h
+++ b/src/core/ddsc/include/dds/ddsc/dds_public_qos.h
@@ -400,6 +400,30 @@ dds_qset_reader_data_lifecycle (
dds_duration_t autopurge_nowriter_samples_delay,
dds_duration_t autopurge_disposed_samples_delay);
+/**
+ * @ingroup qos_setters
+ * @brief Set the writer batching policy of a qos structure
+ *
+ * When batching is disabled, each write/dispose/unregister operation results in its own
+ * RTPS message that is sent out onto the transport. For small data types, this means
+ * most messages (and hence network packets) are small. As a consequence the fixed cost
+ * of processing a message (or packet) increases load.
+ *
+ * Enabling write batching causes the samples to be aggregated into a single larger RTPS
+ * message. This improves efficiency by spreading the fixed cost out over more samples.
+ * Naturally this increases latency a bit.
+ *
+ * The batching mechanism may or may not send out packets on a write/&c. operation. It
+ * buffers only a limited amount and will send out what has been buffered when a new
+ * write/&c. can not be added. To guarantee that the buffered data is sent, one must call
+ * "dds_flush".
+ *
+ * @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
+ * @param[in] batch_updates - Whether writes should be batched
+ */
+DDS_EXPORT void
+dds_qset_writer_batching (dds_qos_t * __restrict qos, bool batch_updates);
+
/**
* @ingroup qos_setters
* @brief Set the durability-service policy of a qos structure
@@ -847,6 +871,20 @@ dds_qget_reader_data_lifecycle (
dds_duration_t *autopurge_nowriter_samples_delay,
dds_duration_t *autopurge_disposed_samples_delay);
+/**
+ * @ingroup qos_getters
+ * @brief Get the writer batching qos policy
+ *
+ * @param[in] qos - Pointer to a dds_qos_t structure storing the policy
+ * @param[in,out] batch_updates - Pointer that will store the batching enable value
+ *
+ * @returns - false iff any of the arguments is invalid or the qos is not present in the qos object
+ */
+DDS_EXPORT bool
+dds_qget_writer_batching (
+ const dds_qos_t * __restrict qos,
+ bool *batch_updates);
+
/**
* @ingroup qos_getters
* @brief Get the durability-service qos policy values.
diff --git a/src/core/ddsc/src/dds__qos.h b/src/core/ddsc/src/dds__qos.h
index b45ebe04dd..cd85e74069 100644
--- a/src/core/ddsc/src/dds__qos.h
+++ b/src/core/ddsc/src/dds__qos.h
@@ -53,7 +53,7 @@ extern "C" {
QP_LIFESPAN | QP_DESTINATION_ORDER | QP_HISTORY | \
QP_RESOURCE_LIMITS | QP_ADLINK_WRITER_DATA_LIFECYCLE | \
QP_CYCLONE_IGNORELOCAL | QP_PROPERTY_LIST | QP_DATA_REPRESENTATION | \
- QP_ENTITY_NAME)
+ QP_ENTITY_NAME | QP_CYCLONE_WRITER_BATCHING)
dds_return_t dds_ensure_valid_data_representation (dds_qos_t *qos, uint32_t allowed_data_representations, bool topicqos);
diff --git a/src/core/ddsc/src/dds__reader.h b/src/core/ddsc/src/dds__reader.h
index 5817bf1a5e..6408f3f01d 100644
--- a/src/core/ddsc/src/dds__reader.h
+++ b/src/core/ddsc/src/dds__reader.h
@@ -23,6 +23,11 @@ struct ddsi_status_cb_data;
void dds_reader_status_cb (void *entity, const struct ddsi_status_cb_data * data);
+/** @brief Invokes listeners for events signalled in the entity status
+ * @note expects `e->m_observers_lock` to be held
+ */
+void dds_reader_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status);
+
dds_return_t dds_return_reader_loan (dds_reader *rd, void **buf, int32_t bufsz);
/*
diff --git a/src/core/ddsc/src/dds__types.h b/src/core/ddsc/src/dds__types.h
index ca9cb0f336..e290ec6382 100644
--- a/src/core/ddsc/src/dds__types.h
+++ b/src/core/ddsc/src/dds__types.h
@@ -117,6 +117,10 @@ typedef struct dds_entity_deriver {
dds_return_t (*validate_status) (uint32_t mask);
struct dds_statistics * (*create_statistics) (const struct dds_entity *e);
void (*refresh_statistics) (const struct dds_entity *e, struct dds_statistics *s);
+ /// Invoke listeners for which the corresponding event flag is set in the status mask
+ /// @note expects `e->m_observers_lock` to be held on entry
+ /// @note may unlock and re-lock `e->m_observers_lock`
+ void (*invoke_cbs_for_pending_events) (struct dds_entity *e, uint32_t status);
} dds_entity_deriver;
struct dds_waitset;
@@ -192,6 +196,8 @@ dds_return_t dds_entity_deriver_dummy_validate_status (uint32_t mask);
struct dds_statistics *dds_entity_deriver_dummy_create_statistics (const struct dds_entity *e);
void dds_entity_deriver_dummy_refresh_statistics (const struct dds_entity *e, struct dds_statistics *s);
+void dds_entity_deriver_dummy_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status);
+
DDS_INLINE_EXPORT inline void dds_entity_deriver_interrupt (struct dds_entity *e) {
(dds_entity_deriver_table[e->m_kind]->interrupt) (e);
}
@@ -219,6 +225,9 @@ DDS_INLINE_EXPORT inline struct dds_statistics *dds_entity_deriver_create_statis
DDS_INLINE_EXPORT inline void dds_entity_deriver_refresh_statistics (const struct dds_entity *e, struct dds_statistics *s) {
dds_entity_deriver_table[e->m_kind]->refresh_statistics (e, s);
}
+DDS_INLINE_EXPORT inline void dds_entity_deriver_invoke_cbs_for_pending_events (struct dds_entity *e, uint32_t status) {
+ dds_entity_deriver_table[e->m_kind]->invoke_cbs_for_pending_events (e, status);
+}
typedef struct dds_cyclonedds_entity {
struct dds_entity m_entity;
diff --git a/src/core/ddsc/src/dds__writer.h b/src/core/ddsc/src/dds__writer.h
index 3ce408cc4f..212c5e066b 100644
--- a/src/core/ddsc/src/dds__writer.h
+++ b/src/core/ddsc/src/dds__writer.h
@@ -27,6 +27,8 @@ void dds_writer_status_cb (void *entity, const struct ddsi_status_cb_data * data
DDS_EXPORT dds_return_t dds_return_writer_loan(dds_writer *writer, void **buf,
int32_t bufsz) ddsrt_nonnull_all;
+void dds_writer_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status);
+
DDS_EXPORT dds_return_t dds__ddsi_writer_wait_for_acks (struct dds_writer *wr, ddsi_guid_t *rdguid, dds_time_t abstimeout);
#if defined (__cplusplus)
diff --git a/src/core/ddsc/src/dds_domain.c b/src/core/ddsc/src/dds_domain.c
index 3929d52594..cb8ccafd0c 100644
--- a/src/core/ddsc/src/dds_domain.c
+++ b/src/core/ddsc/src/dds_domain.c
@@ -44,7 +44,8 @@ const struct dds_entity_deriver dds_entity_deriver_domain = {
.set_qos = dds_entity_deriver_dummy_set_qos,
.validate_status = dds_entity_deriver_dummy_validate_status,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
static int dds_domain_compare (const void *va, const void *vb)
diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c
index 16c99e807c..f6bd570609 100644
--- a/src/core/ddsc/src/dds_entity.c
+++ b/src/core/ddsc/src/dds_entity.c
@@ -73,6 +73,9 @@ struct dds_statistics *dds_entity_deriver_dummy_create_statistics (const struct
void dds_entity_deriver_dummy_refresh_statistics (const struct dds_entity *e, struct dds_statistics *s) {
(void) e; (void) s;
}
+void dds_entity_deriver_dummy_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status) {
+ (void) e; (void) status;
+}
DDS_EXPORT extern inline void dds_entity_deriver_interrupt (struct dds_entity *e);
DDS_EXPORT extern inline void dds_entity_deriver_close (struct dds_entity *e);
@@ -83,6 +86,7 @@ DDS_EXPORT extern inline bool dds_entity_supports_set_qos (struct dds_entity *e)
DDS_EXPORT extern inline bool dds_entity_supports_validate_status (struct dds_entity *e);
DDS_EXPORT extern inline struct dds_statistics *dds_entity_deriver_create_statistics (const struct dds_entity *e);
DDS_EXPORT extern inline void dds_entity_deriver_refresh_statistics (const struct dds_entity *e, struct dds_statistics *s);
+DDS_EXPORT extern inline void dds_entity_deriver_invoke_cbs_for_pending_events (struct dds_entity *e, uint32_t status);
static int compare_instance_handle (const void *va, const void *vb)
{
@@ -1006,10 +1010,16 @@ static void pushdown_listener (dds_entity *e)
while (c->m_cb_pending_count > 0)
ddsrt_cond_wait (&c->m_observers_cond, &c->m_observers_lock);
+ c->m_cb_pending_count++;
ddsrt_mutex_lock (&e->m_observers_lock);
dds_override_inherited_listener (&c->m_listener, &e->m_listener);
ddsrt_mutex_unlock (&e->m_observers_lock);
+ uint32_t status = ddsrt_atomic_ld32 (&c->m_status.m_status_and_mask) & SAM_STATUS_MASK;
+ if (status) {
+ dds_entity_deriver_invoke_cbs_for_pending_events(c, status);
+ }
+ c->m_cb_pending_count--;
ddsrt_mutex_unlock (&c->m_observers_lock);
pushdown_listener (c);
@@ -1021,10 +1031,12 @@ static void pushdown_listener (dds_entity *e)
ddsrt_mutex_unlock (&e->m_mutex);
}
+
dds_return_t dds_set_listener (dds_entity_t entity, const dds_listener_t *listener)
{
dds_entity *e, *x;
dds_return_t rc;
+ uint32_t status;
if ((rc = dds_entity_pin (entity, &e)) != DDS_RETCODE_OK)
return rc;
@@ -1055,7 +1067,22 @@ dds_return_t dds_set_listener (dds_entity_t entity, const dds_listener_t *listen
ddsrt_mutex_unlock (&e->m_observers_lock);
pushdown_listener (e);
+ /* Check for pending events, and when needed notify their listeners. */
+ ddsrt_mutex_lock (&e->m_observers_lock);
+ e->m_cb_pending_count++;
+ while (e->m_cb_count > 0)
+ ddsrt_cond_wait (&e->m_observers_cond, &e->m_observers_lock);
+ e->m_cb_count++;
+ status = ddsrt_atomic_ld32 (&e->m_status.m_status_and_mask) & SAM_STATUS_MASK;
+ if (listener && status) {
+ dds_entity_deriver_invoke_cbs_for_pending_events(e, status);
+ }
+ e->m_cb_count--;
+ e->m_cb_pending_count--;
+ ddsrt_cond_broadcast (&e->m_observers_cond);
+ ddsrt_mutex_unlock (&e->m_observers_lock);
dds_entity_unpin (e);
+
return DDS_RETCODE_OK;
}
diff --git a/src/core/ddsc/src/dds_guardcond.c b/src/core/ddsc/src/dds_guardcond.c
index 2d8ec02fbb..1ab6f9a60a 100644
--- a/src/core/ddsc/src/dds_guardcond.c
+++ b/src/core/ddsc/src/dds_guardcond.c
@@ -29,7 +29,8 @@ const struct dds_entity_deriver dds_entity_deriver_guardcondition = {
.set_qos = dds_entity_deriver_dummy_set_qos,
.validate_status = dds_entity_deriver_dummy_validate_status,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_entity_t dds_create_guardcondition (dds_entity_t owner)
diff --git a/src/core/ddsc/src/dds_init.c b/src/core/ddsc/src/dds_init.c
index c50b589d44..564bc71f0e 100644
--- a/src/core/ddsc/src/dds_init.c
+++ b/src/core/ddsc/src/dds_init.c
@@ -43,7 +43,8 @@ const struct dds_entity_deriver dds_entity_deriver_cyclonedds = {
.set_qos = dds_entity_deriver_dummy_set_qos,
.validate_status = dds_entity_deriver_dummy_validate_status,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_cyclonedds_entity dds_global;
diff --git a/src/core/ddsc/src/dds_participant.c b/src/core/ddsc/src/dds_participant.c
index 87c4700563..7fc0195359 100644
--- a/src/core/ddsc/src/dds_participant.c
+++ b/src/core/ddsc/src/dds_participant.c
@@ -89,7 +89,8 @@ const struct dds_entity_deriver dds_entity_deriver_participant = {
.set_qos = dds_participant_qos_set,
.validate_status = dds_participant_status_validate,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_entity_t dds_create_participant (const dds_domainid_t domain, const dds_qos_t *qos, const dds_listener_t *listener)
diff --git a/src/core/ddsc/src/dds_publisher.c b/src/core/ddsc/src/dds_publisher.c
index e3e8546799..ecb8c20481 100644
--- a/src/core/ddsc/src/dds_publisher.c
+++ b/src/core/ddsc/src/dds_publisher.c
@@ -45,7 +45,8 @@ const struct dds_entity_deriver dds_entity_deriver_publisher = {
.set_qos = dds_publisher_qos_set,
.validate_status = dds_publisher_status_validate,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_entity_t dds__create_publisher_l (dds_participant *par, bool implicit, const dds_qos_t *qos, const dds_listener_t *listener)
diff --git a/src/core/ddsc/src/dds_qos.c b/src/core/ddsc/src/dds_qos.c
index 44694363c1..b9be69326d 100644
--- a/src/core/ddsc/src/dds_qos.c
+++ b/src/core/ddsc/src/dds_qos.c
@@ -317,6 +317,14 @@ void dds_qset_reader_data_lifecycle (dds_qos_t * __restrict qos, dds_duration_t
qos->present |= QP_ADLINK_READER_DATA_LIFECYCLE;
}
+void dds_qset_writer_batching (dds_qos_t * __restrict qos, bool batch_updates)
+{
+ if (qos == NULL)
+ return;
+ qos->writer_batching.batch_updates = batch_updates;
+ qos->present |= QP_CYCLONE_WRITER_BATCHING;
+}
+
void dds_qset_durability_service (dds_qos_t * __restrict qos, dds_duration_t service_cleanup_delay, dds_history_kind_t history_kind, int32_t history_depth, int32_t max_samples, int32_t max_instances, int32_t max_samples_per_instance)
{
if (qos == NULL)
@@ -697,6 +705,15 @@ bool dds_qget_reader_data_lifecycle (const dds_qos_t * __restrict qos, dds_durat
return true;
}
+bool dds_qget_writer_batching (const dds_qos_t * __restrict qos, bool *batch_updates)
+{
+ if (qos == NULL || !(qos->present & QP_CYCLONE_WRITER_BATCHING))
+ return false;
+ if (batch_updates)
+ *batch_updates = qos->writer_batching.batch_updates;
+ return true;
+}
+
bool dds_qget_durability_service (const dds_qos_t * __restrict qos, dds_duration_t *service_cleanup_delay, dds_history_kind_t *history_kind, int32_t *history_depth, int32_t *max_samples, int32_t *max_instances, int32_t *max_samples_per_instance)
{
if (qos == NULL || !(qos->present & QP_DURABILITY_SERVICE))
diff --git a/src/core/ddsc/src/dds_readcond.c b/src/core/ddsc/src/dds_readcond.c
index 4ec96cc260..dfda3ee8c5 100644
--- a/src/core/ddsc/src/dds_readcond.c
+++ b/src/core/ddsc/src/dds_readcond.c
@@ -38,7 +38,8 @@ const struct dds_entity_deriver dds_entity_deriver_readcondition = {
.set_qos = dds_entity_deriver_dummy_set_qos,
.validate_status = dds_entity_deriver_dummy_validate_status,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_readcond *dds_create_readcond (dds_reader *rd, dds_entity_kind_t kind, uint32_t mask, dds_querycondition_filter_fn filter)
diff --git a/src/core/ddsc/src/dds_reader.c b/src/core/ddsc/src/dds_reader.c
index 3ae7fb1fdd..4e1c72571b 100644
--- a/src/core/ddsc/src/dds_reader.c
+++ b/src/core/ddsc/src/dds_reader.c
@@ -170,15 +170,15 @@ static void data_avail_cb_leave_listener_exclusive_access (dds_entity *e)
ddsrt_cond_broadcast (&e->m_observers_cond);
}
-static void data_avail_cb_invoke_dor (dds_entity *sub, const struct dds_listener *lst)
+static void data_avail_cb_invoke_dor (dds_entity *sub, const struct dds_listener *lst, bool async)
{
// assumes sub->m_observers_lock held on entry
// unlocks and relocks sub->m_observers_lock
- data_avail_cb_enter_listener_exclusive_access (sub);
+ if (async) data_avail_cb_enter_listener_exclusive_access (sub);
ddsrt_mutex_unlock (&sub->m_observers_lock);
lst->on_data_on_readers (sub->m_hdllink.hdl, lst->on_data_on_readers_arg);
ddsrt_mutex_lock (&sub->m_observers_lock);
- data_avail_cb_leave_listener_exclusive_access (sub);
+ if (async) data_avail_cb_leave_listener_exclusive_access (sub);
}
static uint32_t data_avail_cb_set_status (dds_entity *rd, uint32_t status_and_mask)
@@ -216,6 +216,32 @@ static void data_avail_cb_trigger_waitsets (dds_entity *rd, uint32_t signal)
}
}
+static uint32_t da_or_dor_cb_invoke(struct dds_reader *rd, struct dds_listener const * const lst, uint32_t status_and_mask, bool async)
+{
+ uint32_t signal = 0;
+
+ if (lst->on_data_on_readers)
+ {
+ dds_entity * const sub = rd->m_entity.m_parent;
+ ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
+ ddsrt_mutex_lock (&sub->m_observers_lock);
+ if (!(lst->reset_on_invoke & DDS_DATA_ON_READERS_STATUS))
+ signal = data_avail_cb_set_status (&rd->m_entity, status_and_mask);
+ data_avail_cb_invoke_dor (sub, lst, async);
+ ddsrt_mutex_unlock (&sub->m_observers_lock);
+ ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
+ }
+ else if(rd->m_entity.m_listener.on_data_available)
+ {
+ if (!(lst->reset_on_invoke & DDS_DATA_AVAILABLE_STATUS))
+ signal = data_avail_cb_set_status (&rd->m_entity, status_and_mask);
+ ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
+ lst->on_data_available (rd->m_entity.m_hdllink.hdl, lst->on_data_available_arg);
+ ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
+ }
+ return signal;
+}
+
void dds_reader_data_available_cb (struct dds_reader *rd)
{
/* DATA_AVAILABLE is special in two ways: firstly, it should first try
@@ -223,8 +249,8 @@ void dds_reader_data_available_cb (struct dds_reader *rd)
status on the subscriber; secondly it is the only one for which
overhead really matters. Otherwise, it is pretty much like
dds_reader_status_cb. */
+ uint32_t signal;
struct dds_listener const * const lst = &rd->m_entity.m_listener;
- uint32_t signal = 0;
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
const uint32_t status_and_mask = ddsrt_atomic_ld32 (&rd->m_entity.m_status.m_status_and_mask);
@@ -234,26 +260,7 @@ void dds_reader_data_available_cb (struct dds_reader *rd)
{
// "lock" listener object so we can look at "lst" without holding m_observers_lock
data_avail_cb_enter_listener_exclusive_access (&rd->m_entity);
- if (lst->on_data_on_readers)
- {
- dds_entity * const sub = rd->m_entity.m_parent;
- ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
- ddsrt_mutex_lock (&sub->m_observers_lock);
- if (!(lst->reset_on_invoke & DDS_DATA_ON_READERS_STATUS))
- signal = data_avail_cb_set_status (&rd->m_entity, status_and_mask);
- data_avail_cb_invoke_dor (sub, lst);
- ddsrt_mutex_unlock (&sub->m_observers_lock);
- ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
- }
- else
- {
- assert (rd->m_entity.m_listener.on_data_available);
- if (!(lst->reset_on_invoke & DDS_DATA_AVAILABLE_STATUS))
- signal = data_avail_cb_set_status (&rd->m_entity, status_and_mask);
- ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
- lst->on_data_available (rd->m_entity.m_hdllink.hdl, lst->on_data_available_arg);
- ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
- }
+ signal = da_or_dor_cb_invoke(rd, lst, status_and_mask, true);
data_avail_cb_leave_listener_exclusive_access (&rd->m_entity);
}
data_avail_cb_trigger_waitsets (&rd->m_entity, signal);
@@ -437,6 +444,35 @@ void dds_reader_status_cb (void *ventity, const ddsi_status_cb_data_t *data)
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
}
+void dds_reader_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status)
+{
+ dds_reader * const rdr = (dds_reader *) e;
+ struct dds_listener const * const lst = &e->m_listener;
+
+ if (lst->on_requested_deadline_missed && (status & DDS_REQUESTED_DEADLINE_MISSED_STATUS)) {
+ status_cb_requested_deadline_missed_invoke(rdr);
+ }
+ if (lst->on_requested_incompatible_qos && (status & DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS)) {
+ status_cb_requested_incompatible_qos_invoke(rdr);
+ }
+ if (lst->on_sample_lost && (status & DDS_SAMPLE_LOST_STATUS)) {
+ status_cb_sample_lost_invoke(rdr);
+ }
+ if (lst->on_sample_rejected && (status & DDS_SAMPLE_REJECTED_STATUS)) {
+ status_cb_sample_rejected_invoke(rdr);
+ }
+ if (lst->on_liveliness_changed && (status & DDS_LIVELINESS_CHANGED_STATUS)) {
+ status_cb_liveliness_changed_invoke(rdr);
+ }
+ if (lst->on_subscription_matched && (status & DDS_SUBSCRIPTION_MATCHED_STATUS)) {
+ status_cb_subscription_matched_invoke(rdr);
+ }
+ if ((status & DDS_DATA_AVAILABLE_STATUS)) {
+ const uint32_t status_and_mask = ddsrt_atomic_ld32 (&e->m_status.m_status_and_mask);
+ (void) da_or_dor_cb_invoke(rdr, lst, status_and_mask, false);
+ }
+}
+
static const struct dds_stat_keyvalue_descriptor dds_reader_statistics_kv[] = {
{ "discarded_bytes", DDS_STAT_KIND_UINT64 }
};
@@ -465,7 +501,8 @@ const struct dds_entity_deriver dds_entity_deriver_reader = {
.set_qos = dds_reader_qos_set,
.validate_status = dds_reader_status_validate,
.create_statistics = dds_reader_create_statistics,
- .refresh_statistics = dds_reader_refresh_statistics
+ .refresh_statistics = dds_reader_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_reader_invoke_cbs_for_pending_events
};
#ifdef DDS_HAS_SHM
diff --git a/src/core/ddsc/src/dds_subscriber.c b/src/core/ddsc/src/dds_subscriber.c
index 44d1a31e04..4036ccb022 100644
--- a/src/core/ddsc/src/dds_subscriber.c
+++ b/src/core/ddsc/src/dds_subscriber.c
@@ -44,7 +44,8 @@ const struct dds_entity_deriver dds_entity_deriver_subscriber = {
.set_qos = dds_subscriber_qos_set,
.validate_status = dds_subscriber_status_validate,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_entity_t dds__create_subscriber_l (dds_participant *participant, bool implicit, const dds_qos_t *qos, const dds_listener_t *listener)
diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c
index 1d7359f9a5..40e62ebfb1 100644
--- a/src/core/ddsc/src/dds_topic.c
+++ b/src/core/ddsc/src/dds_topic.c
@@ -283,7 +283,8 @@ const struct dds_entity_deriver dds_entity_deriver_topic = {
.set_qos = dds_topic_qos_set,
.validate_status = dds_topic_status_validate,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
/**
diff --git a/src/core/ddsc/src/dds_waitset.c b/src/core/ddsc/src/dds_waitset.c
index e93ba3e39e..78d26924f6 100644
--- a/src/core/ddsc/src/dds_waitset.c
+++ b/src/core/ddsc/src/dds_waitset.c
@@ -141,7 +141,8 @@ const struct dds_entity_deriver dds_entity_deriver_waitset = {
.set_qos = dds_entity_deriver_dummy_set_qos,
.validate_status = dds_entity_deriver_dummy_validate_status,
.create_statistics = dds_entity_deriver_dummy_create_statistics,
- .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics
+ .refresh_statistics = dds_entity_deriver_dummy_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_entity_deriver_dummy_invoke_cbs_for_pending_events
};
dds_entity_t dds_create_waitset (dds_entity_t owner)
diff --git a/src/core/ddsc/src/dds_writer.c b/src/core/ddsc/src/dds_writer.c
index 31d04f0500..3e104558f5 100644
--- a/src/core/ddsc/src/dds_writer.c
+++ b/src/core/ddsc/src/dds_writer.c
@@ -167,6 +167,25 @@ static uint32_t get_bandwidth_limit (dds_transport_priority_qospolicy_t transpor
#endif
}
+void dds_writer_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status)
+{
+ dds_writer * const wr = (dds_writer *) e;
+ struct dds_listener const * const lst = &e->m_listener;
+
+ if (lst->on_publication_matched && (status & DDS_PUBLICATION_MATCHED_STATUS)) {
+ status_cb_publication_matched_invoke(wr);
+ }
+ if (lst->on_liveliness_lost && (status & DDS_LIVELINESS_LOST_STATUS)) {
+ status_cb_liveliness_lost_invoke(wr);
+ }
+ if (lst->on_offered_incompatible_qos && (status & DDS_OFFERED_INCOMPATIBLE_QOS_STATUS)) {
+ status_cb_offered_incompatible_qos_invoke(wr);
+ }
+ if (lst->on_offered_deadline_missed && (status & DDS_OFFERED_DEADLINE_MISSED_STATUS)) {
+ status_cb_offered_deadline_missed_invoke(wr);
+ }
+}
+
static void dds_writer_interrupt (dds_entity *e) ddsrt_nonnull_all;
static void dds_writer_interrupt (dds_entity *e)
@@ -280,7 +299,8 @@ const struct dds_entity_deriver dds_entity_deriver_writer = {
.set_qos = dds_writer_qos_set,
.validate_status = dds_writer_status_validate,
.create_statistics = dds_writer_create_statistics,
- .refresh_statistics = dds_writer_refresh_statistics
+ .refresh_statistics = dds_writer_refresh_statistics,
+ .invoke_cbs_for_pending_events = dds_writer_invoke_cbs_for_pending_events
};
#ifdef DDS_HAS_SHM
@@ -452,6 +472,12 @@ dds_entity_t dds_create_writer (dds_entity_t participant_or_publisher, dds_entit
wr->m_whc = whc_new (gv, wrinfo);
whc_free_wrinfo (wrinfo);
wr->whc_batch = gv->config.whc_batch;
+ // We now have the QoS which defaults to "false", but it used to be controlled by a global setting
+ // (that most people were sensible enough to leave at false and that this deprecated now). Or'ing
+ // the two together is perhaps a bit simplistic because it doesn't allow you to enable it globally
+ // and then disable it for a specific writer. Should somebody runs into a problem because of this
+ // we can have another look.
+ wr->whc_batch = wqos->writer_batching.batch_updates || gv->config.whc_batch;
#ifdef DDS_HAS_SHM
assert(wqos->present & QP_LOCATOR_MASK);
diff --git a/src/core/ddsc/tests/cdr.c b/src/core/ddsc/tests/cdr.c
index 14897a614c..952080349a 100644
--- a/src/core/ddsc/tests/cdr.c
+++ b/src/core/ddsc/tests/cdr.c
@@ -326,7 +326,6 @@ static struct ddsi_serdata *sd_from_ser (const struct ddsi_sertype *tpcmn, enum
};
const ddsi_keyhash_t *kh = ddsi_serdata_keyhash_from_fragchain (fragchain);
CU_ASSERT_FATAL (kh != NULL);
- assert (kh != NULL); // for Clang's static analyzer
printf ("kh rcv %02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x\n",
kh->value[0], kh->value[1], kh->value[2], kh->value[3],
kh->value[4], kh->value[5], kh->value[6], kh->value[7],
diff --git a/src/core/ddsc/tests/domain.c b/src/core/ddsc/tests/domain.c
index e106de6ea8..623a7ebc13 100644
--- a/src/core/ddsc/tests/domain.c
+++ b/src/core/ddsc/tests/domain.c
@@ -317,7 +317,6 @@ static void logsink (void *varg, const dds_log_data_t *msg)
// do by rewriting the {0} to {}
char *p = strchr (arg->buf[arg->size], '{');
CU_ASSERT_FATAL (p != NULL);
- assert (p != NULL); // Clang static analyzer
p++;
CU_ASSERT_FATAL (strcmp (p, "}\n") == 0 || strcmp (p, "0}\n") == 0);
if (*p == '0')
diff --git a/src/core/ddsc/tests/instance_get_key.c b/src/core/ddsc/tests/instance_get_key.c
index c9f40c5bc6..49d98dbb0b 100644
--- a/src/core/ddsc/tests/instance_get_key.c
+++ b/src/core/ddsc/tests/instance_get_key.c
@@ -132,7 +132,6 @@ CU_Test(ddsc_instance_get_key, registered_instance, .init=setup, .fini=teardown)
ret = dds_instance_get_key(writer, handle, &key_data);
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
- assert (key_data.ip != NULL); /* for the benefit of clang's static analyzer */
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
@@ -163,7 +162,6 @@ CU_Test(ddsc_instance_get_key, readcondition, .init=setup, .fini=teardown)
ret = dds_instance_get_key(readcondition, handle, &key_data);
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
- assert (key_data.ip != NULL); /* for the benefit of clang's static analyzer */
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
@@ -194,7 +192,6 @@ CU_Test(ddsc_instance_get_key, querycondition, .init=setup, .fini=teardown)
ret = dds_instance_get_key(querycondition, handle, &key_data);
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
- assert (key_data.ip != NULL); /* for the benefit of clang's static analyzer */
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
diff --git a/src/core/ddsc/tests/liveliness.c b/src/core/ddsc/tests/liveliness.c
index 61fca4a542..1601c657ca 100644
--- a/src/core/ddsc/tests/liveliness.c
+++ b/src/core/ddsc/tests/liveliness.c
@@ -93,7 +93,6 @@ static seqno_t get_pmd_seqno(dds_entity_t participant)
pp = entidx_lookup_participant_guid(pp_entity->m_domain->gv.entity_index, &pp_entity->m_guid);
wr = ddsi_get_builtin_writer (pp, NN_ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER);
CU_ASSERT_FATAL(wr != NULL);
- assert(wr != NULL); /* for Clang's static analyzer */
seqno = wr->seq;
thread_state_asleep(lookup_thread_state());
dds_entity_unpin(pp_entity);
@@ -204,9 +203,9 @@ static void test_pmd_count(dds_liveliness_kind_t kind, uint32_t ldur, double mul
/* End-start should be mult - 1 under ideal circumstances, but consider the test successful
when at least 50% of the expected PMD's was sent. This checks that the frequency for sending
PMDs was increased when the writer was added. */
- CU_ASSERT_FATAL((double) (end_seqno - start_seqno) >= (kind == DDS_LIVELINESS_AUTOMATIC ? (50 * (mult - 1)) / 100 : 0))
+ CU_ASSERT_FATAL((double) (end_seqno - start_seqno) >= (kind == DDS_LIVELINESS_AUTOMATIC ? (50 * (mult - 1)) / 100 : 0));
if (kind != DDS_LIVELINESS_AUTOMATIC)
- CU_ASSERT_FATAL((double) (get_pmd_seqno(g_pub_participant) - start_seqno) < mult)
+ CU_ASSERT_FATAL((double) (get_pmd_seqno(g_pub_participant) - start_seqno) < mult);
/* cleanup */
if (remote_reader)
@@ -499,7 +498,6 @@ static void test_lease_duration_pwr(bool remote_reader)
dds_builtintopic_endpoint_t *ep;
ep = dds_get_matched_publication_data(reader, wrs[0]);
CU_ASSERT_FATAL(ep != NULL);
- assert(ep != NULL); /* for Clang's static analyzer */
CU_ASSERT_EQUAL_FATAL(ep->qos->liveliness.lease_duration, DDS_MSECS(ldur));
dds_builtintopic_free_endpoint (ep);
diff --git a/src/core/ddsc/tests/loan.c b/src/core/ddsc/tests/loan.c
index 2860132918..29445a2461 100644
--- a/src/core/ddsc/tests/loan.c
+++ b/src/core/ddsc/tests/loan.c
@@ -106,7 +106,6 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities)
CU_ASSERT_FATAL (result == DDS_RETCODE_OK);
/* return resets buf[0] (so that it picks up the loan the next time) and zeros the data */
CU_ASSERT_FATAL (ptrs[0] == NULL);
- assert (ptr0copy != NULL); /* clang static analyzer */
CU_ASSERT_FATAL (memcmp (ptr0copy, zeros, sizeof (s)) == 0);
/* read 3, return: should work fine, causes realloc */
@@ -118,7 +117,6 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities)
result = dds_return_loan (reader, ptrs, n);
CU_ASSERT_FATAL (result == DDS_RETCODE_OK);
CU_ASSERT_FATAL (ptrs[0] == NULL);
- assert (ptr0copy != NULL); /* clang static analyzer */
CU_ASSERT_FATAL (memcmp (ptr0copy, zeros, 3 * sizeof (s)) == 0);
/* read 1 using loan, expecting to get the same address (no realloc needed), defer return.
@@ -143,7 +141,6 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities)
{
const struct RoundTripModule_DataType *a = ptrs[0];
const struct RoundTripModule_DataType *b = ptrs2[0];
- assert (a != NULL && b != NULL); /* clang static analyzer */
CU_ASSERT_FATAL (a->payload._length == b->payload._length);
CU_ASSERT_FATAL (a->payload._buffer != b->payload._buffer);
CU_ASSERT_FATAL (a->payload._buffer[0] == b->payload._buffer[0]);
diff --git a/src/core/ddsc/tests/multi_sertopic.c b/src/core/ddsc/tests/multi_sertopic.c
index 5b5689dcaf..e05be1591b 100644
--- a/src/core/ddsc/tests/multi_sertopic.c
+++ b/src/core/ddsc/tests/multi_sertopic.c
@@ -587,7 +587,7 @@ static void ddsc_multi_sertype_impl (dds_entity_t pp_pub, dds_entity_t pp_sub, e
CU_ASSERT_FATAL (si.source_timestamp >= 1 && si.source_timestamp <= 3);
CU_ASSERT_FATAL (u._d == 3);
CU_ASSERT_FATAL (u._u.a._length == 1);
- assert (u._u.a._buffer != NULL); /* for Clang static analyzer */
+ CU_ASSERT_FATAL (u._u.a._buffer != NULL);
CU_ASSERT_FATAL (u._u.a._buffer[0].v[0] == 4);
CU_ASSERT_FATAL (u._u.a._buffer[0].v[1] == 2);
dds_free (u._u.a._buffer);
diff --git a/src/core/ddsc/tests/pp_lease_dur.c b/src/core/ddsc/tests/pp_lease_dur.c
index a7ac4d3a57..cf7c8fd396 100644
--- a/src/core/ddsc/tests/pp_lease_dur.c
+++ b/src/core/ddsc/tests/pp_lease_dur.c
@@ -151,7 +151,6 @@ CU_Test(ddsc_participant_lease_duration, builtin_topic)
if (memcmp (&ppg[i], &s->key, sizeof (s->key)) == 0)
break;
CU_ASSERT_FATAL (i < 3); // thanks to domain tag
- assert (i < 3); // Clang static analyzer doesn't get CU_ASSERT_FATAL
if (!si.valid_data)
continue;
nseen += !seen[i];
diff --git a/src/core/ddsc/tests/publisher.c b/src/core/ddsc/tests/publisher.c
index 72b109e22e..4934632c7a 100644
--- a/src/core/ddsc/tests/publisher.c
+++ b/src/core/ddsc/tests/publisher.c
@@ -293,6 +293,7 @@ CU_Test(ddsc_publisher, wait_for_acks)
CU_Test(ddsc_publisher, coherency)
{
+ CU_PASS ("coherency not implemented yet");
return;
}
diff --git a/src/core/ddsc/tests/qos.c b/src/core/ddsc/tests/qos.c
index 1b5538a726..dd6b82731e 100644
--- a/src/core/ddsc/tests/qos.c
+++ b/src/core/ddsc/tests/qos.c
@@ -761,7 +761,7 @@ CU_Test(ddsc_qos, bproperty, .init=qos_init, .fini=qos_fini)
CU_ASSERT_FATAL(dds_qget_bprop (g_qos, c_bproperty_names[0], &bvalue, &size));
CU_ASSERT_FATAL (bvalue != NULL);
CU_ASSERT_EQUAL_FATAL (size, 3);
- assert (c_bproperty_values[0] != NULL); /* for Clang static analyzer */
+ CU_ASSERT_FATAL (c_bproperty_values[0] != NULL);
CU_ASSERT_EQUAL_FATAL (memcmp (bvalue, c_bproperty_values[0], size), 0);
dds_free (bvalue);
@@ -770,7 +770,7 @@ CU_Test(ddsc_qos, bproperty, .init=qos_init, .fini=qos_fini)
CU_ASSERT_FATAL (dds_qget_bprop (g_qos, c_bproperty_names[0], &bvalue, &size));
CU_ASSERT_FATAL (bvalue != NULL);
CU_ASSERT_EQUAL_FATAL (size, 3);
- assert (c_bproperty_values[1] != NULL); /* for Clang static analyzer */
+ CU_ASSERT_FATAL (c_bproperty_values[1] != NULL);
CU_ASSERT_EQUAL_FATAL (memcmp (bvalue, c_bproperty_values[1], size), 0);
dds_free (bvalue);
dds_qset_bprop (g_qos, c_bproperty_names[0], &c_bproperty_values[0], 3);
@@ -799,13 +799,13 @@ CU_Test(ddsc_qos, bproperty, .init=qos_init, .fini=qos_fini)
CU_ASSERT_FATAL (dds_qget_bprop (g_qos, c_bproperty_names[0], &bvalue, &size));
CU_ASSERT_FATAL (bvalue != NULL);
CU_ASSERT_EQUAL_FATAL (size, 3);
- assert (c_bproperty_values[0] != NULL); /* for Clang static analyzer */
+ CU_ASSERT_FATAL (c_bproperty_values[0] != NULL);
CU_ASSERT_EQUAL_FATAL (memcmp (bvalue, c_bproperty_values[0], size), 0);
dds_free (bvalue);
CU_ASSERT_FATAL (dds_qget_bprop (g_qos, c_bproperty_names[2], &bvalue, &size));
CU_ASSERT_FATAL (bvalue != NULL);
CU_ASSERT_EQUAL_FATAL (size, 3);
- assert (c_bproperty_values[2] != NULL); /* for Clang static analyzer */
+ CU_ASSERT_FATAL (c_bproperty_values[2] != NULL);
CU_ASSERT_EQUAL_FATAL (memcmp (bvalue, c_bproperty_values[2], size), 0);
dds_free (bvalue);
dds_qunset_bprop (g_qos, c_bproperty_names[0]);
@@ -828,7 +828,7 @@ CU_Test(ddsc_qos, property_mixed, .init=qos_init, .fini=qos_fini)
CU_ASSERT_FATAL (dds_qget_bprop (g_qos, c_property_names[0], &bvalue, &size));
CU_ASSERT_FATAL (bvalue != NULL);
CU_ASSERT_EQUAL_FATAL (size, 3);
- assert (c_bproperty_values[0] != NULL); /* for Clang static analyzer */
+ CU_ASSERT_FATAL (c_bproperty_values[0] != NULL);
CU_ASSERT_EQUAL_FATAL (memcmp (bvalue, c_bproperty_values[0], size), 0);
dds_free (bvalue);
CU_ASSERT_FATAL (dds_qget_prop (g_qos, c_property_names[0], &value));
diff --git a/src/core/ddsc/tests/typelookup.c b/src/core/ddsc/tests/typelookup.c
index a161f5d023..1de97a3627 100644
--- a/src/core/ddsc/tests/typelookup.c
+++ b/src/core/ddsc/tests/typelookup.c
@@ -277,7 +277,6 @@ CU_Test(ddsc_typelookup, get_typeobj, .init = typelookup_init, .fini = typelooku
endpoint_info_t *reader_ep = find_typeid_match (g_participant2, DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION, rd_type_id, topic_name_rd, DDSI_TYPEID_KIND_MINIMAL);
CU_ASSERT_FATAL (writer_ep != NULL);
CU_ASSERT_FATAL (reader_ep != NULL);
- assert (writer_ep && reader_ep); // clang static analyzer
endpoint_info_free (writer_ep);
endpoint_info_free (reader_ep);
@@ -331,7 +330,6 @@ CU_Test(ddsc_typelookup, api_resolve, .init = typelookup_init, .fini = typelooku
/* wait for DCPSPublication to be received */
endpoint_info_t *writer_ep = find_typeid_match (g_participant2, DDS_BUILTIN_TOPIC_DCPSPUBLICATION, type_id, name, DDSI_TYPEID_KIND_COMPLETE);
CU_ASSERT_FATAL (writer_ep != NULL);
- assert (writer_ep); // clang static analyzer
/* check if type can be resolved */
dds_topic_descriptor_t *desc;
@@ -389,7 +387,6 @@ CU_Test(ddsc_typelookup, api_resolve_invalid, .init = typelookup_init, .fini = t
/* wait for DCPSPublication to be received */
endpoint_info_t *writer_ep = find_typeid_match (g_participant2, DDS_BUILTIN_TOPIC_DCPSPUBLICATION, type_id, name, DDSI_TYPEID_KIND_COMPLETE);
CU_ASSERT_FATAL (writer_ep != NULL);
- assert (writer_ep); // clang static analyzer
/* confirm that invalid type id cannot be resolved */
struct dds_entity *e;
diff --git a/src/core/ddsc/tests/whc.c b/src/core/ddsc/tests/whc.c
index 145b23a1a2..5179089b19 100644
--- a/src/core/ddsc/tests/whc.c
+++ b/src/core/ddsc/tests/whc.c
@@ -175,7 +175,7 @@ static void test_whc_end_state(dds_durability_kind_t d, dds_reliability_kind_t r
writer = dds_create_writer (g_publisher, topic, g_qos, NULL);
CU_ASSERT_FATAL(writer > 0);
ret = dds_set_status_mask(writer, DDS_PUBLICATION_MATCHED_STATUS);
- CU_ASSERT_FATAL (ret == DDS_RETCODE_OK)
+ CU_ASSERT_FATAL (ret == DDS_RETCODE_OK);
reader = lrd ? create_and_sync_reader (g_subscriber, topic, g_qos, writer) : 0;
reader_remote = rrd ? create_and_sync_reader (g_remote_subscriber, remote_topic, g_qos, writer) : 0;
diff --git a/src/core/ddsi/defconfig.c b/src/core/ddsi/defconfig.c
index bddcaaa31a..0c4ea4ab38 100644
--- a/src/core/ddsi/defconfig.c
+++ b/src/core/ddsi/defconfig.c
@@ -106,11 +106,11 @@ void ddsi_config_init_default (struct ddsi_config *cfg)
}
/* generated from ddsi_config.h[87da706bc9c463a87326e87b311d8291d5761d43] */
/* generated from ddsi_cfgunits.h[fc550f1620aa20dcd9244ef4e24299d5001efbb4] */
-/* generated from ddsi_cfgelems.h[c54fbee60d780fadc6ebc3c738c5d2c5051e689a] */
+/* generated from ddsi_cfgelems.h[a294ec068e0de39ae662e4709f6ed3226a2412f2] */
/* generated from ddsi_config.c[98486715ac072b7b3cc3a449d55676be1218c98c] */
/* generated from _confgen.h[01ffa8a2e53b2309451756861466551cfe28c8ce] */
/* generated from _confgen.c[13cd40932d695abae1470202a42c18dc4d09ea84] */
/* generated from generate_rnc.c[a2ec6e48d33ac14a320c8ec3f320028a737920e0] */
/* generated from generate_md.c[a61b6a9649d18afeca4c73b5784f36989d7994e0] */
/* generated from generate_xsd.c[45064e8869b3c00573057d7c8f02d20f04b40e16] */
-/* generated from generate_defconfig.c[eec9ab7b2d053e68500799b693d089e84153a37b] */
+/* generated from generate_defconfig.c[421f8c9fd9bbfe320f985463dbe8f09c849ed166] */
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_cfgelems.h b/src/core/ddsi/include/dds/ddsi/ddsi_cfgelems.h
index b541abd1f5..7f256f961a 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_cfgelems.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_cfgelems.h
@@ -1482,7 +1482,7 @@ static struct cfgelem internal_cfgelems[] = {
"that Cyclone DDS will forward in either direction. Samples larger than "
"this are discarded with a warning."),
UNIT("memsize")),
- BOOL("WriteBatch", NULL, 1, "false",
+ BOOL(DEPRECATED("WriteBatch"), NULL, 1, "false",
MEMBER(whc_batch),
FUNCTIONS(0, uf_boolean, 0, pf_boolean),
DESCRIPTION(
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_serdata_pserop.h b/src/core/ddsi/include/dds/ddsi/ddsi_serdata_pserop.h
index 9ebba56904..513d5f289b 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_serdata_pserop.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_serdata_pserop.h
@@ -60,7 +60,7 @@ struct ddsi_serdata_pserop {
struct ddsi_sertype_pserop {
struct ddsi_sertype c;
- uint16_t encoding_format; /* CDR_ENC_FORMAT_(PLAIN|DELIMITED|PL) */
+ uint16_t encoding_format; /* CDR_ENC_FORMAT_PLAIN */
size_t memsize;
size_t nops;
const enum pserop *ops;
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h b/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h
index 17019e4137..26c5c39d30 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h
@@ -215,6 +215,10 @@ typedef struct dds_external_reader_lifespan_qospolicy {
ddsi_duration_t duration;
} dds_external_reader_lifespan_qospolicy_t;
+typedef struct dds_writer_batching_qospolicy {
+ unsigned char batch_updates;
+} dds_writer_batching_qospolicy_t;
+
typedef struct dds_ignorelocal_qospolicy {
dds_ignorelocal_kind_t value;
} dds_ignorelocal_qospolicy_t;
@@ -268,6 +272,7 @@ typedef struct dds_data_representation_qospolicy {
#define QP_ADLINK_READER_DATA_LIFECYCLE ((uint64_t)1 << 22)
#define QP_ADLINK_READER_LIFESPAN ((uint64_t)1 << 24)
#define QP_ADLINK_SUBSCRIPTION_KEYS ((uint64_t)1 << 25)
+#define QP_CYCLONE_WRITER_BATCHING ((uint64_t)1 << 26)
#define QP_ADLINK_ENTITY_FACTORY ((uint64_t)1 << 27)
#define QP_CYCLONE_IGNORELOCAL ((uint64_t)1 << 30)
#define QP_PROPERTY_LIST ((uint64_t)1 << 31)
@@ -331,6 +336,7 @@ struct dds_qos {
/*x xR*/dds_reader_data_lifecycle_qospolicy_t reader_data_lifecycle;
/*x xR*/dds_subscription_keys_qospolicy_t subscription_keys;
/*x xR*/dds_reader_lifespan_qospolicy_t reader_lifespan;
+ /*x W*/dds_writer_batching_qospolicy_t writer_batching;
/* x */dds_ignorelocal_qospolicy_t ignorelocal;
/*xxx */dds_property_qospolicy_t property;
/*xxxR*/dds_type_consistency_enforcement_qospolicy_t type_consistency;
diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c
index b26b72c72f..7ae37921b6 100644
--- a/src/core/ddsi/src/ddsi_plist.c
+++ b/src/core/ddsi/src/ddsi_plist.c
@@ -1991,6 +1991,9 @@ static const struct piddesc piddesc_eclipse[] = {
{ PID_PAD, PDF_QOS, QP_LOCATOR_MASK, "CYCLONE_LOCATOR_MASK",
offsetof(struct ddsi_plist, qos.ignore_locator_type), membersize(struct ddsi_plist, qos.ignore_locator_type),
{.desc = { Xu, XSTOP } }, 0 },
+ { PID_PAD, PDF_QOS, QP_CYCLONE_WRITER_BATCHING, "CYCLONE_WRITER_BATCHING",
+ offsetof (struct ddsi_plist, qos.writer_batching), membersize (struct ddsi_plist, qos.writer_batching),
+ { .desc = { Xb, XSTOP } }, 0 },
#ifdef DDS_HAS_TOPIC_DISCOVERY
PP (CYCLONE_TOPIC_GUID, topic_guid, XG),
#endif
@@ -3485,7 +3488,7 @@ const dds_qos_t ddsi_default_qos_reader = {
};
const dds_qos_t ddsi_default_qos_writer = {
- .present = QP_PRESENTATION | QP_DURABILITY | QP_DEADLINE | QP_LATENCY_BUDGET | QP_LIVELINESS | QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS | QP_OWNERSHIP | QP_CYCLONE_IGNORELOCAL | QP_TOPIC_DATA | QP_GROUP_DATA | QP_USER_DATA | QP_PARTITION | QP_DURABILITY_SERVICE | QP_RELIABILITY | QP_OWNERSHIP_STRENGTH | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_ADLINK_WRITER_DATA_LIFECYCLE | QP_LOCATOR_MASK | QP_DATA_REPRESENTATION,
+ .present = QP_PRESENTATION | QP_DURABILITY | QP_DEADLINE | QP_LATENCY_BUDGET | QP_LIVELINESS | QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS | QP_OWNERSHIP | QP_CYCLONE_IGNORELOCAL | QP_TOPIC_DATA | QP_GROUP_DATA | QP_USER_DATA | QP_PARTITION | QP_DURABILITY_SERVICE | QP_RELIABILITY | QP_OWNERSHIP_STRENGTH | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_ADLINK_WRITER_DATA_LIFECYCLE | QP_LOCATOR_MASK | QP_DATA_REPRESENTATION | QP_CYCLONE_WRITER_BATCHING,
.aliased = QP_DATA_REPRESENTATION,
.presentation.access_scope = DDS_PRESENTATION_INSTANCE,
.presentation.coherent_access = 0,
@@ -3523,6 +3526,7 @@ const dds_qos_t ddsi_default_qos_writer = {
.transport_priority.value = 0,
.lifespan.duration = DDS_INFINITY,
.writer_data_lifecycle.autodispose_unregistered_instances = 1,
+ .writer_batching.batch_updates = 0,
.ignore_locator_type = 0,
.data_representation.value.n = 1,
.data_representation.value.ids = (dds_data_representation_id_t []) { DDS_DATA_REPRESENTATION_XCDR1 }
diff --git a/src/core/ddsi/src/ddsi_serdata_pserop.c b/src/core/ddsi/src/ddsi_serdata_pserop.c
index 142d157e45..0162dc65ee 100644
--- a/src/core/ddsi/src/ddsi_serdata_pserop.c
+++ b/src/core/ddsi/src/ddsi_serdata_pserop.c
@@ -94,7 +94,6 @@ static struct ddsi_serdata *serdata_pserop_fix (const struct ddsi_sertype_pserop
d->c.hash = tp->c.serdata_basehash;
if (ops != NULL)
{
- assert (d->pos >= 16 && tp->memsize >= 16);
if (plist_deser_generic (d->sample, d->data, d->pos, needs_bswap, (d->c.kind == SDK_DATA) ? tp->ops : tp->ops_key) < 0)
{
ddsrt_free (d->sample);
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index c72931d52a..b8de9440c0 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -802,6 +802,8 @@ static void wait_for_receive_threads (struct ddsi_domaingv *gv)
static struct ddsi_sertype *make_special_type_pserop (const char *typename, size_t memsize, size_t nops, const enum pserop *ops, size_t nops_key, const enum pserop *ops_key)
{
+ assert (plist_memsize_generic (ops) == memsize);
+ assert (ops_key == NULL || (memsize >= 16 && plist_memsize_generic (ops_key) == 16));
struct ddsi_sertype_pserop *st = ddsrt_malloc (sizeof (*st));
memset (st, 0, sizeof (*st));
ddsi_sertype_init (&st->c, typename, &ddsi_sertype_ops_pserop, &ddsi_serdata_ops_pserop, nops_key == 0);
diff --git a/src/core/ddsi/tests/CMakeLists.txt b/src/core/ddsi/tests/CMakeLists.txt
index 88028ca0c0..1d0610a5b5 100644
--- a/src/core/ddsi/tests/CMakeLists.txt
+++ b/src/core/ddsi/tests/CMakeLists.txt
@@ -15,6 +15,7 @@ set(ddsi_test_sources
"locators.c"
"plist_generic.c"
"plist.c"
+ "plist_leasedur.c"
"radmin.c"
"sysdeps.c"
"mem_ser.h")
diff --git a/src/core/ddsi/tests/plist_generic.c b/src/core/ddsi/tests/plist_generic.c
index a0c5be97d8..85670f5699 100644
--- a/src/core/ddsi/tests/plist_generic.c
+++ b/src/core/ddsi/tests/plist_generic.c
@@ -168,8 +168,7 @@ CU_Test (ddsi_plist_generic, ser_and_deser)
size_t sersize;
dds_return_t ret;
ret = plist_ser_generic (&ser, &sersize, descs[i].data, descs[i].desc);
- if (ret != DDS_RETCODE_OK)
- CU_ASSERT_FATAL (ret == DDS_RETCODE_OK);
+ CU_ASSERT_FATAL (ret == DDS_RETCODE_OK);
if (sersize != descs[i].exp_sersize)
CU_ASSERT (sersize == descs[i].exp_sersize);
/* if sizes don't match, still check prefix */
@@ -279,8 +278,7 @@ CU_Test (ddsi_plist_generic, invalid_input)
{
dds_return_t ret;
ret = plist_deser_generic (&mem, descs_invalid[i].ser, descs_invalid[i].sersize, false, descs_invalid[i].desc);
- if (ret == DDS_RETCODE_OK)
- CU_ASSERT_FATAL (ret != DDS_RETCODE_OK);
+ CU_ASSERT_FATAL (ret != DDS_RETCODE_OK);
}
}
diff --git a/src/core/ddsi/tests/security_msg.c b/src/core/ddsi/tests/security_msg.c
index 4513ccc016..844ae8f284 100644
--- a/src/core/ddsi/tests/security_msg.c
+++ b/src/core/ddsi/tests/security_msg.c
@@ -303,7 +303,6 @@ CU_Test (ddsi_security_msg, serializer)
/* Check serialization result. */
size_t cmpsize = (len < sizeof(test_msg_ser)) ? len : sizeof(test_msg_ser);
- assert(data != NULL); /* for Clang static analyzer */
if (memcmp (data, test_msg_ser, cmpsize) != 0)
{
printf ("memcmp(%d)\n", (int)cmpsize);
diff --git a/src/ddsrt/tests/environ.c b/src/ddsrt/tests/environ.c
index 6f7dd89e6a..46ba738fb7 100644
--- a/src/ddsrt/tests/environ.c
+++ b/src/ddsrt/tests/environ.c
@@ -49,14 +49,12 @@ CU_Test(ddsrt_environ, setenv)
rc = ddsrt_setenv(name, value);
CU_ASSERT_EQUAL(rc, DDS_RETCODE_OK);
ptr = getenv(name);
- CU_ASSERT_PTR_NOT_NULL(ptr);
- assert (ptr != NULL); /* for the benefit of clang's static analyzer */
+ CU_ASSERT_PTR_NOT_NULL_FATAL(ptr);
CU_ASSERT_STRING_EQUAL(ptr, "bar");
/* Ensure value is copied into the environment. */
value[2] = 'z';
ptr = getenv(name);
- CU_ASSERT_PTR_NOT_NULL(ptr);
- assert (ptr != NULL); /* for the benefit of clang's static analyzer */
+ CU_ASSERT_PTR_NOT_NULL_FATAL(ptr);
CU_ASSERT_STRING_EQUAL(ptr, "bar");
rc = ddsrt_setenv(name, "");
CU_ASSERT_EQUAL(rc, DDS_RETCODE_OK);
diff --git a/src/ddsrt/tests/hopscotch.c b/src/ddsrt/tests/hopscotch.c
index 3ece3e36f5..36e22fb2f5 100644
--- a/src/ddsrt/tests/hopscotch.c
+++ b/src/ddsrt/tests/hopscotch.c
@@ -298,7 +298,7 @@ static uint32_t chhtest_thread (void *varg)
{
const uint32_t ix = (raw_oper >> 2) % arg->nkeys;
bool x = ddsrt_chh_lookup (arg->chh, ksptrs[ix]);
- if (arg->check && ((ix < n) ? !x : x)) { CU_ASSERT_FATAL (0) };
+ if (arg->check && ((ix < n) ? !x : x)) { CU_ASSERT_FATAL (0); }
arg->lookups++;
}
break;
diff --git a/src/ddsrt/tests/ifaddrs.c b/src/ddsrt/tests/ifaddrs.c
index 471e01fe7b..cd33aa284d 100644
--- a/src/ddsrt/tests/ifaddrs.c
+++ b/src/ddsrt/tests/ifaddrs.c
@@ -74,7 +74,6 @@ CU_Test(ddsrt_getifaddrs, ipv4)
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
for (ifa = ifa_root; ifa; ifa = ifa->next) {
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
- assert (ifa->addr != NULL); /* for the benefit of clang's static analyzer */
CU_ASSERT_EQUAL(ifa->addr->sa_family, AF_INET);
if (ifa->addr->sa_family == AF_INET) {
if (ifa->flags & IFF_LOOPBACK) {
@@ -132,7 +131,6 @@ CU_Test(ddsrt_getifaddrs, ipv6)
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
for (ifa = ifa_root; ifa; ifa = ifa->next) {
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
- assert (ifa->addr != NULL); /* for the benefit of clang's static analyzer */
CU_ASSERT_EQUAL(ifa->addr->sa_family, AF_INET6);
if (ifa->addr->sa_family == AF_INET6) {
have_ipv6 = 1;
@@ -173,7 +171,6 @@ CU_Test(ddsrt_getifaddrs, ipv4_n_ipv6)
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
for (ifa = ifa_root; ifa; ifa = ifa->next) {
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
- assert (ifa->addr != NULL); /* for the benefit of clang's static analyzer */
CU_ASSERT(ifa->addr->sa_family == AF_INET ||
ifa->addr->sa_family == AF_INET6);
if (ifa->addr->sa_family == AF_INET) {
diff --git a/src/ddsrt/tests/log.c b/src/ddsrt/tests/log.c
index ec4cb06065..f47c7c6c89 100644
--- a/src/ddsrt/tests/log.c
+++ b/src/ddsrt/tests/log.c
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
#ifdef __APPLE__
#include
@@ -316,6 +317,7 @@ CU_Test(dds_log, newline_terminates, .fini=reset)
CU_ASSERT_PTR_NULL_FATAL(msg);
DDS_ERROR("baz\n");
CU_ASSERT_PTR_NOT_NULL_FATAL(msg);
+ assert(msg);
CU_ASSERT(strcmp(msg, "foobarbaz\n") == 0);
ddsrt_free(msg);
#endif
@@ -332,6 +334,7 @@ CU_Test(dds_log, disabled_categories_discarded, .fini=reset)
dds_set_log_mask(DDS_LC_FATAL | DDS_LC_ERROR | DDS_LC_INFO);
DDS_INFO("foobar\n");
CU_ASSERT_PTR_NOT_NULL_FATAL(msg);
+ assert(msg);
CU_ASSERT(strcmp(msg, "foobar\n") == 0);
ddsrt_free(msg);
#endif
@@ -506,5 +509,6 @@ CU_Theory((bool local, int mode, bool expect_in_trace), dds_log, fatal_aborts)
(void) local;
(void) mode;
(void) expect_in_trace;
+ CU_PASS ("test skipped on this platform");
#endif
}
diff --git a/src/ddsrt/tests/string.c b/src/ddsrt/tests/string.c
index 898cf84d7f..9e36feda04 100644
--- a/src/ddsrt/tests/string.c
+++ b/src/ddsrt/tests/string.c
@@ -83,7 +83,6 @@ CU_Theory((const char *str, const char *srch, const char *subst, size_t max, con
if (exp != NULL)
{
CU_ASSERT_FATAL(r != NULL);
- assert(r != NULL); /* for Clang static analyzer */
CU_ASSERT(strcmp(r, exp) == 0);
ddsrt_free(r);
}
diff --git a/src/idl/tests/union.c b/src/idl/tests/union.c
index e9fe07e4e6..2ec1ef9c25 100644
--- a/src/idl/tests/union.c
+++ b/src/idl/tests/union.c
@@ -466,6 +466,7 @@ CU_Test(idl_union, default_discriminator_unsigned_int)
CU_ASSERT(u->default_case && u->default_case->const_expr);
CU_ASSERT_PTR_EQUAL(idl_parent(u->default_case), u);
}
+ CU_ASSERT_FATAL(u->default_case->const_expr);
CU_ASSERT_FATAL(idl_is_literal(u->default_case->const_expr));
l = u->default_case->const_expr;
CU_ASSERT_FATAL(idl_type(l) == IDL_UINT8);
diff --git a/src/security/builtin_plugins/tests/decode_serialized_payload/src/decode_serialized_payload_utests.c b/src/security/builtin_plugins/tests/decode_serialized_payload/src/decode_serialized_payload_utests.c
index 8fd5998809..66f762c46b 100644
--- a/src/security/builtin_plugins/tests/decode_serialized_payload/src/decode_serialized_payload_utests.c
+++ b/src/security/builtin_plugins/tests/decode_serialized_payload/src/decode_serialized_payload_utests.c
@@ -784,7 +784,6 @@ CU_Test(ddssec_builtin_decode_serialized_payload, invalid_data, .init = suite_de
}
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
diff --git a/src/security/builtin_plugins/tests/encode_datareader_submessage/src/encode_datareader_submessage_utests.c b/src/security/builtin_plugins/tests/encode_datareader_submessage/src/encode_datareader_submessage_utests.c
index 8487dfc5a7..499ade5e50 100644
--- a/src/security/builtin_plugins/tests/encode_datareader_submessage/src/encode_datareader_submessage_utests.c
+++ b/src/security/builtin_plugins/tests/encode_datareader_submessage/src/encode_datareader_submessage_utests.c
@@ -825,7 +825,6 @@ static void encode_datareader_submessage_not_signed(uint32_t transformation_kind
reader_crypto = register_local_datareader(&datareader_security_attributes, &datareader_properties);
CU_ASSERT_FATAL(reader_crypto != 0);
- assert(reader_crypto != 0); // for Clang's static analyzer
session_keys = get_datareader_session(reader_crypto);
@@ -851,7 +850,6 @@ static void encode_datareader_submessage_not_signed(uint32_t transformation_kind
}
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
@@ -859,7 +857,6 @@ static void encode_datareader_submessage_not_signed(uint32_t transformation_kind
result = check_encoded_data(&encoded_buffer, is_encrypted, &header, &footer, &data);
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(header->transform_identifier.transformation_kind[3] == transformation_kind);
@@ -978,7 +975,6 @@ static void encode_datareader_submessage_sign(uint32_t transformation_kind)
reader_crypto = register_local_datareader(&datareader_security_attributes, &datareader_properties);
CU_ASSERT_FATAL(reader_crypto != 0);
- assert(reader_crypto != 0); // for Clang's static analyzer
session_keys = get_datareader_session(reader_crypto);
@@ -988,7 +984,6 @@ static void encode_datareader_submessage_sign(uint32_t transformation_kind)
{
writer_crypto = register_remote_datawriter(reader_crypto);
CU_ASSERT_FATAL(writer_crypto != 0);
- assert(writer_crypto != 0); // for Clang's static analyzer
writer_list._buffer[i] = writer_crypto;
}
@@ -1009,7 +1004,6 @@ static void encode_datareader_submessage_sign(uint32_t transformation_kind)
}
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
@@ -1018,7 +1012,6 @@ static void encode_datareader_submessage_sign(uint32_t transformation_kind)
result = check_encoded_data(&encoded_buffer, is_encrypted, &header, &footer, &data);
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(header->transform_identifier.transformation_kind[3] == transformation_kind);
diff --git a/src/security/builtin_plugins/tests/encode_datawriter_submessage/src/encode_datawriter_submessage_utests.c b/src/security/builtin_plugins/tests/encode_datawriter_submessage/src/encode_datawriter_submessage_utests.c
index d5c40c7064..a15ba39f56 100644
--- a/src/security/builtin_plugins/tests/encode_datawriter_submessage/src/encode_datawriter_submessage_utests.c
+++ b/src/security/builtin_plugins/tests/encode_datawriter_submessage/src/encode_datawriter_submessage_utests.c
@@ -799,13 +799,11 @@ static void encode_datawriter_submessage_not_signed(DDS_Security_CryptoTransform
writer_crypto = register_local_datawriter(&datawriter_security_attributes, &datawriter_properties);
CU_ASSERT_FATAL(writer_crypto != 0);
- assert(writer_crypto != 0); // for Clang's static analyzer
session_keys = get_datawriter_session(writer_crypto);
reader_crypto = register_remote_datareader(writer_crypto);
CU_ASSERT_FATAL(reader_crypto != 0);
- assert(reader_crypto != 0); // for Clang's static analyzer
reader_list._length = reader_list._maximum = 1;
reader_list._buffer = DDS_Security_DatareaderCryptoHandleSeq_allocbuf(1);
@@ -828,7 +826,6 @@ static void encode_datawriter_submessage_not_signed(DDS_Security_CryptoTransform
}
CU_ASSERT_FATAL(result);
- assert(result != 0); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
@@ -837,7 +834,6 @@ static void encode_datawriter_submessage_not_signed(DDS_Security_CryptoTransform
result = check_encoded_data(&encoded_buffer, is_encrypted, &header, &footer, &data);
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(header->transform_identifier.transformation_kind[3] == transformation_kind);
@@ -958,7 +954,6 @@ static void encode_datawriter_submessage_sign(DDS_Security_CryptoTransformKind_E
writer_crypto = register_local_datawriter(&datawriter_security_attributes, &datawriter_properties);
CU_ASSERT_FATAL(writer_crypto != 0);
- assert(writer_crypto != 0); // for Clang's static analyzer
session_keys = get_datawriter_session(writer_crypto);
@@ -968,7 +963,6 @@ static void encode_datawriter_submessage_sign(DDS_Security_CryptoTransformKind_E
{
reader_crypto = register_remote_datareader(writer_crypto);
CU_ASSERT_FATAL(reader_crypto != 0);
- assert(reader_crypto != 0); // for Clang's static analyzer
reader_list._buffer[i] = reader_crypto;
}
index = 0;
@@ -993,7 +987,6 @@ static void encode_datawriter_submessage_sign(DDS_Security_CryptoTransformKind_E
}
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
@@ -1003,7 +996,6 @@ static void encode_datawriter_submessage_sign(DDS_Security_CryptoTransformKind_E
result = check_encoded_data(&encoded_buffer, is_encrypted, &header, &footer, &data);
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(header->transform_identifier.transformation_kind[3] == transformation_kind);
diff --git a/src/security/builtin_plugins/tests/encode_rtps_message/src/encode_rtps_message_utests.c b/src/security/builtin_plugins/tests/encode_rtps_message/src/encode_rtps_message_utests.c
index 89a35ea7c2..552787baf5 100644
--- a/src/security/builtin_plugins/tests/encode_rtps_message/src/encode_rtps_message_utests.c
+++ b/src/security/builtin_plugins/tests/encode_rtps_message/src/encode_rtps_message_utests.c
@@ -827,7 +827,6 @@ static void encode_rtps_message_not_authenticated(DDS_Security_CryptoTransformKi
}
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
@@ -835,7 +834,6 @@ static void encode_rtps_message_not_authenticated(DDS_Security_CryptoTransformKi
result = check_encoded_data(&encoded_buffer, encrypted, &header, &footer, &data);
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(header->transform_identifier.transformation_kind[3] == transformation_kind);
@@ -1090,7 +1088,6 @@ CU_Test(ddssec_builtin_encode_rtps_message, invalid_args, .init = suite_encode_r
memset(&empty_reader_list, 0, sizeof(empty_reader_list));
CU_ASSERT_FATAL(local_particpant_crypto != 0);
- assert(local_particpant_crypto != 0); // for Clang's static analyzer
register_remote_participants();
for (i = 0; i < sizeof (remote_particpant_cryptos) / sizeof (remote_particpant_cryptos[0]); i++)
@@ -1100,7 +1097,6 @@ CU_Test(ddssec_builtin_encode_rtps_message, invalid_args, .init = suite_encode_r
}
CU_ASSERT_FATAL(remote_particpant_cryptos[0] != 0);
- assert(remote_particpant_cryptos[0] != 0); // for Clang's static analyzer
reader_list._length = reader_list._maximum = 1;
reader_list._buffer = DDS_Security_ParticipantCryptoHandleSeq_allocbuf(1);
diff --git a/src/security/builtin_plugins/tests/encode_serialized_payload/src/encode_serialized_payload_utests.c b/src/security/builtin_plugins/tests/encode_serialized_payload/src/encode_serialized_payload_utests.c
index f0b6256ae1..56ad5c4e69 100644
--- a/src/security/builtin_plugins/tests/encode_serialized_payload/src/encode_serialized_payload_utests.c
+++ b/src/security/builtin_plugins/tests/encode_serialized_payload/src/encode_serialized_payload_utests.c
@@ -564,7 +564,6 @@ static void encode_serialized_payload_check(uint32_t key_size, bool encrypted)
writer_crypto = register_local_datawriter(encrypted);
CU_ASSERT_FATAL(writer_crypto != 0);
- assert(writer_crypto != 0); // for Clang's static analyzer
CU_ASSERT(check_protection_kind(writer_crypto, encrypted ? DDS_SECURITY_BASICPROTECTION_KIND_ENCRYPT : DDS_SECURITY_BASICPROTECTION_KIND_SIGN));
@@ -586,14 +585,12 @@ static void encode_serialized_payload_check(uint32_t key_size, bool encrypted)
printf("[ERROR] encode_serialized_payload: %s\n", exception.message ? exception.message : "Error message missing");
}
CU_ASSERT_FATAL(result);
- assert(result); // for Clang's static analyzer
CU_ASSERT(exception.code == 0);
CU_ASSERT(exception.message == NULL);
reset_exception(&exception);
result = split_encoded_data(encoded_buffer._buffer, encoded_buffer._length, &header, &encoded_payload, &footer, encrypted);
CU_ASSERT_FATAL(result == true);
- assert(result); // for Clang's static analyzer
CU_ASSERT(check_payload_encoded(&encoded_payload, &plain_buffer, encrypted));
session_id = ddsrt_fromBE4u(*(uint32_t *)header->session_id);
diff --git a/src/security/builtin_plugins/tests/get_authenticated_peer_credential_token/src/get_authenticated_peer_credential_token_utests.c b/src/security/builtin_plugins/tests/get_authenticated_peer_credential_token/src/get_authenticated_peer_credential_token_utests.c
index 77dd71d1f6..c750b0018b 100644
--- a/src/security/builtin_plugins/tests/get_authenticated_peer_credential_token/src/get_authenticated_peer_credential_token_utests.c
+++ b/src/security/builtin_plugins/tests/get_authenticated_peer_credential_token/src/get_authenticated_peer_credential_token_utests.c
@@ -1232,9 +1232,8 @@ fill_handshake_message_token(
dh2 = &tokens[idx++];
hash_c2 = &tokens[idx++];
- CU_ASSERT(hash1_from_request != NULL);
- CU_ASSERT(hash2_from_reply != NULL);
- assert(hash1_from_request && hash2_from_reply); // for Clang's static analyzer
+ CU_ASSERT_FATAL(hash1_from_request != NULL);
+ CU_ASSERT_FATAL(hash2_from_reply != NULL);
set_binary_property_value(hash_c1, DDS_AUTHTOKEN_PROP_HASH_C1, hash1_from_request->value._buffer, hash1_from_request->value._length);
set_binary_property_value(hash_c2, DDS_AUTHTOKEN_PROP_HASH_C2, hash2_from_reply->value._buffer, hash2_from_reply->value._length);
@@ -1361,7 +1360,6 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_request )
&exception);
CU_ASSERT_FATAL(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE);
- assert(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE); // for Clang's static analyzer
/* mock reply */
dh1 = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_DH1);
@@ -1394,7 +1392,6 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_request )
handshake_handle,
&exception);
CU_ASSERT_FATAL(result == DDS_SECURITY_VALIDATION_OK_FINAL_MESSAGE);
- assert(result == DDS_SECURITY_VALIDATION_OK_FINAL_MESSAGE); // for Clang's static analyzer
/*
* Actual test.
@@ -1405,27 +1402,22 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_request )
handshake_handle,
&exception);
- CU_ASSERT_TRUE (success);
- assert(success); // for Clang's static analyzer
+ CU_ASSERT_TRUE_FATAL (success);
CU_ASSERT_FATAL(credential_token.class_id != NULL);
- assert(credential_token.class_id); // for Clang's static analyzer
CU_ASSERT(strcmp(credential_token.class_id, DDS_AUTHTOKEN_CLASS_ID) == 0);
CU_ASSERT(credential_token.properties._length == 2);
CU_ASSERT(credential_token.binary_properties._length == 0);
c_id = find_property(&credential_token, DDS_AUTHTOKEN_PROP_C_ID);
CU_ASSERT_FATAL(c_id != NULL);
- assert(c_id); // for GCC's static analyzer
CU_ASSERT_FATAL(c_id->value != NULL);
- assert(c_id && c_id->value); // for Clang's static analyzer
//printf("c_id->value: %s\n", c_id->value);
CU_ASSERT(strcmp(c_id->value, REMOTE_IDENTITY_CERTIFICATE) == 0);
c_perm = find_property(&credential_token, DDS_AUTHTOKEN_PROP_C_PERM);
CU_ASSERT_FATAL(c_perm != NULL);
CU_ASSERT_FATAL(c_perm->value != NULL);
- assert(c_perm && c_perm->value); // for Clang's static analyzer
//printf("c_perm->value: %s\n", c_perm->value);
CU_ASSERT(strcmp(c_perm->value, PERMISSIONS_DOCUMENT) == 0);
@@ -1492,7 +1484,6 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_reply )
&exception);
CU_ASSERT_FATAL(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE);
- assert(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE); // for Clang's static analyzer
/* mock final */
dh2 = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_DH2);
@@ -1526,7 +1517,6 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_reply )
&exception);
CU_ASSERT_FATAL(result == DDS_SECURITY_VALIDATION_OK);
- assert(result == DDS_SECURITY_VALIDATION_OK); // for Clang's static analyzer
/*
* Actual test.
@@ -1537,8 +1527,7 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_reply )
handshake_handle,
&exception);
- CU_ASSERT_TRUE (success);
- assert(success); // for Clang's static analyzer
+ CU_ASSERT_TRUE_FATAL (success);
CU_ASSERT_FATAL(credential_token.class_id != NULL);
CU_ASSERT(strcmp(credential_token.class_id, DDS_AUTHTOKEN_CLASS_ID) == 0);
@@ -1547,9 +1536,7 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_reply )
c_id = find_property(&credential_token, DDS_AUTHTOKEN_PROP_C_ID);
CU_ASSERT_FATAL(c_id != NULL);
- assert(c_id); // for GCC's static analyzer
CU_ASSERT_FATAL(c_id->value != NULL);
- assert(c_id && c_id->value); // for Clang's static analyzer
//printf("c_id->value: %s\n", c_id->value);
CU_ASSERT(strcmp(c_id->value, REMOTE_IDENTITY_CERTIFICATE) == 0);
@@ -1572,8 +1559,7 @@ CU_Test(ddssec_builtin_get_authenticated_peer_credential,token_after_reply )
CU_ASSERT(credential_token.binary_properties._length == 0);
success = g_auth->return_handshake_handle(g_auth, handshake_handle, &exception);
- CU_ASSERT_TRUE (success);
- assert(success); // for Clang's static analyzer
+ CU_ASSERT_TRUE_FATAL (success);
reset_exception(&exception);
diff --git a/src/security/builtin_plugins/tests/listeners_authentication/src/listeners_authentication_utests.c b/src/security/builtin_plugins/tests/listeners_authentication/src/listeners_authentication_utests.c
index 4b4891df45..0e0076851a 100644
--- a/src/security/builtin_plugins/tests/listeners_authentication/src/listeners_authentication_utests.c
+++ b/src/security/builtin_plugins/tests/listeners_authentication/src/listeners_authentication_utests.c
@@ -1677,7 +1677,6 @@ fill_handshake_message_token(
}
CU_ASSERT_FATAL(hash1_from_request != NULL);
- assert(hash1_from_request != NULL); // for Clang's static analyzer
set_binary_property_value(hash_c1, DDS_AUTHTOKEN_PROP_HASH_C1, hash1_from_request->value._buffer, hash1_from_request->value._length);
@@ -1764,7 +1763,6 @@ fill_handshake_message_token(
else
{
CU_ASSERT_FATAL (rc == DDS_SECURITY_VALIDATION_OK);
- assert(rc == DDS_SECURITY_VALIDATION_OK); // for Clang's static analyzer
set_binary_property_value(signature, DDS_AUTHTOKEN_PROP_SIGNATURE, sign, (uint32_t)signlen);
ddsrt_free(sign);
}
@@ -1967,10 +1965,8 @@ CU_Test(ddssec_builtin_listeners_auth, local_remote_set_before_validation)
hash1_sent_in_request = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert(dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert(dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
dh1_pub_key.data = dh1->value._buffer;
dh1_pub_key.length = dh1->value._length;
diff --git a/src/security/builtin_plugins/tests/process_handshake/src/process_handshake_utests.c b/src/security/builtin_plugins/tests/process_handshake/src/process_handshake_utests.c
index 40ce02ee9c..e8dae33634 100644
--- a/src/security/builtin_plugins/tests/process_handshake/src/process_handshake_utests.c
+++ b/src/security/builtin_plugins/tests/process_handshake/src/process_handshake_utests.c
@@ -1407,7 +1407,6 @@ fill_handshake_message_token(
}
CU_ASSERT_FATAL(hash1_from_request != NULL);
- assert(hash1_from_request != NULL); // for Clang's static analyzer
set_binary_property_value(hash_c1, DDS_AUTHTOKEN_PROP_HASH_C1, hash1_from_request->value._buffer, hash1_from_request->value._length);
@@ -1710,10 +1709,8 @@ CU_Test(ddssec_builtin_process_handshake,happy_day_after_request)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert(dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert(dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
dh1_pub_key.data = dh1->value._buffer;
dh1_pub_key.length = dh1->value._length;
@@ -2004,10 +2001,8 @@ CU_Test(ddssec_builtin_process_handshake,invalid_certificate)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert(dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert(dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
/* prepare reply */
dh1_pub_key.data = dh1->value._buffer;
@@ -2094,10 +2089,8 @@ CU_Test(ddssec_builtin_process_handshake,invalid_dsign_algo)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert(dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert(dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
/* prepare reply */
dh1_pub_key.data = dh1->value._buffer;
@@ -2178,10 +2171,8 @@ CU_Test(ddssec_builtin_process_handshake,invalid_kagree_algo)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert (dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert (dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
/* prepare reply */
dh1_pub_key.data = dh1->value._buffer;
@@ -2261,10 +2252,8 @@ CU_Test(ddssec_builtin_process_handshake,invalid_diffie_hellman)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert (dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert (dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
/* prepare reply */
fill_handshake_message_token(
@@ -2399,7 +2388,6 @@ CU_Test(ddssec_builtin_process_handshake,extended_certificate_check)
printf("begin_handshake_request failed: %s\n", exception.message ? exception.message : "Error message missing");
}
CU_ASSERT_FATAL(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE);
- assert(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE); // for Clang's static analyzer
/* get challenge 1 from the message */
challenge1_glb = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_CHALLENGE1);
@@ -2410,10 +2398,8 @@ CU_Test(ddssec_builtin_process_handshake,extended_certificate_check)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert(dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert(dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
dh1_pub_key.data = dh1->value._buffer;
dh1_pub_key.length = dh1->value._length;
@@ -2489,10 +2475,8 @@ CU_Test(ddssec_builtin_process_handshake,extended_certificate_check)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert (dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert (dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
dh1_pub_key.data = dh1->value._buffer;
dh1_pub_key.length = dh1->value._length;
@@ -2563,10 +2547,8 @@ CU_Test(ddssec_builtin_process_handshake,extended_certificate_check)
hash1_sentrequest = find_binary_property(&handshake_token_out, DDS_AUTHTOKEN_PROP_HASH_C1);
CU_ASSERT_FATAL(dh1 != NULL);
- assert (dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert (dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
dh1_pub_key.data = dh1->value._buffer;
dh1_pub_key.length = dh1->value._length;
@@ -2644,7 +2626,6 @@ CU_Test(ddssec_builtin_process_handshake,crl)
printf("begin_handshake_request failed: %s\n", exception.message ? exception.message : "Error message missing");
}
CU_ASSERT_FATAL(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE);
- assert(result == DDS_SECURITY_VALIDATION_PENDING_HANDSHAKE_MESSAGE); // for Clang's static analyzer
/* get challenge 1 from the message */
challenge1_glb = find_binary_property(&handshake_token_out, "challenge1");
@@ -2655,10 +2636,8 @@ CU_Test(ddssec_builtin_process_handshake,crl)
hash1_sentrequest = find_binary_property(&handshake_token_out, "hash_c1");
CU_ASSERT_FATAL(dh1 != NULL);
- assert(dh1 != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(dh1->value._length > 0);
CU_ASSERT_FATAL(dh1->value._buffer != NULL);
- assert(dh1->value._length > 0 && dh1->value._buffer != NULL); // for Clang's static analyzer
dh1_pub_key.data = dh1->value._buffer;
dh1_pub_key.length = dh1->value._length;
diff --git a/src/security/builtin_plugins/tests/register_local_datareader/src/register_local_datareader_utests.c b/src/security/builtin_plugins/tests/register_local_datareader/src/register_local_datareader_utests.c
index c29f3cc18a..09cdd1c835 100644
--- a/src/security/builtin_plugins/tests/register_local_datareader/src/register_local_datareader_utests.c
+++ b/src/security/builtin_plugins/tests/register_local_datareader/src/register_local_datareader_utests.c
@@ -101,7 +101,7 @@ static void suite_register_local_datareader_init(void)
participant_permissions,
&participant_properties,
&participant_security_attributes,
- &exception)) != DDS_SECURITY_HANDLE_NIL)
+ &exception)) != DDS_SECURITY_HANDLE_NIL);
/* Now call the function. */
remote_participant_crypto_handle = crypto->crypto_key_factory->register_matched_remote_participant(
@@ -174,8 +174,7 @@ CU_Test(ddssec_builtin_register_local_datareader, happy_day, .init = suite_regis
&exception);
/* A valid handle to be returned */
- CU_ASSERT(result != 0);
- assert(result != 0); // for Clang's static analyzer
+ CU_ASSERT_FATAL(result != 0);
CU_ASSERT(exception.code == DDS_SECURITY_ERR_OK_CODE);
@@ -231,9 +230,8 @@ CU_Test(ddssec_builtin_register_local_datareader, builtin_endpoint, .init = suit
printf("register_local_datareader: %s\n", exception.message ? exception.message : "Error message missing");
/* A valid handle to be returned */
- CU_ASSERT(result != 0);
+ CU_ASSERT_FATAL(result != 0);
CU_ASSERT(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
reader_crypto = (local_datareader_crypto *)result;
@@ -286,7 +284,6 @@ CU_Test(ddssec_builtin_register_local_datareader, special_endpoint_name, .init =
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
- assert(result != 0); // for Clang's static analyzer
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
CU_ASSERT_FATAL(((local_datareader_crypto *)result)->is_builtin_participant_volatile_message_secure_reader);
reset_exception(&exception);
diff --git a/src/security/builtin_plugins/tests/register_local_datawriter/src/register_local_datawriter_utests.c b/src/security/builtin_plugins/tests/register_local_datawriter/src/register_local_datawriter_utests.c
index 0852990388..6eab539b7d 100644
--- a/src/security/builtin_plugins/tests/register_local_datawriter/src/register_local_datawriter_utests.c
+++ b/src/security/builtin_plugins/tests/register_local_datawriter/src/register_local_datawriter_utests.c
@@ -180,9 +180,8 @@ CU_Test(ddssec_builtin_register_local_datawriter, happy_day, .init = suite_regis
printf("register_local_datawriter: %s\n", exception.message ? exception.message : "Error message missing");
/* A valid handle to be returned */
- CU_ASSERT(result != 0);
+ CU_ASSERT_FATAL(result != 0);
CU_ASSERT(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
writer_crypto = (local_datawriter_crypto *)result;
@@ -246,7 +245,6 @@ CU_Test(ddssec_builtin_register_local_datawriter, builtin_endpoint, .init = suit
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
writer_crypto = (local_datawriter_crypto *)result;
@@ -309,7 +307,6 @@ CU_Test(ddssec_builtin_register_local_datawriter, special_endpoint_name, .init =
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
CU_ASSERT_FATAL(((local_datawriter_crypto *)result)->is_builtin_participant_volatile_message_secure_writer);
reset_exception(&exception);
diff --git a/src/security/builtin_plugins/tests/register_local_participant/src/register_local_participant_utests.c b/src/security/builtin_plugins/tests/register_local_participant/src/register_local_participant_utests.c
index 8a5dfcac85..1730d195d1 100644
--- a/src/security/builtin_plugins/tests/register_local_participant/src/register_local_participant_utests.c
+++ b/src/security/builtin_plugins/tests/register_local_participant/src/register_local_participant_utests.c
@@ -152,7 +152,6 @@ CU_Test(ddssec_builtin_register_local_participant, empty_identity, .init = suite
CU_ASSERT(exception.code == DDS_SECURITY_ERR_IDENTITY_EMPTY_CODE);
CU_ASSERT_FATAL(exception.message != NULL);
- assert(exception.message != NULL); // for Clang's static analyzer
CU_ASSERT(!strcmp(exception.message, DDS_SECURITY_ERR_IDENTITY_EMPTY_MESSAGE));
CU_ASSERT(result == 0);
diff --git a/src/security/builtin_plugins/tests/register_matched_remote_datareader/src/register_matched_remote_datareader_utests.c b/src/security/builtin_plugins/tests/register_matched_remote_datareader/src/register_matched_remote_datareader_utests.c
index ea9075018d..9c4b2287b7 100644
--- a/src/security/builtin_plugins/tests/register_matched_remote_datareader/src/register_matched_remote_datareader_utests.c
+++ b/src/security/builtin_plugins/tests/register_matched_remote_datareader/src/register_matched_remote_datareader_utests.c
@@ -204,7 +204,6 @@ CU_Test(ddssec_builtin_register_remote_datareader, happy_day, .init = suite_regi
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
reader_crypto = (remote_datareader_crypto *)result;
@@ -268,7 +267,6 @@ CU_Test(ddssec_builtin_register_remote_datareader, volatile_secure, .init = suit
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
- assert(result != 0); // for Clang's static analyzer
CU_ASSERT_FATAL(((remote_datareader_crypto *)result)->is_builtin_participant_volatile_message_secure_reader);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
reset_exception(&exception);
@@ -314,9 +312,8 @@ CU_Test(ddssec_builtin_register_remote_datareader, with_origin_authentication, .
printf("register_remote_datareader: %s\n", exception.message ? exception.message : "Error message missing");
/* A valid handle to be returned */
- CU_ASSERT(result != 0);
+ CU_ASSERT_FATAL(result != 0);
CU_ASSERT(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
reader_crypto = (remote_datareader_crypto *)result;
diff --git a/src/security/builtin_plugins/tests/register_matched_remote_datawriter/src/register_matched_remote_datawriter_utests.c b/src/security/builtin_plugins/tests/register_matched_remote_datawriter/src/register_matched_remote_datawriter_utests.c
index 6806402649..b68063a49d 100644
--- a/src/security/builtin_plugins/tests/register_matched_remote_datawriter/src/register_matched_remote_datawriter_utests.c
+++ b/src/security/builtin_plugins/tests/register_matched_remote_datawriter/src/register_matched_remote_datawriter_utests.c
@@ -112,7 +112,7 @@ static void suite_register_matched_remote_datawriter_init(void)
shared_secret_handle = (DDS_Security_SharedSecretHandle)shared_secret_handle_impl;
/* Check if we actually have the validate_local_identity() function. */
- CU_ASSERT_FATAL (crypto != NULL && crypto->crypto_key_factory != NULL && crypto->crypto_key_factory->register_local_participant != NULL)
+ CU_ASSERT_FATAL (crypto != NULL && crypto->crypto_key_factory != NULL && crypto->crypto_key_factory->register_local_participant != NULL);
memset(&exception, 0, sizeof(DDS_Security_SecurityException));
memset(&participant_properties, 0, sizeof(participant_properties));
@@ -198,12 +198,10 @@ CU_Test(ddssec_builtin_register_remote_datawriter, happy_day, .init = suite_regi
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
writer_crypto = (remote_datawriter_crypto *)result;
CU_ASSERT_FATAL(writer_crypto->reader2writer_key_material != NULL);
- assert(writer_crypto->reader2writer_key_material != NULL); // for Clang's static analyzer
CU_ASSERT(master_salt_not_empty(writer_crypto->reader2writer_key_material));
CU_ASSERT(master_key_not_empty(writer_crypto->reader2writer_key_material));
CU_ASSERT_FATAL(writer_crypto->reader2writer_key_material->receiver_specific_key_id == 0);
@@ -255,7 +253,6 @@ CU_Test(ddssec_builtin_register_remote_datawriter, volatile_secure, .init = suit
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
- assert(result != 0); // for Clang's static analyzer
CU_ASSERT_FATAL(((remote_datawriter_crypto *)result)->is_builtin_participant_volatile_message_secure_writer);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
reset_exception(&exception);
@@ -302,12 +299,10 @@ CU_Test(ddssec_builtin_register_remote_datawriter, with_origin_authentication, .
/* A valid handle to be returned */
CU_ASSERT_FATAL(result != 0);
CU_ASSERT_FATAL(exception.code == DDS_SECURITY_ERR_OK_CODE);
- assert(result != 0); // for Clang's static analyzer
/* NOTE: It would be better to check if the keys have been generated but there is no interface to get them from handle */
writer_crypto = (remote_datawriter_crypto *)result;
CU_ASSERT_FATAL(writer_crypto->reader2writer_key_material != NULL);
- assert(writer_crypto->reader2writer_key_material != NULL); // for Clang's static analyzer
CU_ASSERT(master_salt_not_empty(writer_crypto->reader2writer_key_material));
CU_ASSERT(master_key_not_empty(writer_crypto->reader2writer_key_material));
CU_ASSERT_FATAL(writer_crypto->reader2writer_key_material->receiver_specific_key_id != 0);
diff --git a/src/security/builtin_plugins/tests/validate_begin_handshake_reply/src/validate_begin_handshake_reply_utests.c b/src/security/builtin_plugins/tests/validate_begin_handshake_reply/src/validate_begin_handshake_reply_utests.c
index b411047b46..bc5dda1374 100644
--- a/src/security/builtin_plugins/tests/validate_begin_handshake_reply/src/validate_begin_handshake_reply_utests.c
+++ b/src/security/builtin_plugins/tests/validate_begin_handshake_reply/src/validate_begin_handshake_reply_utests.c
@@ -1618,7 +1618,6 @@ CU_Test(ddssec_builtin_validate_begin_handshake_reply,invalid_participant_data ,
property = find_binary_property(&handshake_token_in, "c.pdata");
CU_ASSERT_FATAL(property != NULL);
- assert(property != NULL); // for Clang's static analyzer
ddsrt_free(property->name);
property->name = ddsrt_strdup("c.pdatax");
diff --git a/src/security/builtin_plugins/tests/validate_local_identity/src/validate_local_identity_utests.c b/src/security/builtin_plugins/tests/validate_local_identity/src/validate_local_identity_utests.c
index 3421796e9b..9527edd353 100644
--- a/src/security/builtin_plugins/tests/validate_local_identity/src/validate_local_identity_utests.c
+++ b/src/security/builtin_plugins/tests/validate_local_identity/src/validate_local_identity_utests.c
@@ -1219,7 +1219,6 @@ CU_Test(ddssec_builtin_validate_local_identity,missing_certificate_property)
CU_ASSERT (result != DDS_SECURITY_VALIDATION_OK);
CU_ASSERT (exception.minor_code != 0);
CU_ASSERT_FATAL (exception.message != NULL);
- assert(exception.message != NULL); // for Clang's static analyzer
CU_ASSERT(strcmp(exception.message, "validate_local_identity: missing property '" DDS_SEC_PROP_AUTH_IDENTITY_CERT "'") == 0);
dds_security_property_deinit(&participant_qos.property.value);
@@ -1278,7 +1277,6 @@ CU_Test(ddssec_builtin_validate_local_identity,missing_ca_property)
CU_ASSERT (result != DDS_SECURITY_VALIDATION_OK);
CU_ASSERT (exception.minor_code != 0);
CU_ASSERT_FATAL (exception.message != NULL);
- assert(exception.message != NULL); // for Clang's static analyzer
CU_ASSERT(strcmp(exception.message, "validate_local_identity: missing property '" DDS_SEC_PROP_AUTH_IDENTITY_CA "'") == 0);
dds_security_property_deinit(&participant_qos.property.value);
@@ -1332,7 +1330,6 @@ CU_Test(ddssec_builtin_validate_local_identity,missing_private_key_property)
CU_ASSERT (result != DDS_SECURITY_VALIDATION_OK);
CU_ASSERT (exception.minor_code != 0);
CU_ASSERT_FATAL (exception.message != NULL);
- assert(exception.message != NULL); // for Clang's static analyzer
CU_ASSERT(strcmp(exception.message, "validate_local_identity: missing property '" DDS_SEC_PROP_AUTH_PRIV_KEY "'") == 0);
dds_security_property_deinit(&participant_qos.property.value);
diff --git a/src/security/builtin_plugins/tests/validate_local_permissions/src/validate_local_permissions_utests.c b/src/security/builtin_plugins/tests/validate_local_permissions/src/validate_local_permissions_utests.c
index 3eb2802aaf..116ad7a0f1 100644
--- a/src/security/builtin_plugins/tests/validate_local_permissions/src/validate_local_permissions_utests.c
+++ b/src/security/builtin_plugins/tests/validate_local_permissions/src/validate_local_permissions_utests.c
@@ -603,7 +603,6 @@ static DDS_Security_long test_corrupted_signature(bool corrupt_permissions, bool
/* Just some (hardcoded) sanity checks. */
CU_ASSERT_FATAL(prop != NULL);
CU_ASSERT_FATAL(prop->value != NULL);
- assert(prop && prop->value); // for Clang's static analyzer
len = strlen(prop->value);
CU_ASSERT_FATAL(len > 2250);
diff --git a/src/security/builtin_plugins/tests/validate_remote_permissions/src/validate_remote_permissions_utests.c b/src/security/builtin_plugins/tests/validate_remote_permissions/src/validate_remote_permissions_utests.c
index c1004cdfff..6dd10c51c1 100644
--- a/src/security/builtin_plugins/tests/validate_remote_permissions/src/validate_remote_permissions_utests.c
+++ b/src/security/builtin_plugins/tests/validate_remote_permissions/src/validate_remote_permissions_utests.c
@@ -261,7 +261,6 @@ static void corrupt_permission_signature(DDS_Security_AuthenticatedPeerCredentia
/* It is expected that the permissions are available in a fixed location. */
CU_ASSERT_FATAL(token != NULL);
CU_ASSERT_FATAL(token->properties._buffer != NULL);
- assert(token->properties._buffer != NULL); // for Clang's static analyzer
CU_ASSERT_FATAL(token->properties._length == 2);
CU_ASSERT_FATAL(token->properties._buffer[1].name != NULL);
CU_ASSERT_FATAL(token->properties._buffer[1].value != NULL);
@@ -270,7 +269,6 @@ static void corrupt_permission_signature(DDS_Security_AuthenticatedPeerCredentia
/* Corrupt a byte somewhere in the signature. */
permissions = token->properties._buffer[1].value;
CU_ASSERT_FATAL(permissions != NULL);
- assert(permissions != NULL); // for Clang's static analyzer
len = strlen(permissions);
CU_ASSERT_FATAL(len > 100);
permissions[len - 75]--;
diff --git a/src/security/core/tests/CMakeLists.txt b/src/security/core/tests/CMakeLists.txt
index 7ed15798e0..855f82d065 100644
--- a/src/security/core/tests/CMakeLists.txt
+++ b/src/security/core/tests/CMakeLists.txt
@@ -46,7 +46,7 @@ function(add_wrapper libname linklibs)
set_target_properties("dds_security_${libname}_wrapper" PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()
- target_link_libraries("dds_security_${libname}_wrapper" PRIVATE CUnit)
+ target_link_libraries("dds_security_${libname}_wrapper" PRIVATE CycloneDDS::ucunit)
target_include_directories("dds_security_${libname}_wrapper" PRIVATE "${CUNIT_DIR}/include")
target_link_libraries("dds_security_${libname}_wrapper" PUBLIC ddsc ${linklibs})
diff --git a/src/security/core/tests/common/test_utils.c b/src/security/core/tests/common/test_utils.c
index 48d1ab0f5e..65e0729e9a 100644
--- a/src/security/core/tests/common/test_utils.c
+++ b/src/security/core/tests/common/test_utils.c
@@ -634,7 +634,6 @@ DDS_Security_DatawriterCryptoHandle get_builtin_writer_crypto_handle(dds_entity_
pp = entidx_lookup_participant_guid(pp_entity->m_domain->gv.entity_index, &pp_entity->m_guid);
wr = ddsi_get_builtin_writer (pp, entityid);
CU_ASSERT_FATAL(wr != NULL);
- assert(wr != NULL); /* for Clang's static analyzer */
crypto_handle = wr->sec_attr->crypto_handle;
thread_state_asleep(lookup_thread_state());
dds_entity_unpin(pp_entity);
@@ -650,7 +649,6 @@ DDS_Security_DatawriterCryptoHandle get_writer_crypto_handle(dds_entity_t writer
thread_state_awake(lookup_thread_state(), &wr_entity->m_domain->gv);
wr = entidx_lookup_writer_guid(wr_entity->m_domain->gv.entity_index, &wr_entity->m_guid);
CU_ASSERT_FATAL(wr != NULL);
- assert(wr != NULL); /* for Clang's static analyzer */
crypto_handle = wr->sec_attr->crypto_handle;
thread_state_asleep(lookup_thread_state());
dds_entity_unpin(wr_entity);
diff --git a/src/security/core/tests/fsm.c b/src/security/core/tests/fsm.c
index 6790d29a58..bae701110a 100644
--- a/src/security/core/tests/fsm.c
+++ b/src/security/core/tests/fsm.c
@@ -404,7 +404,7 @@ CU_Test(ddssec_fsm, create, .init = fsm_control_init, .fini = fsm_control_fini)
{
/* Test single running state machine. Check creation of a single State Machine */
fsm_auth = dds_security_fsm_create (g_fsm_control, HandshakeTransistions, HandshakeTransistionsSize, &fsm_arg);
- CU_ASSERT_FATAL (fsm_auth != NULL)
+ CU_ASSERT_FATAL (fsm_auth != NULL);
/* set a delay that doesn't expire. Should be terminate when fsm is freed. */
dds_security_fsm_set_timeout (fsm_auth, timeout_cb, DDS_SECS(30));
@@ -560,7 +560,7 @@ CU_Test(ddssec_fsm, parallel_timeout, .init = fsm_control_init, .fini = fsm_cont
CU_Test(ddssec_fsm, delete_with_timeout, .init = fsm_control_init, .fini = fsm_control_fini)
{
fsm_timeout = dds_security_fsm_create (g_fsm_control, timeout_transitions, timeout_transitionsSize, &fsm_arg);
- CU_ASSERT_FATAL (fsm_timeout != NULL)
+ CU_ASSERT_FATAL (fsm_timeout != NULL);
dds_security_fsm_start (fsm_timeout);
ddsrt_mutex_lock (&g_lock);
while (visited_timeout == 0)
diff --git a/src/tools/_confgen/generate_defconfig.c b/src/tools/_confgen/generate_defconfig.c
index be888cca49..e4b56eab5a 100644
--- a/src/tools/_confgen/generate_defconfig.c
+++ b/src/tools/_confgen/generate_defconfig.c
@@ -94,9 +94,6 @@ void gendef_pf_networkAddresses (FILE *out, void *parent, struct cfgelem const *
char *** const p = cfg_address (parent, cfgelem);
if (*p != 0)
{
- int n = 0;
- for (int i = 0; (*p)[i] != NULL; i++)
- n++;
fprintf (out, " static char *%s_init_[] = {\n", cfgelem->membername);
for (int i = 0; (*p)[i] != NULL; i++)
fprintf (out, " \"%s\",\n", (*p)[i]);
diff --git a/src/tools/ddsperf/ddsperf.c b/src/tools/ddsperf/ddsperf.c
index f52b7f31dc..64a2a3bce1 100644
--- a/src/tools/ddsperf/ddsperf.c
+++ b/src/tools/ddsperf/ddsperf.c
@@ -1056,7 +1056,6 @@ static bool process_data (dds_entity_t rd, struct subthread_arg *arg)
dds_return_t rc;
if ((rc = dds_write_ts (wr_pong, mseq[i], iseq[i].source_timestamp - 1)) < 0 && rc != DDS_RETCODE_TIMEOUT)
error2 ("dds_write_ts (wr_pong, mseq[i], iseq[i].source_timestamp): %d\n", (int) rc);
- dds_write_flush (wr_pong);
}
}
}
@@ -1085,7 +1084,6 @@ static bool process_ping (dds_entity_t rd, struct subthread_arg *arg)
dds_return_t rc;
if ((rc = dds_write_ts (wr_pong, mseq[i], iseq[i].source_timestamp | 1)) < 0 && rc != DDS_RETCODE_TIMEOUT)
error2 ("dds_write_ts (wr_pong, mseq[i], iseq[i].source_timestamp): %d\n", (int) rc);
- dds_write_flush (wr_pong);
}
}
return (nread_ping > 0);
@@ -1119,7 +1117,6 @@ static bool process_pong (dds_entity_t rd, struct subthread_arg *arg)
ddsrt_mutex_unlock (&pongwr_lock);
if ((rc = dds_write_ts (wr_ping, mseq[i], dds_time () | 1)) < 0 && rc != DDS_RETCODE_TIMEOUT)
error2 ("dds_write (wr_ping, mseq[i]): %d\n", (int) rc);
- dds_write_flush (wr_ping);
}
}
}
@@ -1172,7 +1169,6 @@ static void maybe_send_new_ping (dds_time_t tnow, dds_time_t *tnextping)
ddsrt_mutex_unlock (&pongwr_lock);
if ((rc = dds_write_ts (wr_ping, &data, dds_time () | 1)) < 0 && rc != DDS_RETCODE_TIMEOUT)
error2 ("send_new_ping: dds_write (wr_ping, &data): %d\n", (int) rc);
- dds_write_flush (wr_ping);
if (baggage)
free (baggage);
}
@@ -2261,7 +2257,6 @@ int main (int argc, char *argv[])
if ((dp = dds_create_participant (did, qos, NULL)) < 0)
error2 ("dds_create_participant(domain %d) failed: %d\n", (int) did, (int) dp);
dds_delete_qos (qos);
- dds_write_set_batch (true);
if ((rc = dds_get_instance_handle (dp, &dp_handle)) < 0)
error2 ("dds_get_instance_handle(participant) failed: %d\n", (int) rc);
@@ -2376,8 +2371,10 @@ int main (int argc, char *argv[])
dds_delete_listener (listener);
listener = dds_create_listener ((void *) (uintptr_t) MM_RD_DATA);
dds_lset_publication_matched (listener, publication_matched_listener);
+ dds_qset_writer_batching (qos, true);
if ((wr_data = dds_create_writer (pub, tp_data, qos, listener)) < 0)
error2 ("dds_create_writer(%s) failed: %d\n", tpname_data, (int) wr_data);
+ dds_qset_writer_batching (qos, false);
dds_delete_listener (listener);
/* We only need a pong reader when sending data with a non-zero probability
diff --git a/src/tools/idlc/tests/test_common.c b/src/tools/idlc/tests/test_common.c
index e9b6eabe9f..c45b11101f 100644
--- a/src/tools/idlc/tests/test_common.c
+++ b/src/tools/idlc/tests/test_common.c
@@ -47,7 +47,5 @@ idl_retcode_t generate_test_descriptor (idl_pstate_t *pstate, const char *idl, s
if ((ret = generate_descriptor_impl(pstate, topic, descriptor)) != IDL_RETCODE_OK)
return ret;
CU_ASSERT_PTR_NOT_NULL_FATAL (descriptor);
- assert (descriptor); /* static analyzer */
-
return ret;
}
diff --git a/src/ucunit/CMakeLists.txt b/src/ucunit/CMakeLists.txt
new file mode 100644
index 0000000000..0d31f2191b
--- /dev/null
+++ b/src/ucunit/CMakeLists.txt
@@ -0,0 +1,45 @@
+#
+# Copyright(c) 2023 ZettaScale Technology and others
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
+# v. 1.0 which is available at
+# http://www.eclipse.org/org/documents/edl-v10.php.
+#
+# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+#
+include (GenerateExportHeader)
+
+if (BUILD_SHARED_LIBS OR NOT DEFINED BUILD_SHARED_LIBS)
+ add_library(ucunit SHARED "")
+else()
+ add_library(ucunit)
+endif()
+add_library(${PROJECT_NAME}::ucunit ALIAS ucunit)
+
+set(srcs_ucunit
+ "${CMAKE_CURRENT_LIST_DIR}/src/ucunit.c")
+set(hdrs_ucunit
+ "${CMAKE_CURRENT_LIST_DIR}/include/ucunit/ucunit.h")
+
+target_sources(ucunit PRIVATE ${srcs_ucunit} ${hdrs_ucunit})
+
+target_include_directories(ucunit
+ PUBLIC
+ "$"
+ "$"
+ "$"
+ PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/src"
+ INTERFACE
+ $)
+
+generate_export_header(
+ ucunit BASE_NAME UCUNIT EXPORT_FILE_NAME include/ucunit/export.h)
+
+add_executable(test_ucunit)
+target_sources(test_ucunit PRIVATE tests/test_ucunit.c)
+target_link_libraries(test_ucunit CycloneDDS::ucunit)
+
+add_test(NAME ucunit COMMAND $/test_ucunit)
diff --git a/src/ucunit/include/CUnit/Automated.h b/src/ucunit/include/CUnit/Automated.h
new file mode 100644
index 0000000000..5fcbc720e9
--- /dev/null
+++ b/src/ucunit/include/CUnit/Automated.h
@@ -0,0 +1,6 @@
+#ifndef CUNIT_AUTOMATED_H
+#define CUNIT_AUTOMATED_H
+
+#include "ucunit/ucunit.h"
+
+#endif /* CUNIT_AUTOMATED_H */
diff --git a/src/ucunit/include/CUnit/Basic.h b/src/ucunit/include/CUnit/Basic.h
new file mode 100644
index 0000000000..aacd68b989
--- /dev/null
+++ b/src/ucunit/include/CUnit/Basic.h
@@ -0,0 +1,6 @@
+#ifndef CUNIT_BASIC_H
+#define CUNIT_BASIC_H
+
+#include "ucunit/ucunit.h"
+
+#endif /* CUNIT_BASIC_H */
diff --git a/src/ucunit/include/CUnit/CUError.h b/src/ucunit/include/CUnit/CUError.h
new file mode 100644
index 0000000000..12f85c18bc
--- /dev/null
+++ b/src/ucunit/include/CUnit/CUError.h
@@ -0,0 +1,6 @@
+#ifndef CUNIT_CUERROR_H
+#define CUNIT_CUERROR_H
+
+#include "ucunit/ucunit.h"
+
+#endif /* CUNIT_CUERROR_H */
diff --git a/src/ucunit/include/CUnit/CUnit.h b/src/ucunit/include/CUnit/CUnit.h
new file mode 100644
index 0000000000..000516036b
--- /dev/null
+++ b/src/ucunit/include/CUnit/CUnit.h
@@ -0,0 +1,6 @@
+#ifndef CUNIT_CUNIT_H
+#define CUNIT_CUNIT_H
+
+#include "ucunit/ucunit.h"
+
+#endif /* CUNIT_CUNIT_H */
diff --git a/cmake/Modules/CUnit/include/CUnit/Test.h b/src/ucunit/include/CUnit/Test.h
similarity index 97%
rename from cmake/Modules/CUnit/include/CUnit/Test.h
rename to src/ucunit/include/CUnit/Test.h
index 4797c35dca..6d2b02139b 100644
--- a/cmake/Modules/CUnit/include/CUnit/Test.h
+++ b/src/ucunit/include/CUnit/Test.h
@@ -1,9 +1,7 @@
#ifndef CUNIT_TEST_H
#define CUNIT_TEST_H
-#include
-#include
-#include
+#include "ucunit/ucunit.h"
#if defined (__cplusplus)
extern "C" {
@@ -93,4 +91,3 @@ typedef struct {
#endif
#endif /* CUNIT_TEST_H */
-
diff --git a/cmake/Modules/CUnit/include/CUnit/Theory.h b/src/ucunit/include/CUnit/Theory.h
similarity index 100%
rename from cmake/Modules/CUnit/include/CUnit/Theory.h
rename to src/ucunit/include/CUnit/Theory.h
diff --git a/src/ucunit/include/ucunit/ucunit.h b/src/ucunit/include/ucunit/ucunit.h
new file mode 100644
index 0000000000..d2504ef6ed
--- /dev/null
+++ b/src/ucunit/include/ucunit/ucunit.h
@@ -0,0 +1,320 @@
+// Copyright(c) 2023 ZettaScale Technology and others
+//
+// This program and the accompanying materials are made available under the
+// terms of the Eclipse Public License v. 2.0 which is available at
+// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
+// v. 1.0 which is available at
+// http://www.eclipse.org/org/documents/edl-v10.php.
+//
+// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+
+#ifndef UCUNIT_H
+#define UCUNIT_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ucunit/export.h"
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifdef __GNUC__
+#define CU_UNREACHABLE __builtin_unreachable ()
+#else
+#define CU_UNREACHABLE ((void)0)
+#endif
+
+#define CU_ASSERT_IMPLEMENTATION(value_, line, expr, file, something, fatal_) do { \
+ const bool cu_assert_impl_value = (value_); \
+ const bool cu_assert_impl_fatal = (fatal_); \
+ CU_assertImplementation (cu_assert_impl_value, (line), (expr), (file), (something), cu_assert_impl_fatal); \
+ if (!cu_assert_impl_value && cu_assert_impl_fatal) \
+ CU_UNREACHABLE; \
+} while (0)
+
+/** Record a pass condition without performing a logical test. */
+#define CU_PASS(msg) \
+ CU_ASSERT_IMPLEMENTATION(true, __LINE__, ("CU_PASS(" #msg ")"), __FILE__, "", false)
+
+/** Simple assertion.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT(value) \
+ CU_ASSERT_IMPLEMENTATION((value), __LINE__, #value, __FILE__, "", false)
+
+/** Simple assertion.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_FATAL(value) \
+ CU_ASSERT_IMPLEMENTATION((value), __LINE__, #value, __FILE__, "", true)
+
+/** Simple assertion.
+ * Reports failure with no other action.
+ */
+#define CU_TEST(value) \
+ CU_ASSERT_IMPLEMENTATION((value), __LINE__, #value, __FILE__, "", false)
+
+/** Simple assertion.
+ * Reports failure and causes test to abort.
+ */
+#define CU_TEST_FATAL(value) \
+ CU_ASSERT_IMPLEMENTATION((value), __LINE__, #value, __FILE__, "", true)
+
+/** Record a failure without performing a logical test. */
+#define CU_FAIL(msg) \
+ CU_ASSERT_IMPLEMENTATION(false, __LINE__, ("CU_FAIL(" #msg ")"), __FILE__, "", false)
+
+/** Record a failure without performing a logical test, and abort test. */
+#define CU_FAIL_FATAL(msg) \
+ CU_ASSERT_IMPLEMENTATION(false, __LINE__, ("CU_FAIL_FATAL(" #msg ")"), __FILE__, "", true)
+
+/** Asserts that value is true.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_TRUE(value) \
+ CU_ASSERT_IMPLEMENTATION((value), __LINE__, ("CU_ASSERT_TRUE(" #value ")"), __FILE__, "", false)
+
+/** Asserts that value is true.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_TRUE_FATAL(value) \
+ CU_ASSERT_IMPLEMENTATION((value), __LINE__, ("CU_ASSERT_TRUE_FATAL(" #value ")"), __FILE__, "", true)
+
+/** Asserts that value is false.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_FALSE(value) \
+ CU_ASSERT_IMPLEMENTATION(!(value), __LINE__, ("CU_ASSERT_FALSE(" #value ")"), __FILE__, "", false)
+
+/** Asserts that value is false.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_FALSE_FATAL(value) \
+ CU_ASSERT_IMPLEMENTATION(!(value), __LINE__, ("CU_ASSERT_FALSE_FATAL(" #value ")"), __FILE__, "", true)
+
+/** Asserts that actual == expected.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_EQUAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", false)
+
+/** Asserts that actual == expected.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_EQUAL_FATAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", true)
+
+/** Asserts that actual != expected.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_NOT_EQUAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", false)
+
+/** Asserts that actual != expected.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_NOT_EQUAL_FATAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", true)
+
+/** Asserts that pointers actual == expected.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_PTR_EQUAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((const void*)(actual) == (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", false)
+
+/** Asserts that pointers actual == expected.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_PTR_EQUAL_FATAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((const void*)(actual) == (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", true)
+
+/** Asserts that pointers actual != expected.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_PTR_NOT_EQUAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((const void*)(actual) != (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", false)
+
+/** Asserts that pointers actual != expected.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(((const void*)(actual) != (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", true)
+
+/** Asserts that pointer value is NULL.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_PTR_NULL(value) \
+ CU_ASSERT_IMPLEMENTATION((NULL == (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL(" #value")"), __FILE__, "", false)
+
+/** Asserts that pointer value is NULL.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_PTR_NULL_FATAL(value) \
+ CU_ASSERT_IMPLEMENTATION((NULL == (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL_FATAL(" #value")"), __FILE__, "", true)
+
+/** Asserts that pointer value is not NULL.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_PTR_NOT_NULL(value) \
+ CU_ASSERT_IMPLEMENTATION((NULL != (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", false)
+
+/** Asserts that pointer value is not NULL.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_PTR_NOT_NULL_FATAL(value) \
+ CU_ASSERT_IMPLEMENTATION((NULL != (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value")"), __FILE__, "", true)
+
+/** Asserts that string actual == expected.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_STRING_EQUAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", false)
+
+/** Asserts that string actual == expected.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_STRING_EQUAL_FATAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", true)
+
+/** Asserts that string actual != expected.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_STRING_NOT_EQUAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", false)
+
+/** Asserts that string actual != expected.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected) \
+ CU_ASSERT_IMPLEMENTATION((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", true)
+
+/** Asserts that string actual == expected with length specified.
+ * The comparison is limited to count characters.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_NSTRING_EQUAL(actual, expected, count) \
+ CU_ASSERT_IMPLEMENTATION(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", false)
+
+/** Asserts that string actual == expected with length specified.
+ * The comparison is limited to count characters.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count) \
+ CU_ASSERT_IMPLEMENTATION(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", true)
+
+/** Asserts that string actual != expected with length specified.
+ * The comparison is limited to count characters.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count) \
+ CU_ASSERT_IMPLEMENTATION((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", false)
+
+/** Asserts that string actual != expected with length specified.
+ * The comparison is limited to count characters.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count) \
+ CU_ASSERT_IMPLEMENTATION((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", true)
+
+/** Asserts that double actual == expected within the specified tolerance.
+ * If actual is within granularity of expected, the assertion passes.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity) \
+ CU_ASSERT_IMPLEMENTATION(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", false)
+
+/** Asserts that double actual == expected within the specified tolerance.
+ * If actual is within granularity of expected, the assertion passes.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity) \
+ CU_ASSERT_IMPLEMENTATION(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", true)
+
+/** Asserts that double actual != expected within the specified tolerance.
+ * If actual is within granularity of expected, the assertion fails.
+ * Reports failure with no other action.
+ */
+#define CU_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity) \
+ CU_ASSERT_IMPLEMENTATION(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", false)
+
+/** Asserts that double actual != expected within the specified tolerance.
+ * If actual is within granularity of expected, the assertion fails.
+ * Reports failure and causes test to abort.
+ */
+#define CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity) \
+ CU_ASSERT_IMPLEMENTATION(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", true)
+
+typedef void (*CU_TestFunc) (void);
+typedef int (*CU_InitializeFunc) (void);
+typedef int (*CU_CleanupFunc) (void);
+
+struct CU_FailureRecord {
+ struct CU_FailureRecord *next;
+ const char *file;
+ int line;
+ const char *expr;
+};
+
+typedef struct CU_Test {
+ struct CU_Test *next;
+ char *name;
+ bool active;
+ CU_TestFunc testfunc;
+ uint32_t nasserts;
+ uint32_t nfailures;
+ struct CU_FailureRecord *failures, *latest_failure;
+} *CU_pTest;
+
+typedef struct CU_Suite {
+ struct CU_Suite *next;
+ char *name;
+ bool active;
+ bool initfailed;
+ CU_InitializeFunc init;
+ CU_CleanupFunc cleanup;
+ struct CU_Test *tests;
+ uint32_t ntests;
+ uint32_t ntests_pass;
+ uint32_t ntests_failed;
+} *CU_pSuite;
+
+typedef enum CU_ErrorCode {
+ CUE_SUCCESS,
+ CUE_ERROR
+} CU_ErrorCode;
+
+UCUNIT_EXPORT CU_ErrorCode CU_initialize_registry (void);
+
+UCUNIT_EXPORT CU_pSuite CU_add_suite(const char *strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean);
+
+UCUNIT_EXPORT CU_pSuite CU_get_suite (const char* strName);
+
+UCUNIT_EXPORT CU_ErrorCode CU_set_suite_active (CU_pSuite pSuite, bool fNewActive);
+
+UCUNIT_EXPORT CU_pTest CU_add_test(CU_pSuite pSuite, const char* strName, CU_TestFunc pTestFunc);
+
+UCUNIT_EXPORT void CU_set_test_active(CU_pTest pTest, bool fNewActive);
+
+UCUNIT_EXPORT CU_ErrorCode CU_get_error (void);
+
+UCUNIT_EXPORT const char *CU_get_error_msg (void);
+
+UCUNIT_EXPORT CU_ErrorCode CU_basic_run_tests (void);
+
+UCUNIT_EXPORT uint32_t CU_get_number_of_failures (void);
+
+UCUNIT_EXPORT void CU_cleanup_registry (void);
+
+UCUNIT_EXPORT void CU_assertImplementation (bool value, int line, const char *expr, const char *file, const char *something, bool isfatal);
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif
diff --git a/src/ucunit/src/ucunit.c b/src/ucunit/src/ucunit.c
new file mode 100644
index 0000000000..5fc484528f
--- /dev/null
+++ b/src/ucunit/src/ucunit.c
@@ -0,0 +1,274 @@
+// Copyright(c) 2023 ZettaScale Technology and others
+//
+// This program and the accompanying materials are made available under the
+// terms of the Eclipse Public License v. 2.0 which is available at
+// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
+// v. 1.0 which is available at
+// http://www.eclipse.org/org/documents/edl-v10.php.
+//
+// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ucunit/ucunit.h"
+
+static const char *output_filename_root;
+static CU_ErrorCode last_error;
+static struct CU_Suite *suites;
+
+static struct CU_Suite *cur_suite;
+static struct CU_Test *cur_test;
+static jmp_buf fatal_jmpbuf;
+static uint32_t failure_count;
+
+void CU_assertImplementation (bool value, int line, const char *expr, const char *file, const char *something, bool isfatal)
+{
+ (void)something;
+ assert (cur_suite && cur_test);
+ cur_test->nasserts++;
+ if (value)
+ return;
+
+ fprintf (stderr, "suite %s test %s: assertion failure: %s:%d: %s\n", cur_suite->name, cur_test->name, file, line, expr);
+ failure_count++;
+ cur_test->nfailures++;
+ struct CU_FailureRecord *fr = malloc (sizeof (*fr));
+ fr->file = file;
+ fr->line = line;
+ fr->expr = expr;
+ fr->next = NULL;
+ if (cur_test->latest_failure)
+ cur_test->latest_failure->next = fr;
+ else
+ cur_test->failures = fr;
+ cur_test->latest_failure = fr;
+
+ if (isfatal)
+ longjmp (fatal_jmpbuf, 1);
+}
+
+CU_ErrorCode CU_initialize_registry (void)
+{
+ output_filename_root = NULL;
+ failure_count = 0;
+ last_error = CUE_SUCCESS;
+ suites = NULL;
+ cur_suite = NULL;
+ cur_test = NULL;
+ return CUE_SUCCESS;
+}
+
+const char *CU_get_error_msg (void)
+{
+ switch (last_error)
+ {
+ case CUE_SUCCESS: return "success";
+ case CUE_ERROR: return "error";
+ }
+ return "?";
+}
+
+static char *ucunit_strdup (const char *s)
+{
+ size_t l = strlen (s) + 1;
+ char *n = malloc (l);
+ memcpy (n, s, l);
+ return n;
+}
+
+CU_pSuite CU_add_suite (const char *strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean)
+{
+ struct CU_Suite *cur, *last;
+ for (cur = suites, last = NULL; cur && strcmp (cur->name, strName) != 0; last = cur, cur = cur->next)
+ ;
+ if (cur != NULL)
+ return cur;
+ cur = malloc (sizeof (*cur));
+ cur->name = ucunit_strdup (strName);
+ cur->init = pInit;
+ cur->cleanup = pClean;
+ cur->next = NULL;
+ cur->active = true;
+ cur->tests = NULL;
+ cur->ntests = 0;
+ cur->ntests_pass = 0;
+ cur->ntests_failed = 0;
+ cur->initfailed = false;
+ if (last)
+ last->next = cur;
+ else
+ suites = cur;
+ return cur;
+}
+
+CU_pSuite CU_get_suite (const char *strName)
+{
+ struct CU_Suite *cur;
+ for (cur = suites; cur; cur = cur->next)
+ if (strcmp (cur->name, strName) == 0)
+ return cur;
+ return NULL;
+}
+
+CU_ErrorCode CU_set_suite_active (CU_pSuite pSuite, bool fNewActive)
+{
+ pSuite->active = fNewActive;
+ return CUE_SUCCESS;
+}
+
+CU_pTest CU_add_test (CU_pSuite pSuite, const char *strName, CU_TestFunc pTestFunc)
+{
+ struct CU_Test *cur, *last;
+ for (cur = pSuite->tests, last = NULL; cur && strcmp (cur->name, strName) != 0; last = cur, cur = cur->next)
+ ;
+ if (cur != NULL)
+ return cur;
+ cur = malloc (sizeof (*cur));
+ cur->name = ucunit_strdup (strName);
+ cur->testfunc = pTestFunc;
+ cur->next = NULL;
+ cur->active = true;
+ cur->nasserts = 0;
+ cur->nfailures = 0;
+ cur->failures = NULL;
+ cur->latest_failure = NULL;
+ if (last)
+ last->next = cur;
+ else
+ pSuite->tests = cur;
+ pSuite->ntests++;
+ return cur;
+}
+
+void CU_set_test_active (CU_pTest pTest, bool fNewActive)
+{
+ pTest->active = fNewActive;
+}
+
+CU_ErrorCode CU_get_error (void)
+{
+ return last_error;
+}
+
+static bool runtest (struct CU_Test *test)
+{
+ volatile int v = setjmp (fatal_jmpbuf);
+ if (v == 0)
+ test->testfunc ();
+ return (v == 0 && test->nfailures == 0 && test->nasserts > 0);
+}
+
+CU_ErrorCode CU_basic_run_tests (void)
+{
+ uint32_t ntests_defined = 0, ntests_failed = 0, ntests_pass = 0;
+ uint32_t nasserts_encountered = 0, nasserts_failed = 0;
+ uint32_t nsuites_failed = 0;
+
+ for (struct CU_Suite *suite = suites; suite; suite = suite->next)
+ {
+ ntests_defined += suite->ntests;
+ if (!suite->active)
+ continue;
+ cur_suite = suite;
+ if (suite->init)
+ {
+ if (suite->init () != 0)
+ {
+ fprintf (stderr, "failed to initialize suite %s\n", suite->name);
+ suite->initfailed = true;
+ nsuites_failed++;
+ continue;
+ }
+ }
+ for (struct CU_Test *test = suite->tests; test; test = test->next)
+ {
+ if (!test->active)
+ continue;
+ cur_test = test;
+ if (runtest (test))
+ suite->ntests_pass++;
+ else
+ {
+ suite->ntests_failed++;
+ if (test->nasserts == 0)
+ {
+ fprintf (stderr, "no asserts in suite %s test %s, considering it a failed test\n", suite->name, test->name);
+ failure_count++;
+ }
+ nasserts_failed += test->nfailures;
+ }
+ nasserts_encountered += test->nasserts;
+ }
+ if (suite->cleanup)
+ (void) suite->cleanup ();
+
+ ntests_failed += suite->ntests_failed;
+ ntests_pass += suite->ntests_pass;
+ }
+
+ fprintf (stderr, "tests: pass %"PRIu32" fail %"PRIu32" (total defined %"PRIu32"); asserts: pass %"PRIu32" fail %"PRIu32"\n",
+ ntests_pass, ntests_failed, ntests_defined, nasserts_encountered - nasserts_failed, nasserts_failed);
+ if (ntests_failed)
+ {
+ fprintf (stderr, "failed tests\n");
+ for (const struct CU_Suite *suite = suites; suite; suite = suite->next)
+ {
+ for (const struct CU_Test *test = suite->tests; test; test = test->next)
+ {
+ if (test->nfailures)
+ {
+ fprintf (stderr, "- %s %s\n", suite->name, test->name);
+ for (const struct CU_FailureRecord *fr = test->failures; fr; fr = fr->next)
+ fprintf (stderr, " assertion failure: %s:%d: %s\n", fr->file, fr->line, fr->expr);
+ }
+ }
+ }
+ }
+ if (nsuites_failed)
+ {
+ fprintf (stderr, "suite initialization failures: %"PRIu32":\n", nsuites_failed);
+ for (const struct CU_Suite *suite = suites; suite; suite = suite->next)
+ if (suite->initfailed)
+ fprintf (stderr, "- %s\n", suite->name);
+ failure_count++;
+ }
+ // no tests at all: failure
+ if (ntests_pass + ntests_failed == 0)
+ failure_count++;
+ return CUE_SUCCESS;
+}
+
+uint32_t CU_get_number_of_failures (void)
+{
+ return failure_count;
+}
+
+void CU_cleanup_registry (void)
+{
+ struct CU_Suite *suite;
+ while ((suite = suites) != NULL)
+ {
+ struct CU_Test *test;
+ suites = suite->next;
+ while ((test = suite->tests) != NULL)
+ {
+ suite->tests = test->next;
+ struct CU_FailureRecord *fr;
+ while ((fr = test->failures) != NULL)
+ {
+ test->failures = fr->next;
+ free (fr);
+ }
+ free (test->name);
+ free (test);
+ }
+ free (suite->name);
+ free (suite);
+ }
+}
diff --git a/src/ucunit/tests/test_ucunit.c b/src/ucunit/tests/test_ucunit.c
new file mode 100644
index 0000000000..49e042ffaa
--- /dev/null
+++ b/src/ucunit/tests/test_ucunit.c
@@ -0,0 +1,300 @@
+#include
+#include "ucunit/ucunit.h"
+
+static int initflag, testflag;
+
+static int fail_suite_init (void)
+{
+ return -1;
+}
+
+static int success_suite_init (void)
+{
+ initflag++;
+ return 0;
+}
+
+static void f_no_assert (void)
+{
+ testflag++;
+}
+
+static void f_pass (void)
+{
+ testflag++;
+ CU_PASS ("this passes");
+}
+
+static void f_fail (void)
+{
+ testflag++;
+ CU_ASSERT (0);
+}
+
+static void f_fatal (void)
+{
+ testflag++;
+ CU_ASSERT_FATAL (0);
+ testflag++; // should not get here
+}
+
+static bool test_fail_no_tests_at_all (void)
+{
+ CU_initialize_registry ();
+ CU_basic_run_tests ();
+ const bool ok = CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_no_suite_no_test (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_basic_run_tests ();
+ const bool ok = CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_suite_no_test (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, false);
+ CU_basic_run_tests ();
+ const bool ok = CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_active_suite_no_test (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_basic_run_tests ();
+ const bool ok = CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_inactive_suite_test (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, false);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 0 && CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_active_suite_inactive_test (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, false);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 0 && CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_pass (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 1 && CU_get_number_of_failures () == 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_suite_init (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", fail_suite_init, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 0 && CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_suite_init2 (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", fail_suite_init, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, true);
+ CU_pSuite suite2 = CU_add_suite ("suite2", NULL, NULL);
+ CU_set_suite_active (suite2, true);
+ CU_pTest test2 = CU_add_test (suite, "test2", f_pass);
+ CU_set_test_active (test2, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 0 && CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_no_assert (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_no_assert);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 1 && CU_get_number_of_failures () > 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_pass_suite_init (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", success_suite_init, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = initflag == 1 && testflag == 1 && CU_get_number_of_failures () == 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_pass_suite_init2 (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", success_suite_init, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_pass);
+ CU_set_test_active (test, true);
+ CU_pTest test2 = CU_add_test (suite, "test2", f_pass);
+ CU_set_test_active (test2, true);
+ CU_basic_run_tests ();
+ const bool ok = initflag == 1 && testflag == 2 && CU_get_number_of_failures () == 0;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_pass_test_fail (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_fail);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 1 && CU_get_number_of_failures () == 1;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_pass_test_fatal (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_fatal);
+ CU_set_test_active (test, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 1 && CU_get_number_of_failures () == 1;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_pass_after_fail (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_fail);
+ CU_set_test_active (test, true);
+ CU_pTest test2 = CU_add_test (suite, "test2", f_pass);
+ CU_set_test_active (test2, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 2 && CU_get_number_of_failures () == 1;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+static bool test_fail_pass_after_fatal (void)
+{
+ initflag = testflag = 0;
+ CU_initialize_registry ();
+ CU_pSuite suite = CU_add_suite ("suite", NULL, NULL);
+ CU_set_suite_active (suite, true);
+ CU_pTest test = CU_add_test (suite, "test", f_fatal);
+ CU_set_test_active (test, true);
+ CU_pTest test2 = CU_add_test (suite, "test2", f_pass);
+ CU_set_test_active (test2, true);
+ CU_basic_run_tests ();
+ const bool ok = testflag == 2 && CU_get_number_of_failures () == 1;
+ CU_cleanup_registry ();
+ return ok;
+}
+
+#define TEST(n) { #n, n }
+static const struct { const char *name; bool (*f) (void); } tests[] = {
+ TEST (test_fail_no_tests_at_all),
+ TEST (test_fail_no_suite_no_test),
+ TEST (test_fail_suite_no_test),
+ TEST (test_fail_active_suite_no_test),
+ TEST (test_fail_inactive_suite_test),
+ TEST (test_fail_active_suite_inactive_test),
+ TEST (test_pass),
+ TEST (test_fail_suite_init),
+ TEST (test_fail_suite_init2),
+ TEST (test_fail_no_assert),
+ TEST (test_pass_suite_init),
+ TEST (test_pass_suite_init2),
+ TEST (test_pass_test_fail),
+ TEST (test_pass_test_fatal),
+ TEST (test_fail_pass_after_fail),
+ TEST (test_fail_pass_after_fatal)
+};
+
+int main (int argc, char **argv)
+{
+ (void) argc; (void) argv;
+ bool ok = true;
+ for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
+ {
+ printf ("%s:\n", tests[i].name);
+ fflush (stdout);
+ if (tests[i].f ())
+ printf ("%s: pass\n", tests[i].name);
+ else
+ {
+ printf ("%s: failed\n", tests[i].name);
+ ok = false;
+ }
+ fflush (stdout);
+ }
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
+}