Skip to content
Draft
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
4 changes: 2 additions & 2 deletions score/mw/com/impl/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ProxyTrait
// Note : at the moment the SkeletonField::Get implementation is not in the branch which means the skeleton and
// proxy side does not have same template parameters.
template <typename SampleType, bool EnableSet = false, bool EnableGet = false, bool EnableNotifier = false>
using Field = ProxyField<SampleType>;
using Field = ProxyField<SampleType, EnableSet, EnableGet, EnableNotifier>;

template <typename MethodSignature>
using Method = ProxyMethod<MethodSignature>;
Expand All @@ -164,7 +164,7 @@ class SkeletonTrait
template <typename SampleType>
using Event = SkeletonEvent<SampleType>;

template <typename SampleType, bool EnableSet = false, bool EnableNotifier = false>
template <typename SampleType, bool EnableGet = false, bool EnableSet = false, bool EnableNotifier = false>
using Field = SkeletonField<SampleType, EnableSet, EnableNotifier>;

template <typename MethodSignature>
Expand Down
6 changes: 5 additions & 1 deletion score/mw/com/impl/traits_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <gtest/gtest.h>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -69,10 +70,13 @@ class MyInterface : public InterfaceTrait::Base
public:
using InterfaceTrait::Base::Base;

static constexpr bool kEnableSet{std::is_same_v<InterfaceTrait, SkeletonTrait>};

typename InterfaceTrait::template Event<TestSampleType> some_event{*this, kEventName};
typename InterfaceTrait::template Field<TestSampleType, true> some_field{*this, kFieldName};
typename InterfaceTrait::template Field<TestSampleType, false, kEnableSet> some_field{*this, kFieldName};
typename InterfaceTrait::template Method<TestMethodType> some_method{*this, kMethodName};
};

using MyProxy = AsProxy<MyInterface>;
using MySkeleton = AsSkeleton<MyInterface>;

Expand Down
16 changes: 16 additions & 0 deletions score/mw/com/test/common_test_resources/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ cc_library(
],
)

cc_library(
name = "process_synchronizer",
srcs = ["process_synchronizer.cpp"],
hdrs = ["process_synchronizer.h"],
features = COMPILER_WARNING_FEATURES,
visibility = ["//score/mw/com/test:__subpackages__"],
deps = [
"//score/mw/com/test/common_test_resources:fail_test",
"//score/mw/com/test/common_test_resources:shared_memory_object_creator",
"//score/mw/com/test/common_test_resources:shared_memory_object_guard",
"@score_baselibs//score/mw/log",
"@score_baselibs//score/os/utils/interprocess:interprocess_notification",
"@score_baselibs//score/result",
],
)

cc_library(
name = "stop_token_sig_term_handler",
srcs = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include "score/mw/com/test/methods/methods_test_resources/process_synchronizer.h"
#include "score/mw/com/test/common_test_resources/process_synchronizer.h"

#include "score/mw/com/test/common_test_resources/fail_test.h"
#include "score/mw/com/test/common_test_resources/shared_memory_object_creator.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#ifndef SCORE_MW_COM_TEST_METHODS_METHODS_TEST_RESOURCES_PROCESS_SYNCHRONIZER_H
#define SCORE_MW_COM_TEST_METHODS_METHODS_TEST_RESOURCES_PROCESS_SYNCHRONIZER_H
#ifndef SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_PROCESS_SYNCHRONIZER_H
#define SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_PROCESS_SYNCHRONIZER_H

#include "score/mw/com/test/common_test_resources/shared_memory_object_creator.h"
#include "score/mw/com/test/common_test_resources/shared_memory_object_guard.h"
Expand Down Expand Up @@ -46,4 +46,4 @@ class ProcessSynchronizer

} // namespace score::mw::com::test

#endif // SCORE_MW_COM_TEST_METHODS_METHODS_TEST_RESOURCES_PROCESS_SYNCHRONIZER_H
#endif // SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_PROCESS_SYNCHRONIZER_H
88 changes: 0 additions & 88 deletions score/mw/com/test/field_initial_value/service.cpp

This file was deleted.

12 changes: 12 additions & 0 deletions score/mw/com/test/fields/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ cc_binary(
features = COMPILER_WARNING_FEATURES + [
"aborts_upon_exception",
],
visibility = ["//score/mw/com/test/field_initial_value:__pkg__"],
visibility = ["//score/mw/com/test/fields/field_initial_value:__pkg__"],
deps = [
":test_datatype",
"//score/mw/com",
"//score/mw/com/test/common_test_resources:sctf_test_runner",
"//score/mw/com/test/common_test_resources:fail_test",
"//score/mw/com/test/common_test_resources:process_synchronizer",
"//score/mw/com/test/common_test_resources:stop_token_sig_term_handler",
"@score_baselibs//score/mw/log",
],
)
Expand All @@ -56,10 +58,11 @@ cc_binary(
features = COMPILER_WARNING_FEATURES + [
"aborts_upon_exception",
],
visibility = ["//score/mw/com/test/field_initial_value:__pkg__"],
visibility = ["//score/mw/com/test/fields/field_initial_value:__pkg__"],
deps = [
":test_datatype",
"//score/mw/com",
"//score/mw/com/test/common_test_resources:process_synchronizer",
"//score/mw/com/test/common_test_resources:sctf_test_runner",
"@score_baselibs//score/mw/log",
],
Expand All @@ -75,7 +78,7 @@ pkg_application(
],
visibility = [
"//platform/aas/test/mw/com:__pkg__",
"//score/mw/com/test/field_initial_value:__subpackages__",
"//score/mw/com/test/fields/field_initial_value:__subpackages__",
],
)

