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
1 change: 1 addition & 0 deletions score/mw/com/impl/bindings/lola/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ cc_unit_test(
"//score/mw/com/impl/bindings/lola/test:transaction_log_test_resources",
"//score/mw/com/impl/bindings/mock_binding:mock_binding_lib",
"//score/mw/com/impl/configuration",
"//score/mw/com/impl/util:type_erased_storage",
"@score_baselibs//score/language/futurecpp:futurecpp_test_support",
"@score_baselibs//score/result",
],
Expand Down
7 changes: 5 additions & 2 deletions score/mw/com/impl/bindings/lola/proxy_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
namespace score::mw::com::impl::lola
{

ProxyEvent::ProxyEvent(Proxy& parent, const ElementFqId element_fq_id, const std::string_view event_name)
ProxyEvent::ProxyEvent(Proxy& parent,
const ElementFqId element_fq_id,
const std::string_view event_name,
const memory::DataTypeSizeInfo data_type_size_info)
: GenericProxyEventBinding{},
meta_info_{parent.GetEventMetaInfo(element_fq_id)},
meta_info_{data_type_size_info},
event_data_storage_{parent.GetEventDataStorage(element_fq_id)},
test_slot_collector_{},
parent_{parent},
Expand Down
10 changes: 8 additions & 2 deletions score/mw/com/impl/bindings/lola/proxy_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ class ProxyEvent final : public GenericProxyEventBinding
/// \param parent Parent proxy of the proxy event.
/// \param element_fq_id The ID of the event inside the proxy type.
/// \param event_name The name of the event inside the proxy type.
ProxyEvent(Proxy& parent, const ElementFqId element_fq_id, const std::string_view event_name);
/// \param data_type_size_info Size/alignment info of the event's data type, as determined by the caller (either
/// from the known SampleType of a typed proxy event, or looked up from the EventMetaInfo stored in
/// shared-memory for a generic/type-erased proxy event).
ProxyEvent(Proxy& parent,
const ElementFqId element_fq_id,
const std::string_view event_name,
const memory::DataTypeSizeInfo data_type_size_info);

ProxyEvent(const ProxyEvent&) = delete;
ProxyEvent(ProxyEvent&&) noexcept = delete;
Expand Down Expand Up @@ -119,7 +125,7 @@ class ProxyEvent final : public GenericProxyEventBinding
/// GetNewSamplesSlotIndices() is only called when the event is in the subscribed state.
SlotCollector::SlotIndices GetNewSamplesSlotIndices(const std::size_t max_count);

const EventMetaInfo& meta_info_;
const EventMetaInfo meta_info_;
const EventDataStorage& event_data_storage_;

/// \brief Manually insert a slot collector. Only used for tests.
Expand Down
5 changes: 3 additions & 2 deletions score/mw/com/impl/bindings/lola/proxy_event_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@ TEST_F(LolaProxyEventFixture, HasSerializedFormat)
EXPECT_EQ(this->test_proxy_event_->HasSerializedFormat(), false);
}

TEST_F(LolaProxyEventFixture, HoldsEventMetaInfoAsConstReference)
TEST_F(LolaProxyEventFixture, HoldsEventMetaInfoAsConstValue)
{
// Given a ProxyEvent
this->GivenAProxyEvent(this->element_fq_id_, this->event_name_);

// When accessing the proxy event through the test attorney
ProxyEventAttorney proxy_event_attorney{*test_proxy_event_};

// Then the proxy stores EventMetaInfo as const data
// Then the proxy stores EventMetaInfo as const data, which it received via its constructor instead of looking it
// up from a shared-memory reference.
using MetaInfoMemberType = typename std::remove_reference<decltype(proxy_event_attorney.GetMetaInfoMember())>::type;
static_assert(std::is_const<MetaInfoMemberType>::value, "Proxy should hold const event meta info.");
}
Expand Down
10 changes: 6 additions & 4 deletions score/mw/com/impl/bindings/lola/proxy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "score/mw/com/impl/handle_type.h"
#include "score/mw/com/impl/instance_identifier.h"
#include "score/mw/com/impl/subscription_state.h"
#include "score/mw/com/impl/util/type_erased_storage.h"

#include "score/result/result.h"

