-
Notifications
You must be signed in to change notification settings - Fork 85
mw/com: Add methods integration tests #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
27e7a7f
2832a9a
60cbc88
6380cb2
dd28657
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # ******************************************************************************* | ||
| # 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_binary( | ||
| name = "disabled_method_test", | ||
| srcs = ["disabled_method_test.cpp"], | ||
| data = ["config/disabled_methods_mw_com_config.json"], | ||
| features = COMPILER_WARNING_FEATURES + [ | ||
| "aborts_upon_exception", | ||
| ], | ||
| deps = [ | ||
| "//score/mw/com", | ||
| "//score/mw/com/test/common_test_resources:assert_handler", | ||
| "//score/mw/com/test/common_test_resources:command_line_parser", | ||
| "//score/mw/com/test/common_test_resources:fail_test", | ||
| "//score/mw/com/test/methods/methods_test_resources:proxy_container", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype:all_signatures_method_provider", | ||
| "@score_baselibs//score/language/futurecpp", | ||
| ], | ||
| ) | ||
|
|
||
| cc_binary( | ||
| name = "incomplete_handlers_test", | ||
| srcs = ["incomplete_handlers_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:assert_handler", | ||
| "//score/mw/com/test/common_test_resources:fail_test", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype:all_signatures_method_provider", | ||
| "@score_baselibs//score/language/futurecpp", | ||
| ], | ||
| ) | ||
|
|
||
| cc_binary( | ||
| name = "proxy_recreation_test", | ||
| srcs = ["proxy_recreation_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:assert_handler", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype:all_signatures_method_consumer", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype:all_signatures_method_provider", | ||
| "@score_baselibs//score/language/futurecpp", | ||
| ], | ||
| ) | ||
|
|
||
| cc_binary( | ||
| name = "skeleton_recreation_test", | ||
| srcs = ["skeleton_recreation_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:assert_handler", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype:all_signatures_method_consumer", | ||
| "//score/mw/com/test/methods/methods_test_resources/all_signatures_datatype:all_signatures_method_provider", | ||
| "@score_baselibs//score/language/futurecpp", | ||
| ], | ||
| ) | ||
|
|
||
| pkg_application( | ||
| name = "edge-case-test-pkg", | ||
| app_name = "EdgeCasesTestApp", | ||
| bin = [ | ||
| ":disabled_method_test", | ||
| ":incomplete_handlers_test", | ||
| ":proxy_recreation_test", | ||
| ":skeleton_recreation_test", | ||
| ], | ||
| etc = [ | ||
| "config/disabled_methods_mw_com_config.json", | ||
| "config/mw_com_config.json", | ||
| ], | ||
| visibility = [ | ||
| "//score/mw/com/test/methods/edge_cases_test/integration_test:__subpackages__", | ||
| ], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| { | ||
| "serviceTypes": [ | ||
| { | ||
| "serviceTypeName": "/test/methods/edge_cases_test/MethodSignature", | ||
| "version": { | ||
| "major": 1, | ||
| "minor": 0 | ||
| }, | ||
| "bindings": [ | ||
| { | ||
| "binding": "SHM", | ||
| "serviceId": 2000, | ||
| "methods": [ | ||
| { | ||
| "methodName": "with_in_args_and_return", | ||
| "methodId": 1 | ||
| }, | ||
| { | ||
| "methodName": "with_in_args_only", | ||
| "methodId": 2 | ||
| }, | ||
| { | ||
| "methodName": "with_return_only", | ||
| "methodId": 3 | ||
| }, | ||
| { | ||
| "methodName": "without_args_or_return", | ||
| "methodId": 4 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "serviceInstances": [ | ||
| { | ||
| "instanceSpecifier": "test/methods/edge_cases_test/MethodSignature", | ||
| "serviceTypeName": "/test/methods/edge_cases_test/MethodSignature", | ||
| "version": { | ||
| "major": 1, | ||
| "minor": 0 | ||
| }, | ||
| "instances": [ | ||
| { | ||
| "instanceId": 1, | ||
| "asil-level": "B", | ||
| "binding": "SHM", | ||
| "methods": [ | ||
| { | ||
| "methodName": "with_in_args_and_return", | ||
| "queueSize": 1, | ||
| "use": false | ||
| }, | ||
| { | ||
| "methodName": "with_in_args_only", | ||
| "queueSize": 1, | ||
| "use": false | ||
| }, | ||
| { | ||
| "methodName": "with_return_only", | ||
| "queueSize": 1, | ||
| "use": false | ||
| }, | ||
| { | ||
| "methodName": "without_args_or_return", | ||
| "queueSize": 1, | ||
| "use": false | ||
| } | ||
| ], | ||
| "allowedConsumer": { | ||
| "QM": [ | ||
| 0 | ||
| ], | ||
| "B": [ | ||
| 0 | ||
| ] | ||
| }, | ||
| "allowedProvider": { | ||
| "QM": [ | ||
| 0 | ||
| ], | ||
| "B": [ | ||
| 0 | ||
| ] | ||
| } | ||
|
|
||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "global": { | ||
| "asil-level": "B" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| { | ||
| "serviceTypes": [ | ||
| { | ||
| "serviceTypeName": "/test/methods/edge_cases_test/MethodSignature", | ||
| "version": { | ||
| "major": 1, | ||
| "minor": 0 | ||
| }, | ||
| "bindings": [ | ||
| { | ||
| "binding": "SHM", | ||
| "serviceId": 2000, | ||
| "methods": [ | ||
| { | ||
| "methodName": "with_in_args_and_return", | ||
| "methodId": 1 | ||
| }, | ||
| { | ||
| "methodName": "with_in_args_only", | ||
| "methodId": 2 | ||
| }, | ||
| { | ||
| "methodName": "with_return_only", | ||
| "methodId": 3 | ||
| }, | ||
| { | ||
| "methodName": "without_args_or_return", | ||
| "methodId": 4 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "serviceInstances": [ | ||
| { | ||
| "instanceSpecifier": "test/methods/edge_cases_test/MethodSignature", | ||
| "serviceTypeName": "/test/methods/edge_cases_test/MethodSignature", | ||
| "version": { | ||
| "major": 1, | ||
| "minor": 0 | ||
| }, | ||
| "instances": [ | ||
| { | ||
| "instanceId": 1, | ||
| "asil-level": "B", | ||
| "binding": "SHM", | ||
| "methods": [ | ||
| { | ||
| "methodName": "with_in_args_and_return", | ||
| "queueSize": 1 | ||
| }, | ||
| { | ||
| "methodName": "with_in_args_only", | ||
| "queueSize": 1 | ||
| }, | ||
| { | ||
| "methodName": "with_return_only", | ||
| "queueSize": 1 | ||
| }, | ||
| { | ||
| "methodName": "without_args_or_return", | ||
| "queueSize": 1 | ||
| } | ||
| ], | ||
| "allowedConsumer": { | ||
| "QM": [ | ||
| 0 | ||
| ], | ||
| "B": [ | ||
| 0 | ||
| ] | ||
| }, | ||
| "allowedProvider": { | ||
| "QM": [ | ||
| 0 | ||
| ], | ||
| "B": [ | ||
| 0 | ||
| ] | ||
| } | ||
|
|
||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "global": { | ||
| "asil-level": "B" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||
| /******************************************************************************** | ||||
| * 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/runtime.h" | ||||
| #include "score/mw/com/test/common_test_resources/assert_handler.h" | ||||
| #include "score/mw/com/test/common_test_resources/command_line_parser.h" | ||||
| #include "score/mw/com/test/common_test_resources/fail_test.h" | ||||
| #include "score/mw/com/test/methods/methods_test_resources/all_signatures_datatype/all_signatures_datatype.h" | ||||
| #include "score/mw/com/test/methods/methods_test_resources/all_signatures_datatype/all_signatures_method_provider.h" | ||||
| #include "score/mw/com/test/methods/methods_test_resources/proxy_container.h" | ||||
|
|
||||
| #include <cstdint> | ||||
| #include <cstdlib> | ||||
| #include <iostream> | ||||
| #include <string> | ||||
|
|
||||
| namespace score::mw::com::test | ||||
| { | ||||
| namespace | ||||
| { | ||||
|
|
||||
| const InstanceSpecifier kInstanceSpecifier = | ||||
| InstanceSpecifier::Create(std::string{"test/methods/edge_cases_test/MethodSignature"}).value(); | ||||
| const std::string kFailureMessagePrefix{"disabled_method_test"}; | ||||
|
|
||||
| const std::string kServiceInstanceManifest{"service-instance-manifest"}; | ||||
|
|
||||
| constexpr std::int32_t kReturnOnlyMethodReturnValue{15}; | ||||
| constexpr std::int32_t kInArgOnlyMethodTestValueA{17}; | ||||
| constexpr std::int32_t kInArgOnlyMethodTestValueB{18}; | ||||
|
|
||||
| constexpr std::int32_t kTestValueA{10}; | ||||
| constexpr std::int32_t kTestValueB{20}; | ||||
|
|
||||
| std::string ParseServiceInstanceManifest(int argc, const char** argv) | ||||
| { | ||||
| auto args = ParseCommandLineArguments(argc, argv, {{kServiceInstanceManifest, ""}}); | ||||
| return {GetValue<std::string>(args, kServiceInstanceManifest)}; | ||||
| } | ||||
|
|
||||
| template <typename ResultType> | ||||
| void FailIfMethodCallDidNotFail(const std::string& method_name, const ResultType& call_result) | ||||
| { | ||||
| if (call_result.has_value()) | ||||
| { | ||||
| FailTest(kFailureMessagePrefix, " Consumer: ", method_name, " unexpectedly succeeded."); | ||||
| return; | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| } | ||||
|
|
||||
| std::cout << "Consumer: " << method_name << " failed as expected: " << call_result.error() << std::endl; | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically we would need to disambiguate at call_result.error(). |
||||
| } | ||||
|
|
||||
| void RunDisabledMethodTest() | ||||
| { | ||||
| std::cout << "\n=== Disabled methods return errors ===" << std::endl; | ||||
|
|
||||
| std::cout << "\nProvider: Step 1: Create skeleton" << std::endl; | ||||
| AllSignaturesMethodProvider provider{}; | ||||
| provider.CreateSkeleton(kInstanceSpecifier, kFailureMessagePrefix); | ||||
|
|
||||
| std::cout << "\nProvider: Step 2: Register method handlers" << std::endl; | ||||
| provider.RegisterMethodHandlerWithInArgsAndReturn(kFailureMessagePrefix); | ||||
| provider.RegisterMethodHandlerWithInArgsOnly( | ||||
| kInArgOnlyMethodTestValueA, kInArgOnlyMethodTestValueB, kFailureMessagePrefix); | ||||
| provider.RegisterMethodHandlerWithReturnOnly(kReturnOnlyMethodReturnValue, kFailureMessagePrefix); | ||||
| provider.RegisterWithoutInArgsOrReturn(kFailureMessagePrefix); | ||||
|
|
||||
| std::cout << "\nProvider: Step 3: Offer Service" << std::endl; | ||||
| provider.OfferService(kFailureMessagePrefix); | ||||
|
|
||||
| std::cout << "\nConsumer: Step 4: Find service and create proxy" << std::endl; | ||||
| ProxyContainer<AllSignaturesProxy> proxy_container{}; | ||||
| proxy_container.CreateProxy(kInstanceSpecifier, kFailureMessagePrefix); | ||||
| auto& proxy = proxy_container.GetProxy(); | ||||
|
|
||||
| std::cout << "\nConsumer: Step 5: Call methods which have been disabled in the C++ interface" << std::endl; | ||||
| FailIfMethodCallDidNotFail("with_in_args_and_return", proxy.with_in_args_and_return(kTestValueA, kTestValueB)); | ||||
| FailIfMethodCallDidNotFail("with_in_args_only", proxy.with_in_args_only(kTestValueA, kTestValueB)); | ||||
| FailIfMethodCallDidNotFail("with_return_only", proxy.with_return_only()); | ||||
| FailIfMethodCallDidNotFail("without_args_or_return", proxy.without_args_or_return()); | ||||
|
|
||||
| std::cout << "=== Disabled method test: PASSED ===" << std::endl; | ||||
| } | ||||
|
|
||||
| } // namespace | ||||
| } // namespace score::mw::com::test | ||||
|
|
||||
| int main(int argc, const char** argv) | ||||
| { | ||||
| const auto service_instance_manifest = score::mw::com::test::ParseServiceInstanceManifest(argc, argv); | ||||
|
|
||||
| score::mw::com::test::SetupAssertHandler(); | ||||
| score::mw::com::runtime::InitializeRuntime( | ||||
| score::mw::com::runtime::RuntimeConfiguration{service_instance_manifest}); | ||||
|
|
||||
| score::mw::com::test::RunDisabledMethodTest(); | ||||
| return EXIT_SUCCESS; | ||||
| } | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nitpick, but the name has too much logic in it. Maybe name it sth without a negation, like FailOnUnexpectedSuccess?