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: 4 additions & 0 deletions score/mw/com/impl/bindings/lola/skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ auto Skeleton::PrepareOffer(SkeletonEventBindings& events,
auto& lola_message_passing = lola_runtime.GetLolaMessaging();
const SkeletonInstanceIdentifier skeleton_instance_identifier{lola_service_id_, lola_instance_id_};

// Once StopOfferService is called these scopes are expired, thus we need to reinitialize them here
on_service_method_subscribed_handler_scope_ = score::safecpp::Scope<>();
method_call_handler_scope_ = score::safecpp::Scope<>();

// Register a handler with message passing which will open methods shared memory regions when the proxy notifies via
// message passing that it has finished setting up the regions. We always register a handler for QM proxies and also
// register a handler for ASIL-B proxies if this skeleton is ASIL-B.
Expand Down
33 changes: 33 additions & 0 deletions score/mw/com/test/common_test_resources/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ cc_library(
],
)

cc_library(
name = "fail_test",
srcs = [
"fail_test.cpp",
],
hdrs = [
"fail_test.h",
],
features = COMPILER_WARNING_FEATURES,
visibility = [
"//score/mw/com/test:__subpackages__",
],
)

cc_library(
name = "shared_memory_object_guard",
srcs = [
Expand Down Expand Up @@ -129,6 +143,25 @@ cc_library(
],
)

cc_library(
name = "command_line_parser",
srcs = [
"command_line_parser.cpp",
],
hdrs = [
"command_line_parser.h",
],
features = COMPILER_WARNING_FEATURES,
visibility = [
"//score/mw/com/test:__subpackages__",
],
deps = [
"//score/mw/com",
"//score/mw/com/test/common_test_resources:test_error_domain",
"@boost.program_options",
],
)

cc_library(
name = "sctf_test_runner",
srcs = [
Expand Down
55 changes: 55 additions & 0 deletions score/mw/com/test/common_test_resources/command_line_parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* 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
*******************************************************************************/

#include "score/mw/com/test/common_test_resources/command_line_parser.h"
#include <vector>

namespace score::mw::com::test
{
auto ParseCommandLineArguments(int argc,
const char** argv,
const std::vector<std::pair<std::string, std::string>>& param_names)
-> CommandLineArgsMapType
{
// uid is needed internally by sctftestrunner

namespace po = boost::program_options;
po::options_description options;
options.add_options()("help,h", "display the help message");
for (const auto& [param_name, param_doc] : param_names)
{
options.add_options()(
param_name.data(), po::value<std::string>(), ("specify " + std::string{param_doc}).data());
}

po::variables_map args;
const auto parsed_args =
po::command_line_parser{argc, argv}
.options(options)
.allow_unregistered()
.style(po::command_line_style::unix_style | po::command_line_style::allow_long_disguise)
.run();
po::store(parsed_args, args);

if (args.count("help") > 0U)
{
std::cerr << options << '\n';
return args;
}

po::notify(args);

return args;
}

} // namespace score::mw::com::test
68 changes: 68 additions & 0 deletions score/mw/com/test/common_test_resources/command_line_parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*******************************************************************************
* 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
*******************************************************************************/

#ifndef SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_COMMAND_LINE_PARSER_H
#define SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_COMMAND_LINE_PARSER_H

#include "score/mw/com/test/common_test_resources/test_error_domain.h"
#include <boost/program_options.hpp>

#include <score/optional.hpp>

#include "score/result/result.h"
#include <iostream>
#include <string>
#include <type_traits>
#include <vector>

namespace score::mw::com::test
{

using CommandLineArgsMapType = boost::program_options::variables_map;

template <typename ParsedType>
auto GetValueIfProvided(const boost::program_options::variables_map& args, const std::string& arg_string)
-> Result<ParsedType>
{
std::string error_msg = "could nod find the requested parameter: " + arg_string;
if constexpr (std::is_same_v<ParsedType, std::string>)
{
return (args.count(arg_string) > 0U) ? args[arg_string].as<std::string>()
: score::MakeUnexpected<ParsedType>(MakeError(
TestErrorCode::kParsingCommandLineArgumentFailed, error_msg));
}
if constexpr (std::is_integral_v<ParsedType>)
{
return (args.count(arg_string) > 0U) ? static_cast<ParsedType>(std::stoull(args[arg_string].as<std::string>()))
: score::MakeUnexpected<ParsedType>(MakeError(
TestErrorCode::kParsingCommandLineArgumentFailed, error_msg));
}
if constexpr (std::is_floating_point_v<ParsedType>)
{
return (args.count(arg_string) > 0U) ? static_cast<ParsedType>(std::stold(args[arg_string].as<std::string>()))
: score::MakeUnexpected<ParsedType>(MakeError(
TestErrorCode::kParsingCommandLineArgumentFailed, error_msg));
}

return score::MakeUnexpected<ParsedType>(
MakeError(TestErrorCode::kParsingCommandLineArgumentFailed,
"Only std::string, integral and floatin point types can be parsed as command line arguments!\n"));
}

auto ParseCommandLineArguments(int argc,
const char** argv,
const std::vector<std::pair<std::string, std::string>>& param_names)
-> boost::program_options::variables_map;

} // namespace score::mw::com::test
#endif // SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_COMMAND_LINE_PARSER_H
28 changes: 28 additions & 0 deletions score/mw/com/test/common_test_resources/fail_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/********************************************************************************
* 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
********************************************************************************/

#include "score/mw/com/test/common_test_resources/fail_test.h"

#include <iostream>

namespace score::mw::com::test::detail
{

void fail_test_(std::stringstream&& strstr)
{
strstr << "\033[0m \033[1m\033[41mTEST FAILED\033[0m\n";
std::cerr << std::move(strstr).str() << std::flush;
std::_Exit(EXIT_FAILURE);
}

} // namespace score::mw::com::test::detail
59 changes: 59 additions & 0 deletions score/mw/com/test/common_test_resources/fail_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/********************************************************************************
* 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
********************************************************************************/
#ifndef SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_FAIL_TEST_H
#define SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_FAIL_TEST_H

#include <sstream>

namespace score::mw::com::test
{

namespace detail
{
void fail_test_(std::stringstream&& strstr);

template <typename Start, typename... Tail>
void fail_test_(std::stringstream&& strstr, Start&& start, Tail&&... tail)
{
strstr << std::forward<Start>(start);
if constexpr (sizeof...(Tail) > 0U)
{
fail_test_(std::move(strstr), std::forward<Tail>(tail)...);
}
else
{
fail_test_(std::move(strstr));
}
}
} // namespace detail

template <typename... Args>
void fail_test(Args&&... args)
{
std::stringstream strstr;
strstr << "\033[1m\033[31m";
detail::fail_test_(std::move(strstr), std::forward<Args>(args)...);
}

template <typename... Args>
void fail_test_if(bool condition, Args&&... args)
{
if (condition)
{
fail_test(std::forward<Args>(args)...);
}
}

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

#endif // SCORE_MW_COM_TEST_COMMON_TEST_RESOURCES_FAIL_TEST_H
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ std::string_view score::mw::com::test::TestErrorDomain::MessageFor(const score::
return "Failed to create instance specifier.";
case score::mw::com::test::TestErrorCode::kCreateSkeletonFailed:
return "Failed to create skeleton.";
case score::mw::com::test::TestErrorCode::kParsingCommandLineArgumentFailed:
return "Failed to parse command line argument.";
default:
return "Unknown Error!";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum class TestErrorCode : score::result::ErrorCode
{
kCreateInstanceSpecifierFailed = 1,
kCreateSkeletonFailed = 2,
kParsingCommandLineArgumentFailed = 3,
};

class TestErrorDomain final : public score::result::ErrorDomain
Expand Down
4 changes: 4 additions & 0 deletions score/mw/com/test/methods/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ test_suite(
name = "component_tests",
tests = [
"//score/mw/com/test/methods/basic_acceptance_test:component_tests",
"//score/mw/com/test/methods/edge_cases_test:component_tests",
"//score/mw/com/test/methods/mixed_criticality:component_tests",
"//score/mw/com/test/methods/multiple_proxies:component_tests",
"//score/mw/com/test/methods/signature_variations:component_tests",
"//score/mw/com/test/methods/stop_offer_during_call:component_tests",
],
visibility = ["//score/mw/com/test:__pkg__"],
)
65 changes: 65 additions & 0 deletions score/mw/com/test/methods/edge_cases_test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# *******************************************************************************
# 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
# *******************************************************************************

load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES")
load("//score/mw/com/test:pkg_application.bzl", "pkg_application")

cc_library(
name = "test_method_datatype",
srcs = ["test_method_datatype.cpp"],
hdrs = ["test_method_datatype.h"],
features = COMPILER_WARNING_FEATURES,
visibility = [
"//score/mw/com/test/methods/edge_cases_test:__subpackages__",
],
deps = [
"//score/mw/com",
],
)

cc_binary(
name = "edge_cases_test",
srcs = ["edge_cases_test.cpp"],
data = ["config/mw_com_config.json"],
features = COMPILER_WARNING_FEATURES + [
"aborts_upon_exception",
],
deps = [
"//score/mw/com",
"//score/mw/com/test/common_test_resources:command_line_parser",
"//score/mw/com/test/common_test_resources:fail_test",
"//score/mw/com/test/common_test_resources:assert_handler",
"//score/mw/com/test/methods/edge_cases_test:test_method_datatype",
"//score/mw/com/test/methods/methods_test_resources:proxy_container",
"@score_baselibs//score/language/futurecpp",
],
)

pkg_application(
name = "edge-case-test-pkg",
app_name = "EdgeCasesTestApp",
bin = [":edge_cases_test"],
etc = [
"config/mw_com_config.json",
],
visibility = [
"//score/mw/com/test/methods/edge_cases_test/integration_test:__subpackages__",
],
)

test_suite(
name = "component_tests",
tests = [
"//score/mw/com/test/methods/edge_cases_test/integration_test:component_tests",
],
)
Loading
Loading