diff --git a/Android.bp b/Android.bp index 931a180d4..f6e958bfe 100644 --- a/Android.bp +++ b/Android.bp @@ -74,7 +74,7 @@ cc_library_shared { cflags: [ "-DWITHOUT_SYSTEMD", - "-DVSOMEIP_VERSION=\"3.6.3\"", + "-DVSOMEIP_VERSION=\"3.6.4\"", "-DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\"", ], diff --git a/Android.mk b/Android.mk index f2fa9b053..f89ff8959 100644 --- a/Android.mk +++ b/Android.mk @@ -100,7 +100,7 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.6.3\" \ + -DVSOMEIP_VERSION=\"3.6.4\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ @@ -159,7 +159,7 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.6.3\" \ + -DVSOMEIP_VERSION=\"3.6.4\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ diff --git a/CHANGES b/CHANGES index 1f2a3d8fc..3cab2e070 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,43 @@ Changes ======= +v3.6.4 +- global + - improve logging + - add defaults to CMakePresets + - scoped lock all recursive mutexes + - remove unused definitions + - cleanup exported symbols + - pragma once the entire codebase + - debouncing drop send_current_value_after + - fix internal.hpp with ANDROID_CI_BUILD flag + +- application + - fix plugin_manager_impl singleton free-after-use on dtor bug + +- endpoints + - refactor local_endpoint::start + - drop prepare_stop + - fix data race when calling get_local_port() + - fix delayed availability + +- routing + - send initial event on every sub + - fix missing find on resume + +- tests + - general test speedups + - remove valgrind trace-children-skip + - stop routing app last + - extend helpers to simulate suspend + - enable ctest -R for fake socket tests + - fix offer_test_local race condition + - fix usei_fixture.no_overwrite + - fix someip_tp_tests + - fix block_registration_process + - rewrite process_manager + - new subscribe_before_register test + - new shutdown_test for IPC + v3.6.3 - global - rework shutdown to simplify thread detach mechanism diff --git a/CMakeLists.txt b/CMakeLists.txt index ad31d7842..3f87a1df4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set (VSOMEIP_NAME vsomeip3) set (VSOMEIP_MAJOR_VERSION 3) set (VSOMEIP_MINOR_VERSION 6) -set (VSOMEIP_PATCH_VERSION 3) +set (VSOMEIP_PATCH_VERSION 4) set (VSOMEIP_HOTFIX_VERSION 0) set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION}) @@ -120,11 +120,22 @@ endif () if (NOT MSVC) # Sanitizers if (ENABLE_SANITIZERS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined") + set(flags "-fno-omit-frame-pointer -fsanitize=address -fsanitize=leak -fsanitize=undefined -pthread") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flags}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags}") + set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${flags}") endif () if (ENABLE_THREAD_SANITIZER) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=thread -pthread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=thread -pthread") + set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread -pthread") + endif () + + if (ENABLE_SANITIZERS OR ENABLE_THREAD_SANITIZER) + # force RPATH instead of RUNPATH + # see https://stackoverflow.com/questions/53286707/why-would-runpath-be-ignored, *sans cause issues! + SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags") endif () if (ENABLE_PROFILING) @@ -278,6 +289,8 @@ else() set(USE_RT "rt") endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + ################################################################################ # Configuration library ################################################################################ @@ -286,10 +299,14 @@ file(GLOB ${VSOMEIP_NAME}-cfg_SRC ) list(SORT ${VSOMEIP_NAME}-cfg_SRC) if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 0) - add_library(${VSOMEIP_NAME}-cfg SHARED ${${VSOMEIP_NAME}-cfg_SRC}) + add_library(${VSOMEIP_NAME}-cfg-internal OBJECT ${${VSOMEIP_NAME}-cfg_SRC}) + target_link_libraries(${VSOMEIP_NAME}-cfg-internal ${VSOMEIP_NAME}-internal ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES}) + + add_library(${VSOMEIP_NAME}-cfg SHARED $) set_target_properties (${VSOMEIP_NAME}-cfg PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) target_compile_features(${VSOMEIP_NAME}-cfg PRIVATE cxx_std_17) if (MSVC) + set_target_properties(${VSOMEIP_NAME}-cfg-internal PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") set_target_properties(${VSOMEIP_NAME}-cfg PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") endif() @@ -321,20 +338,28 @@ endif() list(SORT ${VSOMEIP_NAME}_SRC) -add_library(${VSOMEIP_NAME} SHARED ${${VSOMEIP_NAME}_SRC}) -set_target_properties (${VSOMEIP_NAME} PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) +# internal object library, all symbols exposed, used for testing +add_library(${VSOMEIP_NAME}-internal OBJECT ${${VSOMEIP_NAME}_SRC}) +target_link_libraries(${VSOMEIP_NAME}-internal ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${DLT_LIBRARIES} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + +add_library(${VSOMEIP_NAME} SHARED $) +# libvsomeip also `dlopens` other libs (cfg, sd, ..) so leave a rpath hint +set_target_properties(${VSOMEIP_NAME} PROPERTIES BUILD_RPATH "${CMAKE_BINARY_DIR}") +set_target_properties(${VSOMEIP_NAME} PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) target_compile_features(${VSOMEIP_NAME} PRIVATE cxx_std_17) if (MSVC) + set_target_properties(${VSOMEIP_NAME}-internal PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION") + set_target_properties(${VSOMEIP_NAME}-internal PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) set_target_properties(${VSOMEIP_NAME} PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION") set_target_properties(${VSOMEIP_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) else () - if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") - # add syscall wrappers to deal with CLOEXEC - set_target_properties(${VSOMEIP_NAME} PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open") - else () - # add syscall wrappers to deal with CLOEXEC + react on certain errors - set_target_properties(${VSOMEIP_NAME} PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open -Wl,-wrap,close -Wl,-wrap,recvfrom -Wl,-wrap,recvmsg -Wl,-wrap,sendto -Wl,-wrap,sendmsg -Wl,-wrap,epoll_wait -Wl,-wrap,epoll_pwait") - endif () + if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + # add syscall wrappers to deal with CLOEXEC + set_target_properties(${VSOMEIP_NAME} PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open") + else () + # add syscall wrappers to deal with CLOEXEC + react on certain errors + set_target_properties(${VSOMEIP_NAME} PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open -Wl,-wrap,close -Wl,-wrap,recvfrom -Wl,-wrap,recvmsg -Wl,-wrap,sendto -Wl,-wrap,sendmsg -Wl,-wrap,epoll_wait -Wl,-wrap,epoll_pwait") + endif () endif () target_include_directories(${VSOMEIP_NAME} INTERFACE $ @@ -359,10 +384,14 @@ file(GLOB ${VSOMEIP_NAME}-sd_SRC ) list(SORT ${VSOMEIP_NAME}-sd_SRC) -add_library(${VSOMEIP_NAME}-sd SHARED ${${VSOMEIP_NAME}-sd_SRC}) +add_library(${VSOMEIP_NAME}-sd-internal OBJECT ${${VSOMEIP_NAME}-sd_SRC}) +target_link_libraries(${VSOMEIP_NAME}-sd-internal ${VSOMEIP_NAME}-internal ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + +add_library(${VSOMEIP_NAME}-sd SHARED $) target_compile_features(${VSOMEIP_NAME}-sd PRIVATE cxx_std_17) set_target_properties (${VSOMEIP_NAME}-sd PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) if (MSVC) + set_target_properties(${VSOMEIP_NAME}-sd-internal PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") set_target_properties(${VSOMEIP_NAME}-sd PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") endif () @@ -377,10 +406,14 @@ file(GLOB_RECURSE ${VSOMEIP_NAME}-e2e_SRC ) list(SORT ${VSOMEIP_NAME}-e2e_SRC) -add_library(${VSOMEIP_NAME}-e2e SHARED ${${VSOMEIP_NAME}-e2e_SRC}) +add_library(${VSOMEIP_NAME}-e2e-internal OBJECT ${${VSOMEIP_NAME}-e2e_SRC}) +target_link_libraries(${VSOMEIP_NAME}-e2e-internal ${VSOMEIP_NAME}-internal ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES}) + +add_library(${VSOMEIP_NAME}-e2e SHARED $) target_compile_features(${VSOMEIP_NAME}-e2e PRIVATE cxx_std_17) set_target_properties (${VSOMEIP_NAME}-e2e PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) if (MSVC) + set_target_properties(${VSOMEIP_NAME}-e2e-internal PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") set_target_properties(${VSOMEIP_NAME}-e2e PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") endif () @@ -524,11 +557,12 @@ configure_file (${VSOMEIP_NAME}Config.cmake.in "${PROJECT_BINARY_DIR}/${VSOMEIP_ configure_file (${VSOMEIP_NAME}ConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}ConfigVersion.cmake" @ONLY) # configure internal.hpp for correct version number +if(NOT ANDROID_CI_BUILD) configure_file ( "${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp.in" "${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp" ) - +endif () # Install the ${VSOMEIP_NAME}Config.cmake and ${VSOMEIP_NAME}ConfigVersion.cmake install ( FILES @@ -602,6 +636,8 @@ add_subdirectory( examples/routingmanagerd ) add_subdirectory( examples/hello_world ) endif() +add_subdirectory( examples/wait-until-available ) + # build tools add_custom_target( tools ) add_subdirectory( tools/vsomeip_ctrl ) @@ -614,6 +650,8 @@ add_subdirectory( examples EXCLUDE_FROM_ALL ) # add test directory enable_testing() +option(WITH_TEST_DISCOVERY "Enables ctest regex selection of single test cases" OFF) + add_subdirectory( test EXCLUDE_FROM_ALL ) if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") diff --git a/CMakePresets.json b/CMakePresets.json index c7061c700..0bf184571 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -43,7 +43,7 @@ }, "CMAKE_CXX_FLAGS_INIT": { "type": "STRING", - "value": "--coverage -Wno-error=tsan -fprofile-update=atomic" + "value": "--coverage -fprofile-update=atomic" }, "TEST_IP_SLAVE_SECOND": { "type": "STRING", @@ -89,7 +89,6 @@ "displayName": "Network tests (CI)", "description": "Preset for network tests on CI", "environment": { - "LD_LIBRARY_PATH": "/home/build", "LXC_TEST_MASTER_IP": "master", "LXC_TEST_SLAVE_IP": "slave", "TSAN_OPTIONS": "suppressions=${sourceDir}/test/tsan-suppressions.txt", @@ -99,7 +98,19 @@ "output": { "maxFailedTestOutputSize": 1e9, "maxPassedTestOutputSize": 1e9, - "outputOnFailure": true + "outputOnFailure": true, + "verbosity": "default" + }, + "execution": { + "repeat": { + "mode": "until-fail", + "count": 1 + } + }, + "filter": { + "include": { + "name": "^" + } } } ] diff --git a/documentation/vsomeipConfiguration.md b/documentation/vsomeipConfiguration.md index 30cbc41bc..98244c58f 100644 --- a/documentation/vsomeipConfiguration.md +++ b/documentation/vsomeipConfiguration.md @@ -1598,7 +1598,6 @@ Debounce time for requests to the service on 192.168.1.9 should have a: - **mask** - 1 Byte bitmask applied to byte at given payload index. **Example mask**: 0x0f ignores payload changes in low nibble of the byte at given index. - **interval** - Specifies if the event shall be debounced based on elapsed time interval. (valid values: `time in ms`, `never`). The default value is `never`. - **on_change_resets_interval** (optional) - Specifies if interval timer is reset when payload change was detected, valid values are `false`, `true`. The default value is `false`. - - **send_current_value_after** (optional) - Specifies if last message should be sent after interval timeout, valid values are `false`, `true`. The default value is `false`.
Debounce configuration diff --git a/examples/routingmanagerd/CMakeLists.txt b/examples/routingmanagerd/CMakeLists.txt index 438604c82..ea068cd40 100644 --- a/examples/routingmanagerd/CMakeLists.txt +++ b/examples/routingmanagerd/CMakeLists.txt @@ -12,7 +12,7 @@ endif() if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(routingmanagerd socket) endif() -add_dependencies(routingmanagerd ${VSOMEIP_NAME}) +add_dependencies(routingmanagerd ${VSOMEIP_NAME} ${VSOMEIP_NAME}-cfg ${VSOMEIP_NAME}-sd ${VSOMEIP_NAME}-e2e) option(VSOMEIP_INSTALL_ROUTINGMANAGERD "Whether or not to install the routing manager daemon.") diff --git a/examples/sample-ids.hpp b/examples/sample-ids.hpp index 3f1415cb3..8557a7a0a 100644 --- a/examples/sample-ids.hpp +++ b/examples/sample-ids.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP -#define VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP +#pragma once #define SAMPLE_SERVICE_ID 0x1234 #define SAMPLE_INSTANCE_ID 0x5678 @@ -19,5 +18,3 @@ #define OTHER_SAMPLE_SERVICE_ID 0x0248 #define OTHER_SAMPLE_INSTANCE_ID 0x5422 #define OTHER_SAMPLE_METHOD_ID 0x1421 - -#endif // VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP diff --git a/examples/wait-until-available/CMakeLists.txt b/examples/wait-until-available/CMakeLists.txt new file mode 100644 index 000000000..a5e00d6ed --- /dev/null +++ b/examples/wait-until-available/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +add_executable(wait-until-available wait-until-available.cpp) +target_link_libraries(wait-until-available ${VSOMEIP_NAME}) +add_dependencies(wait-until-available ${VSOMEIP_NAME}) diff --git a/examples/wait-until-available/wait-until-available.cpp b/examples/wait-until-available/wait-until-available.cpp new file mode 100644 index 000000000..758de521e --- /dev/null +++ b/examples/wait-until-available/wait-until-available.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include +#include +#include +#include +#include + +#include + +void print_help() { + std::cout << "Usage: wait-until-available [-h|--help][-t|--timeout ]" << std::endl; + std::cout << " Service to wait for, in hex" << std::endl; + std::cout << " -t, --timeout Timeout in seconds (default: 10)" << std::endl; + std::cout << " -h, --help Show this help message" << std::endl; +} + +int main(int argc, char** argv) { + vsomeip::service_t service_id = 0; + std::chrono::seconds timeout = std::chrono::seconds(10); + + if (argc < 2) { + print_help(); + return EXIT_FAILURE; + } + + for (int i = 1; i < argc; i++) { + std::string arg(argv[i]); + if (arg == "-h" || arg == "--help") { + print_help(); + return EXIT_SUCCESS; + } else if (i == 1) { + // parse service-id + try { + service_id = static_cast(std::stoul(arg, nullptr, 16)); + } catch (...) { + std::cerr << "Error: could not parse service-id '" << arg << "'" << std::endl; + print_help(); + return EXIT_FAILURE; + } + } else if (arg == "-t" || arg == "--timeout") { + if (i + 1 < argc) { + timeout = std::chrono::seconds(std::stoul(argv[++i])); + } else { + std::cerr << "Error: --timeout requires a value" << std::endl; + print_help(); + return EXIT_FAILURE; + } + } else { + std::cerr << "Error: unknown argument '" << arg << "'" << std::endl; + print_help(); + return EXIT_FAILURE; + } + } + + std::shared_ptr app = vsomeip::runtime::get()->create_application("wait-until-available"); + if (!app->init()) { + std::cerr << "Couldn't initialize application" << std::endl; + return EXIT_FAILURE; + } + + std::promise availability_promise; + std::future availability_future = availability_promise.get_future(); + app->register_availability_handler( + service_id, vsomeip::ANY_INSTANCE, + [&availability_promise](vsomeip::service_t /*_service*/, vsomeip::instance_t _instance, bool _is_available) { + if (_instance != vsomeip::ANY_INSTANCE && _is_available) { + try { + availability_promise.set_value(true); + } catch (...) { + // in case there is a "double" available; avoids the "promise already satisfied" exception + } + } + }); + app->request_service(service_id, vsomeip::ANY_INSTANCE); + + std::thread app_thread([app]() { app->start(); }); + + bool available = (availability_future.wait_for(timeout) == std::future_status::ready); + std::cout << "Service [" << std::hex << std::setfill('0') << std::setw(4) << service_id << "] is " + << (available ? "available" : "NOT available") << std::endl; + + app->stop(); + app_thread.join(); + return available ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/exportmap.gcc b/exportmap.gcc index 3bf93f94b..67904355c 100644 --- a/exportmap.gcc +++ b/exportmap.gcc @@ -3,40 +3,20 @@ global: extern "C++" { *vsomeip_v3::configuration; vsomeip_v3::configuration::*; - *vsomeip_v3::cfg::configuration_impl; - vsomeip_v3::cfg::configuration_impl::*; *vsomeip_v3::serializer; vsomeip_v3::serializer::*; *vsomeip_v3::deserializer; vsomeip_v3::deserializer::*; - *vsomeip_v3::e2e::e2e_provider_impl; - vsomeip_v3::e2e::e2e_provider_impl::*; *vsomeip_v3::endpoint_definition; vsomeip_v3::endpoint_definition*; - *vsomeip_v3::tcp*; - vsomeip_v3::tcp*; - *vsomeip_v3::udp*; - vsomeip_v3::udp*; - *vsomeip_v3::message_base_impl; - *vsomeip_v3::message_base_impl::*; - *vsomeip_v3::message_header_impl; - *vsomeip_v3::message_header_impl::*; - *vsomeip_v3::payload_impl; - *vsomeip_v3::payload_impl::*; *vsomeip_v3::policy; vsomeip_v3::policy::*; *vsomeip_v3::policy_manager; vsomeip_v3::policy_manager::*; - *vsomeip_v3::policy_manager_impl; - vsomeip_v3::policy_manager_impl::*; - *vsomeip_v3::routing_manager_impl; - vsomeip_v3::routing_manager_impl::*; vsomeip_v3::security::*; *vsomeip_v3::runtime; vsomeip_v3::runtime::get*; vsomeip_v3::runtime::set_property*; - *vsomeip_v3::application_impl; - vsomeip_v3::application_impl*; *vsomeip_v3::event; vsomeip_v3::event::*; *vsomeip_v3::eventgroupinfo; @@ -47,24 +27,37 @@ global: vsomeip_v3::serviceinfo::*; *vsomeip_v3::sd::runtime; vsomeip_v3::sd::runtime::*; - *vsomeip_v3::utility; - vsomeip_v3::utility::is*; - vsomeip_v3::utility::data*; - vsomeip_v3::utility::re*; - vsomeip_v3::utility::get_*; - vsomeip_v3::utility::exists*; *vsomeip_v3::plugin_manager; vsomeip_v3::plugin_manager::*; vsomeip_v3::tp::tp_reassembler::*; *vsomeip_v3::logger::message; vsomeip_v3::logger::message::*; - *vsomeip_v3::logger::logger_impl; - vsomeip_v3::logger::logger_impl::*; vsomeip::runtime::*; *vsomeip::runtime; vsomeip::logger::*; *vsomeip::logger; - vsomeip_v3::set_abstract_factory*; + /* libvsomeip-cfg directly uses logger/policy/utils from libvsomeip */ + /* TODO: FIXME! */ + *vsomeip_v3::policy_manager_impl; + vsomeip_v3::policy_manager_impl::*; + *vsomeip_v3::logger::logger_impl; + vsomeip_v3::logger::logger_impl::init*; + *vsomeip_v3::utility; + vsomeip_v3::utility::is*; + /* libvsomeip-sd directly uses message* and tsei/usei impl from libvsomeip */ + /* TODO: FIXME! */ + *vsomeip_v3::message_base_impl; + *vsomeip_v3::message_base_impl::*; + *vsomeip_v3::message_header_impl; + *vsomeip_v3::message_header_impl::*; + *vsomeip_v3::payload_impl; + *vsomeip_v3::payload_impl::*; + *vsomeip_v3::tcp_server_endpoint_impl; + vsomeip_v3::tcp_server_endpoint_impl::is_established_to*; + *vsomeip_v3::udp_server_endpoint_impl; + vsomeip_v3::udp_server_endpoint_impl::is_joined*; + vsomeip_v3::udp_server_endpoint_impl::join*; + vsomeip_v3::udp_server_endpoint_impl::leave*; }; vsomeip_plugin_init; local: diff --git a/implementation/configuration/include/application_configuration.hpp b/implementation/configuration/include/application_configuration.hpp index 285a16c4f..916d147be 100644 --- a/implementation/configuration/include/application_configuration.hpp +++ b/implementation/configuration/include/application_configuration.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_APPLICATION_CONFIGURATION_HPP_ -#define VSOMEIP_V3_CFG_APPLICATION_CONFIGURATION_HPP_ +#pragma once #include #include @@ -34,5 +33,3 @@ struct application_configuration { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_APPLICATION_CONFIGURATION_HPP_ diff --git a/implementation/configuration/include/client.hpp b/implementation/configuration/include/client.hpp index dbf79f206..b6780a296 100644 --- a/implementation/configuration/include/client.hpp +++ b/implementation/configuration/include/client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_CLIENT_HPP -#define VSOMEIP_V3_CFG_CLIENT_HPP +#pragma once #include #include @@ -32,5 +31,3 @@ struct client { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_CLIENT_HPP diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index d2e53e82b..f799dd761 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CONFIGURATION_HPP -#define VSOMEIP_V3_CONFIGURATION_HPP +#pragma once #include #include @@ -329,5 +328,3 @@ struct port_range_t { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CONFIGURATION_HPP diff --git a/implementation/configuration/include/configuration_element.hpp b/implementation/configuration/include/configuration_element.hpp index 7d9c62496..5fa9082b7 100644 --- a/implementation/configuration/include/configuration_element.hpp +++ b/implementation/configuration/include/configuration_element.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CONFIGURATION_CONFIGURATION_ELEMENT_HPP_ -#define VSOMEIP_V3_CONFIGURATION_CONFIGURATION_ELEMENT_HPP_ +#pragma once #include @@ -24,5 +23,3 @@ struct configuration_element { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CONFIGURATION_CONFIGURATION_ELEMENT_HPP_ diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index fac48b4cd..96fce8ad4 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP -#define VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP +#pragma once #include #include @@ -657,5 +656,3 @@ class configuration_impl : public configuration, public std::enable_shared_from_ } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP diff --git a/implementation/configuration/include/configuration_plugin.hpp b/implementation/configuration/include/configuration_plugin.hpp index b9a8426b6..cafc94a62 100644 --- a/implementation/configuration/include/configuration_plugin.hpp +++ b/implementation/configuration/include/configuration_plugin.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CONFIGURATION_PLUGIN_HPP_ -#define VSOMEIP_V3_CONFIGURATION_PLUGIN_HPP_ +#pragma once #include #include @@ -23,5 +22,3 @@ class configuration_plugin { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CONFIGURATION_PLUGIN_HPP_ diff --git a/implementation/configuration/include/configuration_plugin_impl.hpp b/implementation/configuration/include/configuration_plugin_impl.hpp index 3ccdbb44e..8ee2b7de3 100644 --- a/implementation/configuration/include/configuration_plugin_impl.hpp +++ b/implementation/configuration/include/configuration_plugin_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ -#define VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ +#pragma once #include #include @@ -34,5 +33,3 @@ class configuration_plugin_impl : public configuration_plugin, public plugin_imp }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ diff --git a/implementation/configuration/include/debounce_filter_impl.hpp b/implementation/configuration/include/debounce_filter_impl.hpp index 3ab77e5e0..b40944f95 100644 --- a/implementation/configuration/include/debounce_filter_impl.hpp +++ b/implementation/configuration/include/debounce_filter_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_DEBOUNCE_HPP -#define VSOMEIP_V3_DEBOUNCE_HPP +#pragma once #include @@ -27,5 +26,3 @@ struct debounce_filter_impl_t : debounce_filter_t { using debounce_configuration_t = service_instance_map>>; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_DEBOUNCE_HPP diff --git a/implementation/configuration/include/e2e.hpp b/implementation/configuration/include/e2e.hpp index e9687be71..4dc216979 100644 --- a/implementation/configuration/include/e2e.hpp +++ b/implementation/configuration/include/e2e.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_E2E_HPP_ -#define VSOMEIP_V3_CFG_E2E_HPP_ +#pragma once #include #include @@ -36,5 +35,3 @@ struct e2e { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_E2E_HPP_ diff --git a/implementation/configuration/include/event.hpp b/implementation/configuration/include/event.hpp index aaba595f6..0de2ec99e 100644 --- a/implementation/configuration/include/event.hpp +++ b/implementation/configuration/include/event.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_EVENT_HPP -#define VSOMEIP_V3_CFG_EVENT_HPP +#pragma once #include #include @@ -34,5 +33,3 @@ struct event { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_EVENT_HPP diff --git a/implementation/configuration/include/eventgroup.hpp b/implementation/configuration/include/eventgroup.hpp index 5de0d0db1..276e213c1 100644 --- a/implementation/configuration/include/eventgroup.hpp +++ b/implementation/configuration/include/eventgroup.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_EVENTGROUP_HPP -#define VSOMEIP_V3_CFG_EVENTGROUP_HPP +#pragma once #include @@ -25,5 +24,3 @@ struct eventgroup { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_EVENTGROUP_HPP diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in index adc7c9eda..4f41672c2 100644 --- a/implementation/configuration/include/internal.hpp.in +++ b/implementation/configuration/include/internal.hpp.in @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_INTERNAL_HPP_ -#define VSOMEIP_V3_INTERNAL_HPP_ +#pragma once #include #include @@ -29,7 +28,6 @@ "vsomeip_portcfg.json,vsomeip_device.json" #define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "@DEFAULT_CONFIGURATION_FOLDER@" -#define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" #define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip" #define VSOMEIP_BASE_PATH "@VSOMEIP_BASE_PATH@/" @@ -78,7 +76,6 @@ #define VSOMEIP_DEFAULT_CONNECT_TIMEOUT 100 #define VSOMEIP_MAX_CONNECT_TIMEOUT 1600 #define VSOMEIP_DEFAULT_CONNECTING_TIMEOUT 500 -#define VSOMEIP_DEFAULT_FLUSH_TIMEOUT 1000 #define VSOMEIP_ROUTING_ROOT_RECONNECT_RETRIES 10000 #define VSOMEIP_ROUTING_ROOT_RECONNECT_INTERVAL 10 // miliseconds @@ -94,8 +91,6 @@ #define VSOMEIP_MAX_TCP_SENT_WAIT_TIME 10000 #define VSOMEIP_TCP_USER_TIMEOUT 3000 -#define VSOMEIP_MAX_NETLINK_RETRIES 3 - #define VSOMEIP_TP_MAX_SEGMENT_LENGTH_DEFAULT 1392 #define VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD 5 @@ -113,8 +108,6 @@ #define VSOMEIP_DEFAULT_MAX_DISPATCH_TIME 100 #define VSOMEIP_DEFAULT_MAX_DISPATCHERS 10 -#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 3 - #define VSOMEIP_REQUEST_DEBOUNCE_TIME 10 #define VSOMEIP_DEFAULT_STATISTICS_MAX_MSG 50 #define VSOMEIP_DEFAULT_STATISTICS_MIN_FREQ 50 @@ -146,18 +139,12 @@ #define VSOMEIP_DEFAULT_TCP_KEEPINTVL 1 #define VSOMEIP_DEFAULT_TCP_KEEPCNT 3 -#define MIN_ENDPOINT_WAIT_INTERVAL 10 -#define MAX_ENDPOINT_WAIT_INTERVAL 160 -#define SUM_ENDPOINT_WAIT_INTERVAL 500 - #if defined(__linux__) || defined(__QNX__) #include #endif -#define VSOMEIP_DATA_ID 0x677D #define VSOMEIP_DIAGNOSIS_ADDRESS @VSOMEIP_DIAGNOSIS_ADDRESS@ -#define VSOMEIP_DEFAULT_SHM_PERMISSION 0666 #define VSOMEIP_DEFAULT_UDS_PERMISSIONS 0666 #define VSOMEIP_EXTERNAL_ROUTING_READY_MESSAGE "@VSOMEIP_ROUTING_READY_MESSAGE@" @@ -198,4 +185,3 @@ inline constexpr partition_id_t VSOMEIP_DEFAULT_PARTITION_ID = 0; } // namespace vsomeip_v3 -#endif // VSOMEIP_V3_INTERNAL_HPP_ diff --git a/implementation/configuration/include/internal_android.hpp b/implementation/configuration/include/internal_android.hpp index 216d74c48..7a2ea748d 100644 --- a/implementation/configuration/include/internal_android.hpp +++ b/implementation/configuration/include/internal_android.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_INTERNAL_HPP_ -#define VSOMEIP_V3_INTERNAL_HPP_ +#pragma once #include #include @@ -29,7 +28,6 @@ "vsomeip_portcfg.json,vsomeip_device.json" #define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/vendor/run/etc/vsomeip" -#define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" #define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip" // VSOMEIP_BASE_PATH should be specified in Android.bp or/and Android.mk file via c/c++ compiler @@ -61,7 +59,6 @@ #define VSOMEIP_DEFAULT_CONNECT_TIMEOUT 100 #define VSOMEIP_MAX_CONNECT_TIMEOUT 1600 #define VSOMEIP_DEFAULT_CONNECTING_TIMEOUT 500 -#define VSOMEIP_DEFAULT_FLUSH_TIMEOUT 1000 #define VSOMEIP_ROUTING_ROOT_RECONNECT_RETRIES 10000 #define VSOMEIP_ROUTING_ROOT_RECONNECT_INTERVAL 10 // miliseconds @@ -77,8 +74,6 @@ #define VSOMEIP_MAX_TCP_SENT_WAIT_TIME 10000 #define VSOMEIP_TCP_USER_TIMEOUT 3000 -#define VSOMEIP_MAX_NETLINK_RETRIES 3 - #define VSOMEIP_TP_MAX_SEGMENT_LENGTH_DEFAULT 1392 #define VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD 5 @@ -96,8 +91,6 @@ #define VSOMEIP_DEFAULT_MAX_DISPATCH_TIME 100 #define VSOMEIP_DEFAULT_MAX_DISPATCHERS 10 -#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 3 - #define VSOMEIP_REQUEST_DEBOUNCE_TIME 10 #define VSOMEIP_DEFAULT_STATISTICS_MAX_MSG 50 #define VSOMEIP_DEFAULT_STATISTICS_MIN_FREQ 50 @@ -129,16 +122,10 @@ #define VSOMEIP_DEFAULT_TCP_KEEPINTVL 1 #define VSOMEIP_DEFAULT_TCP_KEEPCNT 3 -#define MIN_ENDPOINT_WAIT_INTERVAL 10 -#define MAX_ENDPOINT_WAIT_INTERVAL 160 -#define SUM_ENDPOINT_WAIT_INTERVAL 500 - #include -#define VSOMEIP_DATA_ID 0x677D #define VSOMEIP_DIAGNOSIS_ADDRESS 0x01 -#define VSOMEIP_DEFAULT_SHM_PERMISSION 0666 #define VSOMEIP_DEFAULT_UDS_PERMISSIONS 0666 #define VSOMEIP_EXTERNAL_ROUTING_READY_MESSAGE "SOME/IP routing ready." @@ -173,5 +160,3 @@ typedef uint8_t partition_id_t; const partition_id_t VSOMEIP_DEFAULT_PARTITION_ID = 0; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_INTERNAL_HPP_ diff --git a/implementation/configuration/include/local_clients_keepalive.hpp b/implementation/configuration/include/local_clients_keepalive.hpp index cf4e7c29b..8df8f0287 100644 --- a/implementation/configuration/include/local_clients_keepalive.hpp +++ b/implementation/configuration/include/local_clients_keepalive.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_LOCAL_CLIENTS_KEEPALIVE_HPP_ -#define VSOMEIP_V3_CFG_LOCAL_CLIENTS_KEEPALIVE_HPP_ +#pragma once namespace vsomeip_v3 { namespace cfg { @@ -18,5 +17,3 @@ struct local_clients_keepalive { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_LOCAL_CLIENTS_KEEPALIVE_HPP_ diff --git a/implementation/configuration/include/routing.hpp b/implementation/configuration/include/routing.hpp index cf8f5cca8..09274a5b7 100644 --- a/implementation/configuration/include/routing.hpp +++ b/implementation/configuration/include/routing.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_ROUTING_HPP_ -#define VSOMEIP_V3_CFG_ROUTING_HPP_ +#pragma once #include @@ -67,5 +66,3 @@ struct routing_t { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_ROUTING_HPP_ diff --git a/implementation/configuration/include/service.hpp b/implementation/configuration/include/service.hpp index 44aeed7e2..c16b0c0dc 100644 --- a/implementation/configuration/include/service.hpp +++ b/implementation/configuration/include/service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_SERVICE_HPP -#define VSOMEIP_V3_CFG_SERVICE_HPP +#pragma once #include @@ -43,5 +42,3 @@ struct service { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_SERVICE_HPP diff --git a/implementation/configuration/include/service_instance_range.hpp b/implementation/configuration/include/service_instance_range.hpp index 1a814b965..66b0ec355 100644 --- a/implementation/configuration/include/service_instance_range.hpp +++ b/implementation/configuration/include/service_instance_range.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_SERVICE_INSTANCE_RANGE_HPP -#define VSOMEIP_V3_CFG_SERVICE_INSTANCE_RANGE_HPP +#pragma once #include @@ -20,5 +19,3 @@ struct service_instance_range { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_SERVICE_INSTANCE_RANGE_HPP diff --git a/implementation/configuration/include/trace.hpp b/implementation/configuration/include/trace.hpp index 4e2eb0c70..665af9b5a 100644 --- a/implementation/configuration/include/trace.hpp +++ b/implementation/configuration/include/trace.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_TRACE_HPP_ -#define VSOMEIP_V3_CFG_TRACE_HPP_ +#pragma once #include #include @@ -42,5 +41,3 @@ struct trace { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_TRACE_HPP_ diff --git a/implementation/configuration/include/watchdog.hpp b/implementation/configuration/include/watchdog.hpp index c308bcc47..2dfc92d24 100644 --- a/implementation/configuration/include/watchdog.hpp +++ b/implementation/configuration/include/watchdog.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CFG_WATCHDOG_HPP_ -#define VSOMEIP_V3_CFG_WATCHDOG_HPP_ +#pragma once namespace vsomeip_v3 { namespace cfg { @@ -20,5 +19,3 @@ struct watchdog { } // namespace cfg } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CFG_WATCHDOG_HPP_ diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 38b3ae97e..34fd34320 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -3942,6 +3942,7 @@ void configuration_impl::load_event_debounce(const boost::property_tree::ptree& its_converter >> its_debounce->interval_; } } else if (its_key == "send_current_value_after") { + VSOMEIP_WARNING << "Filter uses unsupported parameter 'send_current_value_after'"; its_debounce->send_current_value_after_ = (its_value == "true"); } } diff --git a/implementation/e2e_protection/include/buffer/buffer.hpp b/implementation/e2e_protection/include/buffer/buffer.hpp index 370795883..d598f31b7 100644 --- a/implementation/e2e_protection/include/buffer/buffer.hpp +++ b/implementation/e2e_protection/include/buffer/buffer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_BUFFER_HPP -#define VSOMEIP_V3_E2E_BUFFER_HPP +#pragma once #include #include @@ -39,5 +38,3 @@ class buffer_view { std::ostream& operator<<(std::ostream& _os, const e2e_buffer& _buffer); } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_BUFFER_HPP diff --git a/implementation/e2e_protection/include/crc/crc.hpp b/implementation/e2e_protection/include/crc/crc.hpp index 3a9dd23ce..d963f7815 100644 --- a/implementation/e2e_protection/include/crc/crc.hpp +++ b/implementation/e2e_protection/include/crc/crc.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_CRC_HPP -#define VSOMEIP_V3_E2E_CRC_HPP +#pragma once #include #include "../buffer/buffer.hpp" @@ -29,5 +28,3 @@ class e2e_crc { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_CRC_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp b/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp index 7de81f989..0bf365fd7 100644 --- a/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp +++ b/implementation/e2e_protection/include/e2e/profile/e2e_provider.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROVIDER_HPP -#define VSOMEIP_V3_E2E_PROVIDER_HPP +#pragma once #include #include @@ -33,5 +32,3 @@ class e2e_provider { } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROVIDER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp b/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp index ca00e1198..e4dcf96af 100644 --- a/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp +++ b/implementation/e2e_protection/include/e2e/profile/e2e_provider_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP -#define VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP +#pragma once #include #include @@ -66,5 +65,3 @@ class e2e_provider_impl : public e2e_provider, } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROVIDER_IMPL_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp index ce3003f60..a61f51629 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile01/checker.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE01_CHECKER_HPP -#define VSOMEIP_V3_E2E_PROFILE01_CHECKER_HPP +#pragma once #include "../profile01/profile_01.hpp" #include "../profile_interface/checker.hpp" @@ -32,5 +31,3 @@ class profile_01_checker final : public e2e::profile_interface::checker { } // namespace profile01 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE01_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp b/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp index ebc859eb3..878293310 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile01/profile_01.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP -#define VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP +#pragma once #include @@ -55,5 +54,3 @@ struct profile_config { } // namespace profile01 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE01_PROFILE01_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp index 74be0f826..22b6a7f5f 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile01/protector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE01_PROTECTOR_HPP -#define VSOMEIP_V3_E2E_PROFILE01_PROTECTOR_HPP +#pragma once #include @@ -41,5 +40,3 @@ class protector final : public e2e::profile_interface::protector { } // namespace profile01 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE01_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile04/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile04/checker.hpp index 253470084..2c2c8d62e 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile04/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile04/checker.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE04_CHECKER_HPP -#define VSOMEIP_V3_E2E_PROFILE04_CHECKER_HPP +#pragma once #include @@ -42,5 +41,3 @@ class profile_04_checker final : public e2e::profile_interface::checker { } // namespace profile_04 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE04_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile04/profile_04.hpp b/implementation/e2e_protection/include/e2e/profile/profile04/profile_04.hpp index 57e37885e..9b48d47c8 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile04/profile_04.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile04/profile_04.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE04_PROFILE04_HPP -#define VSOMEIP_V3_E2E_PROFILE04_PROFILE04_HPP +#pragma once #include @@ -54,5 +53,3 @@ struct profile_config { } // namespace profile_04 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE04_PROFILE04_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile04/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile04/protector.hpp index 4d73f7080..e0e375aa3 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile04/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile04/protector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE04_PROTECTOR_HPP -#define VSOMEIP_V3_E2E_PROFILE04_PROTECTOR_HPP +#pragma once #include #include @@ -41,5 +40,3 @@ class protector final : public e2e::profile_interface::protector { } // namespace profile_04 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE04_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile05/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile05/checker.hpp index 0becbef64..fd8840efa 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile05/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile05/checker.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE05_CHECKER_HPP -#define VSOMEIP_V3_E2E_PROFILE05_CHECKER_HPP +#pragma once #include @@ -42,5 +41,3 @@ class profile_05_checker final : public e2e::profile_interface::checker { } // namespace profile_05 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE05_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile05/profile_05.hpp b/implementation/e2e_protection/include/e2e/profile/profile05/profile_05.hpp index b819fa0cc..13e510f9d 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile05/profile_05.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile05/profile_05.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE05_PROFILE05_HPP -#define VSOMEIP_V3_E2E_PROFILE05_PROFILE05_HPP +#pragma once #include @@ -55,5 +54,3 @@ struct profile_config { } // namespace profile_05 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE05_PROFILE05_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile05/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile05/protector.hpp index 06a187fba..50569f4c5 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile05/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile05/protector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE05_PROTECTOR_HPP -#define VSOMEIP_V3_E2E_PROFILE05_PROTECTOR_HPP +#pragma once #include #include @@ -41,5 +40,3 @@ class protector final : public e2e::profile_interface::protector { } // namespace profile_05 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE05_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile07/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile07/checker.hpp index c50e1cf24..007938474 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile07/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile07/checker.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE07_CHECKER_HPP -#define VSOMEIP_V3_E2E_PROFILE07_CHECKER_HPP +#pragma once #include @@ -42,5 +41,3 @@ class profile_07_checker final : public e2e::profile_interface::checker { } // namespace profile_07 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE07_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile07/profile_07.hpp b/implementation/e2e_protection/include/e2e/profile/profile07/profile_07.hpp index c2ff8c4ab..de1af46c1 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile07/profile_07.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile07/profile_07.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE07_PROFILE07_HPP -#define VSOMEIP_V3_E2E_PROFILE07_PROFILE07_HPP +#pragma once #include @@ -54,5 +53,3 @@ struct profile_config { } // namespace profile_07 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE07_PROFILE07_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile07/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile07/protector.hpp index 95f6f4c87..97e501d52 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile07/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile07/protector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE07_PROTECTOR_HPP -#define VSOMEIP_V3_E2E_PROFILE07_PROTECTOR_HPP +#pragma once #include #include @@ -41,5 +40,3 @@ class protector final : public e2e::profile_interface::protector { } // namespace profile_07 } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE07_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp index b455e6095..70a796d05 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_custom/checker.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE_CUSTOM_CHECKER_HPP -#define VSOMEIP_V3_E2E_PROFILE_CUSTOM_CHECKER_HPP +#pragma once #include "../profile_custom/profile_custom.hpp" #include "../profile_interface/checker.hpp" @@ -35,5 +34,3 @@ class profile_custom_checker final : public e2e::profile_interface::checker { } // namespace profile_custom } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE_CUSTOM_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp b/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp index ce6f156a7..6e6cee1e1 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_custom/profile_custom.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP -#define VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP +#pragma once #include @@ -39,5 +38,3 @@ struct profile_config { } // namespace profile_custom } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROFILE_CUSTOM_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp index 1e2aa9673..644896c48 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_custom/protector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROTECTOR_HPP -#define VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROTECTOR_HPP +#pragma once #include #include "../profile_custom/profile_custom.hpp" @@ -33,5 +32,3 @@ class protector final : public e2e::profile_interface::protector { } // namespace profile_custom } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE_CUSTOM_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp b/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp index 67996b886..1258f5375 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_interface/checker.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_CHECKER_HPP -#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_CHECKER_HPP +#pragma once #include @@ -25,5 +24,3 @@ class checker : public profile_interface { } // namespace profile_interface } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_CHECKER_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp b/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp index 4b3aeb84d..5438c8a4e 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_interface/profile_interface.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP -#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP +#pragma once #include @@ -23,5 +22,3 @@ class profile_interface { } // namespace profile_interface } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROFILE_INTERFACE_HPP diff --git a/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp b/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp index 480b595d7..5e48d07e1 100644 --- a/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp +++ b/implementation/e2e_protection/include/e2e/profile/profile_interface/protector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROTECTOR_HPP -#define VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROTECTOR_HPP +#pragma once #include @@ -23,5 +22,3 @@ class protector : public profile_interface { } // namespace profile_interface } // namespace e2e } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2E_PROFILE_INTERFACE_PROTECTOR_HPP diff --git a/implementation/e2e_protection/include/e2exf/config.hpp b/implementation/e2e_protection/include/e2exf/config.hpp index eab9d901f..5f5075244 100644 --- a/implementation/e2e_protection/include/e2exf/config.hpp +++ b/implementation/e2e_protection/include/e2exf/config.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_E2EXF_CONFIG_HPP -#define VSOMEIP_V3_E2EXF_CONFIG_HPP +#pragma once #include #include "../e2e/profile/profile_interface/checker.hpp" @@ -22,5 +21,3 @@ std::ostream& operator<<(std::ostream& _os, const e2exf::data_identifier_t& _dat } // namespace e2exf } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_E2EXF_CONFIG_HPP diff --git a/implementation/endpoints/include/abstract_netlink_connector.hpp b/implementation/endpoints/include/abstract_netlink_connector.hpp index 498e7ecac..dbb8e0cc7 100644 --- a/implementation/endpoints/include/abstract_netlink_connector.hpp +++ b/implementation/endpoints/include/abstract_netlink_connector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ABSTRACT_NETLINK_CONNECTOR_HPP_ -#define VSOMEIP_V3_ABSTRACT_NETLINK_CONNECTOR_HPP_ +#pragma once #if defined(__linux__) @@ -31,5 +30,3 @@ class abstract_netlink_connector { } // namespace vsomeip_v3 #endif // __linux__ - -#endif // VSOMEIP_V3_NETLINK_CONNECTOR_HPP_ diff --git a/implementation/endpoints/include/abstract_socket_factory.hpp b/implementation/endpoints/include/abstract_socket_factory.hpp index 21cdaa7cd..074572cb1 100644 --- a/implementation/endpoints/include/abstract_socket_factory.hpp +++ b/implementation/endpoints/include/abstract_socket_factory.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ABSTRACT_SOCKET_FACTORY_HPP_ -#define VSOMEIP_V3_ABSTRACT_SOCKET_FACTORY_HPP_ +#pragma once #include "abstract_netlink_connector.hpp" #include "abstract_timer.hpp" @@ -57,5 +56,3 @@ class abstract_socket_factory { void set_abstract_factory(std::shared_ptr ptr); } - -#endif diff --git a/implementation/endpoints/include/abstract_timer.hpp b/implementation/endpoints/include/abstract_timer.hpp index e6cc7e088..dfddc3a76 100644 --- a/implementation/endpoints/include/abstract_timer.hpp +++ b/implementation/endpoints/include/abstract_timer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ABSTRACT_TIMER_HPP_ -#define VSOMEIP_V3_ABSTRACT_TIMER_HPP_ +#pragma once #include @@ -32,5 +31,3 @@ class abstract_timer { virtual void async_wait(handler_t _handler) = 0; }; } - -#endif diff --git a/implementation/endpoints/include/asio_socket_factory.hpp b/implementation/endpoints/include/asio_socket_factory.hpp index 08d711baa..b0e2a9794 100644 --- a/implementation/endpoints/include/asio_socket_factory.hpp +++ b/implementation/endpoints/include/asio_socket_factory.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ASIO_SOCKET_FACTORY_HPP_ -#define VSOMEIP_V3_ASIO_SOCKET_FACTORY_HPP_ +#pragma once #include "abstract_socket_factory.hpp" @@ -34,4 +33,3 @@ class asio_socket_factory final : public abstract_socket_factory { }; } -#endif diff --git a/implementation/endpoints/include/asio_tcp_socket.hpp b/implementation/endpoints/include/asio_tcp_socket.hpp index 6e0a712df..42d86b40e 100644 --- a/implementation/endpoints/include/asio_tcp_socket.hpp +++ b/implementation/endpoints/include/asio_tcp_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ASIO_TCP_SOCKET_HPP_ -#define VSOMEIP_V3_ASIO_TCP_SOCKET_HPP_ +#pragma once #include "tcp_socket.hpp" @@ -119,4 +118,3 @@ class asio_tcp_acceptor final : public tcp_acceptor { }; } -#endif diff --git a/implementation/endpoints/include/asio_timer.hpp b/implementation/endpoints/include/asio_timer.hpp index cad35aca2..e1febbd6a 100644 --- a/implementation/endpoints/include/asio_timer.hpp +++ b/implementation/endpoints/include/asio_timer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ASIO_TIMER_HPP_ -#define VSOMEIP_V3_ASIO_TIMER_HPP_ +#pragma once #include "abstract_timer.hpp" #include @@ -26,5 +25,3 @@ class asio_timer : public abstract_timer { boost::asio::steady_timer timer_; }; } - -#endif diff --git a/implementation/endpoints/include/asio_udp_socket.hpp b/implementation/endpoints/include/asio_udp_socket.hpp index 066e4fa12..3d8988f69 100644 --- a/implementation/endpoints/include/asio_udp_socket.hpp +++ b/implementation/endpoints/include/asio_udp_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ASIO_UDP_SOCKET_HPP_ -#define VSOMEIP_V3_ASIO_UDP_SOCKET_HPP_ +#pragma once #include "udp_socket.hpp" @@ -67,4 +66,3 @@ class asio_udp_socket final : public udp_socket { }; } -#endif diff --git a/implementation/endpoints/include/asio_uds_acceptor.hpp b/implementation/endpoints/include/asio_uds_acceptor.hpp index 1dbfa1e94..8880d78d2 100644 --- a/implementation/endpoints/include/asio_uds_acceptor.hpp +++ b/implementation/endpoints/include/asio_uds_acceptor.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ASIO_UDS_ACCEPTOR_HPP_ -#define VSOMEIP_V3_ASIO_UDS_ACCEPTOR_HPP_ +#pragma once #if defined(__linux__) || defined(__QNX__) #include "uds_acceptor.hpp" @@ -54,4 +53,3 @@ class asio_uds_acceptor final : public uds_acceptor { } #endif -#endif diff --git a/implementation/endpoints/include/asio_uds_socket.hpp b/implementation/endpoints/include/asio_uds_socket.hpp index 3003d48e8..0534a1f7c 100644 --- a/implementation/endpoints/include/asio_uds_socket.hpp +++ b/implementation/endpoints/include/asio_uds_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ASIO_UDS_SOCKET_HPP_ -#define VSOMEIP_V3_ASIO_UDS_SOCKET_HPP_ +#pragma once #if defined(__linux__) || defined(__QNX__) #include "uds_socket.hpp" @@ -52,4 +51,3 @@ class asio_uds_socket final : public uds_socket { } #endif -#endif diff --git a/implementation/endpoints/include/boardnet_endpoint.hpp b/implementation/endpoints/include/boardnet_endpoint.hpp index 3560d0b8f..11f7ac18f 100644 --- a/implementation/endpoints/include/boardnet_endpoint.hpp +++ b/implementation/endpoints/include/boardnet_endpoint.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_BOARDNET_ENDPOINT_HPP_ -#define VSOMEIP_V3_BOARDNET_ENDPOINT_HPP_ +#pragma once #include #include @@ -19,12 +18,8 @@ class endpoint_definition; class boardnet_endpoint { public: - using prepare_stop_handler_t = std::function&)>; - virtual ~boardnet_endpoint() = default; - virtual void prepare_stop(const prepare_stop_handler_t& _handler, service_t _service = ANY_SERVICE) = 0; - virtual void start() = 0; /** * @brief Stop endpoint @@ -41,7 +36,6 @@ class boardnet_endpoint { virtual void add_default_target(service_t _service, const std::string& _address, uint16_t _port) = 0; virtual void remove_default_target(service_t _service) = 0; - virtual void remove_stop_handler(service_t _service) = 0; virtual bool is_established() const = 0; virtual bool is_established_or_connected() const = 0; @@ -58,5 +52,3 @@ class boardnet_endpoint { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_BOARDNET_ENDPOINT_HPP_ diff --git a/implementation/endpoints/include/boardnet_endpoint_host.hpp b/implementation/endpoints/include/boardnet_endpoint_host.hpp index dac389619..448f11dbe 100644 --- a/implementation/endpoints/include/boardnet_endpoint_host.hpp +++ b/implementation/endpoints/include/boardnet_endpoint_host.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_BOARDNET_ENDPOINT_HOST_HPP_ -#define VSOMEIP_V3_BOARDNET_ENDPOINT_HOST_HPP_ +#pragma once #include @@ -46,5 +45,3 @@ class boardnet_endpoint_host { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_BOARDNET_ENDPOINT_HOST_HPP_ \ No newline at end of file diff --git a/implementation/endpoints/include/buffer.hpp b/implementation/endpoints/include/buffer.hpp index 7e8afc84e..26f3e0a76 100644 --- a/implementation/endpoints/include/buffer.hpp +++ b/implementation/endpoints/include/buffer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_BUFFER_HPP_ -#define VSOMEIP_V3_BUFFER_HPP_ +#pragma once #include #include @@ -51,5 +50,3 @@ struct train { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_BUFFER_HPP_ diff --git a/implementation/endpoints/include/client_endpoint.hpp b/implementation/endpoints/include/client_endpoint.hpp index f777a16b0..ce72c8329 100644 --- a/implementation/endpoints/include/client_endpoint.hpp +++ b/implementation/endpoints/include/client_endpoint.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CLIENT_ENDPOINT_HPP_ -#define VSOMEIP_V3_CLIENT_ENDPOINT_HPP_ +#pragma once #include "boardnet_endpoint.hpp" @@ -19,5 +18,3 @@ class client_endpoint { }; } // namespace vsomeip - -#endif // VSOMEIP_V3_CLIENT_ENDPOINT_HPP_ diff --git a/implementation/endpoints/include/client_endpoint_impl.hpp b/implementation/endpoints/include/client_endpoint_impl.hpp index 7778ca2a5..fa81a9914 100644 --- a/implementation/endpoints/include/client_endpoint_impl.hpp +++ b/implementation/endpoints/include/client_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CLIENT_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_CLIENT_ENDPOINT_IMPL_HPP_ +#pragma once #include #include @@ -55,7 +54,6 @@ class client_endpoint_impl : public endpoint_impl, bool send_error(const std::shared_ptr _target, const byte_t* _data, uint32_t _size); bool flush(); - void prepare_stop(const boardnet_endpoint::prepare_stop_handler_t& _handler, service_t _service); virtual void stop(bool _due_to_error); virtual void restart(bool _force = false) = 0; @@ -159,5 +157,3 @@ class client_endpoint_impl : public endpoint_impl, }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CLIENT_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/credentials.hpp b/implementation/endpoints/include/credentials.hpp deleted file mode 100644 index d4ab72afd..000000000 --- a/implementation/endpoints/include/credentials.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef VSOMEIP_V3_ENDPOINTS_INCLUDE_CREDENTIALS_HPP_ -#define VSOMEIP_V3_ENDPOINTS_INCLUDE_CREDENTIALS_HPP_ - -#include - -#include - -#include - -namespace vsomeip_v3 { - -class credentials { -public: - static void activate_credentials(const int _fd); - - static void deactivate_credentials(const int _fd); - - using received_t = std::tuple; - static boost::optional receive_credentials(const int _fd); - - static void send_credentials(const int _fd, client_t _client, std::string _client_host); -}; - -} // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ENDPOINTS_INCLUDE_CREDENTIALS_HPP_ diff --git a/implementation/endpoints/include/endpoint_definition.hpp b/implementation/endpoints/include/endpoint_definition.hpp index 95ec2ea47..ce854a4a5 100644 --- a/implementation/endpoints/include/endpoint_definition.hpp +++ b/implementation/endpoints/include/endpoint_definition.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ENDPOINT_DEFINITION_HPP_ -#define VSOMEIP_V3_ENDPOINT_DEFINITION_HPP_ +#pragma once #include #include @@ -46,5 +45,3 @@ class endpoint_definition { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ENDPOINT_DEFINITION_HPP_ diff --git a/implementation/endpoints/include/endpoint_impl.hpp b/implementation/endpoints/include/endpoint_impl.hpp index 56bbf6c38..5497f8953 100644 --- a/implementation/endpoints/include/endpoint_impl.hpp +++ b/implementation/endpoints/include/endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_ENDPOINT_IMPL_HPP_ +#pragma once #include #include @@ -36,7 +35,6 @@ class endpoint_impl : public boardnet_endpoint { void add_default_target(service_t, const std::string&, uint16_t) override; void remove_default_target(service_t) override; - void remove_stop_handler(service_t) override; virtual std::uint16_t get_local_port() const = 0; virtual bool is_reliable() const = 0; @@ -71,8 +69,6 @@ class endpoint_impl : public boardnet_endpoint { endpoint_type local_; - std::mutex error_handler_mutex_; - configuration::endpoint_queue_limit_t queue_limit_; std::shared_ptr configuration_; @@ -81,5 +77,3 @@ class endpoint_impl : public boardnet_endpoint { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/endpoint_manager_base.hpp b/implementation/endpoints/include/endpoint_manager_base.hpp index c1ecb70e5..e8700a4c6 100644 --- a/implementation/endpoints/include/endpoint_manager_base.hpp +++ b/implementation/endpoints/include/endpoint_manager_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ENDPOINT_MANAGER_BASE_HPP_ -#define VSOMEIP_V3_ENDPOINT_MANAGER_BASE_HPP_ +#pragma once #include #include @@ -71,5 +70,3 @@ class endpoint_manager_base : public std::enable_shared_from_this #include @@ -135,5 +134,3 @@ class endpoint_manager_impl : public endpoint_manager_base, public boardnet_endp }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ENDPOINT_MANAGER_IMPL_HPP_ diff --git a/implementation/endpoints/include/io_control_operation.hpp b/implementation/endpoints/include/io_control_operation.hpp index b0f157ff6..f1da0189f 100644 --- a/implementation/endpoints/include/io_control_operation.hpp +++ b/implementation/endpoints/include/io_control_operation.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_IO_CONTROL_OPERATION_HPP_ -#define VSOMEIP_V3_IO_CONTROL_OPERATION_HPP_ +#pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma once @@ -47,5 +46,3 @@ class io_control_operation { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_IO_CONTROL_OPERATION_HPP_ diff --git a/implementation/endpoints/include/local_acceptor.hpp b/implementation/endpoints/include/local_acceptor.hpp index 6b6c6111f..5c301ce00 100644 --- a/implementation/endpoints/include/local_acceptor.hpp +++ b/implementation/endpoints/include/local_acceptor.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_ACCEPTOR_HPP_ -#define VSOMEIP_V3_LOCAL_ACCEPTOR_HPP_ +#pragma once #include @@ -73,5 +72,3 @@ class local_acceptor { }; } - -#endif diff --git a/implementation/endpoints/include/local_acceptor_tcp_impl.hpp b/implementation/endpoints/include/local_acceptor_tcp_impl.hpp index 8573a3bdc..194a28a08 100644 --- a/implementation/endpoints/include/local_acceptor_tcp_impl.hpp +++ b/implementation/endpoints/include/local_acceptor_tcp_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_ACCEPTOR_TCP_IMPL_HPP_ -#define VSOMEIP_V3_LOCAL_ACCEPTOR_TCP_IMPL_HPP_ +#pragma once #include "local_acceptor.hpp" #include @@ -80,5 +79,3 @@ class local_acceptor_tcp_impl : public local_acceptor, public std::enable_shared }; } - -#endif diff --git a/implementation/endpoints/include/local_acceptor_uds_impl.hpp b/implementation/endpoints/include/local_acceptor_uds_impl.hpp index 3c789db2f..e90276e9c 100644 --- a/implementation/endpoints/include/local_acceptor_uds_impl.hpp +++ b/implementation/endpoints/include/local_acceptor_uds_impl.hpp @@ -4,8 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #if defined(__linux__) || defined(__QNX__) -#ifndef VSOMEIP_V3_LOCAL_ACCEPTOR_UDS_IMPL_HPP_ -#define VSOMEIP_V3_LOCAL_ACCEPTOR_UDS_IMPL_HPP_ +#pragma once #include "local_acceptor.hpp" #include "uds_socket.hpp" @@ -85,4 +84,3 @@ class local_acceptor_uds_impl : public local_acceptor, public std::enable_shared } #endif -#endif diff --git a/implementation/endpoints/include/local_endpoint.hpp b/implementation/endpoints/include/local_endpoint.hpp index c26f465f4..5e2685269 100644 --- a/implementation/endpoints/include/local_endpoint.hpp +++ b/implementation/endpoints/include/local_endpoint.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_ENDPOINT_HPP_ -#define VSOMEIP_V3_LOCAL_ENDPOINT_HPP_ +#pragma once #include "local_receive_buffer.hpp" #include "timer.hpp" @@ -86,6 +85,15 @@ struct local_endpoint_params { * (routing_host, error_handler) are invoked without holding internal locks * to prevent deadlocks. * + * Callback Guarantee: All public member functions guarantee that they will not + * synchronously invoke any callbacks (error handlers, message handlers, etc.) except + * for destructors of promoted weak_ptr references that expire during the function call, + * or the injected local_socket. + * This ensures that: + * - Public functions can be safely called while holding external locks + * - No re-entrancy issues arise from calling public methods + * - Callbacks are only invoked asynchronously via boost::asio::post() on the io_context + * * Protocol-agnostic: Delegates protocol-specific behavior to local_socket implementations. * * @note This endpoint is non-restartable - once stopped, it cannot be reused. @@ -207,7 +215,7 @@ class local_endpoint : public std::enable_shared_from_this { void connect_cbk(boost::system::error_code const& _ec); void send_cbk(boost::system::error_code const& _ec, size_t _bytes, std::vector _send_buffer); void receive_cbk(boost::system::error_code const& _ec, size_t _bytes); - [[nodiscard]] bool process(size_t _new_bytes); + [[nodiscard]] bool process(size_t _new_bytes, std::unique_lock& _lock); void assignment_timeout(); @@ -253,5 +261,3 @@ class local_endpoint : public std::enable_shared_from_this { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ENDPOINT_HPP_ diff --git a/implementation/endpoints/include/local_receive_buffer.hpp b/implementation/endpoints/include/local_receive_buffer.hpp index c28f87484..ab6385f3d 100644 --- a/implementation/endpoints/include/local_receive_buffer.hpp +++ b/implementation/endpoints/include/local_receive_buffer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_RECEIVE_BUFFER_ -#define VSOMEIP_V3_LOCAL_RECEIVE_BUFFER_ +#pragma once #include #include @@ -264,5 +263,3 @@ class local_receive_buffer { size_t end_{0}; }; } - -#endif diff --git a/implementation/endpoints/include/local_server.hpp b/implementation/endpoints/include/local_server.hpp index be54735b1..01fbca98d 100644 --- a/implementation/endpoints/include/local_server.hpp +++ b/implementation/endpoints/include/local_server.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_SERVER_HPP_ -#define VSOMEIP_V3_LOCAL_SERVER_HPP_ +#pragma once #include "local_receive_buffer.hpp" #include "timer.hpp" @@ -204,5 +203,3 @@ class local_server : public std::enable_shared_from_this { std::unordered_map> clients_; }; } - -#endif diff --git a/implementation/endpoints/include/local_socket.hpp b/implementation/endpoints/include/local_socket.hpp index 0403cd378..a3ca38c9c 100644 --- a/implementation/endpoints/include/local_socket.hpp +++ b/implementation/endpoints/include/local_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_SOCKET_HPP_ -#define VSOMEIP_V3_LOCAL_SOCKET_HPP_ +#pragma once #include #include @@ -112,5 +111,3 @@ class local_socket { virtual size_t get_send_buffer_size(boost::system::error_code& _ec) = 0; }; } // namespace vsomeip_v3 - -#endif diff --git a/implementation/endpoints/include/local_socket_tcp_impl.hpp b/implementation/endpoints/include/local_socket_tcp_impl.hpp index d059877ef..28b3292d8 100644 --- a/implementation/endpoints/include/local_socket_tcp_impl.hpp +++ b/implementation/endpoints/include/local_socket_tcp_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOCAL_SOCKET_TCP_IMPL_HPP_ -#define VSOMEIP_V3_LOCAL_SOCKET_TCP_IMPL_HPP_ +#pragma once #include "local_socket.hpp" #include "tcp_socket.hpp" @@ -97,5 +96,3 @@ class local_socket_tcp_impl : public local_socket, public std::enable_shared_fro std::string const name_; }; } // namespace vsomeip_v3 - -#endif diff --git a/implementation/endpoints/include/local_socket_uds_impl.hpp b/implementation/endpoints/include/local_socket_uds_impl.hpp index 3be8f4387..ae62fa747 100644 --- a/implementation/endpoints/include/local_socket_uds_impl.hpp +++ b/implementation/endpoints/include/local_socket_uds_impl.hpp @@ -4,8 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #if defined(__linux__) || defined(__QNX__) -#ifndef VSOMEIP_V3_LOCAL_SOCKET_UDS_IMPL_HPP_ -#define VSOMEIP_V3_LOCAL_SOCKET_UDS_IMPL_HPP_ +#pragma once #include "local_socket.hpp" #include "uds_socket.hpp" @@ -89,4 +88,3 @@ class local_socket_uds_impl : public local_socket { } #endif -#endif diff --git a/implementation/endpoints/include/netlink_connector.hpp b/implementation/endpoints/include/netlink_connector.hpp index c42f94443..9aba21d13 100644 --- a/implementation/endpoints/include/netlink_connector.hpp +++ b/implementation/endpoints/include/netlink_connector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_NETLINK_CONNECTOR_HPP_ -#define VSOMEIP_V3_NETLINK_CONNECTOR_HPP_ +#pragma once #if defined(__linux__) @@ -175,9 +174,7 @@ class netlink_connector : public abstract_netlink_connector, public std::enable_ bool multicast_route_found_ = false; state_e current_state_ = state_e::INIT; - static const std::uint32_t max_retries_ = VSOMEIP_MAX_NETLINK_RETRIES; static const std::uint32_t retry_bit_shift_ = 8; - static const std::uint32_t request_sequence_bitmask_ = 0xFF; static const std::uint32_t ifa_request_sequence_ = 1; static const std::uint32_t ifi_request_sequence_ = 2; static const std::uint32_t rt_request_sequence_ = 3; @@ -186,5 +183,3 @@ class netlink_connector : public abstract_netlink_connector, public std::enable_ } // namespace vsomeip_v3 #endif // __linux__ - -#endif // VSOMEIP_V3_NETLINK_CONNECTOR_HPP_ diff --git a/implementation/endpoints/include/server_endpoint_impl.hpp b/implementation/endpoints/include/server_endpoint_impl.hpp index 71dd98094..97cae49ce 100644 --- a/implementation/endpoints/include/server_endpoint_impl.hpp +++ b/implementation/endpoints/include/server_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SERVER_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_SERVER_ENDPOINT_IMPL_HPP_ +#pragma once #include #include @@ -76,7 +75,6 @@ class server_endpoint_impl : public endpoint_impl, public std::enable_ bool send(const uint8_t* _data, uint32_t _size); bool send(const std::vector& _cmd_header, const byte_t* _data, uint32_t _size); - void prepare_stop(const boardnet_endpoint::prepare_stop_handler_t& _handler, service_t _service); bool flush(endpoint_type _it); size_t get_queue_size() const; @@ -88,7 +86,6 @@ class server_endpoint_impl : public endpoint_impl, public std::enable_ void connect_cbk(boost::system::error_code const& _error); void send_cbk(const endpoint_type _key, boost::system::error_code const& _error, std::size_t _bytes); void flush_cbk(endpoint_type _key, const boost::system::error_code& _error_code); - void remove_stop_handler(service_t _service); protected: // The caller must hold the `mutex_` lock @@ -126,8 +123,6 @@ class server_endpoint_impl : public endpoint_impl, public std::enable_ target_data_type targets_; - std::map prepare_stop_handlers_; - mutable std::mutex mutex_; private: @@ -146,5 +141,3 @@ class server_endpoint_impl : public endpoint_impl, public std::enable_ }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SERVER_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp index 015236db7..58f7b5dc0 100644 --- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TCP_CLIENT_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_TCP_CLIENT_ENDPOINT_IMPL_HPP_ +#pragma once #include @@ -92,5 +91,3 @@ class tcp_client_endpoint_impl : public tcp_client_endpoint_base_impl { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TCP_CLIENT_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp index 8b634651f..7e166a2ef 100644 --- a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TCP_SERVER_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_TCP_SERVER_ENDPOINT_IMPL_HPP_ +#pragma once #include #include @@ -143,5 +142,3 @@ class tcp_server_endpoint_impl : public tcp_server_endpoint_base_impl { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TCP_SERVER_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/tcp_socket.hpp b/implementation/endpoints/include/tcp_socket.hpp index 2001ab85f..c13598e30 100644 --- a/implementation/endpoints/include/tcp_socket.hpp +++ b/implementation/endpoints/include/tcp_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TCP_SOCKET_HPP_ -#define VSOMEIP_V3_TCP_SOCKET_HPP_ +#pragma once #include #include @@ -143,5 +142,3 @@ class tcp_acceptor : public tcp_base_socket { }; } - -#endif diff --git a/implementation/endpoints/include/timer.hpp b/implementation/endpoints/include/timer.hpp index b2b21cead..7bafc0641 100644 --- a/implementation/endpoints/include/timer.hpp +++ b/implementation/endpoints/include/timer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TIMER_HPP_ -#define VSOMEIP_V3_TIMER_HPP_ +#pragma once #include "abstract_timer.hpp" @@ -114,5 +113,3 @@ class timer : public std::enable_shared_from_this { mutable std::mutex mtx_; }; } - -#endif diff --git a/implementation/endpoints/include/tp.hpp b/implementation/endpoints/include/tp.hpp index 24cd3cfc0..f8c394152 100644 --- a/implementation/endpoints/include/tp.hpp +++ b/implementation/endpoints/include/tp.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TP_HPP_ -#define VSOMEIP_V3_TP_HPP_ +#pragma once #include #include @@ -45,5 +44,3 @@ class tp { } // namespace tp } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TP_HPP_ diff --git a/implementation/endpoints/include/tp_message.hpp b/implementation/endpoints/include/tp_message.hpp index 6f3d7cf5d..e5a1fdedd 100644 --- a/implementation/endpoints/include/tp_message.hpp +++ b/implementation/endpoints/include/tp_message.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TP_MESSAGE_HPP_ -#define VSOMEIP_V3_TP_MESSAGE_HPP_ +#pragma once #include #include @@ -56,5 +55,3 @@ class tp_message { } // namespace tp } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TP_MESSAGE_HPP_ diff --git a/implementation/endpoints/include/tp_reassembler.hpp b/implementation/endpoints/include/tp_reassembler.hpp index abbbfaa84..f146b4ef0 100644 --- a/implementation/endpoints/include/tp_reassembler.hpp +++ b/implementation/endpoints/include/tp_reassembler.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TP_REASSEMBLER_HPP_ -#define VSOMEIP_V3_TP_REASSEMBLER_HPP_ +#pragma once #include #include @@ -55,5 +54,3 @@ class tp_reassembler : public std::enable_shared_from_this { } // namespace tp } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TP_REASSEMBLER_HPP_ diff --git a/implementation/endpoints/include/udp_client_endpoint_impl.hpp b/implementation/endpoints/include/udp_client_endpoint_impl.hpp index 5fdc30c13..96903f4af 100644 --- a/implementation/endpoints/include/udp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_client_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UDP_CLIENT_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_UDP_CLIENT_ENDPOINT_IMPL_HPP_ +#pragma once #include @@ -64,11 +63,7 @@ class udp_client_endpoint_impl : public udp_client_endpoint_base_impl { const std::uint16_t remote_port_; const int udp_receive_buffer_size_; std::shared_ptr tp_reassembler_; - - std::mutex last_sent_mutex_; std::chrono::steady_clock::time_point last_sent_; }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_UDP_CLIENT_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/udp_server_endpoint_impl.hpp b/implementation/endpoints/include/udp_server_endpoint_impl.hpp index 9d33f3bab..b99838df0 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_HPP_ +#pragma once #include #include @@ -147,5 +146,3 @@ class udp_server_endpoint_impl : public udp_server_endpoint_base_impl { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp index ef05266ae..571cf0c67 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_RECEIVE_OP_HPP_ -#define VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_RECEIVE_OP_HPP_ +#pragma once #ifdef _WIN32 #include @@ -302,5 +301,3 @@ struct storage : public std::enable_shared_from_this { } // namespace udp_endpoint_receive_op } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_RECEIVE_OP_HPP_ diff --git a/implementation/endpoints/include/udp_socket.hpp b/implementation/endpoints/include/udp_socket.hpp index 26d7c7e9c..c389e2d0c 100644 --- a/implementation/endpoints/include/udp_socket.hpp +++ b/implementation/endpoints/include/udp_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UDP_SOCKET_HPP_ -#define VSOMEIP_V3_UDP_SOCKET_HPP_ +#pragma once #include #include @@ -55,5 +54,3 @@ class udp_socket { }; } - -#endif diff --git a/implementation/endpoints/include/uds_acceptor.hpp b/implementation/endpoints/include/uds_acceptor.hpp index 32c029fcd..d13f4bc64 100644 --- a/implementation/endpoints/include/uds_acceptor.hpp +++ b/implementation/endpoints/include/uds_acceptor.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UDS_ACCEPTOR_HPP_ -#define VSOMEIP_V3_UDS_ACCEPTOR_HPP_ +#pragma once #include #include @@ -37,5 +36,3 @@ class uds_acceptor { }; } - -#endif diff --git a/implementation/endpoints/include/uds_socket.hpp b/implementation/endpoints/include/uds_socket.hpp index b64bd6399..7d3634f61 100644 --- a/implementation/endpoints/include/uds_socket.hpp +++ b/implementation/endpoints/include/uds_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UDS_SOCKET_HPP_ -#define VSOMEIP_V3_UDS_SOCKET_HPP_ +#pragma once #include @@ -37,5 +36,3 @@ class uds_socket { }; } - -#endif diff --git a/implementation/endpoints/include/virtual_server_endpoint_impl.hpp b/implementation/endpoints/include/virtual_server_endpoint_impl.hpp index 720946c8e..9a3489949 100644 --- a/implementation/endpoints/include/virtual_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/virtual_server_endpoint_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_VIRTUAL_SERVER_ENDPOINT_IMPL_HPP_ -#define VSOMEIP_V3_VIRTUAL_SERVER_ENDPOINT_IMPL_HPP_ +#pragma once #include "boardnet_endpoint.hpp" @@ -19,7 +18,6 @@ class virtual_server_endpoint_impl : public boardnet_endpoint, public std::enabl virtual ~virtual_server_endpoint_impl(); void start(); - void prepare_stop(const prepare_stop_handler_t& _handler, service_t _service); void stop(bool _due_to_error); bool is_established() const; @@ -34,7 +32,6 @@ class virtual_server_endpoint_impl : public boardnet_endpoint, public std::enabl void add_default_target(service_t _service, const std::string& _address, uint16_t _port); void remove_default_target(service_t _service); - void remove_stop_handler(service_t _service); bool get_remote_address(boost::asio::ip::address& _address) const; std::uint16_t get_local_port() const; @@ -52,10 +49,6 @@ class virtual_server_endpoint_impl : public boardnet_endpoint, public std::enabl std::string address_; uint16_t port_; bool reliable_; - - boost::asio::io_context& io_; }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_VIRTUAL_SERVER_ENDPOINT_IMPL_HPP_ diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index 7dcea27dc..b7b26ac40 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -103,17 +103,10 @@ void client_endpoint_impl::set_connected(bool _connected) { } } -template -void client_endpoint_impl::prepare_stop(const boardnet_endpoint::prepare_stop_handler_t& _handler, service_t _service) { - - (void)_handler; - (void)_service; -} - template void client_endpoint_impl::stop(bool _due_to_error) { { - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); endpoint_impl::sending_blocked_ = true; // delete unsent messages queue_.clear(); @@ -164,7 +157,7 @@ bool client_endpoint_impl::send_error(const std::shared_ptr bool client_endpoint_impl::send(const uint8_t* _data, uint32_t _size) { - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); bool must_depart(false); auto its_now(std::chrono::steady_clock::now()); @@ -332,7 +325,7 @@ bool client_endpoint_impl::flush() { bool has_queued(true); bool is_current_train(true); - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); std::shared_ptr its_train(train_); if (!dispatched_trains_.empty()) { @@ -494,7 +487,7 @@ void client_endpoint_impl::send_cbk(boost::system::error_code const& _ (void)_bytes; if (!_error) { - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); if (queue_.size() > 0) { queue_size_ -= queue_.front().first->size(); queue_.pop_front(); @@ -526,7 +519,7 @@ void client_endpoint_impl::send_cbk(boost::system::error_code const& _ bool stopping(false); { - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); stopping = endpoint_impl::sending_blocked_; if (stopping) { queue_.clear(); @@ -566,7 +559,7 @@ void client_endpoint_impl::send_cbk(boost::system::error_code const& _ } if (_error == boost::asio::error::no_permission) { - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); queue_.clear(); queue_size_ = 0; } @@ -604,7 +597,7 @@ void client_endpoint_impl::send_cbk(boost::system::error_code const& _ print_status(); } - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); was_not_connected_ = true; is_sending_ = false; } @@ -831,7 +824,7 @@ void client_endpoint_impl::queue_train(const std::shared_ptr& _ template size_t client_endpoint_impl::get_queue_size() const { - std::lock_guard its_lock(mutex_); + std::scoped_lock its_lock(mutex_); return queue_size_; } diff --git a/implementation/endpoints/src/credentials.cpp b/implementation/endpoints/src/credentials.cpp deleted file mode 100644 index c9cafffe2..000000000 --- a/implementation/endpoints/src/credentials.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#if defined(__linux__) - -#include -#include -#include - -#include "../include/credentials.hpp" - -#include -#ifdef ANDROID -#include "../../configuration/include/internal_android.hpp" -#else -#include "../../configuration/include/internal.hpp" -#endif - -namespace vsomeip_v3 { - -void credentials::activate_credentials(const int _fd) { - int optval = 1; - if (setsockopt(_fd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)) == -1) { - VSOMEIP_ERROR << __func__ << ": vSomeIP Security: Activating socket option for receiving " - << "credentials failed."; - } -} - -void credentials::deactivate_credentials(const int _fd) { - int optval = 0; - if (setsockopt(_fd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)) == -1) { - VSOMEIP_ERROR << __func__ << ": vSomeIP Security: Deactivating socket option for receiving " - << "credentials failed."; - } -} - -boost::optional credentials::receive_credentials(const int _fd) { - struct msghdr msgh; - struct iovec iov[2]; - union { - struct cmsghdr cmh; - char control[CMSG_SPACE(sizeof(struct ucred))]; - } control_un; - - // We don't need address of peer as we using connect - msgh.msg_name = NULL; - msgh.msg_namelen = 0; - - // Set fields of 'msgh' to point to buffer used to receive (real) data read by recvmsg() - msgh.msg_iov = iov; - msgh.msg_iovlen = 2; - - // Set 'msgh' fields to describe 'control_un' - msgh.msg_control = control_un.control; - msgh.msg_controllen = sizeof(control_un.control); - - // Sender client_id and client_host_length will be received as data - client_t client = VSOMEIP_ROUTING_CLIENT; - uint8_t client_host_length(0); - iov[0].iov_base = &client; - iov[0].iov_len = sizeof(client_t); - iov[1].iov_base = &client_host_length; - iov[1].iov_len = sizeof(uint8_t); - - // Set 'control_un' to describe ancillary data that we want to receive - control_un.cmh.cmsg_len = CMSG_LEN(sizeof(struct ucred)); - control_un.cmh.cmsg_level = SOL_SOCKET; - control_un.cmh.cmsg_type = SCM_CREDENTIALS; - - // Receive client_id plus client_host_length plus ancillary data - ssize_t nr = recvmsg(_fd, &msgh, 0); - if (nr == -1) { - VSOMEIP_ERROR << __func__ << ": vSomeIP Security: Receiving credentials failed. No data. errno: " << errno; - return boost::none; - } - - struct cmsghdr* cmhp = CMSG_FIRSTHDR(&msgh); - if (cmhp == NULL || cmhp->cmsg_len != CMSG_LEN(sizeof(struct ucred)) || cmhp->cmsg_level != SOL_SOCKET - || cmhp->cmsg_type != SCM_CREDENTIALS) { - VSOMEIP_ERROR << __func__ << ": vSomeIP Security: Receiving credentials failed. Invalid data."; - return boost::none; - } - - // Use the implicitly-defined copy constructor - struct ucred ucred = *reinterpret_cast(CMSG_DATA(cmhp)); - - msgh.msg_iov = iov; - msgh.msg_iovlen = 1; - msgh.msg_control = nullptr; - msgh.msg_controllen = 0; - - // Receive client_host as data - std::string client_host(client_host_length, '\0'); - iov[0].iov_base = &client_host.front(); - iov[0].iov_len = client_host.length(); - - nr = recvmsg(_fd, &msgh, 0); - if (nr == -1) { - VSOMEIP_ERROR << __func__ << ": vSomeIP Security: Receiving client host failed. No data. errno: " << errno; - return boost::none; - } - - return received_t{client, ucred.uid, ucred.gid, client_host}; -} - -void credentials::send_credentials(const int _fd, client_t _client, std::string _client_host) { - struct msghdr msgh; - struct iovec iov[3]; - auto client_host_length = static_cast(_client_host.length()); - - // data to send - msgh.msg_iov = &iov[0]; - msgh.msg_iovlen = 3; - iov[0].iov_base = &_client; - iov[0].iov_len = sizeof(client_t); - iov[1].iov_base = &client_host_length; - iov[1].iov_len = sizeof(uint8_t); - iov[2].iov_base = &_client_host[0]; - iov[2].iov_len = client_host_length; - - // destination not needed as we use connect - msgh.msg_name = NULL; - msgh.msg_namelen = 0; - - // credentials not need to set explicitly - msgh.msg_control = NULL; - msgh.msg_controllen = 0; - - // send client id with credentials - ssize_t ns = sendmsg(_fd, &msgh, MSG_NOSIGNAL); - if (ns == -1) { - VSOMEIP_ERROR << __func__ << ": vSomeIP Security: Sending credentials failed. errno: " << errno; - } -} - -} // namespace vsomeip_v3 - -#endif // __linux__ diff --git a/implementation/endpoints/src/endpoint_impl.cpp b/implementation/endpoints/src/endpoint_impl.cpp index 6dbdb3b59..df77a3ede 100644 --- a/implementation/endpoints/src/endpoint_impl.cpp +++ b/implementation/endpoints/src/endpoint_impl.cpp @@ -63,9 +63,6 @@ void endpoint_impl::add_default_target(service_t, const std::string&, template void endpoint_impl::remove_default_target(service_t) { } -template -void endpoint_impl::remove_stop_handler(service_t) { } - template instance_t endpoint_impl::get_instance(service_t _service) { diff --git a/implementation/endpoints/src/endpoint_manager_impl.cpp b/implementation/endpoints/src/endpoint_manager_impl.cpp index b595eb51f..6a4575adb 100644 --- a/implementation/endpoints/src/endpoint_manager_impl.cpp +++ b/implementation/endpoints/src/endpoint_manager_impl.cpp @@ -71,7 +71,7 @@ std::shared_ptr endpoint_manager_impl::find_or_create_remote_ std::shared_ptr its_endpoint; bool start_endpoint(false); { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); its_endpoint = find_remote_client(_service, _instance, _reliable); if (!its_endpoint) { its_endpoint = create_remote_client(_service, _instance, _reliable); @@ -97,7 +97,7 @@ void endpoint_manager_impl::find_or_create_remote_client(service_t _service, ins bool start_reliable_endpoint(false); bool start_unreliable_endpoint(false); { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); its_reliable_endpoint = find_remote_client(_service, _instance, true); if (!its_reliable_endpoint) { its_reliable_endpoint = create_remote_client(_service, _instance, true); @@ -126,7 +126,7 @@ void endpoint_manager_impl::is_remote_service_known(service_t _service, instance const boost::asio::ip::address& _unreliable_address, uint16_t _unreliable_port, bool* _unreliable_known) const { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_service = remote_service_info_.find(_service); if (found_service != remote_service_info_.end()) { auto found_instance = found_service->second.find(_instance); @@ -173,15 +173,13 @@ void endpoint_manager_impl::add_remote_service_info(service_t _service, instance std::shared_ptr its_endpoint; bool must_report(false); { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); remote_service_info_[_service][_instance][_ep_definition->is_reliable()] = _ep_definition; - if (_ep_definition->is_reliable()) { - its_endpoint = find_remote_client(_service, _instance, true); - must_report = (its_endpoint && its_endpoint->is_established_or_connected()); - if (must_report) - its_info = rm_->find_service(_service, _instance); - } + its_endpoint = find_remote_client(_service, _instance, _ep_definition->is_reliable()); + must_report = (its_endpoint && its_endpoint->is_established_or_connected()); + if (must_report) + its_info = rm_->find_service(_service, _instance); } if (must_report) @@ -197,7 +195,7 @@ void endpoint_manager_impl::add_remote_service_info(service_t _service, instance std::shared_ptr its_reliable, its_unreliable; bool must_report(false); { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); remote_service_info_[_service][_instance][false] = _ep_definition_unreliable; remote_service_info_[_service][_instance][true] = _ep_definition_reliable; @@ -220,7 +218,7 @@ void endpoint_manager_impl::add_remote_service_info(service_t _service, instance } void endpoint_manager_impl::clear_remote_service_info(service_t _service, instance_t _instance, bool _reliable) { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); const auto found_service = remote_service_info_.find(_service); if (found_service != remote_service_info_.end()) { const auto found_instance = found_service->second.find(_instance); @@ -250,7 +248,7 @@ std::shared_ptr endpoint_manager_impl::create_server_endpoint boost::asio::ip::address its_unicast{configuration_->get_unicast_address()}; const std::string its_unicast_str{its_unicast.to_string()}; - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); if (_start) { if (_reliable) { bool its_magic_cookies_enabled = configuration_->has_enabled_magic_cookies(its_unicast_str, _port) @@ -295,7 +293,7 @@ std::shared_ptr endpoint_manager_impl::create_server_endpoint std::shared_ptr endpoint_manager_impl::find_server_endpoint(uint16_t _port, bool _reliable) const { std::shared_ptr its_endpoint; - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_port = server_endpoints_.find(_port); if (found_port != server_endpoints_.end()) { auto found_endpoint = found_port->second.find(_reliable); @@ -317,7 +315,7 @@ std::shared_ptr endpoint_manager_impl::find_or_create_server_ _is_found = true; } if (its_endpoint) { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); if (!_is_multicast) { service_instances_[_service][its_endpoint.get()] = _instance; } @@ -329,7 +327,7 @@ bool endpoint_manager_impl::remove_server_endpoint(uint16_t _port, bool _reliabl std::shared_ptr its_endpoint; { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_port = server_endpoints_.find(_port); if (found_port != server_endpoints_.end()) { auto found_reliable = found_port->second.find(_reliable); @@ -340,7 +338,7 @@ bool endpoint_manager_impl::remove_server_endpoint(uint16_t _port, bool _reliabl } if (!is_used_endpoint(its_endpoint.get())) { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_port = server_endpoints_.find(_port); if (found_port != server_endpoints_.end()) { if (found_port->second.erase(_reliable)) { @@ -366,7 +364,7 @@ void endpoint_manager_impl::clear_client_endpoints(service_t _service, instance_ bool other_services_reachable_through_endpoint(false); { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); // Clear client endpoints for remote services (generic and specific ones) const auto found_service = remote_services_.find(_service); if (found_service != remote_services_.end()) { @@ -465,7 +463,7 @@ void endpoint_manager_impl::find_or_create_multicast_endpoint(service_t _service const boost::asio::ip::address& _address, uint16_t _port) { bool is_known_multicast(false); { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); const auto found_service = multicast_info_.find(_service); if (found_service != multicast_info_.end()) { const auto found_instance = found_service->second.find(_instance); @@ -487,14 +485,14 @@ void endpoint_manager_impl::find_or_create_multicast_endpoint(service_t _service // Only save multicast info if we created a new endpoint // to be able to delete the new endpoint // as soon as the instance stops offering its service - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); std::shared_ptr endpoint_def = endpoint_definition::get(_address, _port, false, _service, _instance); multicast_info_[_service][_instance] = endpoint_def; } if (its_endpoint) { if (!is_known_multicast) { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); service_instances_multicast_[_service][_sender] = _instance; } @@ -511,7 +509,7 @@ void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, instan std::string its_address; { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); // Clear multicast info and endpoint and multicast instance (remote service) if (multicast_info_.find(_service) != multicast_info_.end()) { if (multicast_info_[_service].find(_instance) != multicast_info_[_service].end()) { @@ -548,7 +546,7 @@ void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, instan bool endpoint_manager_impl::supports_selective(service_t _service, instance_t _instance) const { bool supports_selective(false); - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); const auto its_service = remote_service_info_.find(_service); if (its_service != remote_service_info_.end()) { const auto its_instance = its_service->second.find(_instance); @@ -570,7 +568,7 @@ void endpoint_manager_impl::print_status() const { client_endpoints_t its_client_endpoints; server_endpoints_t its_server_endpoints; { - std::scoped_lock its_lock{endpoint_mutex_}; + std::scoped_lock its_lock(endpoint_mutex_); its_client_endpoints = client_endpoints_; its_server_endpoints = server_endpoints_; } @@ -753,7 +751,7 @@ bool endpoint_manager_impl::create_routing_root(std::shared_ptr& _ instance_t endpoint_manager_impl::find_instance(service_t _service, boardnet_endpoint* const _endpoint) const { instance_t its_instance(0xFFFF); - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_service = service_instances_.find(_service); if (found_service != service_instances_.end()) { auto found_endpoint = found_service->second.find(_endpoint); @@ -766,7 +764,7 @@ instance_t endpoint_manager_impl::find_instance(service_t _service, boardnet_end instance_t endpoint_manager_impl::find_instance_multicast(service_t _service, const boost::asio::ip::address& _sender) const { instance_t its_instance(0xFFFF); - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_service = service_instances_multicast_.find(_service); if (found_service != service_instances_multicast_.end()) { auto found_sender = found_service->second.find(_sender); @@ -779,7 +777,7 @@ instance_t endpoint_manager_impl::find_instance_multicast(service_t _service, co bool endpoint_manager_impl::remove_instance(service_t _service, boardnet_endpoint* const _endpoint) { { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_service = service_instances_.find(_service); if (found_service != service_instances_.end()) { if (found_service->second.erase(_endpoint)) { @@ -793,7 +791,7 @@ bool endpoint_manager_impl::remove_instance(service_t _service, boardnet_endpoin } bool endpoint_manager_impl::remove_instance_multicast(service_t _service, instance_t _instance) { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); auto found_service = service_instances_multicast_.find(_service); if (found_service != service_instances_multicast_.end()) { for (auto& its_sender : found_service->second) { @@ -829,7 +827,7 @@ void endpoint_manager_impl::on_connect(std::shared_ptr _endpo std::forward_list services_to_report_; { const bool endpoint_is_reliable = _endpoint->is_reliable(); - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); for (auto& its_service : remote_services_) { for (auto& its_instance : its_service.second) { auto found_endpoint = its_instance.second.find(endpoint_is_reliable); @@ -863,7 +861,7 @@ void endpoint_manager_impl::on_connect(std::shared_ptr _endpo void endpoint_manager_impl::on_disconnect(std::shared_ptr _endpoint) { // Is called when endpoint->connect fails! - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); for (auto& its_service : remote_services_) { for (auto& its_instance : its_service.second) { const bool is_reliable = _endpoint->is_reliable(); @@ -890,7 +888,7 @@ void endpoint_manager_impl::on_disconnect(std::shared_ptr _en bool endpoint_manager_impl::on_bind_error(std::shared_ptr _endpoint, const boost::asio::ip::address& _remote_address, std::uint16_t _remote_port, uint16_t& _local_port) { - std::lock_guard its_ep_lock(endpoint_mutex_); + std::scoped_lock its_ep_lock{endpoint_mutex_}; for (auto& its_service : remote_services_) { for (auto& its_instance : its_service.second) { const bool is_reliable = _endpoint->is_reliable(); @@ -1110,7 +1108,7 @@ void endpoint_manager_impl::log_client_states() const { std::vector, size_t>> its_client_queue_sizes; { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); its_client_endpoints = client_endpoints_; } @@ -1151,7 +1149,7 @@ void endpoint_manager_impl::log_server_states() const { std::vector, size_t>> its_client_queue_sizes; { - std::scoped_lock its_lock{endpoint_mutex_}; + std::scoped_lock its_lock(endpoint_mutex_); its_server_endpoints = server_endpoints_; } @@ -1242,7 +1240,7 @@ void endpoint_manager_impl::process_multicast_options() { bool endpoint_manager_impl::is_used_endpoint(boardnet_endpoint* const _endpoint) const { { - std::lock_guard its_lock(endpoint_mutex_); + std::scoped_lock its_lock(endpoint_mutex_); // Do we still use the endpoint to offer a service instance? for (const auto& si : service_instances_) if (si.second.find(_endpoint) != si.second.end()) @@ -1282,7 +1280,7 @@ void endpoint_manager_impl::resume() { std::vector> servers; { - std::scoped_lock its_lock{endpoint_mutex_}; + std::scoped_lock its_lock(endpoint_mutex_); // restart client endpoints @@ -1309,7 +1307,7 @@ void endpoint_manager_impl::resume() { std::shared_ptr its_endpoint; { - std::scoped_lock its_lock{endpoint_mutex_}; + std::scoped_lock its_lock(endpoint_mutex_); const auto& ports = client_endpoints_.find(its_address); if (ports == client_endpoints_.end()) { @@ -1346,7 +1344,7 @@ void endpoint_manager_impl::resume() { std::shared_ptr its_endpoint; { - std::scoped_lock its_lock{endpoint_mutex_}; + std::scoped_lock its_lock(endpoint_mutex_); const auto& ports = server_endpoints_.find(its_port); if (ports == server_endpoints_.end()) { @@ -1369,7 +1367,7 @@ void endpoint_manager_impl::resume() { std::shared_ptr its_check_endpoint; { - std::scoped_lock its_lock{endpoint_mutex_}; + std::scoped_lock its_lock(endpoint_mutex_); const auto& ports = server_endpoints_.find(its_port); if (ports != server_endpoints_.end()) { diff --git a/implementation/endpoints/src/local_endpoint.cpp b/implementation/endpoints/src/local_endpoint.cpp index 70771a0f0..9e225534c 100644 --- a/implementation/endpoints/src/local_endpoint.cpp +++ b/implementation/endpoints/src/local_endpoint.cpp @@ -79,14 +79,23 @@ void local_endpoint::start() { if (state_ == state_e::INIT) { connect_unlock(); } else if (state_ == state_e::CONNECTED) { - send_unlock(); - // process is not allowed to be called with a lock hold, as process - // might dispatch to a callback - lock.unlock(); - if (!process(0)) { - escalate(); - return; - } + // Posting the actual start action here ensures that + // every public method can be called without re-entering any other callback. + boost::asio::post(io_, [this, weak_self = weak_from_this()] { + if (auto self = weak_self.lock(); self) { + std::unique_lock inner_lock{mutex_}; + // ensure that we weren't stopped in between + if (state_ != state_e::CONNECTED) { + VSOMEIP_INFO << "le::start::post: Not starting to process due to state: " << status_unlock(); + return; + } + if (!process(0, inner_lock)) { + escalate_internal(inner_lock); + } + // sending is not required to be started here, as nothing + // should be in the queue for the just accepted connection + } + }); } else { VSOMEIP_ERROR << "le::" << __func__ << ": Unexpected state when trying to start: " << status_unlock(); } @@ -366,8 +375,7 @@ void local_endpoint::send_cbk(boost::system::error_code const& _ec, [[maybe_unus VSOMEIP_WARNING << "le::" << __func__ << " not dealing with the error: " << _ec.message() << ", " << status(); } -[[nodiscard]] bool local_endpoint::process(size_t _new_bytes) { - std::unique_lock lock{mutex_}; +[[nodiscard]] bool local_endpoint::process(size_t _new_bytes, std::unique_lock& _lock) { if (_new_bytes > 0 && !receive_buffer_->bump_end(_new_bytes)) { VSOMEIP_ERROR << "le::" << __func__ << ": inconsistent buffer handling, trying add the read of: " << _new_bytes << " bytes, escalating on " << status_unlock(); @@ -389,17 +397,17 @@ void local_endpoint::send_cbk(boost::system::error_code const& _ec, [[maybe_unus assignment_timebox_->stop(); } } - lock.unlock(); // fine to unlock, because the caller needs to return, before we would schedule another read + _lock.unlock(); // fine to unlock, because the caller needs to return, before we would schedule another read routing->on_message(result.message_data_, result.message_size_, nullptr, false, peer_, &sec_client_, endpoint.address(), endpoint.port()); - lock.lock(); // because next_message changes internal state -> lock + _lock.lock(); // because next_message changes internal state -> lock } } else { while (receive_buffer_->next_message(result)) { - lock.unlock(); // fine to unlock, because the caller needs to return, before we would schedule another read + _lock.unlock(); // fine to unlock, because the caller needs to return, before we would schedule another read routing->on_message(result.message_data_, result.message_size_, nullptr, false, peer_, &sec_client_, endpoint.address(), endpoint.port()); - lock.lock(); // because next_message changes internal state -> lock + _lock.lock(); // because next_message changes internal state -> lock } } if (result.error_) { @@ -428,8 +436,8 @@ void local_endpoint::receive_cbk(boost::system::error_code const& _ec, size_t _b } return; } - if (!process(_bytes)) { - escalate(); + if (std::unique_lock lock{mutex_}; !process(_bytes, lock)) { + escalate_internal(lock); } } @@ -486,7 +494,7 @@ void local_endpoint::flush_queue() { } if (is_sending_ || !send_queue_.empty() || send_buffer_size > 0) { - VSOMEIP_WARNING << "ls::" << __func__ << ": waiting[" << retry_count << "] on close to send remaining data, " << status_unlock() + VSOMEIP_WARNING << "le::" << __func__ << ": waiting[" << retry_count << "] on close to send remaining data, " << status_unlock() << " and send_buffer_size: " << send_buffer_size; lock.unlock(); std::this_thread::sleep_for(std::chrono::milliseconds(VSOMEIP_LOCAL_CLOSE_SEND_BUFFER_CHECK_PERIOD)); @@ -496,7 +504,7 @@ void local_endpoint::flush_queue() { break; } if (retry_count > VSOMEIP_LOCAL_CLOSE_SEND_BUFFER_RETRIES) { - VSOMEIP_ERROR << "ls::" << __func__ << ": max retries reached to send! will drop remaining data on close, " << status_unlock() + VSOMEIP_ERROR << "le::" << __func__ << ": max retries reached to send! will drop remaining data on close, " << status_unlock() << " and send_buffer_size: " << send_buffer_size; ; break; diff --git a/implementation/endpoints/src/local_server.cpp b/implementation/endpoints/src/local_server.cpp index dcc87cd62..831cbd289 100644 --- a/implementation/endpoints/src/local_server.cpp +++ b/implementation/endpoints/src/local_server.cpp @@ -220,8 +220,6 @@ void local_server::add_connection(client_t _client, [[maybe_unused]] client_t _e } } }); - // Carful: A call to start might end up calling the error handler causing a lock inversion - lock.unlock(); ep->start(); } else { VSOMEIP_WARNING << "ls::" << __func__ << ": Dropping connection from: " << std::hex << std::setfill('0') << std::setw(4) @@ -329,8 +327,9 @@ void local_server::tmp_connection::receive_cbk(boost::system::error_code const& return; } } else { - VSOMEIP_ERROR << "ls::" << __func__ << ": Unexpected command: " << result.message_data_[protocol::COMMAND_POSITION_ID] - << " received. Breaking connection > " << socket_->to_string(); + VSOMEIP_ERROR << "ls::" << __func__ << ": Unexpected command: 0x" << std::hex << std::setfill('0') << std::setw(2) + << static_cast(result.message_data_[protocol::COMMAND_POSITION_ID]) << " received. Breaking connection > " + << socket_->to_string(); socket_->stop(true); return; } diff --git a/implementation/endpoints/src/netlink_connector.cpp b/implementation/endpoints/src/netlink_connector.cpp index 0aea9ae95..505b95d1a 100644 --- a/implementation/endpoints/src/netlink_connector.cpp +++ b/implementation/endpoints/src/netlink_connector.cpp @@ -310,8 +310,8 @@ void netlink_connector::send_ifa_request(std::uint32_t _retry) { { std::lock_guard its_lock(socket_mutex_); socket_.async_send(boost::asio::buffer(get_address_msg.get(), get_address_msg->nlhdr.nlmsg_len), - [this, data = get_address_msg](auto... args) mutable { - send_cbk(args...); + [self = shared_from_this(), data = get_address_msg](auto... args) mutable { + self->send_cbk(args...); data.reset(); }); } @@ -344,8 +344,8 @@ void netlink_connector::send_ifi_request(std::uint32_t _retry) { { std::lock_guard its_lock(socket_mutex_); socket_.async_send(boost::asio::buffer(get_link_msg.get(), sizeof(*get_link_msg)), - [this, data = get_link_msg](auto... args) mutable { - send_cbk(args...); + [self = shared_from_this(), data = get_link_msg](auto... args) mutable { + self->send_cbk(args...); data.reset(); }); } @@ -375,8 +375,8 @@ void netlink_connector::send_rt_request(std::uint32_t _retry) { { std::lock_guard its_lock(socket_mutex_); socket_.async_send(boost::asio::buffer(get_route_msg.get(), sizeof(*get_route_msg)), - [this, data = get_route_msg](auto... args) mutable { - send_cbk(args...); + [self = shared_from_this(), data = get_route_msg](auto... args) mutable { + self->send_cbk(args...); data.reset(); }); } diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index 3e020cc98..2a94a17ca 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -33,73 +33,6 @@ server_endpoint_impl::server_endpoint_impl(const std::shared_ptr& _configuration) : endpoint_impl(_boardnet_endpoint_host, _routing_host, _io, _configuration) { } -template -void server_endpoint_impl::prepare_stop(const boardnet_endpoint::prepare_stop_handler_t& _handler, service_t _service) { - - std::scoped_lock its_lock(mutex_); - std::vector its_erased; - - if (_service == ANY_SERVICE) { - endpoint_impl::sending_blocked_ = true; - if (std::all_of(targets_.begin(), targets_.end(), - [&](const typename target_data_type::value_type& _t) { return _t.second.queue_.empty(); })) { - // nothing was queued and all queues are empty -> ensure cbk is called - auto ptr = this->shared_from_this(); - boost::asio::post(endpoint_impl::io_, [ptr, _handler]() { _handler(ptr); }); - } else { - prepare_stop_handlers_[_service] = _handler; - } - - for (auto t = targets_.begin(); t != targets_.end(); t++) { - auto its_train(t->second.train_); - // cancel dispatch timer - t->second.dispatch_timer_->cancel(); - if (its_train->buffer_->size() > 0) { - if (queue_train(t, its_train)) - its_erased.push_back(t); - } - } - } else { - // check if any of the queues contains a message of to be stopped service - bool found_service_msg(false); - for (const auto& t : targets_) { - for (const auto& q : t.second.queue_) { - const service_t its_service = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_SERVICE_POS_MIN]); - if (its_service == _service) { - found_service_msg = true; - break; - } - } - if (found_service_msg) { - break; - } - } - if (found_service_msg) { - prepare_stop_handlers_[_service] = _handler; - } else { // no messages of the to be stopped service are or have been queued - auto ptr = this->shared_from_this(); - boost::asio::post(endpoint_impl::io_, [ptr, _handler]() { _handler(ptr); }); - } - - for (auto t = targets_.begin(); t != targets_.end(); t++) { - auto its_train(t->second.train_); - for (auto const& passenger_iter : its_train->passengers_) { - if (passenger_iter.first == _service) { - // cancel dispatch timer - t->second.dispatch_timer_->cancel(); - // TODO: Queue all(!) trains here... - if (queue_train(t, its_train)) - its_erased.push_back(t); - break; - } - } - } - } - - for (const auto t : its_erased) - targets_.erase(t); -} - template void server_endpoint_impl::stop(bool /*_due_to_error*/) { } @@ -196,19 +129,6 @@ bool server_endpoint_impl::send_intern(endpoint_type _target, const by return segment_message(_data, _size, _target) == endpoint_impl::cms_ret_e::MSG_WAS_SPLIT; } - if (!prepare_stop_handlers_.empty()) { - const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); - if (prepare_stop_handlers_.find(its_service) != prepare_stop_handlers_.end()) { - const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); - const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); - VSOMEIP_WARNING << "server_endpoint::send: Service is stopping, ignoring message: [" << std::hex << std::setfill('0') - << std::setw(4) << its_service << "." << std::setw(4) << its_method << "." << std::setw(4) << its_client << "." - << std::setw(4) << its_session << "]"; - return false; - } - } - const auto its_target_iterator = find_or_create_target_unlocked(_target); auto& its_data(its_target_iterator->second); @@ -543,57 +463,6 @@ void server_endpoint_impl::connect_cbk(boost::system::error_code const template void server_endpoint_impl::send_cbk(const endpoint_type _key, boost::system::error_code const& _error, std::size_t _bytes) { (void)_bytes; - // Helper - auto check_if_all_msgs_for_stopped_service_are_sent = [&]() { - bool found_service_msg(false); - service_t its_stopped_service(ANY_SERVICE); - for (auto stp_hndlr_iter = prepare_stop_handlers_.begin(); stp_hndlr_iter != prepare_stop_handlers_.end();) { - its_stopped_service = stp_hndlr_iter->first; - if (its_stopped_service == ANY_SERVICE) { - ++stp_hndlr_iter; - continue; - } - for (const auto& t : targets_) { - for (const auto& e : t.second.queue_) { - const service_t its_service = bithelper::read_uint16_be(&(*e.first)[VSOMEIP_SERVICE_POS_MIN]); - if (its_service == its_stopped_service) { - found_service_msg = true; - break; - } - } - if (found_service_msg) { - break; - } - } - if (found_service_msg) { - ++stp_hndlr_iter; - } else { // all messages of the to be stopped service have been sent - auto handler = stp_hndlr_iter->second; - auto ptr = this->shared_from_this(); - boost::asio::post(endpoint_impl::io_, [ptr, handler]() { handler(ptr); }); - stp_hndlr_iter = prepare_stop_handlers_.erase(stp_hndlr_iter); - } - } - }; - - auto check_if_all_queues_are_empty = [&]() { - if (prepare_stop_handlers_.size() > 1) { - // before the endpoint was stopped completely other - // prepare_stop_handlers have been queued ensure to call them as well - check_if_all_msgs_for_stopped_service_are_sent(); - } - if (std::all_of(targets_.begin(), targets_.end(), - [&](const typename target_data_type::value_type& _t) { return _t.second.queue_.empty(); })) { - // all outstanding response have been sent. - auto found_cbk = prepare_stop_handlers_.find(ANY_SERVICE); - if (found_cbk != prepare_stop_handlers_.end()) { - auto handler = found_cbk->second; - auto ptr = this->shared_from_this(); - boost::asio::post(endpoint_impl::io_, [ptr, handler]() { handler(ptr); }); - prepare_stop_handlers_.erase(found_cbk); - } - } - }; std::scoped_lock its_lock(mutex_); @@ -652,19 +521,8 @@ void server_endpoint_impl::send_cbk(const endpoint_type _key, boost::s update_last_departure(its_data); - if (!prepare_stop_handlers_.empty() && !endpoint_impl::sending_blocked_) { - // only one service instance is stopped - check_if_all_msgs_for_stopped_service_are_sent(); - } - if (its_data.queue_.empty() || !send_queued(it)) { - if (!prepare_stop_handlers_.empty() && endpoint_impl::sending_blocked_) { - // endpoint is shutting down completely - cancel_dispatch_timer(it); - targets_.erase(it); - check_if_all_queues_are_empty(); - } else - its_data.is_sending_ = false; + its_data.is_sending_ = false; } } else { // error: sending of outstanding responses isn't started again @@ -677,16 +535,6 @@ void server_endpoint_impl::send_cbk(const endpoint_type _key, boost::s << " endpoint -> " << this; cancel_dispatch_timer(it); targets_.erase(it); - if (!prepare_stop_handlers_.empty()) { - if (endpoint_impl::sending_blocked_) { - // endpoint is shutting down completely, ensure to call - // prepare_stop_handlers even in error cases - check_if_all_queues_are_empty(); - } else { - // only one service instance is stopped - check_if_all_msgs_for_stopped_service_are_sent(); - } - } } } @@ -699,19 +547,6 @@ void server_endpoint_impl::flush_cbk(endpoint_type _key, const boost:: } } -template -void server_endpoint_impl::remove_stop_handler(service_t _service) { - std::stringstream its_services_log; - its_services_log << __func__ << ": "; - - std::scoped_lock its_lock{mutex_}; - for (const auto& its_service : prepare_stop_handlers_) - its_services_log << std::hex << std::setfill('0') << std::setw(4) << its_service.first << ' '; - - VSOMEIP_INFO << its_services_log.str(); - prepare_stop_handlers_.erase(_service); -} - template size_t server_endpoint_impl::get_queue_size() const { size_t its_queue_size(0); diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index 8b0b42409..343646778 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -370,6 +370,8 @@ bool tcp_client_endpoint_impl::get_remote_address(boost::asio::ip::address& _add } uint16_t tcp_client_endpoint_impl::get_local_port() const { + std::scoped_lock its_lock(socket_mutex_); + return local_.port(); } diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp index f1598be36..b79f65df2 100644 --- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp @@ -127,6 +127,8 @@ void tcp_server_endpoint_impl::start() { void tcp_server_endpoint_impl::stop(bool /*_due_to_error*/) { VSOMEIP_INFO << instance_name_ << __func__; + connections_t conns; + { std::scoped_lock first_lock(acceptor_mutex_); @@ -141,9 +143,13 @@ void tcp_server_endpoint_impl::stop(bool /*_due_to_error*/) { for (const auto& [_, c] : connections_) { c->stop(); } + + conns = connections_; connections_.clear(); } + conns.clear(); // release outside of held mutexes; `tsei::~connection` is non-trivial + VSOMEIP_INFO << instance_name_ << __func__ << ": done"; } @@ -188,32 +194,6 @@ bool tcp_server_endpoint_impl::send_queued(const target_data_iterator_type _it) << std::dec << static_cast(_it->first.port()) << " dropping outstanding messages (" << std::dec << _it->second.queue_.size() << ")."; - if (_it->second.queue_.size()) { - std::set its_services; - - // check all outstanding messages of this connection - // whether stop handlers need to be called - for (const auto& its_q : _it->second.queue_) { - auto its_buffer(its_q.first); - if (its_buffer && its_buffer->size() > VSOMEIP_SESSION_POS_MAX) { - service_t its_service = bithelper::read_uint16_be(&(*its_buffer)[VSOMEIP_SERVICE_POS_MIN]); - its_services.insert(its_service); - } - } - - for (auto its_service : its_services) { - auto found_cbk = prepare_stop_handlers_.find(its_service); - if (found_cbk != prepare_stop_handlers_.end()) { - VSOMEIP_INFO << instance_name_ << __func__ << ": calling prepare stop handler " - << "for service: 0x" << std::hex << std::setfill('0') << std::setw(4) << its_service; - auto handler = found_cbk->second; - auto ptr = this->shared_from_this(); - boost::asio::post(io_, [ptr, handler]() { handler(ptr); }); - prepare_stop_handlers_.erase(found_cbk); - } - } - } - // Drop outstanding messages. _it->second.queue_.clear(); must_erase = true; diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp index 88c8d04f7..1e3b45d2a 100644 --- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp @@ -194,7 +194,6 @@ void udp_client_endpoint_impl::restart(bool _force) { } void udp_client_endpoint_impl::send_queued(std::pair& _entry) { - std::scoped_lock its_last_sent_lock(last_sent_mutex_); std::scoped_lock its_socket_lock(socket_mutex_); // Check whether we need to wait (SOME/IP-TP separation time) @@ -243,6 +242,8 @@ bool udp_client_endpoint_impl::get_remote_address(boost::asio::ip::address& _add } std::uint16_t udp_client_endpoint_impl::get_local_port() const { + std::scoped_lock its_lock(socket_mutex_); + return local_.port(); } diff --git a/implementation/endpoints/src/virtual_server_endpoint_impl.cpp b/implementation/endpoints/src/virtual_server_endpoint_impl.cpp index 0bb38958c..98d22f05f 100644 --- a/implementation/endpoints/src/virtual_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/virtual_server_endpoint_impl.cpp @@ -13,21 +13,14 @@ namespace vsomeip_v3 { virtual_server_endpoint_impl::virtual_server_endpoint_impl(const std::string& _address, uint16_t _port, bool _reliable, - boost::asio::io_context& _io) : + boost::asio::io_context& /*_io*/) : - address_(_address), port_(_port), reliable_(_reliable), io_(_io) { } + address_(_address), port_(_port), reliable_(_reliable) { } virtual_server_endpoint_impl::~virtual_server_endpoint_impl() { } void virtual_server_endpoint_impl::start() { } -void virtual_server_endpoint_impl::prepare_stop(const prepare_stop_handler_t& _handler, service_t _service) { - (void)_service; - - auto ptr = shared_from_this(); - boost::asio::post(io_, [ptr, _handler]() { _handler(ptr); }); -} - void virtual_server_endpoint_impl::stop(bool /*_due_to_error*/) { } bool virtual_server_endpoint_impl::is_established() const { @@ -78,8 +71,6 @@ void virtual_server_endpoint_impl::remove_default_target(service_t _service) { (void)_service; } -void virtual_server_endpoint_impl::remove_stop_handler(service_t) { } - bool virtual_server_endpoint_impl::get_remote_address(boost::asio::ip::address& _address) const { (void)_address; return false; diff --git a/implementation/logger/include/logger_impl.hpp b/implementation/logger/include/logger_impl.hpp index 05e6f82bc..0295b5923 100644 --- a/implementation/logger/include/logger_impl.hpp +++ b/implementation/logger/include/logger_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOGGER_CONFIGURATION_HPP_ -#define VSOMEIP_V3_LOGGER_CONFIGURATION_HPP_ +#pragma once #include #include @@ -58,5 +57,3 @@ class logger_impl { } // namespace logger } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_LOGGER_CONFIGURATION_HPP_ diff --git a/implementation/message/include/deserializer.hpp b/implementation/message/include/deserializer.hpp index c6dd807eb..603035e87 100644 --- a/implementation/message/include/deserializer.hpp +++ b/implementation/message/include/deserializer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_DESERIALIZER_HPP -#define VSOMEIP_V3_DESERIALIZER_HPP +#pragma once #include #include @@ -68,5 +67,3 @@ class deserializer { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_DESERIALIZER_HPP diff --git a/implementation/message/include/message_base_impl.hpp b/implementation/message/include/message_base_impl.hpp index 998a3692c..b99fef06d 100644 --- a/implementation/message/include/message_base_impl.hpp +++ b/implementation/message/include/message_base_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_MESSAGE_BASE_IMPL_HPP -#define VSOMEIP_V3_MESSAGE_BASE_IMPL_HPP +#pragma once #include #include @@ -66,5 +65,3 @@ class message_base_impl : virtual public message_base { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_MESSAGE_BASE_IMPL_HPP diff --git a/implementation/message/include/message_header_impl.hpp b/implementation/message/include/message_header_impl.hpp index 3a2403441..e220d3da7 100644 --- a/implementation/message/include/message_header_impl.hpp +++ b/implementation/message/include/message_header_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_MESSAGE_HEADER_IMPL_HPP -#define VSOMEIP_V3_MESSAGE_HEADER_IMPL_HPP +#pragma once #include #include @@ -43,5 +42,3 @@ class message_header_impl : virtual public serializable { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_MESSAGE_HEADER_IMPL_HPP diff --git a/implementation/message/include/message_impl.hpp b/implementation/message/include/message_impl.hpp index 39fa9813b..4eece043b 100644 --- a/implementation/message/include/message_impl.hpp +++ b/implementation/message/include/message_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_MESSAGE_IMPL_HPP -#define VSOMEIP_V3_MESSAGE_IMPL_HPP +#pragma once #include @@ -63,5 +62,3 @@ class message_impl : virtual public message, virtual public message_base_impl { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_MESSAGE_IMPL_HPP diff --git a/implementation/message/include/payload_impl.hpp b/implementation/message/include/payload_impl.hpp index 2053ffaa7..5c8ee6942 100644 --- a/implementation/message/include/payload_impl.hpp +++ b/implementation/message/include/payload_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PAYLOAD_IMPL_HPP -#define VSOMEIP_V3_PAYLOAD_IMPL_HPP +#pragma once #include #include @@ -46,5 +45,3 @@ class payload_impl : public payload { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PAYLOAD_IMPL_HPP diff --git a/implementation/message/include/serializer.hpp b/implementation/message/include/serializer.hpp index ec4a28a15..ae759e848 100644 --- a/implementation/message/include/serializer.hpp +++ b/implementation/message/include/serializer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SERIALIZER_HPP -#define VSOMEIP_V3_SERIALIZER_HPP +#pragma once #include @@ -53,5 +52,3 @@ class VSOMEIP_IMPORT_EXPORT serializer { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SERIALIZER_IMPL_HPP diff --git a/implementation/plugin/include/plugin_manager_impl.hpp b/implementation/plugin/include/plugin_manager_impl.hpp index bad5d8639..6949fa732 100644 --- a/implementation/plugin/include/plugin_manager_impl.hpp +++ b/implementation/plugin/include/plugin_manager_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP -#define VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP +#pragma once #include @@ -48,5 +47,3 @@ class plugin_manager_impl : public plugin_manager { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index 866020ec7..73eef7f85 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -47,7 +47,7 @@ plugin_manager_impl::~plugin_manager_impl() { } std::shared_ptr plugin_manager_impl::get_plugin(plugin_type_e _type, const std::string& _name) { - std::lock_guard its_lock_start_stop(plugins_mutex_); + std::scoped_lock its_lock_start_stop{plugins_mutex_}; auto its_type = plugins_.find(_type); if (its_type != plugins_.end()) { auto its_name = its_type->second.find(_name); @@ -80,7 +80,7 @@ std::shared_ptr plugin_manager_impl::load_plugin(const std::string& _lib } bool plugin_manager_impl::unload_plugin(plugin_type_e _type) { - std::lock_guard its_lock_start_stop(plugins_mutex_); + std::scoped_lock its_lock_start_stop{plugins_mutex_}; const auto found_handle = handles_.find(_type); if (found_handle != handles_.end()) { for (const auto& its_name : found_handle->second) { diff --git a/implementation/protocol/include/assign_client_ack_command.hpp b/implementation/protocol/include/assign_client_ack_command.hpp index dc006311a..1e3565607 100644 --- a/implementation/protocol/include/assign_client_ack_command.hpp +++ b/implementation/protocol/include/assign_client_ack_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_ASSIGN_CLIENT_ACK_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_ASSIGN_CLIENT_ACK_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -30,5 +29,3 @@ client_t read_client_id(byte_t const* _data, uint32_t _size); } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_ASSIGN_CLIENT_ACK_COMMAND_HPP_ diff --git a/implementation/protocol/include/assign_client_command.hpp b/implementation/protocol/include/assign_client_command.hpp index 8d3e311af..0cc14aba2 100644 --- a/implementation/protocol/include/assign_client_command.hpp +++ b/implementation/protocol/include/assign_client_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_ASSIGN_CLIENT_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_ASSIGN_CLIENT_COMMAND_HPP_ +#pragma once #include @@ -33,5 +32,3 @@ class assign_client_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_ASSIGN_CLIENT_COMMAND_HPP_ diff --git a/implementation/protocol/include/command.hpp b/implementation/protocol/include/command.hpp index 23fdfc415..89621679b 100644 --- a/implementation/protocol/include/command.hpp +++ b/implementation/protocol/include/command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_COMMAND_HPP_ +#pragma once #include // memcpy #include @@ -40,5 +39,3 @@ class command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_COMMAND_HPP_ diff --git a/implementation/protocol/include/config_command.hpp b/implementation/protocol/include/config_command.hpp index d026a4363..d90425b91 100644 --- a/implementation/protocol/include/config_command.hpp +++ b/implementation/protocol/include/config_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_CONFIG_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_CONFIG_COMMAND_HPP_ +#pragma once #include @@ -63,5 +62,3 @@ class config_command final : public command { }; } // namespace vsomeip_v3::protocol - -#endif // VSOMEIP_V3_PROTOCOL_CONFIG_COMMAND_HPP_ diff --git a/implementation/protocol/include/deregister_application_command.hpp b/implementation/protocol/include/deregister_application_command.hpp index 18061d7d4..539dbefcd 100644 --- a/implementation/protocol/include/deregister_application_command.hpp +++ b/implementation/protocol/include/deregister_application_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_DEREGISTER_APPLICATION_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_DEREGISTER_APPLICATION_COMMAND_HPP_ +#pragma once #include "simple_command.hpp" @@ -19,5 +18,3 @@ class deregister_application_command : public simple_command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_DEREGISTER_APPLICATION_COMMAND_HPP_ diff --git a/implementation/protocol/include/distribute_security_policies_command.hpp b/implementation/protocol/include/distribute_security_policies_command.hpp index c09eca7d0..03313aa0b 100644 --- a/implementation/protocol/include/distribute_security_policies_command.hpp +++ b/implementation/protocol/include/distribute_security_policies_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_DISTRIBUTE_SECURITY_POLICIES_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_DISTRIBUTE_SECURITY_POLICIES_COMMAND_HPP_ +#pragma once #include #include @@ -39,5 +38,3 @@ class distribute_security_policies_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_DISTRIBUTE_SECURITY_POLICIES_COMMAND_HPP_ diff --git a/implementation/protocol/include/dummy_command.hpp b/implementation/protocol/include/dummy_command.hpp index 3887e4d39..0220065ba 100644 --- a/implementation/protocol/include/dummy_command.hpp +++ b/implementation/protocol/include/dummy_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_DUMMY_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_DUMMY_COMMAND_HPP_ +#pragma once #include "simple_command.hpp" @@ -18,5 +17,3 @@ class dummy_command : public simple_command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_DUMMY_COMMAND_HPP_ diff --git a/implementation/protocol/include/expire_command.hpp b/implementation/protocol/include/expire_command.hpp index 169a0cc77..9c80d9931 100644 --- a/implementation/protocol/include/expire_command.hpp +++ b/implementation/protocol/include/expire_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_EXPIRE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_EXPIRE_COMMAND_HPP_ +#pragma once #include @@ -30,5 +29,3 @@ class expire_command : public subscribe_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_EXPIRE_COMMAND_HPP_ diff --git a/implementation/protocol/include/multiple_services_command_base.hpp b/implementation/protocol/include/multiple_services_command_base.hpp index a16198c22..84210bbc9 100644 --- a/implementation/protocol/include/multiple_services_command_base.hpp +++ b/implementation/protocol/include/multiple_services_command_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_MULTIPLE_SERVICES_COMMAND_BASE_HPP_ -#define VSOMEIP_V3_PROTOCOL_MULTIPLE_SERVICES_COMMAND_BASE_HPP_ +#pragma once #include @@ -32,5 +31,3 @@ class multiple_services_command_base : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_MULTIPLE_SERVICES_COMMAND_BASE_HPP_ diff --git a/implementation/protocol/include/offer_service_command.hpp b/implementation/protocol/include/offer_service_command.hpp index 254c954a0..59fa3f3f8 100644 --- a/implementation/protocol/include/offer_service_command.hpp +++ b/implementation/protocol/include/offer_service_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_OFFER_SERVICE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_OFFER_SERVICE_COMMAND_HPP_ +#pragma once #include "service_command_base.hpp" @@ -19,5 +18,3 @@ class offer_service_command : public service_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_OFFER_SERVICE_COMMAND_HPP_ diff --git a/implementation/protocol/include/offered_services_request_command.hpp b/implementation/protocol/include/offered_services_request_command.hpp index 123cb03c2..a53acd53b 100644 --- a/implementation/protocol/include/offered_services_request_command.hpp +++ b/implementation/protocol/include/offered_services_request_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_OFFERED_SERVICES_REQUEST_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_OFFERED_SERVICES_REQUEST_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -28,5 +27,3 @@ class offered_services_request_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_OFFERED_SERVICES_REQUEST_COMMAND_HPP_ diff --git a/implementation/protocol/include/offered_services_response_command.hpp b/implementation/protocol/include/offered_services_response_command.hpp index b897fd5f9..897903944 100644 --- a/implementation/protocol/include/offered_services_response_command.hpp +++ b/implementation/protocol/include/offered_services_response_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_OFFERED_SERVICES_RESPONSE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_OFFERED_SERVICES_RESPONSE_COMMAND_HPP_ +#pragma once #include "multiple_services_command_base.hpp" @@ -18,5 +17,3 @@ class offered_services_response_command : public multiple_services_command_base } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_OFFERED_SERVICES_RESPONSE_COMMAND_HPP_ diff --git a/implementation/protocol/include/ping_command.hpp b/implementation/protocol/include/ping_command.hpp index 49541aa54..710979f81 100644 --- a/implementation/protocol/include/ping_command.hpp +++ b/implementation/protocol/include/ping_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_PING_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_PING_COMMAND_HPP_ +#pragma once #include "simple_command.hpp" @@ -19,5 +18,3 @@ class ping_command : public simple_command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_PING_COMMAND_HPP_ diff --git a/implementation/protocol/include/pong_command.hpp b/implementation/protocol/include/pong_command.hpp index 40266fdc1..1e54df03d 100644 --- a/implementation/protocol/include/pong_command.hpp +++ b/implementation/protocol/include/pong_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_PONG_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_PONG_COMMAND_HPP_ +#pragma once #include "simple_command.hpp" @@ -19,5 +18,3 @@ class pong_command : public simple_command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_PONG_COMMAND_HPP_ diff --git a/implementation/protocol/include/protocol.hpp b/implementation/protocol/include/protocol.hpp index e4eafdab9..c09c09179 100644 --- a/implementation/protocol/include/protocol.hpp +++ b/implementation/protocol/include/protocol.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_PROTOCOL_HPP_ -#define VSOMEIP_V3_PROTOCOL_PROTOCOL_HPP_ +#pragma once #include #include @@ -127,5 +126,3 @@ static inline bool operator==(const id_e& _lhs, const byte_t& _rhs) { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_PROTOCOL_HPP_ diff --git a/implementation/protocol/include/register_application_command.hpp b/implementation/protocol/include/register_application_command.hpp index 33ef1a136..8db2b1bbc 100644 --- a/implementation/protocol/include/register_application_command.hpp +++ b/implementation/protocol/include/register_application_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_REGISTER_APPLICATION_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_REGISTER_APPLICATION_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -28,5 +27,3 @@ class register_application_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REGISTER_APPLICATION_COMMAND_HPP_ diff --git a/implementation/protocol/include/register_event.hpp b/implementation/protocol/include/register_event.hpp index b8a08de3e..821c14030 100644 --- a/implementation/protocol/include/register_event.hpp +++ b/implementation/protocol/include/register_event.hpp @@ -1,5 +1,4 @@ -#ifndef VSOMEIP_V3_PROTOCOL_REGISTER_EVENT_HPP_ -#define VSOMEIP_V3_PROTOCOL_REGISTER_EVENT_HPP_ +#pragma once #include #include @@ -62,5 +61,3 @@ class register_event { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REGISTER_EVENT_HPP_ diff --git a/implementation/protocol/include/register_events_command.hpp b/implementation/protocol/include/register_events_command.hpp index 5e5a516ed..bcabc6cbd 100644 --- a/implementation/protocol/include/register_events_command.hpp +++ b/implementation/protocol/include/register_events_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_REGISTER_EVENTS_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_REGISTER_EVENTS_COMMAND_HPP_ +#pragma once #include @@ -34,5 +33,3 @@ class register_events_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REGISTER_EVENTS_COMMAND_HPP_ diff --git a/implementation/protocol/include/registered_ack_command.hpp b/implementation/protocol/include/registered_ack_command.hpp index b35462f5f..c3d674698 100644 --- a/implementation/protocol/include/registered_ack_command.hpp +++ b/implementation/protocol/include/registered_ack_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_REGISTERED_ACK_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_REGISTERED_ACK_COMMAND_HPP_ +#pragma once #include "simple_command.hpp" @@ -19,5 +18,3 @@ class registered_ack_command : public simple_command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REGISTERED_ACK_COMMAND_HPP_ diff --git a/implementation/protocol/include/release_service_command.hpp b/implementation/protocol/include/release_service_command.hpp index 44dec947e..f578dc06b 100644 --- a/implementation/protocol/include/release_service_command.hpp +++ b/implementation/protocol/include/release_service_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_RELEASE_SERVICE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_RELEASE_SERVICE_COMMAND_HPP_ +#pragma once #include @@ -34,5 +33,3 @@ class release_service_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_RELEASE_SERVICE_COMMAND_HPP_ diff --git a/implementation/protocol/include/remove_security_policy_command.hpp b/implementation/protocol/include/remove_security_policy_command.hpp index 792c97fe7..0dd7530f6 100644 --- a/implementation/protocol/include/remove_security_policy_command.hpp +++ b/implementation/protocol/include/remove_security_policy_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_REMOVE_SECURITY_POLICY_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_REMOVE_SECURITY_POLICY_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -36,5 +35,3 @@ class remove_security_policy_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REMOVE_SECURITY_POLICY_COMMAND_HPP_ diff --git a/implementation/protocol/include/remove_security_policy_response_command.hpp b/implementation/protocol/include/remove_security_policy_response_command.hpp index 0cab6eceb..a77aee58b 100644 --- a/implementation/protocol/include/remove_security_policy_response_command.hpp +++ b/implementation/protocol/include/remove_security_policy_response_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_REMOVE_SECURITY_POLICY_RESPONSE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_REMOVE_SECURITY_POLICY_RESPONSE_COMMAND_HPP_ +#pragma once #include "security_policy_response_command_base.hpp" @@ -19,5 +18,3 @@ class remove_security_policy_response_command : public security_policy_response_ } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REMOVE_SECURITY_POLICY_RESPONSE_COMMAND_HPP_ diff --git a/implementation/protocol/include/request_service_command.hpp b/implementation/protocol/include/request_service_command.hpp index db766ccf0..35c5f662a 100644 --- a/implementation/protocol/include/request_service_command.hpp +++ b/implementation/protocol/include/request_service_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_REQUEST_SERVICE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_REQUEST_SERVICE_COMMAND_HPP_ +#pragma once #include "multiple_services_command_base.hpp" @@ -18,5 +17,3 @@ class request_service_command : public multiple_services_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REQUEST_SERVICE_COMMAND_HPP_ diff --git a/implementation/protocol/include/resend_provided_events_command.hpp b/implementation/protocol/include/resend_provided_events_command.hpp index 0fa4581cb..09332f248 100644 --- a/implementation/protocol/include/resend_provided_events_command.hpp +++ b/implementation/protocol/include/resend_provided_events_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_RESEND_PROVIDED_EVENTS_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_RESEND_PROVIDED_EVENTS_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -28,5 +27,3 @@ class resend_provided_events_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_RESEND_PROVIDED_EVENTS_COMMAND_HPP_ diff --git a/implementation/protocol/include/routing_info_command.hpp b/implementation/protocol/include/routing_info_command.hpp index 420683277..1564534be 100644 --- a/implementation/protocol/include/routing_info_command.hpp +++ b/implementation/protocol/include/routing_info_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_ROUTING_INFO_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_ROUTING_INFO_COMMAND_HPP_ +#pragma once #include "command.hpp" #include "routing_info_entry.hpp" @@ -31,5 +30,3 @@ class routing_info_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_ROUTING_INFO_COMMAND_HPP_ diff --git a/implementation/protocol/include/routing_info_entry.hpp b/implementation/protocol/include/routing_info_entry.hpp index 16e4dbbd7..09649bde2 100644 --- a/implementation/protocol/include/routing_info_entry.hpp +++ b/implementation/protocol/include/routing_info_entry.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_ROUTING_INFO_ENTRY_HPP_ -#define VSOMEIP_V3_PROTOCOL_ROUTING_INFO_ENTRY_HPP_ +#pragma once #include @@ -53,5 +52,3 @@ class routing_info_entry { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_ROUTING_INFO_ENTRY_HPP_ diff --git a/implementation/protocol/include/security_policy_response_command_base.hpp b/implementation/protocol/include/security_policy_response_command_base.hpp index c63214a1b..bcc6de640 100644 --- a/implementation/protocol/include/security_policy_response_command_base.hpp +++ b/implementation/protocol/include/security_policy_response_command_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SECURITY_POLICY_RESPONSE_COMMAND_BASE_HPP_ -#define VSOMEIP_V3_PROTOCOL_SECURITY_POLICY_RESPONSE_COMMAND_BASE_HPP_ +#pragma once #include @@ -37,5 +36,3 @@ class security_policy_response_command_base : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SECURITY_POLICY_RESPONSE_COMMAND_BASE_HPP_ diff --git a/implementation/protocol/include/send_command.hpp b/implementation/protocol/include/send_command.hpp index f8d084de3..a585da1db 100644 --- a/implementation/protocol/include/send_command.hpp +++ b/implementation/protocol/include/send_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SEND_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_SEND_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -44,5 +43,3 @@ class send_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_BASIC_COMMAND_HPP_ diff --git a/implementation/protocol/include/service_command_base.hpp b/implementation/protocol/include/service_command_base.hpp index 67c61e0b8..0d85fc28d 100644 --- a/implementation/protocol/include/service_command_base.hpp +++ b/implementation/protocol/include/service_command_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SERVICE_COMMAND_BASE_HPP_ -#define VSOMEIP_V3_PROTOCOL_SERVICE_COMMAND_BASE_HPP_ +#pragma once #include "command.hpp" @@ -38,5 +37,3 @@ class service_command_base : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SERVICE_COMMAND_BASE_HPP_ diff --git a/implementation/protocol/include/simple_command.hpp b/implementation/protocol/include/simple_command.hpp index fc21c1ed0..dbb1a4279 100644 --- a/implementation/protocol/include/simple_command.hpp +++ b/implementation/protocol/include/simple_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SIMPLE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_SIMPLE_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -22,5 +21,3 @@ class simple_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SIMPLE_COMMAND_HPP_ diff --git a/implementation/protocol/include/stop_offer_service_command.hpp b/implementation/protocol/include/stop_offer_service_command.hpp index 662a4a389..c366383a8 100644 --- a/implementation/protocol/include/stop_offer_service_command.hpp +++ b/implementation/protocol/include/stop_offer_service_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_STOP_OFFER_SERVICE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_STOP_OFFER_SERVICE_COMMAND_HPP_ +#pragma once #include "service_command_base.hpp" @@ -19,5 +18,3 @@ class stop_offer_service_command : public service_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_STOP_OFFER_SERVICE_COMMAND_HPP_ diff --git a/implementation/protocol/include/subscribe_ack_command.hpp b/implementation/protocol/include/subscribe_ack_command.hpp index f8179b460..27f34bca5 100644 --- a/implementation/protocol/include/subscribe_ack_command.hpp +++ b/implementation/protocol/include/subscribe_ack_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SUBSCRIBE_ACK_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_SUBSCRIBE_ACK_COMMAND_HPP_ +#pragma once #include "subscribe_ack_command_base.hpp" @@ -19,5 +18,3 @@ class subscribe_ack_command : public subscribe_ack_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SUBSCRIBE_ACK_COMMAND_HPP_ diff --git a/implementation/protocol/include/subscribe_ack_command_base.hpp b/implementation/protocol/include/subscribe_ack_command_base.hpp index ed5e965e7..c27ff2160 100644 --- a/implementation/protocol/include/subscribe_ack_command_base.hpp +++ b/implementation/protocol/include/subscribe_ack_command_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SUBSCRIBE_ACK_COMMAND_BASE_HPP_ -#define VSOMEIP_V3_PROTOCOL_SUBSCRIBE_ACK_COMMAND_BASE_HPP_ +#pragma once #include @@ -50,5 +49,3 @@ class subscribe_ack_command_base : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SUBSCRIBE_ACK_COMMAND_BASE_HPP_ diff --git a/implementation/protocol/include/subscribe_command.hpp b/implementation/protocol/include/subscribe_command.hpp index b4fb878f5..d8a30b86e 100644 --- a/implementation/protocol/include/subscribe_command.hpp +++ b/implementation/protocol/include/subscribe_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SUBSCRIBE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_SUBSCRIBE_COMMAND_HPP_ +#pragma once #include @@ -33,5 +32,3 @@ class subscribe_command : public subscribe_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SUBSCRIBE_COMMAND_HPP_ diff --git a/implementation/protocol/include/subscribe_command_base.hpp b/implementation/protocol/include/subscribe_command_base.hpp index 6d5a14a93..2dd63b630 100644 --- a/implementation/protocol/include/subscribe_command_base.hpp +++ b/implementation/protocol/include/subscribe_command_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SUBSCRIBE_COMMAND_BASE_HPP_ -#define VSOMEIP_V3_PROTOCOL_SUBSCRIBE_COMMAND_BASE_HPP_ +#pragma once #include @@ -52,5 +51,3 @@ class subscribe_command_base : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SUBSCRIBE_COMMAND_BASE_HPP_ diff --git a/implementation/protocol/include/subscribe_nack_command.hpp b/implementation/protocol/include/subscribe_nack_command.hpp index 52840a747..57c457707 100644 --- a/implementation/protocol/include/subscribe_nack_command.hpp +++ b/implementation/protocol/include/subscribe_nack_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SUBSCRIBE_NACK_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_SUBSCRIBE_NACK_COMMAND_HPP_ +#pragma once #include "subscribe_ack_command_base.hpp" @@ -19,5 +18,3 @@ class subscribe_nack_command : public subscribe_ack_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SUBSCRIBE_NACK_COMMAND_HPP_ diff --git a/implementation/protocol/include/suspend_command.hpp b/implementation/protocol/include/suspend_command.hpp index 69ef39c82..7e2c10c41 100644 --- a/implementation/protocol/include/suspend_command.hpp +++ b/implementation/protocol/include/suspend_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_SUSPEND_HPP_ -#define VSOMEIP_V3_PROTOCOL_SUSPEND_HPP_ +#pragma once #include "simple_command.hpp" @@ -19,5 +18,3 @@ class suspend_command : public simple_command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_SUSPEND_COMMAND_HPP_ diff --git a/implementation/protocol/include/unregister_event_command.hpp b/implementation/protocol/include/unregister_event_command.hpp index adcb450f1..c510f80d3 100644 --- a/implementation/protocol/include/unregister_event_command.hpp +++ b/implementation/protocol/include/unregister_event_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_UNREGISTER_EVENT_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_UNREGISTER_EVENT_COMMAND_HPP_ +#pragma once #include @@ -48,5 +47,3 @@ class unregister_event_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_REGISTER_EVENT_COMMAND_HPP_ diff --git a/implementation/protocol/include/unsubscribe_ack_command.hpp b/implementation/protocol/include/unsubscribe_ack_command.hpp index 154c3d26a..625238386 100644 --- a/implementation/protocol/include/unsubscribe_ack_command.hpp +++ b/implementation/protocol/include/unsubscribe_ack_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_UNSUBSCRIBE_ACK_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_UNSUBSCRIBE_ACK_COMMAND_HPP_ +#pragma once #include "command.hpp" @@ -40,5 +39,3 @@ class unsubscribe_ack_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_UNSUBSCRIBE_ACK_COMMAND_HPP_ diff --git a/implementation/protocol/include/unsubscribe_command.hpp b/implementation/protocol/include/unsubscribe_command.hpp index 886f285f3..71c9f3cb4 100644 --- a/implementation/protocol/include/unsubscribe_command.hpp +++ b/implementation/protocol/include/unsubscribe_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_UNSUBSCRIBE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_UNSUBSCRIBE_COMMAND_HPP_ +#pragma once #include @@ -26,5 +25,3 @@ class unsubscribe_command : public subscribe_command_base { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_UNSUBSCRIBE_COMMAND_HPP_ diff --git a/implementation/protocol/include/update_security_credentials_command.hpp b/implementation/protocol/include/update_security_credentials_command.hpp index 774cf9de0..9cdd80caf 100644 --- a/implementation/protocol/include/update_security_credentials_command.hpp +++ b/implementation/protocol/include/update_security_credentials_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_CREDENTIALS_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_CREDENTIALS_COMMAND_HPP_ +#pragma once #include @@ -33,5 +32,3 @@ class update_security_credentials_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_CREDENTIALS_COMMAND_HPP_ diff --git a/implementation/protocol/include/update_security_policy_command.hpp b/implementation/protocol/include/update_security_policy_command.hpp index 2d27dde32..8710ba063 100644 --- a/implementation/protocol/include/update_security_policy_command.hpp +++ b/implementation/protocol/include/update_security_policy_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_POLICY_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_POLICY_COMMAND_HPP_ +#pragma once #include @@ -37,5 +36,3 @@ class update_security_policy_command : public command { } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_POLICY_COMMAND_HPP_ diff --git a/implementation/protocol/include/update_security_policy_response_command.hpp b/implementation/protocol/include/update_security_policy_response_command.hpp index b2e021b68..f15f00151 100644 --- a/implementation/protocol/include/update_security_policy_response_command.hpp +++ b/implementation/protocol/include/update_security_policy_response_command.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_POLICY_RESPONSE_COMMAND_HPP_ -#define VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_POLICY_RESPONSE_COMMAND_HPP_ +#pragma once #include "security_policy_response_command_base.hpp" @@ -19,5 +18,3 @@ class update_security_policy_response_command : public security_policy_response_ } // namespace protocol } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PROTOCOL_UPDATE_SECURITY_POLICY_RESPONSE_COMMAND_HPP_ diff --git a/implementation/routing/include/event.hpp b/implementation/routing/include/event.hpp index 59b43280b..85a0169a3 100644 --- a/implementation/routing/include/event.hpp +++ b/implementation/routing/include/event.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_EVENT_IMPL_HPP_ -#define VSOMEIP_V3_EVENT_IMPL_HPP_ +#pragma once #include #include @@ -133,8 +132,6 @@ class event : public std::enable_shared_from_this { bool prepare_update_payload_unlocked(const std::shared_ptr& _payload, bool _force); void update_payload_unlocked(); - void get_pending_updates(const std::set& _clients); - /// Updates the `is_set` flag to the given `value`. /// /// This is used to track changes to the flag. @@ -179,5 +176,3 @@ class event : public std::enable_shared_from_this { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_EVENT_IMPL_HPP_ diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp index d4efd17f3..eb9e200f8 100644 --- a/implementation/routing/include/eventgroupinfo.hpp +++ b/implementation/routing/include/eventgroupinfo.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_EVENTGROUPINFO_HPP_ -#define VSOMEIP_V3_EVENTGROUPINFO_HPP_ +#pragma once #include #include @@ -133,5 +132,3 @@ class eventgroupinfo { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_EVENTGROUPINFO_HPP_ diff --git a/implementation/routing/include/function_types.hpp b/implementation/routing/include/function_types.hpp index ccf9123be..36a0d6c83 100644 --- a/implementation/routing/include/function_types.hpp +++ b/implementation/routing/include/function_types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_FUNCTION_TYPES_HPP_ -#define VSOMEIP_V3_ROUTING_FUNCTION_TYPES_HPP_ +#pragma once namespace vsomeip_v3 { @@ -13,5 +12,3 @@ class remote_subscription; typedef std::function& _subscription)> remote_subscription_callback_t; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_FUNCTION_TYPES_HPP_ diff --git a/implementation/routing/include/remote_subscription.hpp b/implementation/routing/include/remote_subscription.hpp index f2643717f..4978827dc 100644 --- a/implementation/routing/include/remote_subscription.hpp +++ b/implementation/routing/include/remote_subscription.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_ -#define VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_ +#pragma once #include #include @@ -140,5 +139,3 @@ class remote_subscription { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_ diff --git a/implementation/routing/include/routing_client_state_machine.hpp b/implementation/routing/include/routing_client_state_machine.hpp index 901a98154..d78a834c6 100644 --- a/implementation/routing/include/routing_client_state_machine.hpp +++ b/implementation/routing/include/routing_client_state_machine.hpp @@ -3,11 +3,18 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_CLIENT_STATE_MACHINE_HPP -#define VSOMEIP_V3_ROUTING_CLIENT_STATE_MACHINE_HPP +#pragma once + +#include #include "../../endpoints/include/timer.hpp" +#ifdef ANDROID +#include "../../configuration/include/internal_android.hpp" +#else +#include "../../configuration/include/internal.hpp" +#endif + #include #include #include @@ -204,10 +211,11 @@ class routing_client_state_machine : public std::enable_shared_from_this ST_ASSIGNED * Cancels the assignment timeout timer. * + * @param client_ assigned client-id, used for logging * @return true if transition succeeded, false if: * - Current state is not ST_ASSIGNING */ - [[nodiscard]] bool assigned(); + [[nodiscard]] bool assigned(client_t _client); /** * @brief Start the application registration phase. @@ -342,6 +350,9 @@ class routing_client_state_machine : public std::enable_shared_from_this registration_timebox_; + /// Client-id for logging + client_t client_ = VSOMEIP_CLIENT_UNSET; + /// Protects all state and timers mutable std::mutex mtx_; @@ -350,5 +361,3 @@ class routing_client_state_machine : public std::enable_shared_from_this @@ -54,5 +53,3 @@ class routing_host { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_HOST_ diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp index b644c9836..70b511123 100644 --- a/implementation/routing/include/routing_manager.hpp +++ b/implementation/routing/include/routing_manager.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_ -#define VSOMEIP_V3_ROUTING_MANAGER_ +#pragma once #include #include @@ -99,13 +98,6 @@ class routing_manager { bool _force) = 0; virtual void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) = 0; - - virtual void register_debounce(const std::shared_ptr& _filter, client_t _client, - const std::shared_ptr& _event) = 0; - virtual void remove_debounce(client_t _client, event_t _event) = 0; - virtual void update_debounce_clients(const std::set& _clients, event_t _event) = 0; }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_ diff --git a/implementation/routing/include/routing_manager_adapter.hpp b/implementation/routing/include/routing_manager_adapter.hpp index 5d775bbaa..5bba05136 100644 --- a/implementation/routing/include/routing_manager_adapter.hpp +++ b/implementation/routing/include/routing_manager_adapter.hpp @@ -19,5 +19,3 @@ class routing_manager_adapter { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_ADAPTER_HPP_ diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp index d20f04406..b68b8208d 100644 --- a/implementation/routing/include/routing_manager_base.hpp +++ b/implementation/routing/include/routing_manager_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_BASE_ -#define VSOMEIP_V3_ROUTING_MANAGER_BASE_ +#pragma once #include #include @@ -61,11 +60,6 @@ class routing_manager_base : public routing_manager, public routing_host, public virtual std::string get_env(client_t _client) const = 0; - virtual void register_debounce(const std::shared_ptr& _filter, client_t _client, - const std::shared_ptr& _event); - virtual void remove_debounce(client_t _client, event_t _event); - virtual void update_debounce_clients(const std::set& _clients, event_t _event); - virtual bool is_routing_manager() const; virtual void init() = 0; @@ -181,8 +175,7 @@ class routing_manager_base : public routing_manager, public routing_host, public bool _reliable, protocol::id_e _command, uint8_t _status_check) const; bool insert_subscription(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - const std::shared_ptr& _filter, client_t _client, - std::set* _already_subscribed_events); + const std::shared_ptr& _filter, client_t _client); void clear_shadow_subscriptions(void); @@ -201,8 +194,7 @@ class routing_manager_base : public routing_manager, public routing_host, public void unset_all_eventpayloads(service_t _service, instance_t _instance); void unset_all_eventpayloads(service_t _service, instance_t _instance, eventgroup_t _eventgroup); - void notify_one_current_value(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - const std::set& _events_to_exclude); + void notify_one_current_value(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); std::set> get_subscriptions(const client_t _client); @@ -218,7 +210,6 @@ class routing_manager_base : public routing_manager, public routing_host, public private: virtual bool create_placeholder_event_and_subscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, const std::shared_ptr& _filter, client_t _client) = 0; - void debounce_timeout_update_cbk(const boost::system::error_code& _error, size_t _lifecycle_idx); protected: routing_manager_host* host_; @@ -248,18 +239,6 @@ class routing_manager_base : public routing_manager, public routing_host, public mutable std::mutex events_mutex_; service_instance_map>> events_; - struct debounce_data_t { - client_t client_; - bool update_; - event_t event_; - std::weak_ptr weak_event_; - std::weak_ptr weak_filter_; - }; - boost::asio::steady_timer debounce_timer_; - size_t debounce_lifecycle_idx_ = 0; - std::multimap debounce_clients_; - mutable std::mutex debounce_mutex_; - std::mutex event_registration_mutex_; struct subscription_data_t { @@ -307,5 +286,3 @@ class routing_manager_base : public routing_manager, public routing_host, public }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_BASE_ diff --git a/implementation/routing/include/routing_manager_client.hpp b/implementation/routing/include/routing_manager_client.hpp index 1b8eadd30..0a5822424 100644 --- a/implementation/routing/include/routing_manager_client.hpp +++ b/implementation/routing/include/routing_manager_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_CLIENT_HPP -#define VSOMEIP_V3_ROUTING_MANAGER_CLIENT_HPP +#pragma once #include #include @@ -138,8 +137,7 @@ class routing_manager_client : public routing_manager_base { void init_receiver(std::unique_lock const& _receive_lock); - void notify_remote_initially(service_t _service, instance_t _instance, eventgroup_t _eventgroup, - const std::set& _events_to_exclude); + void notify_remote_initially(service_t _service, instance_t _instance, eventgroup_t _eventgroup); uint32_t get_remote_subscriber_count(service_t _service, instance_t _instance, eventgroup_t _eventgroup, bool _increment); void clear_remote_subscriber_count(service_t _service, instance_t _instance); @@ -244,5 +242,3 @@ class routing_manager_client : public routing_manager_base { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_CLIENT_HPP_ diff --git a/implementation/routing/include/routing_manager_host.hpp b/implementation/routing/include/routing_manager_host.hpp index 8b3a2a13c..5f5b4be28 100644 --- a/implementation/routing/include/routing_manager_host.hpp +++ b/implementation/routing/include/routing_manager_host.hpp @@ -2,8 +2,8 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_HOST_ -#define VSOMEIP_V3_ROUTING_MANAGER_HOST_ + +#pragma once #include @@ -45,5 +45,3 @@ class routing_manager_host { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_HOST_ diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index 8e952a224..2d744d7eb 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_IMPL_HPP_ -#define VSOMEIP_V3_ROUTING_MANAGER_IMPL_HPP_ +#pragma once #include #include @@ -278,6 +277,8 @@ class routing_manager_impl : public routing_manager_base, public routing_manager minor_version_t _minor); std::set get_requesters(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); std::set get_requesters_unlocked(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); + + bool has_requester(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); bool has_requester_unlocked(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); void call_sd_endpoint_connected(const boost::system::error_code& _error, service_t _service, instance_t _instance, @@ -407,5 +408,3 @@ class routing_manager_impl : public routing_manager_base, public routing_manager }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_IMPL_HPP_ diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp index 9548a28ae..9233deeff 100644 --- a/implementation/routing/include/routing_manager_stub.hpp +++ b/implementation/routing/include/routing_manager_stub.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_STUB_ -#define VSOMEIP_V3_ROUTING_MANAGER_STUB_ +#pragma once #include #include @@ -244,5 +243,3 @@ class routing_manager_stub : public routing_host, public std::enable_shared_from }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_STUB_ diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp index 8445a573f..f8e07bc09 100644 --- a/implementation/routing/include/routing_manager_stub_host.hpp +++ b/implementation/routing/include/routing_manager_stub_host.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_ -#define VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_ +#pragma once #include #include @@ -121,5 +120,3 @@ class routing_manager_stub_host { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_ diff --git a/implementation/routing/include/serviceinfo.hpp b/implementation/routing/include/serviceinfo.hpp index 92b5bddcc..310b1c0d9 100644 --- a/implementation/routing/include/serviceinfo.hpp +++ b/implementation/routing/include/serviceinfo.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SERVICEINFO_HPP_ -#define VSOMEIP_V3_SERVICEINFO_HPP_ +#pragma once #include #include @@ -87,5 +86,3 @@ class serviceinfo { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SERVICEINFO_HPP_ diff --git a/implementation/routing/include/types.hpp b/implementation/routing/include/types.hpp index e8a15db94..439e16f6c 100644 --- a/implementation/routing/include/types.hpp +++ b/implementation/routing/include/types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ROUTING_TYPES_HPP_ -#define VSOMEIP_V3_ROUTING_TYPES_HPP_ +#pragma once #include #include @@ -45,5 +44,3 @@ struct msg_statistic_t { } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ROUTING_TYPES_HPP_ diff --git a/implementation/routing/src/event.cpp b/implementation/routing/src/event.cpp index b8e836b1f..6b9c0e783 100644 --- a/implementation/routing/src/event.cpp +++ b/implementation/routing/src/event.cpp @@ -446,8 +446,14 @@ bool event::add_subscriber(eventgroup_t _eventgroup, const std::shared_ptrignore_) its_filter_parameters << "(" << std::dec << i.first << ", " << std::hex << std::setfill('0') << std::setw(2) << static_cast(i.second) << ") "; - its_filter_parameters << "])"; + its_filter_parameters << "], send_current_value_after_=" << std::boolalpha << _filter->send_current_value_after_ << ")"; + VSOMEIP_INFO << "Filter parameters: " << its_filter_parameters.str(); + + if (_filter->send_current_value_after_) { + VSOMEIP_WARNING << "Filter uses unsupported parameter `send_current_value_after_`"; + } + { std::scoped_lock lk{filters_mutex_}; filters_[_client] = [_filter](const std::shared_ptr& _old, const std::shared_ptr& _new) { @@ -512,9 +518,6 @@ bool event::add_subscriber(eventgroup_t _eventgroup, const std::shared_ptrregister_debounce(_filter, _client, shared_from_this()); } else { std::scoped_lock lk{filters_mutex_}; filters_.erase(_client); @@ -537,7 +540,6 @@ void event::remove_subscriber(eventgroup_t _eventgroup, client_t _client) { auto find_eventgroup = eventgroups_.find(_eventgroup); if (find_eventgroup != eventgroups_.end()) { find_eventgroup->second.erase(_client); - routing_->remove_debounce(_client, get_event()); } } @@ -616,20 +618,12 @@ std::set event::get_filtered_subscribers(bool _force) { return its_filtered_subscribers; } -// Get the clients that have pending updates after debounce timeout -void event::get_pending_updates(const std::set& _clients) { - if (has_changed(current_->get_payload(), update_->get_payload())) { - routing_->update_debounce_clients(_clients, get_event()); - } -} - std::set event::update_and_get_filtered_subscribers(const std::shared_ptr& _payload, bool _is_from_remote) { std::scoped_lock its_lock(mutex_); (void)prepare_update_payload_unlocked(_payload, true); auto its_subscribers = get_filtered_subscribers(!_is_from_remote); - get_pending_updates(its_subscribers); if (_is_from_remote) update_payload_unlocked(); diff --git a/implementation/routing/src/routing_client_state_machine.cpp b/implementation/routing/src/routing_client_state_machine.cpp index 2ebffcd5b..08d344763 100644 --- a/implementation/routing/src/routing_client_state_machine.cpp +++ b/implementation/routing/src/routing_client_state_machine.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "../include/routing_client_state_machine.hpp" #include "../../utility/include/is_value.hpp" @@ -65,15 +67,18 @@ void routing_client_state_machine::target_running() { return true; } -[[nodiscard]] bool routing_client_state_machine::assigned() { +[[nodiscard]] bool routing_client_state_machine::assigned(client_t _client) { std::scoped_lock lock{mtx_}; if (state_ != routing_client_state_e::ST_ASSIGNING) { VSOMEIP_WARNING << "rcsm::" << __func__ << ": Unexpected state: " << state_; return false; } + + client_ = _client; change_state_unlocked(routing_client_state_e::ST_ASSIGNED); return true; } + [[nodiscard]] bool routing_client_state_machine::start_registration() { std::scoped_lock lock{mtx_}; @@ -162,6 +167,7 @@ void routing_client_state_machine::registration_timed_out() { void routing_client_state_machine::deregister_unlocked(std::unique_lock _acquired_lock) { change_state_unlocked(routing_client_state_e::ST_DEREGISTERED); + client_ = VSOMEIP_CLIENT_UNSET; if (registration_timebox_) { registration_timebox_->stop(); } @@ -178,7 +184,8 @@ void routing_client_state_machine::deregister_unlocked(std::unique_lock " << _state; + VSOMEIP_INFO << "rcsm::" << __func__ << ": client " << std::hex << std::setfill('0') << std::setw(4) << client_ << ", state " << state_ + << " -> " << _state; state_ = _state; if (is_value(state_).any_of(routing_client_state_e::ST_REGISTERED, routing_client_state_e::ST_DEREGISTERED)) { cv_.notify_one(); diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index 946196520..d70b47d9c 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -22,8 +22,7 @@ namespace vsomeip_v3 { routing_manager_base::routing_manager_base(routing_manager_host* _host) : - host_(_host), io_(host_->get_io()), configuration_(host_->get_configuration()), debounce_timer_(host_->get_io()), - tc_(trace::connector_impl::get()) { + host_(_host), io_(host_->get_io()), configuration_(host_->get_configuration()), tc_(trace::connector_impl::get()) { const std::size_t its_max = configuration_->get_io_thread_count(host_->get_name()); const uint32_t its_buffer_shrink_threshold = configuration_->get_buffer_shrink_threshold(); @@ -41,131 +40,6 @@ routing_manager_base::routing_manager_base(routing_manager_host* _host) : } } -void routing_manager_base::debounce_timeout_update_cbk(const boost::system::error_code& _error, size_t _lifecycle_idx) { - if (_error) { - // nothing to do - return; - } - - auto const now = std::chrono::steady_clock::now(); - - bool notify = false; - client_t client = 0; - std::shared_ptr event; - std::shared_ptr filter; - - { - std::scoped_lock its_lock(debounce_mutex_); - - if (_lifecycle_idx != debounce_lifecycle_idx_) { - // nothing to do, stale timer - return; - } - - auto const itr = debounce_clients_.begin(); - if (itr == debounce_clients_.end()) { - // nothing to do, not even a reschedule - return; - } - - if (itr->first > now) { - // only need to reschedule - debounce_timer_.expires_at(itr->first); - debounce_timer_.async_wait(std::bind(&routing_manager_base::debounce_timeout_update_cbk, shared_from_this(), - std::placeholders::_1, _lifecycle_idx)); - return; - } - - event = itr->second.weak_event_.lock(); - filter = itr->second.weak_filter_.lock(); - auto data = itr->second; - // NOTE! invalidated `itr` - debounce_clients_.erase(itr); - - if (event && filter) { - std::chrono::steady_clock::time_point last = filter->last_forwarded_.load(); - int64_t elapsed = std::chrono::duration_cast(now - last).count(); - bool is_elapsed = (last == std::chrono::steady_clock::time_point::max() || elapsed >= filter->interval_); - if (is_elapsed) { - if (data.update_) { - data.update_ = false; - notify = true; - client = data.client_; - } - elapsed = 0; - } - - auto timeout = now + std::chrono::milliseconds(filter->interval_ - elapsed); - debounce_clients_.emplace(timeout, - debounce_data_t{data.client_, data.update_, data.event_, data.weak_event_, data.weak_filter_}); - } - - if (!debounce_clients_.empty()) { - auto first = debounce_clients_.begin(); - - debounce_timer_.expires_at(first->first); - debounce_timer_.async_wait(std::bind(&routing_manager_base::debounce_timeout_update_cbk, shared_from_this(), - std::placeholders::_1, _lifecycle_idx)); - } - } - - if (notify && event && client) { - // NOTE: subscriber check done here because otherwise we'd have a lock inversion with - // debounce_mutex_+eventgroup_mutex (in remove_subscribes) - auto its_subscribers = event->get_subscribers(); - if (its_subscribers.find(client) != its_subscribers.end()) { - event->notify_one(client, false); - } - } -} - -void routing_manager_base::register_debounce(const std::shared_ptr& _filter, client_t _client, - const std::shared_ptr& _event) { - if (_filter->send_current_value_after_ == true) { - std::scoped_lock its_lock(debounce_mutex_); - auto sec = std::chrono::milliseconds(_filter->interval_); - auto timeout = std::chrono::steady_clock::now() + sec; - - auto weak_event = std::weak_ptr(_event); - auto weak_filter = std::weak_ptr(_filter); - - auto itr = debounce_clients_.emplace(timeout, debounce_data_t{_client, false, _event->get_event(), weak_event, weak_filter}); - - // reschedule timer; timer is anyhow a "hint" for the next debouncing we need to process - if (itr == debounce_clients_.begin()) { - debounce_lifecycle_idx_ += 1; - debounce_timer_.expires_at(itr->first); - debounce_timer_.async_wait(std::bind(&routing_manager_base::debounce_timeout_update_cbk, shared_from_this(), - std::placeholders::_1, debounce_lifecycle_idx_)); - } - } -} - -void routing_manager_base::remove_debounce(client_t _client, event_t _event) { - std::scoped_lock its_lock(debounce_mutex_); - for (auto itr = debounce_clients_.begin(); itr != debounce_clients_.end();) { - if (itr->second.client_ == _client && itr->second.event_ == _event) { - itr = debounce_clients_.erase(itr); - } else { - ++itr; - } - } -} - -void routing_manager_base::update_debounce_clients(const std::set& _clients, event_t _event) { - std::scoped_lock its_lock(debounce_mutex_); - for (auto& itr : debounce_clients_) { - if (itr.second.event_ == _event) { - itr.second.update_ = true; - for (auto client : _clients) { - if (itr.second.client_ == client) { - itr.second.update_ = false; - } - } - } - } -} - boost::asio::io_context& routing_manager_base::get_io() { return io_; @@ -571,8 +445,6 @@ void routing_manager_base::register_event(client_t _client, service_t _service, return (is_changed || is_elapsed); }; - // Create a new callback for this client if filter interval is used - register_debounce(its_debounce, _client, its_event); } else { if (_is_shadow || !is_routing_manager()) { _epsilon_change_func = [](const std::shared_ptr& _old, const std::shared_ptr& _new) { @@ -902,7 +774,7 @@ void routing_manager_base::unset_all_eventpayloads(service_t _service, instance_ } void routing_manager_base::notify_one_current_value(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - event_t _event, const std::set& _events_to_exclude) { + event_t _event) { if (_event != ANY_EVENT) { std::shared_ptr its_event = find_event(_service, _instance, _event); if (its_event && its_event->is_field()) @@ -912,7 +784,7 @@ void routing_manager_base::notify_one_current_value(client_t _client, service_t if (its_eventgroup) { std::set> its_events = its_eventgroup->get_events(); for (const auto& e : its_events) { - if (e->is_field() && _events_to_exclude.find(e->get_event()) == _events_to_exclude.end()) { + if (e->is_field()) { e->notify_one(_client, false); } } @@ -1302,8 +1174,7 @@ bool routing_manager_base::send_local(std::shared_ptr& _target, } bool routing_manager_base::insert_subscription(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - const std::shared_ptr& _filter, client_t _client, - std::set* _already_subscribed_events) { + const std::shared_ptr& _filter, client_t _client) { bool is_inserted(false); std::scoped_lock its_lock{subscription_mutex}; @@ -1329,12 +1200,6 @@ bool routing_manager_base::insert_subscription(service_t _service, instance_t _i create_place_holder = true; } else { for (const auto& e : its_events) { - if (e->is_subscribed(_client)) { - // client is already subscribed to event from eventgroup - // this can happen if events are members of multiple - // eventgroups - _already_subscribed_events->insert(e->get_event()); - } is_inserted = e->add_subscriber(_eventgroup, _filter, _client, host_->is_routing()) || is_inserted; } } diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index f74a7f5da..18fb8b0b3 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -114,7 +114,7 @@ void routing_manager_client::init() { std::chrono::milliseconds(configuration_->get_shutdown_timeout())}, [this, weak_self = weak_from_this()] { if (auto self = weak_self.lock(); self) { - std::unique_lock lock{sender_mutex_}; + std::unique_lock lock{sender_mutex_}; restart_sender(lock); } }); @@ -131,7 +131,7 @@ void routing_manager_client::start() { receiver_ = ep_mgr_->create_local_server(shared_from_this()); } } - std::unique_lock lock{sender_mutex_}; + std::unique_lock lock{sender_mutex_}; restart_sender(lock); { std::scoped_lock its_lock{log_timer_mutex_}; @@ -183,7 +183,7 @@ void routing_manager_client::stop() { { // the subsequent deregister_application might lead to a "end of file" // error in the sender, which could initiate a reconnection attempt - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->register_error_handler(nullptr); } @@ -221,7 +221,7 @@ void routing_manager_client::stop() { status_log_timer_.cancel(); } { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->stop(false); } @@ -310,7 +310,7 @@ void routing_manager_client::ping_host() { if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -370,7 +370,7 @@ bool routing_manager_client::send_offer_service(client_t _client, service_t _ser its_offer.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_ && sender_->send(&its_buffer[0], uint32_t(its_buffer.size()))) { return true; } @@ -432,7 +432,7 @@ void routing_manager_client::stop_offer_service(client_t _client, service_t _ser its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -605,7 +605,7 @@ void routing_manager_client::unregister_event(client_t _client, service_t _servi protocol::error_e its_error; its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -695,7 +695,7 @@ void routing_manager_client::send_subscribe(client_t _client, service_t _service handle_client_error(its_target_client); } } else { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -731,7 +731,7 @@ void routing_manager_client::send_subscribe_nack(client_t _subscriber, service_t } } { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -767,7 +767,7 @@ void routing_manager_client::send_subscribe_ack(client_t _subscriber, service_t } } { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -809,7 +809,7 @@ void routing_manager_client::unsubscribe(client_t _client, const vsomeip_sec_cli if (its_target) { its_target->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -886,7 +886,7 @@ bool routing_manager_client::send(client_t _client, const byte_t* _data, length_ is_sent = send_local(its_target, get_client(), _data, _size, _instance, _reliable, protocol::id_e::SEND_ID, _status_check); if (is_sent) { trace::header its_header; - if (its_header.prepare(nullptr, true, _instance, trace::protocol_e::unknown)) + if (its_header.prepare(its_target, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); } @@ -897,7 +897,7 @@ bool routing_manager_client::send(client_t _client, const byte_t* _data, length_ // or for notifications ~> route to routing_manager_stub bool message_to_stub(false); if (!its_target) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { its_target = sender_; message_to_stub = true; @@ -924,7 +924,7 @@ bool routing_manager_client::send(client_t _client, const byte_t* _data, length_ is_sent = send_local(its_target, its_client, _data, _size, _instance, _reliable, its_command, _status_check); if (is_sent && !utility::is_notification(VSOMEIP_MESSAGE_TYPE_POS) && !message_to_stub) { trace::header its_header; - if (its_header.prepare(nullptr, true, _instance, trace::protocol_e::unknown)) + if (its_header.prepare(its_target, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); } } @@ -1250,17 +1250,13 @@ void routing_manager_client::on_message(const byte_t* _data, length_t _size, boa its_major](const bool _subscription_accepted) { std::uint32_t its_count(0); if (_subscription_accepted) { - std::set its_already_subscribed_events; - bool inserted = - insert_subscription(its_service, its_instance, its_eventgroup, its_event, its_filter, - VSOMEIP_ROUTING_CLIENT, &its_already_subscribed_events); + insert_subscription(its_service, its_instance, its_eventgroup, its_event, its_filter, + VSOMEIP_ROUTING_CLIENT); // NOTE: order matters, send ACK _after_ inserting the subscription send_subscribe_ack(its_client, its_service, its_instance, its_eventgroup, its_event, its_pending_id); - if (inserted) { - notify_remote_initially(its_service, its_instance, its_eventgroup, - its_already_subscribed_events); - } + notify_remote_initially(its_service, its_instance, its_eventgroup); + its_count = get_remote_subscriber_count(its_service, its_instance, its_eventgroup, true); } else { send_subscribe_nack(its_client, its_service, its_instance, its_eventgroup, its_event, @@ -1320,32 +1316,29 @@ void routing_manager_client::on_message(const byte_t* _data, length_t _size, boa auto its_info = find_service(its_service, its_instance); if (its_info) { - host_->on_subscription(its_service, its_instance, its_eventgroup, its_client, _sec_client, its_env, true, - [this, self, its_client, its_filter, its_pending_id, its_env, its_service, its_instance, - its_eventgroup, its_event, its_major](const bool _subscription_accepted) { - if (!_subscription_accepted) { - send_subscribe_nack(its_client, its_service, its_instance, its_eventgroup, its_event, - PENDING_SUBSCRIPTION_ID); - } else { - - std::set its_already_subscribed_events; - insert_subscription(its_service, its_instance, its_eventgroup, its_event, its_filter, - its_client, &its_already_subscribed_events); - // NOTE: order matters, send ACK _after_ inserting the subscription - send_subscribe_ack(its_client, its_service, its_instance, its_eventgroup, its_event, - PENDING_SUBSCRIPTION_ID); - notify_one_current_value(its_client, its_service, its_instance, its_eventgroup, - its_event, its_already_subscribed_events); - } - - VSOMEIP_INFO << "SUBSCRIBE(" << std::hex << std::setfill('0') << std::setw(4) - << its_client << "): [" << std::setw(4) << its_service << "." - << std::setw(4) << its_instance << "." << std::setw(4) << its_eventgroup - << ":" << std::setw(4) << its_event << ":" << std::dec - << static_cast(its_major) << "] " << std::boolalpha - << (its_pending_id != PENDING_SUBSCRIPTION_ID) - << (_subscription_accepted ? " accepted" : "not accepted"); - }); + host_->on_subscription( + its_service, its_instance, its_eventgroup, its_client, _sec_client, its_env, true, + [this, self, its_client, its_filter, its_pending_id, its_env, its_service, its_instance, its_eventgroup, + its_event, its_major](const bool _subscription_accepted) { + if (!_subscription_accepted) { + send_subscribe_nack(its_client, its_service, its_instance, its_eventgroup, its_event, + PENDING_SUBSCRIPTION_ID); + } else { + + insert_subscription(its_service, its_instance, its_eventgroup, its_event, its_filter, its_client); + // NOTE: order matters, send ACK _after_ inserting the subscription + send_subscribe_ack(its_client, its_service, its_instance, its_eventgroup, its_event, + PENDING_SUBSCRIPTION_ID); + notify_one_current_value(its_client, its_service, its_instance, its_eventgroup, its_event); + } + + VSOMEIP_INFO << "SUBSCRIBE(" << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" + << std::setw(4) << its_service << "." << std::setw(4) << its_instance << "." + << std::setw(4) << its_eventgroup << ":" << std::setw(4) << its_event << ":" << std::dec + << static_cast(its_major) << "] " << std::boolalpha + << (its_pending_id != PENDING_SUBSCRIPTION_ID) + << (_subscription_accepted ? " accepted" : "not accepted"); + }); } else { send_subscribe_nack(its_client, its_service, its_instance, its_eventgroup, its_event, PENDING_SUBSCRIPTION_ID); } @@ -1870,7 +1863,7 @@ void routing_manager_client::register_application() { its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { if (!state_machine_->start_registration()) { VSOMEIP_INFO << "rmc::" << __func__ << ": interrupting the application registration for Client 0x" << std::hex @@ -1899,7 +1892,7 @@ void routing_manager_client::deregister_application() { if (its_error == protocol::error_e::ERROR_OK) { if (auto state = state_machine_->state(); is_value(state).any_of(routing_client_state_e::ST_REGISTERED, routing_client_state_e::ST_DEREGISTERING)) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -1927,7 +1920,7 @@ void routing_manager_client::send_pong() const { if (auto state = state_machine_->state(); is_value(state).any_of(routing_client_state_e::ST_REGISTERED, routing_client_state_e::ST_REGISTERING, routing_client_state_e::ST_ASSIGNED, routing_client_state_e::ST_ASSIGNING)) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -1954,7 +1947,7 @@ bool routing_manager_client::send_request_services(const std::set its_sender_lock{sender_mutex_}; if (sender_ && sender_->send(&its_buffer[0], uint32_t(its_buffer.size()))) { return true; } @@ -1979,7 +1972,7 @@ void routing_manager_client::send_release_service(client_t _client, service_t _s protocol::error_e its_error; its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2049,7 +2042,7 @@ void routing_manager_client::send_register_event(client_t _client, service_t _se its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2172,13 +2165,12 @@ void routing_manager_client::init_receiver([[maybe_unused]] std::unique_lock& _events_to_exclude) { +void routing_manager_client::notify_remote_initially(service_t _service, instance_t _instance, eventgroup_t _eventgroup) { auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); if (its_eventgroup) { auto service_info = find_service(_service, _instance); for (const auto& e : its_eventgroup->get_events()) { - if (e->is_field() && e->is_set() && _events_to_exclude.find(e->get_event()) == _events_to_exclude.end()) { + if (e->is_field() && e->is_set()) { std::shared_ptr its_notification = runtime::get()->create_notification(); its_notification->set_service(_service); its_notification->set_instance(_instance); @@ -2191,7 +2183,7 @@ void routing_manager_client::notify_remote_initially(service_t _service, instanc std::shared_ptr its_serializer(get_serializer()); if (its_serializer->serialize(its_notification.get())) { { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { send_local(sender_, VSOMEIP_ROUTING_CLIENT, its_serializer->get_data(), its_serializer->get_size(), _instance, false, protocol::id_e::NOTIFY_ID, 0); @@ -2264,7 +2256,7 @@ bool routing_manager_client::send_registered_ack() { if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_ && sender_->send(&its_buffer[0], uint32_t(its_buffer.size()))) { return true; } @@ -2385,7 +2377,7 @@ void routing_manager_client::send_get_offered_services_info(client_t _client, of its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2411,7 +2403,7 @@ void routing_manager_client::send_unsubscribe_ack(service_t _service, instance_t its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2442,7 +2434,7 @@ void routing_manager_client::send_resend_provided_event_response(pending_remote_ its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2465,7 +2457,7 @@ void routing_manager_client::send_update_security_policy_response(pending_securi its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2487,7 +2479,7 @@ void routing_manager_client::send_remove_security_policy_response(pending_securi its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - std::scoped_lock its_sender_lock{sender_mutex_}; + std::scoped_lock its_sender_lock{sender_mutex_}; if (sender_) { sender_->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -2550,7 +2542,7 @@ void routing_manager_client::on_client_assign_ack(const client_t& _client) { // interleaving stopping of the receiver within the ::stop method. bool is_started{false}; std::unique_lock its_lock{receiver_mutex_}; - if (!state_machine_->assigned()) { + if (!state_machine_->assigned(_client)) { VSOMEIP_INFO << "rmc::" << __func__ << ": Not starting the application registration for Client 0x" << std::hex << std::setw(4) << std::setfill('0') << _client; its_lock.unlock(); @@ -2627,7 +2619,7 @@ void routing_manager_client::restart_sender([[maybe_unused]] std::unique_lock its_sender_lock(sender_mutex_); sender_debounce_active_ = false; if (start_sender_after_debounce_) { restart_sender(its_sender_lock); diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 49326130f..584a4be4a 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -415,13 +415,11 @@ bool routing_manager_impl::offer_service(client_t _client, service_t _service, i } { - std::set its_already_subscribed_events; { std::scoped_lock ist_lock(pending_subscription_mutex_); for (auto& ps : pending_subscriptions_) { if (ps.service_ == _service && ps.instance_ == _instance && ps.major_ == _major) { - insert_subscription(ps.service_, ps.instance_, ps.eventgroup_, ps.event_, nullptr, get_client(), - &its_already_subscribed_events); + insert_subscription(ps.service_, ps.instance_, ps.eventgroup_, ps.event_, nullptr, get_client()); } } } @@ -596,7 +594,10 @@ void routing_manager_impl::release_service(client_t _client, service_t _service, } } else { if (discovery_) { - discovery_->release_service(_service, _instance); + // Release the service only if there are no more requesters. + if (!has_requester(_service, _instance, ANY_MAJOR, ANY_MINOR)) { + discovery_->release_service(_service, _instance); + } } } } @@ -624,15 +625,14 @@ void routing_manager_impl::subscribe(client_t _client, const vsomeip_sec_client_ if (stub_) stub_->send_subscribe_nack(_client, _service, _instance, _eventgroup, _event); } else { - std::set its_already_subscribed_events; - insert_subscription(_service, _instance, _eventgroup, _event, _filter, _client, &its_already_subscribed_events); + insert_subscription(_service, _instance, _eventgroup, _event, _filter, _client); // NOTE: order matters, send ACK _after_ inserting the subscription if (stub_) { stub_->send_subscribe_ack(_client, _service, _instance, _eventgroup, _event); } - notify_one_current_value(_client, _service, _instance, _eventgroup, _event, its_already_subscribed_events); + notify_one_current_value(_client, _service, _instance, _eventgroup, _event); } VSOMEIP_INFO << "SUBSCRIBE(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) @@ -642,21 +642,19 @@ void routing_manager_impl::subscribe(client_t _client, const vsomeip_sec_client_ }); } else { if (discovery_) { - std::set its_already_subscribed_events; - // Note: The calls to insert_subscription & handle_subscription_state must not // run concurrently to a call to on_subscribe_ack. Therefore the lock is acquired // before calling insert_subscription and released after the call to // handle_subscription_state. std::unique_lock its_critical(remote_subscription_state_mutex_); - bool inserted = insert_subscription(_service, _instance, _eventgroup, _event, _filter, _client, &its_already_subscribed_events); + bool inserted = insert_subscription(_service, _instance, _eventgroup, _event, _filter, _client); const bool subscriber_is_rm_host = (get_client() == _client); if (inserted) { if (0 == its_local_client) { handle_subscription_state(_client, _service, _instance, _eventgroup, _event); its_critical.unlock(); static const ttl_t configured_ttl(configuration_->get_sd_ttl()); - notify_one_current_value(_client, _service, _instance, _eventgroup, _event, its_already_subscribed_events); + notify_one_current_value(_client, _service, _instance, _eventgroup, _event); auto its_info = find_eventgroup(_service, _instance, _eventgroup); // if the subscriber is the rm_host itself: check if service @@ -1465,97 +1463,27 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se * After triggering "del_routing_info" this endpoints gets cleanup up * within this method if they not longer used by any other local service. */ - std::shared_ptr its_reliable_endpoint; - std::shared_ptr its_unreliable_endpoint; std::shared_ptr its_info(find_service(_service, _instance)); if (its_info) { - its_reliable_endpoint = its_info->get_endpoint(true); - its_unreliable_endpoint = its_info->get_endpoint(false); - - // Create a ready_to_stop_t object to synchronize the stopping - // of the service on reliable and unreliable endpoints. - struct ready_to_stop_t { - ready_to_stop_t(bool _reliable, bool _unreliable, major_version_t _major, minor_version_t _minor) : - reliable_ready_(_reliable), unreliable_ready_(_unreliable), major_(_major), minor_(_minor) { } - - inline bool is_ready() const { return reliable_ready_ && unreliable_ready_; } - std::mutex is_ready_mutex_; - bool done_{false}; - std::atomic reliable_ready_; - std::atomic unreliable_ready_; - - major_version_t major_; - minor_version_t minor_; - }; - auto ready_to_stop = std::make_shared(its_reliable_endpoint == nullptr, its_unreliable_endpoint == nullptr, - its_info->get_major(), its_info->get_minor()); - auto ptr = shared_from_this(); - - auto callback = [this, ptr, ready_to_stop, _client, _service, _instance, _major, - _minor](std::shared_ptr _endpoint) { - bool reliable_endpoint = _endpoint->is_reliable(); - if (reliable_endpoint) { - ready_to_stop->reliable_ready_ = true; - } else { - ready_to_stop->unreliable_ready_ = true; - } + std::shared_ptr its_reliable_endpoint = its_info->get_endpoint(true); + std::shared_ptr its_unreliable_endpoint = its_info->get_endpoint(false); - if (discovery_) { - if (ready_to_stop->major_ == _major && ready_to_stop->minor_ == _minor) { - auto service_info = find_service(_service, _instance); - if (service_info) - discovery_->stop_offer_service(service_info, true); - } - } - - if (ep_mgr_impl_->remove_instance(_service, _endpoint.get())) { - // last instance -> pass ANY_INSTANCE and shutdown completely - _endpoint->prepare_stop( - [this, ptr](std::shared_ptr _endpoint_to_stop) { - if (ep_mgr_impl_->remove_server_endpoint(_endpoint_to_stop->get_local_port(), - _endpoint_to_stop->is_reliable())) { - _endpoint_to_stop->stop(false); - } - }, - ANY_SERVICE); + for (const auto& ep : {its_reliable_endpoint, its_unreliable_endpoint}) { + if (ep == nullptr) { + continue; } - if (ready_to_stop->is_ready()) { - { - std::scoped_lock ready_lck{ready_to_stop->is_ready_mutex_}; - if (!ready_to_stop->done_) { - ready_to_stop->done_ = true; - del_routing_info(_service, _instance, reliable_endpoint, !reliable_endpoint, false); - // NOTE: Order matters. The 'erase_offer_command' must be done after the on_availability to ensure that the process - // has completed before starting the next one, otherwise, we may have the availability being reported in the wrong - // order - on_availability(_service, _instance, availability_state_e::AS_UNAVAILABLE, _major, _minor); - if (stub_) { - stub_->on_stop_offer_service(_client, _service, _instance, _major, _minor); - } - erase_offer_command(_service, _instance); - } else { - del_routing_info(_service, _instance, reliable_endpoint, !reliable_endpoint, false); - } - } - } else { - del_routing_info(_service, _instance, reliable_endpoint, !reliable_endpoint, false); + if (ep_mgr_impl_->remove_instance(_service, ep.get()) + && ep_mgr_impl_->remove_server_endpoint(ep->get_local_port(), ep->is_reliable())) { + ep->stop(false); } - }; - - for (const auto& ep : {its_reliable_endpoint, its_unreliable_endpoint}) { - if (ep) - ep->prepare_stop(callback, _service); } - if (!its_reliable_endpoint && !its_unreliable_endpoint) { - // NOTE: Order matters. The 'erase_offer_command' must be done after the on_availability to ensure that the process has - // completed before starting the next one, otherwise, we may have the availability being reported in the wrong order - on_availability(_service, _instance, availability_state_e::AS_UNAVAILABLE, _major, _minor); - if (stub_) { - stub_->on_stop_offer_service(_client, _service, _instance, _major, _minor); - } - erase_offer_command(_service, _instance); + del_routing_info(_service, _instance, its_reliable_endpoint != nullptr, its_unreliable_endpoint != nullptr, false); + + if (discovery_) { + if (its_info->get_major() == _major && its_info->get_minor() == _minor) + discovery_->stop_offer_service(its_info, true); } std::set> its_eventgroup_info_set; @@ -1573,15 +1501,15 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se for (auto e : its_eventgroup_info_set) { e->clear_remote_subscriptions(); } - } else { - // NOTE: Order matters. The 'erase_offer_command' must be done after the on_availability to ensure that the process has completed - // before starting the next one, otherwise, we may have the availability being reported in the wrong order - on_availability(_service, _instance, availability_state_e::AS_UNAVAILABLE, _major, _minor); - if (stub_) { - stub_->on_stop_offer_service(_client, _service, _instance, _major, _minor); - } - erase_offer_command(_service, _instance); } + + // NOTE: Order matters. The 'erase_offer_command' must be done after the on_availability to ensure that the process has completed + // before starting the next one, otherwise, we may have the availability being reported in the wrong order + on_availability(_service, _instance, availability_state_e::AS_UNAVAILABLE, _major, _minor); + if (stub_) { + stub_->on_stop_offer_service(_client, _service, _instance, _major, _minor); + } + erase_offer_command(_service, _instance); } bool routing_manager_impl::deliver_message(const byte_t* _data, length_t _size, instance_t _instance, bool _reliable, @@ -3130,27 +3058,6 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { bool has_unreliable(info->get_endpoint(false) != nullptr); if (has_reliable || has_unreliable) { const client_t its_client(find_local_client(service, instance)); - if (its_client == VSOMEIP_ROUTING_CLIENT) { - // Inconsistency between services_ and local_services_ table detected - // --> cleanup. - VSOMEIP_WARNING << "rmi::" << __func__ << " Found table inconsistency for [" << std::hex << std::setfill('0') - << std::setw(4) << service << "." << std::setw(4) << instance << "]"; - - // Remove the service from the offer_commands_ and - // prepare_stop_handlers_ to force the next offer to be processed - offer_commands_.erase(std::make_pair(service, instance)); - if (has_reliable) - info->get_endpoint(true)->remove_stop_handler(service); - if (has_unreliable) - info->get_endpoint(false)->remove_stop_handler(service); - - del_routing_info(service, instance, has_reliable, has_unreliable, true); - - std::scoped_lock its_lock{pending_offers_mutex_}; - auto its_pending_offer = pending_offers_.find(service); - if (its_pending_offer != pending_offers_.end()) - its_pending_offer->second.erase(instance); - } VSOMEIP_WARNING << "rmi::" << __func__ << ": Service " << std::hex << std::setfill('0') << std::setw(4) << service << "." << std::setw(4) << instance << " still offered by " << std::setw(4) << its_client; } @@ -3579,6 +3486,11 @@ std::set routing_manager_impl::get_requesters_unlocked(service_t _serv return its_requesters; } +bool routing_manager_impl::has_requester(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor) { + std::scoped_lock lock{requested_services_mutex_}; + return has_requester_unlocked(_service, _instance, _major, _minor); +} + bool routing_manager_impl::has_requester_unlocked(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor) { @@ -3599,10 +3511,9 @@ bool routing_manager_impl::has_requester_unlocked(service_t _service, instance_t } for (const auto& [major, minors_map] : found_instance->second) { - if (major == _major || _major == DEFAULT_MAJOR || major == ANY_MAJOR) { + if (major == _major || _major == DEFAULT_MAJOR || major == ANY_MAJOR || _major == ANY_MAJOR) { for (const auto& [minor, clients] : minors_map) { - if (minor <= _minor || _minor == DEFAULT_MINOR || minor == ANY_MINOR) { - + if (minor <= _minor || _minor == DEFAULT_MINOR || minor == ANY_MINOR || _minor == ANY_MINOR) { return true; } } diff --git a/implementation/runtime/include/application_impl.hpp b/implementation/runtime/include/application_impl.hpp index bf226cc1d..e64b7e361 100644 --- a/implementation/runtime/include/application_impl.hpp +++ b/implementation/runtime/include/application_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_APPLICATION_IMPL_HPP_ -#define VSOMEIP_V3_APPLICATION_IMPL_HPP_ +#pragma once #include #include @@ -40,6 +39,7 @@ class runtime; class configuration; class routing_manager; class routing_manager_stub; +class plugin_manager_impl; class application_impl : public application, public routing_manager_host, public std::enable_shared_from_this { public: @@ -284,6 +284,7 @@ class application_impl : public application, public routing_manager_host, public // terminate() during process exit. Therefore, we extend the runtime data to be valid for all applications in that process. std::shared_ptr runtime_; std::shared_ptr configuration_; + std::shared_ptr plugin_manager_; std::atomic client_; // unique application identifier session_t session_; std::mutex session_mutex_; @@ -401,5 +402,3 @@ class application_impl : public application, public routing_manager_host, public }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_APPLICATION_IMPL_HPP_ diff --git a/implementation/runtime/include/runtime_impl.hpp b/implementation/runtime/include/runtime_impl.hpp index e70473050..3bb79678e 100644 --- a/implementation/runtime/include/runtime_impl.hpp +++ b/implementation/runtime/include/runtime_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_RUNTIME_IMPL_HPP_ -#define VSOMEIP_V3_RUNTIME_IMPL_HPP_ +#pragma once #include #include @@ -52,5 +51,3 @@ class runtime_impl : public runtime { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_RUNTIME_IMPL_HPP_ diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index b41b965d9..503b52981 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -47,7 +47,8 @@ configuration::~configuration() { } #endif application_impl::application_impl(const std::string& _name, const std::string& _path) : - runtime_{runtime::get()}, client_{VSOMEIP_CLIENT_UNSET}, session_{0}, is_initialized_{false}, name_{_name}, path_{_path}, + runtime_{runtime::get()}, plugin_manager_{plugin_manager_impl::get()}, client_{VSOMEIP_CLIENT_UNSET}, session_{0}, + is_initialized_{false}, name_{_name}, path_{_path}, #if defined(__linux__) || defined(__QNX__) start_thread_{0}, #endif @@ -62,8 +63,8 @@ application_impl::application_impl(const std::string& _name, const std::string& application_impl::~application_impl() { runtime_->remove_application(name_); #ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS - if (configuration_) { - auto its_plugin = plugin_manager::get()->get_plugin(plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY); + if (configuration_ && plugin_manager_) { + auto its_plugin = plugin_manager_->get_plugin(plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY); if (its_plugin) { auto its_configuration_plugin = std::dynamic_pointer_cast(its_plugin); if (its_configuration_plugin) { @@ -102,7 +103,7 @@ bool application_impl::init() { // TODO: Add loading of custom configuration module } else { // load default module #ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS - auto its_plugin = plugin_manager::get()->get_plugin(plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY); + auto its_plugin = plugin_manager_->get_plugin(plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY); if (its_plugin) { auto its_configuration_plugin = std::dynamic_pointer_cast(its_plugin); if (its_configuration_plugin) { @@ -293,7 +294,7 @@ bool application_impl::init() { auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN); if (its_app_plugin_info != its_plugins.end()) { for (auto its_library : its_app_plugin_info->second) { - auto its_application_plugin = plugin_manager::get()->get_plugin(plugin_type_e::APPLICATION_PLUGIN, its_library); + auto its_application_plugin = plugin_manager_->get_plugin(plugin_type_e::APPLICATION_PLUGIN, its_library); if (its_application_plugin) { VSOMEIP_INFO << "Client 0x" << std::hex << get_client() << " Loading plug-in library: " << its_library << " succeeded!"; std::dynamic_pointer_cast(its_application_plugin) @@ -434,7 +435,7 @@ void application_impl::start() { auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN); if (its_app_plugin_info != its_plugins.end()) { for (const auto& its_library : its_app_plugin_info->second) { - auto its_application_plugin = plugin_manager::get()->get_plugin(plugin_type_e::APPLICATION_PLUGIN, its_library); + auto its_application_plugin = plugin_manager_->get_plugin(plugin_type_e::APPLICATION_PLUGIN, its_library); if (its_application_plugin) { std::dynamic_pointer_cast(its_application_plugin) ->on_application_state_change(name_, application_plugin_state_e::STATE_STARTED); @@ -562,7 +563,7 @@ void application_impl::stop() { auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN); if (its_app_plugin_info != its_plugins.end()) { for (const auto& its_library : its_app_plugin_info->second) { - auto its_application_plugin = plugin_manager::get()->get_plugin(plugin_type_e::APPLICATION_PLUGIN, its_library); + auto its_application_plugin = plugin_manager_->get_plugin(plugin_type_e::APPLICATION_PLUGIN, its_library); if (its_application_plugin) { std::dynamic_pointer_cast(its_application_plugin) ->on_application_state_change(name_, application_plugin_state_e::STATE_STOPPED); @@ -876,7 +877,7 @@ void application_impl::notify(service_t _service, instance_t _instance, event_t bool _force) const { if (routing_) { - auto its_payload{runtime::get()->create_payload(_payload->get_data(), _payload->get_length())}; + auto its_payload{runtime_->create_payload(_payload->get_data(), _payload->get_length())}; routing_->notify(_service, _instance, _event, its_payload, _force); } } @@ -884,7 +885,7 @@ void application_impl::notify(service_t _service, instance_t _instance, event_t void application_impl::notify_one(service_t _service, instance_t _instance, event_t _event, std::shared_ptr _payload, client_t _client, bool _force) const { if (routing_) { - auto its_payload{runtime::get()->create_payload(_payload->get_data(), _payload->get_length())}; + auto its_payload{runtime_->create_payload(_payload->get_data(), _payload->get_length())}; routing_->notify_one(_service, _instance, _event, its_payload, _client, _force); } } @@ -2088,12 +2089,7 @@ bool application_impl::is_routing() const { void application_impl::send_back_cached_event(service_t _service, instance_t _instance, event_t _event) { std::shared_ptr its_event = routing_->find_event(_service, _instance, _event); if (its_event && its_event->is_field() && its_event->is_set()) { - auto rt = runtime::get(); - if (!rt) { - VSOMEIP_ERROR << "Cannot send cached event - runtime already destroyed"; - return; - } - std::shared_ptr its_message = rt->create_notification(); + std::shared_ptr its_message = runtime_->create_notification(); its_message->set_service(_service); its_message->set_method(_event); its_message->set_instance(_instance); @@ -2106,16 +2102,10 @@ void application_impl::send_back_cached_event(service_t _service, instance_t _in } void application_impl::send_back_cached_eventgroup(service_t _service, instance_t _instance, eventgroup_t _eventgroup) { - auto rt = runtime::get(); - if (!rt) { - VSOMEIP_ERROR << "Cannot send cached eventgroup - runtime already destroyed"; - return; - } - std::set> its_events = routing_->find_events(_service, _instance, _eventgroup); for (const auto& its_event : its_events) { if (its_event && its_event->is_field() && its_event->is_set()) { - std::shared_ptr its_message = rt->create_notification(); + std::shared_ptr its_message = runtime_->create_notification(); const event_t its_event_id(its_event->get_event()); its_message->set_service(_service); its_message->set_method(its_event_id); diff --git a/implementation/security/include/policy.hpp b/implementation/security/include/policy.hpp index a0748146c..798b551fd 100644 --- a/implementation/security/include/policy.hpp +++ b/implementation/security/include/policy.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_POLICY_HPP_ -#define VSOMEIP_V3_POLICY_HPP_ +#pragma once #include #include @@ -92,5 +91,3 @@ struct policy { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_POLICY_HPP_ diff --git a/implementation/security/include/policy_manager_impl.hpp b/implementation/security/include/policy_manager_impl.hpp index b3f240d08..ea6faf40e 100644 --- a/implementation/security/include/policy_manager_impl.hpp +++ b/implementation/security/include/policy_manager_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SECURITY_POLICY_MANAGER_IMPL_HPP_ -#define VSOMEIP_V3_SECURITY_POLICY_MANAGER_IMPL_HPP_ +#pragma once #include #include @@ -169,5 +168,3 @@ class VSOMEIP_IMPORT_EXPORT policy_manager_impl }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SECURITY_POLICY_MANAGER_IMPL_HPP_ diff --git a/implementation/security/include/security.hpp b/implementation/security/include/security.hpp index 65408de77..5f5e476ba 100644 --- a/implementation/security/include/security.hpp +++ b/implementation/security/include/security.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SECURITY_HPP_ -#define VSOMEIP_V3_SECURITY_HPP_ +#pragma once #include #include @@ -40,5 +39,3 @@ class VSOMEIP_IMPORT_EXPORT security { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SECURITY_HPP_ diff --git a/implementation/service_discovery/include/configuration_option_impl.hpp b/implementation/service_discovery/include/configuration_option_impl.hpp index 6dc985a46..cbef4dec6 100644 --- a/implementation/service_discovery/include/configuration_option_impl.hpp +++ b/implementation/service_discovery/include/configuration_option_impl.hpp @@ -2,8 +2,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_CONFIGURATION_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_CONFIGURATION_OPTION_IMPL_HPP_ +#pragma once #include #include @@ -42,5 +41,3 @@ class configuration_option_impl : public option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_CONFIGURATION_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/constants.hpp b/implementation/service_discovery/include/constants.hpp index 6f690a93b..fa6c52847 100644 --- a/implementation/service_discovery/include/constants.hpp +++ b/implementation/service_discovery/include/constants.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_CONSTANTS_HPP_ -#define VSOMEIP_V3_SD_CONSTANTS_HPP_ +#pragma once #include #include @@ -33,5 +32,3 @@ const uint8_t udp = 0x11; } // namespace protocol } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_CONSTANTS_HPP_ diff --git a/implementation/service_discovery/include/defines.hpp b/implementation/service_discovery/include/defines.hpp index 159e41ab1..f274df254 100644 --- a/implementation/service_discovery/include/defines.hpp +++ b/implementation/service_discovery/include/defines.hpp @@ -3,24 +3,17 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_SD_DEFINES_HPP -#define VSOMEIP_SD_DEFINES_HPP +#pragma once -#define VSOMEIP_MAX_TCP_SD_PAYLOAD 4075 // Available for entries & options #define VSOMEIP_MAX_UDP_SD_PAYLOAD 1380 #define VSOMEIP_SOMEIP_SD_DATA_SIZE 12 #define VSOMEIP_SOMEIP_SD_ENTRY_LENGTH_SIZE 4 #define VSOMEIP_SOMEIP_SD_ENTRY_SIZE 16 -#define VSOMEIP_SOMEIP_SD_IPV4_OPTION_SIZE 12 -#define VSOMEIP_SOMEIP_SD_IPV6_OPTION_SIZE 24 -#define VSOMEIP_SOMEIP_SD_LOAD_BALANCING_OPTION_SIZE 8 -#define VSOMEIP_SOMEIP_SD_PROTECTION_OPTION_SIZE 12 #define VSOMEIP_SOMEIP_SD_OPTION_LENGTH_SIZE 4 #define VSOMEIP_SOMEIP_SD_OPTION_HEADER_SIZE 3 #define VSOMEIP_SOMEIP_SD_EMPTY_MESSAGE_SIZE 28 -#define VSOMEIP_SOMEIP_SD_SPACE_FOR_PAYLOAD VSOMEIP_MAX_UDP_MESSAGE_SIZE - VSOMEIP_SOMEIP_SD_EMPTY_MESSAGE_SIZE; #define VSOMEIP_SD_IPV4_OPTION_LENGTH 0x0009 #define VSOMEIP_SD_IPV6_OPTION_LENGTH 0x0015 @@ -49,5 +42,3 @@ #define VSOMEIP_SD_WAIT_ROUTE_NETLINK_NOTIFICATION true #define VSOMEIP_SD_STOP_OFFER_WATCHDOG_TIME 2000 #define VSOMEIP_SD_OFFERS_WATCHDOG_TIME 4000 - -#endif // VSOMEIP_SD_DEFINES_HPP diff --git a/implementation/service_discovery/include/deserializer.hpp b/implementation/service_discovery/include/deserializer.hpp index 54a9c6be0..07d1a623b 100644 --- a/implementation/service_discovery/include/deserializer.hpp +++ b/implementation/service_discovery/include/deserializer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_DESERIALIZER_HPP -#define VSOMEIP_V3_SD_DESERIALIZER_HPP +#pragma once #include "../../message/include/deserializer.hpp" @@ -25,5 +24,3 @@ class deserializer : public vsomeip_v3::deserializer { } // namespace sd } // vsomeip_v3 - -#endif // VSOMEIP_V3_SD_DESERIALIZER_HPP diff --git a/implementation/service_discovery/include/entry_impl.hpp b/implementation/service_discovery/include/entry_impl.hpp index 949947105..edf0dfe92 100644 --- a/implementation/service_discovery/include/entry_impl.hpp +++ b/implementation/service_discovery/include/entry_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_ENTRY_IMPL_HPP -#define VSOMEIP_V3_SD_ENTRY_IMPL_HPP +#pragma once #include #include @@ -77,5 +76,3 @@ class entry_impl : public message_element_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_ENTRY_IMPL_HPP diff --git a/implementation/service_discovery/include/enumeration_types.hpp b/implementation/service_discovery/include/enumeration_types.hpp index 2fb18cb8f..b3d67a9c2 100644 --- a/implementation/service_discovery/include/enumeration_types.hpp +++ b/implementation/service_discovery/include/enumeration_types.hpp @@ -5,8 +5,7 @@ #include -#ifndef VSOMEIP_V3_SD_ENUMERATION_TYPES_HPP -#define VSOMEIP_V3_SD_ENUMERATION_TYPES_HPP +#pragma once namespace vsomeip_v3 { namespace sd { @@ -42,5 +41,3 @@ enum class layer_four_protocol_e : uint8_t { TCP = 0x06, UDP = 0x11, UNKNOWN = 0 } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_ENUMERATION_TYPES_HPP diff --git a/implementation/service_discovery/include/eventgroupentry_impl.hpp b/implementation/service_discovery/include/eventgroupentry_impl.hpp index d8f9fad6f..2c1187449 100644 --- a/implementation/service_discovery/include/eventgroupentry_impl.hpp +++ b/implementation/service_discovery/include/eventgroupentry_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_EVENTGROUPENTRY_IMPL_HPP_ -#define VSOMEIP_V3_SD_EVENTGROUPENTRY_IMPL_HPP_ +#pragma once #include "entry_impl.hpp" #include "../../endpoints/include/endpoint_definition.hpp" @@ -60,5 +59,3 @@ class eventgroupentry_impl : public entry_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_EVENTGROUPENTRY_IMPL_HPP_ diff --git a/implementation/service_discovery/include/ip_option_impl.hpp b/implementation/service_discovery/include/ip_option_impl.hpp index ef8291336..94c3e9f93 100644 --- a/implementation/service_discovery/include/ip_option_impl.hpp +++ b/implementation/service_discovery/include/ip_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_IP_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_IP_OPTION_IMPL_HPP_ +#pragma once #include @@ -38,5 +37,3 @@ class ip_option_impl : public option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_IP_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/ipv4_option_impl.hpp b/implementation/service_discovery/include/ipv4_option_impl.hpp index 43fa36978..66c8b1813 100644 --- a/implementation/service_discovery/include/ipv4_option_impl.hpp +++ b/implementation/service_discovery/include/ipv4_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_IPV4_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_IPV4_OPTION_IMPL_HPP_ +#pragma once #include @@ -36,5 +35,3 @@ class ipv4_option_impl : public ip_option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_IPV4_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/ipv6_option_impl.hpp b/implementation/service_discovery/include/ipv6_option_impl.hpp index f99b92625..1bc3375df 100644 --- a/implementation/service_discovery/include/ipv6_option_impl.hpp +++ b/implementation/service_discovery/include/ipv6_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_IPV6_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_IPV6_OPTION_IMPL_HPP_ +#pragma once #include @@ -36,5 +35,3 @@ class ipv6_option_impl : public ip_option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_IPV6_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/load_balancing_option_impl.hpp b/implementation/service_discovery/include/load_balancing_option_impl.hpp index 751a3d3e9..87ff80c17 100644 --- a/implementation/service_discovery/include/load_balancing_option_impl.hpp +++ b/implementation/service_discovery/include/load_balancing_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_LOAD_BALANCING_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_LOAD_BALANCING_OPTION_IMPL_HPP_ +#pragma once #include "primitive_types.hpp" #include "option_impl.hpp" @@ -35,5 +34,3 @@ class load_balancing_option_impl : public option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_LOAD_BALANCING_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/message_element_impl.hpp b/implementation/service_discovery/include/message_element_impl.hpp index df6bc6dc7..27939dc74 100644 --- a/implementation/service_discovery/include/message_element_impl.hpp +++ b/implementation/service_discovery/include/message_element_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_MESSAGE_ELEMENT_IMPL_HPP_ -#define VSOMEIP_V3_SD_MESSAGE_ELEMENT_IMPL_HPP_ +#pragma once namespace vsomeip_v3 { namespace sd { @@ -24,5 +23,3 @@ class message_element_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_MESSAGE_ELEMENT_IMPL_HPP_ diff --git a/implementation/service_discovery/include/message_impl.hpp b/implementation/service_discovery/include/message_impl.hpp index 796238f3d..12511df9a 100644 --- a/implementation/service_discovery/include/message_impl.hpp +++ b/implementation/service_discovery/include/message_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ -#define VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ +#pragma once #include #include @@ -121,5 +120,3 @@ class message_impl : public vsomeip_v3::message, public vsomeip_v3::message_base } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ diff --git a/implementation/service_discovery/include/option_impl.hpp b/implementation/service_discovery/include/option_impl.hpp index 85565f04c..c67ee67a0 100644 --- a/implementation/service_discovery/include/option_impl.hpp +++ b/implementation/service_discovery/include/option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_OPTION_IMPL_HPP_ +#pragma once #include #include @@ -43,5 +42,3 @@ class option_impl : public message_element_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/primitive_types.hpp b/implementation/service_discovery/include/primitive_types.hpp index 6c9131dad..86e804ebe 100644 --- a/implementation/service_discovery/include/primitive_types.hpp +++ b/implementation/service_discovery/include/primitive_types.hpp @@ -5,8 +5,7 @@ #include -#ifndef VSOMEIP_V3_SD_PRIMITIVE_TYPES_HPP_ -#define VSOMEIP_V3_SD_PRIMITIVE_TYPES_HPP_ +#pragma once namespace vsomeip_v3 { namespace sd { @@ -24,5 +23,3 @@ typedef uint8_t flags_t; } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_PRIMITIVE_TYPES_HPP_ diff --git a/implementation/service_discovery/include/protection_option_impl.hpp b/implementation/service_discovery/include/protection_option_impl.hpp index b290f6b6c..ce442e9c8 100644 --- a/implementation/service_discovery/include/protection_option_impl.hpp +++ b/implementation/service_discovery/include/protection_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_PROTECTION_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_PROTECTION_OPTION_IMPL_HPP_ +#pragma once #include "../include/primitive_types.hpp" #include "../include/option_impl.hpp" @@ -35,5 +34,3 @@ class protection_option_impl : public option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_PROTECTION_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/remote_subscription_ack.hpp b/implementation/service_discovery/include/remote_subscription_ack.hpp index 496e94636..0c837a884 100644 --- a/implementation/service_discovery/include/remote_subscription_ack.hpp +++ b/implementation/service_discovery/include/remote_subscription_ack.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_ -#define VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_ +#pragma once #include #include @@ -59,5 +58,3 @@ class remote_subscription_ack { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_ diff --git a/implementation/service_discovery/include/request.hpp b/implementation/service_discovery/include/request.hpp index 764e1a8c8..f13eb4c05 100644 --- a/implementation/service_discovery/include/request.hpp +++ b/implementation/service_discovery/include/request.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_REQUEST_HPP_ -#define VSOMEIP_V3_SD_REQUEST_HPP_ +#pragma once #include @@ -42,5 +41,3 @@ class request { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_REQUEST_HPP_ diff --git a/implementation/service_discovery/include/runtime.hpp b/implementation/service_discovery/include/runtime.hpp index 6629c1ae3..fa41ed4d5 100644 --- a/implementation/service_discovery/include/runtime.hpp +++ b/implementation/service_discovery/include/runtime.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_RUNTIME_HPP_ -#define VSOMEIP_V3_SD_RUNTIME_HPP_ +#pragma once #include @@ -33,5 +32,3 @@ class runtime { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_RUNTIME_HPP_ diff --git a/implementation/service_discovery/include/runtime_impl.hpp b/implementation/service_discovery/include/runtime_impl.hpp index 5831b0b7b..60138c9c9 100644 --- a/implementation/service_discovery/include/runtime_impl.hpp +++ b/implementation/service_discovery/include/runtime_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_RUNTIME_IMPL_HPP_ -#define VSOMEIP_V3_SD_RUNTIME_IMPL_HPP_ +#pragma once #include #include "runtime.hpp" @@ -23,5 +22,3 @@ class runtime_impl : public runtime, public plugin_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_RUNTIME_IMPL_HPP_ diff --git a/implementation/service_discovery/include/selective_option_impl.hpp b/implementation/service_discovery/include/selective_option_impl.hpp index 4e3b89013..5fea3d82c 100644 --- a/implementation/service_discovery/include/selective_option_impl.hpp +++ b/implementation/service_discovery/include/selective_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_SELECTIVE_OPTION_IMPL_HPP -#define VSOMEIP_V3_SD_SELECTIVE_OPTION_IMPL_HPP +#pragma once #include @@ -43,5 +42,3 @@ class selective_option_impl : public option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_SELECTIVE_OPTION_IMPL_HPP diff --git a/implementation/service_discovery/include/service_discovery.hpp b/implementation/service_discovery/include/service_discovery.hpp index dcdff868c..8099e8475 100644 --- a/implementation/service_discovery/include/service_discovery.hpp +++ b/implementation/service_discovery/include/service_discovery.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_SERVICE_DISCOVERY_HPP_ -#define VSOMEIP_V3_SD_SERVICE_DISCOVERY_HPP_ +#pragma once #include @@ -70,5 +69,3 @@ class service_discovery { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_SERVICE_DISCOVERY_HPP_ diff --git a/implementation/service_discovery/include/service_discovery_host.hpp b/implementation/service_discovery/include/service_discovery_host.hpp index 573072f88..97a740eb5 100644 --- a/implementation/service_discovery/include/service_discovery_host.hpp +++ b/implementation/service_discovery/include/service_discovery_host.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SERVICE_DISCOVERY_HOST_HPP_ -#define VSOMEIP_V3_SERVICE_DISCOVERY_HOST_HPP_ +#pragma once #include #include @@ -83,5 +82,3 @@ class service_discovery_host { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SERVICE_DISCOVERY_HOST_HPP_ diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index b345b3850..2cbdc09e2 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_SERVICE_DISCOVERY_IMPL_ -#define VSOMEIP_V3_SD_SERVICE_DISCOVERY_IMPL_ +#pragma once #include #include @@ -333,8 +332,6 @@ class service_discovery_impl : public service_discovery, public std::enable_shar boost::asio::steady_timer subscription_expiration_timer_; std::chrono::steady_clock::time_point next_subscription_expiration_; - uint32_t max_message_size_; - std::chrono::milliseconds initial_delay_; std::chrono::milliseconds offer_debounce_time_; std::chrono::milliseconds repetitions_base_delay_; @@ -430,5 +427,3 @@ class service_discovery_impl : public service_discovery, public std::enable_shar } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_SERVICE_DISCOVERY_IMPL_ diff --git a/implementation/service_discovery/include/serviceentry_impl.hpp b/implementation/service_discovery/include/serviceentry_impl.hpp index c9e677ab2..9e2d01112 100644 --- a/implementation/service_discovery/include/serviceentry_impl.hpp +++ b/implementation/service_discovery/include/serviceentry_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_SERVICEENTRY_IMPL_HPP -#define VSOMEIP_V3_SD_SERVICEENTRY_IMPL_HPP +#pragma once #include "entry_impl.hpp" @@ -28,5 +27,3 @@ class serviceentry_impl : public entry_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_SERVICEENTRY_IMPL_HPP diff --git a/implementation/service_discovery/include/subscription.hpp b/implementation/service_discovery/include/subscription.hpp index 29209329d..1a53e9feb 100644 --- a/implementation/service_discovery/include/subscription.hpp +++ b/implementation/service_discovery/include/subscription.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_SUBSCRIPTION_HPP_ -#define VSOMEIP_V3_SD_SUBSCRIPTION_HPP_ +#pragma once #include #include @@ -84,5 +83,3 @@ class subscription { } // namespace sd } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SD_SUBSCRIPTION_HPP_ diff --git a/implementation/service_discovery/include/unknown_option_impl.hpp b/implementation/service_discovery/include/unknown_option_impl.hpp index 77a4bab60..5e808b11f 100644 --- a/implementation/service_discovery/include/unknown_option_impl.hpp +++ b/implementation/service_discovery/include/unknown_option_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SD_UNKOWN_OPTION_IMPL_HPP_ -#define VSOMEIP_V3_SD_UNKOWN_OPTION_IMPL_HPP_ +#pragma once #include @@ -41,5 +40,3 @@ class unknown_option_impl : public option_impl { } // namespace sd } // namespace vsomeip_v3 - -#endif diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 7033527be..b8fda0f8c 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -49,10 +49,10 @@ service_discovery_impl::service_discovery_impl(service_discovery_host* _host, co serializer_(std::make_shared(configuration_->get_buffer_shrink_threshold())), deserializer_(std::make_shared(configuration_->get_buffer_shrink_threshold())), ttl_timer_(_host->get_io()), ttl_timer_runtime_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY / 2), ttl_(VSOMEIP_SD_DEFAULT_TTL), - subscription_expiration_timer_(_host->get_io()), max_message_size_(VSOMEIP_MAX_UDP_SD_PAYLOAD), initial_delay_(0), - offer_debounce_time_(VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME), repetitions_base_delay_(VSOMEIP_SD_DEFAULT_REPETITIONS_BASE_DELAY), - repetitions_max_(VSOMEIP_SD_DEFAULT_REPETITIONS_MAX), cyclic_offer_delay_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY), - offer_debounce_timer_(_host->get_io()), find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME), + subscription_expiration_timer_(_host->get_io()), initial_delay_(0), offer_debounce_time_(VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME), + repetitions_base_delay_(VSOMEIP_SD_DEFAULT_REPETITIONS_BASE_DELAY), repetitions_max_(VSOMEIP_SD_DEFAULT_REPETITIONS_MAX), + cyclic_offer_delay_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY), offer_debounce_timer_(_host->get_io()), + find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME), remaining_find_initial_debounce_reps_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS), find_debounce_time_(VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME), find_debounce_timer_(_host->get_io()), main_phase_timer_(_host->get_io()), is_suspended_(false), is_diagnosis_(false), last_msg_received_timer_(_host->get_io()), @@ -81,7 +81,6 @@ void service_discovery_impl::init() { port_ = configuration_->get_sd_port(); reliable_ = (configuration_->get_sd_protocol() == "tcp"); - max_message_size_ = (reliable_ ? VSOMEIP_MAX_TCP_SD_PAYLOAD : VSOMEIP_MAX_UDP_SD_PAYLOAD); ttl_ = configuration_->get_sd_ttl(); @@ -257,7 +256,7 @@ void service_discovery_impl::subscribe(service_t _service, instance_t _instance, return; } - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -387,7 +386,7 @@ void service_discovery_impl::unsubscribe(service_t _service, instance_t _instanc boost::asio::ip::address its_address; { - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -457,7 +456,7 @@ void service_discovery_impl::unsubscribe_all(service_t _service, instance_t _ins boost::asio::ip::address its_address; { - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -493,7 +492,7 @@ void service_discovery_impl::unsubscribe_all_on_suspend() { std::map>> its_stopsubscribes; { - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); for (auto its_service : subscribed_) { for (auto its_instance : its_service.second) { for (auto& its_eventgroup : its_instance.second) { @@ -532,7 +531,7 @@ void service_discovery_impl::unsubscribe_all_on_suspend() { void service_discovery_impl::remove_subscriptions(service_t _service, instance_t _instance) { - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { found_service->second.erase(_instance); @@ -794,7 +793,7 @@ entry_data_t service_discovery_impl::create_eventgroup_entry(service_t _service, for (const auto its_client : _subscription->get_clients()) { if (_subscription->get_state(its_client) == subscription_state_e::ST_RESUBSCRIBING_NOT_ACKNOWLEDGED) { its_other = std::make_shared(); - its_other->set_type(entry_type_e::SUBSCRIBE_EVENTGROUP); + its_other->set_type(entry_type_e::STOP_SUBSCRIBE_EVENTGROUP); its_other->set_service(_service); its_other->set_instance(_instance); its_other->set_eventgroup(_eventgroup); @@ -844,7 +843,7 @@ entry_data_t service_discovery_impl::create_eventgroup_entry(service_t _service, if (_subscription->get_state(its_client) == subscription_state_e::ST_RESUBSCRIBING_NOT_ACKNOWLEDGED) { if (!its_other) { its_other = std::make_shared(); - its_other->set_type(entry_type_e::SUBSCRIBE_EVENTGROUP); + its_other->set_type(entry_type_e::STOP_SUBSCRIBE_EVENTGROUP); its_other->set_service(_service); its_other->set_instance(_instance); its_other->set_eventgroup(_eventgroup); @@ -997,7 +996,7 @@ void service_discovery_impl::on_message(const byte_t* _data, length_t _length, c bool _is_multicast) { std::scoped_lock its_lock(check_ttl_mutex_); std::scoped_lock its_session_lock(sessions_received_mutex_); - std::lock_guard its_subscribed_lock(subscribed_mutex_); + std::scoped_lock its_subscribed_lock(subscribed_mutex_); if (is_suspended_) { return; @@ -1552,7 +1551,7 @@ void service_discovery_impl::on_endpoint_connected(service_t _service, instance_ get_subscription_address(its_dummy, _endpoint, its_address); { - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -2210,7 +2209,7 @@ void service_discovery_impl::handle_eventgroup_subscription_nack(service_t _serv uint8_t _counter, const std::set& _clients) { (void)_counter; - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); @@ -2240,7 +2239,7 @@ void service_discovery_impl::handle_eventgroup_subscription_ack(service_t _servi (void)_ttl; (void)_counter; - std::lock_guard its_lock(subscribed_mutex_); + std::scoped_lock its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { auto found_instance = found_service->second.find(_instance); diff --git a/implementation/tracing/include/channel_impl.hpp b/implementation/tracing/include/channel_impl.hpp index 0a747cddf..31f2d164a 100644 --- a/implementation/tracing/include/channel_impl.hpp +++ b/implementation/tracing/include/channel_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TRACE_CHANNEL_IMPL_HPP_ -#define VSOMEIP_V3_TRACE_CHANNEL_IMPL_HPP_ +#pragma once #include #include @@ -58,5 +57,3 @@ class channel_impl : public channel { } // namespace trace } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TRACE_CHANNEL_IMPL_HPP_ diff --git a/implementation/tracing/include/connector_impl.hpp b/implementation/tracing/include/connector_impl.hpp index bfdee636c..7180d78bb 100644 --- a/implementation/tracing/include/connector_impl.hpp +++ b/implementation/tracing/include/connector_impl.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TRACE_CONNECTOR_HPP_ -#define VSOMEIP_V3_TRACE_CONNECTOR_HPP_ +#pragma once #ifdef USE_DLT #include @@ -77,5 +76,3 @@ class connector_impl : public connector { } // namespace trace } // namespace vsomeip_v3 - -#endif // VSOMEIP_TC_TRACE_CONNECTOR_HPP diff --git a/implementation/tracing/include/defines.hpp b/implementation/tracing/include/defines.hpp index 4b1a72560..1d08e409f 100644 --- a/implementation/tracing/include/defines.hpp +++ b/implementation/tracing/include/defines.hpp @@ -3,13 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_TRACE_DEFINES_HPP_ -#define VSOMEIP_TRACE_DEFINES_HPP_ +#pragma once #define VSOMEIP_TC_DEFAULT_CHANNEL_NAME "Trace Connector Network Logging" #define VSOMEIP_TC_DEFAULT_FILTER_TYPE "positive" #define VSOMEIP_TC_INSTANCE_POS_MIN 8 #define VSOMEIP_TC_INSTANCE_POS_MAX 9 - -#endif // VSOMEIP_TRACE_DEFINES_HPP_ diff --git a/implementation/tracing/include/enumeration_types.hpp b/implementation/tracing/include/enumeration_types.hpp index 5471dddce..587b8ef62 100644 --- a/implementation/tracing/include/enumeration_types.hpp +++ b/implementation/tracing/include/enumeration_types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TRACE_ENUMERATION_TYPES_HPP_ -#define VSOMEIP_V3_TRACE_ENUMERATION_TYPES_HPP_ +#pragma once namespace vsomeip_v3 { namespace trace { @@ -13,5 +12,3 @@ enum class filter_type_e : uint8_t { NEGATIVE = 0x00, POSITIVE = 0x01, HEADER_ON } // namespace trace } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TRACE_ENUMERATION_TYPES_HPP_ diff --git a/implementation/tracing/include/header.hpp b/implementation/tracing/include/header.hpp index 4fefe255c..0ddfb0a6c 100644 --- a/implementation/tracing/include/header.hpp +++ b/implementation/tracing/include/header.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TRACE_HEADER_HPP_ -#define VSOMEIP_V3_TRACE_HEADER_HPP_ +#pragma once #include @@ -36,5 +35,3 @@ struct header { } // namespace trace } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_TRACE_HEADER_HPP_ diff --git a/implementation/utility/include/bithelper.hpp b/implementation/utility/include/bithelper.hpp index b6d9abe4a..c3667c5d3 100644 --- a/implementation/utility/include/bithelper.hpp +++ b/implementation/utility/include/bithelper.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_BITHELPER_HPP -#define VSOMEIP_V3_BITHELPER_HPP +#pragma once #include #include @@ -126,5 +125,3 @@ class bithelper { }; } - -#endif // VSOMEIP_V3_BITHELPER_HPP diff --git a/implementation/utility/include/byteorder.hpp b/implementation/utility/include/byteorder.hpp index 673937f8e..7d9e2cf6a 100644 --- a/implementation/utility/include/byteorder.hpp +++ b/implementation/utility/include/byteorder.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_BYTEORDER_HPP -#define VSOMEIP_V3_BYTEORDER_HPP +#pragma once #define BYTEORDER_UNKNOWN 0 #define BYTEORDER_LITTLE_ENDIAN 1 @@ -47,5 +46,3 @@ #else #define COMPILE_TIME_ENDIAN BYTEORDER_UNKNOWN #endif - -#endif // VSOMEIP_V3_BYTEORDER_HPP diff --git a/implementation/utility/include/criticalsection.hpp b/implementation/utility/include/criticalsection.hpp index 47ef33b12..e0a8bd1e5 100644 --- a/implementation/utility/include/criticalsection.hpp +++ b/implementation/utility/include/criticalsection.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CRITICALSECTION_HPP -#define VSOMEIP_V3_CRITICALSECTION_HPP +#pragma once #include #include @@ -42,5 +41,3 @@ using CriticalSection = std::mutex; #endif } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CRITICALSECTION_HPP diff --git a/implementation/utility/include/is_value.hpp b/implementation/utility/include/is_value.hpp index 5f0f4947e..961389312 100644 --- a/implementation/utility/include/is_value.hpp +++ b/implementation/utility/include/is_value.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_IS_VALUE_HPP_ -#define VSOMEIP_V3_IS_VALUE_HPP_ +#pragma once namespace vsomeip_v3 { @@ -26,5 +25,3 @@ struct is_value { }; } - -#endif diff --git a/implementation/utility/include/qnx_helper.hpp b/implementation/utility/include/qnx_helper.hpp index bf3ce0ade..11dffec1c 100644 --- a/implementation/utility/include/qnx_helper.hpp +++ b/implementation/utility/include/qnx_helper.hpp @@ -4,8 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifdef __QNX__ -#ifndef VSOMEIP_V3_QNX_HELPER_HPP_ -#define VSOMEIP_V3_QNX_HELPER_HPP_ +#pragma once #include #include @@ -21,7 +20,3 @@ struct in_pktinfo { }; #define _STRUCT_IN_PKTINFO #endif - -#endif // VSOMEIP_V3_QNX_HELPER_HPP_ - -#endif diff --git a/implementation/utility/include/service_instance_map.hpp b/implementation/utility/include/service_instance_map.hpp index 780d1212b..9403e94e9 100644 --- a/implementation/utility/include/service_instance_map.hpp +++ b/implementation/utility/include/service_instance_map.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SERVICEINSTANCEMAP_HPP -#define VSOMEIP_V3_SERVICEINSTANCEMAP_HPP +#pragma once #include #include @@ -47,5 +46,3 @@ struct hash { } }; } // namespace std - -#endif // VSOMEIP_V3_SERVICE_INSTANCE_MAP_HPP diff --git a/implementation/utility/include/utility.hpp b/implementation/utility/include/utility.hpp index 971428c91..97191abc5 100644 --- a/implementation/utility/include/utility.hpp +++ b/implementation/utility/include/utility.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_UTILITY_HPP -#define VSOMEIP_V3_UTILITY_HPP +#pragma once #include #include @@ -74,8 +73,8 @@ class utility { static bool is_routing_manager(const std::string& _network); static void remove_lockfile(const std::string& _network); static bool exists(const std::string& _path); - static bool VSOMEIP_IMPORT_EXPORT is_file(const std::string& _path); - static bool VSOMEIP_IMPORT_EXPORT is_folder(const std::string& _path); + static bool is_file(const std::string& _path); + static bool is_folder(const std::string& _path); static std::string get_base_path(const std::string& _network); @@ -138,5 +137,3 @@ class utility { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_UTILITY_HPP diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp index 8c509688a..f2e081211 100644 --- a/interface/vsomeip/application.hpp +++ b/interface/vsomeip/application.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_APPLICATION_HPP_ -#define VSOMEIP_V3_APPLICATION_HPP_ +#pragma once #include #include @@ -1108,5 +1107,3 @@ class application { /** @} */ } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_APPLICATION_HPP_ diff --git a/interface/vsomeip/constants.hpp b/interface/vsomeip/constants.hpp index 41e6bbd81..3a4ecb87e 100644 --- a/interface/vsomeip/constants.hpp +++ b/interface/vsomeip/constants.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_CONSTANTS_HPP_ -#define VSOMEIP_V3_CONSTANTS_HPP_ +#pragma once #include @@ -59,5 +58,3 @@ inline constexpr int VSOMEIP_ALL = -1; inline constexpr pending_security_update_id_t DEFAULT_SECURITY_UPDATE_ID = 0x0; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CONSTANTS_HPP_ diff --git a/interface/vsomeip/defines.hpp b/interface/vsomeip/defines.hpp index cb7c49886..8307acbb9 100644 --- a/interface/vsomeip/defines.hpp +++ b/interface/vsomeip/defines.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_DEFINES_HPP_ -#define VSOMEIP_V3_DEFINES_HPP_ +#pragma once #include #include @@ -40,5 +39,3 @@ constexpr std::size_t VSOMEIP_INTERFACE_VERSION_POS = 13; constexpr std::size_t VSOMEIP_MESSAGE_TYPE_POS = 14; constexpr std::size_t VSOMEIP_RETURN_CODE_POS = 15; constexpr std::size_t VSOMEIP_PAYLOAD_POS = 16; - -#endif // VSOMEIP_V3_DEFINES_HPP_ diff --git a/interface/vsomeip/deprecated.hpp b/interface/vsomeip/deprecated.hpp index 9ba023573..18b83d90c 100644 --- a/interface/vsomeip/deprecated.hpp +++ b/interface/vsomeip/deprecated.hpp @@ -1,10 +1,12 @@ -#ifndef VSOMEIP_V3_DEPRECATED_HPP_ -#define VSOMEIP_V3_DEPRECATED_HPP_ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once #ifdef VSOMEIP_INTERNAL_SUPPRESS_DEPRECATED #define VSOMEIP_DEPRECATED_UID_GID #else #define VSOMEIP_DEPRECATED_UID_GID [[deprecated("Use vsomeip_sec_client_t-aware functions and types instead.")]] #endif - -#endif // VSOMEIP_V3_DEPRECATED_HPP_ diff --git a/interface/vsomeip/enumeration_types.hpp b/interface/vsomeip/enumeration_types.hpp index d4a76c4b2..409483456 100644 --- a/interface/vsomeip/enumeration_types.hpp +++ b/interface/vsomeip/enumeration_types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ENUMERATION_TYPES_HPP_ -#define VSOMEIP_V3_ENUMERATION_TYPES_HPP_ +#pragma once #include @@ -92,5 +91,3 @@ enum class endianess_e { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ENUMERATION_TYPES_HPP_ diff --git a/interface/vsomeip/error.hpp b/interface/vsomeip/error.hpp index 6ff48ddac..00f862610 100644 --- a/interface/vsomeip/error.hpp +++ b/interface/vsomeip/error.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_ERROR_HPP_ -#define VSOMEIP_V3_ERROR_HPP_ +#pragma once #include @@ -19,5 +18,3 @@ enum class error_code_e : uint8_t { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_ERROR_HPP_ diff --git a/interface/vsomeip/export.hpp b/interface/vsomeip/export.hpp index 17b68c853..fe7b6749e 100644 --- a/interface/vsomeip/export.hpp +++ b/interface/vsomeip/export.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_EXPORT_HPP_ -#define VSOMEIP_V3_EXPORT_HPP_ +#pragma once #if _WIN32 #define VSOMEIP_EXPORT __declspec(dllexport) @@ -26,5 +25,3 @@ #define VSOMEIP_IMPORT_EXPORT #define VSOMEIP_IMPORT_EXPORT_CONFIG #endif - -#endif // VSOMEIP_V3_EXPORT_HPP_ diff --git a/interface/vsomeip/function_types.hpp b/interface/vsomeip/function_types.hpp index 697822ece..dcb84d4c3 100644 --- a/interface/vsomeip/function_types.hpp +++ b/interface/vsomeip/function_types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_FUNCTION_TYPES_HPP_ -#define VSOMEIP_V3_FUNCTION_TYPES_HPP_ +#pragma once #include #include @@ -16,5 +15,3 @@ class payload; typedef std::function&, const std::shared_ptr&)> epsilon_change_func_t; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_FUNCTION_TYPES_HPP_ diff --git a/interface/vsomeip/handler.hpp b/interface/vsomeip/handler.hpp index fe828d473..eb5b42266 100644 --- a/interface/vsomeip/handler.hpp +++ b/interface/vsomeip/handler.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_HANDLER_HPP_ -#define VSOMEIP_V3_HANDLER_HPP_ +#pragma once #include #include @@ -103,5 +102,3 @@ typedef std::function security_update_handler_t; typedef std::function message_acceptance_handler_t; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_HANDLER_HPP_ diff --git a/interface/vsomeip/internal/deserializable.hpp b/interface/vsomeip/internal/deserializable.hpp index 4796cc9ce..1938ea121 100644 --- a/interface/vsomeip/internal/deserializable.hpp +++ b/interface/vsomeip/internal/deserializable.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_DESERIALIZABLE_HPP_ -#define VSOMEIP_V3_DESERIALIZABLE_HPP_ +#pragma once #include @@ -19,5 +18,3 @@ class deserializable { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SERIALIZABLE_HPP_ diff --git a/interface/vsomeip/internal/logger.hpp b/interface/vsomeip/internal/logger.hpp index bdbd9fa1d..f3373c374 100644 --- a/interface/vsomeip/internal/logger.hpp +++ b/interface/vsomeip/internal/logger.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_LOGGER_HPP_ -#define VSOMEIP_V3_LOGGER_HPP_ +#pragma once #include #include @@ -95,5 +94,3 @@ class message : public std::ostream { fflush(stderr); \ std::abort(); \ } while (0) - -#endif // VSOMEIP_V3_LOGGER_HPP_ diff --git a/interface/vsomeip/internal/plugin_manager.hpp b/interface/vsomeip/internal/plugin_manager.hpp index d0ebcd1ec..a0d51fcb1 100644 --- a/interface/vsomeip/internal/plugin_manager.hpp +++ b/interface/vsomeip/internal/plugin_manager.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PLUGIN_MANAGER_HPP -#define VSOMEIP_V3_PLUGIN_MANAGER_HPP +#pragma once #include #include @@ -26,5 +25,3 @@ class plugin_manager { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PLUGIN_MANAGER_HPP diff --git a/interface/vsomeip/internal/policy_manager.hpp b/interface/vsomeip/internal/policy_manager.hpp index c213cfae6..b4c228870 100644 --- a/interface/vsomeip/internal/policy_manager.hpp +++ b/interface/vsomeip/internal/policy_manager.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_POLICY_MANAGER_HPP_ -#define VSOMEIP_V3_POLICY_MANAGER_HPP_ +#pragma once #include @@ -31,5 +30,3 @@ class VSOMEIP_IMPORT_EXPORT policy_manager { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_POLICY_MANAGER_HPP_ diff --git a/interface/vsomeip/internal/serializable.hpp b/interface/vsomeip/internal/serializable.hpp index 1044e3ac1..a2e45b751 100644 --- a/interface/vsomeip/internal/serializable.hpp +++ b/interface/vsomeip/internal/serializable.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_SERIALIZABLE_HPP_ -#define VSOMEIP_V3_SERIALIZABLE_HPP_ +#pragma once #include @@ -26,5 +25,3 @@ class serializable { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_SERIALIZABLE_HPP_ diff --git a/interface/vsomeip/message.hpp b/interface/vsomeip/message.hpp index 0d975bcf3..9f99d7305 100644 --- a/interface/vsomeip/message.hpp +++ b/interface/vsomeip/message.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_MESSAGE_HPP_ -#define VSOMEIP_V3_MESSAGE_HPP_ +#pragma once #include @@ -85,5 +84,3 @@ class message : virtual public message_base { /** @} */ } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_MESSAGE_HPP_ diff --git a/interface/vsomeip/message_base.hpp b/interface/vsomeip/message_base.hpp index 7c581d51f..3dc32bc56 100644 --- a/interface/vsomeip/message_base.hpp +++ b/interface/vsomeip/message_base.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_MESSAGE_BASE_HPP_ -#define VSOMEIP_V3_MESSAGE_BASE_HPP_ +#pragma once #include #include @@ -193,5 +192,3 @@ class message_base : public serializable, public deserializable { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_MESSAGE_BASE_HPP_ diff --git a/interface/vsomeip/payload.hpp b/interface/vsomeip/payload.hpp index 1f974c5a7..595abc28f 100644 --- a/interface/vsomeip/payload.hpp +++ b/interface/vsomeip/payload.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PAYLOAD_HPP_ -#define VSOMEIP_V3_PAYLOAD_HPP_ +#pragma once #include @@ -99,5 +98,3 @@ class payload : public serializable, public deserializable { /** @} */ } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PAYLOAD_HPP_ diff --git a/interface/vsomeip/plugin.hpp b/interface/vsomeip/plugin.hpp index 4714c2c72..d7b93580b 100644 --- a/interface/vsomeip/plugin.hpp +++ b/interface/vsomeip/plugin.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PLUGIN_HPP_ -#define VSOMEIP_V3_PLUGIN_HPP_ +#pragma once #include #include @@ -74,5 +73,3 @@ class plugin_impl : public plugin { } } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PLUGIN_HPP_ diff --git a/interface/vsomeip/plugins/application_plugin.hpp b/interface/vsomeip/plugins/application_plugin.hpp index b7ff65abf..0f2a623c2 100644 --- a/interface/vsomeip/plugins/application_plugin.hpp +++ b/interface/vsomeip/plugins/application_plugin.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_APPLICATION_PLUGIN_HPP_ -#define VSOMEIP_V3_APPLICATION_PLUGIN_HPP_ +#pragma once #include #include @@ -35,5 +34,3 @@ class application_plugin { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_APPLICATION_PLUGIN_HPP_ diff --git a/interface/vsomeip/plugins/pre_configuration_plugin.hpp b/interface/vsomeip/plugins/pre_configuration_plugin.hpp index 234bed60f..3cf7703b8 100644 --- a/interface/vsomeip/plugins/pre_configuration_plugin.hpp +++ b/interface/vsomeip/plugins/pre_configuration_plugin.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PRE_CONFIGURATION_PLUGIN_HPP_ -#define VSOMEIP_V3_PRE_CONFIGURATION_PLUGIN_HPP_ +#pragma once #include @@ -26,5 +25,3 @@ class pre_configuration_plugin { }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PRE_CONFIGURATION_PLUGIN_HPP_ diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index 9c32fde6f..4fea1e0b5 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_PRIMITIVE_TYPES_HPP_ -#define VSOMEIP_V3_PRIMITIVE_TYPES_HPP_ +#pragma once #include #include @@ -63,5 +62,3 @@ typedef ::uid_t gid_t; #endif } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_PRIMITIVE_TYPES_HPP diff --git a/interface/vsomeip/runtime.hpp b/interface/vsomeip/runtime.hpp index 35a2f5539..6f92a1c1b 100644 --- a/interface/vsomeip/runtime.hpp +++ b/interface/vsomeip/runtime.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_RUNTIME_HPP -#define VSOMEIP_V3_RUNTIME_HPP +#pragma once #include #include @@ -221,5 +220,3 @@ class VSOMEIP_IMPORT_EXPORT runtime { /** @} */ } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_RUNTIME_HPP_ diff --git a/interface/vsomeip/structured_types.hpp b/interface/vsomeip/structured_types.hpp index 6201823f3..3a65080fc 100644 --- a/interface/vsomeip/structured_types.hpp +++ b/interface/vsomeip/structured_types.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_STRUCTURED_TYPES_HPP_ -#define VSOMEIP_V3_STRUCTURED_TYPES_HPP_ +#pragma once #include #include @@ -34,26 +33,18 @@ struct debounce_filter_t { } inline bool operator==(const debounce_filter_t& _other) const { - return (on_change_ == _other.on_change_ && on_change_resets_interval_ == _other.on_change_resets_interval_ && interval_ == _other.interval_ && ignore_ == _other.ignore_ && send_current_value_after_ == _other.send_current_value_after_); } - inline bool operator!=(const debounce_filter_t& _other) const { - - return (on_change_ != _other.on_change_ || on_change_resets_interval_ != _other.on_change_resets_interval_ - || interval_ != _other.interval_ || ignore_ != _other.ignore_ - || send_current_value_after_ != _other.send_current_value_after_); - } + inline bool operator!=(const debounce_filter_t& _other) const { return !(*this == _other); } bool on_change_; bool on_change_resets_interval_; int64_t interval_; std::map ignore_; - bool send_current_value_after_; + bool send_current_value_after_; // ignored, does nothing }; } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_STRUCTURED_TYPES_HPP diff --git a/interface/vsomeip/trace.hpp b/interface/vsomeip/trace.hpp index c3fcdff44..b2a1de6ff 100644 --- a/interface/vsomeip/trace.hpp +++ b/interface/vsomeip/trace.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TRACE_HPP_ -#define VSOMEIP_V3_TRACE_HPP_ +#pragma once #include #include @@ -204,5 +203,3 @@ class connector { /** @} */ } // namespace vsomeip_v3 - -#endif // VSOMEIP_V3_CONSTANTS_HPP_ diff --git a/interface/vsomeip/vsomeip.hpp b/interface/vsomeip/vsomeip.hpp index d4334daf5..1dfd41379 100644 --- a/interface/vsomeip/vsomeip.hpp +++ b/interface/vsomeip/vsomeip.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_VSOMEIP_HPP -#define VSOMEIP_VSOMEIP_HPP +#pragma once /** * \brief The central vsomeip header. Include this to use vsomeip. @@ -19,5 +18,3 @@ #include namespace vsomeip = vsomeip_v3; - -#endif // VSOMEIP_VSOMEIP_HPP diff --git a/libvsomeip.yaml b/libvsomeip.yaml index 0821547e5..99d519efa 100644 --- a/libvsomeip.yaml +++ b/libvsomeip.yaml @@ -1,5 +1,5 @@ - name: libvsomeip - version: 3.6.3 + version: 3.6.4 vendor: Lynx Team license: concluded: CLOSED and MPLv2 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3a59e0c12..2869d6175 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -40,6 +40,47 @@ if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1") set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) endif() +############################################################################## +# test libraries +# these expose all symbols, unlike the normal vsomeip libraries; useful for tests + +add_library(${VSOMEIP_NAME}-test SHARED $) +# libvsomeip also `dlopens` other libs (cfg, sd, ..) so leave a rpath hint +set_target_properties(${VSOMEIP_NAME}-test PROPERTIES BUILD_RPATH "${CMAKE_CURRENT_BINARY_DIR}") +set_target_properties(${VSOMEIP_NAME}-test PROPERTIES OUTPUT_NAME ${VSOMEIP_NAME} VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) +target_link_libraries(${VSOMEIP_NAME}-test PRIVATE ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${DLT_LIBRARIES} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + +if (NOT MSVC) + if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + # add syscall wrappers to deal with CLOEXEC + set_target_properties(${VSOMEIP_NAME}-test PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open") + else () + # add syscall wrappers to deal with CLOEXEC + react on certain errors + set_target_properties(${VSOMEIP_NAME}-test PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open -Wl,-wrap,close -Wl,-wrap,recvfrom -Wl,-wrap,recvmsg -Wl,-wrap,sendto -Wl,-wrap,sendmsg -Wl,-wrap,epoll_wait -Wl,-wrap,epoll_pwait") + endif () +endif () + +add_library(${VSOMEIP_NAME}-cfg-test SHARED $) +set_target_properties(${VSOMEIP_NAME}-cfg-test PROPERTIES OUTPUT_NAME ${VSOMEIP_NAME}-cfg VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) +target_link_libraries(${VSOMEIP_NAME}-cfg-test ${VSOMEIP_NAME}-test ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES}) +set_target_properties(${VSOMEIP_NAME}-cfg-test PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) + +add_library(${VSOMEIP_NAME}-sd-test SHARED $) +set_target_properties(${VSOMEIP_NAME}-sd-test PROPERTIES OUTPUT_NAME ${VSOMEIP_NAME}-sd VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) +target_link_libraries(${VSOMEIP_NAME}-sd-test ${VSOMEIP_NAME}-test ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + +add_library(${VSOMEIP_NAME}-e2e-test SHARED $) +set_target_properties(${VSOMEIP_NAME}-e2e-test PROPERTIES OUTPUT_NAME ${VSOMEIP_NAME}-e2e VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION}) +target_link_libraries(${VSOMEIP_NAME}-e2e-test ${VSOMEIP_NAME}-test ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES}) + +if (MSVC) + set_target_properties(${VSOMEIP_NAME}-test PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + set_target_properties(${VSOMEIP_NAME}-test PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") + set_target_properties(${VSOMEIP_NAME}-cfg-test PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") + set_target_properties(${VSOMEIP_NAME}-sd-test PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") + set_target_properties(${VSOMEIP_NAME}-e2e-test PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN") +endif () + ############################################################################## # build tests @@ -108,19 +149,15 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) add_dependencies(check build_tests) add_custom_target(build_network_tests) -add_dependencies(build_network_tests ${VSOMEIP_NAME}) -add_dependencies(build_network_tests ${VSOMEIP_NAME}-e2e) -add_dependencies(build_network_tests ${VSOMEIP_NAME}-sd) +add_dependencies(build_network_tests ${VSOMEIP_NAME}-test ${VSOMEIP_NAME}-cfg-test ${VSOMEIP_NAME}-e2e-test ${VSOMEIP_NAME}-sd-test) add_dependencies(build_tests build_network_tests) add_custom_target(build_unit_tests) -add_dependencies(build_unit_tests ${VSOMEIP_NAME}) -add_dependencies(build_unit_tests ${VSOMEIP_NAME}-sd) +add_dependencies(build_unit_tests ${VSOMEIP_NAME}-test ${VSOMEIP_NAME}-cfg-test ${VSOMEIP_NAME}-e2e-test ${VSOMEIP_NAME}-sd-test) add_dependencies(build_tests build_unit_tests) add_custom_target(build_benchmark_tests) -add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}) -add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}-sd) +add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}-test ${VSOMEIP_NAME}-cfg-test ${VSOMEIP_NAME}-e2e-test ${VSOMEIP_NAME}-sd-test) add_dependencies(build_tests build_benchmark_tests) ############################################################################## diff --git a/test/benchmark_tests/CMakeLists.txt b/test/benchmark_tests/CMakeLists.txt index d861aa564..fcf22b14c 100644 --- a/test/benchmark_tests/CMakeLists.txt +++ b/test/benchmark_tests/CMakeLists.txt @@ -16,8 +16,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable (${PROJECT_NAME} ${SRCS} ) target_link_libraries ( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test Threads::Threads ${Boost_LIBRARIES} ${DL_LIBRARY} diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt index 1f4dcc136..2f60eece1 100644 --- a/test/common/CMakeLists.txt +++ b/test/common/CMakeLists.txt @@ -21,7 +21,7 @@ file(COPY ${EXAMPLES_POLICIES_FILES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/ex # Declare the library # ---------------------------------------------------------------------------- add_library ( - ${PROJECT_NAME} SHARED + ${PROJECT_NAME} OBJECT ${SRC} ${INC} ) @@ -29,7 +29,7 @@ add_library ( TARGET_LINK_LIBRARIES ( ${PROJECT_NAME} PUBLIC - ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-test ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} diff --git a/test/common/include/common/external/process.hpp b/test/common/include/common/external/process.hpp index a887436dd..fa8f85d4f 100644 --- a/test/common/include/common/external/process.hpp +++ b/test/common/include/common/external/process.hpp @@ -19,8 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#ifndef TINY_PROCESS_LIBRARY_HPP_ -#define TINY_PROCESS_LIBRARY_HPP_ +#pragma once #include #include #include @@ -195,5 +194,3 @@ class Process { }; } // namespace TinyProcessLib - -#endif // TINY_PROCESS_LIBRARY_HPP_ diff --git a/test/common/include/common/process_manager.hpp b/test/common/include/common/process_manager.hpp index 420356fb1..e32e554d3 100644 --- a/test/common/include/common/process_manager.hpp +++ b/test/common/include/common/process_manager.hpp @@ -30,7 +30,6 @@ #include #include #endif -#include #include @@ -46,61 +45,64 @@ class process_manager { * @param env_vars Specific environment variables to be passed to new process, new process environemnt base is copied from the current * one. */ - process_manager(std::string cmd, std::map env_vars) : command_{cmd}, env_vars_{env_vars} { } + process_manager(const std::string& cmd, const std::map& env_vars) : command_{cmd}, env_vars_{env_vars} { } /** - * @brief Dtor, waits for spawning thread. - * TBD - Should probably try terminate process also. + * @brief Destructor + * + * EXPLODES if you do not wait for the launched process! */ - ~process_manager() { join(); } + ~process_manager() { + if (process_) { + std::cerr << "ABORTING BECAUSE THERE ARE STILL BACKGROUND PROCESSES RUNNING!" << std::endl; + std::abort(); + }; + } /** - * @brief Creates Spawning thread. + * @brief Laucnh process */ - void run() { thread_ = std::make_unique(std::bind(&process_manager::spawn, this)); } + void run() { + std::scoped_lock lock(mutex_); + if (process_) { + std::cerr << "ABORTING BECAUSE THERE ARE STILL BACKGROUND PROCESSES RUNNING!" << std::endl; + std::abort(); + } - /** - * @brief If joinable, joins spawning thread. - */ - void join() { - if (thread_->joinable()) { - thread_->join(); + boost::process::environment cp_env; + for (const auto& env_entry : boost::this_process::environment()) { + cp_env[env_entry.get_name()] = env_entry.to_string(); + } + for (const auto& env_map : env_vars_) { + const std::string& k = env_map.first; + const std::string& v = env_map.second; + cp_env[k] = v; } - } - /** - * @brief Forces the restart of the process with same conditions. - */ - void reset() { - terminate(); - join(); - thread_.reset(std::make_unique(std::bind(&process_manager::spawn, this)).release()); + process_ = std::make_unique(command_, cp_env); + + std::cout << "Process '" << command_ << "' started, pid " << process_->id() << std::endl; } /** - * @brief Forces the shutdown of the spawned process. + * @brief Wait for process to finish, return exit code */ - void terminate() { - std::scoped_lock lock(process_mutex_); - if (process_.running()) { - process_.terminate(); + [[nodiscard]] int wait() { + std::unique_lock lock(mutex_); + if (process_ == nullptr) { + std::cerr << "Aborting because there is no process '" << command_ << "' running!" << std::endl; + std::abort(); } - } - /** - * @brief Waits for spawned process to be shifted into ready state i.e., the process might not have started yet. - */ - void wait_for_start() { - std::unique_lock lock(process_mutex_); - start_cv_.wait(lock, [this]() { return process_.valid(); }); - } + lock.unlock(); + process_->wait(); + lock.lock(); - /** - * @brief Verifies if process native handle has been created. - * - * @return True is valid, false otherwise. - */ - bool valid() { return process_.valid(); } + int exit_code = process_->exit_code(); + std::cout << "Process '" << command_ << "' exited with " << exit_code << std::endl; + process_ = nullptr; + return exit_code; + } /** * @brief Send a specified signal type to the spawned process. @@ -108,47 +110,18 @@ class process_manager { * @param signal Signal to be sent. */ void send_signal(int signal) { - std::scoped_lock lock(process_mutex_); - kill(process_.id(), signal); - } - - std::atomic_int32_t exit_code_{0}; - -private: - /** - * @brief Manages the creation of the process and enforces the wait on it to ensure it's lifetime. - */ - void spawn() { - std::unique_lock lock(process_mutex_); - boost::asio::io_context io; - - // Handle env vars - boost::process::environment cp_env; - for (const auto& env_entry : boost::this_process::environment()) { - cp_env[env_entry.get_name()] = env_entry.to_string(); - } - for (const auto& env_map : env_vars_) { - const std::string& k = env_map.first; - const std::string& v = env_map.second; - cp_env[k] = v; + std::scoped_lock lock(mutex_); + if (process_ == nullptr) { + std::cerr << "Aborting because there is no process '" << command_ << "' running!" << std::endl; + std::abort(); } - process_ = boost::process::child( - command_, cp_env, io, boost::process::on_exit = [this](int exit, const std::error_code& eci) { - exit_code_ = exit; - std::cout << "Process " << command_ << " exited with " << exit << " and ec " << eci.message() << std::endl; - }); - start_cv_.notify_all(); - if (process_.running()) { - lock.unlock(); - io.run(); - } + kill(process_->id(), signal); } - boost::process::child process_; - std::unique_ptr thread_; - std::string command_; - std::map env_vars_; - std::mutex process_mutex_; - std::condition_variable start_cv_; +private: + const std::string command_; + const std::map env_vars_; + std::mutex mutex_; + std::unique_ptr process_; }; diff --git a/test/common/include/common/test_timer.hpp b/test/common/include/common/test_timer.hpp index d5284a99a..4534e4d6f 100644 --- a/test/common/include/common/test_timer.hpp +++ b/test/common/include/common/test_timer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef COMMON_TEST_TIMER_HPP -#define COMMON_TEST_TIMER_HPP +#pragma once #include @@ -25,5 +24,3 @@ class test_timer_t { std::chrono::system_clock::time_point start; }; } // namespace common - -#endif // COMMON_TEST_TIMER_HPP diff --git a/test/common/include/common/timeout_detector.hpp b/test/common/include/common/timeout_detector.hpp index 700d20882..21d56c43c 100644 --- a/test/common/include/common/timeout_detector.hpp +++ b/test/common/include/common/timeout_detector.hpp @@ -1,3 +1,8 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + #pragma once #include diff --git a/test/common/include/common/vsomeip_app_utilities.hpp b/test/common/include/common/vsomeip_app_utilities.hpp index 9a70fd097..71caeb14a 100644 --- a/test/common/include/common/vsomeip_app_utilities.hpp +++ b/test/common/include/common/vsomeip_app_utilities.hpp @@ -3,8 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_BASE_APP -#define VSOMEIP_BASE_APP +#pragma once + #include #include #include @@ -30,4 +30,3 @@ class base_vsip_app { ~base_vsip_app(); }; } -#endif // VSOMEIP_BASE_APP diff --git a/test/common/src/process.cpp b/test/common/src/process.cpp index 8b7064445..cedd38920 100644 --- a/test/common/src/process.cpp +++ b/test/common/src/process.cpp @@ -83,10 +83,6 @@ process_group_t& process_group_t::add_process(const std::string& name, const std // Always set application name to the process name env["VSOMEIP_APPLICATION_NAME"] = name; - const char* ld_library_path = std::getenv("LD_LIBRARY_PATH"); - std::string asdf = ld_library_path ? ld_library_path : ""; - // std::cout << "LD_LIBRARY_PATH:" << asdf << std::endl; - env["LD_LIBRARY_PATH"] = asdf; configs_.push_back({name, type.executable, env}); return *this; } @@ -95,7 +91,6 @@ process_group_t& process_group_t::add_daemon(std::string config_file) { auto& type = types_.at("daemon"); std::map env; env["VSOMEIP_CONFIGURATION"] = std::move(config_file); - env["LD_LIBRARY_PATH"] = std::getenv("LD_LIBRARY_PATH"); configs_.push_back({"daemon", type.executable, env}); return *this; diff --git a/test/internal_routing_disabled_acceptance_test/CMakeLists.txt b/test/internal_routing_disabled_acceptance_test/CMakeLists.txt index cce2eac69..05864c881 100644 --- a/test/internal_routing_disabled_acceptance_test/CMakeLists.txt +++ b/test/internal_routing_disabled_acceptance_test/CMakeLists.txt @@ -13,7 +13,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} applet.cpp client.cpp server.cpp main.cpp) target_include_directories(${PROJECT_NAME} PRIVATE ${gtest_SOURCE_DIR}/include) -target_link_libraries(${PROJECT_NAME} PRIVATE gtest Threads::Threads vsomeip3 ${Boost_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE gtest Threads::Threads vsomeip3-test ${Boost_LIBRARIES}) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_link_libraries(${PROJECT_NAME} PRIVATE stdc++ m) diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index 8c0c9ad66..bbce7b279 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -57,13 +57,14 @@ endfunction() function(targets_link_default_libraries targets) foreach(target ${targets}) target_link_libraries(${target} - ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-test ${Boost_LIBRARIES} ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} ${DLT_LIBRARIES} vsomeip_utilities ) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_link_libraries(${target} stdc++) if(UNIX) @@ -156,7 +157,6 @@ if(NOT ${TESTS_BAT}) add_subdirectory(client_id_tests) add_subdirectory(configuration_tests) add_subdirectory(cpu_load_tests) - add_subdirectory(debounce_callback_tests) add_subdirectory(debounce_epsilon_tests) add_subdirectory(debounce_filter_tests) add_subdirectory(debounce_frequency_tests) @@ -186,6 +186,7 @@ if(NOT ${TESTS_BAT}) add_subdirectory(subscribe_notify_tests) add_subdirectory(suspend_resume_tests) add_subdirectory(start_stop_start_tests) + add_subdirectory(shutdown_tests) endif() add_subdirectory(application_tests) @@ -196,7 +197,7 @@ add_subdirectory(npdu_tests) add_subdirectory(payload_tests) add_subdirectory(routing_tests) -# some tests require the routingmanagerd +# some tests require example binaries if(NOT MSVC) - add_dependencies(build_network_tests routingmanagerd) + add_dependencies(build_network_tests routingmanagerd wait-until-available) endif() diff --git a/test/network_tests/application_tests/CMakeLists.txt b/test/network_tests/application_tests/CMakeLists.txt index 687fbc3cc..67d369dd0 100644 --- a/test/network_tests/application_tests/CMakeLists.txt +++ b/test/network_tests/application_tests/CMakeLists.txt @@ -34,11 +34,6 @@ set(executable_targets targets_add_default_dependencies("${executable_targets}") targets_link_default_libraries("${executable_targets}") -# Skip valgrind -if (DEFINED VALGRIND_TYPE AND NOT VALGRIND_TYPE STREQUAL "") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --trace-children-skip=*/application_test*,*/routingmanagerd) -endif() - # Add custom test command. add_custom_test( NAME application_test diff --git a/test/network_tests/application_tests/application_test.cpp b/test/network_tests/application_tests/application_test.cpp index 7bcd00731..ffab0fbd9 100644 --- a/test/network_tests/application_tests/application_test.cpp +++ b/test/network_tests/application_tests/application_test.cpp @@ -64,7 +64,6 @@ TEST_F(someip_application_test, start_stop_application_multiple) { app_->start(); }); EXPECT_TRUE(its_promise.get_future().get()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); app_->stop(); t.join(); } @@ -82,9 +81,7 @@ TEST_F(someip_application_test, start_stop_application_multiple_offer_service) { }); EXPECT_TRUE(its_promise.get_future().get()); app_->offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); app_->stop_offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); app_->stop(); t.join(); } @@ -98,9 +95,9 @@ TEST_F(someip_application_test, restart_without_stopping) { std::thread t([&]() { its_promise.set_value(true); app_->start(); + app_->stop(); }); EXPECT_TRUE(its_promise.get_future().get()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); VSOMEIP_WARNING << "An error message should appear now"; // should print error app_->start(); @@ -127,7 +124,9 @@ TEST_F(someip_application_test, stop_application_twice) { /** * @test Checks whether watchdog handler is invoked (regularly) also after restarting. */ -TEST_F(someip_application_test, watchdog_handler) { +TEST_F(someip_application_test, DISABLED_watchdog_handler) { + // TODO: need to somehow test this without these *HORRIBLE* sleeps! + std::atomic cb_count(0); auto wd_handler = [&]() { ++cb_count; }; diff --git a/test/network_tests/application_tests/application_test_globals.hpp b/test/network_tests/application_tests/application_test_globals.hpp index 3ebd108dc..8b2b81322 100644 --- a/test/network_tests/application_tests/application_test_globals.hpp +++ b/test/network_tests/application_tests/application_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef APPLICATION_TEST_GLOBALS_HPP_ -#define APPLICATION_TEST_GLOBALS_HPP_ +#pragma once namespace application_test { @@ -23,5 +22,3 @@ struct service_info service = {0x1111, 0x1, 0x1111, 0x1111, 0x1000, 0x1404, 0x2, static constexpr int number_of_messages_to_send = 150; } - -#endif /* APPLICATION_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/application_tests/conf/application_test_starter.sh.in b/test/network_tests/application_tests/conf/application_test_starter.sh.in index 563490835..2cd17b3e0 100755 --- a/test/network_tests/application_tests/conf/application_test_starter.sh.in +++ b/test/network_tests/application_tests/conf/application_test_starter.sh.in @@ -35,7 +35,7 @@ cat < #include @@ -64,5 +63,3 @@ class availability_handler_utils { }; } - -#endif /* AVAILABILITY_HANDLER_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/big_payload_tests/big_payload_test_client.hpp b/test/network_tests/big_payload_tests/big_payload_test_client.hpp index f02677b2f..fc9cd4322 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_client.hpp +++ b/test/network_tests/big_payload_tests/big_payload_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef BIGPAYLOADTESTCLIENT_HPP_ -#define BIGPAYLOADTESTCLIENT_HPP_ +#pragma once #include @@ -47,5 +46,3 @@ class big_payload_test_client { std::thread sender_; vsomeip::service_t service_id_; }; - -#endif /* BIGPAYLOADTESTCLIENT_HPP_ */ diff --git a/test/network_tests/big_payload_tests/big_payload_test_globals.hpp b/test/network_tests/big_payload_tests/big_payload_test_globals.hpp index 08dbc00e7..79bf3bcf1 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_globals.hpp +++ b/test/network_tests/big_payload_tests/big_payload_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef BIG_PAYLOAD_TEST_GLOBALS_HPP_ -#define BIG_PAYLOAD_TEST_GLOBALS_HPP_ +#pragma once #include @@ -16,7 +15,7 @@ constexpr vsomeip::byte_t DATA_SERVICE_TO_CLIENT = 0xAA; constexpr vsomeip::byte_t DATA_CLIENT_TO_SERVICE = 0xFF; constexpr std::uint32_t BIG_PAYLOAD_TEST_NUMBER_MESSAGES = 10; -constexpr std::uint32_t BIG_PAYLOAD_TEST_NUMBER_MESSAGES_RANDOM = 50; +constexpr std::uint32_t BIG_PAYLOAD_TEST_NUMBER_MESSAGES_RANDOM = 5; constexpr vsomeip::service_t TEST_SERVICE_SERVICE_ID = 0x1234; constexpr vsomeip::service_t TEST_SERVICE_SERVICE_ID_LIMITED = 0x1235; @@ -33,5 +32,3 @@ constexpr vsomeip::method_t STOP_METHOD = 0x0999; enum test_mode { RANDOM, LIMITED, LIMITED_GENERAL, QUEUE_LIMITED_GENERAL, QUEUE_LIMITED_SPECIFIC, UDP, UNKNOWN }; } - -#endif /* BIG_PAYLOAD_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/big_payload_tests/big_payload_test_service.hpp b/test/network_tests/big_payload_tests/big_payload_test_service.hpp index 73166f5be..616dc2b24 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_service.hpp +++ b/test/network_tests/big_payload_tests/big_payload_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef BIGPAYLOADTESTSERVICE_HPP_ -#define BIGPAYLOADTESTSERVICE_HPP_ +#pragma once #include #include @@ -47,5 +46,3 @@ class big_payload_test_service { vsomeip::service_t service_id_; std::queue> incoming_requests_; }; - -#endif /* BIGPAYLOADTESTSERVICE_HPP_ */ diff --git a/test/network_tests/cached_event_tests/conf/cached_event_test_client.sh.in b/test/network_tests/cached_event_tests/conf/cached_event_test_client.sh.in index 7d6860bf0..fb438f937 100755 --- a/test/network_tests/cached_event_tests/conf/cached_event_test_client.sh.in +++ b/test/network_tests/cached_event_tests/conf/cached_event_test_client.sh.in @@ -14,7 +14,7 @@ export VSOMEIP_CONFIGURATION=cached_event_test_client.json # Start the routing manager. export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & DAEMON_PID=$! # Start the test clients. diff --git a/test/network_tests/client_id_tests/CMakeLists.txt b/test/network_tests/client_id_tests/CMakeLists.txt index b4457c45a..f60b285f3 100644 --- a/test/network_tests/client_id_tests/CMakeLists.txt +++ b/test/network_tests/client_id_tests/CMakeLists.txt @@ -39,7 +39,7 @@ add_executable(client_id_test_utility # Link vsomeip configuration libraries. target_link_libraries(client_id_test_utility - ${VSOMEIP_NAME}-cfg + ${VSOMEIP_NAME}-cfg-test ) # Add build dependencies and link libraries to executables. diff --git a/test/network_tests/client_id_tests/client_id_test_globals.hpp b/test/network_tests/client_id_tests/client_id_test_globals.hpp index c0b43cd96..19e8d2c90 100644 --- a/test/network_tests/client_id_tests/client_id_test_globals.hpp +++ b/test/network_tests/client_id_tests/client_id_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef CLIENT_ID_TEST_CLIENT_ID_TEST_GLOBALS_HPP_ -#define CLIENT_ID_TEST_CLIENT_ID_TEST_GLOBALS_HPP_ +#pragma once namespace client_id_test { @@ -28,5 +27,3 @@ static constexpr std::array service_infos = {{// placeholder to static constexpr int messages_to_send = 10; } - -#endif /* CLIENT_ID_TEST_CLIENT_ID_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/conf/setup_test.sh.in b/test/network_tests/conf/setup_test.sh.in index 57e90841e..bfb10b161 100644 --- a/test/network_tests/conf/setup_test.sh.in +++ b/test/network_tests/conf/setup_test.sh.in @@ -1,5 +1,5 @@ #!/bin/bash -x -# Copyright (C) 2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. @@ -12,6 +12,10 @@ RELATIVE_DIR=$(realpath $0) # has to be $0, not $BASH_SOURCE, because we need th RELATIVE_DIR="test/${RELATIVE_DIR#*/test}" # prefix removal RELATIVE_DIR=$(dirname $RELATIVE_DIR) # suffix removal +# add common binaries to path +# bit of a strong assumption on the directory structure, but this is anyhow just to simplify tests +export PATH="$PATH:../../../examples/routingmanagerd:../../../examples/wait-until-available" + ####################################### ######### test setup helpers ########## ####################################### diff --git a/test/network_tests/configuration_tests/CMakeLists.txt b/test/network_tests/configuration_tests/CMakeLists.txt index 43948f770..78643e7df 100644 --- a/test/network_tests/configuration_tests/CMakeLists.txt +++ b/test/network_tests/configuration_tests/CMakeLists.txt @@ -18,7 +18,8 @@ add_executable(configuration_test # Link vsomeip configuration libraries. target_link_libraries(configuration_test - ${VSOMEIP_NAME}-cfg + ${VSOMEIP_NAME}-test + ${VSOMEIP_NAME}-cfg-test ) # Add build dependencies and link libraries to executable. diff --git a/test/network_tests/cpu_load_tests/CMakeLists.txt b/test/network_tests/cpu_load_tests/CMakeLists.txt index 420b017ce..e8fc89e13 100644 --- a/test/network_tests/cpu_load_tests/CMakeLists.txt +++ b/test/network_tests/cpu_load_tests/CMakeLists.txt @@ -36,11 +36,6 @@ set(executables targets_link_default_libraries("${executables}") targets_add_default_dependencies("${executables}") -# Skip valgrind -if (DEFINED VALGRIND_TYPE AND NOT VALGRIND_TYPE STREQUAL "") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --trace-children-skip=*/ssh) -endif() - add_custom_test( NAME cpu_load_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/cpu_load_test_master_starter.sh diff --git a/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_master_starter.sh.in b/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_master_starter.sh.in index 0ce1320fd..3a700cf92 100755 --- a/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_master_starter.sh.in +++ b/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_master_starter.sh.in @@ -15,7 +15,7 @@ export VSOMEIP_CONFIGURATION=service # Start the routing manager. export VSOMEIP_APPLICATION_NAME="service-daemon" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & DAEMON_PID=$! # Start the test service. diff --git a/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_slave_starter.sh.in b/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_slave_starter.sh.in index bba222052..1ffd0de03 100755 --- a/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_slave_starter.sh.in +++ b/test/network_tests/cyclic_event_tests/conf/cyclic_event_test_slave_starter.sh.in @@ -15,7 +15,7 @@ export VSOMEIP_CONFIGURATION=cyclic_event_test_client.json # Start the routing manager. export VSOMEIP_APPLICATION_NAME="client-daemon" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & DAEMON_PID=$! # Start the test client. diff --git a/test/network_tests/debounce_callback_tests/CMakeLists.txt b/test/network_tests/debounce_callback_tests/CMakeLists.txt deleted file mode 100644 index 4ded22604..000000000 --- a/test/network_tests/debounce_callback_tests/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -project(debounce_callback_tests LANGUAGES CXX) - -# Configure necessary files into the build directory. -set(configuration_files - debounce_callback_test_client.json - debounce_callback_test_master_starter.sh - debounce_callback_test_service.json - debounce_callback_test_slave_starter.sh -) -configure_files("${configuration_files}") - -# Add test executable. -add_executable(debounce_callback_test_client - debounce_callback_test_client.cpp -) - -# Add test executable. -add_executable(debounce_callback_test_service - debounce_callback_test_service.cpp -) - -# Add build dependencies and link libraries to executables. -set(executables - debounce_callback_test_client - debounce_callback_test_service -) -targets_link_default_libraries("${executables}") -targets_add_default_dependencies("${executables}") - -# Add custom test command. -add_custom_test( - NAME debounce_callback_test - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/debounce_callback_test_master_starter.sh -) diff --git a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_client.json.in b/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_client.json.in deleted file mode 100644 index 93122f766..000000000 --- a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_client.json.in +++ /dev/null @@ -1,42 +0,0 @@ -{ - "unicast" : "@TEST_IP_MASTER@", - "logging": { - "level": "trace", - "console": "true" - }, - "tracing" : - { - "enable" : "true" - }, - "debounce" : - [ - { - "service" : "0xb657", - "instance" : "0x0003", - "events" : - [ - { - "event" : "0x8001", - "on_change" : "false", - "interval": 2000, - "send_current_value_after" : "true" - }, - { - "event" : "0x8002", - "on_change" : "false", - "interval": 3000, - "send_current_value_after" : "true" - } - ] - } - ], - "routing": "routingmanagerd", - "service-discovery" : - { - "enable" : "true", - "multicast" : "224.251.192.252", - "port" : "30490", - "protocol" : "udp", - "cyclic_offer_delay" : "1000" - } -} diff --git a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_master_starter.sh.in b/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_master_starter.sh.in index e373d5aca..7e4e76f4a 100755 --- a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_master_starter.sh.in +++ b/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_master_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_APPLICATION_NAME="client-routingmanagerd" export VSOMEIP_CONFIGURATION=debounce_callback_test_client.json -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="client-sample" diff --git a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_service.json.in b/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_service.json.in deleted file mode 100644 index 597c6f5a8..000000000 --- a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_service.json.in +++ /dev/null @@ -1,28 +0,0 @@ -{ - "unicast" : "@TEST_IP_SLAVE@", - "logging": { - "level": "trace", - "console": "true" - }, - "tracing" : - { - "enable" : "true" - }, - "services" : - [ - { - "service" : "0xb657", - "instance" : "0x0003", - "unreliable" : "30503" - } - ], - "routing": "routingmanagerd", - "service-discovery" : - { - "enable" : "true", - "multicast" : "224.251.192.252", - "port" : "30490", - "protocol" : "udp", - "cyclic_offer_delay" : "1000" - } -} diff --git a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_slave_starter.sh.in b/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_slave_starter.sh.in index 21c121114..db0602a99 100755 --- a/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_slave_starter.sh.in +++ b/test/network_tests/debounce_callback_tests/conf/debounce_callback_test_slave_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_APPLICATION_NAME="service-routingmanagerd" export VSOMEIP_CONFIGURATION=debounce_callback_test_service.json -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="service-sample" diff --git a/test/network_tests/debounce_callback_tests/debounce_callback_test.md b/test/network_tests/debounce_callback_tests/debounce_callback_test.md deleted file mode 100644 index 617857a38..000000000 --- a/test/network_tests/debounce_callback_tests/debounce_callback_test.md +++ /dev/null @@ -1,37 +0,0 @@ -# Debounce_callback_test - -This test assures that the debounce timers are respected and that the last message sent during debounce time is received after the timeout. - -There is 1 service with 2 events being offered by a service-provider that are being consumed by another application, service-consumer. - -## Purpose - - - Assure that debounce times are respected. - - ASsure that last message sent during debounce time is received by the service-consumer. - -## Test Logic - -### Service provider - -The service provider will initially offer one service with 2 different events, and wait for a request from service-consumer for the DEBOUNCE_START_METHOD to actually start sending notifications. - -There are 5 scenarios covered here: - - Send 2 notifications with a second in between to make sure that both are received. - - Send 2 notifications with 3 seconds in between to make sure that both are received. - - Send 3 notifications with 0.5 seconds in between to make sure that only the 1st and last are received. - - Send 6 notifications in pairs (different events) with 0.5 seconds in between to make sure that the 1st and last pair of notifications are received. - - Send 30 pairs of notifications (differet events) with 0.05 seconds in between to make sure that only the 1st and last pair are received. - -Finally wait for another request from service-consumer for DEBOUNCE_STOP_METHOD to end operations. - -![Diagram](docs/debounce_callback_test_service.png) - -### Service consumer - -The service consumer will initially set the expected payloads then request and subscribe to the service offered by service-consumer, after which will send a request for DEBOUNCE_START_METHOD to start the notification sending from service-provider. - -For each message received it will compare to each previously set payload to make sure that the order and number of messages are correct. - -Finally send another request for DEBOUNCE_STOP_METHOD to trigger service provider stop. - -![Diagram](docs/debounce_callback_test_client.png) diff --git a/test/network_tests/debounce_callback_tests/debounce_callback_test_client.cpp b/test/network_tests/debounce_callback_tests/debounce_callback_test_client.cpp deleted file mode 100644 index a0cf2f611..000000000 --- a/test/network_tests/debounce_callback_tests/debounce_callback_test_client.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include -#include - -#include - -#include "debounce_callback_test_client.hpp" -#include "common/timeout_detector.hpp" - -static std::vector> payloads__; - -debounce_test_client::debounce_test_client(int64_t _interval) : - interval(_interval), index_(0), is_available_(false), messagesReceived_(false), runner_(std::bind(&debounce_test_client::run, this)), - app_(vsomeip::runtime::get()->create_application("debounce_timeout_test_client")) { } - -bool debounce_test_client::init() { - - bool its_result = app_->init(); - if (its_result) { - app_->register_availability_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, - std::bind(&debounce_test_client::on_availability, this, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3), - DEBOUNCE_MAJOR, DEBOUNCE_MINOR); - app_->register_message_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, vsomeip::ANY_EVENT, - std::bind(&debounce_test_client::on_message, this, std::placeholders::_1)); - app_->request_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, {DEBOUNCE_EVENTGROUP}, vsomeip::event_type_e::ET_FIELD, - vsomeip::reliability_type_e::RT_UNRELIABLE); - app_->request_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, {DEBOUNCE_EVENTGROUP}, vsomeip::event_type_e::ET_FIELD, - vsomeip::reliability_type_e::RT_UNRELIABLE); - app_->request_service(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_MAJOR, DEBOUNCE_MINOR); - app_->subscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENTGROUP, DEBOUNCE_MAJOR, DEBOUNCE_EVENT); - app_->subscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENTGROUP, DEBOUNCE_MAJOR, DEBOUNCE_EVENT_2); - } - return its_result; -} - -void debounce_test_client::start() { - - VSOMEIP_INFO << "Starting Client..."; - app_->start(); -} - -void debounce_test_client::stop() { - - VSOMEIP_INFO << "Stopping Client..."; - app_->stop(); -} - -void debounce_test_client::run() { - - { - std::unique_lock its_lock(run_mutex_); - auto availability_timeout = interval > 0 ? std::chrono::milliseconds(interval * 2) : std::chrono::seconds(20); - if (!run_condition_.wait_for(its_lock, availability_timeout, [this] { return is_available_; })) { - GTEST_FATAL_FAILURE_("Debounce service did not become available before timeout."); - stop(); - return; - } - } - - VSOMEIP_INFO << __func__ << ": Running test."; - run_test(); - - unsubscribe_all(); - - VSOMEIP_INFO << __func__ << ": Stopping the service."; - stop_service(); - - // magic sleep to give time for the last message to be sent - // TODO: FIXME! REMOVE THIS! - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - - stop(); -} - -void debounce_test_client::wait() { - - if (runner_.joinable()) - runner_.join(); -} - -void debounce_test_client::on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { - - if (_service == DEBOUNCE_SERVICE && _instance == DEBOUNCE_INSTANCE) { - - if (_is_available) { - VSOMEIP_INFO << __func__ << ": Debounce service becomes available."; - { - std::scoped_lock its_lock(run_mutex_); - is_available_ = true; - } - run_condition_.notify_one(); - } else { - VSOMEIP_ERROR << __func__ << ": Debounce service becomes unavailable."; - - std::scoped_lock its_lock(run_mutex_); - is_available_ = false; - } - } -} - -void debounce_test_client::on_message(const std::shared_ptr& _message) { - - std::stringstream s; - s << "RECV: "; - for (uint32_t i = 0; i < _message->get_payload()->get_length(); i++) { - s << std::hex << std::setfill('0') << std::setw(2) << static_cast(_message->get_payload()->get_data()[i]) << ' '; - } - VSOMEIP_DEBUG << s.str(); - - // Check if message received is equal to the one it was expecting - if (DEBOUNCE_SERVICE == _message->get_service() - && (DEBOUNCE_EVENT == _message->get_method() || DEBOUNCE_EVENT_2 == _message->get_method())) { - bool is_equal = compare_payload(_message->get_payload(), index_++); - EXPECT_EQ(is_equal, true); - - if (index_ == payloads__.size()) { - std::scoped_lock its_lock(run_mutex_); - messagesReceived_ = true; - run_condition_.notify_one(); - } - } -} - -bool debounce_test_client::compare_payload(const std::shared_ptr& _payload, std::size_t _index) const { - auto its_expected_payload = payloads__[_index]; - return _payload->operator==(*its_expected_payload); -} - -void debounce_test_client::run_test() { - - // Trigger the test - auto its_runtime = vsomeip::runtime::get(); - auto its_payload = its_runtime->create_payload(); - auto its_message = its_runtime->create_request(false); - its_message->set_service(DEBOUNCE_SERVICE); - its_message->set_instance(DEBOUNCE_INSTANCE); - its_message->set_method(DEBOUNCE_START_METHOD); - its_message->set_interface_version(DEBOUNCE_MAJOR); - its_message->set_message_type(vsomeip::message_type_e::MT_REQUEST_NO_RETURN); - its_message->set_payload(its_payload); - app_->send(its_message); - - std::unique_lock lock(run_mutex_); - auto expected_messages = static_cast(payloads__.size()); - auto wait_budget = - interval > 0 ? std::chrono::milliseconds(interval * static_cast(expected_messages)) : std::chrono::seconds(30); - if (!run_condition_.wait_for(lock, wait_budget, [&] { return messagesReceived_; })) { - VSOMEIP_ERROR << "debounce_test_client::on_message: Timeout waiting for messages"; - } -} - -void debounce_test_client::unsubscribe_all() { - - app_->unsubscribe(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENTGROUP); -} - -void debounce_test_client::stop_service() { - - auto its_runtime = vsomeip::runtime::get(); - auto its_payload = its_runtime->create_payload(); - auto its_message = its_runtime->create_request(false); - its_message->set_service(DEBOUNCE_SERVICE); - its_message->set_instance(DEBOUNCE_INSTANCE); - its_message->set_method(DEBOUNCE_STOP_METHOD); - its_message->set_interface_version(DEBOUNCE_MAJOR); - its_message->set_message_type(vsomeip::message_type_e::MT_REQUEST_NO_RETURN); - its_message->set_payload(its_payload); - app_->send(its_message); -} - -size_t debounce_test_client::getIndex() { - return index_; -} - -TEST(debounce_timeout_test, callback) { - // Interval time of 2 seconds - debounce_test_client its_client(2000); - ASSERT_TRUE(its_client.init()); - VSOMEIP_INFO << "Debounce Client successfully initialized!"; - its_client.start(); - its_client.wait(); - - // Check it got all messages - EXPECT_EQ(its_client.getIndex(), payloads__.size()); -} -int main(int argc, char** argv) { - timeout_detector td; - std::shared_ptr its_payload; - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0D}); - payloads__.push_back(its_payload); - - its_payload = vsomeip::runtime::get()->create_payload(); - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0D}); - payloads__.push_back(its_payload); - - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/network_tests/debounce_callback_tests/debounce_callback_test_client.hpp b/test/network_tests/debounce_callback_tests/debounce_callback_test_client.hpp index 21e9951dc..a76fd4b5e 100644 --- a/test/network_tests/debounce_callback_tests/debounce_callback_test_client.hpp +++ b/test/network_tests/debounce_callback_tests/debounce_callback_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_CLIENT_HPP_ -#define DEBOUNCE_TEST_CLIENT_HPP_ +#pragma once #include #include @@ -55,5 +54,3 @@ class debounce_test_client { std::thread runner_; std::shared_ptr app_; }; - -#endif // DEBOUNCE_CALLBACK_TEST_CLIENT_HPP_ diff --git a/test/network_tests/debounce_callback_tests/debounce_callback_test_common.hpp b/test/network_tests/debounce_callback_tests/debounce_callback_test_common.hpp index 75561f3c4..5b4746e2d 100644 --- a/test/network_tests/debounce_callback_tests/debounce_callback_test_common.hpp +++ b/test/network_tests/debounce_callback_tests/debounce_callback_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_COMMON_HPP_ -#define DEBOUNCE_TEST_COMMON_HPP_ +#pragma once #include @@ -17,5 +16,3 @@ const vsomeip::event_t DEBOUNCE_EVENT_2 = 0x8002; const vsomeip::eventgroup_t DEBOUNCE_EVENTGROUP = 0x0005; const vsomeip::major_version_t DEBOUNCE_MAJOR = 0x01; const vsomeip::minor_version_t DEBOUNCE_MINOR = 0x01; - -#endif // DEBOUNCE_CALLBACK_TEST_COMMON_HPP_ diff --git a/test/network_tests/debounce_callback_tests/debounce_callback_test_service.cpp b/test/network_tests/debounce_callback_tests/debounce_callback_test_service.cpp deleted file mode 100644 index 8e45601e2..000000000 --- a/test/network_tests/debounce_callback_tests/debounce_callback_test_service.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include "debounce_callback_test_service.hpp" -#include "common/timeout_detector.hpp" - -debounce_test_service::debounce_test_service() : - runner_(std::bind(&debounce_test_service::run, this)), - app_(vsomeip::runtime::get()->create_application("debounce_timeout_test_service")) { } - -bool debounce_test_service::init() { - - bool is_initialized = app_->init(); - if (is_initialized) { - app_->register_message_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_START_METHOD, - std::bind(&debounce_test_service::on_start, this, std::placeholders::_1)); - app_->register_message_handler(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_STOP_METHOD, - std::bind(&debounce_test_service::on_stop, this, std::placeholders::_1)); - app_->offer_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, {DEBOUNCE_EVENTGROUP}, vsomeip::event_type_e::ET_FIELD, - std::chrono::milliseconds::zero(), false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); - app_->offer_event(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, {DEBOUNCE_EVENTGROUP}, vsomeip::event_type_e::ET_FIELD, - std::chrono::milliseconds::zero(), false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); - app_->offer_service(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_MAJOR, DEBOUNCE_MINOR); - } - return is_initialized; -} - -void debounce_test_service::start() { - - VSOMEIP_INFO << "Starting Service..."; - app_->start(); -} - -void debounce_test_service::stop() { - - VSOMEIP_INFO << "Stopping Service..."; - app_->stop(); -} - -void debounce_test_service::run() { - - { - std::unique_lock its_lock(run_mutex_); - auto its_result = run_condition_.wait_for(its_lock, std::chrono::seconds(10)); - if (its_result == std::cv_status::timeout) - return; - } - - start_test(); -} - -void debounce_test_service::wait() { - - if (runner_.joinable()) - runner_.join(); -} - -void debounce_test_service::on_start(const std::shared_ptr& _message) { - - (void)_message; - - VSOMEIP_INFO << __func__ << ": Starting test"; - run_condition_.notify_one(); -} - -void debounce_test_service::on_stop(const std::shared_ptr& _message) { - - (void)_message; - - VSOMEIP_INFO << __func__ << ": Received a STOP command."; - stop(); -} - -void debounce_test_service::start_test() { - - auto its_payload = vsomeip::runtime::get()->create_payload(); - - // To check if debouncer send the last message after timeout - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent first message!"; - std::this_thread::sleep_for(std::chrono::seconds(1)); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent second message!"; - - std::this_thread::sleep_for(std::chrono::seconds(3)); - - // To check normal function of the debouncer - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent third message!"; - std::this_thread::sleep_for(std::chrono::seconds(3)); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent fourth message!"; - - std::this_thread::sleep_for(std::chrono::seconds(3)); - - // To check only one message is forwarded after timeout - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent fifth message!"; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent sixth message!"; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent seventh message!"; - - std::this_thread::sleep_for(std::chrono::seconds(3)); - - // To check the interaction when two events use the debounce - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent eight message!"; - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, its_payload); - VSOMEIP_INFO << "Sent first event 2 message!"; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent ninth message!"; - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, its_payload); - VSOMEIP_INFO << "Sent second event 2 message!"; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - its_payload->set_data({0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - VSOMEIP_INFO << "Sent tenth message!"; - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, its_payload); - VSOMEIP_INFO << "Sent third event 2 message!"; - - std::this_thread::sleep_for(std::chrono::seconds(3)); - - // Testing with lots of messages - - VSOMEIP_INFO << "Sending lot of messages!"; - for (int i = 0; i < 30; i++) { - its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, (unsigned char)(i % 16)}); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); - app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT_2, its_payload); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } -} - -TEST(debounce_timeout_test, callback) { - debounce_test_service its_service; - ASSERT_TRUE(its_service.init()); - its_service.start(); - its_service.wait(); -} - -int main(int argc, char** argv) { - timeout_detector td; - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/network_tests/debounce_callback_tests/debounce_callback_test_service.hpp b/test/network_tests/debounce_callback_tests/debounce_callback_test_service.hpp index 6f4c627ae..3216e56bb 100644 --- a/test/network_tests/debounce_callback_tests/debounce_callback_test_service.hpp +++ b/test/network_tests/debounce_callback_tests/debounce_callback_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_SERVICE_HPP_ -#define DEBOUNCE_TEST_SERVICE_HPP_ +#pragma once #include #include @@ -40,5 +39,3 @@ class debounce_test_service { std::thread runner_; std::shared_ptr app_; }; - -#endif // DEBOUNCE_CALLBACK_TEST_SERVICE_HPP_ diff --git a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_client.png b/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_client.png deleted file mode 100644 index 6c73bd82c..000000000 Binary files a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_client.png and /dev/null differ diff --git a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_client.puml b/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_client.puml deleted file mode 100644 index 509491515..000000000 --- a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_client.puml +++ /dev/null @@ -1,35 +0,0 @@ -@startuml - -Actor service_consumer as SC - -participant routing_manager as RM - -SC -> RM : REQUEST - -RM --\ SC : ON_AVAILABLE - -SC -> RM : SUBSCRIBE - -RM --\ SC : SUBSCRIBE ACK - -SC -> RM : REQUEST DEBOUNCE_START_METHOD - -loop for every notification from service_provider - -RM --\ SC : notification - -SC -> SC : compare received payload to expected - -alt if client received all responses - - SC -> SC : trigger stop - -end - -SC -> RM : UNSUBSCRIBE - -SC -> RM : REQUEST DEBOUNCE_STOP_METHOD - -end - -@enduml diff --git a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_service.png b/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_service.png deleted file mode 100644 index 7f947d558..000000000 Binary files a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_service.png and /dev/null differ diff --git a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_service.puml b/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_service.puml deleted file mode 100644 index c10b5c361..000000000 --- a/test/network_tests/debounce_callback_tests/docs/debounce_callback_test_service.puml +++ /dev/null @@ -1,75 +0,0 @@ -@startuml - -Actor service_provider as SP - -participant routingmanager as RM - -SP -> RM : OFFER - -note over SP - wait for DEBOUNCE_START_METHOD request -end note - -RM --\ SP : REQUEST DEBOUNCE_START_METHOD - -note across - To check if debouncer send the last message after timeout -end note -SP -> RM : Send notification -SP -> SP : sleep 1 second -SP -> RM : Send notification - -SP -> SP : sleep 3 seconds - -note across - To check normal function of the debouncer -end note -SP -> RM : Send notification -SP -> SP : sleep 3 seconds -SP -> RM : Send notification - -SP -> SP : sleep 3 seconds - -note across - To check only one message is forwarded after timeout -end note -SP -> RM : Send notification -SP -> SP : sleep 0.5 seconds -SP -> RM : Send notification -SP -> SP : sleep 0.5 seconds -SP -> RM : Send notification - -SP -> SP : sleep 3 seconds - -note across - To check the interaction when two events use the debounce -end note -SP -> RM : Send notification event 1 -SP -> RM : Send notification event 2 -SP -> SP : sleep 0.5 seconds -SP -> RM : Send notification event 1 -SP -> RM : Send notification event 2 -SP -> SP : sleep 0.5 seconds -SP -> RM : Send notification event 1 -SP -> RM : Send notification event 2 - -SP -> SP : sleep 3 seconds - -note across - Testing with lots of messages -end note - -loop 30 times - -SP -> RM : Send notification event 1 -SP -> RM : Send notification event 2 -SP -> SP : sleep 0.05 seconds -end - -note over SP - wait for DEBOUNCE_STOP_METHOD request -end note - -RM --\ SP : REQUEST DEBOUNCE_STOP_METHOD - -@enduml diff --git a/test/network_tests/debounce_epsilon_tests/conf/debounce_epsilon_test_service.sh.in b/test/network_tests/debounce_epsilon_tests/conf/debounce_epsilon_test_service.sh.in index b27324302..66d96600a 100755 --- a/test/network_tests/debounce_epsilon_tests/conf/debounce_epsilon_test_service.sh.in +++ b/test/network_tests/debounce_epsilon_tests/conf/debounce_epsilon_test_service.sh.in @@ -26,7 +26,7 @@ function main() { # Start the routing host. export VSOMEIP_APPLICATION_NAME=routingmanagerd - ../../../examples/routingmanagerd/routingmanagerd & + routingmanagerd & host_pid="$!" echo -e "$SCRIPT: Starting test service." diff --git a/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_master_starter.sh.in b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_master_starter.sh.in index 40a136d34..97b14b6e9 100755 --- a/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_master_starter.sh.in +++ b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_master_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_APPLICATION_NAME="client-routingmanagerd" export VSOMEIP_CONFIGURATION=debounce_filter_test_client.json -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="client-sample" diff --git a/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_slave_starter.sh.in b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_slave_starter.sh.in index 474d5bd19..2d897b9e0 100755 --- a/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_slave_starter.sh.in +++ b/test/network_tests/debounce_filter_tests/conf/debounce_filter_test_slave_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_APPLICATION_NAME="service-routingmanagerd" export VSOMEIP_CONFIGURATION=debounce_filter_test_service.json -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="service-sample" diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp index 95564daab..3d4779855 100644 --- a/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.cpp @@ -137,7 +137,15 @@ void debounce_test_client::run_test() { its_message->set_payload(its_payload); app_->send(its_message); - std::this_thread::sleep_for(std::chrono::seconds(15)); + if (interval > 0) { + // wait until we receive enough messages + while (nb_msgs_rcvd.load() < 5) { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + } else { + // wait.. a while, to see that nothing appears + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } } void debounce_test_client::unsubscribe_all() { @@ -172,9 +180,9 @@ TEST(debounce_test, normal_interval) { its_client.start(); its_client.wait(); - // Average Interval should be between 95ms and 105ms - EXPECT_GE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_1 - 5); - EXPECT_LE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_1 + 5); + // Average Interval should be between 30ms and 70ms + EXPECT_GE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_1 - 20); + EXPECT_LE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_1 + 20); } TEST(debounce_test, large_interval) { @@ -184,9 +192,9 @@ TEST(debounce_test, large_interval) { its_client.start(); its_client.wait(); - // Average Interval should be between 995ms and 1005ms - EXPECT_GE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_2 - 5); - EXPECT_LE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_2 + 5); + // Average Interval should be between 280ms and 320ms + EXPECT_GE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_2 - 20); + EXPECT_LE(its_client.get_avgtime().count(), (double)DEBOUNCE_INTERVAL_2 + 20); } TEST(debounce_test, disable) { diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp index 1a35766b4..2fd1e6ecd 100644 --- a/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_CLIENT_HPP_ -#define DEBOUNCE_TEST_CLIENT_HPP_ +#pragma once #include #include @@ -51,10 +50,8 @@ class debounce_test_client { vsomeip::debounce_filter_t dBFilter; - int64_t nb_msgs_rcvd = 0; + std::atomic nb_msgs_rcvd{0}; std::chrono::milliseconds sum_time; std::chrono::time_point time_start; std::chrono::time_point time_last; }; - -#endif // DEBOUNCE_TEST_CLIENT_HPP_ diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp index 2afba1c39..c5e1dddf1 100644 --- a/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_COMMON_HPP_ -#define DEBOUNCE_TEST_COMMON_HPP_ +#pragma once #include @@ -17,8 +16,6 @@ const vsomeip::eventgroup_t DEBOUNCE_EVENTGROUP = 0x0005; const vsomeip::major_version_t DEBOUNCE_MAJOR = 0x01; const vsomeip::minor_version_t DEBOUNCE_MINOR = 0x01; -const int64_t DEBOUNCE_INTERVAL_1 = 100; -const int64_t DEBOUNCE_INTERVAL_2 = 1000; +const int64_t DEBOUNCE_INTERVAL_1 = 50; +const int64_t DEBOUNCE_INTERVAL_2 = 300; const int64_t DEBOUNCE_INTERVAL_3 = -1; - -#endif // DEBOUNCE_TEST_COMMON_HPP_ diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_service.cpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_service.cpp index d875dabba..8b23a18b2 100644 --- a/test/network_tests/debounce_filter_tests/debounce_filter_test_service.cpp +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_service.cpp @@ -67,7 +67,7 @@ void debounce_test_service::start_test() { auto its_payload = vsomeip::runtime::get()->create_payload(); auto wakeup_time = std::chrono::steady_clock::now(); - for (int i = 0; i <= 1000; i++) { + while (is_running_.load()) { its_payload->set_data({0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); app_->notify(DEBOUNCE_SERVICE, DEBOUNCE_INSTANCE, DEBOUNCE_EVENT, its_payload); wakeup_time += std::chrono::milliseconds(5); diff --git a/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp b/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp index 9e8ca3644..b695825ad 100644 --- a/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp +++ b/test/network_tests/debounce_filter_tests/debounce_filter_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_SERVICE_HPP_ -#define DEBOUNCE_TEST_SERVICE_HPP_ +#pragma once #include #include @@ -41,5 +40,3 @@ class debounce_test_service { std::thread runner_; std::shared_ptr app_; }; - -#endif // DEBOUNCE_TEST_SERVICE_HPP_ diff --git a/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_master_starter.sh.in b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_master_starter.sh.in index e361765ba..1820c251a 100755 --- a/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_master_starter.sh.in +++ b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_master_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=debounce_frequency_test_client.json export VSOMEIP_APPLICATION_NAME=client-routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=client-sample diff --git a/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_slave_starter.sh.in b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_slave_starter.sh.in index 298ee30b8..ebea7bc97 100755 --- a/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_slave_starter.sh.in +++ b/test/network_tests/debounce_frequency_tests/conf/debounce_frequency_test_slave_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=debounce_frequency_test_service.json export VSOMEIP_APPLICATION_NAME=service-routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=service-sample diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp index d35d9ad95..a9ff4c6c2 100644 --- a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_FREQUENCY_TEST_CLIENT_HPP_ -#define DEBOUNCE_FREQUENCY_TEST_CLIENT_HPP_ +#pragma once #include #include @@ -41,5 +40,3 @@ class test_client : public vsomeip_utilities::base_vsip_app { void send_request(); ~test_client(); }; - -#endif // DEBOUNCE_FREQUENCY_TEST_CLIENT_HPP_ diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp index 984358705..a3994a806 100644 --- a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_FREQUENCY_TEST_COMMON_HPP_ -#define DEBOUNCE_FREQUENCY_TEST_COMMON_HPP_ +#pragma once #include @@ -21,5 +20,3 @@ const vsomeip::minor_version_t DEBOUNCE_MINOR = 0x01; enum debounce_frequency_test_id_e : uint8_t { DTI_FLAT = 0x00, }; - -#endif // DEBOUNCE_FREQUENCY_TEST_COMMON_HPP_ diff --git a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp index 64df03c64..90add3305 100644 --- a/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp +++ b/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_FREQUENCY_TEST_SERVICE_HPP_ -#define DEBOUNCE_FREQUENCY_TEST_SERVICE_HPP_ +#pragma once #include #include @@ -37,5 +36,3 @@ class test_service : public vsomeip_utilities::base_vsip_app { bool was_event_1_sent(); bool was_event_2_sent(); }; - -#endif // debounce_frequency_test_SERVICE_HPP_ diff --git a/test/network_tests/debounce_tests/conf/debounce_test_master_starter.sh.in b/test/network_tests/debounce_tests/conf/debounce_test_master_starter.sh.in index 7d9095048..df9dc8de9 100755 --- a/test/network_tests/debounce_tests/conf/debounce_test_master_starter.sh.in +++ b/test/network_tests/debounce_tests/conf/debounce_test_master_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=debounce_test_client.json export VSOMEIP_APPLICATION_NAME=client-routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=client-sample diff --git a/test/network_tests/debounce_tests/conf/debounce_test_slave_starter.sh.in b/test/network_tests/debounce_tests/conf/debounce_test_slave_starter.sh.in index 5682dd365..83d774dba 100755 --- a/test/network_tests/debounce_tests/conf/debounce_test_slave_starter.sh.in +++ b/test/network_tests/debounce_tests/conf/debounce_test_slave_starter.sh.in @@ -13,7 +13,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=debounce_test_service.json export VSOMEIP_APPLICATION_NAME=service-routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=service-sample diff --git a/test/network_tests/debounce_tests/debounce_test_client.hpp b/test/network_tests/debounce_tests/debounce_test_client.hpp index dd33420f4..695dcdfdf 100644 --- a/test/network_tests/debounce_tests/debounce_test_client.hpp +++ b/test/network_tests/debounce_tests/debounce_test_client.hpp @@ -2,8 +2,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_CLIENT_HPP_ -#define DEBOUNCE_TEST_CLIENT_HPP_ +#pragma once #include #include @@ -48,5 +47,3 @@ class debounce_test_client { std::thread runner_; std::shared_ptr app_; }; - -#endif // DEBOUNCE_TEST_CLIENT_HPP_ diff --git a/test/network_tests/debounce_tests/debounce_test_common.hpp b/test/network_tests/debounce_tests/debounce_test_common.hpp index 2d9edd922..b3ec343f1 100644 --- a/test/network_tests/debounce_tests/debounce_test_common.hpp +++ b/test/network_tests/debounce_tests/debounce_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_COMMON_HPP_ -#define DEBOUNCE_TEST_COMMON_HPP_ +#pragma once #include @@ -20,5 +19,3 @@ const vsomeip::major_version_t DEBOUNCE_MAJOR = 0x01; const vsomeip::minor_version_t DEBOUNCE_MINOR = 0x01; enum debounce_test_id_e : uint8_t { DTI_FLAT = 0x00, DTI_INCREASE = 0x01, DTI_DECREASE = 0x02, DTI_MASK = 0x03 }; - -#endif // DEBOUNCE_TEST_COMMON_HPP_ diff --git a/test/network_tests/debounce_tests/debounce_test_service.hpp b/test/network_tests/debounce_tests/debounce_test_service.hpp index b724ad966..9d98333ee 100644 --- a/test/network_tests/debounce_tests/debounce_test_service.hpp +++ b/test/network_tests/debounce_tests/debounce_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef DEBOUNCE_TEST_SERVICE_HPP_ -#define DEBOUNCE_TEST_SERVICE_HPP_ +#pragma once #include #include @@ -43,5 +42,3 @@ class debounce_test_service { std::thread runner_; std::shared_ptr app_; }; - -#endif // DEBOUNCE_TEST_SERVICE_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_client.hpp b/test/network_tests/e2e_tests/e2e_profile_04_test_client.hpp index 1ada8f03a..8535545fb 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_client.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_PROFILE_04_TEST_CLIENT_HPP_ -#define E2E_PROFILE_04_TEST_CLIENT_HPP_ +#pragma once #include @@ -43,5 +42,3 @@ class e2e_profile_04_test_client { std::atomic received_; }; - -#endif // E2E_PROFILE_04_TEST_CLIENT_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_common.hpp b/test/network_tests/e2e_tests/e2e_profile_04_test_common.hpp index fda3df52a..8ec2f5986 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_common.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_PROFILE_04_TEST_COMMON_HPP_ -#define E2E_PROFILE_04_TEST_COMMON_HPP_ +#pragma once #include @@ -20,5 +19,3 @@ const vsomeip::eventgroup_t PROFILE_04_EVENTGROUP = 0x0001; const vsomeip::event_t PROFILE_04_EVENT = 0x8001; #define PROFILE_O4_NUM_MESSAGES 3 - -#endif // E2E_PROFILE_04_TEST_COMMON_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp b/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp index 7fac896a5..0e0746b0d 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_PROFILE_04_TEST_SERVICE_HPP_ -#define E2E_PROFILE_04_TEST_SERVICE_HPP_ +#pragma once #include @@ -45,5 +44,3 @@ class e2e_profile_04_test_service { std::atomic received_; }; - -#endif // E2E_PROFILE_04_TEST_SERVICE_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_profile_07_test_client.hpp b/test/network_tests/e2e_tests/e2e_profile_07_test_client.hpp index 1684b1269..830211aec 100644 --- a/test/network_tests/e2e_tests/e2e_profile_07_test_client.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_07_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_PROFILE_07_TEST_CLIENT_HPP_ -#define E2E_PROFILE_07_TEST_CLIENT_HPP_ +#pragma once #include @@ -43,5 +42,3 @@ class e2e_profile_07_test_client { std::atomic received_; }; - -#endif // E2E_PROFILE_07_TEST_CLIENT_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_profile_07_test_common.hpp b/test/network_tests/e2e_tests/e2e_profile_07_test_common.hpp index 42edceb51..85652b655 100644 --- a/test/network_tests/e2e_tests/e2e_profile_07_test_common.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_07_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_PROFILE_07_TEST_COMMON_HPP_ -#define E2E_PROFILE_07_TEST_COMMON_HPP_ +#pragma once #include @@ -20,5 +19,3 @@ const vsomeip::eventgroup_t PROFILE_07_EVENTGROUP = 0x0001; const vsomeip::event_t PROFILE_07_EVENT = 0x8001; #define PROFILE_07_NUM_MESSAGES 3 - -#endif // E2E_PROFILE_07_TEST_COMMON_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_profile_07_test_service.hpp b/test/network_tests/e2e_tests/e2e_profile_07_test_service.hpp index 916dd5081..cf49e697d 100644 --- a/test/network_tests/e2e_tests/e2e_profile_07_test_service.hpp +++ b/test/network_tests/e2e_tests/e2e_profile_07_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_PROFILE_07_TEST_SERVICE_HPP_ -#define E2E_PROFILE_07_TEST_SERVICE_HPP_ +#pragma once #include @@ -45,5 +44,3 @@ class e2e_profile_07_test_service { std::atomic received_; }; - -#endif // E2E_PROFILE_07_TEST_SERVICE_HPP_ diff --git a/test/network_tests/e2e_tests/e2e_test_client.hpp b/test/network_tests/e2e_tests/e2e_test_client.hpp index 11c7e32f3..9044b9c7e 100644 --- a/test/network_tests/e2e_tests/e2e_test_client.hpp +++ b/test/network_tests/e2e_tests/e2e_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef E2E_TEST_CLIENT_HPP -#define E2E_TEST_CLIENT_HPP +#pragma once #include @@ -46,5 +45,3 @@ class e2e_test_client { std::atomic received_responses_; std::atomic received_allowed_events_; }; - -#endif // E2E_TEST_CLIENT_HPP diff --git a/test/network_tests/e2e_tests/e2e_test_service.hpp b/test/network_tests/e2e_tests/e2e_test_service.hpp index 9cc96a6aa..dc2e10f30 100644 --- a/test/network_tests/e2e_tests/e2e_test_service.hpp +++ b/test/network_tests/e2e_tests/e2e_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef e2e_test_SERVICE_HPP -#define e2e_test_SERVICE_HPP +#pragma once #include @@ -41,5 +40,3 @@ class e2e_test_service { std::uint32_t number_of_received_messages_; std::thread offer_thread_; }; - -#endif // E2E_TEST_SERVICE_HPP diff --git a/test/network_tests/event_tests/conf/event_test_master_starter.sh.in b/test/network_tests/event_tests/conf/event_test_master_starter.sh.in index ae9275f8a..04255259f 100755 --- a/test/network_tests/event_tests/conf/event_test_master_starter.sh.in +++ b/test/network_tests/event_tests/conf/event_test_master_starter.sh.in @@ -24,7 +24,7 @@ COMMUNICATIONMODE=$2 export VSOMEIP_CONFIGURATION=event_test_master.json export VSOMEIP_APPLICATION_NAME="client-routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="client-sample" diff --git a/test/network_tests/event_tests/conf/event_test_slave_starter.sh.in b/test/network_tests/event_tests/conf/event_test_slave_starter.sh.in index dda9bfba9..1ed9d42af 100755 --- a/test/network_tests/event_tests/conf/event_test_slave_starter.sh.in +++ b/test/network_tests/event_tests/conf/event_test_slave_starter.sh.in @@ -27,7 +27,7 @@ elif [ "$COMMUNICATIONMODE" = "UDP" ]; then fi export VSOMEIP_APPLICATION_NAME="service-routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="service-sample" diff --git a/test/network_tests/event_tests/event_test_globals.hpp b/test/network_tests/event_tests/event_test_globals.hpp index ef865b42a..c423e0dcd 100644 --- a/test/network_tests/event_tests/event_test_globals.hpp +++ b/test/network_tests/event_tests/event_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef EVENT_TEST_GLOBALS_HPP_ -#define EVENT_TEST_GLOBALS_HPP_ +#pragma once namespace event_test { @@ -25,5 +24,3 @@ enum test_mode_e : std::uint8_t { UNKNOWN, PAYLOAD_FIXED, PAYLOAD_DYNAMIC }; std::uint32_t payload_fixed_length = 20; } - -#endif /* EVENT_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/fake_socket_tests/CMakeLists.txt b/test/network_tests/fake_socket_tests/CMakeLists.txt index cc4a4eeac..f9706af81 100644 --- a/test/network_tests/fake_socket_tests/CMakeLists.txt +++ b/test/network_tests/fake_socket_tests/CMakeLists.txt @@ -24,9 +24,15 @@ add_executable(${PROJECT_NAME} helpers/to_string.cpp main.cpp test_connection_restoration.cpp + test_debounce.cpp ) targets_link_default_libraries("${PROJECT_NAME}") targets_add_default_dependencies("${PROJECT_NAME}") -add_custom_test(NAME ${PROJECT_NAME} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}) +if (WITH_TEST_DISCOVERY) + include(GoogleTest) + gtest_add_tests(TARGET ${PROJECT_NAME} TEST_LIST tests) +else() + add_custom_test(NAME ${PROJECT_NAME} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}) +endif() diff --git a/test/network_tests/fake_socket_tests/conf/multiple_client_one_process.json.in b/test/network_tests/fake_socket_tests/conf/multiple_client_one_process.json.in index 07c6af5ce..2a9525be6 100644 --- a/test/network_tests/fake_socket_tests/conf/multiple_client_one_process.json.in +++ b/test/network_tests/fake_socket_tests/conf/multiple_client_one_process.json.in @@ -3,7 +3,11 @@ "logging": { "level":"trace", - "console":"true" + "console":"true", + "version" : + { + "interval": 0 + } }, "tracing" : { @@ -48,6 +52,10 @@ } ] } + }, + "service-discovery" : + { + "enable": "false" } } diff --git a/test/network_tests/fake_socket_tests/helpers/app.cpp b/test/network_tests/fake_socket_tests/helpers/app.cpp index 79a1f81df..3c1e38d3e 100644 --- a/test/network_tests/fake_socket_tests/helpers/app.cpp +++ b/test/network_tests/fake_socket_tests/helpers/app.cpp @@ -44,6 +44,10 @@ void app::stop() { app_ = nullptr; } +bool app::is_router() const { + return app_ && app_->is_routing(); +} + void app::offer(service_instance _si) { TEST_LOG << "[app] \"" << app_->get_name() << "\" is offering: " << _si; app_->offer_service(_si.service_, _si.instance_); @@ -69,14 +73,34 @@ void app::subscribe_field(event_ids const& _ei) { subscribe(_ei, vsomeip::event_type_e::ET_FIELD); } -void app::answer_request(request const& r, std::function()> payload_creator) { - app_->register_message_handler(r.service_instance_.service_, r.service_instance_.instance_, r.method_, - [this, payload_creator](auto const& message) { +void app::subscribe_eventgroup_event(event_ids const& _ei) { + TEST_LOG << "[app] \"" << app_->get_name() << "\" is subscribing to: " << _ei; + subscribe_eventgroup(_ei, vsomeip::event_type_e::ET_EVENT); +} + +void app::subscribe_eventgroup_field(event_ids const& _ei) { + TEST_LOG << "[app] \"" << app_->get_name() << "\" is subscribing to: " << _ei; + subscribe_eventgroup(_ei, vsomeip::event_type_e::ET_FIELD); +} + +void app::subscribe_event_debounce(event_ids const& _ei, debounce_filter_t const& _filter) { + TEST_LOG << "[app] \"" << app_->get_name() << "\" is subscribing-with-debounce to: " << _ei; + subscribe_with_debounce(_ei, vsomeip::event_type_e::ET_EVENT, _filter); +} + +void app::subscribe_field_debounce(event_ids const& _ei, debounce_filter_t const& _filter) { + TEST_LOG << "[app] \"" << app_->get_name() << "\" is subscribing-with-debounce to: " << _ei; + subscribe_with_debounce(_ei, vsomeip::event_type_e::ET_FIELD, _filter); +} + +void app::answer_request(request const& _r, std::function()> _payload_creator) { + app_->register_message_handler(_r.service_instance_.service_, _r.service_instance_.instance_, _r.method_, + [this, _payload_creator](auto const& message) { // capture the message and log the reception on_message(message); auto response = vsomeip::runtime::get()->create_response(message); auto payload = vsomeip::runtime::get()->create_payload(); - payload->set_data(payload_creator()); + payload->set_data(_payload_creator()); response->set_payload(payload); app_->send(response); }); @@ -160,6 +184,36 @@ void app::subscribe(event_ids const& _ei, vsomeip::event_type_e _et) { app_->subscribe(_ei.si_.service_, _ei.si_.instance_, _ei.eventgroup_id_, 0, _ei.event_id_); } +void app::subscribe_eventgroup(event_ids const& _ei, vsomeip::event_type_e _et) { + TEST_LOG << "[app] \"" << app_->get_name() << "\" is requesting: " << _ei; + std::set its_eventgroups; + app_->register_subscription_status_handler(_ei.si_.service_, _ei.si_.instance_, _ei.eventgroup_id_, _ei.event_id_, + std::bind(&app::on_subscription_status_changed, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, + std::placeholders::_5)); + + its_eventgroups.insert(_ei.eventgroup_id_); + app_->request_event(_ei.si_.service_, _ei.si_.instance_, _ei.event_id_, its_eventgroups, _et, vsomeip::reliability_type_e::RT_RELIABLE); + TEST_LOG << "[app] \"" << app_->get_name() << "\" is subscribing to: " << _ei; + + app_->subscribe(_ei.si_.service_, _ei.si_.instance_, _ei.eventgroup_id_, 0, ANY_EVENT); +} + +void app::subscribe_with_debounce(event_ids const& _ei, vsomeip::event_type_e _et, debounce_filter_t const& filter) { + TEST_LOG << "[app] \"" << app_->get_name() << "\" is requesting: " << _ei; + std::set its_eventgroups; + app_->register_subscription_status_handler(_ei.si_.service_, _ei.si_.instance_, _ei.eventgroup_id_, _ei.event_id_, + std::bind(&app::on_subscription_status_changed, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, + std::placeholders::_5)); + + its_eventgroups.insert(_ei.eventgroup_id_); + app_->request_event(_ei.si_.service_, _ei.si_.instance_, _ei.event_id_, its_eventgroups, _et, vsomeip::reliability_type_e::RT_RELIABLE); + TEST_LOG << "[app] \"" << app_->get_name() << "\" is subscribing-with-debounce to: " << _ei; + + app_->subscribe_with_debounce(_ei.si_.service_, _ei.si_.instance_, _ei.eventgroup_id_, 0, _ei.event_id_, filter); +} + void app::offer(event_ids const& _ei, vsomeip::event_type_e _et) { TEST_LOG << "[app] \"" << app_->get_name() << "\" is offering: " << _ei; std::set its_eventgroups; diff --git a/test/network_tests/fake_socket_tests/helpers/app.hpp b/test/network_tests/fake_socket_tests/helpers/app.hpp index 726e2c7d6..a001e8606 100644 --- a/test/network_tests/fake_socket_tests/helpers/app.hpp +++ b/test/network_tests/fake_socket_tests/helpers/app.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_APP_HPP_ -#define VSOMEIP_V3_TESTING_APP_HPP_ +#pragma once #include #include @@ -53,6 +52,11 @@ class app { */ void stop(); + /** + * Whether application is a router, e.g., is routingmanagerd + */ + bool is_router() const; + /** * Forwards the request to the vsomeip::application::offer_service() */ @@ -103,6 +107,40 @@ class app { */ void subscribe_field(event_ids const& _ei); + /** + * 1. registers a subscription handler to record subscription events with @see + * subscription_record_. + * 2. calls vsomeip::application::request_event() + * 3. calls vsomeip::application::subscribe(), with only the event group + * + * Note: Received events are recorded in the @see message_record_. + */ + void subscribe_eventgroup_event(event_ids const& _ei); + + /** + * 1. registers a subscription handler to record subscription events with @see + * subscription_record_. + * 2. calls vsomeip::application::request_event() + * 3. calls vsomeip::application::subscribe(), with only the event group + * + * Note: Received events are recorded in the @see message_record_. + */ + void subscribe_eventgroup_field(event_ids const& _ei); + + /** + * @see subscribe_event + * + * Uses `subscribe_with_debounce` + */ + void subscribe_event_debounce(event_ids const& _ei, debounce_filter_t const& _filter); + + /* + * @see subscribe_field + * + * Uses `subscribe_with_debounce` + */ + void subscribe_field_debounce(event_ids const& _ei, debounce_filter_t const& _filter); + /** * registers a message handler that will * 1. record the incoming request in the @@ -110,13 +148,35 @@ class app { * 2. uses the _payload_creator to fill the response * 3. dispatch the response with vsomeip::application::send() */ - void answer_request(request const& r, std::function()> payload_creator); + void answer_request(request const& _r, std::function()> _payload_creator); /** * Forwards the event payload to the vsomeip::application::notify() */ void send_event(event_ids const& _ei, std::vector const& _payload); + /** + * Wait for message (payloads!) to reach given state + * + * It is essentially an advanced wrapper around `message_record_`, which only looks at payloads (and ignores service/method/session/...) + */ + bool wait_for_messages(std::vector> const& _payloads, + std::chrono::milliseconds timeout = std::chrono::seconds(3)) { + return message_record_.wait_for( + [&_payloads](auto const& _record) { + if (_record.size() != _payloads.size()) { + return false; + } + + bool equal = true; + for (size_t i = 0; i < _record.size(); ++i) { + equal = equal && _record[i].payload_ == _payloads[i]; + } + return equal; + }, + timeout); + } + /** * After app::start() has been called this helper can be used to await the registration * of the application @@ -146,6 +206,8 @@ class app { void on_subscription_status_changed(vsomeip::service_t _service, vsomeip::instance_t _instance, vsomeip::eventgroup_t _eventgroup, vsomeip::event_t _event, uint16_t error_code); void subscribe(event_ids const& _ei, vsomeip::event_type_e _et); + void subscribe_eventgroup(event_ids const& _ei, vsomeip::event_type_e _et); + void subscribe_with_debounce(event_ids const& _ei, vsomeip::event_type_e _et, debounce_filter_t const& _filter); void offer(event_ids const& _ei, vsomeip::event_type_e _et); bool is_running_{false}; @@ -153,4 +215,3 @@ class app { std::thread runner_; }; } -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/app_connection.cpp b/test/network_tests/fake_socket_tests/helpers/app_connection.cpp index 77e798c1b..78e609763 100644 --- a/test/network_tests/fake_socket_tests/helpers/app_connection.cpp +++ b/test/network_tests/fake_socket_tests/helpers/app_connection.cpp @@ -72,6 +72,17 @@ bool app_connection::delay_message_processing(bool _delay, socket_role _role) { return apply_options(std::move(lock)); } +void app_connection::set_ignore_nothing_to_read_from(socket_role _role, bool _ignore) { + std::unique_lock lock{mtx_}; + if (_role == socket_role::unspecified || _role == socket_role::sender) { + from_options_.ignore_nothing_to_read_from_ = _ignore; + } + if (_role == socket_role::unspecified || _role == socket_role::receiver) { + to_options_.ignore_nothing_to_read_from_ = _ignore; + } + apply_options(std::move(lock)); +} + void app_connection::set_custom_command_handler(vsomeip_command_handler _handler, socket_role _sender) { std::unique_lock lock{mtx_}; if (_sender == socket_role::unspecified || _sender == socket_role::sender) { @@ -174,6 +185,7 @@ bool app_connection::apply_options(std::unique_lock _lock) { if (opt.handler_) { ptr->set_vsomeip_command_handler(opt.handler_); } + ptr->ignore_nothing_to_read_from(opt.ignore_nothing_to_read_from_); return true; } LOCAL_LOG << __func__ << ": Failed, no socket to apply options to on: " << name_; diff --git a/test/network_tests/fake_socket_tests/helpers/app_connection.hpp b/test/network_tests/fake_socket_tests/helpers/app_connection.hpp index f1bc7a34d..997148699 100644 --- a/test/network_tests/fake_socket_tests/helpers/app_connection.hpp +++ b/test/network_tests/fake_socket_tests/helpers/app_connection.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_APP_CONNECTION_HPP_ -#define VSOMEIP_V3_TESTING_APP_CONNECTION_HPP_ +#pragma once #include "fake_tcp_socket_handle.hpp" @@ -57,6 +56,12 @@ class app_connection { **/ [[nodiscard]] bool set_ignore_inner_close(bool _from, bool _to); + /** + * toggles the fake_tcp_socket_handle to (not) report an error if there is no + * connected socket when async_receive is invoked. + **/ + void set_ignore_nothing_to_read_from(socket_role _role, bool _ignore); + /** * sets the handler on each socket (can be set ahead of time), see socket_manager::set_custom_command_handler() **/ @@ -97,6 +102,7 @@ class app_connection { struct connection_options { bool delay_message_processing_{false}; bool ignore_inner_close_{false}; + bool ignore_nothing_to_read_from_{false}; std::optional block_on_close_time_{}; vsomeip_command_handler handler_{}; }; @@ -118,5 +124,3 @@ class app_connection { std::mutex mutable mtx_; }; } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/attribute_recorder.hpp b/test/network_tests/fake_socket_tests/helpers/attribute_recorder.hpp index 963003802..5b4aa774b 100644 --- a/test/network_tests/fake_socket_tests/helpers/attribute_recorder.hpp +++ b/test/network_tests/fake_socket_tests/helpers/attribute_recorder.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_ATTRIBUTE_RECORDER_HPP_ -#define VSOMEIP_V3_TESTING_ATTRIBUTE_RECORDER_HPP_ +#pragma once #include #include @@ -71,9 +70,17 @@ class attribute_recorder { std::string to_string() const { auto lock = std::unique_lock(mtx_); std::stringstream s; + s << "["; + bool first = true; for (auto const& val : record_) { + if (first) { + first = false; + } else { + s << ", "; + } s << val; } + s << "]"; return s.str(); } @@ -90,4 +97,3 @@ std::ostream& operator<<(std::ostream& _out, attribute_recorder const& _m return _out; } } -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.cpp b/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.cpp index ca9917a3c..3c39c3a67 100644 --- a/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.cpp +++ b/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.cpp @@ -19,8 +19,17 @@ base_fake_socket_fixture::base_fake_socket_fixture() { } base_fake_socket_fixture::~base_fake_socket_fixture() { + // stop normal applications first, let them deregister for (auto& name_to_client : name_to_client_) { - name_to_client.second->stop(); + if (!name_to_client.second->is_router()) { + name_to_client.second->stop(); + } + } + // stop routing applications + for (auto& name_to_client : name_to_client_) { + if (name_to_client.second->is_router()) { + name_to_client.second->stop(); + } } name_to_client_.clear(); factory_->set_manager(nullptr); @@ -110,6 +119,11 @@ void base_fake_socket_fixture::set_ignore_connections(std::string const& _app_na return socket_manager_->set_ignore_inner_close(_from, _ignore_in_from, _to, _ignore_in_to); } +void base_fake_socket_fixture::set_ignore_nothing_to_read_from(std::string const& _from, std::string const& _to, socket_role _role, + bool _ignore) { + return socket_manager_->set_ignore_nothing_to_read_from(_from, _to, _role, _ignore); +} + [[nodiscard]] bool base_fake_socket_fixture::block_on_close_for(std::string const& _from, std::optional _from_block_time, std::string const& _to, @@ -137,9 +151,10 @@ void base_fake_socket_fixture::fail_on_bind(std::string const& _app, bool _fail) void base_fake_socket_fixture::set_ignore_broken_pipe(std::string const& _app_name, bool _set) { socket_manager_->set_ignore_broken_pipe(_app_name, _set); } -bool base_fake_socket_fixture::wait_once_for_dropped_command(std::string const& _from, std::string const& _to, protocol::id_e _id, - std::chrono::milliseconds _timeout) { - return socket_manager_->wait_once_for_dropped_command(_from, _to, _id, _timeout); + +std::future base_fake_socket_fixture::drop_command_once(std::string const& _from, std::string const& _to, + protocol::id_e _id) { + return socket_manager_->drop_command_once(_from, _to, _id); } void base_fake_socket_fixture::set_custom_command_handler(std::string const& _from, std::string const& _to, diff --git a/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.hpp b/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.hpp index ea0ea33c2..4b1533401 100644 --- a/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.hpp +++ b/test/network_tests/fake_socket_tests/helpers/base_fake_socket_fixture.hpp @@ -150,6 +150,11 @@ struct base_fake_socket_fixture : ::testing::Test { [[nodiscard]] bool delay_message_processing(std::string const& _from, std::string const& _to, bool _delay, socket_role _role = socket_role::receiver); + /** + * @see socket_manager::set_ignore_nothing_to_read_from() + **/ + void set_ignore_nothing_to_read_from(std::string const& _from, std::string const& _to, socket_role _role, bool _ignore); + /** * @see socket_manager::set_ignore_inner_close() **/ @@ -186,10 +191,9 @@ struct base_fake_socket_fixture : ::testing::Test { void set_ignore_broken_pipe(std::string const& _app_name, bool _set); /** - * @see socket_manager::wait_once_for_dropped_command + * @see socket_manager::drop_command_once */ - bool wait_once_for_dropped_command(std::string const& _from, std::string const& _to, protocol::id_e _id, - std::chrono::milliseconds _timeout); + std::future drop_command_once(std::string const& _from, std::string const& _to, protocol::id_e _id); /** * @see socket_manager::inject_command diff --git a/test/network_tests/fake_socket_tests/helpers/command_message.hpp b/test/network_tests/fake_socket_tests/helpers/command_message.hpp index 029ae6a50..7990f10ea 100644 --- a/test/network_tests/fake_socket_tests/helpers/command_message.hpp +++ b/test/network_tests/fake_socket_tests/helpers/command_message.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_COMMAND_MESSAGE_HPP_ -#define VSOMEIP_V3_COMMAND_MESSAGE_HPP_ +#pragma once #include #include "../../../../implementation/protocol/include/protocol.hpp" @@ -95,5 +94,3 @@ std::vector construct_basic_raw_command(Ts&&... payload) { return message; } } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/command_record.hpp b/test/network_tests/fake_socket_tests/helpers/command_record.hpp index d7a80b9c3..1449f6e78 100644 --- a/test/network_tests/fake_socket_tests/helpers/command_record.hpp +++ b/test/network_tests/fake_socket_tests/helpers/command_record.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_COMMAND_RECORD_ -#define VSOMEIP_V3_TESTING_COMMAND_RECORD_ +#pragma once #include "command_message.hpp" #include "vsomeip_command_handler.hpp" @@ -52,5 +51,3 @@ class command_record : public std::enable_shared_from_this { bool operator==(std::vector> const& _lhs, command_record const& _rhs); } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/fake_netlink_connector.hpp b/test/network_tests/fake_socket_tests/helpers/fake_netlink_connector.hpp index 8e782706f..0b85f1baf 100644 --- a/test/network_tests/fake_socket_tests/helpers/fake_netlink_connector.hpp +++ b/test/network_tests/fake_socket_tests/helpers/fake_netlink_connector.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_FAKE_NETLINK_CONNECTOR_HPP_ -#define VSOMEIP_V3_TESTING_FAKE_NETLINK_CONNECTOR_HPP_ +#pragma once #if defined(__linux__) #include "../../../implementation/endpoints/include/abstract_netlink_connector.hpp" @@ -41,5 +40,4 @@ class fake_netlink_connector : public abstract_netlink_connector, public std::en }; } -#endif -#endif +#endif \ No newline at end of file diff --git a/test/network_tests/fake_socket_tests/helpers/fake_socket_factory.hpp b/test/network_tests/fake_socket_tests/helpers/fake_socket_factory.hpp index a4ac0e738..a88770a41 100644 --- a/test/network_tests/fake_socket_tests/helpers/fake_socket_factory.hpp +++ b/test/network_tests/fake_socket_tests/helpers/fake_socket_factory.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_FAKE_SOCKET_FACTORY_HPP_ -#define VSOMEIP_V3_TESTING_FAKE_SOCKET_FACTORY_HPP_ +#pragma once #include "../../../implementation/endpoints/include/abstract_socket_factory.hpp" #include "../../../implementation/endpoints/include/asio_timer.hpp" @@ -65,5 +64,3 @@ class fake_socket_factory : public abstract_socket_factory { std::weak_ptr socket_manager_; }; } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket.hpp b/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket.hpp index 1a9dae4ac..ec3a15e77 100644 --- a/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket.hpp +++ b/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_FAKE_TCP_SOCKET_HPP_ -#define VSOMEIP_V3_TESTING_FAKE_TCP_SOCKET_HPP_ +#pragma once #include "../../../implementation/endpoints/include/tcp_socket.hpp" @@ -217,4 +216,3 @@ class fake_tcp_acceptor : public tcp_acceptor { }; } -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.cpp b/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.cpp index 44c02228e..947b5e1df 100644 --- a/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.cpp +++ b/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.cpp @@ -145,6 +145,20 @@ void fake_tcp_socket_handle::delay_processing(bool _delay) { update_reception(); } +void fake_tcp_socket_handle::ignore_nothing_to_read_from(bool _ignore) { + auto const lock = std::scoped_lock(mtx_); + TEST_LOG << "[fake-socket] setting ignore_nothing_to_read_from: " << (_ignore ? "true" : "false") << " on: " << socket_id_; + ignore_nothing_to_read_from_ = _ignore; + if (auto remote = connected_socket_.lock(); !remote && !ignore_nothing_to_read_from_ && receptor_) { + TEST_LOG << "[fake-socket] Error on: " << socket_id_ << ", no connection to read from"; + boost::asio::post(io_, [handler = std::move(receptor_->handler_)] { handler(boost::asio::error::connection_reset, 0); }); + // safe to do under the lock, because the handler is already empty and will be destructed after being called on one of the io + // threads. + receptor_ = std::nullopt; + return; + } +} + void fake_tcp_socket_handle::block_on_close_for(std::optional _block_time) { auto const lock = std::scoped_lock(mtx_); block_on_close_time_ = _block_time; @@ -270,11 +284,12 @@ void fake_tcp_socket_handle::async_receive(boost::asio::mutable_buffer _buffer, boost::asio::post(io_, [ec = *stashed_ec_, handler = std::move(_handler)] { handler(ec, 0); }); stashed_ec_ = std::nullopt; } - if (auto remote = connected_socket_.lock(); !remote) { + if (auto remote = connected_socket_.lock(); !remote && input_data_.size() == 0 && !ignore_nothing_to_read_from_) { TEST_LOG << "[fake-socket] Error on: " << socket_id_ << ", no connection to read from"; boost::asio::post(io_, [handler = std::move(_handler)] { handler(boost::asio::error::connection_reset, 0); }); return; } + receptor_ = Receptor{std::move(_buffer), std::move(_handler)}; update_reception(); } diff --git a/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.hpp b/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.hpp index e2df0ec3f..63444e438 100644 --- a/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.hpp +++ b/test/network_tests/fake_socket_tests/helpers/fake_tcp_socket_handle.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_SHARED_TCP_SOCKET_STATE_HPP_ -#define VSOMEIP_V3_TESTING_SHARED_TCP_SOCKET_STATE_HPP_ +#pragma once #include "../../../implementation/endpoints/include/tcp_socket.hpp" #include "attribute_recorder.hpp" @@ -161,6 +160,12 @@ struct fake_tcp_socket_handle : std::enable_shared_from_this @@ -110,5 +109,3 @@ std::ostream& operator<<(std::ostream& o, event_ids const& s); std::ostream& operator<<(std::ostream& o, event_subscription const& s); std::ostream& operator<<(std::ostream& o, std::vector const& s); } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/socket_manager.cpp b/test/network_tests/fake_socket_tests/helpers/socket_manager.cpp index f69f57e4a..59b5d2d79 100644 --- a/test/network_tests/fake_socket_tests/helpers/socket_manager.cpp +++ b/test/network_tests/fake_socket_tests/helpers/socket_manager.cpp @@ -339,6 +339,11 @@ void socket_manager::set_ignore_connections(std::string const& _app_name, bool _ return connection->set_ignore_inner_close(_ignore_in_from, _ignore_in_to); } +void socket_manager::set_ignore_nothing_to_read_from(std::string const& _from, std::string const& _to, socket_role _role, bool _ignore) { + auto connection = get_or_create_connection(_from, _to); + connection->set_ignore_nothing_to_read_from(_role, _ignore); +} + [[nodiscard]] bool socket_manager::block_on_close_for(std::string const& _from, std::optional _from_block_time, std::string const& _to, std::optional _to_block_time) { auto connection = get_or_create_connection(_from, _to); @@ -383,23 +388,20 @@ bool socket_manager::ignore_broken_pipe(fake_tcp_socket_handle const& _handle) { return true; } -bool socket_manager::wait_once_for_dropped_command(std::string const& _from, std::string const& _to, protocol::id_e _id, - [[maybe_unused]] std::chrono::milliseconds _timeout) { +std::future socket_manager::drop_command_once(std::string const& _from, std::string const& _to, protocol::id_e _id) { std::shared_ptr> blocked_promise{std::make_shared>()}; - auto blocked_future = blocked_promise->get_future(); - set_custom_command_handler(_from, _to, [blocked_promise, _id](command_message const& _cmd) { + auto fut = blocked_promise->get_future(); + set_custom_command_handler(_from, _to, [this, blocked_promise, _id, from = _from, to = _to](command_message const& _cmd) { if (_cmd.id_ == _id) { blocked_promise->set_value(_id); + // reset handler + set_custom_command_handler(from, to, nullptr); return true; } return false; }); - auto expired = blocked_future.wait_for(_timeout); - // Destroy previous registered handler and consequently dangling captures. - set_custom_command_handler(_from, _to, nullptr); - - return expired == std::future_status::ready; + return fut; } bool socket_manager::inject_command(std::string const& _from, std::string const& _to, std::vector& _payload) { diff --git a/test/network_tests/fake_socket_tests/helpers/socket_manager.hpp b/test/network_tests/fake_socket_tests/helpers/socket_manager.hpp index abd112b76..b8d41358c 100644 --- a/test/network_tests/fake_socket_tests/helpers/socket_manager.hpp +++ b/test/network_tests/fake_socket_tests/helpers/socket_manager.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_SOCKET_MANAGER_HPP_ -#define VSOMEIP_V3_TESTING_SOCKET_MANAGER_HPP_ +#pragma once #include "fake_tcp_socket_handle.hpp" @@ -127,6 +126,13 @@ class socket_manager : public std::enable_shared_from_this { **/ [[nodiscard]] bool set_ignore_inner_close(std::string const& _from, bool _ignore_in_from, std::string const& _to, bool _ignore_in_to); + /** + * Ensures that a async_receive will not fail, if the other socket disconnected. + * This is helpful for simulating suspend sequences. + * Note: This option is permanent to the connection and needs to be actively reset. + **/ + void set_ignore_nothing_to_read_from(std::string const& _from, std::string const& _to, socket_role _role, bool _ignore); + /** * searches for the _from -> _to connected sockets and demands from _from to block execution * for _from_block_time when close is invoked, equivalent for _to with _to_block_time. @@ -211,11 +217,11 @@ class socket_manager : public std::enable_shared_from_this { void awaiting(); /** - * Stops once the delivery of a specific vsomeip command @param _id from @param _from towards @param _to. - * Returns when the command is stopped or when @param _timeout expires. + * Prepares a drop for the specific vsomeip command @param _id from @param _from towards @param _to, gives a future for when it happens + * + * NOTE: not composeable, difficut to use, take care.. */ - bool wait_once_for_dropped_command(std::string const& _from, std::string const& _to, protocol::id_e _id, - std::chrono::milliseconds _timeout); + std::future drop_command_once(std::string const& _from, std::string const& _to, protocol::id_e _id); /** * Forces the delivery of a vsomeip message @param _payload from @param _from to @param _to. @@ -268,5 +274,3 @@ class socket_manager : public std::enable_shared_from_this { std::set ignore_broken_pipe_; }; } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/test_logging.hpp b/test/network_tests/fake_socket_tests/helpers/test_logging.hpp index 95c41f80e..7a90f42f5 100644 --- a/test/network_tests/fake_socket_tests/helpers/test_logging.hpp +++ b/test/network_tests/fake_socket_tests/helpers/test_logging.hpp @@ -3,11 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_TEST_LOGGING_HPP_ -#define VSOMEIP_V3_TESTING_TEST_LOGGING_HPP_ +#pragma once #include #define TEST_LOG vsomeip_v3::logger::message(vsomeip_v3::logger::level_e::LL_DEBUG) << "[TEST_LOG] " - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/to_string.cpp b/test/network_tests/fake_socket_tests/helpers/to_string.cpp index f0b7323ce..485b9d2d5 100644 --- a/test/network_tests/fake_socket_tests/helpers/to_string.cpp +++ b/test/network_tests/fake_socket_tests/helpers/to_string.cpp @@ -6,11 +6,6 @@ #include "to_string.hpp" #include "command_message.hpp" -#include "../../../../implementation/protocol/src/routing_info_command.cpp" -#include "../../../../implementation/protocol/src/config_command.cpp" -#include "../../../../implementation/protocol/src/command.cpp" -#include "../../../../implementation/protocol/src/routing_info_entry.cpp" - #include #include diff --git a/test/network_tests/fake_socket_tests/helpers/to_string.hpp b/test/network_tests/fake_socket_tests/helpers/to_string.hpp index 443ed086d..db39c15ed 100644 --- a/test/network_tests/fake_socket_tests/helpers/to_string.hpp +++ b/test/network_tests/fake_socket_tests/helpers/to_string.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TO_STRING_HPP_ -#define VSOMEIP_V3_TO_STRING_HPP_ +#pragma once #include "../../../../implementation/protocol/include/protocol.hpp" #include "../../../../implementation/protocol/include/routing_info_command.hpp" @@ -56,5 +55,3 @@ std::string to_string(std::vector const& _container) { return s.str(); } } - -#endif diff --git a/test/network_tests/fake_socket_tests/helpers/vsomeip_command_handler.hpp b/test/network_tests/fake_socket_tests/helpers/vsomeip_command_handler.hpp index cb8336dd2..c7d342906 100644 --- a/test/network_tests/fake_socket_tests/helpers/vsomeip_command_handler.hpp +++ b/test/network_tests/fake_socket_tests/helpers/vsomeip_command_handler.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TESTING_VSOMEIP_COMMAND_HANDLER_ -#define VSOMEIP_V3_TESTING_VSOMEIP_COMMAND_HANDLER_ +#pragma once #include "command_message.hpp" #include @@ -14,5 +13,3 @@ namespace vsomeip_v3::testing { using vsomeip_command_handler = std::function; } - -#endif diff --git a/test/network_tests/fake_socket_tests/test_connection_restoration.cpp b/test/network_tests/fake_socket_tests/test_connection_restoration.cpp index 50382a36d..f299c7f7d 100644 --- a/test/network_tests/fake_socket_tests/test_connection_restoration.cpp +++ b/test/network_tests/fake_socket_tests/test_connection_restoration.cpp @@ -411,8 +411,12 @@ TEST_F(test_client_helper, client_server_connection_breakdown_on_client_suspend_ send_first_message(); ASSERT_TRUE(client_->message_record_.wait_for_last(first_expected_message_)); - // simulating a suspend of a client: + // simulating a suspend of a client (the client should not react to any action of the server) + ASSERT_TRUE(set_ignore_inner_close(client_name_, true, server_name_, false)); + ASSERT_TRUE(set_ignore_inner_close(server_name_, true, client_name_, false)); set_ignore_connections(client_name_, true); + set_ignore_nothing_to_read_from(server_name_, client_name_, socket_role::receiver, true); + ASSERT_TRUE(disconnect(server_name_, boost::asio::error::timed_out, client_name_, std::nullopt)); std::ignore = disconnect(client_name_, std::nullopt, server_name_, boost::asio::error::timed_out); @@ -920,6 +924,38 @@ TEST_F(test_client_helper, routing_info_conflict_routingmanagerd) { EXPECT_TRUE(client_->availability_record_.wait_for_any(service_availability::unavailable(service_instance_))); } +TEST_F(test_client_helper, subscribe_eventgroup_connection_break) { + /// check whether a subscription to an event group is restored after a connection break + + start_apps(); + + send_field_message(); + + client_->request_service(service_instance_); + client_->subscribe_eventgroup_field(offered_field_); + + ASSERT_TRUE(client_->availability_record_.wait_for_last(service_availability::available(service_instance_))); + ASSERT_TRUE(client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_field_))); + ASSERT_TRUE(client_->message_record_.wait_for([](auto const& record) { return record.size() > 0; })); + + // need to increase the odds, hence the extra iterations + for (size_t i = 0; i < 100; ++i) { + TEST_LOG << "Iteration " << i; + + client_->availability_record_.clear(); + client_->subscription_record_.clear(); + client_->message_record_.clear(); + + // client -> server connection breaks.. + std::ignore = disconnect(client_name_, boost::asio::error::timed_out, server_name_, std::nullopt); + + // we *MUST* see available/subscribed/message + ASSERT_TRUE(client_->availability_record_.wait_for_last(service_availability::available(service_instance_))); + ASSERT_TRUE(client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_field_))); + ASSERT_TRUE(client_->message_record_.wait_for([](auto const& record) { return record.size() > 0; })); + } +} + struct test_restart_clients : test_client_helper { bool subscribe(app* client) { @@ -1035,12 +1071,22 @@ TEST_F(test_restart_clients, test_restart_service_availability) { */ TEST_F(test_restart_clients, block_registration_process) { start_router(); + + std::future fut = drop_command_once(client_one_, routingmanager_name_, protocol::id_e::REGISTER_APPLICATION_ID); + + // start a client create_app(client_one_); auto* one = start_client(client_one_); - ASSERT_TRUE(await_connection(client_one_, routingmanager_name_, std::chrono::seconds(2))); - ASSERT_TRUE(wait_once_for_dropped_command(client_one_, routingmanager_name_, protocol::id_e::REGISTER_APPLICATION_ID, - std::chrono::milliseconds(500))); + ASSERT_TRUE(await_connection(client_one_, routingmanager_name_)); + ASSERT_FALSE(one->app_state_record_.wait_for_last(vsomeip::state_type_e::ST_REGISTERED, std::chrono::seconds(1))); + + // sanity check that the right message was dropped + ASSERT_TRUE(fut.wait_for(std::chrono::seconds(5)) == std::future_status::ready); + ASSERT_EQ(fut.get(), protocol::id_e::REGISTER_APPLICATION_ID); + + // and that application eventually registers + EXPECT_TRUE(one->app_state_record_.wait_for_last(vsomeip::state_type_e::ST_REGISTERED)); } struct test_single_connection_breakdown : test_client_helper, ::testing::WithParamInterface> { }; diff --git a/test/network_tests/fake_socket_tests/test_debounce.cpp b/test/network_tests/fake_socket_tests/test_debounce.cpp new file mode 100644 index 000000000..a6069532e --- /dev/null +++ b/test/network_tests/fake_socket_tests/test_debounce.cpp @@ -0,0 +1,255 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "helpers/attribute_recorder.hpp" +#include "helpers/base_fake_socket_fixture.hpp" +#include "helpers/app.hpp" +#include "helpers/command_record.hpp" +#include "helpers/fake_socket_factory.hpp" +#include "helpers/fake_tcp_socket_handle.hpp" +#include "helpers/service_state.hpp" + +#include +#include +#include + +#include + +using namespace vsomeip_v3; +using namespace vsomeip_v3::testing; + +static std::string const routingmanager_name_{"routingmanagerd"}; +static std::string const server_name_{"server"}; +static std::string const client_name_{"client"}; + +struct test_debounce_helper : public base_fake_socket_fixture { + test_debounce_helper() { + use_configuration("multiple_client_one_process.json"); + create_app(routingmanager_name_); + create_app(server_name_); + create_app(client_name_); + } + + void start_router() { + routingmanagerd_ = start_client(routingmanager_name_); + ASSERT_TRUE(routingmanagerd_ && await_connectable(routingmanager_name_)); + } + + void start_server() { + server_ = start_client(server_name_); + ASSERT_TRUE(server_ && server_->app_state_record_.wait_for_last(vsomeip::state_type_e::ST_REGISTERED)); + server_->offer(service_instance_); + server_->offer_event(offered_event_); + server_->offer_field(offered_field_); + } + + void start_client_app() { + client_ = start_client(client_name_); + ASSERT_TRUE(client_ && client_->app_state_record_.wait_for_last(vsomeip::state_type_e::ST_REGISTERED)); + } + + void start_apps() { + start_router(); + start_server(); + start_client_app(); + } + + [[nodiscard]] bool subscribe_to_event(debounce_filter_t const& filter) { + client_->request_service(service_instance_); + client_->subscribe_event_debounce(offered_event_, filter); + return client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_event_)); + } + [[nodiscard]] bool subscribe_to_field(debounce_filter_t const& filter) { + client_->request_service(service_instance_); + client_->subscribe_field_debounce(offered_field_, filter); + return client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_field_)); + } + + service_instance service_instance_{0x3344, 0x1}; + service_instance service_instance_two_{0x3345, 0x1}; + event_ids offered_event_{service_instance_, 0x8002, 0x1}; + event_ids offered_field_{service_instance_, 0x8003, 0x6}; + + app* routingmanagerd_{}; + app* client_{}; + app* server_{}; +}; + +TEST_F(test_debounce_helper, debounce_on_change) { + /// `subscribe_with_debounce`, server offers, client subscribes such that it only waits changes + + start_apps(); + + debounce_filter_t filter; + filter.on_change_ = true; + filter.interval_ = -1; + + ASSERT_TRUE(subscribe_to_field(filter)); + // can't receive a notification the server did not send! + ASSERT_TRUE(client_->wait_for_messages({})); + + server_->send_event(offered_field_, {0x00}); + ASSERT_TRUE(client_->wait_for_messages({{0x00}})); + + // client only sees changes + server_->send_event(offered_field_, {0x00}); + server_->send_event(offered_field_, {0x01}); + ASSERT_TRUE(client_->wait_for_messages({{0x00}, {0x01}})); + + server_->send_event(offered_field_, {0x00}); + server_->send_event(offered_field_, {0x02, 0x02}); + ASSERT_TRUE(client_->wait_for_messages({{0x00}, {0x01}, {0x00}, {0x02, 0x02}})); +} + +TEST_F(test_debounce_helper, router_debounce_on_change) { + /// sanity test for `subscribe_with_debounce` with configuration that only waits changes + /// router is the one offering the service, so that we check the *router* debouncing behavior + + start_router(); + start_client_app(); + + // router offers several events, which happen to have the same event-id + event_ids offered_field{service_instance_, 0x8001, 0x1}; + event_ids offered_field_two{service_instance_two_, 0x8001, 0x02}; + routingmanagerd_->offer(service_instance_); + routingmanagerd_->offer(service_instance_two_); + routingmanagerd_->offer_field(offered_field); + routingmanagerd_->offer_event(offered_field_two); + + routingmanagerd_->send_event(offered_field, {0x00}); + routingmanagerd_->send_event(offered_field_two, {0xF0}); + + // client only requests *one* of the services + // and does a subscribe_with_debounce, with parameters that *ONLY* want changes + debounce_filter_t filter; + filter.on_change_ = true; + filter.interval_ = -1; + filter.send_current_value_after_ = true; + + client_->request_service(service_instance_); + client_->subscribe_field_debounce(offered_field, filter); + + // ensure client only sees first service available + ASSERT_TRUE(client_->availability_record_.wait_for_last(service_availability::available(service_instance_))); + ASSERT_TRUE(client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_field))); + + ASSERT_TRUE(client_->wait_for_messages({{0x00}})); + routingmanagerd_->send_event(offered_field, {0x00}); + routingmanagerd_->send_event(offered_field, {0x01}); + ASSERT_TRUE(client_->wait_for_messages({{0x00}, {0x01}})); + routingmanagerd_->send_event(offered_field, {0x01}); + routingmanagerd_->send_event(offered_field_two, {0xF1}); + routingmanagerd_->send_event(offered_field, {0x01}); + routingmanagerd_->send_event(offered_field_two, {0xF1}); + routingmanagerd_->send_event(offered_field, {0x01}); + + // give the other notifications a chance to do something.. + // TODO: not good.. + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + routingmanagerd_->send_event(offered_field, {0x02}); + ASSERT_TRUE(client_->wait_for_messages({{0x00}, {0x01}, {0x02}})); +} + +TEST_F(test_debounce_helper, debounce_default) { + /// `subscribe_with_debounce`, check default values + + start_apps(); + + // default `filter`, so.. essentially the same as a normal subscribe + // no "on-change", no interval, nothing + debounce_filter_t filter; + + ASSERT_TRUE(subscribe_to_event(filter)); + ASSERT_TRUE(client_->wait_for_messages({})); + + server_->send_event(offered_event_, {0x00}); + server_->send_event(offered_event_, {0x00}); + server_->send_event(offered_event_, {0x01, 0x01}); + server_->send_event(offered_event_, {0x02}); + // currently receive nothing + // TODO: FIXME! + ASSERT_FALSE(client_->wait_for_messages({{0x00}, {0x00}, {0x01, 0x01}, {0x02}}, std::chrono::milliseconds(10))); + ASSERT_TRUE(client_->wait_for_messages({})); +} + +TEST_F(test_debounce_helper, debounce_interval) { + /// `subscribe_with_debounce`, check interval behavior + + start_apps(); + + debounce_filter_t filter; + filter.interval_ = 1000; // only accept messages every sec + + ASSERT_TRUE(subscribe_to_event(filter)); + ASSERT_TRUE(client_->wait_for_messages({})); + + // immediately send 3 events + server_->send_event(offered_event_, {0x00}); + server_->send_event(offered_event_, {0x01}); + server_->send_event(offered_event_, {0x02}); + + // definitely shouldn't ever, ever see the 3 events + // TODO: not good, this is essentially a 10ms sleep.. + ASSERT_FALSE(client_->wait_for_messages({{0x00}, {0x01}, {0x02}}, std::chrono::milliseconds(10))); + ASSERT_TRUE(client_->wait_for_messages({{0x00}})) << client_->message_record_; +} + +TEST_F(test_debounce_helper, debounce_on_change_interval) { + /// `subscribe_with_debounce`, check on_change + interval + /// where the expectation is that changed values will bypass interval + + start_apps(); + + debounce_filter_t filter_event; + filter_event.on_change_ = true; + filter_event.interval_ = 1000; // only accept messages every sec + + debounce_filter_t filter_field; + filter_field.on_change_resets_interval_ = true; // changes `on_change_resets_interval_` instead of `on_change`! + filter_field.interval_ = 1000; // only accept messages every sec + + // NOTE: careful, do not want to do `request_service` twice + client_->request_service(service_instance_); + client_->subscribe_event_debounce(offered_event_, filter_event); + ASSERT_TRUE(client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_event_))); + client_->subscribe_field_debounce(offered_field_, filter_field); + ASSERT_TRUE(client_->subscription_record_.wait_for_last(event_subscription::successfully_subscribed_to(offered_field_))); + ASSERT_TRUE(client_->wait_for_messages({})); + + // immediately send several events + for (std::vector const& payload : std::vector>{{0x00}, {0x01}, {0x01}, {0x02}}) { + server_->send_event(offered_event_, payload); + server_->send_event(offered_field_, payload); + } + + // only `on_change` bypasses interval, not `on_change_resets_interval_` + // hence why 0x00 is seen twice + ASSERT_TRUE(client_->wait_for_messages({{0x00}, {0x00}, {0x01}, {0x02}})) << client_->message_record_; + // and of course, last notification is from event (which uses `on_change`) + ASSERT_TRUE(client_->message_record_.last()->method_ = offered_event_.event_id_) << client_->message_record_; +} + +TEST_F(test_debounce_helper, debounce_send_after) { + /// `subscribe_with_debounce`, check `send_current_value_after_` behavior + + start_apps(); + + debounce_filter_t filter; + filter.interval_ = 100; + filter.send_current_value_after_ = true; + + ASSERT_TRUE(subscribe_to_event(filter)); + ASSERT_TRUE(client_->wait_for_messages({})); + + // immediately send 3 messages + server_->send_event(offered_event_, {0x00}); + server_->send_event(offered_event_, {0x01}); + server_->send_event(offered_event_, {0x02}); + + // will only receive first, because `send_current_value_after_` is broken and does absolutely nothing + ASSERT_FALSE(client_->wait_for_messages({{0x00, 0x02}}, std::chrono::milliseconds(150))); + ASSERT_TRUE(client_->wait_for_messages({{0x00}})) << client_->message_record_; +} diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.hpp b/test/network_tests/header_factory_tests/header_factory_test_client.hpp index a5ee7b145..e8640e5a5 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_client.hpp +++ b/test/network_tests/header_factory_tests/header_factory_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef HEADERFACTORYTESTCLIENT_HPP_ -#define HEADERFACTORYTESTCLIENT_HPP_ +#pragma once #include @@ -43,5 +42,3 @@ class header_factory_test_client { std::uint32_t number_of_acknowledged_messages_; std::thread sender_; }; - -#endif /* HEADERFACTORYTESTCLIENT_HPP_ */ diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.cpp b/test/network_tests/header_factory_tests/header_factory_test_service.cpp index 35da152b0..bdd6f4255 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_service.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test_service.cpp @@ -105,10 +105,6 @@ void header_factory_test_service::run() { } condition_.wait(its_lock, [this] { return blocked_; }); - // magic sleep to give time for the last message to be sent - // TODO: FIXME! REMOVE THIS! - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - VSOMEIP_INFO << "Stopping..."; app_->stop(); diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.hpp b/test/network_tests/header_factory_tests/header_factory_test_service.hpp index 1cb3f7085..526d16de4 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_service.hpp +++ b/test/network_tests/header_factory_tests/header_factory_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef HEADERFACTORYTESTSERVICE_HPP_ -#define HEADERFACTORYTESTSERVICE_HPP_ +#pragma once #include #include @@ -40,5 +39,3 @@ class header_factory_test_service { std::uint32_t number_of_received_messages_; std::thread offer_thread_; }; - -#endif /* HEADERFACTORYTESTSERVICE_HPP_ */ diff --git a/test/network_tests/hostname_tests/conf/hostname_test_starter.sh.in b/test/network_tests/hostname_tests/conf/hostname_test_starter.sh.in index 50142c889..6f045c20a 100755 --- a/test/network_tests/hostname_tests/conf/hostname_test_starter.sh.in +++ b/test/network_tests/hostname_tests/conf/hostname_test_starter.sh.in @@ -14,7 +14,7 @@ export VSOMEIP_CONFIGURATION=hostname_test_service.json # Start the routing manager. export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & DAEMON_PID=$! # Start the test service. diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter.sh.in b/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter.sh.in index 43e110e66..0a4d858a5 100755 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter.sh.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter.sh.in @@ -39,6 +39,7 @@ FAIL=0 # Start the services export VSOMEIP_CONFIGURATION=$PASSED_JSON_FILE +# NOTE: this application does routing! export VSOMEIP_APPLICATION_NAME=initial_event_test_service_one ./initial_event_test_service 1 $REMAINING_OPTIONS & PID_SERVICE_ONE=$! @@ -51,8 +52,6 @@ export VSOMEIP_APPLICATION_NAME=initial_event_test_service_three ./initial_event_test_service 3 $REMAINING_OPTIONS & PID_SERVICE_THREE=$! -sleep 3 - unset VSOMEIP_APPLICATION_NAME # Array for client pids @@ -69,8 +68,6 @@ export VSOMEIP_APPLICATION_NAME=master_initial_event_test_availability_checker ./initial_event_test_availability_checker 1234 $REMAINING_OPTIONS & PID_AVAILABILITY_CHECKER=$! -sleep 1 - exec_slave "./initial_event_test_slave_starter.sh $CLIENT_JSON_FILE $REMAINING_OPTIONS" PID_SERVICE=$! @@ -85,12 +82,10 @@ echo "WAITING FOR SERVICE AVAILABILITY" wait $PID_AVAILABILITY_CHECKER echo "ALL SERVICES ARE AVAILABLE NOW" -sleep 2 - for client_number in $(seq 9003 9013) do export VSOMEIP_APPLICATION_NAME="master_initial_event_test_client_$client_number" - ./initial_event_test_client $client_number STRICT_CHECKING $REMAINING_OPTIONS & + ./initial_event_test_client $client_number $REMAINING_OPTIONS & CLIENT_PIDS+=($!) done @@ -106,21 +101,21 @@ echo "Starting stop service | Master" # wait until all clients exited on slave side export VSOMEIP_APPLICATION_NAME=master_initial_event_test_stop_service -./initial_event_test_stop_service MASTER & -PID_STOP_SERVICE=$! -wait $PID_STOP_SERVICE +./initial_event_test_stop_service MASTER || FAIL=$(($FAIL+1)) -# shutdown the first client +# shutdown all clients/services kill $FIRST_PID -wait $FIRST_PID || FAIL=$(($FAIL+1)) +kill $PID_SERVICE_THREE +kill $PID_SERVICE_TWO +# wait for slave wait $PID_SERVICE || FAIL=$(($FAIL+1)) -# shutdown the services -kill $PID_SERVICE_THREE +wait $FIRST_PID || FAIL=$(($FAIL+1)) wait $PID_SERVICE_THREE || FAIL=$(($FAIL+1)) -kill $PID_SERVICE_TWO wait $PID_SERVICE_TWO || FAIL=$(($FAIL+1)) + +# after everything, because this application is the router kill $PID_SERVICE_ONE wait $PID_SERVICE_ONE || FAIL=$(($FAIL+1)) diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter_qnx.sh.in b/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter_qnx.sh.in index 19972725f..ecf9a2e05 100755 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter_qnx.sh.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_master_starter_qnx.sh.in @@ -39,6 +39,7 @@ FAIL=0 # Start the services export VSOMEIP_CONFIGURATION=$PASSED_JSON_FILE +# NOTE: this application does routing! export VSOMEIP_APPLICATION_NAME=initial_event_test_service_one ./initial_event_test_service 1 $REMAINING_OPTIONS & PID_SERVICE_ONE=$! @@ -51,8 +52,6 @@ export VSOMEIP_APPLICATION_NAME=initial_event_test_service_three ./initial_event_test_service 3 $REMAINING_OPTIONS & PID_SERVICE_THREE=$! -sleep 3 - unset VSOMEIP_APPLICATION_NAME # Start first client which subscribes remotely @@ -64,8 +63,6 @@ FIRST_PID=$! ./initial_event_test_availability_checker 1234 $REMAINING_OPTIONS & PID_AVAILABILITY_CHECKER=$! -sleep 1 - exec_slave "./initial_event_test_slave_starter.sh $CLIENT_JSON_FILE $REMAINING_OPTIONS" PID_SERVICE=$! @@ -80,29 +77,27 @@ echo "WAITING FOR SERVICE AVAILABILITY" wait $PID_AVAILABILITY_CHECKER echo "ALL SERVICES ARE AVAILABLE NOW" -sleep 2 - -./initial_event_test_client 9001 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9001 $REMAINING_OPTIONS & CLIENT_PID_ONE=$! -./initial_event_test_client 9002 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9002 $REMAINING_OPTIONS & CLIENT_PID_TWO=$! -./initial_event_test_client 9003 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9003 $REMAINING_OPTIONS & CLIENT_PID_THREE=$! -./initial_event_test_client 9004 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9004 $REMAINING_OPTIONS & CLIENT_PID_FOUR=$! -./initial_event_test_client 9005 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9005 $REMAINING_OPTIONS & CLIENT_PID_FIVE=$! -./initial_event_test_client 9006 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9006 $REMAINING_OPTIONS & CLIENT_PID_SIX=$! -./initial_event_test_client 9007 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9007 $REMAINING_OPTIONS & CLIENT_PID_SEVEN=$! -./initial_event_test_client 9008 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9008 $REMAINING_OPTIONS & CLIENT_PID_EIGHT=$! -./initial_event_test_client 9009 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9009 $REMAINING_OPTIONS & CLIENT_PID_NINE=$! -./initial_event_test_client 9010 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9010 $REMAINING_OPTIONS & CLIENT_PID_TEN=$! -./initial_event_test_client 9011 STRICT_CHECKING $REMAINING_OPTIONS & +./initial_event_test_client 9011 $REMAINING_OPTIONS & CLIENT_PID_ELEVEN=$! # Wait until all clients are finished @@ -120,21 +115,21 @@ wait $CLIENT_PID_TEN || FAIL=$(($FAIL+1)) wait $CLIENT_PID_ELEVEN || FAIL=$(($FAIL+1)) # wait until all clients exited on slave side -./initial_event_test_stop_service MASTER & -PID_STOP_SERVICE=$! -wait $PID_STOP_SERVICE +./initial_event_test_stop_service MASTER || FAIL=$(($FAIL+1)) -# shutdown the first client +# shutdown all clients/services kill $FIRST_PID -wait $FIRST_PID || FAIL=$(($FAIL+1)) +kill $PID_SERVICE_THREE +kill $PID_SERVICE_TWO +# wait for slave wait $PID_SERVICE || FAIL=$(($FAIL+1)) -# shutdown the services -kill $PID_SERVICE_THREE +wait $FIRST_PID || FAIL=$(($FAIL+1)) wait $PID_SERVICE_THREE || FAIL=$(($FAIL+1)) -kill $PID_SERVICE_TWO wait $PID_SERVICE_TWO || FAIL=$(($FAIL+1)) + +# after everything, because this application is the router kill $PID_SERVICE_ONE wait $PID_SERVICE_ONE || FAIL=$(($FAIL+1)) diff --git a/test/network_tests/initial_event_tests/conf/initial_event_test_slave_starter.sh.in b/test/network_tests/initial_event_tests/conf/initial_event_test_slave_starter.sh.in index aa41168d6..8ef5689cf 100755 --- a/test/network_tests/initial_event_tests/conf/initial_event_test_slave_starter.sh.in +++ b/test/network_tests/initial_event_tests/conf/initial_event_test_slave_starter.sh.in @@ -31,9 +31,10 @@ REMAINING_OPTIONS=$@ FAIL=0 +# Start the services export VSOMEIP_CONFIGURATION=$PASSED_JSON_FILE -# Start the services +# NOTE: this application does routing! export VSOMEIP_APPLICATION_NAME=initial_event_test_service_four ./initial_event_test_service 4 $REMAINING_OPTIONS & PID_SERVICE_FOUR=$! @@ -46,8 +47,6 @@ export VSOMEIP_APPLICATION_NAME=initial_event_test_service_six ./initial_event_test_service 6 $REMAINING_OPTIONS & PID_SERVICE_SIX=$! -sleep 3 - unset VSOMEIP_APPLICATION_NAME # Array for client pids @@ -66,16 +65,12 @@ REMAINING_OPTIONS=${REMAINING_OPTIONS#SUBSCRIBE_ONLY_ONE} # Start availability checker in order to wait until the services on the remote # were started as well export VSOMEIP_APPLICATION_NAME=slave_initial_event_test_availability_checker -./initial_event_test_availability_checker 1235 $REMAINING_OPTIONS & -PID_AVAILABILITY_CHECKER=$! +./initial_event_test_availability_checker 1235 $REMAINING_OPTIONS || FAIL=$(($FAIL+1)) -# wait until the services on the remote node were started as well -wait $PID_AVAILABILITY_CHECKER -sleep 2 for client_number in $(seq 9014 9024) do export VSOMEIP_APPLICATION_NAME="slave_initial_event_test_$client_number" - ./initial_event_test_client $client_number STRICT_CHECKING $REMAINING_OPTIONS & + ./initial_event_test_client $client_number $REMAINING_OPTIONS & CLIENT_PIDS+=($!) done @@ -89,19 +84,18 @@ done echo "Starting stop service | Slave" # wait until all clients exited on master side export VSOMEIP_APPLICATION_NAME=slave_initial_event_test_stop_service -./initial_event_test_stop_service SLAVE & -PID_STOP_SERVICE=$! -wait $PID_STOP_SERVICE +./initial_event_test_stop_service SLAVE || FAIL=$(($FAIL+1)) -# shutdown the first client +# shutdown all clients/services kill $FIRST_PID -wait $FIRST_PID || FAIL=$(($FAIL+1)) - -# shutdown the services kill $PID_SERVICE_SIX -wait $PID_SERVICE_SIX || FAIL=$(($FAIL+1)) kill $PID_SERVICE_FIVE + +wait $FIRST_PID || FAIL=$(($FAIL+1)) +wait $PID_SERVICE_SIX || FAIL=$(($FAIL+1)) wait $PID_SERVICE_FIVE || FAIL=$(($FAIL+1)) + +# after everything, because this application is the router kill $PID_SERVICE_FOUR wait $PID_SERVICE_FOUR || FAIL=$(($FAIL+1)) diff --git a/test/network_tests/initial_event_tests/initial_event_boardnet_test_manager.cpp b/test/network_tests/initial_event_tests/initial_event_boardnet_test_manager.cpp index f69e81048..40c2f9f46 100644 --- a/test/network_tests/initial_event_tests/initial_event_boardnet_test_manager.cpp +++ b/test/network_tests/initial_event_tests/initial_event_boardnet_test_manager.cpp @@ -158,17 +158,19 @@ TEST(someip_initial_boardnet_event_test, wait_for_initial_events_of_all_services // Clear up service sync data service_provider.reset(); // Restart host - host.reset(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); + host.run(); service_provider.wait_for_registration(); service_provider.wait_for_subscription(); EXPECT_TRUE(service_provider.wait_for_message()) << "Client didn't received initial event after host restart"; // Wait for client process exit and test process exit code. - slave.join(); - EXPECT_EQ(slave.exit_code_, 0); + EXPECT_EQ(slave.wait(), 0); - host.terminate(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); } #if defined(__linux__) || defined(__QNX__) diff --git a/test/network_tests/initial_event_tests/initial_event_test_client.cpp b/test/network_tests/initial_event_tests/initial_event_test_client.cpp index bdbc982c6..e3b5dc882 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_client.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_client.cpp @@ -27,15 +27,13 @@ class initial_event_test_client { public: - initial_event_test_client(int _client_number, bool _service_offered_tcp_and_udp, - std::array _service_infos, bool _subscribe_on_available, - std::uint32_t _events_to_subscribe, bool _initial_event_strict_checking, bool _dont_exit, - bool _subscribe_only_one, vsomeip::reliability_type_e _reliability_type, bool _client_subscribes_twice) : - client_number_(_client_number), service_infos_(_service_infos), service_offered_tcp_and_udp_(_service_offered_tcp_and_udp), - app_(vsomeip::runtime::get()->create_application()), wait_for_stop_(true), is_first(true), - subscribe_on_available_(_subscribe_on_available), events_to_subscribe_(_events_to_subscribe), - initial_event_strict_checking_(_initial_event_strict_checking), dont_exit_(_dont_exit), subscribe_only_one_(_subscribe_only_one), - reliability_type_(_reliability_type), client_subscribes_twice_(_client_subscribes_twice) { + initial_event_test_client(int _client_number, std::array _service_infos, + bool _subscribe_on_available, std::uint32_t _events_to_subscribe, bool _dont_exit, bool _subscribe_only_one, + vsomeip::reliability_type_e _reliability_type, bool _client_subscribes_twice) : + client_number_(_client_number), service_infos_(_service_infos), app_(vsomeip::runtime::get()->create_application()), + wait_for_stop_(true), is_first(true), subscribe_on_available_(_subscribe_on_available), events_to_subscribe_(_events_to_subscribe), + dont_exit_(_dont_exit), subscribe_only_one_(_subscribe_only_one), reliability_type_(_reliability_type), + client_subscribes_twice_(_client_subscribes_twice) { if (!app_->init()) { ADD_FAILURE() << "Couldn't initialize application"; return; @@ -211,15 +209,9 @@ class initial_event_test_client { } } } else { - if (!service_offered_tcp_and_udp_) { - std::scoped_lock its_lock(received_notifications_mutex_); - if (all_notifications_received()) { - notify = true; - } - } else { - if (all_notifications_received_tcp_and_udp()) { - notify = true; - } + std::scoped_lock its_lock(received_notifications_mutex_); + if (all_notifications_received()) { + notify = true; } } @@ -235,28 +227,14 @@ class initial_event_test_client { return std::all_of(other_services_received_notification_.cbegin(), other_services_received_notification_.cend(), [&](const std::map, std::uint32_t>::value_type& v) { bool result; - if (v.second == initial_event_test::notifications_to_send) { + // NOTE: can receive multiple initial notifications; see ff0d2ae2 + if (v.second >= initial_event_test::notifications_to_send) { result = true; } else { - if (v.second >= initial_event_test::notifications_to_send) { - VSOMEIP_WARNING << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " - << " Received multiple initial events from service/instance: " << std::setw(4) - << v.first.first << "." << std::setw(4) << v.first.second - << " number of received events: " << v.second - << ". This is caused by StopSubscribe/Subscribe messages and/or" - << " service offered via UDP and TCP"; - if (initial_event_strict_checking_) { - ADD_FAILURE() << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " - << " Received multiple initial events from " - "service/instance: " - << std::setw(4) << v.first.first << "." << std::setw(4) << v.first.second - << " number of received events: " << v.second; - } - result = initial_event_strict_checking_ ? false : true; - - } else { - result = false; - } + VSOMEIP_INFO << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " + << "Still missing initial events from service/instance: " << std::setw(4) << v.first.first + << "." << std::setw(4) << v.first.second << " number of received events: " << v.second; + result = false; } return result; @@ -267,75 +245,19 @@ class initial_event_test_client { return std::all_of(other_services_received_notification_.cbegin(), other_services_received_notification_.cend(), [&](const std::map, std::uint32_t>::value_type& v) { bool result; - if (v.second == initial_event_test::notifications_to_send * 2) { + // NOTE: can receive multiple initial notifications; see ff0d2ae2 + if (v.second >= initial_event_test::notifications_to_send * 2) { result = true; } else { - if (v.second >= initial_event_test::notifications_to_send * 2) { - VSOMEIP_WARNING << __func__ << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ - << "] " - << " Received multiple initial events from service/instance: " << std::setw(4) - << v.first.first << "." << std::setw(4) << v.first.second - << " number of received events: " << v.second - << ". This is caused by StopSubscribe/Subscribe messages and/or" - << " service offered via UDP and TCP"; - if (initial_event_strict_checking_) { - ADD_FAILURE() << __func__ << "[" << std::hex << std::setfill('0') << std::setw(4) - << client_number_ << "] " - << " Received multiple initial events from " - "service/instance: " - << std::setw(4) << v.first.first << "." << std::setw(4) << v.first.second - << " number of received events: " << v.second; - } - result = initial_event_strict_checking_ ? false : true; - - } else { - result = false; - } + VSOMEIP_INFO << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " + << "Still missing initial events from service/instance: " << std::setw(4) << v.first.first + << "." << std::setw(4) << v.first.second << " number of received events: " << v.second; + result = false; } return result; }); } - bool all_notifications_received_tcp_and_udp() { - std::scoped_lock its_lock(received_notifications_mutex_); - std::uint32_t received_twice(0); - std::uint32_t received_normal(0); - for (const auto& v : other_services_received_notification_) { - if (!initial_event_strict_checking_ && v.second > initial_event_test::notifications_to_send * 2) { - VSOMEIP_WARNING << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " - << " Received multiple initial events from service/instance: " << std::setw(4) << v.first.first << "." - << std::setw(4) << v.first.second << ". This is caused by StopSubscribe/Subscribe messages and/or" - << " service offered via UDP and TCP"; - received_twice++; - } else if (initial_event_strict_checking_ && v.second > initial_event_test::notifications_to_send * 2) { - ADD_FAILURE() << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " - << " Received multiple initial events from service/instance: " << std::setw(4) << v.first.first << "." - << std::setw(4) << v.first.second << " number of received events: " << v.second; - } else if (v.second == initial_event_test::notifications_to_send * 2) { - received_twice++; - } else if (v.second == initial_event_test::notifications_to_send) { - received_normal++; - } - } - - if (received_twice == ((service_infos_.size() - 1) * events_to_subscribe_) / 2 - && received_normal == ((service_infos_.size() - 1) * events_to_subscribe_) / 2) { - // routing manager stub receives the notification - // - twice from external nodes - // - and normal from all internal nodes - VSOMEIP_ERROR << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " - << "Received notifications:" - << " Normal: " << received_normal << " Twice: " << received_twice; - return true; - } else if (initial_event_strict_checking_ && (received_twice > ((service_infos_.size() - 1) * events_to_subscribe_) / 2)) { - ADD_FAILURE() << "[" << std::hex << std::setfill('0') << std::setw(4) << client_number_ << "] " - << " Received too much initial events twice: " << received_twice; - } else if (received_normal == (events_to_subscribe_ * (service_infos_.size() - 1))) { - return true; - } - return false; - } - void wait_for_signal() { sigset_t set; sigemptyset(&set); @@ -385,7 +307,6 @@ class initial_event_test_client { private: int client_number_; std::array service_infos_; - bool service_offered_tcp_and_udp_; std::shared_ptr app_; std::map, bool> other_services_available_; std::mutex received_notifications_mutex_; @@ -396,7 +317,6 @@ class initial_event_test_client { bool subscribe_on_available_; std::uint32_t events_to_subscribe_; - bool initial_event_strict_checking_; bool dont_exit_; bool subscribe_only_one_; @@ -410,11 +330,9 @@ class initial_event_test_client { }; static int client_number; -static bool service_offered_tcp_and_udp; static bool use_same_service_id; static bool subscribe_on_available; static std::uint32_t subscribe_multiple_events; -static bool initial_event_strict_checking; static bool dont_exit; static bool subscribe_only_one; static bool client_subscribes_twice; @@ -423,13 +341,13 @@ vsomeip::reliability_type_e reliability_type = vsomeip::reliability_type_e::RT_U TEST(someip_initial_event_test, wait_for_initial_events_of_all_services) { if (use_same_service_id) { - initial_event_test_client its_sample(client_number, service_offered_tcp_and_udp, initial_event_test::service_infos_same_service_id, - subscribe_on_available, subscribe_multiple_events, initial_event_strict_checking, dont_exit, - subscribe_only_one, reliability_type, client_subscribes_twice); + initial_event_test_client its_sample(client_number, initial_event_test::service_infos_same_service_id, subscribe_on_available, + subscribe_multiple_events, dont_exit, subscribe_only_one, reliability_type, + client_subscribes_twice); } else { - initial_event_test_client its_sample(client_number, service_offered_tcp_and_udp, initial_event_test::service_infos, - subscribe_on_available, subscribe_multiple_events, initial_event_strict_checking, dont_exit, - subscribe_only_one, reliability_type, client_subscribes_twice); + initial_event_test_client its_sample(client_number, initial_event_test::service_infos, subscribe_on_available, + subscribe_multiple_events, dont_exit, subscribe_only_one, reliability_type, + client_subscribes_twice); } } @@ -450,9 +368,6 @@ int main(int argc, char** argv) { std::cerr << "Please specify a client number, like: " << argv[0] << " 2 SUBSCRIBE_BEFORE_START SAME_SERVICE_ID" << std::endl; std::cerr << "Valid client numbers are from 0 to 0xFFFF" << std::endl; std::cerr << "After client number one/multiple of these flags can be specified:"; - std::cerr << " - SERVICE_OFFERED_TCP_AND_UDP flag. Set this if the service is offered via " - "TCP and UDP" - << std::endl; std::cerr << " - Time of subscription, valid values: [SUBSCRIBE_ON_AVAILABILITY, " "SUBSCRIBE_BEFORE_START], default SUBSCRIBE_BEFORE_START" << std::endl; @@ -462,10 +377,6 @@ int main(int argc, char** argv) { std::cerr << " - MULTIPLE_EVENTS flag. If set the test will subscribe to multiple events " "in the eventgroup, default false" << std::endl; - std::cerr << " - STRICT_CHECKING flag. If set the test will only successfully finish if " - "exactly the number of initial events were received (and not more). Default " - "false" - << std::endl; std::cerr << " - DONT_EXIT flag. If set the test will not exit if all notifications have " "been received. Default false" << std::endl; @@ -478,8 +389,6 @@ int main(int argc, char** argv) { client_number = std::stoi(std::string(argv[1]), nullptr); subscribe_on_available = false; - initial_event_strict_checking = false; - service_offered_tcp_and_udp = false; use_same_service_id = false; subscribe_multiple_events = 1; dont_exit = false; @@ -499,9 +408,6 @@ int main(int argc, char** argv) { } else if (std::string("MULTIPLE_EVENTS") == std::string(argv[i])) { subscribe_multiple_events = 5; std::cout << "Subscribing to multiple events" << std::endl; - } else if (std::string("STRICT_CHECKING") == std::string(argv[i])) { - initial_event_strict_checking = true; - std::cout << "Checking if the number of events received is correct" << std::endl; } else if (std::string("DONT_EXIT") == std::string(argv[i])) { dont_exit = true; std::cout << "Waiting for all notifications to be received" << std::endl; diff --git a/test/network_tests/initial_event_tests/initial_event_test_globals.hpp b/test/network_tests/initial_event_tests/initial_event_test_globals.hpp index 898f6bc9b..c749e611b 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_globals.hpp +++ b/test/network_tests/initial_event_tests/initial_event_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ -#define SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ +#pragma once namespace initial_event_test { @@ -44,5 +43,3 @@ static constexpr service_info stop_service_slave = {0x9999, 0x1, 0x9999, 0x0, 0x static constexpr int notifications_to_send = 1; } - -#endif /* SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/initial_event_tests/initial_event_test_service.cpp b/test/network_tests/initial_event_tests/initial_event_test_service.cpp index 0627a8fda..421e0fc77 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_service.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_service.cpp @@ -194,8 +194,7 @@ int main(int argc, char** argv) { reliability_type = vsomeip::reliability_type_e::RT_BOTH; std::cout << "Using reliability type RT_BOTH" << std::endl; } else if (std::string("SUBSCRIBE_ON_AVAILABILITY") == std::string(argv[i]) - || std::string("SUBSCRIBE_BEFORE_START") == std::string(argv[i]) - || std::string("STRICT_CHECKING") == std::string(argv[i]) || std::string("DONT_EXIT") == std::string(argv[i]) + || std::string("SUBSCRIBE_BEFORE_START") == std::string(argv[i]) || std::string("DONT_EXIT") == std::string(argv[i]) || std::string("SUBSCRIBE_ONLY_ONE") == std::string(argv[i]) || std::string("CLIENT_SUBSCRIBES_TWICE") == std::string(argv[i])) { std::cout << std::string(argv[i]) << " will be unused for service" << std::endl; diff --git a/test/network_tests/lazy_load_tests/CMakeLists.txt b/test/network_tests/lazy_load_tests/CMakeLists.txt index 541fe21a0..b137d0003 100644 --- a/test/network_tests/lazy_load_tests/CMakeLists.txt +++ b/test/network_tests/lazy_load_tests/CMakeLists.txt @@ -40,11 +40,6 @@ if (TEST_SECURITY) targets_link_default_libraries("${executables}") targets_add_default_dependencies("${executables}") -# Skip valgrind - if (DEFINED VALGRIND_TYPE AND NOT VALGRIND_TYPE STREQUAL "") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --trace-children-skip=*/lazy_load_test_*,*/routingmanagerd) - endif() - # logs won't be generated for this test as there is one application which # will run as uid:1 gid:1, which is not allowed to write to the log file list(FILTER TEST_ENTRYPOINT EXCLUDE REGEX "^--log-file=") diff --git a/test/network_tests/lazy_load_tests/conf/lazy_load_test_start.sh.in b/test/network_tests/lazy_load_tests/conf/lazy_load_test_start.sh.in index ffbaca0c4..99e056f2f 100755 --- a/test/network_tests/lazy_load_tests/conf/lazy_load_test_start.sh.in +++ b/test/network_tests/lazy_load_tests/conf/lazy_load_test_start.sh.in @@ -21,7 +21,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=/vsomeip/ export VSOMEIP_APPLICATION_NAME=routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=service-sample diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp b/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp index 4d17eea84..52e60ef44 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef LAZY_LOAD_TEST_CLIENT_HPP -#define LAZY_LOAD_TEST_CLIENT_HPP +#pragma once #include #include @@ -55,5 +54,3 @@ class lazy_load_test_client { const std::uint16_t NUMBER_OF_MESSAGES_TO_SEND = 10; }; - -#endif // LAZY_LOAD_TEST_CLIENT_HPP diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp index 0c16fa1e1..87e076eee 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp @@ -53,10 +53,6 @@ void lazy_load_lazy_client::stop() { VSOMEIP_INFO << "Stopping..."; shutdown_service(); - // magic sleep to give time for the last message to be sent - // TODO: FIXME! REMOVE THIS! - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - app_->clear_all_handler(); app_->stop(); } diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp index d88a823f3..a5b56a2cc 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef LAZY_LOAD_TEST_LAZY_CLIENT_HPP -#define LAZY_LOAD_TEST_LAZY_CLIENT_HPP +#pragma once #include #include @@ -55,5 +54,3 @@ class lazy_load_lazy_client { const std::uint16_t NUMBER_OF_MESSAGES_TO_SEND = 10; }; - -#endif // LAZY_LOAD_TEST_LAZY_CLIENT_HPP diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp b/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp index aedcfab8e..29b64209a 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef LAZY_LOAD_TEST_SERVICE_HPP -#define LAZY_LOAD_TEST_SERVICE_HPP +#pragma once #include #include @@ -49,5 +48,3 @@ class lazy_load_test_service { // Twice as big as messages to send, account for all messages from both clients const std::uint16_t NUMBER_OF_MESSAGES_TO_RECEIVE = 20; }; - -#endif // LAZY_LOAD_TEST_SERVICE_HPP diff --git a/test/network_tests/malicious_data_tests/CMakeLists.txt b/test/network_tests/malicious_data_tests/CMakeLists.txt index 2e4b2d68a..c30b9173f 100644 --- a/test/network_tests/malicious_data_tests/CMakeLists.txt +++ b/test/network_tests/malicious_data_tests/CMakeLists.txt @@ -17,37 +17,13 @@ add_executable(malicious_data_test_service malicious_data_test_service.cpp ) -# Add test executable. -set(service_discovery_sources - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/configuration_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/entry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/eventgroupentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ip_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv4_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv6_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/load_balancing_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_element_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/protection_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/selective_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/serviceentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/unknown_option_impl.cpp -) -set(message_sources - ${CMAKE_SOURCE_DIR}/implementation/message/src/deserializer.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/payload_impl.cpp -) add_executable(malicious_data_test_msg_sender malicious_data_test_msg_sender.cpp - ${service_discovery_sources} - ${message_sources} ) # Link the vsomeip-sd library to the executable. target_link_libraries(malicious_data_test_msg_sender - ${VSOMEIP_NAME}-sd + vsomeip3-sd-test ) # Add build dependencies and link libraries to executables. diff --git a/test/network_tests/malicious_data_tests/conf/malicious_data_test_master_starter.sh.in b/test/network_tests/malicious_data_tests/conf/malicious_data_test_master_starter.sh.in index 8e04840d4..d79d164be 100755 --- a/test/network_tests/malicious_data_tests/conf/malicious_data_test_master_starter.sh.in +++ b/test/network_tests/malicious_data_tests/conf/malicious_data_test_master_starter.sh.in @@ -31,7 +31,7 @@ export VSOMEIP_CONFIGURATION=malicious_data_test_master.json export VSOMEIP_APPLICATION_NAME=routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services diff --git a/test/network_tests/malicious_data_tests/malicious_data_test_globals.hpp b/test/network_tests/malicious_data_tests/malicious_data_test_globals.hpp index a1b1cfff3..8cd0c84e6 100644 --- a/test/network_tests/malicious_data_tests/malicious_data_test_globals.hpp +++ b/test/network_tests/malicious_data_tests/malicious_data_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef MALICIOUS_DATA_TEST_GLOBALS_HPP_ -#define MALICIOUS_DATA_TEST_GLOBALS_HPP_ +#pragma once namespace malicious_data_test { @@ -22,5 +21,3 @@ struct service_info service = {0x3344, 0x1, 0x1111, 0x8002, 0x1, 0x1404, 0x4242} enum test_mode_e { MALICIOUS_EVENTS, PROTOCOL_VERSION, MESSAGE_TYPE, RETURN_CODE, WRONG_HEADER_FIELDS_UDP }; } - -#endif /* MALICIOUS_DATA_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/memory_tests/memory_test_client.hpp b/test/network_tests/memory_tests/memory_test_client.hpp index 374e278da..154eeff29 100644 --- a/test/network_tests/memory_tests/memory_test_client.hpp +++ b/test/network_tests/memory_tests/memory_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef MEMORY_TEST_CLIENT_HPP_ -#define MEMORY_TEST_CLIENT_HPP_ +#pragma once #include #include @@ -37,5 +36,3 @@ class memory_test_client : public vsomeip_utilities::base_vsip_app { void stop_service(); void unsubscribe_all(); }; - -#endif // MEMORY_TEST_CLIENT_HPP_ diff --git a/test/network_tests/memory_tests/memory_test_common.hpp b/test/network_tests/memory_tests/memory_test_common.hpp index b1d8589cf..649944b5f 100644 --- a/test/network_tests/memory_tests/memory_test_common.hpp +++ b/test/network_tests/memory_tests/memory_test_common.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef MEMORY_TEST_COMMON_HPP_ -#define MEMORY_TEST_COMMON_HPP_ +#pragma once #include @@ -28,5 +27,3 @@ constexpr uint16_t TEST_EVENT_NUMBER = 20; constexpr uint16_t TEST_MESSAGE_NUMBER = 9000; constexpr int NOTIFY_PAYLOAD_SIZE = 4000; constexpr double MEMORY_LOAD_LIMIT = 1.15; // meaning 15% limit above the average value - -#endif // MEMORY_TEST_COMMON_HPP_ diff --git a/test/network_tests/memory_tests/memory_test_service.hpp b/test/network_tests/memory_tests/memory_test_service.hpp index 4025ce17b..e1f4cdd56 100644 --- a/test/network_tests/memory_tests/memory_test_service.hpp +++ b/test/network_tests/memory_tests/memory_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef MEMORY_TEST_SERVICE_HPP_ -#define MEMORY_TEST_SERVICE_HPP_ +#pragma once #include #include @@ -35,5 +34,3 @@ class memory_test_service : public vsomeip_utilities::base_vsip_app { void on_stop(const std::shared_ptr /*&_message*/); }; void check_memory(std::vector& test_memory_); - -#endif // MEMORY_TEST_SERVICE_HPP_ diff --git a/test/network_tests/multicast_group_tests/conf/multicast_group_test_client_starter.sh.in b/test/network_tests/multicast_group_tests/conf/multicast_group_test_client_starter.sh.in index 9cdfeeecc..b83f84d7b 100755 --- a/test/network_tests/multicast_group_tests/conf/multicast_group_test_client_starter.sh.in +++ b/test/network_tests/multicast_group_tests/conf/multicast_group_test_client_starter.sh.in @@ -12,7 +12,7 @@ fi # Start client routing host export VSOMEIP_CONFIGURATION=multicast_group_test_client.json export VSOMEIP_APPLICATION_NAME="routingmanagerd-client" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & HOST_PID=$! diff --git a/test/network_tests/multicast_group_tests/conf/multicast_group_test_service_starter.sh.in b/test/network_tests/multicast_group_tests/conf/multicast_group_test_service_starter.sh.in index 0f1af934e..3f15ffdf0 100755 --- a/test/network_tests/multicast_group_tests/conf/multicast_group_test_service_starter.sh.in +++ b/test/network_tests/multicast_group_tests/conf/multicast_group_test_service_starter.sh.in @@ -15,7 +15,7 @@ export VSOMEIP_CONFIGURATION=multicast_group_test_service.json # Start the routing manager. export VSOMEIP_APPLICATION_NAME="routingmanagerd-service" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & DAEMON_PID=$! # Start the test service. diff --git a/test/network_tests/npdu_tests/CMakeLists.txt b/test/network_tests/npdu_tests/CMakeLists.txt index db23a0f66..3005991b6 100644 --- a/test/network_tests/npdu_tests/CMakeLists.txt +++ b/test/network_tests/npdu_tests/CMakeLists.txt @@ -69,7 +69,7 @@ if(NOT TESTS_BAT AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") # Link executables to vsomeip-cfg. foreach(target ${executables}) - target_link_libraries(${target} ${VSOMEIP_NAME}-cfg) + target_link_libraries(${target} ${VSOMEIP_NAME}-cfg-test) endforeach() # Add custom test command. diff --git a/test/network_tests/npdu_tests/npdu_test_client.hpp b/test/network_tests/npdu_tests/npdu_test_client.hpp index 037b91f9a..a343523a0 100644 --- a/test/network_tests/npdu_tests/npdu_test_client.hpp +++ b/test/network_tests/npdu_tests/npdu_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef NPDUTESTCLIENT_HPP_ -#define NPDUTESTCLIENT_HPP_ +#pragma once #include @@ -93,5 +92,3 @@ class npdu_test_client { std::array finished_; std::thread finished_waiter_; }; - -#endif /* NPDUTESTCLIENT_HPP_ */ diff --git a/test/network_tests/npdu_tests/npdu_test_globals.hpp b/test/network_tests/npdu_tests/npdu_test_globals.hpp index a5af01f41..17054c0f5 100644 --- a/test/network_tests/npdu_tests/npdu_test_globals.hpp +++ b/test/network_tests/npdu_tests/npdu_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef NPDU_TESTS_NPDU_TEST_GLOBALS_HPP_ -#define NPDU_TESTS_NPDU_TEST_GLOBALS_HPP_ +#pragma once namespace npdu_test { @@ -34,4 +33,3 @@ constexpr std::array client_ids_clients = {0x1111, 0x2222, constexpr std::array client_ids_services = service_ids; } -#endif /* NPDU_TESTS_NPDU_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/npdu_tests/npdu_test_rmd.hpp b/test/network_tests/npdu_tests/npdu_test_rmd.hpp index 98e66a8f0..1d8c65ab4 100644 --- a/test/network_tests/npdu_tests/npdu_test_rmd.hpp +++ b/test/network_tests/npdu_tests/npdu_test_rmd.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef NPDU_TESTS_NPDUTESTROUTINGMANAGERDAEMON_HPP_ -#define NPDU_TESTS_NPDUTESTROUTINGMANAGERDAEMON_HPP_ +#pragma once #include @@ -37,5 +36,3 @@ class npdu_test_rmd { std::thread offer_thread_; std::thread shutdown_thread_; }; - -#endif /* NPDU_TESTS_NPDUTESTROUTINGMANAGERDAEMON_HPP_ */ diff --git a/test/network_tests/npdu_tests/npdu_test_service.hpp b/test/network_tests/npdu_tests/npdu_test_service.hpp index c1b8c14ce..4c7e9f7cc 100644 --- a/test/network_tests/npdu_tests/npdu_test_service.hpp +++ b/test/network_tests/npdu_tests/npdu_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef NPDUTESTSERVICE_HPP_ -#define NPDUTESTSERVICE_HPP_ +#pragma once #include #include @@ -60,5 +59,3 @@ class npdu_test_service { std::thread offer_thread_; std::thread shutdown_thread_; }; - -#endif /* NPDUTESTSERVICE_HPP_ */ diff --git a/test/network_tests/offer_stop_offer_test/applications/client.hpp b/test/network_tests/offer_stop_offer_test/applications/client.hpp index 1e6c50df2..06bd6fb0c 100644 --- a/test/network_tests/offer_stop_offer_test/applications/client.hpp +++ b/test/network_tests/offer_stop_offer_test/applications/client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CLIENT_HPP -#define VSOMEIP_CLIENT_HPP +#pragma once #include #include @@ -96,5 +95,3 @@ class client_t { /// client_request_t are removed after the response is received and promise is set. std::list pending_requests; }; - -#endif // VSOMEIP_CLIENT_HPP diff --git a/test/network_tests/offer_stop_offer_test/applications/service.hpp b/test/network_tests/offer_stop_offer_test/applications/service.hpp index e563c2369..52bd0a950 100644 --- a/test/network_tests/offer_stop_offer_test/applications/service.hpp +++ b/test/network_tests/offer_stop_offer_test/applications/service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_SERVICE_HPP -#define VSOMEIP_SERVICE_HPP +#pragma once #include #include @@ -96,5 +95,3 @@ class service_t { std::atomic app_registration_state; }; - -#endif // VSOMEIP_SERVICE_HPP diff --git a/test/network_tests/offer_stop_offer_test/applications/service_ids.hpp b/test/network_tests/offer_stop_offer_test/applications/service_ids.hpp index cb9e3e9fb..7bf00c431 100644 --- a/test/network_tests/offer_stop_offer_test/applications/service_ids.hpp +++ b/test/network_tests/offer_stop_offer_test/applications/service_ids.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_SERVICE_IDS_HPP -#define VSOMEIP_SERVICE_IDS_HPP +#pragma once #include @@ -31,5 +30,3 @@ constexpr vsomeip::event_t EVENT_ID = 0x8778; /// @brief Both services eventgroup id constexpr vsomeip::eventgroup_t EVENTGROUP_ID = 0x4465; - -#endif // VSOMEIP_EXAMPLES_IDS_HPP diff --git a/test/network_tests/offer_stop_offer_test/conf/offer_stop_offer_test_service_starter.sh.in b/test/network_tests/offer_stop_offer_test/conf/offer_stop_offer_test_service_starter.sh.in index 5ff5d3ee4..a98d4182f 100755 --- a/test/network_tests/offer_stop_offer_test/conf/offer_stop_offer_test_service_starter.sh.in +++ b/test/network_tests/offer_stop_offer_test/conf/offer_stop_offer_test_service_starter.sh.in @@ -14,7 +14,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=offer_stop_offer_test_service.json export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & HOST_PID=$! # start service app diff --git a/test/network_tests/offer_stop_offer_test/offer_stop_offer_test_helper.hpp b/test/network_tests/offer_stop_offer_test/offer_stop_offer_test_helper.hpp index 9dba22f2a..f2a0dad69 100644 --- a/test/network_tests/offer_stop_offer_test/offer_stop_offer_test_helper.hpp +++ b/test/network_tests/offer_stop_offer_test/offer_stop_offer_test_helper.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef TEST_OFFER_STOP_OFFER_HELPER_HPP -#define TEST_OFFER_STOP_OFFER_HELPER_HPP +#pragma once #include @@ -20,5 +19,3 @@ constexpr auto SERVICE_STOP_OFFER_TIME = std::chrono::milliseconds(2); /// @brief Time for which the client application is active constexpr auto CLIENT_UP_TIME = std::chrono::seconds(10); - -#endif // TEST_OFFER_STOP_OFFER_HELPER_HPP diff --git a/test/network_tests/offer_tests/CMakeLists.txt b/test/network_tests/offer_tests/CMakeLists.txt index f11588f1f..248dead1d 100644 --- a/test/network_tests/offer_tests/CMakeLists.txt +++ b/test/network_tests/offer_tests/CMakeLists.txt @@ -21,29 +21,6 @@ set(configuration_files ) configure_files("${configuration_files}") -# Add test executable. -set(service_discovery_sources - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/configuration_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/entry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/eventgroupentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ip_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv4_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv6_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/load_balancing_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_element_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/protection_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/selective_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/serviceentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/unknown_option_impl.cpp -) -set(message_sources - ${CMAKE_SOURCE_DIR}/implementation/message/src/deserializer.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/payload_impl.cpp -) - # Add test executable. add_executable(offer_test_service offer_test_service.cpp @@ -67,10 +44,11 @@ add_executable(offer_test_service_external # Add test executable. add_executable(offer_test_external_sd_msg_sender offer_test_external_sd_msg_sender.cpp - ${service_discovery_sources} - ${message_sources} ) +# offer_test_external_sd_msg_sender.cpp directly uses some sd symbols +target_link_libraries(offer_test_external_sd_msg_sender vsomeip3-sd-test) + # Add test executable. add_executable(offer_test_big_sd_msg_service offer_test_big_sd_msg_service.cpp diff --git a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master_starter.sh.in b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master_starter.sh.in index 0a08060b1..765b70760 100755 --- a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master_starter.sh.in +++ b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_master_starter.sh.in @@ -20,7 +20,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=offer_test_big_sd_msg_master.json # start daemon export VSOMEIP_APPLICATION_NAME="client-routingmanager" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME="client-sample" diff --git a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave_starter.sh.in b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave_starter.sh.in index 4684d3c14..7f7e9e270 100755 --- a/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave_starter.sh.in +++ b/test/network_tests/offer_tests/conf/offer_test_big_sd_msg_slave_starter.sh.in @@ -21,7 +21,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=offer_test_big_sd_msg_slave.json # start daemon export VSOMEIP_APPLICATION_NAME="service-routingmanager" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services diff --git a/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in b/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in index 5cce3dfbc..843c3027f 100755 --- a/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in +++ b/test/network_tests/offer_tests/conf/offer_test_external_master_starter.sh.in @@ -27,7 +27,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=offer_test_external_master.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanager" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services export VSOMEIP_APPLICATION_NAME="service-sample" @@ -61,7 +61,7 @@ wait $PID_VSOMEIPD || FAIL=$(($FAIL+1)) export VSOMEIP_CONFIGURATION=offer_test_external_master.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanager" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services export VSOMEIP_APPLICATION_NAME="service-sample" diff --git a/test/network_tests/offer_tests/conf/offer_test_external_slave_starter.sh.in b/test/network_tests/offer_tests/conf/offer_test_external_slave_starter.sh.in index 8b5368f47..94c162dc0 100755 --- a/test/network_tests/offer_tests/conf/offer_test_external_slave_starter.sh.in +++ b/test/network_tests/offer_tests/conf/offer_test_external_slave_starter.sh.in @@ -21,7 +21,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=offer_test_external_slave.json export VSOMEIP_APPLICATION_NAME="service-external-routingmanager" # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services diff --git a/test/network_tests/offer_tests/conf/offer_test_local_starter.sh.in b/test/network_tests/offer_tests/conf/offer_test_local_starter.sh.in index fa7050571..fa51fd38c 100755 --- a/test/network_tests/offer_tests/conf/offer_test_local_starter.sh.in +++ b/test/network_tests/offer_tests/conf/offer_test_local_starter.sh.in @@ -80,7 +80,7 @@ End-of-message export VSOMEIP_CONFIGURATION=offer_test_local.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services @@ -134,7 +134,7 @@ End-of-message export VSOMEIP_CONFIGURATION=offer_test_local.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the service export VSOMEIP_APPLICATION_NAME="service-2" @@ -195,7 +195,7 @@ End-of-message export VSOMEIP_CONFIGURATION=offer_test_local.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the service export VSOMEIP_APPLICATION_NAME="service-2" @@ -207,7 +207,9 @@ export VSOMEIP_APPLICATION_NAME="client-1" ./offer_test_client METHODCALL & CLIENT_PID_ONE=$! -sleep 1 +# wait until service is available.. +export VSOMEIP_APPLICATION_NAME="wua" +wait-until-available 0x1111 || FAIL=$(($FAIL+1)) # Pause the service kill -STOP $PID_SERVICE_TWO @@ -259,7 +261,7 @@ End-of-message export VSOMEIP_CONFIGURATION=offer_test_local.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the service export VSOMEIP_APPLICATION_NAME="service-2" @@ -271,8 +273,11 @@ export VSOMEIP_APPLICATION_NAME="client-1" ./offer_test_client METHODCALL & CLIENT_PID_ONE=$! -# Pause the service -sleep 1 + +# wait until service is available.. +export VSOMEIP_APPLICATION_NAME="wua" +wait-until-available 0x1111 || FAIL=$(($FAIL+1)) +# then pause service kill -STOP $PID_SERVICE_TWO # reoffer the service diff --git a/test/network_tests/offer_tests/offer_test_big_sd_msg_client.cpp b/test/network_tests/offer_tests/offer_test_big_sd_msg_client.cpp index c1befa81f..04988770f 100644 --- a/test/network_tests/offer_tests/offer_test_big_sd_msg_client.cpp +++ b/test/network_tests/offer_tests/offer_test_big_sd_msg_client.cpp @@ -151,7 +151,6 @@ class offer_test_big_sd_msg_client { condition_.wait(its_lock, [this] { return !wait_until_service_available_; }); condition_.wait(its_lock, [this] { return !wait_until_subscribed_; }); - std::this_thread::sleep_for(std::chrono::seconds(3)); std::shared_ptr its_req = vsomeip::runtime::get()->create_request(); its_req->set_service(1); its_req->set_instance(1); diff --git a/test/network_tests/offer_tests/offer_test_globals.hpp b/test/network_tests/offer_tests/offer_test_globals.hpp index 3c85459a9..7ad430b93 100644 --- a/test/network_tests/offer_tests/offer_test_globals.hpp +++ b/test/network_tests/offer_tests/offer_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef OFFER_TEST_GLOBALS_HPP_ -#define OFFER_TEST_GLOBALS_HPP_ +#pragma once namespace offer_test { @@ -23,5 +22,3 @@ static constexpr std::uint16_t big_msg_number_services = 300; static constexpr vsomeip::event_t big_msg_event_id = 0x8000; static constexpr vsomeip::eventgroup_t big_msg_eventgroup_id = 0x1; } - -#endif /* OFFER_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp b/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp index f770dfee4..9cd693356 100644 --- a/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp +++ b/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp @@ -235,10 +235,6 @@ class offered_services_info_test_client { std::unique_lock its_lock(stop_mutex_); stop_condition_.wait(its_lock, [this] { return !wait_for_stop_; }); - // magic sleep to give time for the last message to be sent - // TODO: FIXME! REMOVE THIS! - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - VSOMEIP_INFO << "going down"; app_->clear_all_handler(); app_->stop(); diff --git a/test/network_tests/offered_services_info_tests/offered_services_info_test_globals.hpp b/test/network_tests/offered_services_info_tests/offered_services_info_test_globals.hpp index 927552d0f..7bdfd1250 100644 --- a/test/network_tests/offered_services_info_tests/offered_services_info_test_globals.hpp +++ b/test/network_tests/offered_services_info_tests/offered_services_info_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef OFFER_TEST_GLOBALS_HPP_ -#define OFFER_TEST_GLOBALS_HPP_ +#pragma once namespace offer_test { @@ -25,5 +24,3 @@ uint8_t num_remote_offered_services = 3; struct service_info service = {0x1111, 0x1, 0x1111, 0x1111, 0x1000, 0x0404, 0x1404}; struct service_info remote_service = {0x2222, 0x2, 0x2222, 0x2222, 0x2000, 0x0808, 0x2808}; } - -#endif /* OFFER_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/payload_tests/payload_test_client.hpp b/test/network_tests/payload_tests/payload_test_client.hpp index 14b0a6ddf..fca78cfbb 100644 --- a/test/network_tests/payload_tests/payload_test_client.hpp +++ b/test/network_tests/payload_tests/payload_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef PAYLOADTESTCLIENT_HPP_ -#define PAYLOADTESTCLIENT_HPP_ +#pragma once #include @@ -64,5 +63,3 @@ class payload_test_client { std::thread sender_; }; - -#endif /* PAYLOADTESTCLIENT_HPP_ */ diff --git a/test/network_tests/payload_tests/payload_test_service.hpp b/test/network_tests/payload_tests/payload_test_service.hpp index c07ffb5bd..548b5dd29 100644 --- a/test/network_tests/payload_tests/payload_test_service.hpp +++ b/test/network_tests/payload_tests/payload_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef PAYLOADTESTSERVICE_HPP_ -#define PAYLOADTESTSERVICE_HPP_ +#pragma once #include #include @@ -41,5 +40,3 @@ class payload_test_service { std::uint32_t number_of_received_messages_; std::thread offer_thread_; }; - -#endif /* PAYLOADTESTSERVICE_HPP_ */ diff --git a/test/network_tests/payload_tests/stopwatch.hpp b/test/network_tests/payload_tests/stopwatch.hpp index 0f993731c..b2e919297 100644 --- a/test/network_tests/payload_tests/stopwatch.hpp +++ b/test/network_tests/payload_tests/stopwatch.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef STOP_WATCH_H_ -#define STOP_WATCH_H_ +#pragma once #include @@ -42,4 +41,4 @@ class stop_watch { usec_t total_elapsed_; }; -#endif // STOP_WATCH_H_ +#pragma once diff --git a/test/network_tests/pending_subscription_tests/CMakeLists.txt b/test/network_tests/pending_subscription_tests/CMakeLists.txt index f8e1cd0cc..0c3b062bc 100644 --- a/test/network_tests/pending_subscription_tests/CMakeLists.txt +++ b/test/network_tests/pending_subscription_tests/CMakeLists.txt @@ -18,35 +18,14 @@ add_executable(pending_subscription_test_service ) # Add test executable. -set(service_discovery_sources - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/configuration_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/entry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/eventgroupentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ip_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv4_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv6_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/load_balancing_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_element_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/protection_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/selective_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/serviceentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/unknown_option_impl.cpp -) -set(message_sources - ${CMAKE_SOURCE_DIR}/implementation/message/src/deserializer.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/payload_impl.cpp -) add_executable(pending_subscription_test_sd_msg_sender pending_subscription_test_sd_msg_sender.cpp - ${service_discovery_sources} - ${message_sources} ) # Link vsomeip-sd to executable. -target_link_libraries(pending_subscription_test_sd_msg_sender ${VSOMEIP_NAME}-sd) +target_link_libraries(pending_subscription_test_sd_msg_sender + vsomeip3-sd-test +) # Add build dependencies and link libraries to executables. set(executables @@ -56,11 +35,6 @@ set(executables targets_add_default_dependencies("${executables}") targets_link_default_libraries("${executables}") -# Skip valgrind -if (DEFINED VALGRIND_TYPE AND NOT VALGRIND_TYPE STREQUAL "") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --trace-children-skip=*/pending_*,*/routingmanagerd) -endif() - # Add custom test command. add_custom_test( NAME pending_subscription_test_subscribe diff --git a/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master_starter.sh.in b/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master_starter.sh.in index 3354e1796..2a79d5b01 100755 --- a/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master_starter.sh.in +++ b/test/network_tests/pending_subscription_tests/conf/pending_subscription_test_master_starter.sh.in @@ -31,7 +31,7 @@ export VSOMEIP_CONFIGURATION=pending_subscription_test_master.json # start daemon export VSOMEIP_APPLICATION_NAME="routingmanagerd" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services diff --git a/test/network_tests/pending_subscription_tests/pending_subscription_test_globals.hpp b/test/network_tests/pending_subscription_tests/pending_subscription_test_globals.hpp index c6757d111..7c6ecc2ad 100644 --- a/test/network_tests/pending_subscription_tests/pending_subscription_test_globals.hpp +++ b/test/network_tests/pending_subscription_tests/pending_subscription_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef PENDING_SUBSCRIPTION_TEST_GLOBALS_HPP_ -#define PENDING_SUBSCRIPTION_TEST_GLOBALS_HPP_ +#pragma once namespace pending_subscription_test { @@ -32,5 +31,3 @@ enum test_mode_e { }; } - -#endif /* PENDING_SUBSCRIPTION_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/regression_tests/climate_test_client.cpp b/test/network_tests/regression_tests/climate_test_client.cpp index 0ae816798..4ed2170f3 100644 --- a/test/network_tests/regression_tests/climate_test_client.cpp +++ b/test/network_tests/regression_tests/climate_test_client.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -69,6 +70,7 @@ class client_sample { VSOMEIP_INFO << "Service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." << _instance << "] is " << (_is_available ? "available." : "NOT available.") << std::endl; + std::scoped_lock lock{mutex_}; availability_handler_calls++; } @@ -87,6 +89,7 @@ class client_sample { } VSOMEIP_INFO << its_message.str(); + std::scoped_lock lock{mutex_}; if ((its_payload->get_length() % 5) == 0) { notifications_received++; if (notifications_received == 2) { @@ -110,7 +113,9 @@ class client_sample { } else if (notifications_received == 4) { // All expected notifications received, stop the client and send shutdown message to // service - EXPECT_EQ(availability_handler_calls, 7); + // due to double initial notifications, might be stopping a "bit" early, hence the different number of + // expected availability callbacks + EXPECT_TRUE(availability_handler_calls == 5 || availability_handler_calls == 7); std::shared_ptr its_set = vsomeip::runtime::get()->create_message(); its_set->set_message_type(vsomeip_v3::message_type_e::MT_REQUEST_NO_RETURN); @@ -143,6 +148,7 @@ class client_sample { private: std::shared_ptr app_; struct climate_test::service_info service_info_; + std::mutex mutex_; uint8_t availability_handler_calls = 0; uint8_t notifications_received = 0; }; diff --git a/test/network_tests/regression_tests/climate_test_globals.hpp b/test/network_tests/regression_tests/climate_test_globals.hpp index 59a8b29e0..d4b302204 100644 --- a/test/network_tests/regression_tests/climate_test_globals.hpp +++ b/test/network_tests/regression_tests/climate_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP -#define VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP +#pragma once namespace climate_test { @@ -23,5 +22,3 @@ struct service_info service = {0x1234, 0x5678, 0x0421, 0x8778, 0x4465, 0x0001, 0 constexpr std::chrono::seconds OFFER_CYCLE_INTERVAL = std::chrono::seconds(1); constexpr std::chrono::milliseconds MSG_SEND_WAIT_INTERVAL = std::chrono::milliseconds(500); } - -#endif // VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP diff --git a/test/network_tests/regression_tests/conf/climate_test_slave_starter.sh.in b/test/network_tests/regression_tests/conf/climate_test_slave_starter.sh.in index e190b96cb..954cfdca7 100755 --- a/test/network_tests/regression_tests/conf/climate_test_slave_starter.sh.in +++ b/test/network_tests/regression_tests/conf/climate_test_slave_starter.sh.in @@ -19,7 +19,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=climate_test_slave.json export VSOMEIP_APPLICATION_NAME=routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp b/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp index 66929ff05..709842561 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp @@ -19,10 +19,6 @@ void routing_restart_test_client::stop() { shutdown_service(); - // magic sleep to give time for the last message to be sent - // TODO: FIXME! REMOVE THIS! - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - app_->clear_all_handler(); app_->stop(); if (starter_.joinable()) { @@ -109,9 +105,9 @@ void routing_restart_test_client::run() { { bpi::scoped_lock its_lock(ip_sync->client_mutex_); - restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( + ASSERT_TRUE(restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( ip_sync->client_cv_, its_lock, 10, ip_sync->sending_status_, - restart_routing::restart_routing_test_interprocess_sync::sending_status::SEND_MESSAGES); + restart_routing::restart_routing_test_interprocess_sync::sending_status::SEND_MESSAGES)); } std::uint32_t its_sent_requests(0); @@ -145,10 +141,9 @@ void routing_restart_test_client::run() { its_sent_requests++; VSOMEIP_INFO << "Sent request " << its_sent_requests << " with session id " << std::hex << std::setfill('0') << std::setw(4) << request->get_session(); - std::this_thread::sleep_for(std::chrono::milliseconds(250)); } - if (std::future_status::ready == all_responses_received_.get_future().wait_for(std::chrono::milliseconds(100))) { + if (std::future_status::ready == all_responses_received_.get_future().wait_for(std::chrono::milliseconds(1000))) { EXPECT_EQ(vsomeip_test::NUMBER_OF_MESSAGES_TO_SEND_ROUTING_RESTART_TESTS, received_responses_); VSOMEIP_WARNING << "Received all answers"; } else { @@ -176,7 +171,7 @@ TEST(someip_restart_routing_test, request_response_over_restart) { } int main(int argc, char** argv) { - timeout_detector td(600); + timeout_detector td; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp b/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp index f04968efd..a9c0de42e 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef RESTART_ROUTING_TEST_CLIENT_HPP -#define RESTART_ROUTING_TEST_CLIENT_HPP +#pragma once #include @@ -44,5 +43,3 @@ class routing_restart_test_client { restart_routing::restart_routing_test_interprocess_sync* ip_sync{nullptr}; uint32_t app_id_; }; - -#endif // RESTART_ROUTING_TEST_CLIENT_HPP diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_globals.hpp b/test/network_tests/restart_routing_tests/restart_routing_test_globals.hpp index 2d7f1fc50..6b09b7ff6 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_globals.hpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_globals.hpp @@ -47,14 +47,13 @@ struct restart_routing_test_interprocess_utils { * @param expected_value Part of predicate, expected value to be set by notifier to positive predicate evaluation. */ template - static void wait_and_check_unlocked(boost::interprocess::interprocess_condition& cv, - boost::interprocess::scoped_lock& its_lock, int timeout_s, - T& value_to_check, T expected_value) { + [[nodiscard]] static bool wait_and_check_unlocked(boost::interprocess::interprocess_condition& cv, + boost::interprocess::scoped_lock& its_lock, + int timeout_s, T& value_to_check, T expected_value) { boost::posix_time::ptime timeout = boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(timeout_s); cv.timed_wait(its_lock, timeout, [&] { return value_to_check == expected_value; }); - - ASSERT_EQ(value_to_check, expected_value); + return value_to_check == expected_value; } /** diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_manager.cpp b/test/network_tests/restart_routing_tests/restart_routing_test_manager.cpp index 9fbfe4fcc..c9f3fd28a 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_manager.cpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_manager.cpp @@ -75,7 +75,6 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_host) process_manager host{host_executor, custom_env("restart_routing_test_autoconfig.json", "routingmanagerd")}; host.run(); - host.wait_for_start(); process_manager service{service_executor, custom_env("restart_routing_test_autoconfig.json", "restart_routing_test_service")}; service.run(); @@ -96,13 +95,15 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_host) // Wait for fist registration of all service consumers. for (uint32_t app_counter = 0; app_counter < NUM_SERVICE_CONSUMERS; ++app_counter) { bpi::scoped_lock its_lock(shm_data.sync_ptr->client_mutex_); - restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( + ASSERT_TRUE(restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( shm_data.sync_ptr->client_cv_, its_lock, 10, shm_data.sync_ptr->client_status_[app_counter], - restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED); + restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED)); } // Restart host. - host.reset(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); + host.run(); // Wait for restart to be completed. std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -114,14 +115,13 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_host) restart_routing::restart_routing_test_interprocess_utils::notify_all_component_unlocked(shm_data.sync_ptr->client_cv_); // Wait for processes termination and test exit code. - service.join(); + EXPECT_EQ(service.wait(), 0); for (const auto& client : clients) { - client->join(); - EXPECT_EQ(client->exit_code_, 0); + EXPECT_EQ(client->wait(), 0); } - // Terminate host, do not assert exit code. - host.terminate(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); } /** @@ -152,13 +152,16 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_servic // Wait for fist registration of all service consumers. for (uint32_t app_counter = 0; app_counter < NUM_SERVICE_CONSUMERS; ++app_counter) { bpi::scoped_lock its_lock(shm_data.sync_ptr->client_mutex_); - restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( + ASSERT_TRUE(restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( shm_data.sync_ptr->client_cv_, its_lock, 10, shm_data.sync_ptr->client_status_[app_counter], - restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED); + restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED)); } // Restart host. - service.reset(); + service.send_signal(SIGKILL); + // UGLY AS HELL! we SIGKILL'd, so no exit code check + std::ignore = service.wait(); + service.run(); // Wait for restart to be completed. std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -171,10 +174,10 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_servic // Wait for processes termination and test exit code. for (const auto& client : clients) { - client->join(); - EXPECT_EQ(client->exit_code_, 0); + EXPECT_EQ(client->wait(), 0); } - service.join(); + + EXPECT_EQ(service.wait(), 0); } /** @@ -186,7 +189,6 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_host_w process_manager host{host_executor, custom_env("restart_routing_test_service.json", "routingmanagerd")}; host.run(); - host.wait_for_start(); process_manager service{service_executor, custom_env("restart_routing_test_service.json", "restart_routing_test_service")}; service.run(); @@ -207,13 +209,15 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_host_w // Wait for fist registration of all service consumers. for (uint32_t app_counter = 0; app_counter < NUM_SERVICE_CONSUMERS; ++app_counter) { bpi::scoped_lock its_lock(shm_data.sync_ptr->client_mutex_); - restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( + ASSERT_TRUE(restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( shm_data.sync_ptr->client_cv_, its_lock, 10, shm_data.sync_ptr->client_status_[app_counter], - restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED); + restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED)); } // Restart host. - host.reset(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); + host.run(); // Wait for restart to be completed. std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -225,14 +229,13 @@ TEST_F(restart_routing_test_manager, restart_routing_test_manager_restart_host_w restart_routing::restart_routing_test_interprocess_utils::notify_all_component_unlocked(shm_data.sync_ptr->client_cv_); // Wait for processes termination and test exit code. - service.join(); + EXPECT_EQ(service.wait(), 0); for (const auto& client : clients) { - client->join(); - EXPECT_EQ(client->exit_code_, 0); + EXPECT_EQ(client->wait(), 0); } - // Terminate host, do not assert exit code. - host.terminate(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); } /** @@ -245,11 +248,8 @@ TEST_F(restart_routing_test_manager, client_id_race_condition) { process_manager service{service_executor, custom_env("restart_routing_test_without_id.json", "restart_routing_test_service")}; service.run(); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - process_manager host{host_executor, custom_env("restart_routing_test_without_id.json", "routingmanagerd")}; host.run(); - host.wait_for_start(); std::unordered_set> clients; for (uint32_t app_counter = 0; app_counter < NUM_SERVICE_CONSUMERS; ++app_counter) { @@ -267,13 +267,15 @@ TEST_F(restart_routing_test_manager, client_id_race_condition) { // Wait for fist registration of all service consumers. for (uint32_t app_counter = 0; app_counter < NUM_SERVICE_CONSUMERS; ++app_counter) { bpi::scoped_lock its_lock(shm_data.sync_ptr->client_mutex_); - restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( + ASSERT_TRUE(restart_routing::restart_routing_test_interprocess_utils::wait_and_check_unlocked( shm_data.sync_ptr->client_cv_, its_lock, 10, shm_data.sync_ptr->client_status_[app_counter], - restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED); + restart_routing::restart_routing_test_interprocess_sync::registration_status::STATE_REGISTERED)); } // Restart host. - host.reset(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); + host.run(); // Wait for restart to be completed. std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -285,19 +287,18 @@ TEST_F(restart_routing_test_manager, client_id_race_condition) { restart_routing::restart_routing_test_interprocess_utils::notify_all_component_unlocked(shm_data.sync_ptr->client_cv_); // Wait for processes termination and test exit code. - service.join(); + EXPECT_EQ(service.wait(), 0); for (const auto& client : clients) { - client->join(); - EXPECT_EQ(client->exit_code_, 0); + EXPECT_EQ(client->wait(), 0); } - // Terminate host, do not assert exit code. - host.terminate(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); } #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { - timeout_detector td(600); + timeout_detector td; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp b/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp index feba8e85e..1cbe90d3e 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp @@ -138,7 +138,7 @@ TEST(someip_restart_routing_test, send_response_for_every_request) { #if defined(__linux__) || defined(__QNX__) int main(int argc, char** argv) { - timeout_detector td(600); + timeout_detector td; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp b/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp index 5508b9506..a22029a71 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef RESTART_ROUTING_TEST_SERVICE_HPP -#define RESTART_ROUTING_TEST_SERVICE_HPP +#pragma once #include @@ -53,5 +52,3 @@ class routing_restart_test_service { std::thread offer_thread_; }; - -#endif // RESTART_ROUTING_TEST_SERVICE_HPP diff --git a/test/network_tests/reuse_client_id_tests/reuse_client_id_test_client.hpp b/test/network_tests/reuse_client_id_tests/reuse_client_id_test_client.hpp index d38356b6c..b4e1f9cf0 100644 --- a/test/network_tests/reuse_client_id_tests/reuse_client_id_test_client.hpp +++ b/test/network_tests/reuse_client_id_tests/reuse_client_id_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef REUSE_CLIENT_ID_TEST_CLIENT_HPP_ -#define REUSE_CLIENT_ID_TEST_CLIENT_HPP_ +#pragma once #include #include @@ -29,5 +28,3 @@ class reuse_client_id_test_client { reuse_client_id::reuse_client_id_test_interprocess_sync* ip_sync{nullptr}; std::atomic stopping{false}; }; - -#endif // REUSE_CLIENT_ID_TEST_CLIENT_HPP_ diff --git a/test/network_tests/reuse_client_id_tests/reuse_client_id_test_manager.cpp b/test/network_tests/reuse_client_id_tests/reuse_client_id_test_manager.cpp index 580929353..de68d4169 100644 --- a/test/network_tests/reuse_client_id_tests/reuse_client_id_test_manager.cpp +++ b/test/network_tests/reuse_client_id_tests/reuse_client_id_test_manager.cpp @@ -85,7 +85,6 @@ TEST_F(reuse_client_id_test_manager, reuse_client_id_test) { process_manager host{host_executor, custom_env("reuse_client_id_test.json", "routingmanagerd")}; host.run(); - host.wait_for_start(); // start client1 auto client1 = std::make_unique("./reuse_client_id_test_client 6301 1", @@ -120,7 +119,7 @@ TEST_F(reuse_client_id_test_manager, reuse_client_id_test) { } reuse_client_id::reuse_client_id_test_interprocess_utils::notify_all_component_unlocked(shm_data.sync_ptr->client_cv_); - client4->join(); + EXPECT_EQ(client4->wait(), 0); // restart client1 { @@ -142,7 +141,7 @@ TEST_F(reuse_client_id_test_manager, reuse_client_id_test) { shm_data.sync_ptr->stop_clients_[CLIENT_2_IDX] = true; } reuse_client_id::reuse_client_id_test_interprocess_utils::notify_all_component_unlocked(shm_data.sync_ptr->client_cv_); - client2->join(); + EXPECT_EQ(client2->wait(), 0); // restart client1 { @@ -163,18 +162,12 @@ TEST_F(reuse_client_id_test_manager, reuse_client_id_test) { } reuse_client_id::reuse_client_id_test_interprocess_utils::notify_all_component_unlocked(shm_data.sync_ptr->client_cv_); - client1->join(); - client3->join(); - client5->join(); + EXPECT_EQ(client1->wait(), 0); + EXPECT_EQ(client3->wait(), 0); + EXPECT_EQ(client5->wait(), 0); - EXPECT_EQ(client1->exit_code_, 0); - EXPECT_EQ(client2->exit_code_, 0); - EXPECT_EQ(client3->exit_code_, 0); - EXPECT_EQ(client4->exit_code_, 0); - EXPECT_EQ(client5->exit_code_, 0); - - // Terminate host, do not assert exit code. - host.terminate(); + host.send_signal(SIGINT); + EXPECT_EQ(host.wait(), 0); } #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) diff --git a/test/network_tests/routing_tests/conf/local_routing_test_starter.sh.in b/test/network_tests/routing_tests/conf/local_routing_test_starter.sh.in index 2120e5694..1a2ced482 100755 --- a/test/network_tests/routing_tests/conf/local_routing_test_starter.sh.in +++ b/test/network_tests/routing_tests/conf/local_routing_test_starter.sh.in @@ -40,7 +40,7 @@ check_tcp_udp_sockets_are_closed () export VSOMEIP_CONFIGURATION=local_routing_test_service.json # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the service diff --git a/test/network_tests/routing_tests/external_local_routing_test_service.hpp b/test/network_tests/routing_tests/external_local_routing_test_service.hpp index 4267ea1ab..7cd16917c 100644 --- a/test/network_tests/routing_tests/external_local_routing_test_service.hpp +++ b/test/network_tests/routing_tests/external_local_routing_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef EXTERNALLOCALROUTINGTESTSERVICE_HPP_ -#define EXTERNALLOCALROUTINGTESTSERVICE_HPP_ +#pragma once #include #include @@ -41,5 +40,3 @@ class external_local_routing_test_service { std::uint32_t number_received_messages_external_; std::thread offer_thread_; }; - -#endif /* EXTERNALLOCALROUTINGTESTSERVICE_HPP_ */ diff --git a/test/network_tests/routing_tests/local_routing_test_client.hpp b/test/network_tests/routing_tests/local_routing_test_client.hpp index 32900166d..32a9421fe 100644 --- a/test/network_tests/routing_tests/local_routing_test_client.hpp +++ b/test/network_tests/routing_tests/local_routing_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef LOCALROUTINGTESTCLIENT_HPP_ -#define LOCALROUTINGTESTCLIENT_HPP_ +#pragma once #include @@ -43,5 +42,3 @@ class local_routing_test_client { std::uint32_t number_of_acknowledged_messages_; std::thread sender_; }; - -#endif /* LOCALROUTINGTESTCLIENT_HPP_ */ diff --git a/test/network_tests/routing_tests/local_routing_test_service.hpp b/test/network_tests/routing_tests/local_routing_test_service.hpp index c685e9deb..14a911223 100644 --- a/test/network_tests/routing_tests/local_routing_test_service.hpp +++ b/test/network_tests/routing_tests/local_routing_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef LOCALROUTINGTESTSERVICE_HPP_ -#define LOCALROUTINGTESTSERVICE_HPP_ +#pragma once #include #include @@ -41,5 +40,3 @@ class local_routing_test_service { std::condition_variable condition_; std::thread offer_thread_; }; - -#endif /* LOCALROUTINGTESTSERVICE_HPP_ */ diff --git a/test/network_tests/second_address_tests/conf/second_address_test_master_starter.sh.in b/test/network_tests/second_address_tests/conf/second_address_test_master_starter.sh.in index 109959f9d..7926f3e57 100755 --- a/test/network_tests/second_address_tests/conf/second_address_test_master_starter.sh.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_master_starter.sh.in @@ -40,7 +40,7 @@ elif [ "$OPERATIONMODE" = "CLIENT" ]; then fi export VSOMEIP_APPLICATION_NAME=routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=$MASTER_APPLICATION diff --git a/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in b/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in index 18a7514f0..4c10ccf23 100755 --- a/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in +++ b/test/network_tests/second_address_tests/conf/second_address_test_slave_starter.sh.in @@ -41,7 +41,7 @@ elif [ "$OPERATIONMODE" = "SERVICE" ]; then fi export VSOMEIP_APPLICATION_NAME=routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=$SLAVE_APPLICATION diff --git a/test/network_tests/second_address_tests/second_address_test_globals.hpp b/test/network_tests/second_address_tests/second_address_test_globals.hpp index 59a4ee20f..0184bddaf 100644 --- a/test/network_tests/second_address_tests/second_address_test_globals.hpp +++ b/test/network_tests/second_address_tests/second_address_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SECOND_ADDRESS_TEST_GLOBALS_HPP_ -#define SECOND_ADDRESS_TEST_GLOBALS_HPP_ +#pragma once namespace second_address_test { @@ -25,5 +24,3 @@ struct service_info service = {0x3333, 0x1, 0x1, 0x3301, 0x2, 0x3302, 0x1111, 0x static constexpr std::uint32_t number_of_messages_to_send = 150; static constexpr std::uint8_t number_of_events_to_send = 150; } - -#endif /* SECOND_ADDRESS_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/security_tests/conf/security_test_external_master_start.sh.in b/test/network_tests/security_tests/conf/security_test_external_master_start.sh.in index 504b49d78..e09477564 100755 --- a/test/network_tests/security_tests/conf/security_test_external_master_start.sh.in +++ b/test/network_tests/security_tests/conf/security_test_external_master_start.sh.in @@ -31,7 +31,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=$1 export VSOMEIP_APPLICATION_NAME=routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_CONFIGURATION=$1 diff --git a/test/network_tests/security_tests/conf/security_test_external_slave_start.sh.in b/test/network_tests/security_tests/conf/security_test_external_slave_start.sh.in index e7064472c..6b99f979d 100755 --- a/test/network_tests/security_tests/conf/security_test_external_slave_start.sh.in +++ b/test/network_tests/security_tests/conf/security_test_external_slave_start.sh.in @@ -30,7 +30,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=$1 export VSOMEIP_APPLICATION_NAME=routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_CONFIGURATION=$1 diff --git a/test/network_tests/security_tests/conf/security_test_local_start.sh.in b/test/network_tests/security_tests/conf/security_test_local_start.sh.in index ae3cd25d8..d039e4343 100755 --- a/test/network_tests/security_tests/conf/security_test_local_start.sh.in +++ b/test/network_tests/security_tests/conf/security_test_local_start.sh.in @@ -16,7 +16,7 @@ export VSOMEIP_CONFIGURATION=security_test_local_config.json export VSOMEIP_APPLICATION_NAME=routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! export VSOMEIP_APPLICATION_NAME=service-sample diff --git a/test/network_tests/security_tests/security_test_client.hpp b/test/network_tests/security_tests/security_test_client.hpp index 7b3630de6..9dff15062 100644 --- a/test/network_tests/security_tests/security_test_client.hpp +++ b/test/network_tests/security_tests/security_test_client.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SECURITY_TEST_CLIENT_HPP -#define SECURITY_TEST_CLIENT_HPP +#pragma once #include @@ -49,5 +48,3 @@ class security_test_client { bool test_external_communication_; bool is_remote_client_allowed_; }; - -#endif // SECURITY_TEST_CLIENT_HPP diff --git a/test/network_tests/security_tests/security_test_service.hpp b/test/network_tests/security_tests/security_test_service.hpp index af6a06a8c..f71231e8c 100644 --- a/test/network_tests/security_tests/security_test_service.hpp +++ b/test/network_tests/security_tests/security_test_service.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SECURITY_TEST_SERVICE_HPP -#define SECURITY_TEST_SERVICE_HPP +#pragma once #include @@ -41,5 +40,3 @@ class security_test_service { std::uint32_t number_of_received_messages_; std::thread offer_thread_; }; - -#endif // SECURITY_TEST_SERVICE_HPP diff --git a/test/network_tests/shutdown_tests/CMakeLists.txt b/test/network_tests/shutdown_tests/CMakeLists.txt new file mode 100644 index 000000000..3ecfe26a9 --- /dev/null +++ b/test/network_tests/shutdown_tests/CMakeLists.txt @@ -0,0 +1,112 @@ +# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +project(shutdown_tests LANGUAGES CXX) + +# Configure the necessary files into the build folder. +set(configuration_files + shutdown_test_local_client_host_starter.sh + shutdown_test_local_service_host_starter.sh + shutdown_test_local_starter.sh + shutdown_test_local_service_host_tcp.json + shutdown_test_local_client_host_tcp.json + shutdown_test_local_tcp.json + shutdown_test_local_service_host_uds.json + shutdown_test_local_client_host_uds.json + shutdown_test_local_uds.json +) +configure_files("${configuration_files}") + +# Add test executable. +add_executable(shutdown_test_service_receive + shutdown_test_service_receive.cpp +) + +# Add test executable. +add_executable(shutdown_test_client_send + shutdown_test_client_send.cpp +) + +# Add test executable. +add_executable(shutdown_test_service_send + shutdown_test_service_send.cpp +) + +# Add test executable. +add_executable(shutdown_test_client_receive + shutdown_test_client_receive.cpp +) + +# Add build dependencies and link libraries to executables. +set(test_executables + shutdown_test_service_receive + shutdown_test_client_send + shutdown_test_service_send + shutdown_test_client_receive +) +targets_link_default_libraries("${test_executables}") +targets_add_default_dependencies("${test_executables}") + +# Add custom test commands. + +add_custom_test( + NAME shutdown_test_client_send_local_tcp + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_starter.sh TCP CLIENT +) + +add_custom_test( + NAME shutdown_test_client_send_local_client_host_tcp + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_client_host_starter.sh TCP CLIENT +) + +add_custom_test( + NAME shutdown_test_client_send_local_service_host_tcp + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_service_host_starter.sh TCP CLIENT +) + +add_custom_test( + NAME shutdown_test_client_send_local_uds + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_starter.sh UDS CLIENT +) + +add_custom_test( + NAME shutdown_test_client_send_local_client_host_uds + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_client_host_starter.sh UDS CLIENT +) + +add_custom_test( + NAME shutdown_test_client_send_local_service_host_uds + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_service_host_starter.sh UDS CLIENT +) + +add_custom_test( + NAME shutdown_test_service_send_local_tcp + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_starter.sh TCP SERVICE +) + +add_custom_test( + NAME shutdown_test_service_send_local_client_host_tcp + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_client_host_starter.sh TCP SERVICE +) + +add_custom_test( + NAME shutdown_test_service_send_local_service_host_tcp + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_service_host_starter.sh TCP SERVICE +) + +add_custom_test( + NAME shutdown_test_service_send_local_uds + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_starter.sh UDS SERVICE +) + +add_custom_test( + NAME shutdown_test_service_send_local_client_host_uds + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_client_host_starter.sh UDS SERVICE +) + +add_custom_test( + NAME shutdown_test_service_send_local_service_host_uds + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/shutdown_test_local_service_host_starter.sh UDS SERVICE +) diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_starter.sh.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_starter.sh.in new file mode 100755 index 000000000..6b95648ff --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_starter.sh.in @@ -0,0 +1,51 @@ +#!/bin/bash -x +# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +if ! source $SCRIPT_DIRECTORY/../setup_test.sh; then + exit 1 +fi + +FAIL=0 + +if [[ $# -gt 0 && ($1 != "TCP" && $1 != "UDP" && $1 != "UDS") || ($2 != "CLIENT" && $2 != "SERVICE") ]] +then + echo "The only allowed parameter to this script is TCP, UDP or UDS and CLIENT or SERVICE" + echo "Like $0 TCP CLIENT" + exit 1 +fi + +# Start the client +if [[ $# -gt 0 && $1 == "TCP" ]]; then + export VSOMEIP_CONFIGURATION=shutdown_test_local_client_host_tcp.json +else + export VSOMEIP_CONFIGURATION=shutdown_test_local_client_host_uds.json +fi + +if [[ $2 == "CLIENT" ]]; then + export VSOMEIP_APPLICATION_NAME=shutdown_test_client + ./shutdown_test_client_send $1 & + CLIENT_PID=$! + + export VSOMEIP_APPLICATION_NAME=shutdown_test_service + ./shutdown_test_service_receive & + SERVICE_PID=$! + +else + export VSOMEIP_APPLICATION_NAME=shutdown_test_client + ./shutdown_test_client_receive $1 & + CLIENT_PID=$! + + export VSOMEIP_APPLICATION_NAME=shutdown_test_service + ./shutdown_test_service_send $1 & + SERVICE_PID=$! +fi + +wait $SERVICE_PID || ((FAIL+=1)) +wait $CLIENT_PID || ((FAIL+=1)) + +# Check if client and server both exited successfully +exit $FAIL diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_tcp.json.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_tcp.json.in new file mode 100644 index 000000000..c370edadb --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_tcp.json.in @@ -0,0 +1,40 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"trace", + "console":"true" + }, + "tracing" : + { + "enable" : "true" + }, + "applications": + [ + { + "name":"shutdown_test_service", + "id":"0x1277" + }, + { + "name":"shutdown_test_client", + "id":"0x1343" + } + ], + "routing" : + { + "host": { + "name": "shutdown_test_client", + "unicast": "@TEST_IP_MASTER@", + "port": "8998" + }, + "guests": { + "unicast": "@TEST_IP_MASTER@", + "ports": [ + { + "first": "9000", + "last": "65535" + } + ] + } + } +} diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_uds.json.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_uds.json.in new file mode 100644 index 000000000..4d6df0377 --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_client_host_uds.json.in @@ -0,0 +1,24 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"trace", + "console":"true" + }, + "tracing" : + { + "enable" : "true" + }, + "applications": + [ + { + "name":"shutdown_test_service", + "id":"0x1277" + }, + { + "name":"shutdown_test_client", + "id":"0x1343" + } + ], + "routing" : "shutdown_test_client" +} diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_starter.sh.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_starter.sh.in new file mode 100755 index 000000000..edc1254c5 --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_starter.sh.in @@ -0,0 +1,50 @@ +#!/bin/bash -x +# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +if ! source $SCRIPT_DIRECTORY/../setup_test.sh; then + exit 1 +fi + +FAIL=0 + +if [[ $# -gt 0 && ($1 != "TCP" && $1 != "UDP" && $1 != "UDS") || ($2 != "CLIENT" && $2 != "SERVICE") ]] +then + echo "The only allowed parameter to this script is TCP, UDP or UDS and CLIENT or SERVICE" + echo "Like $0 TCP CLIENT" + exit 1 +fi + +if [[ $# -gt 0 && $1 == "TCP" ]]; then + export VSOMEIP_CONFIGURATION=shutdown_test_local_service_host_tcp.json +else + export VSOMEIP_CONFIGURATION=shutdown_test_local_service_host_uds.json +fi + +if [[ $2 == "CLIENT" ]]; then + export VSOMEIP_APPLICATION_NAME=shutdown_test_service + ./shutdown_test_service_receive & + SERVICE_PID=$! + + export VSOMEIP_APPLICATION_NAME=shutdown_test_client + ./shutdown_test_client_send $1 & + CLIENT_PID=$! + +else + export VSOMEIP_APPLICATION_NAME=shutdown_test_service + ./shutdown_test_service_send $1 & + SERVICE_PID=$! + + export VSOMEIP_APPLICATION_NAME=shutdown_test_client + ./shutdown_test_client_receive $1 & + CLIENT_PID=$! +fi + +wait $SERVICE_PID || ((FAIL+=1)) +wait $CLIENT_PID || ((FAIL+=1)) + +# Check if client and server both exited successfully +exit $FAIL diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_tcp.json.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_tcp.json.in new file mode 100644 index 000000000..45e1e355e --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_tcp.json.in @@ -0,0 +1,40 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"trace", + "console":"true" + }, + "tracing" : + { + "enable" : "true" + }, + "applications": + [ + { + "name":"shutdown_test_service", + "id":"0x1277" + }, + { + "name":"shutdown_test_client", + "id":"0x1343" + } + ], + "routing" : + { + "host": { + "name": "shutdown_test_service", + "unicast": "@TEST_IP_MASTER@", + "port": "8998" + }, + "guests": { + "unicast": "@TEST_IP_MASTER@", + "ports": [ + { + "first": "9000", + "last": "65535" + } + ] + } + } +} diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_uds.json.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_uds.json.in new file mode 100644 index 000000000..85c187265 --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_service_host_uds.json.in @@ -0,0 +1,24 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"trace", + "console":"true" + }, + "tracing" : + { + "enable" : "true" + }, + "applications": + [ + { + "name":"shutdown_test_service", + "id":"0x1277" + }, + { + "name":"shutdown_test_client", + "id":"0x1343" + } + ], + "routing" : "shutdown_test_service" +} diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_starter.sh.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_starter.sh.in new file mode 100755 index 000000000..44f075162 --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_starter.sh.in @@ -0,0 +1,56 @@ +#!/bin/bash -x +# Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +if ! source $SCRIPT_DIRECTORY/../setup_test.sh; then + exit 1 +fi + +FAIL=0 + +if [[ $# -gt 0 && ($1 != "TCP" && $1 != "UDP" && $1 != "UDS") || ($2 != "CLIENT" && $2 != "SERVICE") ]] +then + echo "The only allowed parameter to this script is TCP, UDP or UDS and CLIENT or SERVICE" + echo "Like $0 TCP CLIENT" + exit 1 +fi + +if [[ $# -gt 0 && $1 == "TCP" ]]; then + export VSOMEIP_CONFIGURATION=shutdown_test_local_tcp.json +else + export VSOMEIP_CONFIGURATION=shutdown_test_local_uds.json +fi + +export VSOMEIP_APPLICATION_NAME="routingmanagerd" +../../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! + +if [[ $2 == "CLIENT" ]]; then + export VSOMEIP_APPLICATION_NAME=shutdown_test_service + ./shutdown_test_service_receive & + SERVICE_PID=$! + + export VSOMEIP_APPLICATION_NAME=shutdown_test_client + ./shutdown_test_client_send $1 & + CLIENT_PID=$! +else + export VSOMEIP_APPLICATION_NAME=shutdown_test_service + ./shutdown_test_service_send $1 & + SERVICE_PID=$! + + export VSOMEIP_APPLICATION_NAME=shutdown_test_client + ./shutdown_test_client_receive $1 & + CLIENT_PID=$! +fi + +wait $SERVICE_PID || ((FAIL+=1)) +wait $CLIENT_PID || ((FAIL+=1)) + +kill $PID_VSOMEIPD +wait $PID_VSOMEIPD + +# Check if client and server both exited successfully +exit $FAIL diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_tcp.json.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_tcp.json.in new file mode 100644 index 000000000..bec8f1f96 --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_tcp.json.in @@ -0,0 +1,40 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"trace", + "console":"true" + }, + "tracing" : + { + "enable" : "true" + }, + "applications": + [ + { + "name":"shutdown_test_service", + "id":"0x1277" + }, + { + "name":"shutdown_test_client", + "id":"0x1343" + } + ], + "routing" : + { + "host": { + "name": "routingmanagerd", + "unicast": "@TEST_IP_MASTER@", + "port": "8998" + }, + "guests": { + "unicast": "@TEST_IP_MASTER@", + "ports": [ + { + "first": "9000", + "last": "65535" + } + ] + } + } +} diff --git a/test/network_tests/shutdown_tests/conf/shutdown_test_local_uds.json.in b/test/network_tests/shutdown_tests/conf/shutdown_test_local_uds.json.in new file mode 100644 index 000000000..6626b3e77 --- /dev/null +++ b/test/network_tests/shutdown_tests/conf/shutdown_test_local_uds.json.in @@ -0,0 +1,24 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"trace", + "console":"true" + }, + "tracing" : + { + "enable" : "true" + }, + "applications": + [ + { + "name":"shutdown_test_service", + "id":"0x1277" + }, + { + "name":"shutdown_test_client", + "id":"0x1343" + } + ], + "routing" : "routingmanagerd" +} diff --git a/test/network_tests/shutdown_tests/shutdown_test.md b/test/network_tests/shutdown_tests/shutdown_test.md new file mode 100644 index 000000000..fd8358e4e --- /dev/null +++ b/test/network_tests/shutdown_tests/shutdown_test.md @@ -0,0 +1,37 @@ +# Shutdown Test + +These tests ensure that message delivery reaches its destination in the case where an application sends a message and immediately stops. + +## Purpose + +- Verify that messages are properly delivered even when the sender application terminates immediately after sending +- Ensure that the routing manager correctly handles rapid shutdown scenarios +- Validate that message queues are flushed before application termination + +## Test Logic + +Shutdown_test has 2 test cases: + +1. Client sends 5 shutdown messages and stops immediately +2. Service sends 5 replies to shutdown message and stops immediately + +### 1st Test Case - Client sends 5 shutdown messages and stops immediately + +1. Start the applications and Service offers +2. The Client subscribes, sends 5 shutdown messages and stops immediately - The 5 messages must reach its destination +3. The Service receives the 5 shutdown messages and stops + +### 2nd Test Case - Service sends 5 shutdown replies and stops immediately + +1. Start the applications and Service offers +2. The Client subscribes and sends a shutdown message +3. The Service receives the shutdown message, sends 5 replies and stops immediately - The 5 messages must reach its destination +4. The Client receives the 5 shutdown replies and stops + +## Executions + +### Different scenarios for local communication covered in TCP and UDS: + +1. Routingmanagerd (Host), Client and Service +2. Client (Host) and Service +3. Service (Host) and Client diff --git a/test/network_tests/shutdown_tests/shutdown_test_client_receive.cpp b/test/network_tests/shutdown_tests/shutdown_test_client_receive.cpp new file mode 100644 index 000000000..dfbd231fe --- /dev/null +++ b/test/network_tests/shutdown_tests/shutdown_test_client_receive.cpp @@ -0,0 +1,140 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "shutdown_test_globals.hpp" +#include +#include + +#include "common/timeout_detector.hpp" + +class shutdown_test_client { +public: + shutdown_test_client(); + + void run_test() { + std::unique_lock its_lock(mutex_); + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [this] { return is_available_; })) + << "Service not available in time"; + + request_->set_service(shutdown_test::TEST_SERVICE_SERVICE_ID); + request_->set_instance(shutdown_test::TEST_SERVICE_INSTANCE_ID); + request_->set_method(shutdown_test::STOP_METHOD); + request_->set_reliable(shutdown_test_client::is_tcp_); + request_->set_payload(0); + + app_->send(request_); + + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [this] { return to_stop; })) + << "Did not receive the shutdown reply in time"; + + stop(); + } + + bool init() { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + + app_->register_message_handler(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, + shutdown_test::STOP_METHOD, std::bind(&shutdown_test_client::on_shutdown_method_reply, this)); + + app_->register_availability_handler(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&shutdown_test_client::on_availability, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); + + app_->request_service(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, false); + return true; + } + + void start() { + VSOMEIP_INFO << "Starting Client..."; + app_->start(); + } + + void stop() { + VSOMEIP_INFO << "Stopping Client..."; + app_->stop(); + } + + void on_shutdown_method_reply() { + n_messages_received_++; + VSOMEIP_INFO << "Shutdown message " << n_messages_received_ << " received."; + if (n_messages_received_ == shutdown_test::SHUTDOWN_NUMBER_MESSAGES) { + VSOMEIP_INFO << "All shutdown messages received, preparing to stop."; + std::lock_guard its_lock(mutex_); + to_stop = true; + condition_.notify_one(); + } + } + + void join_sender_thread() { sender_.join(); } + + void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { + VSOMEIP_INFO << "Service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." << _instance << "] is " + << (_is_available ? "available." : "NOT available."); + + std::lock_guard its_lock(mutex_); + if (is_available_ && !_is_available) { + is_available_ = false; + } else if (_is_available && !is_available_) { + is_available_ = true; + condition_.notify_one(); + } + } + + static bool is_tcp_; + +private: + std::shared_ptr app_; + std::shared_ptr request_; + std::mutex mutex_; + std::condition_variable condition_; + bool is_available_; + bool to_stop; + std::thread sender_; + int n_messages_received_{0}; +}; + +shutdown_test_client::shutdown_test_client() : + app_(vsomeip::runtime::get()->create_application("shutdown_test_client")), request_(vsomeip::runtime::get()->create_request(true)), + is_available_(false), to_stop(false), sender_(std::bind(&shutdown_test_client::run_test, this)) { } + +TEST(someip_shutdown_test, send_messages_to_service_and_wait_for_shutdown_reply) { + shutdown_test_client test_client_; + if (test_client_.init()) { + test_client_.start(); + test_client_.join_sender_thread(); + } +} + +bool shutdown_test_client::is_tcp_ = false; + +#if defined(__linux__) || defined(__QNX__) +int main(int argc, char** argv) { + timeout_detector td; + if (argc > 1) { + if (std::string("TCP") == std::string(argv[1])) { + shutdown_test_client::is_tcp_ = true; + } else { + shutdown_test_client::is_tcp_ = false; + } + } + ::testing::GTEST_FLAG(throw_on_failure) = true; + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/shutdown_tests/shutdown_test_client_send.cpp b/test/network_tests/shutdown_tests/shutdown_test_client_send.cpp new file mode 100644 index 000000000..ae6e2d21c --- /dev/null +++ b/test/network_tests/shutdown_tests/shutdown_test_client_send.cpp @@ -0,0 +1,135 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "shutdown_test_globals.hpp" +#include +#include + +#include "common/timeout_detector.hpp" + +class shutdown_test_client { +public: + shutdown_test_client(); + + void run_test() { + std::unique_lock its_lock(mutex_); + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [this] { return is_available_; })) + << "Service not available in time"; + + std::shared_ptr its_payload = vsomeip::runtime::get()->create_payload(); + std::vector its_payload_data; + + for (std::uint32_t i = 0; i < shutdown_test::SHUTDOWN_NUMBER_MESSAGES; ++i) { + request_->set_service(shutdown_test::TEST_SERVICE_SERVICE_ID); + request_->set_instance(shutdown_test::TEST_SERVICE_INSTANCE_ID); + request_->set_method(shutdown_test::STOP_METHOD); + request_->set_reliable(shutdown_test_client::is_tcp_); + its_payload_data.assign(shutdown_test_client::size_buffer_, shutdown_test::DATA_CLIENT_TO_SERVICE); + its_payload->set_data(its_payload_data); + request_->set_payload(its_payload); + + app_->send(request_); + } + + stop(); + } + + bool init() { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + + app_->register_availability_handler(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&shutdown_test_client::on_availability, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); + + app_->request_service(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, false); + return true; + } + + void start() { + VSOMEIP_INFO << "Starting Client..."; + app_->start(); + } + + void stop() { + VSOMEIP_INFO << "Stopping Client..."; + app_->stop(); + } + + void join_sender_thread() { sender_.join(); } + + void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) { + VSOMEIP_INFO << "Service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." << _instance << "] is " + << (_is_available ? "available." : "NOT available."); + + std::lock_guard its_lock(mutex_); + if (is_available_ && !_is_available) { + is_available_ = false; + } else if (_is_available && !is_available_) { + is_available_ = true; + condition_.notify_one(); + } + } + + static std::uint32_t size_buffer_; + static bool is_tcp_; + +private: + std::shared_ptr app_; + std::shared_ptr request_; + std::mutex mutex_; + std::condition_variable condition_; + bool is_available_; + std::thread sender_; +}; + +shutdown_test_client::shutdown_test_client() : + app_(vsomeip::runtime::get()->create_application("shutdown_test_client")), request_(vsomeip::runtime::get()->create_request(true)), + is_available_(false), sender_(std::bind(&shutdown_test_client::run_test, this)) { } + +TEST(someip_shutdown_test, send_messages_to_service_and_immediately_stop) { + shutdown_test_client test_client_; + if (test_client_.init()) { + test_client_.start(); + test_client_.join_sender_thread(); + } +} + +std::uint32_t shutdown_test_client::size_buffer_ = 0; +bool shutdown_test_client::is_tcp_ = false; + +#if defined(__linux__) || defined(__QNX__) +int main(int argc, char** argv) { + timeout_detector td; + if (argc > 1) { + if (std::string("TCP") == std::string(argv[1])) { + shutdown_test_client::size_buffer_ = shutdown_test::SHUTDOWN_SIZE_TCP; + shutdown_test_client::is_tcp_ = true; + } else if (std::string("UDP") == std::string(argv[1])) { + shutdown_test_client::size_buffer_ = shutdown_test::SHUTDOWN_SIZE_UDP; + shutdown_test_client::is_tcp_ = false; + } else { + shutdown_test_client::size_buffer_ = shutdown_test::SHUTDOWN_SIZE_UDS; + shutdown_test_client::is_tcp_ = false; + } + } + ::testing::InitGoogleTest(&argc, argv); + ::testing::GTEST_FLAG(throw_on_failure) = true; + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/shutdown_tests/shutdown_test_globals.hpp b/test/network_tests/shutdown_tests/shutdown_test_globals.hpp new file mode 100644 index 000000000..cfba01e47 --- /dev/null +++ b/test/network_tests/shutdown_tests/shutdown_test_globals.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef SHUTDOWN_TEST_GLOBALS_HPP_ +#define SHUTDOWN_TEST_GLOBALS_HPP_ + +#include + +namespace shutdown_test { +constexpr std::uint32_t SHUTDOWN_SIZE_UDS = 1024 * 256; +constexpr std::uint32_t SHUTDOWN_SIZE_UDP = 1024; +constexpr std::uint32_t SHUTDOWN_SIZE_TCP = 1024 * 768; +constexpr std::uint32_t SHUTDOWN_NUMBER_MESSAGES = 5; +constexpr vsomeip::byte_t DATA_SERVICE_TO_CLIENT = 0xAA; +constexpr vsomeip::byte_t DATA_CLIENT_TO_SERVICE = 0xFF; + +constexpr vsomeip::service_t TEST_SERVICE_SERVICE_ID = 0x1236; + +constexpr vsomeip::instance_t TEST_SERVICE_INSTANCE_ID = 0x1; +constexpr vsomeip::method_t TEST_SERVICE_METHOD_ID = 0x8421; + +constexpr vsomeip::method_t STOP_METHOD = 0x0999; +} + +#endif /* SHUTDOWN_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/shutdown_tests/shutdown_test_service_receive.cpp b/test/network_tests/shutdown_tests/shutdown_test_service_receive.cpp new file mode 100644 index 000000000..d55d40454 --- /dev/null +++ b/test/network_tests/shutdown_tests/shutdown_test_service_receive.cpp @@ -0,0 +1,117 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "shutdown_test_globals.hpp" +#include +#include "common/timeout_detector.hpp" + +class shutdown_test_service { +public: + shutdown_test_service(); + + void run_test() { + std::unique_lock its_lock(mutex_); + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [&] { return is_registered_; })) + << "Service not registered in time"; + + app_->offer_service(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID); + + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [&] { return to_stop; })) + << "Did not received the Shutdown message in time"; + + stop(); + } + + bool init() { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + app_->register_message_handler(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, + shutdown_test::STOP_METHOD, std::bind(&shutdown_test_service::on_stop, this)); + app_->register_state_handler(std::bind(&shutdown_test_service::on_state, this, std::placeholders::_1)); + return true; + } + + void start() { + VSOMEIP_INFO << "Starting Service..."; + app_->start(); + } + + void stop() { + VSOMEIP_INFO << "Stopping Service..."; + app_->stop_offer_service(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID); + app_->stop(); + } + + void on_stop() { + n_messages_received_++; + VSOMEIP_INFO << "Shutdown message " << n_messages_received_ << " received."; + if (n_messages_received_ == shutdown_test::SHUTDOWN_NUMBER_MESSAGES) { + VSOMEIP_INFO << "All shutdown messages received, preparing to stop."; + std::unique_lock lk(mutex_); + to_stop = true; + condition_.notify_one(); + } + } + + void join_offer_thread() { offer_thread_.join(); } + + void on_state(vsomeip::state_type_e _state) { + VSOMEIP_INFO << "Application " << app_->get_name() << " is " + << (_state == vsomeip::state_type_e::ST_REGISTERED ? "registered." : "deregistered."); + + std::lock_guard its_lock(mutex_); + if (_state == vsomeip::state_type_e::ST_REGISTERED) { + if (!is_registered_) { + is_registered_ = true; + condition_.notify_one(); + } + } else { + is_registered_ = false; + } + } + +private: + std::shared_ptr app_; + bool is_registered_; + std::mutex mutex_; + std::condition_variable condition_; + bool to_stop; + std::thread offer_thread_; + int n_messages_received_{0}; +}; + +shutdown_test_service::shutdown_test_service() : + app_(vsomeip::runtime::get()->create_application("shutdown_test_service")), is_registered_(false), to_stop(false), + offer_thread_(std::bind(&shutdown_test_service::run_test, this)) { } + +TEST(someip_shutdown_test, receive_message__send_reply_and_wait_for_shutdown) { + shutdown_test_service test_service; + if (test_service.init()) { + test_service.start(); + test_service.join_offer_thread(); + } +} + +#if defined(__linux__) || defined(__QNX__) +int main(int argc, char** argv) { + timeout_detector td; + ::testing::GTEST_FLAG(throw_on_failure) = true; + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/shutdown_tests/shutdown_test_service_send.cpp b/test/network_tests/shutdown_tests/shutdown_test_service_send.cpp new file mode 100644 index 000000000..cb6a3acdc --- /dev/null +++ b/test/network_tests/shutdown_tests/shutdown_test_service_send.cpp @@ -0,0 +1,148 @@ +// Copyright (C) 2014-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "shutdown_test_globals.hpp" +#include +#include "common/timeout_detector.hpp" + +class shutdown_test_service { +public: + shutdown_test_service(); + + void run_test() { + std::unique_lock its_lock(mutex_); + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [&] { return is_registered_; })) + << "Service not registered in time"; + + app_->offer_service(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID); + + ASSERT_TRUE(condition_.wait_for(its_lock, std::chrono::seconds(10), [&] { return to_stop; })) + << "Did not received the Shutdown message in time"; + + for (std::uint32_t i = 0; i < shutdown_test::SHUTDOWN_NUMBER_MESSAGES; ++i) { + reply_->set_reliable(shutdown_test_service::is_tcp_); + reply_->set_session(static_cast(i + 1)); + std::shared_ptr its_payload = vsomeip::runtime::get()->create_payload(); + std::vector its_payload_data; + its_payload_data.assign(shutdown_test_service::size_buffer_, shutdown_test::DATA_SERVICE_TO_CLIENT); + its_payload->set_data(its_payload_data); + reply_->set_payload(its_payload); + + app_->send(reply_); + } + + VSOMEIP_INFO << "Shutdown reply sent"; + stop(); + } + + bool init() { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + app_->register_message_handler(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID, + shutdown_test::STOP_METHOD, + std::bind(&shutdown_test_service::on_stop_message, this, std::placeholders::_1)); + app_->register_state_handler(std::bind(&shutdown_test_service::on_state, this, std::placeholders::_1)); + return true; + } + + void start() { + VSOMEIP_INFO << "Starting Service..."; + app_->start(); + } + + void stop() { + VSOMEIP_INFO << "Stopping Service..."; + app_->stop_offer_service(shutdown_test::TEST_SERVICE_SERVICE_ID, shutdown_test::TEST_SERVICE_INSTANCE_ID); + app_->stop(); + } + + void on_stop_message(const std::shared_ptr& _message) { + VSOMEIP_INFO << "Shutdown method called, sending response"; + + reply_ = vsomeip::runtime::get()->create_response(_message); + + std::lock_guard its_lock(mutex_); + to_stop = true; + condition_.notify_one(); + } + + void join_offer_thread() { offer_thread_.join(); } + + void on_state(vsomeip::state_type_e _state) { + VSOMEIP_INFO << "Application " << app_->get_name() << " is " + << (_state == vsomeip::state_type_e::ST_REGISTERED ? "registered." : "deregistered."); + + std::lock_guard its_lock(mutex_); + if (_state == vsomeip::state_type_e::ST_REGISTERED) { + if (!is_registered_) { + is_registered_ = true; + condition_.notify_one(); + } + } else { + is_registered_ = false; + } + } + + static std::uint32_t size_buffer_; + static bool is_tcp_; + +private: + std::shared_ptr app_; + std::shared_ptr reply_; + bool is_registered_; + std::mutex mutex_; + std::condition_variable condition_; + bool to_stop; + std::thread offer_thread_; +}; + +shutdown_test_service::shutdown_test_service() : + app_(vsomeip::runtime::get()->create_application("shutdown_test_service")), is_registered_(false), to_stop(false), + offer_thread_(std::bind(&shutdown_test_service::run_test, this)) { } + +TEST(someip_shutdown_test, receive_messages_send_shutdown_reply_and_immediately_stop) { + shutdown_test_service test_service; + if (test_service.init()) { + test_service.start(); + test_service.join_offer_thread(); + } +} + +std::uint32_t shutdown_test_service::size_buffer_ = 0; +bool shutdown_test_service::is_tcp_ = false; + +#if defined(__linux__) || defined(__QNX__) +int main(int argc, char** argv) { + timeout_detector td; + if (argc > 1) { + if (std::string("TCP") == std::string(argv[1])) { + shutdown_test_service::size_buffer_ = shutdown_test::SHUTDOWN_SIZE_TCP; + shutdown_test_service::is_tcp_ = true; + } else if (std::string("UDP") == std::string(argv[1])) { + shutdown_test_service::size_buffer_ = shutdown_test::SHUTDOWN_SIZE_UDP; + shutdown_test_service::is_tcp_ = false; + } else { + shutdown_test_service::size_buffer_ = shutdown_test::SHUTDOWN_SIZE_UDS; + shutdown_test_service::is_tcp_ = false; + } + } + ::testing::GTEST_FLAG(throw_on_failure) = true; + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/someip_test_globals.hpp b/test/network_tests/someip_test_globals.hpp index f7d64ed65..3de5bc521 100644 --- a/test/network_tests/someip_test_globals.hpp +++ b/test/network_tests/someip_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SOMEIP_TEST_GLOBALS_HPP_ -#define SOMEIP_TEST_GLOBALS_HPP_ +#pragma once #include #include @@ -46,5 +45,3 @@ constexpr std::uint32_t NUMBER_OF_MESSAGES_TO_SEND_SECURITY_TESTS = 32; constexpr std::uint32_t NUMBER_OF_CLIENTS_TO_REQUEST_SHUTDOWN = 4; } - -#endif /* SOMEIP_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/someip_tp_tests/CMakeLists.txt b/test/network_tests/someip_tp_tests/CMakeLists.txt index 54b8559ae..832636511 100644 --- a/test/network_tests/someip_tp_tests/CMakeLists.txt +++ b/test/network_tests/someip_tp_tests/CMakeLists.txt @@ -18,42 +18,13 @@ add_executable(someip_tp_test_service ) # Add test executable. -set(service_discovery_sources - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/configuration_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/entry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/eventgroupentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ip_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv4_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/ipv6_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/load_balancing_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_element_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/protection_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/selective_option_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/serviceentry_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/service_discovery/src/unknown_option_impl.cpp -) -set(message_sources - ${CMAKE_SOURCE_DIR}/implementation/message/src/deserializer.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/message_impl.cpp - ${CMAKE_SOURCE_DIR}/implementation/message/src/payload_impl.cpp -) -set(endpoint_sources - ${CMAKE_SOURCE_DIR}/implementation/endpoints/src/tp.cpp - ${CMAKE_SOURCE_DIR}/implementation/endpoints/src/tp_reassembler.cpp - ${CMAKE_SOURCE_DIR}/implementation/endpoints/src/tp_message.cpp -) add_executable(someip_tp_test_msg_sender someip_tp_test_msg_sender.cpp - ${service_discovery_sources} - ${message_sources} - ${endpoint_sources} ) # Link vsomeip-sd to test executable. target_link_libraries(someip_tp_test_msg_sender - ${VSOMEIP_NAME}-sd + ${VSOMEIP_NAME}-sd-test ) # Add build dependencies and link libraries to executables. diff --git a/test/network_tests/someip_tp_tests/conf/someip_tp_test_master_starter.sh.in b/test/network_tests/someip_tp_tests/conf/someip_tp_test_master_starter.sh.in index bf534e90c..8d9c44263 100755 --- a/test/network_tests/someip_tp_tests/conf/someip_tp_test_master_starter.sh.in +++ b/test/network_tests/someip_tp_tests/conf/someip_tp_test_master_starter.sh.in @@ -23,7 +23,7 @@ TESTMODE=$1 export VSOMEIP_APPLICATION_NAME="routingmanagerd" export VSOMEIP_CONFIGURATION=someip_tp_test_master.json # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services export VSOMEIP_APPLICATION_NAME="service-sample" diff --git a/test/network_tests/someip_tp_tests/someip_tp_test_globals.hpp b/test/network_tests/someip_tp_tests/someip_tp_test_globals.hpp index 053743359..c2f653a9f 100644 --- a/test/network_tests/someip_tp_tests/someip_tp_test_globals.hpp +++ b/test/network_tests/someip_tp_tests/someip_tp_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SOMEIP_TP_TEST_GLOBALS_HPP_ -#define SOMEIP_TP_TEST_GLOBALS_HPP_ +#pragma once #include @@ -29,5 +28,3 @@ const std::uint32_t number_of_fragments = 6; const std::uint32_t max_segment_size = 1392; } - -#endif /* SOMEIP_TP_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp b/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp index 6935ecd31..a6c942b41 100644 --- a/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp +++ b/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp @@ -66,6 +66,8 @@ class someip_tp : public ::testing::TestWithParam { address_local_(boost::asio::ip::make_address(std::string(local_address))), runtime_(vsomeip::runtime::get()) { } protected: + std::mutex udp_sd_socket_mutex; + void TearDown() { io_.stop(); io_thread_.join(); @@ -105,6 +107,8 @@ class someip_tp : public ::testing::TestWithParam { } void subscribe_at_master(boost::asio::ip::udp::socket* const _udp_socket) { + boost::asio::ip::udp::socket::endpoint_type target_sd(address_remote_, 30490); + std::uint8_t its_subscription[] = { 0xff, 0xff, 0x81, 0x00, 0x00, 0x00, 0x00, 0x30, // length 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // length entries array @@ -116,10 +120,9 @@ class someip_tp : public ::testing::TestWithParam { 0x00, 0x11, 0x75, 0x31, // port 30001 }; std::memcpy(&its_subscription[48], &address_local_.to_v4().to_bytes()[0], 4); + std::scoped_lock its_lock(udp_sd_socket_mutex); std::uint16_t its_session = htons(++sd_session_); std::memcpy(&its_subscription[10], &its_session, sizeof(its_session)); - - boost::asio::ip::udp::socket::endpoint_type target_sd(address_remote_, 30490); _udp_socket->send_to(boost::asio::buffer(its_subscription), target_sd); } @@ -339,7 +342,6 @@ TEST_P(someip_tp, send_in_mode) { std::atomic remote_client_subscription_port(0); std::promise offer_received; - std::mutex udp_sd_socket_mutex; boost::asio::ip::udp::socket udp_sd_socket(io_, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 30490)); udp_sd_socket.set_option(boost::asio::socket_base::reuse_address(true)); @@ -350,12 +352,13 @@ TEST_P(someip_tp, send_in_mode) { udp_server_socket.set_option(boost::asio::socket_base::reuse_address(true)); std::thread sd_receive_thread([&]() { - std::atomic keep_receiving(true); + bool keep_receiving(true); std::vector receive_buffer(4096); std::vector its_received_events; - std::atomic service_offered(false); - std::atomic client_subscribed(false); + bool service_offered(false); + bool client_subscribed(false); std::size_t bytes_transferred; + bool its_subscribed_at_master; // join the sd multicast group 224.0.77.1 udp_sd_socket.set_option(boost::asio::ip::multicast::join_group(boost::asio::ip::make_address("224.0.77.1").to_v4())); @@ -364,7 +367,8 @@ TEST_P(someip_tp, send_in_mode) { { std::scoped_lock its_lock(udp_sd_socket_mutex); bytes_transferred = udp_sd_socket.receive(boost::asio::buffer(receive_buffer, receive_buffer.capacity()), 0, error); - offer_service(&udp_sd_socket); + if (!client_subscribed) + offer_service(&udp_sd_socket); } if (error) { keep_receiving = false; @@ -441,9 +445,19 @@ TEST_P(someip_tp, send_in_mode) { } offer_received.set_value(); service_offered = true; + // Try to subscribe at master after receiving its offer + subscribe_at_master(&udp_sd_socket); + } else if (e->get_type() == vsomeip::sd::entry_type_e::SUBSCRIBE_EVENTGROUP_ACK) { + if (e->get_ttl()) { + its_subscribed_at_master = true; + } else { + // Sleep to avoid sending an excessive amount of subscriptions when retrying to subscribe + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + subscribe_at_master(&udp_sd_socket); + } } } - if (service_offered && client_subscribed) { + if (service_offered && client_subscribed && its_subscribed_at_master) { keep_receiving = false; } } else { @@ -463,11 +477,6 @@ TEST_P(someip_tp, send_in_mode) { return; } - { - std::scoped_lock its_lock(udp_sd_socket_mutex); - subscribe_at_master(&udp_sd_socket); - } - std::mutex all_fragments_received_mutex_; std::condition_variable all_fragments_received_cond_; bool wait_for_all_response_fragments_received_(true); @@ -556,7 +565,7 @@ TEST_P(someip_tp, send_in_mode) { } }); - // send SOMEI-TP message fragmented into 6 parts to service: + // send SOMEIP-TP message fragmented into 6 parts to service: boost::asio::ip::udp::socket::endpoint_type target_service(address_remote_, 30001); std::unique_lock its_lock(all_fragments_received_mutex_); @@ -727,7 +736,7 @@ TEST_P(someip_tp, send_in_mode) { } { while (wait_for_all_response_fragments_received_) { - if (std::cv_status::timeout == all_fragments_received_cond_.wait_for(its_lock, std::chrono::seconds(20))) { + if (std::cv_status::timeout == all_fragments_received_cond_.wait_for(its_lock, std::chrono::seconds(5))) { ADD_FAILURE() << "Didn't receive response to" " fragmented message within time: " << std::uint32_t(mode); @@ -806,7 +815,7 @@ TEST_P(someip_tp, send_in_mode) { fragments_request_to_master_.clear(); } - if (!all_fragments_received_cond_.wait_for(its_lock, std::chrono::seconds(20), [&wait_for_all_event_fragments_received_] { + if (!all_fragments_received_cond_.wait_for(its_lock, std::chrono::seconds(5), [&wait_for_all_event_fragments_received_] { return !wait_for_all_event_fragments_received_; })) { ADD_FAILURE() << "Didn't receive fragmented event from master within time"; @@ -1034,7 +1043,7 @@ TEST_P(someip_tp, send_in_mode) { for (const order_e mode : {order_e::ASCENDING, order_e::DESCENDING}) { while (wait_for_all_fragments_received_as_server_) { if (std::cv_status::timeout - == all_fragments_received_as_server_cond_.wait_for(all_fragments_received_as_server_lock, std::chrono::seconds(20))) { + == all_fragments_received_as_server_cond_.wait_for(all_fragments_received_as_server_lock, std::chrono::seconds(5))) { ADD_FAILURE() << "Didn't receive request from client within time: " << std::uint32_t(mode); return; } else { diff --git a/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp b/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp index de289dff1..4b15af37a 100644 --- a/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp +++ b/test/network_tests/someip_tp_tests/someip_tp_test_service.cpp @@ -261,6 +261,8 @@ class someip_tp_test_service { offer(); condition_.wait(its_lock, [this] { return !wait_for_slave_service_available_; }); + + condition_.wait(its_lock, [this] { return !wait_for_slave_subscription_; }); send_fragmented_request_to_slave(); condition_.wait(its_lock, [this] { return !wait_for_two_responses_of_slave_; }); @@ -270,9 +272,9 @@ class someip_tp_test_service { EXPECT_EQ(2u, number_requests_from_slave_); condition_.wait(its_lock, [this] { return !wait_for_two_notifications_of_slave_; }); + EXPECT_EQ(2u, number_notifications_of_slave_); - condition_.wait(its_lock, [this] { return !wait_for_slave_subscription_; }); // slave subscribed --> sent a notification on_notify_method_called(vsomeip::runtime::get()->create_message()); diff --git a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_globals.hpp b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_globals.hpp index 84ca4ae2e..7aa0e836f 100644 --- a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_globals.hpp +++ b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ -#define SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ +#pragma once namespace subscribe_notify_one_test { @@ -29,5 +28,3 @@ static constexpr std::array service_infos = {{// placeholder to static constexpr int notifications_to_send = 10; } - -#endif /* SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_starter.sh.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_starter.sh.in index 42d8dbb54..794b53390 100755 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_starter.sh.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_master_starter.sh.in @@ -38,7 +38,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=$2 export VSOMEIP_APPLICATION_NAME=client-routingmanagerd # start daemon -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the client diff --git a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_slave_starter.sh.in b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_slave_starter.sh.in index 1b6aab939..7626f61f9 100755 --- a/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_slave_starter.sh.in +++ b/test/network_tests/subscribe_notify_tests/conf/subscribe_notify_test_one_event_two_eventgroups_slave_starter.sh.in @@ -28,7 +28,7 @@ FAIL=0 export VSOMEIP_CONFIGURATION=$2 # start daemon export VSOMEIP_APPLICATION_NAME=server-routingmanagerd -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! # Start the services diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_globals.hpp b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_globals.hpp index bb646de3b..5f0ce9205 100644 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_globals.hpp +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_globals.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ -#define SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ +#pragma once namespace subscribe_notify_test { @@ -47,5 +46,3 @@ static constexpr vsomeip::method_t shutdown_method_id = 0x6666; static constexpr vsomeip::method_t set_method_id = 0x7777; } - -#endif /* SUBSCRIBE_NOTIFY_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp index cbbbe5350..23b69c361 100644 --- a/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp +++ b/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_client.cpp @@ -129,10 +129,6 @@ class subscribe_notify_test_one_event_two_eventgroups_client { } else if (_response->get_method() >= info_.event_id && _response->get_method() <= static_cast(info_.event_id + 3)) { received_events_.push_back(_response->get_payload()); - if (received_events_.size() > 8) { - ADD_FAILURE() << "Received too many events [" << std::hex << _response->get_method() << " (" << std::dec - << received_events_.size() << ")"; - } number_received_events_[_response->get_method()]++; events_condition_.notify_one(); } else { @@ -197,14 +193,14 @@ class subscribe_notify_test_one_event_two_eventgroups_client { } void wait_for_events(std::unique_lock& _lock, std::condition_variable& _condition) { - // For the "normal" events, we expected to received 1 notification from each event, which sums up to 3 total notifications + // For the "normal" events, we expected to receive at least one 1 notification from each event, so >= 3 notifications constexpr int _expected_number_received_events = 3; if (!_condition.wait_for(_lock, std::chrono::seconds(5), [this] { return received_events_.size() >= _expected_number_received_events; })) { ADD_FAILURE() << "Didn't receive expected number of events: " << _expected_number_received_events << " within time. Instead received: " << received_events_.size(); } - ASSERT_EQ(received_events_.size(), 3); + ASSERT_GE(received_events_.size(), 3); } void check_received_events_payload(vsomeip::byte_t _value) { @@ -218,7 +214,7 @@ class subscribe_notify_test_one_event_two_eventgroups_client { void check_received_initial_events_number(std::set> _expected) { for (const auto& e : _expected) { auto event = number_received_events_.find(e.first); - ASSERT_NE(number_received_events_.end(), event); + ASSERT_NE(number_received_events_.end(), event) << e.first; switch (event->first) { case 0x8111: ASSERT_GE(event->second, 1) << "Didn't receive initial events for event:" << event->first; @@ -264,7 +260,7 @@ class subscribe_notify_test_one_event_two_eventgroups_client { std::set> its_expected; its_expected.insert({info_.event_id, 1}); its_expected.insert({static_cast(info_.event_id + 1), 1}); - // Initial event for the event which is member of both eventgroups has to be sent twice + // Initial event for the event which is member of both eventgroups has to be sent at least twice // see TR_SOMEIP_00571 its_expected.insert({static_cast(info_.event_id + 2), 2}); diff --git a/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_master_starter.sh.in b/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_master_starter.sh.in index 729dd9af9..ab15f3ffa 100755 --- a/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_master_starter.sh.in +++ b/test/network_tests/suspend_resume_tests/conf/suspend_resume_test_master_starter.sh.in @@ -23,7 +23,7 @@ export VSOMEIP_CONFIGURATION=suspend_resume_test_service.json # start daemon echo -e "[TEST-sh]: Starting RoutingManager" -../../../examples/routingmanagerd/routingmanagerd & +routingmanagerd & PID_VSOMEIPD=$! echo -e "\n\n[TEST-sh]: Started RoutingManager with PID=$PID_VSOMEIPD" diff --git a/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp b/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp index b5211dc8d..229f62260 100644 --- a/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp +++ b/test/network_tests/suspend_resume_tests/suspend_resume_test.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef SUSPEND_RESUME_TEST_ -#define SUSPEND_RESUME_TEST_ +#pragma once #include "../someip_test_globals.hpp" #include @@ -21,5 +20,3 @@ #define TEST_SUSPEND 0x00 #define TEST_STOP 0xFF - -#endif // SUSPEND_RESUME_TEST_ diff --git a/test/unit_tests/endpoint_tests/CMakeLists.txt b/test/unit_tests/endpoint_tests/CMakeLists.txt index c55bec740..55211938d 100644 --- a/test/unit_tests/endpoint_tests/CMakeLists.txt +++ b/test/unit_tests/endpoint_tests/CMakeLists.txt @@ -14,29 +14,6 @@ set(TEST_SRCS test_local_receive_buffer.cpp ) -# We need to set the source files directly because vsomeip doesn't export the -# timer for linking. -set( - VSIP_SRCS - ../../../implementation/endpoints/src/timer.cpp - ../../../implementation/endpoints/src/abstract_socket_factory.cpp - ../../../implementation/endpoints/src/asio_socket_factory.cpp - ../../../implementation/endpoints/src/netlink_connector.cpp - ../../../implementation/endpoints/src/local_endpoint.cpp - ../../../implementation/endpoints/src/local_server.cpp - ../../../implementation/endpoints/src/local_receive_buffer.cpp - ../../../implementation/endpoints/src/local_acceptor_uds_impl.cpp - ../../../implementation/endpoints/src/local_socket_uds_impl.cpp - ../../../implementation/endpoints/src/local_socket.cpp - ../../../implementation/protocol/src/command.cpp - ../../../implementation/protocol/src/config_command.cpp - ../../../implementation/protocol/src/assign_client_command.cpp - ../../../implementation/protocol/src/assign_client_ack_command.cpp - ../../../implementation/protocol/src/service_command_base.cpp - ../../../implementation/protocol/src/offer_service_command.cpp - ../../../implementation/configuration/src/configuration_impl.cpp -) - # see https://github.com/google/googletest/issues/3514 # otherwise test_local_endpoint.cpp fails to compile in clang add_compile_options(-Wno-uninitialized) @@ -51,7 +28,8 @@ target_link_libraries( ${PROJECT_NAME} gtest gmock - ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-test + ${VSOMEIP_NAME}-cfg-test ${Boost_LIBRARIES} ) diff --git a/test/unit_tests/endpoint_tests/base_endpoint_fixture.hpp b/test/unit_tests/endpoint_tests/base_endpoint_fixture.hpp index 6bd567983..a2ff7ed3a 100644 --- a/test/unit_tests/endpoint_tests/base_endpoint_fixture.hpp +++ b/test/unit_tests/endpoint_tests/base_endpoint_fixture.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_BASE_ENDPOINT_FIXTURE -#define VSOMEIP_V3_BASE_ENDPOINT_FIXTURE +#pragma once #include "delegating_socket_factory.hpp" @@ -19,5 +18,3 @@ struct base_endpoint_fixture : ::testing::Test { }; } - -#endif diff --git a/test/unit_tests/endpoint_tests/delegating_socket_factory.hpp b/test/unit_tests/endpoint_tests/delegating_socket_factory.hpp index a1d150137..a9655de31 100644 --- a/test/unit_tests/endpoint_tests/delegating_socket_factory.hpp +++ b/test/unit_tests/endpoint_tests/delegating_socket_factory.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_DELEGATING_SOCKET_FACTORY_ -#define VSOMEIP_V3_DELEGATING_SOCKET_FACTORY_ +#pragma once #include "../../../implementation/endpoints/include/abstract_socket_factory.hpp" @@ -34,5 +33,3 @@ class delegating_socket_factory : public abstract_socket_factory { std::shared_ptr impl_; }; } - -#endif diff --git a/test/unit_tests/endpoint_tests/mock_routing_host.hpp b/test/unit_tests/endpoint_tests/mock_routing_host.hpp index 831378663..65aa1e29b 100644 --- a/test/unit_tests/endpoint_tests/mock_routing_host.hpp +++ b/test/unit_tests/endpoint_tests/mock_routing_host.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_MOCK_ROUTING_HOST_ -#define VSOMEIP_V3_MOCK_ROUTING_HOST_ +#pragma once #include "../../../implementation/routing/include/routing_host.hpp" @@ -31,5 +30,3 @@ class mock_routing_host : public routing_host { MOCK_METHOD(void, remove_subscriptions, (port_t, const boost::asio::ip::address&, port_t), (override)); }; } - -#endif diff --git a/test/unit_tests/endpoint_tests/test_timer.hpp b/test/unit_tests/endpoint_tests/test_timer.hpp index 1014995c1..06198f51f 100644 --- a/test/unit_tests/endpoint_tests/test_timer.hpp +++ b/test/unit_tests/endpoint_tests/test_timer.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_V3_TIMER_TESTING_ -#define VSOMEIP_V3_TIMER_TESTING_ +#pragma once #include "base_endpoint_fixture.hpp" @@ -73,4 +72,3 @@ struct test_timer_base : base_endpoint_fixture { std::shared_ptr factory_; }; } -#endif diff --git a/test/unit_tests/message_deserializer_tests/CMakeLists.txt b/test/unit_tests/message_deserializer_tests/CMakeLists.txt index d00bc3853..9bc7cbd2f 100644 --- a/test/unit_tests/message_deserializer_tests/CMakeLists.txt +++ b/test/unit_tests/message_deserializer_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test Threads::Threads ${Boost_LIBRARIES} ${DL_LIBRARY} diff --git a/test/unit_tests/message_payload_impl_tests/CMakeLists.txt b/test/unit_tests/message_payload_impl_tests/CMakeLists.txt index c23898401..0a638589e 100644 --- a/test/unit_tests/message_payload_impl_tests/CMakeLists.txt +++ b/test/unit_tests/message_payload_impl_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test ${Boost_LIBRARIES} ${DL_LIBRARY} gtest diff --git a/test/unit_tests/message_serializer_tests/CMakeLists.txt b/test/unit_tests/message_serializer_tests/CMakeLists.txt index b28eb52e3..25f11af90 100644 --- a/test/unit_tests/message_serializer_tests/CMakeLists.txt +++ b/test/unit_tests/message_serializer_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test ${Boost_LIBRARIES} ${DL_LIBRARY} gtest diff --git a/test/unit_tests/netlink_tests/CMakeLists.txt b/test/unit_tests/netlink_tests/CMakeLists.txt index 8856dffd4..66e73f558 100644 --- a/test/unit_tests/netlink_tests/CMakeLists.txt +++ b/test/unit_tests/netlink_tests/CMakeLists.txt @@ -7,16 +7,18 @@ project(unit_tests_netlink_tests LANGUAGES CXX) set(THREADS_PREFER_PTHREAD_FLAG ON) -file(GLOB SRCS *.cpp ../main.cpp - "../../../implementation/endpoints/src/netlink_connector.cpp") +file(GLOB SRCS *.cpp ../main.cpp) add_executable(${PROJECT_NAME} ${SRCS}) -target_link_libraries(${PROJECT_NAME} - PRIVATE Threads::Threads ${Boost_LIBRARIES} ${DL_LIBRARY} gtest vsomeip_utilities) - -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${PROJECT_NAME} PRIVATE stdc++ m) -endif() +target_link_libraries( + ${PROJECT_NAME} + vsomeip3-test + vsomeip3-cfg-test + ${Boost_LIBRARIES} + ${DL_LIBRARY} + gtest + vsomeip_utilities +) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/test/unit_tests/protocol_tests/CMakeLists.txt b/test/unit_tests/protocol_tests/CMakeLists.txt index 7bd580848..32a6573c8 100644 --- a/test/unit_tests/protocol_tests/CMakeLists.txt +++ b/test/unit_tests/protocol_tests/CMakeLists.txt @@ -7,22 +7,15 @@ project("unit_tests_protocol_tests" LANGUAGES CXX) file(GLOB TEST_SRCS main.cpp *.cpp) -# We need to set the source files directly because vsomeip doesn't export the -# commands for linking. -set( - VSIP_SRCS - ../../../implementation/protocol/src/config_command.cpp - ../../../implementation/protocol/src/command.cpp -) - add_executable( ${PROJECT_NAME} ${TEST_SRCS} - ${VSIP_SRCS} ) target_link_libraries( ${PROJECT_NAME} + vsomeip3-test + vsomeip3-cfg-test gtest ) diff --git a/test/unit_tests/routing_manager_tests/CMakeLists.txt b/test/unit_tests/routing_manager_tests/CMakeLists.txt index 751ca8b06..7ba8df28d 100644 --- a/test/unit_tests/routing_manager_tests/CMakeLists.txt +++ b/test/unit_tests/routing_manager_tests/CMakeLists.txt @@ -3,9 +3,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -project("unit_tests_routing_manager_tests" LANGUAGES CXX) +project(unit_tests_routing_manager_tests LANGUAGES CXX) -file(GLOB SRCS ../main.cpp routing_manager_ut_setup.cpp ut_set_routing_state.cpp mocks/*.cpp) +file(GLOB SRCS ../main.cpp routing_manager_ut_setup.cpp routing_manager_base_tests.cpp ut_set_routing_state.cpp mocks/*.cpp) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -13,10 +13,11 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) # Executable and libraries to link # ---------------------------------------------------------------------------- add_executable(${PROJECT_NAME} ${SRCS}) + target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test Threads::Threads ${Boost_LIBRARIES} ${DL_LIBRARY} @@ -55,7 +56,7 @@ target_link_libraries( unit_tests_routing_client_state_machine gtest gmock - ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-test ${Boost_LIBRARIES} ) diff --git a/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_base.hpp b/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_base.hpp new file mode 100644 index 000000000..154b159fb --- /dev/null +++ b/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_base.hpp @@ -0,0 +1,105 @@ +// Copyright (C) 2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wkeyword-macro" +#endif + +#include "mock_routing_manager_host.hpp" +#include "../../../../implementation/routing/include/routing_manager_base.hpp" + +namespace vsomeip_v3 { + +class mock_rmb final : public routing_manager_base { +public: + explicit mock_rmb(mock_routing_manager_host* host) : routing_manager_base(static_cast(host)) { + using ::testing::_; + using ::testing::Invoke; + + ON_CALL(*this, create_placeholder_event_and_subscribe(_, _, _, _, _, _)) + .WillByDefault(Invoke(this, &mock_rmb::create_placeholder_event_and_subscribe_default)); + } + + ~mock_rmb() override = default; + + using vsomeip_v3::routing_manager_base::insert_subscription; + + MOCK_METHOD(std::string, get_env, (client_t _client), (const, override)); + MOCK_METHOD(void, init, (), (override)); + + MOCK_METHOD(void, subscribe, + (client_t _client, const vsomeip_sec_client_t* _sec_client, service_t _service, instance_t _instance, + eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr& _filter), + (override)); + + MOCK_METHOD(bool, send, + (client_t _client, const byte_t* _data, uint32_t _size, instance_t _instance, bool _reliable, client_t _bound_client, + const vsomeip_sec_client_t* _sec_client, uint8_t _status_check, bool _sent_from_remote, bool _force), + (override)); + + MOCK_METHOD(void, on_message, + (const byte_t* _data, length_t _length, boardnet_endpoint* _receiver, bool _is_multicast, client_t _bound_client, + const vsomeip_sec_client_t* _sec_client, const boost::asio::ip::address& _sender, uint16_t _port), + (override)); + + MOCK_METHOD(void, register_client_error_handler, (client_t _client, const std::shared_ptr& _endpoint), (override)); + + MOCK_METHOD(void, send_get_offered_services_info, (client_t _client, offer_type_e _offer_type), (override)); + + MOCK_METHOD(void, start, (), (override)); + MOCK_METHOD(void, stop, (), (override)); + + MOCK_METHOD(bool, send_to, (client_t _client, const std::shared_ptr& _target, std::shared_ptr _message), + (override)); + + MOCK_METHOD(bool, send_to, + (const std::shared_ptr& _target, const byte_t* _data, uint32_t _size, instance_t _instance), + (override)); + + MOCK_METHOD(void, send_subscribe, + (client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, + event_t _event, const std::shared_ptr& _filter), + (override)); + + MOCK_METHOD(bool, create_placeholder_event_and_subscribe, + (service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, + const std::shared_ptr& _filter, client_t _client), + (override)); + +private: + // Defines a "Default" method to be called as create_placeholder_event_and_subscribe() is a pure virtual and is extremely necessary to + // test rmb_fixture.double_insert_subscription + bool create_placeholder_event_and_subscribe_default(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, + const std::shared_ptr& _filter, client_t _client) { + + bool is_inserted(false); + std::set its_eventgroups({_eventgroup}); + + routing_manager_base::register_event(_client, _service, _instance, _event, its_eventgroups, event_type_e::ET_UNKNOWN, + reliability_type_e::RT_UNKNOWN, std::chrono::milliseconds::zero(), false, true, nullptr, false, + false, true); + + std::shared_ptr its_event = find_event(_service, _instance, _event); + if (its_event) { + is_inserted = its_event->add_subscriber(_eventgroup, _filter, _client, false); + } + + return is_inserted; + } +}; + +} // namespace vsomeip_v3 diff --git a/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_host.hpp b/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_host.hpp index 0322cc96a..f1fd83f3b 100644 --- a/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_host.hpp +++ b/test/unit_tests/routing_manager_tests/mocks/mock_routing_manager_host.hpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#pragma once + #include #include "../../../../implementation/routing/include/routing_manager_host.hpp" diff --git a/test/unit_tests/routing_manager_tests/routing_manager_base_tests.cpp b/test/unit_tests/routing_manager_tests/routing_manager_base_tests.cpp new file mode 100644 index 000000000..360bb048d --- /dev/null +++ b/test/unit_tests/routing_manager_tests/routing_manager_base_tests.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +#include + +#include "mocks/mock_routing_manager_base.hpp" +#include "mocks/mock_routing_manager_host.hpp" +#include "../../../implementation/configuration/include/configuration_impl.hpp" + +using namespace vsomeip_v3; + +class rmb_fixture : public ::testing::Test { +protected: + boost::asio::io_context io_; + ::testing::NiceMock host_; + + std::shared_ptr cfg_ = std::make_shared(""); + std::string name_{"unit_tests_routing_manager_tests"}; + + void SetUp() override { + ON_CALL(host_, get_io()).WillByDefault(::testing::ReturnRef(io_)); + ON_CALL(host_, get_name()).WillByDefault(::testing::ReturnRef(name_)); + ON_CALL(host_, get_configuration()).WillByDefault(::testing::Return(cfg_)); + } + +public: + service_t its_service = 0x1234; + instance_t its_instance = 0x5678; + eventgroup_t its_eventgroup = 0x9999; + event_t its_event = 0x3333; + std::shared_ptr its_filter = std::make_shared(); + client_t client_one = 0x1111; + client_t client_two = 0x2222; +}; + +// Ensures that concurrent calls of insert_subscription does not result in multiple calls to create_placeholder_event_and_subscribe, as this +// will lead to clients failing to subscribe +TEST_F(rmb_fixture, double_insert_subscription) { + vsomeip_v3::mock_rmb rmb(&host_); + + EXPECT_CALL(rmb, + create_placeholder_event_and_subscribe(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .Times(1); + + // Used to add concurrency and check if create_placeholder_event_and_subscribe() will be called twice + std::thread its_thread( + [&]() { (void)rmb.insert_subscription(its_service, its_instance, its_eventgroup, its_event, its_filter, client_one); }); + + (void)rmb.insert_subscription(its_service, its_instance, its_eventgroup, its_event, its_filter, client_two); + its_thread.join(); +} diff --git a/test/unit_tests/routing_manager_tests/routing_manager_ut_setup.hpp b/test/unit_tests/routing_manager_tests/routing_manager_ut_setup.hpp index d09d73a42..31402a61e 100644 --- a/test/unit_tests/routing_manager_tests/routing_manager_ut_setup.hpp +++ b/test/unit_tests/routing_manager_tests/routing_manager_ut_setup.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef ROUTING_MANAGER_UT_SETUP_HPP -#define ROUTING_MANAGER_UT_SETUP_HPP +#pragma once #include @@ -27,5 +26,3 @@ class routing_manager_ut_setup : public testing::Test { // Tears down the test fixture. void TearDown() override; }; - -#endif // ROUTING_MANAGER_UT_SETUP_HPP diff --git a/test/unit_tests/routing_manager_tests/ut_routing_client_state_machine.cpp b/test/unit_tests/routing_manager_tests/ut_routing_client_state_machine.cpp index a47b99752..4a23c195f 100644 --- a/test/unit_tests/routing_manager_tests/ut_routing_client_state_machine.cpp +++ b/test/unit_tests/routing_manager_tests/ut_routing_client_state_machine.cpp @@ -99,7 +99,7 @@ TEST_F(routing_client_state_machine_test, happy_path_full_registration) { EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm->state()); // ST_ASSIGNING -> ST_ASSIGNED - EXPECT_TRUE(sm->assigned()); + EXPECT_TRUE(sm->assigned(0x1234)); EXPECT_EQ(routing_client_state_e::ST_ASSIGNED, sm->state()); // ST_ASSIGNED -> ST_REGISTERING @@ -134,7 +134,7 @@ TEST_F(routing_client_state_machine_test, deregistered_from_any_state) { // From ST_ASSIGNED ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); initial_count = get_error_count(); sm->deregistered(); EXPECT_EQ(routing_client_state_e::ST_DEREGISTERED, sm->state()); @@ -144,7 +144,7 @@ TEST_F(routing_client_state_machine_test, deregistered_from_any_state) { // From ST_REGISTERING ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); initial_count = get_error_count(); sm->deregistered(); @@ -155,7 +155,7 @@ TEST_F(routing_client_state_machine_test, deregistered_from_any_state) { // From ST_REGISTERED ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); initial_count = get_error_count(); @@ -171,7 +171,7 @@ TEST_F(routing_client_state_machine_test, graceful_deregistration_flow) { // Get to registered state ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); @@ -209,7 +209,7 @@ TEST_F(routing_client_state_machine_test, cannot_start_connecting_from_non_dereg EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm->state()); // Get to ST_ASSIGNED - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); EXPECT_FALSE(sm->start_assignment()); EXPECT_EQ(routing_client_state_e::ST_ASSIGNED, sm->state()); } @@ -219,15 +219,15 @@ TEST_F(routing_client_state_machine_test, cannot_mark_assigned_from_non_assignin sm->target_running(); // From ST_DEREGISTERED - EXPECT_FALSE(sm->assigned()); + EXPECT_FALSE(sm->assigned(0x1234)); EXPECT_EQ(routing_client_state_e::ST_DEREGISTERED, sm->state()); // Get to ST_ASSIGNED ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); // From ST_ASSIGNED - EXPECT_FALSE(sm->assigned()); + EXPECT_FALSE(sm->assigned(0x1234)); EXPECT_EQ(routing_client_state_e::ST_ASSIGNED, sm->state()); } @@ -245,7 +245,7 @@ TEST_F(routing_client_state_machine_test, cannot_start_registration_from_non_ass EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm->state()); // Get to ST_REGISTERING - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // From ST_REGISTERING @@ -267,7 +267,7 @@ TEST_F(routing_client_state_machine_test, cannot_mark_registered_from_non_regist EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm->state()); // From ST_ASSIGNED - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); EXPECT_FALSE(sm->registered()); EXPECT_EQ(routing_client_state_e::ST_ASSIGNED, sm->state()); @@ -304,7 +304,7 @@ TEST_F(routing_client_state_machine_test, registration_timeout) { int initial_count = get_error_count(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); EXPECT_EQ(routing_client_state_e::ST_REGISTERING, sm->state()); @@ -319,7 +319,7 @@ TEST_F(routing_client_state_machine_test, registration_timeout_canceled_on_succe int initial_count = get_error_count(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // Complete registration before timeout @@ -340,7 +340,7 @@ TEST_F(routing_client_state_machine_test, await_registered_succeeds_when_already sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); @@ -352,7 +352,7 @@ TEST_F(routing_client_state_machine_test, await_registered_waits_for_registratio sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // Start waiting in separate thread @@ -382,7 +382,7 @@ TEST_F(routing_client_state_machine_test, await_registered_times_out) { sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // Don't call registered() - should timeout @@ -400,7 +400,7 @@ TEST_F(routing_client_state_machine_test, await_deregistered_waits_for_deregistr sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); ASSERT_TRUE(sm->start_deregister()); @@ -437,7 +437,7 @@ TEST_F(routing_client_state_machine_test, can_reregister_after_deregistration) { // First registration ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); @@ -450,7 +450,7 @@ TEST_F(routing_client_state_machine_test, can_reregister_after_deregistration) { // Second registration EXPECT_TRUE(sm->start_assignment()); - EXPECT_TRUE(sm->assigned()); + EXPECT_TRUE(sm->assigned(0x1234)); EXPECT_TRUE(sm->start_registration()); EXPECT_TRUE(sm->registered()); EXPECT_EQ(routing_client_state_e::ST_REGISTERED, sm->state()); @@ -466,7 +466,7 @@ TEST_F(routing_client_state_machine_test, can_reregister_after_registration_time // First attempt with timeout ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); EXPECT_TRUE(wait_for_error(initial_count, 700ms)); EXPECT_EQ(routing_client_state_e::ST_DEREGISTERED, sm->state()); @@ -475,7 +475,7 @@ TEST_F(routing_client_state_machine_test, can_reregister_after_registration_time // Second attempt successful EXPECT_TRUE(sm->start_assignment()); - EXPECT_TRUE(sm->assigned()); + EXPECT_TRUE(sm->assigned(0x1234)); EXPECT_TRUE(sm->start_registration()); EXPECT_TRUE(sm->registered()); EXPECT_EQ(routing_client_state_e::ST_REGISTERED, sm->state()); @@ -509,7 +509,7 @@ TEST_F(routing_client_state_machine_test, can_restart_after_shutdown) { sm->target_shutdown(); // Cannot proceed while shut down - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_FALSE(sm->start_registration()); // Deregister and restart @@ -529,7 +529,7 @@ TEST_F(routing_client_state_machine_test, error_handler_called_on_timeout) { int initial_count = get_error_count(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); EXPECT_TRUE(wait_for_error(initial_count, 200ms)); @@ -565,7 +565,7 @@ TEST_F(routing_client_state_machine_test, error_handler_can_reenter_state_machin sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); std::this_thread::sleep_for(75ms); @@ -580,7 +580,7 @@ TEST_F(routing_client_state_machine_test, no_error_handler_on_graceful_shutdown) sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // Shutdown before timeout @@ -604,7 +604,7 @@ TEST_F(routing_client_state_machine_test, no_stale_handlers_after_rapid_restart) // Start assignment that will timeout ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // Wait for timeout and handler execution @@ -615,7 +615,7 @@ TEST_F(routing_client_state_machine_test, no_stale_handlers_after_rapid_restart) // Immediately restart and complete registration ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); @@ -634,7 +634,7 @@ TEST_F(routing_client_state_machine_test, multiple_shutdown_restart_cycles_no_ac for (int cycle = 0; cycle < 3; ++cycle) { sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); // Shutdown before timeout @@ -649,7 +649,7 @@ TEST_F(routing_client_state_machine_test, multiple_shutdown_restart_cycles_no_ac // Restart one more time sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); std::this_thread::sleep_for(10ms); @@ -663,7 +663,7 @@ TEST_F(routing_client_state_machine_test, graceful_deregister_after_registered_c // Get to registered state ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); @@ -682,7 +682,7 @@ TEST_F(routing_client_state_machine_test, graceful_deregister_with_shutdown_no_h sm->target_running(); ASSERT_TRUE(sm->start_assignment()); - ASSERT_TRUE(sm->assigned()); + ASSERT_TRUE(sm->assigned(0x1234)); ASSERT_TRUE(sm->start_registration()); ASSERT_TRUE(sm->registered()); ASSERT_TRUE(sm->start_deregister()); @@ -708,7 +708,7 @@ TEST_F(routing_client_state_machine_test, rapid_state_transitions) { // Rapid transitions without delays EXPECT_TRUE(sm->start_assignment()); - EXPECT_TRUE(sm->assigned()); + EXPECT_TRUE(sm->assigned(0x1234)); EXPECT_TRUE(sm->start_registration()); EXPECT_TRUE(sm->registered()); EXPECT_EQ(routing_client_state_e::ST_REGISTERED, sm->state()); @@ -728,7 +728,7 @@ TEST_F(routing_client_state_machine_test, multiple_state_machine_instances) { EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm1->state()); EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm2->state()); - EXPECT_TRUE(sm1->assigned()); + EXPECT_TRUE(sm1->assigned(0x1234)); EXPECT_EQ(routing_client_state_e::ST_ASSIGNED, sm1->state()); EXPECT_EQ(routing_client_state_e::ST_ASSIGNING, sm2->state()); } diff --git a/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt b/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt index c19640f49..a35c16698 100644 --- a/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt +++ b/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test ${Boost_LIBRARIES} ${DL_LIBRARY} gtest diff --git a/test/unit_tests/security_policy_tests/CMakeLists.txt b/test/unit_tests/security_policy_tests/CMakeLists.txt index 20b36c02c..e2bba3bcb 100644 --- a/test/unit_tests/security_policy_tests/CMakeLists.txt +++ b/test/unit_tests/security_policy_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test ${Boost_LIBRARIES} ${DL_LIBRARY} gtest diff --git a/test/unit_tests/security_tests/CMakeLists.txt b/test/unit_tests/security_tests/CMakeLists.txt index 6ee0e43d8..7280216ce 100644 --- a/test/unit_tests/security_tests/CMakeLists.txt +++ b/test/unit_tests/security_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test Threads::Threads ${Boost_LIBRARIES} ${DL_LIBRARY} diff --git a/test/unit_tests/usei_tests/CMakeLists.txt b/test/unit_tests/usei_tests/CMakeLists.txt index a17a0b1c7..9fb3cca31 100644 --- a/test/unit_tests/usei_tests/CMakeLists.txt +++ b/test/unit_tests/usei_tests/CMakeLists.txt @@ -7,14 +7,14 @@ project(unit_tests_usei_tests LANGUAGES CXX) set(THREADS_PREFER_PTHREAD_FLAG ON) -file(GLOB SRCS *.cpp ../main.cpp - "../../../implementation/endpoints/src/udp_server_endpoint_impl.cpp") +file(GLOB SRCS *.cpp ../main.cpp) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} PRIVATE - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test Threads::Threads ${Boost_LIBRARIES} ${DL_LIBRARY} diff --git a/test/unit_tests/usei_tests/mocked_vsomeip_dependencies.hpp b/test/unit_tests/usei_tests/mocked_vsomeip_dependencies.hpp index 90a855fec..ffcced254 100644 --- a/test/unit_tests/usei_tests/mocked_vsomeip_dependencies.hpp +++ b/test/unit_tests/usei_tests/mocked_vsomeip_dependencies.hpp @@ -3,8 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef MOCKED_VSOMEIP_DEPENDENCIES_HPP_ -#define MOCKED_VSOMEIP_DEPENDENCIES_HPP_ +#pragma once #include @@ -42,9 +41,6 @@ void vsomeip_v3::endpoint_impl::add_default_target(service_t, const st template void vsomeip_v3::endpoint_impl::remove_default_target(service_t) { } -template -void vsomeip_v3::endpoint_impl::remove_stop_handler(service_t) { } - template vsomeip_v3::instance_t vsomeip_v3::endpoint_impl::get_instance(service_t /*_service*/) { return 0xFFFF; @@ -57,10 +53,6 @@ vsomeip_v3::server_endpoint_impl::server_endpoint_impl(const std::shar const std::shared_ptr& _configuration) : endpoint_impl(_endpoint_host, _routing_host, _io, _configuration) { } -template -void vsomeip_v3::server_endpoint_impl::prepare_stop(const boardnet_endpoint::prepare_stop_handler_t& /*_handler*/, - service_t /*_service*/) { } - template void vsomeip_v3::server_endpoint_impl::stop(bool /*_due_to_error*/) { } @@ -176,9 +168,6 @@ void vsomeip_v3::server_endpoint_impl::send_cbk(const endpoint_type /* template void vsomeip_v3::server_endpoint_impl::flush_cbk(endpoint_type /*_key*/, const boost::system::error_code& /*_error_code*/) { } -template -void vsomeip_v3::server_endpoint_impl::remove_stop_handler(service_t /*_service*/) { } - template size_t vsomeip_v3::server_endpoint_impl::get_queue_size() const { return 0; @@ -258,5 +247,3 @@ struct mock_routing_host : public vsomeip_v3::routing_host { void(vsomeip_v3::port_t _local_port, const boost::asio::ip::address& _remote_address, vsomeip_v3::port_t _remote_port)); MOCK_METHOD0(get_routing_state, vsomeip_v3::routing_state_e()); }; - -#endif /* MOCKED_VSOMEIP_DEPENDENCIES_HPP_ */ diff --git a/test/unit_tests/usei_tests/ut_basic_tests.cpp b/test/unit_tests/usei_tests/ut_basic_tests.cpp index 498ee5cd3..de40dfda6 100644 --- a/test/unit_tests/usei_tests/ut_basic_tests.cpp +++ b/test/unit_tests/usei_tests/ut_basic_tests.cpp @@ -220,15 +220,14 @@ TEST_F(usei_fixture, no_overwrite_during_restart) { // continued to run and, since it shared the same buffer with the new task, this // corrupted the data. The problem is that this condition occurs at restart (so // messages are lost) and that Linux can too discard UDP messages. This makes it - // difficult to detect the problem. However, it has been verified that this - // value of two-thirds of messages lost is symptomatic of the problem. + // difficult to detect the problem constexpr size_t MESSAGE_SENT_COUNT = 10000; using namespace std::chrono_literals; std::atomic finished{false}; EXPECT_CALL(*endpoint_, on_error).Times(0); - EXPECT_CALL(*routing_, on_message).Times(AtLeast(MESSAGE_SENT_COUNT / 3)); + EXPECT_CALL(*routing_, on_message).Times(AtLeast(100)); boost::system::error_code error; server_->init(unicast_parameters_, error); @@ -261,7 +260,7 @@ TEST_F(usei_fixture, no_overwrite_during_restart_with_multicast) { EXPECT_CALL(*endpoint_, on_error).Times(0); EXPECT_CALL(*endpoint_, add_multicast_option).Times(AtLeast(5)); - EXPECT_CALL(*routing_, on_message).Times(AtLeast(MESSAGE_SENT_COUNT / 3)); + EXPECT_CALL(*routing_, on_message).Times(AtLeast(1000)); boost::system::error_code error; server_->init(unicast_parameters_, error); diff --git a/test/unit_tests/utility_utility_tests/CMakeLists.txt b/test/unit_tests/utility_utility_tests/CMakeLists.txt index 3e9e6f71a..ca4407c8b 100644 --- a/test/unit_tests/utility_utility_tests/CMakeLists.txt +++ b/test/unit_tests/utility_utility_tests/CMakeLists.txt @@ -15,8 +15,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + vsomeip3-test + vsomeip3-cfg-test ${Boost_LIBRARIES} ${DL_LIBRARY} gtest