From 66528f6b070ad5d39d9b20e3c27929dfac8c13b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Fri, 16 Jul 2021 08:06:11 +0200 Subject: [PATCH 1/7] Refs #12129. Regression test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../dds/subscriber/DataReaderTests.cpp | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 893417d833c..3750cbf8e40 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -49,11 +49,11 @@ #include #include -#include "./FooBoundedType.hpp" -#include "./FooBoundedTypeSupport.hpp" +#include "FooBoundedType.hpp" +#include "FooBoundedTypeSupport.hpp" -#include "./FooType.hpp" -#include "./FooTypeSupport.hpp" +#include "FooType.hpp" +#include "FooTypeSupport.hpp" #include "../../logging/mock/MockConsumer.h" @@ -1600,6 +1600,46 @@ TEST_F(DataReaderTests, Deserialization_errors) check_sample_values(data_seq, "0123456789"); EXPECT_EQ(ok_code, data_reader_->return_loan(data_seq, info_seq)); } + + { + FooSeq data_seq; + SampleInfoSeq info_seq; + + // Reader should have 10 samples with the following states (R = read, N = not-read, / = removed from history) + // {N, N, N, N, N, N, N, N, N, N} + + // This should return samples 0 to 9 + EXPECT_EQ(ok_code, data_reader_->take(data_seq, info_seq, num_samples, READ_SAMPLE_STATE)); + check_collection(data_seq, false, num_samples, num_samples); + check_sample_values(data_seq, "0123456789"); + EXPECT_EQ(ok_code, data_reader_->return_loan(data_seq, info_seq)); + } + } + + // Check deserialization errors for read_next_sample and take_next_sample. + // Regression test for #12129 + { + // Send two samples + for (char i = 0; i < 2; ++i) + { + data.message()[0] = 1; + EXPECT_EQ(ok_code, data_writer_->write(&data, handle_ok_)); + } + + // There are unread samples, so wait_for_unread should be ok + EXPECT_TRUE(data_reader_->wait_for_unread_message(time_to_wait)); + + { + FooType data; + SampleInfo info; + EXPECT_EQ(no_data_code, data_reader_->take_next_sample(&data, &info)); + } + + { + FooType data; + SampleInfo info; + EXPECT_EQ(no_data_code, data_reader_->read_next_sample(&data, &info)); + } } } @@ -2007,8 +2047,6 @@ TEST_F(DataReaderTests, read_samples_with_future_changes) ASSERT_EQ(publisher_->delete_datawriter(data_writer2), ReturnCode_t::RETCODE_OK); } - - } // namespace dds } // namespace fastdds } // namespace eprosima From 77c91d28537594b2cb9b73f7adf3ae3939af0fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 13 Jul 2021 15:47:56 +0200 Subject: [PATCH 2/7] Refs #11831. Fix error on read_take command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../DataReaderImpl/ReadTakeCommand.hpp | 3 +- test/blackbox/types/Data1mbType.cpp | 52 ++++++++++----- test/blackbox/types/Data64kbType.cpp | 52 ++++++++++----- test/blackbox/types/HelloWorldType.cpp | 63 +++++++++++------- test/blackbox/types/StringType.cpp | 64 ++++++++++++------- 5 files changed, 153 insertions(+), 81 deletions(-) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp index d7ca53d4d25..b59e6ca4496 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp @@ -274,7 +274,6 @@ struct ReadTakeCommand bool& deserialization_error) { // Mark that some data is available - return_value_ = ReturnCode_t::RETCODE_OK; bool ret_val = false; deserialization_error = false; @@ -297,6 +296,8 @@ struct ReadTakeCommand deserialization_error = true; return false; } + + return_value_ = ReturnCode_t::RETCODE_OK; } ++current_slot_; diff --git a/test/blackbox/types/Data1mbType.cpp b/test/blackbox/types/Data1mbType.cpp index 6500a6b5a4b..5bd94019223 100644 --- a/test/blackbox/types/Data1mbType.cpp +++ b/test/blackbox/types/Data1mbType.cpp @@ -48,31 +48,49 @@ bool Data1mbType::serialize( void* data, SerializedPayload_t* payload) { + bool ret_value = false; Data1mb* p_type = (Data1mb*) data; - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - p_type->serialize(ser); // Serialize the object: - payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - return true; + + try + { + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + p_type->serialize(ser); // Serialize the object: + payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } bool Data1mbType::deserialize( SerializedPayload_t* payload, void* data) { + bool ret_value = false; Data1mb* p_type = (Data1mb*) data; //Convert DATA to pointer of your type - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - p_type->deserialize(deser);//Deserialize the object: - return true; + + try + { + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + p_type->deserialize(deser);//Deserialize the object: + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } void* Data1mbType::createData() diff --git a/test/blackbox/types/Data64kbType.cpp b/test/blackbox/types/Data64kbType.cpp index a28e09b3190..9d86cd0e3d3 100644 --- a/test/blackbox/types/Data64kbType.cpp +++ b/test/blackbox/types/Data64kbType.cpp @@ -48,31 +48,49 @@ bool Data64kbType::serialize( void* data, SerializedPayload_t* payload) { + bool ret_value = false; Data64kb* p_type = (Data64kb*) data; - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - p_type->serialize(ser); // Serialize the object: - payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - return true; + + try + { + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + p_type->serialize(ser); // Serialize the object: + payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } bool Data64kbType::deserialize( SerializedPayload_t* payload, void* data) { + bool ret_value = false; Data64kb* p_type = (Data64kb*) data; //Convert DATA to pointer of your type - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - p_type->deserialize(deser); //Deserialize the object: - return true; + + try + { + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + p_type->deserialize(deser); //Deserialize the object: + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } std::function Data64kbType::getSerializedSizeProvider( diff --git a/test/blackbox/types/HelloWorldType.cpp b/test/blackbox/types/HelloWorldType.cpp index 2f266033f3f..1b3f8a11506 100644 --- a/test/blackbox/types/HelloWorldType.cpp +++ b/test/blackbox/types/HelloWorldType.cpp @@ -41,37 +41,54 @@ bool HelloWorldType::serialize( void* data, SerializedPayload_t* payload) { + bool ret_value = false; HelloWorld* hw = (HelloWorld*) data; - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - //serialize the object: - hw->serialize(ser); - payload->length = (uint32_t)ser.getSerializedDataLength(); - return true; + + try + { + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + //serialize the object: + hw->serialize(ser); + payload->length = (uint32_t)ser.getSerializedDataLength(); + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } bool HelloWorldType::deserialize( SerializedPayload_t* payload, void* data) { + bool ret_value = false; HelloWorld* hw = (HelloWorld*) data; - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); - // Object that serializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - //serialize the object: - hw->deserialize(deser); - return true; + try + { + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); + // Object that serializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + //serialize the object: + hw->deserialize(deser); + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } std::function HelloWorldType::getSerializedSizeProvider( diff --git a/test/blackbox/types/StringType.cpp b/test/blackbox/types/StringType.cpp index fa1d7b4e525..7e050c262d5 100644 --- a/test/blackbox/types/StringType.cpp +++ b/test/blackbox/types/StringType.cpp @@ -41,37 +41,55 @@ bool StringType::serialize( void* data, SerializedPayload_t* payload) { + bool ret_value = false; String* hw = (String*) data; - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - //serialize the object: - hw->serialize(ser); - payload->length = (uint32_t)ser.getSerializedDataLength(); - return true; + + try + { + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + //serialize the object: + hw->serialize(ser); + payload->length = (uint32_t)ser.getSerializedDataLength(); + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } bool StringType::deserialize( SerializedPayload_t* payload, void* data) { + bool ret_value = false; String* hw = (String*) data; - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); - // Object that serializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - //serialize the object: - hw->deserialize(deser); - return true; + + try + { + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); + // Object that serializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + //serialize the object: + hw->deserialize(deser); + ret_value = true; + } + catch (eprosima::fastcdr::exception::Exception&) + { + } + return ret_value; } std::function StringType::getSerializedSizeProvider( From aab23ccebc8edc725ddeb0f16fb3eb35ee1cabdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Thu, 15 Jul 2021 10:20:58 +0200 Subject: [PATCH 3/7] Refs #11831. Update datareader tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- test/unittest/dds/subscriber/DataReaderTests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 3750cbf8e40..2ba83419d35 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -999,6 +999,7 @@ TEST_F(DataReaderTests, resource_limits) const ReturnCode_t& ok_code = ReturnCode_t::RETCODE_OK; const ReturnCode_t& resources_code = ReturnCode_t::RETCODE_OUT_OF_RESOURCES; + const ReturnCode_t& no_data_code = ReturnCode_t::RETCODE_NO_DATA; DataWriterQos writer_qos = DATAWRITER_QOS_DEFAULT; writer_qos.history().kind = KEEP_LAST_HISTORY_QOS; @@ -1068,12 +1069,11 @@ TEST_F(DataReaderTests, resource_limits) FooSeq data_seq; SampleInfoSeq info_seq; - // The standard is not clear on what shold be done if max_samples is 0. NO_DATA? OK with length = 0? - // We have assumed the correct interpretation is the second one, so the following loop starts at 0. - // This test should change whenever this interpretation becomes invalid. + // With length == 0 the returned code should be okNO_DATA + EXPECT_EQ(no_data_code, data_reader_->read(data_seq, info_seq, 0)); // Up to max_samples_per_read, max_samples will be returned - for (int32_t i = 0; i <= 10; ++i) + for (int32_t i = 1; i <= 10; ++i) { EXPECT_EQ(ok_code, data_reader_->read(data_seq, info_seq, i)); check_collection(data_seq, false, i, i); From 8dd8241fb2dc4aa5a0af8c13c77ebef7057b14ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2021 08:16:03 +0200 Subject: [PATCH 4/7] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miguel Company Signed-off-by: Ricardo González Moreno --- src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp | 1 + test/unittest/dds/subscriber/DataReaderTests.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp index b59e6ca4496..6c1d2a7e669 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp @@ -297,6 +297,7 @@ struct ReadTakeCommand return false; } + // Mark that some data is available return_value_ = ReturnCode_t::RETCODE_OK; } diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 2ba83419d35..2918366878d 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -1069,7 +1069,7 @@ TEST_F(DataReaderTests, resource_limits) FooSeq data_seq; SampleInfoSeq info_seq; - // With length == 0 the returned code should be okNO_DATA + // With length == 0 the returned code should be NO_DATA EXPECT_EQ(no_data_code, data_reader_->read(data_seq, info_seq, 0)); // Up to max_samples_per_read, max_samples will be returned From 5310be51f60a2a4fdf01b6638a098f9cdd170983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Fri, 16 Jul 2021 08:40:27 +0200 Subject: [PATCH 5/7] Refs #12129. Removed comment which was moved. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp index 6c1d2a7e669..f88cbe0a7f5 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp @@ -273,7 +273,6 @@ struct ReadTakeCommand CacheChange_t* change, bool& deserialization_error) { - // Mark that some data is available bool ret_val = false; deserialization_error = false; From 6eb0994608679f4f948ea537f771a20b6f95d146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2021 10:54:40 +0200 Subject: [PATCH 6/7] Update test/unittest/dds/subscriber/DataReaderTests.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miguel Company Signed-off-by: Ricardo González Moreno --- test/unittest/dds/subscriber/DataReaderTests.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 2918366878d..5134f69356d 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -1069,7 +1069,9 @@ TEST_F(DataReaderTests, resource_limits) FooSeq data_seq; SampleInfoSeq info_seq; - // With length == 0 the returned code should be NO_DATA + // The standard is not clear on what should be done if max_samples is 0. NO_DATA? OK with length = 0? + // We have assumed the correct interpretation is the first one. + // This test should change whenever this interpretation becomes invalid. EXPECT_EQ(no_data_code, data_reader_->read(data_seq, info_seq, 0)); // Up to max_samples_per_read, max_samples will be returned From 828d4a2da824dd6841728de4c5f256c6041a8046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Fri, 16 Jul 2021 12:43:36 +0200 Subject: [PATCH 7/7] Refs #12130. Fix warning on windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- test/unittest/dds/subscriber/DataReaderTests.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 5134f69356d..2bd3b38fe7f 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -1632,13 +1632,11 @@ TEST_F(DataReaderTests, Deserialization_errors) EXPECT_TRUE(data_reader_->wait_for_unread_message(time_to_wait)); { - FooType data; SampleInfo info; EXPECT_EQ(no_data_code, data_reader_->take_next_sample(&data, &info)); } { - FooType data; SampleInfo info; EXPECT_EQ(no_data_code, data_reader_->read_next_sample(&data, &info)); }