Expand All @@ -89,6 +92,6 @@ pkg_application(
],
visibility = [
"//platform/aas/test/mw/com:__pkg__",
"//score/mw/com/test/field_initial_value:__subpackages__",
"//score/mw/com/test/fields/field_initial_value:__subpackages__",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/

#include "score/mw/com/test/common_test_resources/fail_test.h"
#include "score/mw/com/test/common_test_resources/process_synchronizer.h"
#include "score/mw/com/test/common_test_resources/sctf_test_runner.h"
#include "score/mw/com/test/field_initial_value/test_datatype.h"
#include "score/mw/com/test/fields/field_initial_value/test_datatype.h"
#include "score/mw/com/types.h"

#include <score/optional.hpp>
Expand All @@ -21,6 +23,7 @@
#include <cstddef>
#include <future>
#include <iostream>
#include <string>
#include <thread>

namespace score::mw::com::test
Expand All @@ -31,15 +34,22 @@ namespace

constexpr auto kMaxNumSamples{1U};

int run_client(const std::size_t num_retries, const std::chrono::milliseconds retry_backoff_time)
const std::string kInterprocessNotificationShmPath{"/field_initial_value_interprocess_notification"};

void run_client(const std::size_t num_retries, const std::chrono::milliseconds retry_backoff_time)
{
using score::mw::com::test::TestDataProxy;

auto process_synchronizer_result = ProcessSynchronizer::Create(kInterprocessNotificationShmPath);
if (!process_synchronizer_result.has_value())
{
FailTest("Unable to create ProcessSynchronizer");
}

auto instance_specifier_result = InstanceSpecifier::Create(std::string{kInstanceSpecifierString});
if (!instance_specifier_result.has_value())
{
std::cerr << "Unable to create instance specifier, terminating\n";
return -7;
FailTest("Unable to create instance specifier");
}
auto instance_specifier = std::move(instance_specifier_result).value();

Expand All @@ -54,22 +64,19 @@ int run_client(const std::size_t num_retries, const std::chrono::milliseconds re

if (!lola_proxy_handles_result.has_value())
{
std::cerr << "Unable to get handles, terminating\n";
return -1;
FailTest("Unable to get handles");
}

auto lola_proxy_handles = service_discovery_future.get();
if (lola_proxy_handles.empty())
{
std::cerr << "Unable to find lola service, terminating\n";
return -2;
FailTest("Unable to find lola service");
}

auto lola_proxy_result = TestDataProxy::Create(lola_proxy_handles[0]);
if (!lola_proxy_result.has_value())
{
std::cerr << "Unable to create lola proxy, terminating\n";
return -3;
FailTest("Unable to create lola proxy");
}
auto& lola_proxy = lola_proxy_result.value();
score::cpp::optional<std::int32_t> received_value;
Expand All @@ -82,8 +89,7 @@ int run_client(const std::size_t num_retries, const std::chrono::milliseconds re
retries--;
if (retries <= 0)
{
std::cerr << "Subscription failed!\n";
return -4;
FailTest("Subscription failed");
}
}
std::ignore = lola_proxy.test_field.GetNewSamples(
Expand All @@ -96,17 +102,15 @@ int run_client(const std::size_t num_retries, const std::chrono::milliseconds re

if (!received_value.has_value())
{
std::cerr << "Lola didn't receive a sample!\n";
return -5;
FailTest("Lola didn't receive a sample");
}

if (received_value.value() != kTestValue)
{
std::cerr << "Expecting:" << kTestValue << " Received:" << received_value.value() << "!\n ";
return -6;
FailTest("Received value does not match expected value");
}

return 0;
process_synchronizer_result->Notify();
}

} // namespace
Expand All @@ -122,7 +126,7 @@ int main(int argc, const char** argv)
const auto& run_parameters = test_runner.GetRunParameters();
const auto num_retries = run_parameters.GetNumRetries();
const auto retry_backoff_time = run_parameters.GetRetryBackoffTime();
const auto stop_token = test_runner.GetStopToken();

return score::mw::com::test::run_client(num_retries, retry_backoff_time);
score::mw::com::test::run_client(num_retries, retry_backoff_time);
return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
"logLevelThresholdConsole": "kDebug",
"logMode": "kRemote|kConsole"
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"serviceTypes": [
{
"serviceTypeName": "/score/mw/com/test/field_initial_value",
"serviceTypeName": "/score/mw/com/test/fields/field_initial_value",
"version": {
"major": 1,
"minor": 0
Expand All @@ -22,8 +22,8 @@
],
"serviceInstances": [
{
"instanceSpecifier": "test/field_initial_value",
"serviceTypeName": "/score/mw/com/test/field_initial_value",
"instanceSpecifier": "test/fields/field_initial_value",
"serviceTypeName": "/score/mw/com/test/fields/field_initial_value",
"version": {
"major": 1,
"minor": 0
Expand All @@ -45,4 +45,3 @@
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ load("//quality/integration_testing:integration_testing.bzl", "integration_test"
pkg_filegroup(
name = "filesystem",
srcs = [
"//score/mw/com/test/field_initial_value:client-pkg",
"//score/mw/com/test/field_initial_value:service-pkg",
"//score/mw/com/test/fields/field_initial_value:client-pkg",
"//score/mw/com/test/fields/field_initial_value:service-pkg",
],
)

Expand Down
Loading
Loading