From a417f5df182f7961809779b8939521141819c5de Mon Sep 17 00:00:00 2001 From: eduponz Date: Mon, 10 Jun 2024 11:38:12 +0200 Subject: [PATCH 1/3] Refs #21165: Add regression test Signed-off-by: eduponz --- test/unittest/rtps/discovery/EdpTests.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unittest/rtps/discovery/EdpTests.cpp b/test/unittest/rtps/discovery/EdpTests.cpp index 4d268628697..1b982e3d78f 100644 --- a/test/unittest/rtps/discovery/EdpTests.cpp +++ b/test/unittest/rtps/discovery/EdpTests.cpp @@ -481,6 +481,27 @@ TEST_F(EdpTests, CheckDataRepresentationCompatibility) } } +TEST(MatchingFailureMask, matching_failure_mask_overflow) +{ + EDP::MatchingFailureMask mask; + + mask.set(EDP::MatchingFailureMask::different_topic); + ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::different_topic)); + + mask.set(EDP::MatchingFailureMask::inconsistent_topic); + ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::inconsistent_topic)); + + mask.set(EDP::MatchingFailureMask::incompatible_qos); + ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::incompatible_qos)); + + mask.set(EDP::MatchingFailureMask::partitions); + ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::partitions)); + + mask.set(EDP::MatchingFailureMask::different_typeinfo); + ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::different_typeinfo)); +} + + } // namespace rtps } // namespace fastrtps } // namespace eprosima From c3c987b37ded7820f3ee8b94b43fe100622a9f7d Mon Sep 17 00:00:00 2001 From: eduponz Date: Mon, 10 Jun 2024 11:41:07 +0200 Subject: [PATCH 2/3] Refs #21165: Init MatchingFailureMask constants as normal uints Signed-off-by: eduponz --- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index e105c64d5d8..04931a9c5e0 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -78,19 +78,19 @@ class EDP public: //! Bit index for matching failing due to different topic - static const uint32_t different_topic = (0x00000001 << 0u); + static const uint32_t different_topic = 0u; //! Bit index for matching failing due to inconsistent topic (same topic name but different characteristics) - static const uint32_t inconsistent_topic = (0x00000001 << 1u); + static const uint32_t inconsistent_topic = 1u; //! Bit index for matching failing due to incompatible QoS - static const uint32_t incompatible_qos = (0x00000001 << 2u); + static const uint32_t incompatible_qos = 2u; //! Bit index for matching failing due to inconsistent partitions - static const uint32_t partitions = (0x00000001 << 3u); + static const uint32_t partitions = 3u; //! Bit index for matching failing due to incompatible TypeInformation - static const uint32_t different_typeinfo = (0x00000001 << 4u); + static const uint32_t different_typeinfo = 4u; }; /** From 3ecaba01ff62e6046df7ec2184dc3510b91e8e1b Mon Sep 17 00:00:00 2001 From: eduponz Date: Mon, 10 Jun 2024 11:59:41 +0200 Subject: [PATCH 3/3] Refs #21165: Apply Ricardo's suggestions Signed-off-by: eduponz --- test/unittest/rtps/discovery/EdpTests.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unittest/rtps/discovery/EdpTests.cpp b/test/unittest/rtps/discovery/EdpTests.cpp index 1b982e3d78f..b63dbe25fcc 100644 --- a/test/unittest/rtps/discovery/EdpTests.cpp +++ b/test/unittest/rtps/discovery/EdpTests.cpp @@ -486,19 +486,19 @@ TEST(MatchingFailureMask, matching_failure_mask_overflow) EDP::MatchingFailureMask mask; mask.set(EDP::MatchingFailureMask::different_topic); - ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::different_topic)); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::different_topic)); mask.set(EDP::MatchingFailureMask::inconsistent_topic); - ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::inconsistent_topic)); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::inconsistent_topic)); mask.set(EDP::MatchingFailureMask::incompatible_qos); - ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::incompatible_qos)); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::incompatible_qos)); mask.set(EDP::MatchingFailureMask::partitions); - ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::partitions)); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::partitions)); mask.set(EDP::MatchingFailureMask::different_typeinfo); - ASSERT_TRUE(mask.test(EDP::MatchingFailureMask::different_typeinfo)); + EXPECT_TRUE(mask.test(EDP::MatchingFailureMask::different_typeinfo)); }