Skip to content

Commit

Permalink
Refs #20165. Fixes asan
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Sep 17, 2024
1 parent 174fe92 commit fa3eb30
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/dds/xtypes/TypeLookupServicePublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool TypeLookupServicePublisher::create_known_type_impl(
{
// Create a new PubKnownType for the given type
PubKnownType a_type;
a_type.type_ = new Type();
a_type.type_.reset(new Type());
a_type.type_sup_.reset(new TypePubSubType());
a_type.type_sup_.register_type(participant_);

Expand Down
3 changes: 2 additions & 1 deletion test/dds/xtypes/TypeLookupServicePublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <future>
#include <iostream>
#include <map>
#include <memory>
#include <mutex>
#include <thread>
#include <unordered_set>
Expand All @@ -50,7 +51,7 @@ namespace dds {

struct PubKnownType
{
void* type_ {nullptr};
std::shared_ptr<void> type_;
DynamicType::_ref_type dyn_type_;
TypeSupport type_sup_;

Expand Down
2 changes: 1 addition & 1 deletion test/dds/xtypes/TypeLookupServiceSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool TypeLookupServiceSubscriber::create_known_type_impl(
{
// Create a new SubKnownType for the given type
SubKnownType a_type;
a_type.type_ = new Type();
a_type.type_.reset(new Type());
a_type.type_sup_.reset(new TypePubSubType());
a_type.type_sup_.register_type(participant_);

Expand Down
3 changes: 2 additions & 1 deletion test/dds/xtypes/TypeLookupServiceSubscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <future>
#include <iostream>
#include <map>
#include <memory>
#include <mutex>
#include <thread>
#include <unordered_set>
Expand All @@ -51,7 +52,7 @@ namespace dds {

struct SubKnownType
{
void* type_ {nullptr};
std::shared_ptr<void> type_;
DynamicType::_ref_type dyn_type_;
TypeSupport type_sup_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_wrong_EntityId)

TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_malformed_Reply)
{
CacheChange_t* change = new CacheChange_t();
CacheChange_t* change {new CacheChange_t()};
change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;

EXPECT_CALL(*tlm_, receive(
Expand All @@ -484,9 +484,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNSUPPORTED)
std::to_string(static_cast<int>(rpc::RemoteExceptionCode_t::REMOTE_EX_UNSUPPORTED)));


CacheChange_t* change = new CacheChange_t();
change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(change);
CacheChange_t change;
change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(&change);

TypeLookup_Reply expectedReply;
expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_UNSUPPORTED);
Expand All @@ -495,7 +495,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNSUPPORTED)
testing::Matcher<TypeLookup_Reply&>(_)))
.WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true)));

reply_listener_->on_new_cache_change_added(&stateful_reader_, change);
reply_listener_->on_new_cache_change_added(&stateful_reader_, &change);

EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0);

Expand All @@ -511,9 +511,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_INVALID_ARGUMEN
std::to_string(static_cast<int>(rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT)));


CacheChange_t* change = new CacheChange_t();
change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(change);
CacheChange_t change;
change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(&change);

TypeLookup_Reply expectedReply;
expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT);
Expand All @@ -522,7 +522,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_INVALID_ARGUMEN
testing::Matcher<TypeLookup_Reply&>(_)))
.WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true)));

reply_listener_->on_new_cache_change_added(&stateful_reader_, change);
reply_listener_->on_new_cache_change_added(&stateful_reader_, &change);

EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0);

Expand All @@ -538,9 +538,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_OUT_OF_RESOURCE
std::to_string(static_cast<int>(rpc::RemoteExceptionCode_t::REMOTE_EX_OUT_OF_RESOURCES)));


CacheChange_t* change = new CacheChange_t();
change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(change);
CacheChange_t change;
change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(&change);

TypeLookup_Reply expectedReply;
expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_OUT_OF_RESOURCES);
Expand All @@ -549,7 +549,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_OUT_OF_RESOURCE
testing::Matcher<TypeLookup_Reply&>(_)))
.WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true)));

reply_listener_->on_new_cache_change_added(&stateful_reader_, change);
reply_listener_->on_new_cache_change_added(&stateful_reader_, &change);
EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0);

Log::Flush();
Expand All @@ -564,9 +564,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_OPERATI
std::to_string(static_cast<int>(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_OPERATION)));


CacheChange_t* change = new CacheChange_t();
change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(change);
CacheChange_t change;
change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(&change);

TypeLookup_Reply expectedReply;
expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_OPERATION);
Expand All @@ -575,7 +575,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_OPERATI
testing::Matcher<TypeLookup_Reply&>(_)))
.WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true)));

reply_listener_->on_new_cache_change_added(&stateful_reader_, change);
reply_listener_->on_new_cache_change_added(&stateful_reader_, &change);
EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0);

Log::Flush();
Expand All @@ -590,9 +590,9 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_EXCEPTI
std::to_string(static_cast<int>(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION)));


CacheChange_t* change = new CacheChange_t();
change->writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(change);
CacheChange_t change;
change.writerGUID.entityId = c_EntityId_TypeLookup_reply_writer;
stateful_reader_.get_history()->add_change(&change);

TypeLookup_Reply expectedReply;
expectedReply.header().remoteEx(rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION);
Expand All @@ -601,7 +601,7 @@ TEST_F(TypeLookupServiceTests, TypeLookupReplyListener_REMOTE_EX_UNKNOWN_EXCEPTI
testing::Matcher<TypeLookup_Reply&>(_)))
.WillOnce(testing::DoAll(testing::SetArgReferee<1>(expectedReply), testing::Return(true)));

reply_listener_->on_new_cache_change_added(&stateful_reader_, change);
reply_listener_->on_new_cache_change_added(&stateful_reader_, &change);
EXPECT_EQ(reply_listener_->get_replies_queue()->size(), 0);

Log::Flush();
Expand Down

0 comments on commit fa3eb30

Please sign in to comment.