diff --git a/.github/workflows/config/ubsan.meta b/.github/workflows/config/ubsan.meta new file mode 100644 index 00000000000..336a5cdb615 --- /dev/null +++ b/.github/workflows/config/ubsan.meta @@ -0,0 +1,17 @@ +names: + fastdds: + cmake-args: + - -DNO_TLS=OFF + - -DSECURITY=ON + - -DFASTDDS_STATISTICS=ON + - -DSANITIZER=Undefined + - -DCOMPILE_WARNING_AS_ERROR=ON + - -DEPROSIMA_BUILD_TESTS=ON + - -DRTPS_API_TESTS=ON + - -DFASTDDS_PIM_API_TESTS=ON + - -DPERFORMANCE_TESTS=ON + googletest-distribution: + cmake-args: + - -Dgtest_force_shared_crt=ON + - -DBUILD_SHARED_LIBS=ON + - -DBUILD_GMOCK=ON diff --git a/.github/workflows/reusable-sanitizers-ci.yml b/.github/workflows/reusable-sanitizers-ci.yml index a7561d59d62..704617b09da 100644 --- a/.github/workflows/reusable-sanitizers-ci.yml +++ b/.github/workflows/reusable-sanitizers-ci.yml @@ -19,6 +19,10 @@ on: description: 'Run Thread Sanitizer job for Fast DDS' required: false type: boolean + run_ubsan_fastdds: + description: 'Run Undefined Behavior Sanitizer job for Fast DDS' + required: false + type: boolean colcon_build_args: description: 'Optional colcon build arguments' required: false @@ -547,3 +551,189 @@ jobs: run: | Write-Host ${{ steps.report_summary.outcome }} exit 1 + + ubsan_fastdds_build: + if: ${{ inputs.run_ubsan_fastdds == true }} + runs-on: ubuntu-22.04 + steps: + - name: Free disk space + uses: eProsima/eProsima-CI/ubuntu/free_disk_space@v0 + + - name: Sync eProsima/Fast-DDS repository + uses: eProsima/eProsima-CI/external/checkout@v0 + with: + path: src/fastdds + submodules: true + ref: ${{ inputs.fastdds_ref }} + + - name: Install Fix Python version + uses: eProsima/eProsima-CI/external/setup-python@v0 + with: + python-version: '3.11' + + - name: Get minimum supported version of CMake + uses: eProsima/eProsima-CI/external/get-cmake@v0 + with: + cmakeVersion: '3.22.6' + + - name: Install apt packages + uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0 + with: + packages: curl grep libasio-dev libtinyxml2-dev python3 python3-pip software-properties-common wget + + - name: Install colcon + uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0 + + - name: Install Python dependencies + uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0 + with: + packages: vcstool xmlschema + + - name: Setup CCache + uses: eProsima/eProsima-CI/external/setup-ccache-action@v0 + if: ${{ !always() }} + with: + api_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Fast CDR branch + id: get_fastcdr_branch + uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0 + with: + remote_repository: eProsima/Fast-CDR + fallback_branch: ${{ inputs.fastcdr_ref }} + + - name: Download Fast CDR + uses: eProsima/eProsima-CI/external/checkout@v0 + with: + repository: eProsima/Fast-CDR + path: ${{ github.workspace }}/src/fastcdr + ref: ${{ steps.get_fastcdr_branch.outputs.deduced_branch }} + + - name: Fetch Fast DDS dependencies + uses: eProsima/eProsima-CI/ubuntu/vcs_import@v0 + with: + vcs_repos_file: ${{ github.workspace }}/src/fastdds/fastdds.repos + destination_workspace: src + skip_existing: 'true' + + - name: Fetch Fast DDS CI dependencies + uses: eProsima/eProsima-CI/ubuntu/vcs_import@v0 + with: + vcs_repos_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/fastdds_test.repos + destination_workspace: src + skip_existing: 'true' + + - name: Show .meta file + id: show_meta + run: | + cat ${{ github.workspace }}/src/fastdds/.github/workflows/config/ubsan.meta + + - name: Colcon build + continue-on-error: false + uses: eProsima/eProsima-CI/ubuntu/colcon_build@v0 + with: + colcon_meta_file: ${{ github.workspace }}/src/fastdds/.github/workflows/config/ubsan.meta + colcon_build_args: ${{ inputs.colcon_build_args }} + cmake_args: ${{ inputs.cmake_args }} + cmake_args_default: '' + cmake_build_type: 'Debug' + workspace: ${{ github.workspace }} + workspace_dependencies: '' + + - name: Pack workspace preserving permissions + shell: bash + run: | + tar -C "${{ github.workspace }}" -cpf "${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar" . + + - name: Upload build artifacts + uses: eProsima/eProsima-CI/external/upload-artifact@v0 + with: + name: build_artifacts_fastdds_ubsan_${{ inputs.label }} + path: ${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar + + ubsan_fastdds_test: + if: ${{ inputs.run_ubsan_fastdds == true }} + needs: ubsan_fastdds_build + runs-on: ubuntu-22.04 + env: + UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1:print_stacktrace=1 + steps: + - name: Free disk space + uses: eProsima/eProsima-CI/ubuntu/free_disk_space@v0 + + - name: Download build artifact + uses: eProsima/eProsima-CI/external/download-artifact@v0 + with: + name: build_artifacts_fastdds_ubsan_${{ inputs.label }} + path: ${{ runner.temp }} + + - name: Unpack workspace preserving permissions + shell: bash + run: | + tar -C "${{ github.workspace }}" -xpf "${{ runner.temp }}/ubsan_build_${{ inputs.label }}.tar" + + - name: Install Fix Python version + uses: eProsima/eProsima-CI/external/setup-python@v0 + with: + python-version: '3.11' + + - name: Get minimum supported version of CMake + uses: eProsima/eProsima-CI/external/get-cmake@v0 + with: + cmakeVersion: '3.22.6' + + - name: Install apt packages + uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0 + with: + packages: curl grep libasio-dev libtinyxml2-dev python3 python3-pip software-properties-common wget + + - name: Install colcon + uses: eProsima/eProsima-CI/ubuntu/install_colcon@v0 + + - name: Install Python dependencies + uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0 + with: + packages: setuptools gcovr tomark xmltodict jsondiff pandas psutil + + - name: Set up hosts file for DNS testing + run: | + sudo echo "" | sudo tee -a /etc/hosts + sudo echo "127.0.0.1 localhost.test" | sudo tee -a /etc/hosts + sudo echo "::1 localhost.test" | sudo tee -a /etc/hosts + sudo echo "154.56.134.194 www.eprosima.com.test" | sudo tee -a /etc/hosts + sudo echo "216.58.215.164 www.acme.com.test" | sudo tee -a /etc/hosts + sudo echo "2a00:1450:400e:803::2004 www.acme.com.test" | sudo tee -a /etc/hosts + sudo echo "140.82.121.4 www.foo.com.test" | sudo tee -a /etc/hosts + sudo echo "140.82.121.3 www.foo.com.test" | sudo tee -a /etc/hosts + sudo echo "ff1e::ffff:efff:1 acme.org.test" | sudo tee -a /etc/hosts + + - name: Colcon test + id: test + continue-on-error: true + uses: eProsima/eProsima-CI/ubuntu/colcon_test@v0 + with: + colcon_args_default: '' + colcon_test_args: ${{ inputs.colcon_test_args }} + colcon_test_args_default: '--event-handlers=console_direct+ --return-code-on-test-failure' + ctest_args: ${{ inputs.ctest_args }} + ctest_args_default: '--timeout 300 --label-exclude "xfail"' + packages_names: fastdds + workspace: ${{ github.workspace }} + workspace_dependencies: '' + test_report_artifact: ${{ format('test_report_{0}_{1}', inputs.label, github.job) }} + + - name: Report sanitizer errors + run: | + # UBSan finding header lines look like: + # ::: runtime error: + # Filter on ": runtime error:" so we keep one line per finding (the header) + bash src/fastdds/.github/workflows/utils/specific_errors_filter.sh \ + ": runtime error:" \ + log/latest_test/fastdds/stdout_stderr.log \ + _tmp_specific_error_file.log + + python3 src/fastdds/.github/workflows/utils/log_parser.py \ + --log-file log/latest_test/fastdds/stdout_stderr.log \ + --specific-error-file _tmp_specific_error_file.log \ + --output-file $GITHUB_STEP_SUMMARY \ + --sanitizer ubsan diff --git a/.github/workflows/sanitizers-ci.yml b/.github/workflows/sanitizers-ci.yml index 07cc6d0d0d5..bd76eb01b9a 100644 --- a/.github/workflows/sanitizers-ci.yml +++ b/.github/workflows/sanitizers-ci.yml @@ -19,6 +19,10 @@ on: description: 'Run Thread Sanitizer job for Fast DDS' required: false type: boolean + run_ubsan_fastdds: + description: 'Run Undefined Behavior Sanitizer job for Fast DDS' + required: false + type: boolean colcon_build_args: description: 'Optional colcon build arguments' required: false @@ -80,6 +84,12 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'skip-ci') && !contains(github.event.pull_request.labels.*.name, 'no-test') ) }} + run_ubsan_fastdds: ${{ ((inputs.run_ubsan_fastdds == true) && true) || + ( + (github.event_name == 'pull_request') && + !contains(github.event.pull_request.labels.*.name, 'skip-ci') && + !contains(github.event.pull_request.labels.*.name, 'no-test') + ) }} colcon_build_args: ${{ inputs.colcon_build_args || '' }} colcon_test_args: ${{ inputs.colcon_test_args || '' }} cmake_args: ${{ inputs.cmake_args || '' }} diff --git a/.github/workflows/utils/log_parser.py b/.github/workflows/utils/log_parser.py index 937f71635da..f4ade3573e3 100644 --- a/.github/workflows/utils/log_parser.py +++ b/.github/workflows/utils/log_parser.py @@ -22,6 +22,23 @@ DESCRIPTION = """Script to read a test log and return a summary table""" USAGE = ('python3 log_parser.py') +# Each UBSan finding starts with a source location followed by " runtime error: ". +# We group findings by "::: " so that the same UB at the +# same site collapses into a single row regardless of repetition or ctest line prefixes +_UBSAN_LINE_RE = re.compile( + r'(?P\S+?):(?P\d+):(?P\d+):\s*runtime error:\s*(?P.+?)\s*$' +) +# Strip GitHub Actions ISO-8601 timestamp prefix and/or a ctest line prefix (": "). +# The ctest prefix captures the test id so we can attribute UBSan findings to their test; +# .sub() still strips just the prefix, and .match() exposes the id via the named group. +_GH_TIMESTAMP_RE = re.compile(r'^\d{4}-\d{2}-\d{2}T\S+\s+') +_CTEST_PREFIX_RE = re.compile(r'^(?P\d+):\s*') +# Hex addresses ("0x55ade3179480") differ across runs but represent the same logical UB; +# normalize them to "0x..." so identical findings at the same site collapse into one row. +_HEX_ADDRESS_RE = re.compile(r'0x[0-9a-fA-F]+') +# Path fragments whose UBSan findings are suppressed (thirdparty code we don't maintain). +_UBSAN_IGNORED_PATH_SUBSTRINGS = ('sqlite3.c',) + def parse_options(): """ @@ -49,7 +66,7 @@ def parse_options(): '--specific-error-file', type=str, required=True, - help='Path to file with ASAN or TSAN specific errors.' + help='Path to file with ASAN, TSAN or UBSAN specific errors.' ) required_args.add_argument( '-o', @@ -64,14 +81,17 @@ def parse_options(): '--sanitizer', type=str, required=True, - help='Sanitizer to use. [ASAN|TSAN] no case sensitive.' + help='Sanitizer to use. [ASAN|TSAN|UBSAN] no case sensitive.' ) return parser.parse_args() def failure_test_list( - log_file_path: str): + log_file_path: str, + ignored_test_ids: set = None): + + ignored_test_ids = ignored_test_ids or set() # failed tests saved_lines = [] @@ -93,12 +113,16 @@ def failure_test_list( # Thus, it uses this variable to get the correct # of spaces in error name n_spaces_in_error = len(test[test.find('(')+1:test.find(')')].split()) - 1 + test_id = split_test[- 4 - n_spaces_in_error] + if test_id in ignored_test_ids: + continue + # Insert as failed test (in first place, because we are reading them inversed) # the new test failed with the name and id taken from split line failed_tests.insert( 0, dict({ - 'ID': split_test[- 4 - n_spaces_in_error], + 'ID': test_id, 'Name': split_test[- 2 - n_spaces_in_error], 'Type': test[test.find('(')+1:test.find(')')] })) @@ -117,6 +141,35 @@ def failure_test_list( return failed_tests, n_errors +def tests_failing_only_in_ignored_ubsan_paths( + log_file_path: str, + ignored_path_substrings: tuple): + """ + Return the set of ctest test ids whose UBSan findings are exclusively in files + matching ignored_path_substrings. Tests with no UBSan findings or with at least + one finding outside the ignored paths are excluded (i.e., they remain reported). + """ + test_id_to_paths = {} + with open(log_file_path, 'r', encoding='utf-8', errors='replace') as file: + for line in file: + stripped = _GH_TIMESTAMP_RE.sub('', line.rstrip('\r\n')) + id_match = _CTEST_PREFIX_RE.match(stripped) + if not id_match: + continue + ubsan_match = _UBSAN_LINE_RE.search(stripped[id_match.end():]) + if not ubsan_match: + continue + test_id_to_paths.setdefault(id_match.group('id'), set()).add( + ubsan_match.group('path')) + + return { + test_id for test_id, paths in test_id_to_paths.items() + if paths and all( + any(sub in path for sub in ignored_path_substrings) + for path in paths) + } + + def _common_line_splitter( line: str, text_to_split_start: str, @@ -148,6 +201,22 @@ def tsan_line_splitter( text_to_split_end=' (pid=') +def ubsan_line_splitter( + line: str): + stripped = _GH_TIMESTAMP_RE.sub('', line.rstrip('\r\n')) + stripped = _CTEST_PREFIX_RE.sub('', stripped) + match = _UBSAN_LINE_RE.search(stripped) + if not match: + # Not an UBSan finding header + return None + if any(sub in match.group('path') for sub in _UBSAN_IGNORED_PATH_SUBSTRINGS): + # Ignore UBSan findings in thirdparty code we don't maintain. + return None + basename = match.group('path').rsplit('/', 1)[-1] + desc = _HEX_ADDRESS_RE.sub('0x...', match.group('desc')) + return f"{basename}:{match.group('line')}:{match.group('col')}: {desc}" + + def common_specific_errors_list( errors_file_path: str, line_splitter): @@ -170,11 +239,14 @@ def common_specific_errors_dict( errors_file_path: str, line_splitter): - # failed tests + # Open with newline='' so Python's universal-newline mode does not split a single + # grep-emitted line on bare '\r' characters. errors = {} - with open(errors_file_path, 'r') as file: - for line in file.readlines(): + with open(errors_file_path, 'r', newline='') as file: + for line in file: error_id = line_splitter(line) + if error_id is None: + continue if error_id in errors: errors[error_id] += 1 else: @@ -203,10 +275,19 @@ def main(): # Parse arguments args = parse_options() - # Get specific ASAN or TSAN variables - asan = args.sanitizer.lower() == 'asan' - line_splitter = (asan_line_splitter if asan else tsan_line_splitter) - file_title = ('ASAN' if asan else 'TSAN') + ' Errors Summary' + # Select the splitter and report title for the requested sanitizer. + sanitizer = args.sanitizer.lower() + splitters = { + 'asan': (asan_line_splitter, 'ASAN'), + 'tsan': (tsan_line_splitter, 'TSAN'), + 'ubsan': (ubsan_line_splitter, 'UBSAN'), + } + if sanitizer not in splitters: + raise SystemExit( + f"Unsupported sanitizer '{args.sanitizer}'. Expected one of: " + f"{', '.join(s.upper() for s in splitters)}.") + line_splitter, title_prefix = splitters[sanitizer] + file_title = f'{title_prefix} Errors Summary' # Execute specific errors parse specific_errors, n_errors = common_specific_errors_list( @@ -217,9 +298,18 @@ def main(): result=specific_errors, output_file_path=args.output_file) + # For UBSan, also drop from the "Tests failed" table any test whose findings + # were all in ignored thirdparty paths (matches what we suppress above). + ignored_test_ids = set() + if sanitizer == 'ubsan': + ignored_test_ids = tests_failing_only_in_ignored_ubsan_paths( + log_file_path=args.log_file, + ignored_path_substrings=_UBSAN_IGNORED_PATH_SUBSTRINGS) + # Execute failed tests tests_failed, _ = failure_test_list( - log_file_path=args.log_file) + log_file_path=args.log_file, + ignored_test_ids=ignored_test_ids) print_list_to_markdown( title='Tests failed', result=tests_failed, diff --git a/CMakeLists.txt b/CMakeLists.txt index 636d282923f..67950c854f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,23 @@ if (SANITIZER) message(FATAL_ERROR "Thread sanitizer requires Clang or GCC. Aborting.") endif() + elseif(${SANITIZER} STREQUAL "UNDEFINED") + message(STATUS "Enabling undefined behavior sanitizer...") + # Warning/Error messages + if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug")) + message(WARNING "Undefined behavior sanitizer results with an optimized (non-Debug) build may be misleading") + endif() + + if(CMAKE_COMPILER_IS_GNUCXX) + message(STATUS "Building with Undefined behavior sanitizer Tools") + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer -fsanitize=float-cast-overflow -fsanitize=float-divide-by-zero -fsanitize=bounds-strict") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer -fsanitize=float-cast-overflow -fsanitize=float-divide-by-zero -fsanitize=bounds-strict") + + else() + message(FATAL_ERROR "Undefined behavior sanitizer requires GCC. Aborting.") + endif() + else() message(WARNING "Sanitizer option not supported. Continuing without any code instrumentation... ") diff --git a/include/fastdds/statistics/dds/domain/DomainParticipant.hpp b/include/fastdds/statistics/dds/domain/DomainParticipant.hpp index 3c312b298b9..7997dc02c62 100644 --- a/include/fastdds/statistics/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/statistics/dds/domain/DomainParticipant.hpp @@ -25,7 +25,9 @@ #include #include #include +#include #include +#include #include #include @@ -46,6 +48,13 @@ class DomainParticipant : public eprosima::fastdds::dds::DomainParticipant { DomainParticipant() = delete; +protected: + + DomainParticipant( + const eprosima::fastdds::dds::StatusMask& mask); + + friend class eprosima::fastdds::dds::DomainParticipantFactory; + public: /** diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index e58a51d73bb..46d8bb0effd 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -40,6 +40,10 @@ #include #include +#ifdef FASTDDS_STATISTICS +#include +#endif // ifdef FASTDDS_STATISTICS + using namespace eprosima::fastdds::xmlparser; using eprosima::fastdds::rtps::RTPSDomain; @@ -159,10 +163,11 @@ DomainParticipant* DomainParticipantFactory::create_participant( const DomainParticipantQos& pqos = (&qos == &PARTICIPANT_QOS_DEFAULT) ? default_participant_qos_ : qos; - DomainParticipant* dom_part = new DomainParticipant(mask); #ifndef FASTDDS_STATISTICS + DomainParticipant* dom_part = new DomainParticipant(mask); DomainParticipantImpl* dom_part_impl = new DomainParticipantImpl(dom_part, did, pqos, listener); #else + statistics::dds::DomainParticipant* dom_part = new statistics::dds::DomainParticipant(mask); statistics::dds::DomainParticipantImpl* dom_part_impl = new statistics::dds::DomainParticipantImpl(dom_part, did, pqos, listener); #endif // FASTDDS_STATISTICS diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 4aa28eb27fc..3b69327a924 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -1563,7 +1563,7 @@ void DataWriterImpl::configure_deadline_timer_() return deadline_missed(); }, // Park timer with a huge interval (prevents spurious callbacks); we'll arm/cancel explicitly - std::numeric_limits::max() + std::chrono::microseconds::max() ); } diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index a74e04e4db1..d5382c28bdb 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include #if defined(__has_include) && __has_include() @@ -1276,7 +1278,7 @@ void DataReaderImpl::configure_deadline_timer_() return deadline_missed(); }, // Park timer with a huge interval (prevents spurious callbacks); we'll arm/cancel explicitly - std::numeric_limits::max() + std::chrono::microseconds::max() ); } @@ -1570,8 +1572,29 @@ LivelinessChangedStatus& DataReaderImpl::update_liveliness_status( const SampleLostStatus& DataReaderImpl::update_sample_lost_status( int32_t sample_lost_since_last_update) { - sample_lost_status_.total_count += sample_lost_since_last_update; - sample_lost_status_.total_count_change += sample_lost_since_last_update; + constexpr int32_t int32_max = std::numeric_limits::max(); + + // Perform the addition in 64-bit space to avoid signed-integer-overflow UB on int32_t + const int32_t prev_total = sample_lost_status_.total_count; + const int64_t new_total = + static_cast(prev_total) + sample_lost_since_last_update; + const int64_t new_change = + static_cast(sample_lost_status_.total_count_change) + sample_lost_since_last_update; + + // Saturate at int32_t max + sample_lost_status_.total_count = + (new_total > int32_max) ? int32_max : static_cast(new_total); + sample_lost_status_.total_count_change = + (new_change > int32_max) ? int32_max : static_cast(new_change); + + // Warn only when the counter reaches the max value + if (prev_total < int32_max && sample_lost_status_.total_count == int32_max) + { + EPROSIMA_LOG_WARNING(DATA_READER, + "SampleLostStatus counter for DataReader " + << guid() << " reached max value. The cumulative count will remain saturated, " + << "but listener notifications for further lost samples will continue."); + } return sample_lost_status_; } diff --git a/src/cpp/rtps/common/SerializedPayload.cpp b/src/cpp/rtps/common/SerializedPayload.cpp index 979a6871abd..4eef07b5cf8 100644 --- a/src/cpp/rtps/common/SerializedPayload.cpp +++ b/src/cpp/rtps/common/SerializedPayload.cpp @@ -76,7 +76,7 @@ bool SerializedPayload_t::operator == ( { return ((encapsulation == other.encapsulation) && (length == other.length) && - (0 == memcmp(data, other.data, length))); + (length == 0 || 0 == memcmp(data, other.data, length))); } bool SerializedPayload_t::copy( diff --git a/src/cpp/rtps/history/PoolConfig.h b/src/cpp/rtps/history/PoolConfig.h index adb7533b1d3..3f3fd72292f 100644 --- a/src/cpp/rtps/history/PoolConfig.h +++ b/src/cpp/rtps/history/PoolConfig.h @@ -19,6 +19,9 @@ #ifndef RTPS_HISTORY_POOLCONFIG_H_ #define RTPS_HISTORY_POOLCONFIG_H_ +#include +#include + #include #include @@ -56,6 +59,24 @@ struct PoolConfig : public BasicPoolConfig //! Maximum number of elements in the pool. Default value is 0, indicating to make allocations until they fail. uint32_t maximum_size; + /** + * Compute reserved + extra in int64_t and clamp to UINT32_MAX, avoiding the signed overflow + * A reserved value <= 0 means "no preallocation" (initial) or "infinite maximum" (max) + * + * @param reserved initial or maximum reserved caches + * @param extra extra caches to be added to the reserved caches + * @return the sum of reserved and extra, clamped to UINT32_MAX, or 0 if reserved is <= 0 + */ + static constexpr uint32_t clamped_reserved_plus_extra( + int32_t reserved, + int32_t extra) noexcept + { + return reserved <= 0 ? 0u : + (static_cast(reserved) + extra >= + static_cast((std::numeric_limits::max)()) ? (std::numeric_limits::max)() : + static_cast(static_cast(reserved) + extra)); + } + /** * Transform a HistoryAttributes object into a PoolConfig * @@ -70,16 +91,10 @@ struct PoolConfig : public BasicPoolConfig { history_attr.memoryPolicy, history_attr.payloadMaxSize, - // Negative or 0 means no preallocation. - // Otherwise, we need to reserve the extra to avoid dynamic allocations after the pools are created. - static_cast( - history_attr.initialReservedCaches <= 0 ? - 0 : history_attr.initialReservedCaches + history_attr.extraReservedCaches), - // Negative or 0 means infinite maximum. - // Otherwise, we need to allow the extra. - static_cast( - history_attr.maximumReservedCaches <= 0 ? - 0 : history_attr.maximumReservedCaches + history_attr.extraReservedCaches) + clamped_reserved_plus_extra( + history_attr.initialReservedCaches, history_attr.extraReservedCaches), + clamped_reserved_plus_extra( + history_attr.maximumReservedCaches, history_attr.extraReservedCaches) }; } diff --git a/src/cpp/rtps/messages/CDRMessage.cpp b/src/cpp/rtps/messages/CDRMessage.cpp index 756525651d6..6304c6bebfe 100644 --- a/src/cpp/rtps/messages/CDRMessage.cpp +++ b/src/cpp/rtps/messages/CDRMessage.cpp @@ -501,6 +501,11 @@ void CDRMessage::copyToBuffer( const uint32_t length, bool reverse) { + if (length == 0) + { + return; + } + if (reverse) { for (uint32_t i = 0; i < length; i++) @@ -804,7 +809,7 @@ bool CDRMessage::add_string( bool valid = CDRMessage::addUInt32(msg, str_siz); valid &= CDRMessage::addData(msg, (unsigned char*) in_str, str_siz); octet oc = '\0'; - for (; str_siz& 3; ++str_siz) + for (; str_siz & 3; ++str_siz) { valid &= CDRMessage::addOctet(msg, oc); } diff --git a/src/cpp/rtps/resources/TimedEvent.cpp b/src/cpp/rtps/resources/TimedEvent.cpp index b41034ed944..614ec2c03dc 100644 --- a/src/cpp/rtps/resources/TimedEvent.cpp +++ b/src/cpp/rtps/resources/TimedEvent.cpp @@ -39,6 +39,17 @@ TimedEvent::TimedEvent( service_.register_timer(impl_); } +TimedEvent::TimedEvent( + ResourceEvent& service, + std::function callback, + std::chrono::microseconds interval) + : service_(service) + , impl_(nullptr) +{ + impl_ = new TimedEventImpl(callback, interval); + service_.register_timer(impl_); +} + TimedEvent::~TimedEvent() { service_.unregister_timer(impl_); diff --git a/src/cpp/rtps/resources/TimedEvent.h b/src/cpp/rtps/resources/TimedEvent.h index 3bd42ce9c55..f25285a9644 100644 --- a/src/cpp/rtps/resources/TimedEvent.h +++ b/src/cpp/rtps/resources/TimedEvent.h @@ -106,11 +106,23 @@ class TimedEvent * @param callback Callback called when the event expires. * @param milliseconds Expiration time in milliseconds. */ - TimedEvent( + explicit TimedEvent( ResourceEvent& service, std::function callback, double milliseconds); + /*! + * @brief Construct with an expiration time expressed directly in microseconds. + * + * @param service ResourceEvent object that will operate with the event. + * @param callback Callback called when the event expires. + * @param interval Expiration time in std::chrono::microseconds. + */ + explicit TimedEvent( + ResourceEvent& service, + std::function callback, + std::chrono::microseconds interval); + //! Default destructor. virtual ~TimedEvent(); diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 00f972fa126..cf104dc0938 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -338,10 +338,15 @@ bool SecurityManager::init( { crypto_plugin_->set_logger(logging_plugin_, exception); + // When no access control plugin is configured, local_permissions_handle_ is null + NilHandle nil_permissions_handle; + const PermissionsHandle& permissions_handle = (local_permissions_handle_ != nullptr) ? + *local_permissions_handle_ : nil_permissions_handle; + local_participant_crypto_handle_ = crypto_plugin_->cryptokeyfactory()->register_local_participant( *local_identity_handle_, - *local_permissions_handle_, + permissions_handle, participant_properties.properties(), attributes, exception); diff --git a/src/cpp/rtps/security/logging/LogOptions.h b/src/cpp/rtps/security/logging/LogOptions.h index 5ef1c9b6453..5573341082f 100644 --- a/src/cpp/rtps/security/logging/LogOptions.h +++ b/src/cpp/rtps/security/logging/LogOptions.h @@ -34,11 +34,11 @@ namespace security { struct LogOptions { //! Whether the log events should be distributed over DDS - bool distribute; + bool distribute = false; //! Level at which log messages will be logged. //! Messages at or below the log_level are logged. - LoggingLevel log_level; + LoggingLevel log_level = LoggingLevel::EMERGENCY_LEVEL; //! Full path to a local file std::string log_file; diff --git a/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp b/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp index d637026238d..3ad872043cd 100644 --- a/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp +++ b/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp @@ -31,6 +31,12 @@ namespace fastdds { namespace statistics { namespace dds { +DomainParticipant::DomainParticipant( + const eprosima::fastdds::dds::StatusMask& mask) + : eprosima::fastdds::dds::DomainParticipant(mask) +{ +} + fastdds::dds::ReturnCode_t DomainParticipant::enable_statistics_datawriter( const std::string& topic_name, const eprosima::fastdds::dds::DataWriterQos& dwqos) diff --git a/test/blackbox/common/BlackboxTestsDeadlineQos.cpp b/test/blackbox/common/BlackboxTestsDeadlineQos.cpp index e6ca65119bb..cf81d555a43 100644 --- a/test/blackbox/common/BlackboxTestsDeadlineQos.cpp +++ b/test/blackbox/common/BlackboxTestsDeadlineQos.cpp @@ -28,12 +28,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; using fastlog = eprosima::fastdds::dds::Log; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class DeadlineQos : public ::testing::TestWithParam { @@ -46,7 +48,8 @@ class DeadlineQos : public ::testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -64,7 +67,8 @@ class DeadlineQos : public ::testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index 6f138dca32d..ec684aaa169 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -47,12 +47,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class Discovery : public testing::TestWithParam { @@ -65,7 +67,8 @@ class Discovery : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -83,7 +86,8 @@ class Discovery : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -1006,7 +1010,7 @@ TEST_P(Discovery, PubSubAsReliableHelloworldEndpointUserData) } //! Auxiliar method for discovering participants tests -template +template static void discoverParticipantsTest( bool avoid_multicast, size_t n_participants, diff --git a/test/blackbox/common/BlackboxTestsLifespanQoS.cpp b/test/blackbox/common/BlackboxTestsLifespanQoS.cpp index 011720125ef..1188a5e309f 100644 --- a/test/blackbox/common/BlackboxTestsLifespanQoS.cpp +++ b/test/blackbox/common/BlackboxTestsLifespanQoS.cpp @@ -23,12 +23,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class LifespanQos : public testing::TestWithParam { @@ -41,7 +43,8 @@ class LifespanQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -59,7 +62,8 @@ class LifespanQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/BlackboxTestsLivelinessQos.cpp b/test/blackbox/common/BlackboxTestsLivelinessQos.cpp index 035ccdc0567..9f56c87754d 100644 --- a/test/blackbox/common/BlackboxTestsLivelinessQos.cpp +++ b/test/blackbox/common/BlackboxTestsLivelinessQos.cpp @@ -29,12 +29,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class LivelinessQos : public testing::TestWithParam { @@ -47,7 +49,8 @@ class LivelinessQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -65,7 +68,8 @@ class LivelinessQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/BlackboxTestsNetworkConf.cpp b/test/blackbox/common/BlackboxTestsNetworkConf.cpp index 399b0d56fbd..7ab59fa72b7 100644 --- a/test/blackbox/common/BlackboxTestsNetworkConf.cpp +++ b/test/blackbox/common/BlackboxTestsNetworkConf.cpp @@ -28,10 +28,12 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT }; +} // namespace class NetworkConfig : public testing::TestWithParam> { @@ -762,8 +764,8 @@ TEST_P(NetworkConfig, PubGetSendingLocatorsWhitelist) descriptor_->m_output_udp_socket = static_cast(port); for (const auto& network_interface : interfaces) { - std::cout << "Adding interface '" << network_interface.name << "' (" << network_interface.name.size() << ")" << - std::endl; + std::cout << "Adding interface '" << network_interface.name << "' (" << network_interface.name.size() << ")" + << std::endl; descriptor_->interfaceWhiteList.push_back(network_interface.name); } diff --git a/test/blackbox/common/BlackboxTestsPubSubBasic.cpp b/test/blackbox/common/BlackboxTestsPubSubBasic.cpp index accdc723490..86296afcd2c 100644 --- a/test/blackbox/common/BlackboxTestsPubSubBasic.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubBasic.cpp @@ -34,12 +34,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class PubSubBasic : public testing::TestWithParam> { @@ -52,7 +54,8 @@ class PubSubBasic : public testing::TestWithParamset_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -72,7 +75,8 @@ class PubSubBasic : public testing::TestWithParamset_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/BlackboxTestsPubSubFragments.cpp b/test/blackbox/common/BlackboxTestsPubSubFragments.cpp index f596f8dcd30..a759bfefcc4 100644 --- a/test/blackbox/common/BlackboxTestsPubSubFragments.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubFragments.cpp @@ -26,12 +26,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace using test_params = std::tuple; @@ -46,7 +48,8 @@ class PubSubFragments : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -66,7 +69,8 @@ class PubSubFragments : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp index f61898d91aa..18c9088433e 100644 --- a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp @@ -30,12 +30,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace using test_params = std::tuple; @@ -50,7 +52,8 @@ class PubSubHistory : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -80,7 +83,8 @@ class PubSubHistory : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -1179,7 +1183,8 @@ TEST_P(PubSubHistory, WriterUnmatchClearsHistory) PubSubWriter writer2(TEST_TOPIC_NAME); //Reader with limited history size - reader.history_depth(2).reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init(); + reader.history_depth(2).reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS).mem_policy( + mem_policy_).init(); ASSERT_TRUE(reader.isInitialized()); writer.history_kind(eprosima::fastdds::dds::KEEP_ALL_HISTORY_QOS).mem_policy(mem_policy_).init(); diff --git a/test/blackbox/common/BlackboxTestsRealtimeAllocations.cpp b/test/blackbox/common/BlackboxTestsRealtimeAllocations.cpp index 9a6ceb48be3..8694a8d567d 100644 --- a/test/blackbox/common/BlackboxTestsRealtimeAllocations.cpp +++ b/test/blackbox/common/BlackboxTestsRealtimeAllocations.cpp @@ -23,12 +23,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class RealtimeAllocations : public testing::TestWithParam { @@ -41,7 +43,8 @@ class RealtimeAllocations : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -59,7 +62,8 @@ class RealtimeAllocations : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/BlackboxTestsSecurity.cpp b/test/blackbox/common/BlackboxTestsSecurity.cpp index 0136703ce69..1a2d536dadd 100644 --- a/test/blackbox/common/BlackboxTestsSecurity.cpp +++ b/test/blackbox/common/BlackboxTestsSecurity.cpp @@ -44,6 +44,7 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, @@ -55,6 +56,7 @@ enum reliability TEST_BEST_EFFORT, TEST_RELIABLE }; +} // namespace // A LogConsumer that just counts the number of entries consumed struct TestConsumer : public eprosima::fastdds::dds::LogConsumer diff --git a/test/blackbox/common/BlackboxTestsTransportTCP.cpp b/test/blackbox/common/BlackboxTestsTransportTCP.cpp index 4fd43b8f8db..c9a089588cf 100644 --- a/test/blackbox/common/BlackboxTestsTransportTCP.cpp +++ b/test/blackbox/common/BlackboxTestsTransportTCP.cpp @@ -35,10 +35,12 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT }; +} // namespace class TransportTCP : public testing::TestWithParam> { diff --git a/test/blackbox/common/BlackboxTestsTransportUDP.cpp b/test/blackbox/common/BlackboxTestsTransportUDP.cpp index b1c4b8bfabd..951174a75f5 100644 --- a/test/blackbox/common/BlackboxTestsTransportUDP.cpp +++ b/test/blackbox/common/BlackboxTestsTransportUDP.cpp @@ -33,10 +33,12 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT }; +} // namespace class TransportUDP : public testing::TestWithParam> { @@ -1177,6 +1179,100 @@ TEST(TransportUDP, MaliciousHeartbeatBigStart) EXPECT_LT(end - start, std::chrono::seconds(15)); } +// Regression test issue #24365: a sequence-number gap larger than INT32_MAX between two DATA submessages +// must not overflow DataReaderImpl::SampleLostStatus::total_count. The expected behavior is saturation at INT32_MAX. +TEST(TransportUDP, MaliciousDataLargeSequenceNumberGap) +{ + auto udp_transport = std::make_shared(); + + PubSubWriter writer(TEST_TOPIC_NAME); + PubSubReader reader(TEST_TOPIC_NAME); + + struct MaliciousData + { + std::array rtps_id{ {'R', 'T', 'P', 'S'} }; + std::array protocol_version{ {2, 3} }; + std::array vendor_id{ {0x01, 0x0F} }; + GuidPrefix_t sender_prefix{}; + + struct DataSubMsg + { + uint8_t submessage_id = 0x15; // DATA +#if FASTDDS_IS_BIG_ENDIAN_TARGET + uint8_t flags = 0x04; // D=1 +#else + uint8_t flags = 0x05; // E=1, D=1 +#endif // FASTDDS_IS_BIG_ENDIAN_TARGET + uint16_t octets_to_next_header = 24; + uint16_t extra_flags = 0; + uint16_t octets_to_inline_qos = 16; + EntityId_t reader_id{}; + EntityId_t writer_id{}; + SequenceNumber_t sn{ 0, 1u }; + // Minimal serialized payload: just the CDR_LE encapsulation header. + std::array serialized_payload{ {0x00, 0x01, 0x00, 0x00} }; + } + data; + }; + + UDPMessageSender fake_msg_sender; + + reader.disable_builtin_transport().add_user_transport_to_pparams(udp_transport) + .history_depth(10) + .reliability(eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS); + writer.history_depth(10).reliability(eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS); + + Locator_t reader_locator; + ASSERT_TRUE(IPLocator::setIPv4(reader_locator, "127.0.0.1")); + reader_locator.port = global_port; + reader.add_to_unicast_locator_list("127.0.0.1", global_port); + + reader.init(); + ASSERT_TRUE(reader.isInitialized()); + writer.init(); + ASSERT_TRUE(writer.isInitialized()); + + reader.wait_discovery(); + writer.wait_discovery(); + + auto send_data_with_sn = [&](const SequenceNumber_t& sn) + { + auto writer_guid = writer.datawriter_guid(); + + MaliciousData malicious_packet{}; + malicious_packet.sender_prefix = writer_guid.guidPrefix; + malicious_packet.data.writer_id = writer_guid.entityId; + malicious_packet.data.reader_id = reader.datareader_guid().entityId; + malicious_packet.data.sn = sn; + + CDRMessage_t msg(0); + uint32_t msg_len = static_cast(sizeof(malicious_packet)); + msg.init(reinterpret_cast(&malicious_packet), msg_len); + msg.length = msg_len; + msg.pos = msg_len; + fake_msg_sender.send(msg, reader_locator); + }; + + // Packet 1: establish baseline (SN = 1). + send_data_with_sn(SequenceNumber_t{ 0, 1u }); + // Packet 2: small gap (SN = 3) -> total_count becomes 1. + send_data_with_sn(SequenceNumber_t{ 0, 3u }); + // Packet 3: SN = 0x80000004 -> per-event lost saturates at INT32_MAX. + // Without saturation in update_sample_lost_status, total_count = 1 + INT32_MAX overflows. + send_data_with_sn(SequenceNumber_t{ 0, 0x80000004u }); + + // Allow the reader thread to drain the three injected packets. + std::this_thread::sleep_for(std::chrono::seconds(1)); + + // If the previous step did not abort the process under UBSan, the counter must remain + // non-negative (no wrap) and within int32_t range (saturated, not overflowed). + // auto status = reader.get_sample_lost_status(); + // EXPECT_GE(status.total_count, 0); + // EXPECT_LE(status.total_count, std::numeric_limits::max()); + + reader.destroy(); +} + // Test for ==operator UDPTransportDescriptor is not required as it is an abstract class and in UDPv4 is same method // Test for copy UDPTransportDescriptor is not required as it is an abstract class and in UDPv4 is same method @@ -1368,4 +1464,3 @@ GTEST_INSTANTIATE_TEST_MACRO(TransportUDP, } }); - diff --git a/test/blackbox/common/BlackboxTestsVolatile.cpp b/test/blackbox/common/BlackboxTestsVolatile.cpp index aedb0aabe3a..93504591676 100644 --- a/test/blackbox/common/BlackboxTestsVolatile.cpp +++ b/test/blackbox/common/BlackboxTestsVolatile.cpp @@ -28,12 +28,14 @@ using namespace eprosima::fastdds; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class Volatile : public testing::TestWithParam { @@ -46,7 +48,8 @@ class Volatile : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -64,7 +67,8 @@ class Volatile : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/DDSBlackboxTestsDataReader.cpp b/test/blackbox/common/DDSBlackboxTestsDataReader.cpp index ed5731f31d5..11149d1ee5c 100644 --- a/test/blackbox/common/DDSBlackboxTestsDataReader.cpp +++ b/test/blackbox/common/DDSBlackboxTestsDataReader.cpp @@ -44,12 +44,14 @@ using namespace eprosima::fastdds::rtps; std::string("incompatible_") + TEST_TOPIC_NAME) +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class DDSDataReader : public testing::TestWithParam { @@ -62,7 +64,8 @@ class DDSDataReader : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -80,7 +83,8 @@ class DDSDataReader : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -748,7 +752,8 @@ bool validate_publication_builtin_topic_data( ret &= (pubdata.lifespan == dw_qos.lifespan()); ret &= ( (pubdata.user_data.size() == dw_qos.user_data().size()) && - (0 == memcmp(pubdata.user_data.data(), dw_qos.user_data().data(), pubdata.user_data.size()))); + (pubdata.user_data.size() == 0 || + 0 == memcmp(pubdata.user_data.data(), dw_qos.user_data().data(), pubdata.user_data.size()))); ret &= (pubdata.ownership == dw_qos.ownership()); ret &= (pubdata.ownership_strength == dw_qos.ownership_strength()); ret &= (pubdata.destination_order == dw_qos.destination_order()); @@ -1449,4 +1454,3 @@ GTEST_INSTANTIATE_TEST_MACRO(DDSDataReader, } }); - diff --git a/test/blackbox/common/DDSBlackboxTestsDataWriter.cpp b/test/blackbox/common/DDSBlackboxTestsDataWriter.cpp index e76b1aecbda..54c090aa3f0 100644 --- a/test/blackbox/common/DDSBlackboxTestsDataWriter.cpp +++ b/test/blackbox/common/DDSBlackboxTestsDataWriter.cpp @@ -41,12 +41,14 @@ using namespace eprosima::fastdds; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class DDSDataWriter : public testing::TestWithParam { @@ -59,7 +61,8 @@ class DDSDataWriter : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -77,7 +80,8 @@ class DDSDataWriter : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -648,7 +652,8 @@ class TestsDataWriterQosCommonUtils qos.resource_limits().max_samples = 1000; qos.transport_priority().value = 1; qos.ownership().kind = eprosima::fastdds::dds::EXCLUSIVE_OWNERSHIP_QOS; - qos.representation().m_value.push_back(eprosima::fastdds::dds::DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); + qos.representation().m_value.push_back( + eprosima::fastdds::dds::DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); qos.history().kind = eprosima::fastdds::dds::KEEP_ALL_HISTORY_QOS; qos.lifespan().duration = {5, 0}; } @@ -747,7 +752,8 @@ bool validate_subscription_builtin_topic_data( ret &= (subdata.destination_order == dr_qos.destination_order()); ret &= ( (subdata.user_data.size() == dr_qos.user_data().size()) && - (0 == memcmp(subdata.user_data.data(), dr_qos.user_data().data(), subdata.user_data.size()))); + (subdata.user_data.size() == 0 || + 0 == memcmp(subdata.user_data.data(), dr_qos.user_data().data(), subdata.user_data.size()))); // time based filter not implemented // Subscriber Qos diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index f4debecdb66..ac4a1181067 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -36,12 +36,14 @@ using namespace eprosima::fastdds::rtps; std::string("incompatible_") + TEST_TOPIC_NAME) +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class DDSStatus : public testing::TestWithParam { @@ -55,7 +57,8 @@ class DDSStatus : public testing::TestWithParam case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -73,7 +76,8 @@ class DDSStatus : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/DDSBlackboxTestsMonitorService.cpp b/test/blackbox/common/DDSBlackboxTestsMonitorService.cpp index 8b4fdbe40e4..04db5bdf11f 100644 --- a/test/blackbox/common/DDSBlackboxTestsMonitorService.cpp +++ b/test/blackbox/common/DDSBlackboxTestsMonitorService.cpp @@ -35,12 +35,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace using MonitorServiceType = eprosima::fastdds::statistics::MonitorServiceStatusDataPubSubType; using GUIDList = std::vector; @@ -202,8 +204,8 @@ class MonitorServiceParticipant writer_stat_guids_.push_back(statistics::to_statistics_type(writers_.back()->guid())); - std::cout << "Created datawriter " << writers_.back()->guid() << " for topic " << - topics_.back()->get_name() << std::endl; + std::cout << "Created datawriter " << writers_.back()->guid() << " for topic " + << topics_.back()->get_name() << std::endl; } void create_and_add_reader( @@ -225,8 +227,8 @@ class MonitorServiceParticipant reader_stat_guids_.push_back(statistics::to_statistics_type(readers_.back()->guid())); - std::cout << "Created datareader " << readers_.back()->guid() << " for topic " << - topics_.back()->get_name() << std::endl; + std::cout << "Created datareader " << readers_.back()->guid() << " for topic " + << topics_.back()->get_name() << std::endl; } bool delete_writer() @@ -351,8 +353,8 @@ class MonitorServiceParticipant ++cb_counters_[OFFERED_DEADLINE_MISSED_IDX]; } - std::cout << "on_offered_deadline_missed() " << writer->guid() << " total_count " << status.total_count << - std::endl; + std::cout << "on_offered_deadline_missed() " << writer->guid() << " total_count " << status.total_count + << std::endl; } void on_offered_incompatible_qos ( @@ -364,8 +366,8 @@ class MonitorServiceParticipant ++cb_counters_[OFFERED_INCOMPATIBLE_QOS_IDX]; } - std::cout << "on_offered_incompatible_qos " << writer->guid() << " total_count " << status.total_count << - std::endl; + std::cout << "on_offered_incompatible_qos " << writer->guid() << " total_count " << status.total_count + << std::endl; } void on_liveliness_lost ( @@ -389,8 +391,8 @@ class MonitorServiceParticipant ++cb_counters_[PUBLICATION_MATCHED_IDX]; } - std::cout << "on_publication_matched " << writer->guid() << " total_count " << status.total_count << - std::endl; + std::cout << "on_publication_matched " << writer->guid() << " total_count " << status.total_count + << std::endl; } void on_requested_deadline_missed ( @@ -402,8 +404,8 @@ class MonitorServiceParticipant ++cb_counters_[REQUESTED_DEADLINE_MISSED_IDX]; } - std::cout << "on_requested_deadline_missed" << reader->guid() << " total_count " << status.total_count << - std::endl; + std::cout << "on_requested_deadline_missed" << reader->guid() << " total_count " << status.total_count + << std::endl; } void on_requested_incompatible_qos ( @@ -415,8 +417,8 @@ class MonitorServiceParticipant ++cb_counters_[REQUESTED_INCOMPATIBLE_QOS_IDX]; } - std::cout << "on_requested_incompatible_qos" << reader->guid() << " total_count " << status.total_count << - std::endl; + std::cout << "on_requested_incompatible_qos" << reader->guid() << " total_count " << status.total_count + << std::endl; } void on_liveliness_changed ( @@ -428,8 +430,8 @@ class MonitorServiceParticipant ++cb_counters_[LIVELINESS_CHANGED_IDX]; } - std::cout << "on_liveliness_changed " << reader->guid() << " not_alive_count " << status.not_alive_count << - std::endl; + std::cout << "on_liveliness_changed " << reader->guid() << " not_alive_count " << status.not_alive_count + << std::endl; } void on_subscription_matched ( @@ -441,8 +443,8 @@ class MonitorServiceParticipant ++cb_counters_[SUBSCRIPTION_MATCHED_IDX]; } - std::cout << "on_subscription_matched " << reader->guid() << " total_count " << status.total_count << - std::endl; + std::cout << "on_subscription_matched " << reader->guid() << " total_count " << status.total_count + << std::endl; } void on_sample_lost ( @@ -752,7 +754,7 @@ struct ProxySampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - data.local_entity() == elem.local_entity(); + data.local_entity() == elem.local_entity(); }); bool msgs_was_expected = false; @@ -760,8 +762,8 @@ struct ProxySampleValidator : public SampleValidator // If this proxy is not expected, avoid further processing and return if (!msgs_was_expected) { - std::cout << "Unexpected proxy " << statistics::to_fastdds_type(data.local_entity()) << - data.status_kind() << std::endl; + std::cout << "Unexpected proxy " << statistics::to_fastdds_type(data.local_entity()) + << data.status_kind() << std::endl; return; } @@ -847,7 +849,7 @@ struct ProxySampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - data.local_entity() == elem.local_entity(); + data.local_entity() == elem.local_entity(); }); std::cout << "Received unregistration of instance " @@ -878,8 +880,8 @@ struct ConnectionListSampleValidator : public SampleValidator for (auto& connection : data.value().connection_list()) { - std::cout << "Received Connection: \n\tMode: " << static_cast(connection.mode()) << - "\n\tGuid " << statistics::to_fastdds_type(connection.guid()) << "\n\t" + std::cout << "Received Connection: \n\tMode: " << static_cast(connection.mode()) + << "\n\tGuid " << statistics::to_fastdds_type(connection.guid()) << "\n\t" << "Announced Locators: "; for (auto& locator : connection.used_locators()) { @@ -930,9 +932,10 @@ struct ConnectionListSampleValidator : public SampleValidator EPROSIMA_LOG_ERROR(BBTestsMonitorService, "Locator not found in sample msg " << statistics::to_fastdds_type(total_msgs_elem_connection. - announced_locators()[i]) << - " for local entity " << - statistics::to_fastdds_type(total_msgs_elem.local_entity())); + announced_locators()[i]) + << " for local entity " + << statistics::to_fastdds_type( + total_msgs_elem.local_entity())); same_locators = false; break; } @@ -984,9 +987,9 @@ struct IncompatibleQoSSampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - (data.local_entity() == elem.local_entity()) && - (data.value().incompatible_qos_status().last_policy_id() - == elem.value().incompatible_qos_status().last_policy_id()); + (data.local_entity() == elem.local_entity()) && + (data.value().incompatible_qos_status().last_policy_id() + == elem.value().incompatible_qos_status().last_policy_id()); }); bool msg_was_expected = false; @@ -1018,9 +1021,9 @@ struct LivelinessLostSampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - (data.local_entity() == elem.local_entity()) && - (data.value().liveliness_lost_status().total_count() - == elem.value().liveliness_lost_status().total_count()); + (data.local_entity() == elem.local_entity()) && + (data.value().liveliness_lost_status().total_count() + == elem.value().liveliness_lost_status().total_count()); }); if (assert_on_non_expected_msgs_) @@ -1057,9 +1060,9 @@ struct LivelinessChangedSampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - (data.local_entity() == elem.local_entity()) && - (data.value().liveliness_changed_status().not_alive_count() - >= elem.value().liveliness_changed_status().not_alive_count()); + (data.local_entity() == elem.local_entity()) && + (data.value().liveliness_changed_status().not_alive_count() + >= elem.value().liveliness_changed_status().not_alive_count()); }); std::cout << "Received Liveliness Changed on local_entity " @@ -1096,9 +1099,9 @@ struct DeadlineMissedSampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - (data.local_entity() == elem.local_entity()) && - (data.value().deadline_missed_status().total_count() - >= elem.value().deadline_missed_status().total_count()); + (data.local_entity() == elem.local_entity()) && + (data.value().deadline_missed_status().total_count() + >= elem.value().deadline_missed_status().total_count()); }); std::cout << "Received Deadline Missed on local_entity " @@ -1130,8 +1133,8 @@ struct SampleLostSampleValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - (data.local_entity() == elem.local_entity()) && - (data.value().sample_lost_status().total_count() >= 1); + (data.local_entity() == elem.local_entity()) && + (data.value().sample_lost_status().total_count() >= 1); }); std::cout << "Received Sample Lost on local_entity " @@ -1164,10 +1167,10 @@ struct ExtendedIncompatibleQoSValidator : public SampleValidator [&](const MonitorServiceType::type& elem) { return (data.status_kind() == elem.status_kind()) && - (data.local_entity() == elem.local_entity()) && - (std::is_permutation(data.value().extended_incompatible_qos_status().begin(), - data.value().extended_incompatible_qos_status().end(), - elem.value().extended_incompatible_qos_status().begin())); + (data.local_entity() == elem.local_entity()) && + (std::is_permutation(data.value().extended_incompatible_qos_status().begin(), + data.value().extended_incompatible_qos_status().end(), + elem.value().extended_incompatible_qos_status().begin())); }); std::cout << "Received Extended Incompatible QoS on local_entity " @@ -2684,10 +2687,10 @@ TEST(DDSMonitorServiceTest, monitor_service_advanced_extended_incompatible_qos) add_extended_incompatible_policy( expected_msgs, w_guid, - { - {MSPs[1].get_reader_guids().back(), {DURABILITY_QOS_POLICY_ID}}, - {MSPs[2].get_reader_guids().back(), {LIVELINESS_QOS_POLICY_ID}}, - {MSPs[3].get_reader_guids().back(), {OWNERSHIP_QOS_POLICY_ID}}}); + { + {MSPs[1].get_reader_guids().back(), {DURABILITY_QOS_POLICY_ID}}, + {MSPs[2].get_reader_guids().back(), {LIVELINESS_QOS_POLICY_ID}}, + {MSPs[3].get_reader_guids().back(), {OWNERSHIP_QOS_POLICY_ID}}}); MSC.start_reception(expected_msgs); diff --git a/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp b/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp index 6ee263351c7..c09c37a5620 100644 --- a/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp +++ b/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp @@ -26,12 +26,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class OwnershipQos : public testing::TestWithParam { @@ -44,7 +46,8 @@ class OwnershipQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -62,7 +65,8 @@ class OwnershipQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -84,16 +88,20 @@ void exclusive_kind_non_keyed_sample_reception( PubSubWriter writer3(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -229,19 +237,24 @@ void exclusive_kind_keyed_sample_reception( PubSubWriter writer4(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer4.ownership_strength(4).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -453,16 +466,20 @@ void exclusive_kind_non_keyed_writers_same_guid( PubSubWriter writer3(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -557,19 +574,24 @@ void exclusive_kind_keyed_writers_same_guid( PubSubWriter writer4(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer4.ownership_strength(10).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -898,16 +920,20 @@ void exclusive_kind_non_keyed_undiscovered_writer( PubSubWriter writer3(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -1031,19 +1057,24 @@ void exclusive_kind_keyed_undiscovered_writer( PubSubWriter writer4(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer4.ownership_strength(4).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -1272,24 +1303,28 @@ void exclusive_kind_non_keyed_lost_liveliness( }; reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .lease_duration({1, 0}, {0, 500000000}) .init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .add_user_transport_to_pparams(testTransport1) .disable_builtin_transport() .lease_duration({1, 0}, {0, 500000000}) .init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .lease_duration({1, 0}, {0, 500000000}) .init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .add_user_transport_to_pparams(testTransport3) .disable_builtin_transport() @@ -1436,31 +1471,36 @@ void exclusive_kind_keyed_lost_liveliness( }; reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .lease_duration({1, 0}, {0, 500000000}) .init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .lease_duration({1, 0}, {0, 500000000}) .init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .add_user_transport_to_pparams(testTransport2) .disable_builtin_transport() .lease_duration({1, 0}, {0, 500000000}) .init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .add_user_transport_to_pparams(testTransport3) .disable_builtin_transport() .lease_duration({1, 0}, {0, 500000000}) .init(); writer4.ownership_strength(4).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ) .add_user_transport_to_pparams(testTransport4) .disable_builtin_transport() @@ -1681,19 +1721,24 @@ void exclusive_kind_keyed_unregistering_instance( PubSubWriter writer4(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer4.ownership_strength(4).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); @@ -1902,19 +1947,24 @@ void exclusive_kind_keyed_disposing_instance( PubSubWriter writer4(TEST_TOPIC_NAME); reader.ownership_exclusive().reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer1.ownership_strength(1).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer2.ownership_strength(2).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer3.ownership_strength(3).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); writer4.ownership_strength(4).reliability( - reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS + reliable ? eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS : + eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS ).init(); ASSERT_TRUE(reader.isInitialized()); diff --git a/test/blackbox/common/DDSBlackboxTestsPersistence.cpp b/test/blackbox/common/DDSBlackboxTestsPersistence.cpp index d7893df2f6d..f74dd3d64b5 100644 --- a/test/blackbox/common/DDSBlackboxTestsPersistence.cpp +++ b/test/blackbox/common/DDSBlackboxTestsPersistence.cpp @@ -27,12 +27,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class DDSPersistenceTests : public testing::TestWithParam { @@ -54,7 +56,8 @@ class DDSPersistenceTests : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -71,9 +74,9 @@ class DDSPersistenceTests : public testing::TestWithParam std::ostringstream ss; std::string test_case_name(info->test_case_name()); std::string test_name(info->name()); - ss << - test_case_name.replace(test_case_name.find_first_of('/'), 1, "_") << "_" << - test_name.replace(test_name.find_first_of('/'), 1, "_") << "_" << GET_PID() << ".db"; + ss + << test_case_name.replace(test_case_name.find_first_of('/'), 1, "_") << "_" + << test_name.replace(test_name.find_first_of('/'), 1, "_") << "_" << GET_PID() << ".db"; db_file_name_ = ss.str(); } @@ -85,7 +88,8 @@ class DDSPersistenceTests : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp b/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp index eb39a0b7093..f66e9c0adbd 100644 --- a/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp +++ b/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp @@ -31,12 +31,14 @@ using namespace eprosima::fastdds::rtps; using namespace eprosima::fastdds::dds; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class PersistenceGuid : public ::testing::TestWithParam { @@ -50,7 +52,8 @@ class PersistenceGuid : public ::testing::TestWithParam case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -67,9 +70,9 @@ class PersistenceGuid : public ::testing::TestWithParam std::ostringstream ss; std::string test_case_name(info->test_case_name()); std::string test_name(info->name()); - ss << - test_case_name.replace(test_case_name.find_first_of('/'), 1, "_") << "_" << - test_name.replace(test_name.find_first_of('/'), 1, "_") << "_" << GET_PID() << ".db"; + ss + << test_case_name.replace(test_case_name.find_first_of('/'), 1, "_") << "_" + << test_name.replace(test_name.find_first_of('/'), 1, "_") << "_" << GET_PID() << ".db"; db_file_name = ss.str(); } @@ -80,7 +83,8 @@ class PersistenceGuid : public ::testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -98,11 +102,11 @@ class PersistenceGuid : public ::testing::TestWithParam int32_t pid = static_cast(GET_PID()); uint8_t* bytes = reinterpret_cast(&pid); std::stringstream gp; - gp << std::hex << - std::setfill('0') << std::setw(2) << static_cast(bytes[0]) << "." << - std::setfill('0') << std::setw(2) << static_cast(bytes[1]) << "." << - std::setfill('0') << std::setw(2) << static_cast(bytes[2]) << "." << - std::setfill('0') << std::setw(2) << static_cast(bytes[3]); + gp << std::hex + << std::setfill('0') << std::setw(2) << static_cast(bytes[0]) << "." + << std::setfill('0') << std::setw(2) << static_cast(bytes[1]) << "." + << std::setfill('0') << std::setw(2) << static_cast(bytes[2]) << "." + << std::setfill('0') << std::setw(2) << static_cast(bytes[3]); return gp.str(); } @@ -180,29 +184,29 @@ TEST_P(PersistenceGuid, SetPersistenceGuidThroughDDSLayer) std::stringstream command; #ifdef WIN32 // Check if there is one entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 1); #else // Check if there is one entry in the writers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 1); @@ -378,28 +382,28 @@ TEST_P(PersistenceGuid, SetPersistenceGuidByXML) std::stringstream command; #ifdef WIN32 // Check if there is one entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 1); #else - command << "python3 check_guid.py '" << db_file_name << - "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 1); @@ -473,29 +477,29 @@ TEST_P(PersistenceGuid, SetPersistenceForTransientLocal) std::stringstream command; #ifdef WIN32 // Check if there is one entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 1); #else // Check if there is one entry in the writers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 1); @@ -563,29 +567,29 @@ TEST_P(PersistenceGuid, NoSetPersistenceForTransientLocal) std::stringstream command; #ifdef WIN32 // Check if there is no entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70.65.72.73.5f|67.75.69.64\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70.65.72.73.5f|67.75.69.64\""; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 255); // Check if there is no entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << db_file_name << - "\" \"readers\" \"77.65.61.64.65.72.5f.70.65.72.73.5f|68.76.70.65\""; + command << "python check_guid.py \"" << db_file_name + << "\" \"readers\" \"77.65.61.64.65.72.5f.70.65.72.73.5f|68.76.70.65\""; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 255); #else // Check if there is no entry in the writers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'writers_histories' '77.72.69.74.65.72.5f.70.65.72.73.5f|67.75.69.64'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'writers_histories' '77.72.69.74.65.72.5f.70.65.72.73.5f|67.75.69.64'"; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 255); // Check if there is no entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << db_file_name << - "' 'readers' '77.65.61.64.65.72.5f.70.65.72.73.5f|68.76.70.65'"; + command << "python3 check_guid.py '" << db_file_name + << "' 'readers' '77.65.61.64.65.72.5f.70.65.72.73.5f|68.76.70.65'"; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 255); diff --git a/test/blackbox/common/DDSBlackboxTestsPropertyQos.cpp b/test/blackbox/common/DDSBlackboxTestsPropertyQos.cpp index 698b7c0a633..5ba2adc7157 100644 --- a/test/blackbox/common/DDSBlackboxTestsPropertyQos.cpp +++ b/test/blackbox/common/DDSBlackboxTestsPropertyQos.cpp @@ -31,12 +31,14 @@ const std::string INTERNAL_PROPERTY_VALUE = "Other Value"; using namespace eprosima::fastdds; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class PropertyQos : public testing::TestWithParam { @@ -49,7 +51,8 @@ class PropertyQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -67,7 +70,8 @@ class PropertyQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp b/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp index ba009a8a280..4c1afde17c1 100644 --- a/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp +++ b/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp @@ -33,12 +33,14 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class SHMUDP : public testing::TestWithParam { @@ -51,7 +53,8 @@ class SHMUDP : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -69,7 +72,8 @@ class SHMUDP : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; @@ -209,7 +213,7 @@ static void shm_metatraffic_test( auto discovery_checker = [unicast, multicast](const eprosima::fastdds::rtps::ParticipantBuiltinTopicData& info, - eprosima::fastdds::rtps::ParticipantDiscoveryStatus /*status*/) + eprosima::fastdds::rtps::ParticipantDiscoveryStatus /*status*/) { check_shm_locators(info, unicast, multicast); return true; @@ -246,7 +250,8 @@ TEST(SHMUDP, SHM_metatraffic_wrong_config) /* Set up log */ BlackboxMockConsumer* helper_consumer = new BlackboxMockConsumer(); eprosima::fastdds::dds::Log::ClearConsumers(); // Remove default consumers - eprosima::fastdds::dds::Log::RegisterConsumer(std::unique_ptr(helper_consumer)); // Registering a consumer transfer ownership + eprosima::fastdds::dds::Log::RegisterConsumer(std::unique_ptr( + helper_consumer)); // Registering a consumer transfer ownership // Filter specific message eprosima::fastdds::dds::Log::SetVerbosity(eprosima::fastdds::dds::Log::Kind::Warning); eprosima::fastdds::dds::Log::SetCategoryFilter(std::regex("RTPS_NETWORK")); diff --git a/test/blackbox/common/DDSBlackboxTestsUserDataQos.cpp b/test/blackbox/common/DDSBlackboxTestsUserDataQos.cpp index 3bfdff1f555..468ce734a8a 100644 --- a/test/blackbox/common/DDSBlackboxTestsUserDataQos.cpp +++ b/test/blackbox/common/DDSBlackboxTestsUserDataQos.cpp @@ -23,12 +23,14 @@ using namespace eprosima::fastdds; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS, DATASHARING }; +} // namespace class UserDataQos : public testing::TestWithParam { @@ -41,7 +43,8 @@ class UserDataQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_FULL; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = true; @@ -59,7 +62,8 @@ class UserDataQos : public testing::TestWithParam { case INTRAPROCESS: library_settings.intraprocess_delivery = eprosima::fastdds::IntraprocessDeliveryType::INTRAPROCESS_OFF; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_settings); + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings( + library_settings); break; case DATASHARING: enable_datasharing = false; diff --git a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp index a2f2c860b3e..be9a9c4afbb 100644 --- a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp @@ -39,11 +39,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class RTPS : public testing::TestWithParam { @@ -771,8 +773,8 @@ TEST(RTPS, MultithreadedWriterCreation) using SchedulerPolicy_t = eprosima::fastdds::rtps::FlowControllerSchedulerPolicy; auto create_flow_controller = [](const char* name, SchedulerPolicy_t scheduler, - int32_t max_bytes_per_period, - uint64_t period_ms) -> std::shared_ptr + int32_t max_bytes_per_period, + uint64_t period_ms) -> std::shared_ptr { std::shared_ptr descriptor = std::make_shared(); descriptor->name = name; diff --git a/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp b/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp index f9f5d56545b..89f91840cc7 100644 --- a/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp @@ -25,11 +25,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class RTPSDiscovery : public testing::TestWithParam { diff --git a/test/blackbox/common/RTPSBlackboxTestsPersistence.cpp b/test/blackbox/common/RTPSBlackboxTestsPersistence.cpp index 29c9469c647..6964a2c6e6b 100644 --- a/test/blackbox/common/RTPSBlackboxTestsPersistence.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsPersistence.cpp @@ -30,11 +30,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class Persistence : public ::testing::TestWithParam { @@ -134,9 +136,9 @@ class Persistence : public ::testing::TestWithParam std::ostringstream ss; std::string test_case_name(info->test_case_name()); std::string test_name(info->name()); - ss << - test_case_name.replace(test_case_name.find_first_of('/'), 1, "_") << "_" << - test_name.replace(test_name.find_first_of('/'), 1, "_") << "_" << GET_PID() << ".db"; + ss + << test_case_name.replace(test_case_name.find_first_of('/'), 1, "_") << "_" + << test_name.replace(test_name.find_first_of('/'), 1, "_") << "_" << GET_PID() << ".db"; db_file_name_ = ss.str(); // Fill guid prefix diff --git a/test/blackbox/common/RTPSBlackboxTestsPersistenceGuid.cpp b/test/blackbox/common/RTPSBlackboxTestsPersistenceGuid.cpp index ceddac2cf92..294825c2d1c 100644 --- a/test/blackbox/common/RTPSBlackboxTestsPersistenceGuid.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsPersistenceGuid.cpp @@ -30,11 +30,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class PersistenceGuid : public ::testing::TestWithParam { @@ -76,11 +78,11 @@ class PersistenceGuid : public ::testing::TestWithParam int32_t pid = static_cast(GET_PID()); uint8_t* bytes = reinterpret_cast(&pid); std::stringstream gp; - gp << std::hex << - std::setfill('0') << std::setw(2) << static_cast(bytes[0]) << "." << - std::setfill('0') << std::setw(2) << static_cast(bytes[1]) << "." << - std::setfill('0') << std::setw(2) << static_cast(bytes[2]) << "." << - std::setfill('0') << std::setw(2) << static_cast(bytes[3]); + gp << std::hex + << std::setfill('0') << std::setw(2) << static_cast(bytes[0]) << "." + << std::setfill('0') << std::setw(2) << static_cast(bytes[1]) << "." + << std::setfill('0') << std::setw(2) << static_cast(bytes[2]) << "." + << std::setfill('0') << std::setw(2) << static_cast(bytes[3]); return gp.str(); } @@ -151,29 +153,29 @@ TEST_P(PersistenceGuid, SetPersistenceGuidThroughRTPSLayer) std::stringstream command; #ifdef WIN32 // Check if there is one entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << persistence_db << - "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; + command << "python check_guid.py \"" << persistence_db + << "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << persistence_db << - "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; + command << "python check_guid.py \"" << persistence_db + << "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 1); #else // Check if there is one entry in the writers database table with the stated persistence guid - command << "python3 check_guid.py '" << persistence_db << - "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; + command << "python3 check_guid.py '" << persistence_db + << "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << persistence_db << - "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; + command << "python3 check_guid.py '" << persistence_db + << "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 1); @@ -255,57 +257,57 @@ TEST_P(PersistenceGuid, CheckPrevalenceBetweenManualAndPropertyConfiguration) std::stringstream command; #ifdef WIN32 // Check if there is one entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << persistence_db << - "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; + command << "python check_guid.py \"" << persistence_db + << "\" \"writers_histories\" \"77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64\""; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 0); // Check if there is one entry in the writers database table with the stated persistence guid - command << "python check_guid.py \"" << persistence_db << - "\" \"writers_histories\" \"00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.1\""; + command << "python check_guid.py \"" << persistence_db + << "\" \"writers_histories\" \"00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.1\""; result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result1, 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << persistence_db << - "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; + command << "python check_guid.py \"" << persistence_db + << "\" \"readers\" \"77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65\""; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 0); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python check_guid.py \"" << persistence_db << - "\" \"readers\" \"00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.2\""; + command << "python check_guid.py \"" << persistence_db + << "\" \"readers\" \"00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.2\""; result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ(result2, 1); #else // Check if there is one entry in the writers database table with the stated persistence guid - command << "python3 check_guid.py '" << persistence_db << - "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; + command << "python3 check_guid.py '" << persistence_db + << "' 'writers_histories' '77.72.69.74.65.72.5f.70." << guidprefix_4 << "|67.75.69.64'"; int result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 0); // Check if there is one entry in the writers database table with the stated persistence guid - command << "python3 check_guid.py '" << persistence_db << - "' 'writers_histories' '00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.1'"; + command << "python3 check_guid.py '" << persistence_db + << "' 'writers_histories' '00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.1'"; result1 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result1 >> 8), 1); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << persistence_db << - "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; + command << "python3 check_guid.py '" << persistence_db + << "' 'readers' '77.65.61.64.65.72.5f.70." << guidprefix_4 << "|68.76.70.65'"; int result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 0); // Check if there is one entry in the readers database table with the stated persistence guid - command << "python3 check_guid.py '" << persistence_db << - "' 'readers' '00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.2'"; + command << "python3 check_guid.py '" << persistence_db + << "' 'readers' '00.00.00.00.00.00.00.00." << guidprefix_4 << "|0.0.0.2'"; result2 = system(command.str().c_str()); command.str(""); ASSERT_EQ((result2 >> 8), 1); diff --git a/test/blackbox/common/RTPSBlackboxTestsPools.cpp b/test/blackbox/common/RTPSBlackboxTestsPools.cpp index b7a501e07e7..5e4fd2520b0 100644 --- a/test/blackbox/common/RTPSBlackboxTestsPools.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsPools.cpp @@ -26,11 +26,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class RTPSCustomPools : public testing::TestWithParam { @@ -225,7 +227,7 @@ class PoolForTest : public IPayloadPool std::vector free_payloads_; }; -template +template void do_test( const std::string& topic_name, std::list& data, diff --git a/test/blackbox/common/RTPSBlackboxTestsReader.cpp b/test/blackbox/common/RTPSBlackboxTestsReader.cpp index fa721adc37d..0695956c544 100644 --- a/test/blackbox/common/RTPSBlackboxTestsReader.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsReader.cpp @@ -36,11 +36,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class RTPSReaderTests : public testing::TestWithParam { diff --git a/test/blackbox/common/RTPSBlackboxTestsVolatile.cpp b/test/blackbox/common/RTPSBlackboxTestsVolatile.cpp index aa31e76b3d4..63918400988 100644 --- a/test/blackbox/common/RTPSBlackboxTestsVolatile.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsVolatile.cpp @@ -25,11 +25,13 @@ using namespace eprosima::fastdds; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class Volatile : public testing::TestWithParam { diff --git a/test/blackbox/common/RTPSBlackboxTestsWriter.cpp b/test/blackbox/common/RTPSBlackboxTestsWriter.cpp index 50de3428bc7..c67cb7a7e25 100644 --- a/test/blackbox/common/RTPSBlackboxTestsWriter.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsWriter.cpp @@ -36,11 +36,13 @@ using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; +namespace { enum communication_type { TRANSPORT, INTRAPROCESS }; +} // namespace class RTPSWriterTests : public testing::TestWithParam { diff --git a/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp b/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp index 1c6c91391f0..9406068822f 100644 --- a/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp +++ b/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp @@ -96,17 +96,17 @@ class DataWriterHistory : public WriterHistory { if (resource_limited_qos_.max_samples <= 0) { - resource_limited_qos_.max_samples = std::numeric_limits::max(); + resource_limited_qos_.max_samples = -1; } if (resource_limited_qos_.max_instances <= 0) { - resource_limited_qos_.max_instances = std::numeric_limits::max(); + resource_limited_qos_.max_instances = -1; } if (resource_limited_qos_.max_samples_per_instance <= 0) { - resource_limited_qos_.max_samples_per_instance = std::numeric_limits::max(); + resource_limited_qos_.max_samples_per_instance = -1; } } diff --git a/test/mock/rtps/SharedSecretHandle/rtps/security/common/SharedSecretHandle.h b/test/mock/rtps/SharedSecretHandle/rtps/security/common/SharedSecretHandle.h new file mode 100644 index 00000000000..0c93faabe1f --- /dev/null +++ b/test/mock/rtps/SharedSecretHandle/rtps/security/common/SharedSecretHandle.h @@ -0,0 +1,176 @@ +// Copyright 2026 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file SharedSecretHandle.h (test mock) + * + * Drop-in replacement for the production SharedSecretHandle.h. The only + * difference is the SharedSecretHandle typedef: it instantiates HandleImpl + * with MockAuthenticationPlugin instead of PKIDH, so it matches the dynamic + * type of the SharedSecret-bearing handles created by the test (see + * test/mock/rtps/SecurityPluginFactory/rtps/security/MockAuthenticationPlugin.h). + * + * Without this substitution the production translation unit narrows to a + * different HandleImpl instantiation than the test creates; + * the two share layout but have distinct vtables, so the next virtual call + * (e.g. nil()) trips ubsan with a vptr/type mismatch. + */ +#ifndef _FASTDDS_RTPS_SECURITY_COMMON_SHAREDSECRETHANDLE_H_ +#define _FASTDDS_RTPS_SECURITY_COMMON_SHAREDSECRETHANDLE_H_ + +#include + +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { +namespace security { + +class SharedSecret +{ +public: + + class BinaryData + { + public: + + BinaryData() + { + } + + BinaryData( + const BinaryData& data) + : name_(data.name_) + , value_(data.value_) + { + } + + BinaryData( + BinaryData&& data) + : name_(std::move(data.name_)) + , value_(std::move(data.value_)) + { + } + + BinaryData( + const std::string& name, + const std::vector& value) + : name_(name) + , value_(value) + { + } + + BinaryData( + std::string&& name, + std::vector&& value) + : name_(std::move(name)) + , value_(std::move(value)) + { + } + + BinaryData& operator =( + const BinaryData& data) + { + name_ = data.name_; + value_ = data.value_; + return *this; + } + + BinaryData& operator =( + BinaryData&& data) + { + name_ = std::move(data.name_); + value_ = std::move(data.value_); + return *this; + } + + void name( + const std::string& name) + { + name_ = name; + } + + void name( + std::string&& name) + { + name_ = std::move(name); + } + + const std::string& name() const + { + return name_; + } + + std::string& name() + { + return name_; + } + + void value( + const std::vector& value) + { + value_ = value; + } + + void value( + std::vector&& value) + { + value_ = std::move(value); + } + + const std::vector& value() const + { + return value_; + } + + std::vector& value() + { + return value_; + } + + private: + + std::string name_; + + std::vector value_; + }; + + static const char* const class_id_; + + std::vector data_; +}; + +// Forward declaration is enough. The friend declaration inside HandleImpl +// only requires the elaborated name. +class MockAuthenticationPlugin; + +typedef HandleImpl SharedSecretHandle; + +class SharedSecretHelper +{ +public: + + static const std::vector* find_data_value( + const SecretHandle& sharedsecret, + const std::string& name); +}; + +} //namespace security +} //namespace rtps +} //namespace fastdds +} //namespace eprosima + +#endif // _FASTDDS_RTPS_SECURITY_COMMON_SHAREDSECRETHANDLE_H_ diff --git a/test/mock/rtps/TimedEvent/rtps/resources/TimedEvent.h b/test/mock/rtps/TimedEvent/rtps/resources/TimedEvent.h index 44f639a3bc7..5aa736f546d 100644 --- a/test/mock/rtps/TimedEvent/rtps/resources/TimedEvent.h +++ b/test/mock/rtps/TimedEvent/rtps/resources/TimedEvent.h @@ -38,6 +38,13 @@ class TimedEvent { } + TimedEvent( + ResourceEvent&, + std::function, + std::chrono::microseconds) + { + } + MOCK_METHOD0(restart_timer, void()); MOCK_METHOD1(restart_timer, void(const std::chrono::steady_clock::time_point& timeout)); MOCK_METHOD0(cancel_timer, void()); @@ -53,4 +60,3 @@ class TimedEvent } // namespace eprosima #endif // FASTDDS_RTPS_RESOURCES__TIMEDEVENT_H - diff --git a/test/performance/latency/LatencyTestPublisher.cpp b/test/performance/latency/LatencyTestPublisher.cpp index b108a879253..ff2d9db7d2b 100644 --- a/test/performance/latency/LatencyTestPublisher.cpp +++ b/test/performance/latency/LatencyTestPublisher.cpp @@ -925,8 +925,11 @@ void LatencyTestPublisher::analyze_times( stats.received_ = received_count_ - 1; // Because we are not counting the first one. stats.minimum_ = *min_element(times_.begin(), times_.end()); stats.maximum_ = *max_element(times_.begin(), times_.end()); - stats.mean_ = accumulate(times_.begin(), times_.end(), - std::chrono::duration(0)).count() / times_.size(); + if (times_.size() > 0) + { + stats.mean_ = accumulate(times_.begin(), times_.end(), + std::chrono::duration(0)).count() / times_.size(); + } double aux_stdev = 0; for (std::vector>::iterator tit = times_.begin(); tit != times_.end(); @@ -934,7 +937,10 @@ void LatencyTestPublisher::analyze_times( { aux_stdev += pow(((*tit).count() - stats.mean_), 2); } - aux_stdev = sqrt(aux_stdev / times_.size()); + if (times_.size() > 0) + { + aux_stdev = sqrt(aux_stdev / times_.size()); + } stats.stdev_ = aux_stdev; /* Percentiles */ diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 525a511b181..1b9510945d2 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -625,7 +625,8 @@ TEST(ParticipantTests, CreateDomainParticipantWithExtendedQosFromProfile) // Test create_participant_with_profile using the default profile DomainParticipant* default_participant = - DomainParticipantFactory::get_instance()->create_participant_with_profile("test_default_participant_profile"); + DomainParticipantFactory::get_instance()->create_participant_with_profile( + "test_default_participant_profile"); ASSERT_NE(default_participant, nullptr); ASSERT_EQ(default_participant->get_domain_id(), domain_id); //Keep the DID given to the method, not the one on the profile check_participant_extended_qos_from_profile(default_participant, "test_default_participant_profile"); @@ -998,27 +999,35 @@ TEST(ParticipantTests, ChangeDomainParticipantQos) } -class DomainParticipantTest : public DomainParticipant -{ -public: +namespace { + +using DomainParticipantImplPtr = DomainParticipantImpl * DomainParticipant::*; + +DomainParticipantImplPtr get_domain_participant_impl_ptr(); - const DomainParticipantImpl* get_impl() const +template +struct DomainParticipantImplAccessor +{ + friend DomainParticipantImplPtr get_domain_participant_impl_ptr() { - return impl_; + return P; } }; +template struct DomainParticipantImplAccessor<&DomainParticipant::impl_>; + +} // namespace + fastdds::rtps::RTPSParticipantAttributes get_rtps_attributes( const DomainParticipant* participant) { - const DomainParticipantTest* participant_test = static_cast(participant); - EXPECT_NE(nullptr, participant_test); - if (participant_test == nullptr) + EXPECT_NE(nullptr, participant); + if (participant == nullptr) { return {}; } - const DomainParticipantImpl* participant_impl = participant_test->get_impl(); + const DomainParticipantImpl* participant_impl = participant->*get_domain_participant_impl_ptr(); EXPECT_NE(nullptr, participant_impl); if (participant_impl == nullptr) { @@ -1088,8 +1097,9 @@ void set_server_qos( } void set_environment_variable( - const std::string environment_servers = "84.22.253.128:8888;;UDPv4:[localhost]:1234;[2a02:ec80:600:ed1a::3]:8783" - ) + const std::string environment_servers = + "84.22.253.128:8888;;UDPv4:[localhost]:1234;[2a02:ec80:600:ed1a::3]:8783" +) { #ifdef _WIN32 ASSERT_EQ(0, _putenv_s(rtps::DEFAULT_ROS2_MASTER_URI, environment_servers.c_str())); @@ -1100,7 +1110,7 @@ void set_environment_variable( void set_easy_mode_environment_variable( const std::string ip = "127.0.0.1" - ) +) { #ifdef _WIN32 ASSERT_EQ(0, _putenv_s(rtps::ROS2_EASY_MODE_URI, ip.c_str())); @@ -1404,7 +1414,8 @@ TEST(ParticipantTests, SimpleParticipantDynamicAdditionRemoteServers) // Modify environment file #ifndef __APPLE__ std::ofstream file(filename); - file << + file + << "{\"ROS_DISCOVERY_SERVER\": \"84.22.253.128:8888;192.168.1.133:64863;UDPv4:[localhost]:1234;[2a02:ec80:600:ed1a::3]:8783\"}"; file.close(); @@ -4433,7 +4444,8 @@ TEST(ParticipantTests, RegisterDynamicTypeToFactories) traits::ref_type type_descriptor = traits::make_shared(); type_descriptor->kind(TK_STRUCTURE); type_descriptor->name("mystruct"); - traits::ref_type builder {DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)}; + traits::ref_type builder {DynamicTypeBuilderFactory::get_instance()->create_type( + type_descriptor)}; traits::ref_type member_descriptor = traits::make_shared(); member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); member_descriptor->name("myuint"); diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index 1e797d8df37..82453c94cde 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -1963,28 +1963,44 @@ TEST(DataWriterTests, LoanNegativeTests) ASSERT_TRUE(DomainParticipantFactory::get_instance()->delete_participant(participant) == RETCODE_OK); } -class DataWriterTest : public DataWriter -{ -public: +namespace { + +// Accessor to DataWriterImpl from DataWriter +using DataWriterImplPtr = DataWriterImpl * DataWriter::*; - DataWriterImpl* get_impl() const +DataWriterImplPtr get_datawriter_impl_ptr(); + +template +struct DataWriterImplAccessor +{ + friend DataWriterImplPtr get_datawriter_impl_ptr() { - return impl_; + return P; } }; -class DataWriterImplTest : public DataWriterImpl -{ -public: +template struct DataWriterImplAccessor<&DataWriter::impl_>; + +// Accessor to DataWriterHistory unique ptr from DataWriterImpl +using DataWriterHistoryPtr = std::unique_ptr DataWriterImpl::*; + +DataWriterHistoryPtr get_datawriter_history_ptr(); - DataWriterHistory* get_history() +template +struct DataWriterHistoryAccessor +{ + friend DataWriterHistoryPtr get_datawriter_history_ptr() { - return history_.get(); + return P; } }; +template struct DataWriterHistoryAccessor<&DataWriterImpl::history_>; + +} // namespace + /** * This test checks instance wait_for_acknowledgements API */ @@ -2046,13 +2062,10 @@ TEST(DataWriterTests, InstanceWaitForAcknowledgement) #endif // NDEBUG // Access DataWriterHistory - DataWriterTest* instance_datawriter_test = static_cast(instance_datawriter); - ASSERT_NE(nullptr, instance_datawriter_test); - DataWriterImpl* datawriter_impl = instance_datawriter_test->get_impl(); + DataWriterImpl* datawriter_impl = instance_datawriter->*get_datawriter_impl_ptr(); ASSERT_NE(nullptr, datawriter_impl); - DataWriterImplTest* datawriter_impl_test = static_cast(datawriter_impl); - ASSERT_NE(nullptr, datawriter_impl_test); - auto history = datawriter_impl_test->get_history(); + DataWriterHistory* history = (datawriter_impl->*get_datawriter_history_ptr()).get(); + ASSERT_NE(nullptr, history); // 5. Calling wait_for_acknowledgments in a keyed topic with HANDLE_NIL returns // RETCODE_OK diff --git a/test/unittest/dds/status/ListenerTests.cpp b/test/unittest/dds/status/ListenerTests.cpp index 03636be1f06..cd48d3f21e5 100644 --- a/test/unittest/dds/status/ListenerTests.cpp +++ b/test/unittest/dds/status/ListenerTests.cpp @@ -36,6 +36,10 @@ #include #include +#include +#include +#include + using ::testing::StrictMock; using ::testing::NiceMock; @@ -109,22 +113,14 @@ class RTPSReaderMock : public eprosima::fastdds::rtps::BaseReader }; -class RTPSWriterMock : public eprosima::fastdds::rtps::RTPSWriter +class RTPSWriterMock : public eprosima::fastdds::rtps::BaseWriter { public: - RTPSWriterMock() - { - } + RTPSWriterMock() = default; virtual ~RTPSWriterMock() = default; - virtual bool matched_reader_add( - const eprosima::fastdds::rtps::SubscriptionBuiltinTopicData&) - { - return true; - } - virtual bool matched_reader_remove( const eprosima::fastdds::rtps::GUID_t&) { @@ -561,6 +557,10 @@ class UserListeners : public ::testing::Test RTPSDomain::writer_ = &writer_mock_; RTPSDomain::reader_ = &reader_mock_; + // BaseWriter::get_participant_impl() must return non-null; some code + // paths (e.g. get_publication_builtin_topic_data) assert on it. + writer_mock_.mp_RTPSParticipant = &participant_impl_mock_; + // Create the DDS entities with the user listeners participant_ = DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT, @@ -611,6 +611,7 @@ class UserListeners : public ::testing::Test NiceMock participant_mock_; NiceMock writer_mock_; NiceMock reader_mock_; + eprosima::fastdds::rtps::RTPSParticipantImpl participant_impl_mock_; // User listeners are strick, we want to track unexpected calls StrictMock participant_listener_; diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 0c471943e94..49044355fdd 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -111,6 +111,8 @@ set(TCPTransportInterface_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp ) if(TLS_FOUND) set(TCPTransportInterface_SOURCE diff --git a/test/unittest/rtps/writer/CMakeLists.txt b/test/unittest/rtps/writer/CMakeLists.txt index 73902ee2a6a..7736b29b99e 100644 --- a/test/unittest/rtps/writer/CMakeLists.txt +++ b/test/unittest/rtps/writer/CMakeLists.txt @@ -56,6 +56,8 @@ target_include_directories(ReaderProxyTests PRIVATE ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderLocator ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSGapBuilder ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSMessageGroup + ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl + ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/TimedEvent ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include diff --git a/test/unittest/security/authentication/CMakeLists.txt b/test/unittest/security/authentication/CMakeLists.txt index 3fd0381acf7..ee72147ae00 100644 --- a/test/unittest/security/authentication/CMakeLists.txt +++ b/test/unittest/security/authentication/CMakeLists.txt @@ -33,6 +33,7 @@ set(COMMON_SOURCES_AUTH_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Token.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/exceptions/Exception.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/CDRMessage.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp @@ -70,6 +71,8 @@ target_compile_definitions(BuiltinPKIDH PRIVATE target_include_directories(BuiltinPKIDH PRIVATE ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory/ + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData/ + ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterProxyData/ ${OPENSSL_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantMockTests.cpp b/test/unittest/statistics/dds/StatisticsDomainParticipantMockTests.cpp index 1ac206a440e..3e0eb4204f5 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantMockTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantMockTests.cpp @@ -48,33 +48,62 @@ class StatisticsDomainParticipantMockTests : public ::testing::Test }; -class DomainParticipantImplTest : public DomainParticipantImpl -{ -public: +namespace { + +// Accessor to DomainParticipantImpl* from DomainParticipant +using DomainParticipantImplPtr = + eprosima::fastdds::dds::DomainParticipantImpl * eprosima::fastdds::dds::DomainParticipant::*; - eprosima::fastdds::dds::Publisher* get_builtin_publisher() const +DomainParticipantImplPtr get_domain_participant_impl_ptr(); + +template +struct DomainParticipantImplAccessor +{ + friend DomainParticipantImplPtr get_domain_participant_impl_ptr() { - return builtin_publisher_; + return P; } - PublisherImpl* get_builtin_publisher_impl() const +}; + +template struct DomainParticipantImplAccessor<&eprosima::fastdds::dds::DomainParticipant::impl_>; + +// Accessor to builtin_publisher_ from statistics DomainParticipantImpl +using BuiltinPublisherPtr = eprosima::fastdds::dds::Publisher * DomainParticipantImpl::*; + +BuiltinPublisherPtr get_builtin_publisher_ptr(); + +template +struct BuiltinPublisherAccessor +{ + friend BuiltinPublisherPtr get_builtin_publisher_ptr() { - return builtin_publisher_impl_; + return P; } }; -class DomainParticipantTest : public eprosima::fastdds::dds::DomainParticipant -{ -public: +template struct BuiltinPublisherAccessor<&DomainParticipantImpl::builtin_publisher_>; + +// Accessor to builtin_publisher_impl_ from statistics DomainParticipantImpl +using BuiltinPublisherImplPtr = PublisherImpl * DomainParticipantImpl::*; - eprosima::fastdds::dds::DomainParticipantImpl* get_impl() const +BuiltinPublisherImplPtr get_builtin_publisher_impl_ptr(); + +template +struct BuiltinPublisherImplAccessor +{ + friend BuiltinPublisherImplPtr get_builtin_publisher_impl_ptr() { - return impl_; + return P; } }; +template struct BuiltinPublisherImplAccessor<&DomainParticipantImpl::builtin_publisher_impl_>; + +} // namespace + /** * This test checks that enable_statistics_datawriter fails returning eprosima::fastdds::dds::RETCODE_ERROR when create_datawriter fails * returning a nullptr. @@ -106,12 +135,10 @@ TEST_F(StatisticsDomainParticipantMockTests, EnableStatisticsDataWriterFailureCr ASSERT_NE(statistics_participant, nullptr); // 2. Mock create_datawriter - DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); - DomainParticipantImplTest* statistics_participant_impl_test = static_cast( - participant_test->get_impl()); + DomainParticipantImpl* statistics_participant_impl_test = static_cast( + participant->*get_domain_participant_impl_ptr()); ASSERT_NE(nullptr, statistics_participant_impl_test); - PublisherImpl* builtin_pub_impl = statistics_participant_impl_test->get_builtin_publisher_impl(); + PublisherImpl* builtin_pub_impl = statistics_participant_impl_test->*get_builtin_publisher_impl_ptr(); EXPECT_CALL(*builtin_pub_impl, create_datawriter_mock()).WillOnce(testing::Return(true)); // 3. enable_statistics_datawriter @@ -155,14 +182,12 @@ TEST_F(StatisticsDomainParticipantMockTests, DisableStatisticsDataWriterFailureD ASSERT_NE(statistics_participant, nullptr); // 2. Mock delete_datawriter - DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); - DomainParticipantImplTest* statistics_participant_impl_test = static_cast( - participant_test->get_impl()); + DomainParticipantImpl* statistics_participant_impl_test = static_cast( + participant->*get_domain_participant_impl_ptr()); ASSERT_NE(nullptr, statistics_participant_impl_test); - eprosima::fastdds::dds::Publisher* builtin_pub = statistics_participant_impl_test->get_builtin_publisher(); + eprosima::fastdds::dds::Publisher* builtin_pub = statistics_participant_impl_test->*get_builtin_publisher_ptr(); ASSERT_NE(nullptr, builtin_pub); - PublisherImpl* builtin_pub_impl = statistics_participant_impl_test->get_builtin_publisher_impl(); + PublisherImpl* builtin_pub_impl = statistics_participant_impl_test->*get_builtin_publisher_impl_ptr(); ASSERT_NE(nullptr, builtin_pub_impl); EXPECT_CALL(*builtin_pub, delete_datawriter_mock()).WillOnce(testing::Return(true)); EXPECT_CALL(*statistics_participant_impl_test, delete_topic_mock()).WillOnce(testing::Return(false)); @@ -211,14 +236,12 @@ TEST_F(StatisticsDomainParticipantMockTests, DisableStatisticsDataWriterFailureD ASSERT_NE(statistics_participant, nullptr); // 2. Mock delete_topic - DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); - DomainParticipantImplTest* statistics_participant_impl_test = static_cast( - participant_test->get_impl()); + DomainParticipantImpl* statistics_participant_impl_test = static_cast( + participant->*get_domain_participant_impl_ptr()); ASSERT_NE(nullptr, statistics_participant_impl_test); - eprosima::fastdds::dds::Publisher* builtin_pub = statistics_participant_impl_test->get_builtin_publisher(); + eprosima::fastdds::dds::Publisher* builtin_pub = statistics_participant_impl_test->*get_builtin_publisher_ptr(); ASSERT_NE(nullptr, builtin_pub); - PublisherImpl* builtin_pub_impl = statistics_participant_impl_test->get_builtin_publisher_impl(); + PublisherImpl* builtin_pub_impl = statistics_participant_impl_test->*get_builtin_publisher_impl_ptr(); ASSERT_NE(nullptr, builtin_pub_impl); EXPECT_CALL(*statistics_participant_impl_test, delete_topic_mock()).WillOnce(testing::Return(true)); EXPECT_CALL(*builtin_pub, delete_datawriter_mock()).WillOnce(testing::Return(false)); diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp index 0a31919979d..7d66d8f5426 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp @@ -119,40 +119,64 @@ class StatisticsDomainParticipantStatusQueryableTests : public ::testing::Test }; -class DomainParticipantImplTest : public DomainParticipantImpl -{ -public: +namespace { - eprosima::fastdds::dds::Publisher* get_builtin_publisher() const - { - return builtin_publisher_; - } +// Accessor to DomainParticipantImpl* from DomainParticipant +using DomainParticipantImplPtr = + eprosima::fastdds::dds::DomainParticipantImpl * eprosima::fastdds::dds::DomainParticipant::*; + +DomainParticipantImplPtr get_domain_participant_impl_ptr(); - PublisherImpl* get_builtin_publisher_impl() const +template +struct DomainParticipantImplAccessor +{ + friend DomainParticipantImplPtr get_domain_participant_impl_ptr() { - return builtin_publisher_impl_; + return P; } - bool monitoring_status( - fastdds::rtps::GUID_t guid, - statistics::MonitorServiceData& status) +}; + +template struct DomainParticipantImplAccessor<&eprosima::fastdds::dds::DomainParticipant::impl_>; + +// Accessor to builtin_publisher_impl_ from statistics DomainParticipantImpl +using BuiltinPublisherImplPtr = PublisherImpl * DomainParticipantImpl::*; + +BuiltinPublisherImplPtr get_builtin_publisher_impl_ptr(); + +template +struct BuiltinPublisherImplAccessor +{ + friend BuiltinPublisherImplPtr get_builtin_publisher_impl_ptr() { - return get_monitoring_status(guid, status); + return P; } }; -class DomainParticipantTest : public eprosima::fastdds::dds::DomainParticipant -{ -public: +template struct BuiltinPublisherImplAccessor<&DomainParticipantImpl::builtin_publisher_impl_>; - eprosima::fastdds::dds::DomainParticipantImpl* get_impl() const +// Accessor to protected get_monitoring_status() member function +using GetMonitoringStatusFn = bool (DomainParticipantImpl::*)( + const fastdds::rtps::GUID_t&, + statistics::MonitorServiceData&); + +GetMonitoringStatusFn get_monitoring_status_fn(); + +template +struct GetMonitoringStatusAccessor +{ + friend GetMonitoringStatusFn get_monitoring_status_fn() { - return impl_; + return F; } }; +template struct GetMonitoringStatusAccessor<&DomainParticipantImpl::get_monitoring_status>; + +} // namespace + TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_incompatible_qos) { #ifdef FASTDDS_STATISTICS @@ -165,18 +189,15 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_in DomainParticipant* statistics_participant = DomainParticipant::narrow(participant); ASSERT_NE(statistics_participant, nullptr); - DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); - DomainParticipantImplTest* statistics_participant_impl_test = static_cast( - participant_test->get_impl()); - + DomainParticipantImpl* statistics_participant_impl_test = static_cast( + participant->*get_domain_participant_impl_ptr()); ASSERT_NE(nullptr, statistics_participant_impl_test); fastdds::dds::TypeSupport type(new TopicDataTypeMock()); type.register_type(statistics_participant); - auto publisher = participant_test->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); - auto topic = participant_test->create_topic(TEST_TOPIC, "footype", fastdds::dds::TOPIC_QOS_DEFAULT); + auto publisher = participant->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); + auto topic = participant->create_topic(TEST_TOPIC, "footype", fastdds::dds::TOPIC_QOS_DEFAULT); //! Create DataWriters EXPECT_CALL(*publisher, create_datawriter_mock()).WillRepeatedly(testing::Return(false)); @@ -195,8 +216,8 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_in incomp_qos_status_dw_1.incompatible_qos_status(IncompatibleQoSStatus_s{}); MonitorServiceData incomp_qos_status_dw_2; incomp_qos_status_dw_2.incompatible_qos_status(IncompatibleQoSStatus_s{}); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), incomp_qos_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), incomp_qos_status_dw_2)); + ASSERT_TRUE((statistics_participant_impl_test->*get_monitoring_status_fn())(dw1->guid(), incomp_qos_status_dw_1)); + ASSERT_TRUE((statistics_participant_impl_test->*get_monitoring_status_fn())(dw2->guid(), incomp_qos_status_dw_2)); //! Expect incompatibilities ASSERT_EQ(1u, incomp_qos_status_dw_1.incompatible_qos_status().total_count()); @@ -228,18 +249,15 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_li DomainParticipant* statistics_participant = DomainParticipant::narrow(participant); ASSERT_NE(statistics_participant, nullptr); - DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); - DomainParticipantImplTest* statistics_participant_impl_test = static_cast( - participant_test->get_impl()); - + DomainParticipantImpl* statistics_participant_impl_test = static_cast( + participant->*get_domain_participant_impl_ptr()); ASSERT_NE(nullptr, statistics_participant_impl_test); fastdds::dds::TypeSupport type(new TopicDataTypeMock()); type.register_type(statistics_participant); - auto publisher = participant_test->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); - auto topic = participant_test->create_topic(TEST_TOPIC, "footype", fastdds::dds::TOPIC_QOS_DEFAULT); + auto publisher = participant->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); + auto topic = participant->create_topic(TEST_TOPIC, "footype", fastdds::dds::TOPIC_QOS_DEFAULT); //! Create DataWriters EXPECT_CALL(*publisher, create_datawriter_mock()).WillRepeatedly(testing::Return(false)); @@ -258,8 +276,8 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_li liv_lost_status_dw_1.liveliness_lost_status(LivelinessLostStatus_s{}); MonitorServiceData liv_lost_status_dw_2; liv_lost_status_dw_2.liveliness_lost_status(LivelinessLostStatus_s{}); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), liv_lost_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), liv_lost_status_dw_2)); + ASSERT_TRUE((statistics_participant_impl_test->*get_monitoring_status_fn())(dw1->guid(), liv_lost_status_dw_1)); + ASSERT_TRUE((statistics_participant_impl_test->*get_monitoring_status_fn())(dw2->guid(), liv_lost_status_dw_2)); //! Expect incompatibilities ASSERT_EQ(1u, liv_lost_status_dw_1.liveliness_lost_status().total_count()); @@ -287,18 +305,15 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_de DomainParticipant* statistics_participant = DomainParticipant::narrow(participant); ASSERT_NE(statistics_participant, nullptr); - DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); - DomainParticipantImplTest* statistics_participant_impl_test = static_cast( - participant_test->get_impl()); - + DomainParticipantImpl* statistics_participant_impl_test = static_cast( + participant->*get_domain_participant_impl_ptr()); ASSERT_NE(nullptr, statistics_participant_impl_test); fastdds::dds::TypeSupport type(new TopicDataTypeMock()); type.register_type(statistics_participant); - auto publisher = participant_test->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); - auto topic = participant_test->create_topic(TEST_TOPIC, "footype", fastdds::dds::TOPIC_QOS_DEFAULT); + auto publisher = participant->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); + auto topic = participant->create_topic(TEST_TOPIC, "footype", fastdds::dds::TOPIC_QOS_DEFAULT); //! Create DataWriters EXPECT_CALL(*publisher, create_datawriter_mock()).WillRepeatedly(testing::Return(false)); @@ -317,8 +332,10 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_de deadline_missed_status_dw_1.deadline_missed_status(DeadlineMissedStatus_s{}); MonitorServiceData deadline_missed_status_dw_2; deadline_missed_status_dw_2.deadline_missed_status(DeadlineMissedStatus_s{}); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), deadline_missed_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), deadline_missed_status_dw_2)); + ASSERT_TRUE((statistics_participant_impl_test->*get_monitoring_status_fn())(dw1->guid(), + deadline_missed_status_dw_1)); + ASSERT_TRUE((statistics_participant_impl_test->*get_monitoring_status_fn())(dw2->guid(), + deadline_missed_status_dw_2)); //! Expect incompatibilities ASSERT_EQ(1u, deadline_missed_status_dw_1.deadline_missed_status().total_count()); diff --git a/test/unittest/statistics/dds/StatisticsQosTests.cpp b/test/unittest/statistics/dds/StatisticsQosTests.cpp index 6cb53a38351..a5f4f187017 100644 --- a/test/unittest/statistics/dds/StatisticsQosTests.cpp +++ b/test/unittest/statistics/dds/StatisticsQosTests.cpp @@ -39,33 +39,53 @@ namespace fastdds { namespace statistics { namespace dds { -class StatisticsFromXMLProfileTests : public ::testing::Test -{ -public: - #ifdef FASTDDS_STATISTICS - class TestDomainParticipant : public eprosima::fastdds::statistics::dds::DomainParticipant +namespace { + +// Accessor to DomainParticipantImpl* from DomainParticipant +using DomainParticipantImplPtr = efd::DomainParticipantImpl * efd::DomainParticipant::*; + +DomainParticipantImplPtr get_domain_participant_impl_ptr(); + +template +struct DomainParticipantImplAccessor +{ + friend DomainParticipantImplPtr get_domain_participant_impl_ptr() { - public: + return P; + } + +}; + +template struct DomainParticipantImplAccessor<&efd::DomainParticipant::impl_>; - DomainParticipantImpl* get_domain_participant_impl() - { - return static_cast(impl_); - } +// Accessor to builtin_publisher_ from statistics DomainParticipantImpl +using BuiltinPublisherPtr = + efd::Publisher * eprosima::fastdds::statistics::dds::DomainParticipantImpl::*; - }; +BuiltinPublisherPtr get_builtin_publisher_ptr(); - class TestDomainParticipantImpl : public eprosima::fastdds::statistics::dds::DomainParticipantImpl +template +struct BuiltinPublisherAccessor +{ + friend BuiltinPublisherPtr get_builtin_publisher_ptr() { - public: + return P; + } + +}; - efd::Publisher* get_publisher() - { - return builtin_publisher_; - } +template struct BuiltinPublisherAccessor< + & eprosima::fastdds::statistics::dds::DomainParticipantImpl::builtin_publisher_>; - }; +} // namespace +#endif // ifdef FASTDDS_STATISTICS +class StatisticsFromXMLProfileTests : public ::testing::Test +{ +public: + +#ifdef FASTDDS_STATISTICS eprosima::fastdds::statistics::dds::DomainParticipant* statistics_participant = nullptr; eprosima::fastdds::dds::Publisher* statistics_publisher = nullptr; @@ -89,24 +109,18 @@ class StatisticsFromXMLProfileTests : public ::testing::Test eprosima::fastdds::statistics::dds::DomainParticipant::narrow(participant); ASSERT_NE(_statistics_participant, nullptr); - // Static conversion to child class TestDomainParticipant - TestDomainParticipant* test_statistics_participant = - static_cast(_statistics_participant); - ASSERT_NE(test_statistics_participant, nullptr); + // Get DomainParticipantImpl via accessor (no UB downcast) + efd::DomainParticipantImpl* base_impl = + _statistics_participant->*get_domain_participant_impl_ptr(); + ASSERT_NE(base_impl, nullptr); - // Get DomainParticipantImpl eprosima::fastdds::statistics::dds::DomainParticipantImpl* domain_statistics_participant_impl = - test_statistics_participant->get_domain_participant_impl(); + static_cast(base_impl); ASSERT_NE(domain_statistics_participant_impl, nullptr); - // Static conversion to child class TestDomainParticipantImpl - TestDomainParticipantImpl* test_statistics_domain_participant_impl = - static_cast(domain_statistics_participant_impl); - ASSERT_NE(test_statistics_domain_participant_impl, nullptr); - - // Get Publisher + // Get Publisher via accessor statistics_pub = - test_statistics_domain_participant_impl->get_publisher(); + domain_statistics_participant_impl->*get_builtin_publisher_ptr(); ASSERT_NE(statistics_pub, nullptr); } diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index c10f92dd5fc..b565d629bb0 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/CMakeLists.txt @@ -52,6 +52,8 @@ set(TCPTransportInterface_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp ) if(TLS_FOUND) set(TCPTransportInterface_SOURCE diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index adfaa7ac091..1337c31df57 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -57,21 +57,28 @@ namespace fastdds { namespace statistics { namespace rtps { -class RTPSParticipantMock : public fastdds::rtps::RTPSParticipant -{ +namespace { -public: +// Accessor to RTPSParticipantImpl* from RTPSParticipant +using RTPSParticipantImplPtr = fastdds::rtps::RTPSParticipantImpl * fastdds::rtps::RTPSParticipant::*; - fastdds::rtps::RTPSParticipantImpl* get_impl() +RTPSParticipantImplPtr get_rtps_part_impl(); + +template +struct RTPSParticipantImplAccessor +{ + friend RTPSParticipantImplPtr get_rtps_part_impl() { - return mp_impl; + return P; } -private: - - ~RTPSParticipantMock(); }; +template struct RTPSParticipantImplAccessor<&fastdds::rtps::RTPSParticipant::mp_impl>; + +} // namespace + + struct MockListener : IListener { MockListener() @@ -1394,8 +1401,7 @@ TEST_F(RTPSStatisticsTests, iconnections_queryable_get_entity_connections) // match writer and reader on a dummy topic match_endpoints(false, "string", "test_topic_name"); - auto participant_mock = static_cast(participant_); - auto part_impl = participant_mock->get_impl(); + eprosima::fastdds::rtps::RTPSParticipantImpl* part_impl = participant_->*get_rtps_part_impl(); part_impl->get_entity_connections(reader_->getGuid(), conns_reader); part_impl->get_entity_connections(writer_->getGuid(), conns_writer); diff --git a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp index b03d416cc48..c2f954def9c 100644 --- a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp +++ b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp @@ -86,7 +86,7 @@ class MonitorService void set_writer( fastdds::rtps::RTPSWriter* writer) { - status_writer_ = static_cast(writer); + status_writer_ = writer; } ~MonitorService(); @@ -276,7 +276,7 @@ class MonitorService MonitorServiceListener* listener_; - fastdds::rtps::StatefulWriter* status_writer_; + fastdds::rtps::RTPSWriter* status_writer_; std::unique_ptr status_writer_history_; @@ -302,4 +302,3 @@ class MonitorService } // namespace eprosima #endif // _STATISTICS_RTPS_MONITOR_SERVICE_MONITORSERVICE_HPP_ - diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index 05ade9d422b..84013fb192d 100644 --- a/test/unittest/transport/CMakeLists.txt +++ b/test/unittest/transport/CMakeLists.txt @@ -56,6 +56,8 @@ set(TCPTransportInterface_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp ) if(TLS_FOUND) set(TCPTransportInterface_SOURCE @@ -251,6 +253,7 @@ set(TCPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp diff --git a/test/unittest/transport/TCPv4Tests.cpp b/test/unittest/transport/TCPv4Tests.cpp index fcb4b1a01a2..b441e7d0e7d 100644 --- a/test/unittest/transport/TCPv4Tests.cpp +++ b/test/unittest/transport/TCPv4Tests.cpp @@ -584,8 +584,8 @@ TEST_F(TCPv4Tests, send_and_receive_between_allowed_interfaces_ports_by_name) std::regex filter("RTCP(?!_SEQ)"); eprosima::fastdds::dds::Log::SetCategoryFilter(filter); TCPv4TransportDescriptor recvDescriptor; - std::cout << "Adding to whitelist: " << interfaces[0].dev << " " << interfaces[0].name << " " << - interfaces[0].locator << std::endl; + std::cout << "Adding to whitelist: " << interfaces[0].dev << " " << interfaces[0].name << " " + << interfaces[0].locator << std::endl; recvDescriptor.interfaceWhiteList.emplace_back(interfaces[0].dev); recvDescriptor.add_listener_port(g_default_port); @@ -1558,7 +1558,7 @@ TEST_F(TCPv4Tests, secure_non_blocking_send) auto sender_unbound_channel_resources = senderTransportUnderTest.get_unbound_channel_resources(); ASSERT_TRUE(sender_unbound_channel_resources.size() == 1u); auto sender_channel_resource = - std::static_pointer_cast( + std::static_pointer_cast( sender_unbound_channel_resources[0]); // Prepare the message