Expand Down Expand Up @@ -434,7 +435,7 @@ TEST_F(ProxyAutoReconnectFixture, ProxyEventCreationWhenProviderNotExistsLeadsTo
EXPECT_NE(proxy_, nullptr);

// and a ProxyEvent registers itself with the Proxy
ProxyEvent proxy_event{*proxy_, kDummyElementFqId, kDummyEventName};
ProxyEvent proxy_event{*proxy_, kDummyElementFqId, kDummyEventName, CreateDataTypeSizeInfoFromTypes<SampleType>()};
score::cpp::ignore = proxy_event.Subscribe(kMaxNumSlots);

// Then the Proxy notified the event during registration that the provider service instance is not available,
Expand Down Expand Up @@ -465,7 +466,7 @@ TEST_F(ProxyAutoReconnectFixture, ProxyEventCreationWhenProviderExistsLeadsToSub
EXPECT_NE(proxy_, nullptr);

// and a ProxyEvent registers itself with the Proxy
ProxyEvent proxy_event{*proxy_, kDummyElementFqId, kDummyEventName};
ProxyEvent proxy_event{*proxy_, kDummyElementFqId, kDummyEventName, CreateDataTypeSizeInfoFromTypes<SampleType>()};
score::cpp::ignore = proxy_event.Subscribe(kMaxNumSlots);

// Then the Proxy notified the event during registration that the provider service instance is available, so the
Expand Down Expand Up @@ -503,7 +504,8 @@ TEST_F(ProxyAutoReconnectFixture, ProxyEventSubscriptionStateReflectsLatestState
EXPECT_NE(proxy_, nullptr);

// and the first ProxyEvent registers itself with the Proxy while the provider service instance is available
ProxyEvent proxy_event_0{*proxy_, kDummyElementFqId, kDummyEventName};
ProxyEvent proxy_event_0{
*proxy_, kDummyElementFqId, kDummyEventName, CreateDataTypeSizeInfoFromTypes<SampleType>()};
score::cpp::ignore = proxy_event_0.Subscribe(kMaxNumSlots);
ASSERT_EQ(proxy_event_0.GetSubscriptionState(), SubscriptionState::kSubscribed);

Expand All @@ -515,7 +517,7 @@ TEST_F(ProxyAutoReconnectFixture, ProxyEventSubscriptionStateReflectsLatestState
EXPECT_EQ(proxy_event_0.GetSubscriptionState(), SubscriptionState::kSubscriptionPending);

// and the second ProxyEvent registers itself with the Proxy while the provider service instance is unavailable
ProxyEvent proxy_event_1{*proxy_, element_fq_id_1, event_name_1};
ProxyEvent proxy_event_1{*proxy_, element_fq_id_1, event_name_1, CreateDataTypeSizeInfoFromTypes<SampleType>()};
score::cpp::ignore = proxy_event_1.Subscribe(kMaxNumSlots);

// Then the second ProxyEvent is notified during registration that the provider service instance is not available
Expand Down
6 changes: 1 addition & 5 deletions score/mw/com/impl/bindings/lola/skeleton_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ namespace score::mw::com::impl::lola
{

SkeletonMethod::SkeletonMethod(Skeleton& skeleton, UniqueMethodIdentifier unique_method_identifier)
: in_args_type_erased_info_{},
return_type_type_erased_info_{},
type_erased_callback_{},
registration_guards_{},
registration_guards_mutex_{}
: type_erased_callback_{}, registration_guards_{}, registration_guards_mutex_{}
{
skeleton.RegisterMethod(unique_method_identifier, *this);
}
Expand Down
3 changes: 0 additions & 3 deletions score/mw/com/impl/bindings/lola/skeleton_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "score/mw/com/impl/methods/skeleton_method_binding.h"

#include "score/language/safecpp/scoped_function/scope.h"
#include "score/memory/data_type_size_info.h"
#include "score/result/result.h"

#include <sched.h>
Expand Down Expand Up @@ -73,8 +72,6 @@ class SkeletonMethod : public SkeletonMethodBinding
const std::optional<score::cpp::span<std::byte>> return_arg);
void CleanUpOldHandlers(const GlobalConfiguration::ApplicationId application_id, pid_t proxy_pid);

std::optional<memory::DataTypeSizeInfo> in_args_type_erased_info_;
std::optional<memory::DataTypeSizeInfo> return_type_type_erased_info_;
std::optional<SkeletonMethodBinding::TypeErasedHandler> type_erased_callback_;

std::unordered_map<ProxyMethodInstanceIdentifier, std::pair<pid_t, MethodCallRegistrationGuard>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "score/mw/com/impl/bindings/lola/test/proxy_event_test_resources.h"
#include "score/mw/com/impl/sample_reference_tracker.h"
#include "score/mw/com/impl/subscription_state.h"
#include "score/mw/com/impl/util/type_erased_storage.h"

#include "score/language/safecpp/scoped_function/scope.h"

Expand Down Expand Up @@ -101,7 +102,8 @@ class LolaProxyEventFixture : public LolaProxyEventResources
public:
LolaProxyEventFixture& GivenAProxyEvent(const ElementFqId element_fq_id, const std::string& event_name)
{
test_proxy_event_ = std::make_unique<ProxyEvent>(*proxy_, element_fq_id, event_name);
test_proxy_event_ = std::make_unique<ProxyEvent>(
*proxy_, element_fq_id, event_name, CreateDataTypeSizeInfoFromTypes<TestSampleType>());
return *this;
}

Expand Down
37 changes: 31 additions & 6 deletions score/mw/com/impl/methods/proxy_method_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ class ProxyMethodTestFixture : public ::testing::Test
ProxyMethodTestFixture& GivenAProxyMethodWithoutBinding()
{
EXPECT_CALL(proxy_method_binding_factory_mock_guard_.factory_mock_,
Create(_ /*handle*/, _ /*parent binding*/, _ /*method_name*/, _ /*method_type*/))
Create(_ /*handle*/,
_ /*parent binding*/,
_ /*method_name*/,
_ /*method_type*/,
_ /*in_arg_type_info*/,
_ /*return_type_info*/))
.WillOnce(Return(ByMove(MakeUnexpected(ComErrc::kBindingFailure))));

unit_ = std::make_unique<ProxyServiceMethodType>(proxy_base_, kMethodName);
Expand Down Expand Up @@ -124,7 +129,7 @@ class ProxyMethodTestFixture : public ::testing::Test
mock_binding::ProxyMethod proxy_method_binding_mock_;
TestProxyBase proxy_base_{std::make_unique<mock_binding::Proxy>(), config_store_.GetHandle()};

ProxyMethodBindingFactoryMockGuard<MethodType> proxy_method_binding_factory_mock_guard_{};
ProxyMethodBindingFactoryMockGuard proxy_method_binding_factory_mock_guard_{};
std::unique_ptr<ProxyServiceMethodType> unit_{nullptr};
};

Expand Down Expand Up @@ -263,7 +268,12 @@ TYPED_TEST(ProxyMethodAllArgCombinationsTestFixture, SucceedingToCreateMethodBin
{
// Expecting that a binding factory can create a binding
EXPECT_CALL(this->proxy_method_binding_factory_mock_guard_.factory_mock_,
Create(_ /*handle*/, _ /*parent binding*/, _ /*method_name*/, _ /*method_type*/))
Create(_ /*handle*/,
_ /*parent binding*/,
_ /*method_name*/,
_ /*method_type*/,
_ /*in_arg_type_info*/,
_ /*return_type_info*/))
.WillOnce(Return(ByMove(std::make_unique<mock_binding::ProxyMethodFacade>(this->proxy_method_binding_mock_))));

// When the 2-parameter constructor of the ProxyMethod class is called
Expand All @@ -276,7 +286,12 @@ TYPED_TEST(ProxyMethodAllArgCombinationsTestFixture, SucceedingToCreateMethodBin
{
// Expecting that a binding factory can create a binding
EXPECT_CALL(this->proxy_method_binding_factory_mock_guard_.factory_mock_,
Create(_ /*handle*/, _ /*parent binding*/, _ /*method_name*/, _ /*method_type*/))
Create(_ /*handle*/,
_ /*parent binding*/,
_ /*method_name*/,
_ /*method_type*/,
_ /*in_arg_type_info*/,
_ /*return_type_info*/))
.WillOnce(Return(ByMove(std::make_unique<mock_binding::ProxyMethodFacade>(this->proxy_method_binding_mock_))));

// When the 2-parameter constructor of the ProxyMethod class is called
Expand All @@ -291,7 +306,12 @@ TYPED_TEST(ProxyMethodAllArgCombinationsTestFixture, FailingToCreateMethodBindin
{
// Expecting that a binding factory fails to create a binding and returns an error
EXPECT_CALL(this->proxy_method_binding_factory_mock_guard_.factory_mock_,
Create(_ /*handle*/, _ /*parent binding*/, _ /*method_name*/, _ /*method_type*/))
Create(_ /*handle*/,
_ /*parent binding*/,
_ /*method_name*/,
_ /*method_type*/,
_ /*in_arg_type_info*/,
_ /*return_type_info*/))
.WillOnce(Return(ByMove(MakeUnexpected(ComErrc::kBindingFailure))));

// When the 2-parameter constructor of the ProxyMethod class is called
Expand All @@ -304,7 +324,12 @@ TYPED_TEST(ProxyMethodAllArgCombinationsTestFixture, FailingToCreateMethodBindin
{
// Expecting that a binding factory fails to create a binding and returns an error
EXPECT_CALL(this->proxy_method_binding_factory_mock_guard_.factory_mock_,
Create(_ /*handle*/, _ /*parent binding*/, _ /*method_name*/, _ /*method_type*/))
Create(_ /*handle*/,
_ /*parent binding*/,
_ /*method_name*/,
_ /*method_type*/,
_ /*in_arg_type_info*/,
_ /*return_type_info*/))
.WillOnce(Return(ByMove(MakeUnexpected(ComErrc::kBindingFailure))));

// When the 2-parameter constructor of the ProxyMethod class is called
Expand Down
10 changes: 6 additions & 4 deletions score/mw/com/impl/methods/proxy_method_with_in_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ class ProxyMethod<void(ArgTypes...)> final : public ProxyMethodBase
public:
ProxyMethod(ProxyBase& proxy_base, std::string_view method_name) noexcept
: ProxyMethodBase(method_name,
ProxyMethodBindingFactory<void(ArgTypes...)>::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod),
ProxyMethodBindingFactory::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod,
type_erased_in_args_,
type_erased_return_type_),
MethodType::kMethod),
are_in_arg_ptrs_active_(kCallQueueSize)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ class ProxyMethod<ReturnType(ArgTypes...)> final : public ProxyMethodBase

public:
ProxyMethod(ProxyBase& proxy_base, std::string_view method_name) noexcept
: ProxyMethodBase(
method_name,
ProxyMethodBindingFactory<ReturnType(ArgTypes...)>::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod),
MethodType::kMethod),
: ProxyMethodBase(method_name,
ProxyMethodBindingFactory::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod,
type_erased_in_args_,
type_erased_return_type_),
MethodType::kMethod),
are_in_arg_ptrs_active_(kCallQueueSize)
{
auto proxy_base_view = ProxyBaseView{proxy_base};
Expand Down
10 changes: 6 additions & 4 deletions score/mw/com/impl/methods/proxy_method_with_return_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ class ProxyMethod<ReturnType()> final : public ProxyMethodBase
public:
ProxyMethod(ProxyBase& proxy_base, std::string_view method_name) noexcept
: ProxyMethodBase(method_name,
ProxyMethodBindingFactory<ReturnType()>::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod),
ProxyMethodBindingFactory::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod,
type_erased_in_args_,
type_erased_return_type_),
MethodType::kMethod)
{
auto proxy_base_view = ProxyBaseView{proxy_base};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class ProxyMethod<void()> final : public ProxyMethodBase
public:
ProxyMethod(ProxyBase& proxy_base, std::string_view method_name)
: ProxyMethodBase(method_name,
ProxyMethodBindingFactory<void()>::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod),
ProxyMethodBindingFactory::Create(proxy_base.GetHandle(),
ProxyBaseView{proxy_base}.GetBinding(),
method_name,
MethodType::kMethod,
type_erased_in_args_,
type_erased_return_type_),
MethodType::kMethod)
{
auto proxy_base_view = ProxyBaseView{proxy_base};
Expand Down
8 changes: 6 additions & 2 deletions score/mw/com/impl/methods/skeleton_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class SkeletonMethod<ReturnType(ArgTypes...)> final : public SkeletonMethodBase
SkeletonMethodBindingFactory::Create(SkeletonBaseView{skeleton_base}.GetAssociatedInstanceIdentifier(),
SkeletonBaseView{skeleton_base}.GetBinding(),
method_name,
::score::mw::com::impl::MethodType::kMethod),
::score::mw::com::impl::MethodType::kMethod,
TypeErasedMethodSignatureInfo<MethodType>::InArgsTypeInfo(),
TypeErasedMethodSignatureInfo<MethodType>::ReturnTypeInfo()),
::score::mw::com::impl::MethodType::kMethod)
{
}
Expand All @@ -103,7 +105,9 @@ class SkeletonMethod<ReturnType(ArgTypes...)> final : public SkeletonMethodBase
SkeletonMethodBindingFactory::Create(SkeletonBaseView{skeleton_base}.GetAssociatedInstanceIdentifier(),
SkeletonBaseView{skeleton_base}.GetBinding(),
method_name,
method_type),
method_type,
TypeErasedMethodSignatureInfo<MethodType>::InArgsTypeInfo(),
TypeErasedMethodSignatureInfo<MethodType>::ReturnTypeInfo()),
method_type)
{
AssertMethodSignatureDoesNotContainPointersOrReferences<FailureMode::kCompileTime, ReturnType, ArgTypes...>();
Expand Down
Loading
Loading