Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion score/mw/com/impl/proxy_event.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is actually happening in the old code? I can't imagine that there was actually infinite recursion because we would have seen it when moving a proxy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can run this without changing the move op

gdb --batch --ex 'run --gtest_filter=ProxyEventTest.MoveAssignmentTransfersBindingFromSourceToDestination' --ex 'bt 10' bazel-bin/score/mw/com/impl/proxy_event_test
then you will see this

Program received signal SIGSEGV, Segmentation fault.
0x0000555555604d32 in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#0 0x0000555555604d32 in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#1 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#2 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#3 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#4 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#5 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#6 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#7 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#8 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#9 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
q551424@clid2082740:~/score/communication (fix_move_bug)$ gdb --batch --ex 'run --gtest_filter=ProxyEventTest.MoveAssignmentTransfersBindingFromSourceToDestination' --ex 'bt 10' bazel-bin/score/mw/com/impl/proxy_event_test

Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ auto ProxyEvent<SampleType>::operator=(ProxyEvent&& other) & noexcept -> ProxyEv
{
if (this != &other)
{
ProxyEvent::operator=(std::move(other));
ProxyEventBase::operator=(std::move(static_cast<ProxyEventBase&&>(other)));
proxy_event_mock_ = std::move(other.proxy_event_mock_);
// Since the address of this event has changed, we need update the address stored in the parent proxy.
ProxyBaseView proxy_base_view{proxy_base_.get()};
Expand Down
31 changes: 31 additions & 0 deletions score/mw/com/impl/proxy_event_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,37 @@ TEST(ProxyEventTest, IsMoveable)
static_assert(std::is_move_assignable<ProxyEvent<SampleType>>::value, "Is not move assignable");
}

using ProxyEventMoveAssignmentTest = ProxyEventFixture<ProxyEventStruct>;
TEST_F(ProxyEventMoveAssignmentTest, MoveAssignmentTransfersBindingFromSourceToDestination)
{
RecordProperty("Verifies", "SCR-5897869"); // SWS_CM_00135
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What requirement are you linking here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a copy paste from the one above which checked this "IsMovable"

RecordProperty("Description",
"After move-assigning one ProxyEvent into another the destination delegates calls to the source's "
"binding");
RecordProperty("TestType", "Requirements-based test");
RecordProperty("Priority", "1");
RecordProperty("DerivationTechnique", "Analysis of requirements");

StrictMock<mock_binding::ProxyEvent<SampleType>> second_binding_mock{};
auto second_binding_facade = std::make_unique<mock_binding::ProxyEventFacade<SampleType>>(second_binding_mock);

// Given two registered ProxyEvents, each with their own binding mock
ProxyEventType second_event{empty_proxy_, std::move(second_binding_facade), kEventName2};
ProxyBaseView{empty_proxy_}.RegisterEvent(kEventName, proxy_event_);
ProxyBaseView{empty_proxy_}.RegisterEvent(kEventName2, second_event);

constexpr std::size_t max_sample_count{7U};
EXPECT_CALL(second_binding_mock, GetSubscriptionState()).WillOnce(Return(SubscriptionState::kNotSubscribed));
EXPECT_CALL(second_binding_mock, Subscribe(max_sample_count)).WillOnce(Return(score::Result<void>{}));

// When move-assigning the first into the second
proxy_event_ = std::move(second_event);

// Then subsequent calls on the destination dispatch to the source's binding (proving the binding was transferred)
const auto subscribe_result = proxy_event_.Subscribe(max_sample_count);
ASSERT_TRUE(subscribe_result.has_value());
}

TEST(ProxyEventTest, ClassTypeDependsOnEventDataType)
{
RecordProperty("Verifies", "SCR-29235350");
Expand Down