From 34d317359428f1206703fc8139936d67d295dc96 Mon Sep 17 00:00:00 2001 From: James Choi Date: Wed, 26 Apr 2023 16:49:20 -0400 Subject: [PATCH] Add support for QNX 7.1 Signed-off-by: James Choi --- .gitignore | 2 +- CMakeLists.txt | 29 +- build_qnx/Makefile | 8 + build_qnx/common.mk | 108 +++++++ build_qnx/nto/Makefile | 8 + build_qnx/nto/aarch64/Makefile | 8 + build_qnx/nto/aarch64/le/Makefile | 5 + build_qnx/nto/x86_64/Makefile | 8 + build_qnx/nto/x86_64/o/Makefile | 3 + build_qnx/qnx.nto.toolchain.cmake | 43 +++ examples/routingmanagerd/CMakeLists.txt | 3 + .../configuration/include/internal.hpp.in | 2 +- .../configuration/src/configuration_impl.cpp | 6 +- .../local_server_endpoint_impl_receive_op.hpp | 2 +- .../local_uds_server_endpoint_impl.hpp | 4 +- .../udp_server_endpoint_impl_receive_op.hpp | 2 +- .../endpoints/src/client_endpoint_impl.cpp | 6 +- .../endpoints/src/endpoint_impl.cpp | 7 + .../endpoints/src/endpoint_manager_base.cpp | 6 +- .../endpoints/src/endpoint_manager_impl.cpp | 4 +- .../src/local_tcp_server_endpoint_impl.cpp | 2 +- .../src/local_uds_client_endpoint_impl.cpp | 4 + .../src/local_uds_server_endpoint_impl.cpp | 8 + .../endpoints/src/server_endpoint_impl.cpp | 6 +- .../src/tcp_client_endpoint_impl.cpp | 2 +- .../src/tcp_server_endpoint_impl.cpp | 2 +- implementation/endpoints/src/tp.cpp | 2 +- implementation/endpoints/src/tp_message.cpp | 2 +- .../src/udp_client_endpoint_impl.cpp | 2 +- .../src/udp_server_endpoint_impl.cpp | 2 +- .../asio/detail/impl/socket_ops_ext_local.ipp | 70 +++++ implementation/logger/src/logger_impl.cpp | 4 +- .../plugin/src/plugin_manager_impl.cpp | 4 + .../include/routing_manager_client.hpp | 2 +- .../routing/include/routing_manager_stub.hpp | 6 +- .../routing/src/routing_manager_client.cpp | 10 +- .../routing/src/routing_manager_impl.cpp | 8 +- .../runtime/src/application_impl.cpp | 6 +- .../security/src/policy_manager_impl.cpp | 6 +- implementation/utility/src/wrappers_qnx.cpp | 161 ++++++++++ interface/compat/vsomeip/primitive_types.hpp | 2 +- interface/vsomeip/primitive_types.hpp | 4 +- interface/vsomeip/vsomeip_sec.h | 5 + .../CMakeLists.txt | 4 + test/network_tests/CMakeLists.txt | 51 +++- .../application_tests/application_test.cpp | 2 +- .../application_test_availability.cpp | 2 +- .../application_test_single_process.cpp | 2 +- .../big_payload_test_client.cpp | 2 +- .../big_payload_test_service.cpp | 2 +- .../client_id_test_master_starter_qnx.sh | 80 +++++ .../client_id_test_service.cpp | 2 +- .../client_id_test_utility.cpp | 2 +- .../configuration-test.cpp | 4 +- .../cpu_load_tests/cpu_load_test_client.cpp | 2 +- .../cpu_load_tests/cpu_load_test_service.cpp | 2 +- .../e2e_tests/e2e_profile_04_test_service.cpp | 2 +- .../e2e_tests/e2e_test_service.cpp | 2 +- .../event_tests/event_test_client.cpp | 2 +- .../event_tests/event_test_service.cpp | 2 +- .../header_factory_test.cpp | 2 +- .../header_factory_test_client.cpp | 2 +- .../header_factory_test_service.cpp | 2 +- ...nitial_event_test_availability_checker.cpp | 2 +- .../initial_event_test_client.cpp | 2 +- .../initial_event_test_master_starter_qnx.sh | 163 ++++++++++ .../initial_event_test_service.cpp | 2 +- .../initial_event_test_stop_service.cpp | 2 +- .../malicious_data_test_msg_sender.cpp | 2 +- .../malicious_data_test_service.cpp | 2 +- .../npdu_tests/npdu_test_client.cpp | 2 +- .../npdu_tests/npdu_test_service.cpp | 2 +- ...fer_test_external_master_starter_qnx.sh.in | 150 ++++++++++ .../offer_test_big_sd_msg_client.cpp | 2 +- .../offer_test_big_sd_msg_service.cpp | 2 +- .../offer_tests/offer_test_client.cpp | 2 +- .../offer_test_external_sd_msg_sender.cpp | 2 +- .../offer_test_local_starter_qnx.sh | 278 ++++++++++++++++++ .../offer_tests/offer_test_service.cpp | 2 +- .../offer_test_service_external.cpp | 2 +- .../offered_services_info_test_client.cpp | 2 +- .../offered_services_info_test_service.cpp | 2 +- .../payload_tests/payload_test_client.cpp | 2 +- .../payload_tests/payload_test_service.cpp | 2 +- .../network_tests/payload_tests/stopwatch.cpp | 4 + ...ending_subscription_test_sd_msg_sender.cpp | 2 +- .../pending_subscription_test_service.cpp | 2 +- .../restart_routing_test_service.cpp | 2 +- .../conf/local_routing_test_starter_qnx.sh.in | 76 +++++ .../external_local_routing_test_service.cpp | 2 +- .../local_routing_test_client.cpp | 2 +- .../local_routing_test_service.cpp | 2 +- .../second_address_test_client.cpp | 2 +- .../second_address_test_service.cpp | 2 +- .../security_tests/security_test_service.cpp | 2 +- .../someip_tp_test_msg_sender.cpp | 2 +- .../someip_tp_test_service.cpp | 2 +- ...ribe_notify_one_test_master_starter_qnx.sh | 79 +++++ .../subscribe_notify_one_test_service.cpp | 2 +- ...ubscribe_notify_test_master_starter_qnx.sh | 85 ++++++ ..._test_one_event_two_eventgroups_client.cpp | 2 +- ...test_one_event_two_eventgroups_service.cpp | 2 +- .../subscribe_notify_test_service.cpp | 2 +- .../suspend_resume_test_client.cpp | 2 +- .../suspend_resume_test_service.cpp | 2 +- .../ut_is_policy_update_allowed.cpp | 2 + 106 files changed, 1550 insertions(+), 112 deletions(-) create mode 100644 build_qnx/Makefile create mode 100644 build_qnx/common.mk create mode 100644 build_qnx/nto/Makefile create mode 100644 build_qnx/nto/aarch64/Makefile create mode 100644 build_qnx/nto/aarch64/le/Makefile create mode 100644 build_qnx/nto/x86_64/Makefile create mode 100644 build_qnx/nto/x86_64/o/Makefile create mode 100644 build_qnx/qnx.nto.toolchain.cmake create mode 100644 implementation/utility/src/wrappers_qnx.cpp create mode 100755 test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh create mode 100755 test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh create mode 100755 test/network_tests/offer_tests/conf/offer_test_external_master_starter_qnx.sh.in create mode 100755 test/network_tests/offer_tests/offer_test_local_starter_qnx.sh create mode 100755 test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in create mode 100755 test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh create mode 100755 test/network_tests/subscribe_notify_tests/subscribe_notify_test_master_starter_qnx.sh diff --git a/.gitignore b/.gitignore index 23330ffac..fce128e87 100644 --- a/.gitignore +++ b/.gitignore @@ -109,4 +109,4 @@ test/security_tests/security_test_local_config.json /test/event_tests/event_test_master.json /test/event_tests/event_test_slave_tcp.json /test/event_tests/event_test_slave_udp.json - +!build_qnx/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ff1bbb9e..363500996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,11 @@ find_package(Threads REQUIRED) # Boost find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED ) -include_directories(SYSTEM ${Boost_INCLUDE_DIR} ) +if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + include_directories(${Boost_INCLUDE_DIR} ) +else() + include_directories(SYSTEM ${Boost_INCLUDE_DIR} ) +endif() if(Boost_FOUND) if(Boost_LIBRARY_DIR) @@ -245,6 +249,8 @@ if (MSVC) set(USE_RT "") link_directories(${Boost_LIBRARY_DIR_DEBUG}) ADD_DEFINITIONS( -DBOOST_ALL_DYN_LINK ) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(USE_RT "") else() set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OS_CXX_FLAGS} -g ${OPTIMIZE} -std=c++14 ${NO_DEPRECATED} ${EXPORTSYMBOLS}") set(USE_RT "rt") @@ -347,6 +353,9 @@ endif () target_link_libraries(${VSOMEIP_NAME}-e2e ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES}) +if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + target_link_libraries(${VSOMEIP_NAME}-e2e socket) +endif() ################################################################################ # Compatibility library ################################################################################ @@ -395,7 +404,11 @@ set(EXAMPLE_CONFIG_FILES ################################################################################ # Configuration parameters ################################################################################ -set (VSOMEIP_BASE_PATH "/tmp") +if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set (VSOMEIP_BASE_PATH "/var") +else() + set (VSOMEIP_BASE_PATH "/tmp") +endif() if (BASE_PATH) set (VSOMEIP_BASE_PATH ${BASE_PATH}) endif () @@ -741,3 +754,15 @@ add_dependencies(build_tests build_benchmark_tests) # add test directory add_subdirectory( test EXCLUDE_FROM_ALL ) + +if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + install(DIRECTORY ${PROJECT_BINARY_DIR}/test/ + DESTINATION bin/vsomeip_tests/test + PATTERN "CMakeFiles" EXCLUDE + PATTERN "*.cmake" EXCLUDE + PATTERN "Makefile" EXCLUDE + ) + + install(FILES ${PROJECT_BINARY_DIR}/examples/routingmanagerd/routingmanagerd + DESTINATION bin/vsomeip_tests/examples/routingmanagerd) +endif() diff --git a/build_qnx/Makefile b/build_qnx/Makefile new file mode 100644 index 000000000..1f2540041 --- /dev/null +++ b/build_qnx/Makefile @@ -0,0 +1,8 @@ +LIST=OS +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/common.mk b/build_qnx/common.mk new file mode 100644 index 000000000..387937467 --- /dev/null +++ b/build_qnx/common.mk @@ -0,0 +1,108 @@ +ifndef QCONFIG +QCONFIG=qconfig.mk +endif +include $(QCONFIG) + +#where to install vsomeip: +#$(INSTALL_ROOT_$(OS)) is pointing to $QNX_TARGET +#by default, unless it was manually re-routed to +#a staging area by setting both INSTALL_ROOT_nto +#and USE_INSTALL_ROOT +VSOMEIP_INSTALL_ROOT ?= $(INSTALL_ROOT_$(OS)) + +#where to find the vsomeip external dependencies, such as Boost +VSOMEIP_EXTERNAL_DEPS_INSTALL ?= $(USE_ROOT_$(OS)) + +# Get version information from CMakeLists.txt +VSOMEIP_MAJOR_VERSION = $(word 3, $(shell bash -c "grep VSOMEIP_MAJOR_VERSION $(PROJECT_ROOT)/../CMakeLists.txt | head -1 | head -c-2")) +VSOMEIP_MINOR_VERSION = $(word 3, $(shell bash -c "grep VSOMEIP_MINOR_VERSION $(PROJECT_ROOT)/../CMakeLists.txt | head -1 | head -c-2")) +VSOMEIP_PATCH_VERSION = $(word 3, $(shell bash -c "grep VSOMEIP_PATCH_VERSION $(PROJECT_ROOT)/../CMakeLists.txt | head -1 | head -c-2")) + +#choose Release or Debug +CMAKE_BUILD_TYPE ?= Release + +#set the following to TRUE if you want to compile the vsomeip tests. +#If you do, make sure to set GTEST_ROOT to point to the google test library sources +GENERATE_TESTS ?= TRUE +TEST_IP_MASTER ?= XXX.XXX.XXX.XXX +TEST_IP_SLAVE ?= XXX.XXX.XXX.XXX + +#set the following to FALSE if generating .pinfo files is causing problems +GENERATE_PINFO_FILES ?= TRUE + +#override 'all' target to bypass the default QNX build system +ALL_DEPENDENCIES = vsomeip_all +.PHONY: vsomeip_all + +FLAGS += -g -D_QNX_SOURCE +LDFLAGS += -Wl,--build-id=md5 -lang-c++ -lsocket + +CMAKE_ARGS = -DCMAKE_TOOLCHAIN_FILE=$(PROJECT_ROOT)/qnx.nto.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=$(VSOMEIP_INSTALL_ROOT)/$(CPUVARDIR)/usr \ + -DCMAKE_CXX_STANDARD=14 \ + -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE \ + -DVSOMEIP_EXTERNAL_DEPS_INSTALL=$(VSOMEIP_EXTERNAL_DEPS_INSTALL) \ + -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \ + -DCMAKE_MODULE_PATH=$(PROJECT_ROOT) \ + -DEXTRA_CMAKE_C_FLAGS="$(FLAGS)" \ + -DEXTRA_CMAKE_CXX_FLAGS="$(FLAGS)" \ + -DEXTRA_CMAKE_LINKER_FLAGS="$(LDFLAGS)" \ + -DINSTALL_INCLUDE_DIR=$(VSOMEIP_INSTALL_ROOT)/usr/include \ + -DCPUVARDIR=$(CPUVARDIR) \ + -DGCC_VER=${GCC_VER} \ + -DVSOMEIP_INSTALL_ROUTINGMANAGERD=ON + +ifeq ($(GENERATE_TESTS), TRUE) +CMAKE_ARGS += -DENABLE_SIGNAL_HANDLING=1 \ + -DTEST_IP_MASTER=$(TEST_IP_MASTER) \ + -DTEST_IP_SLAVE=$(TEST_IP_SLAVE) +endif + +MAKE_ARGS ?= -j $(firstword $(JLEVEL) 4) + +define PINFO +endef +PINFO_STATE=Experimental +USEFILE= + +include $(MKFILES_ROOT)/qtargets.mk + +ifneq ($(wildcard $(foreach dir,$(LIBVPATH),$(dir)/libregex.so)),) + LDFLAGS += -lregex +endif + + +ifndef NO_TARGET_OVERRIDE +vsomeip_all: + @mkdir -p build + @cd build && cmake $(CMAKE_ARGS) ../../../../../ + @cd build && make all $(MAKE_ARGS) + @cd build && make build_tests $(MAKE_ARGS) + +install: vsomeip_all + @cd build && make install $(MAKE_ARGS) + @cd build && make build_tests install $(MAKE_ARGS) + +clean iclean spotless: + @rm -fr build + +endif + +#everything down below deals with the generation of the PINFO +#information for shared objects that is used by the QNX build +#infrastructure to embed metadata in the .so files, for example +#data and time, version number, description, etc. Metadata can +#be retrieved on the target by typing 'use -i '. +#this is optional: setting GENERATE_PINFO_FILES to FALSE will disable +#the insertion of metadata in .so files. +ifeq ($(GENERATE_PINFO_FILES), TRUE) +#the following rules are called by the cmake generated makefiles, +#in order to generate the .pinfo files for the shared libraries +%.so.$(VSOMEIP_MAJOR_VERSION).$(VSOMEIP_MINOR_VERSION).$(VSOMEIP_PATCH_VERSION): + $(ADD_PINFO) + $(ADD_USAGE) + +%vsomeipd: + $(ADD_PINFO) + $(ADD_USAGE) +endif diff --git a/build_qnx/nto/Makefile b/build_qnx/nto/Makefile new file mode 100644 index 000000000..0cc5eae2d --- /dev/null +++ b/build_qnx/nto/Makefile @@ -0,0 +1,8 @@ +LIST=CPU +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/nto/aarch64/Makefile b/build_qnx/nto/aarch64/Makefile new file mode 100644 index 000000000..0e22650c0 --- /dev/null +++ b/build_qnx/nto/aarch64/Makefile @@ -0,0 +1,8 @@ +LIST=VARIANT +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/nto/aarch64/le/Makefile b/build_qnx/nto/aarch64/le/Makefile new file mode 100644 index 000000000..966eb3d39 --- /dev/null +++ b/build_qnx/nto/aarch64/le/Makefile @@ -0,0 +1,5 @@ +include ../../../common.mk + +CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=aarch64 +FLAGS += $(VFLAG_le) $(CCVFLAG_le) +LDFLAGS += $(VFLAG_le) $(LDVFLAG_le) diff --git a/build_qnx/nto/x86_64/Makefile b/build_qnx/nto/x86_64/Makefile new file mode 100644 index 000000000..0e22650c0 --- /dev/null +++ b/build_qnx/nto/x86_64/Makefile @@ -0,0 +1,8 @@ +LIST=VARIANT +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/nto/x86_64/o/Makefile b/build_qnx/nto/x86_64/o/Makefile new file mode 100644 index 000000000..68ecccfae --- /dev/null +++ b/build_qnx/nto/x86_64/o/Makefile @@ -0,0 +1,3 @@ +include ../../../common.mk + +CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=x86_64 diff --git a/build_qnx/qnx.nto.toolchain.cmake b/build_qnx/qnx.nto.toolchain.cmake new file mode 100644 index 000000000..6df87db28 --- /dev/null +++ b/build_qnx/qnx.nto.toolchain.cmake @@ -0,0 +1,43 @@ +if("$ENV{QNX_HOST}" STREQUAL "") + message(FATAL_ERROR "QNX_HOST environment variable not found. Please set the variable to your host's build tools") +endif() +if("$ENV{QNX_TARGET}" STREQUAL "") + message(FATAL_ERROR "QNX_TARGET environment variable not found. Please set the variable to the qnx target location") +endif() + +if(CMAKE_HOST_WIN32) + set(HOST_EXECUTABLE_SUFFIX ".exe") + #convert windows paths to cmake paths + file(TO_CMAKE_PATH "$ENV{QNX_HOST}" QNX_HOST) + file(TO_CMAKE_PATH "$ENV{QNX_TARGET}" QNX_TARGET) +else() + set(QNX_HOST "$ENV{QNX_HOST}") + set(QNX_TARGET "$ENV{QNX_TARGET}") +endif() + +message(STATUS "using QNX_HOST ${QNX_HOST}") +message(STATUS "using QNX_TARGET ${QNX_TARGET}") + +set(CMAKE_SYSTEM_NAME QNX) +set(CMAKE_C_COMPILER ${QNX_HOST}/usr/bin/qcc) +set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/qcc) +set(CMAKE_AR "${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-ar${HOST_EXECUTABLE_SUFFIX}" CACHE PATH "archiver") +set(CMAKE_RANLIB "${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-ranlib${HOST_EXECUTABLE_SUFFIX}" CACHE PATH "ranlib") + +if ("${GCC_VER}" STREQUAL "") + set(GCC_VERSION "" CACHE STRING "gcc_ver") +else() + set(GCC_VERSION "${GCC_VER}," CACHE STRING "gcc_ver") +endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -V${GCC_VERSION}gcc_nto${CMAKE_SYSTEM_PROCESSOR} ${EXTRA_CMAKE_C_FLAGS}" CACHE STRING "c_flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -V${GCC_VERSION}gcc_nto${CMAKE_SYSTEM_PROCESSOR} ${EXTRA_CMAKE_CXX_FLAGS}" CACHE STRING "cxx_flags") + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_CMAKE_LINKER_FLAGS}" CACHE STRING "exe_linker_flags") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${EXTRA_CMAKE_LINKER_FLAGS}" CACHE STRING "so_linker_flags") + +set(CMAKE_FIND_ROOT_PATH ${VSOMEIP_EXTERNAL_DEPS_INSTALL};${VSOMEIP_EXTERNAL_DEPS_INSTALL}/${CPUVARDIR};${QNX_TARGET};${QNX_TARGET}/${CPUVARDIR}) + +set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries.") +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/examples/routingmanagerd/CMakeLists.txt b/examples/routingmanagerd/CMakeLists.txt index e0d85aafb..dbdbd4a7a 100644 --- a/examples/routingmanagerd/CMakeLists.txt +++ b/examples/routingmanagerd/CMakeLists.txt @@ -6,6 +6,9 @@ # Daemon add_executable(routingmanagerd routingmanagerd.cpp) target_link_libraries(routingmanagerd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY} ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + target_link_libraries(routingmanagerd socket) +endif() add_dependencies(routingmanagerd ${VSOMEIP_NAME}) option(VSOMEIP_INSTALL_ROUTINGMANAGERD "Whether or not to install the routing manager daemon.") diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in index 45471b4db..02103bfe9 100644 --- a/implementation/configuration/include/internal.hpp.in +++ b/implementation/configuration/include/internal.hpp.in @@ -114,7 +114,7 @@ #define VSOMEIP_MINIMUM_CHECK_TTL_TIMEOUT 100 #define VSOMEIP_SETSOCKOPT_TIMEOUT_US 500000 // microseconds -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #endif diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 9c98002fc..bd61d4e3a 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -274,7 +274,7 @@ bool configuration_impl::load(const std::string &_name) { } if (its_folder != "") { its_input.insert(its_folder); -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) // load security configuration files from UID_GID sub folder if existing std::stringstream its_security_config_folder; its_security_config_folder << its_folder << "/" << getuid() << "_" << getgid(); @@ -1101,13 +1101,13 @@ void configuration_impl::add_plugin(std::map= 106600 -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include diff --git a/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp b/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp index 7897a00b1..2f87dff08 100644 --- a/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp @@ -107,7 +107,7 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl void set_bound_client_host(const std::string &_bound_client_host); std::string get_bound_client_host() const; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) void set_bound_sec_client(const vsomeip_sec_client_t &_sec_client); #endif @@ -124,7 +124,7 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl boost::system::error_code const &_error, std::size_t _bytes); void receive_cbk(boost::system::error_code const &_error, std::size_t _bytes -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) , std::uint32_t const &_uid, std::uint32_t const &_gid #endif ); 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 cc6dd72ef..c2ca541df 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp @@ -7,7 +7,7 @@ #define VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_RECEIVE_OP_HPP_ #if VSOMEIP_BOOST_VERSION >= 106600 -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index ad8a7b6b3..d3b56fa66 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -641,7 +641,7 @@ void client_endpoint_impl::shutdown_and_close_socket_unlocked(bool _re local_port_ = 0; if (socket_->is_open()) { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (-1 == fcntl(socket_->native_handle(), F_GETFD)) { VSOMEIP_ERROR << "cei::shutdown_and_close_socket_unlocked: socket/handle closed already '" << std::string(std::strerror(errno)) @@ -830,7 +830,7 @@ void client_endpoint_impl::start_dispatch_timer( its_offset = std::chrono::nanoseconds::zero(); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) dispatch_timer_.expires_from_now(its_offset); #else dispatch_timer_.expires_from_now( @@ -857,7 +857,7 @@ void client_endpoint_impl::update_last_departure() { } // Instantiate template -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) template class client_endpoint_impl; #endif template class client_endpoint_impl; diff --git a/implementation/endpoints/src/endpoint_impl.cpp b/implementation/endpoints/src/endpoint_impl.cpp index 9863173b6..c966198f0 100644 --- a/implementation/endpoints/src/endpoint_impl.cpp +++ b/implementation/endpoints/src/endpoint_impl.cpp @@ -153,6 +153,13 @@ template class endpoint_impl; #endif #endif +#ifdef __QNX__ +#if VSOMEIP_BOOST_VERSION < 106600 +template class endpoint_impl; +#endif +template class endpoint_impl; +#endif + template class endpoint_impl; template class endpoint_impl; diff --git a/implementation/endpoints/src/endpoint_manager_base.cpp b/implementation/endpoints/src/endpoint_manager_base.cpp index ec8fede85..dde325c2e 100644 --- a/implementation/endpoints/src/endpoint_manager_base.cpp +++ b/implementation/endpoints/src/endpoint_manager_base.cpp @@ -12,7 +12,7 @@ #include "../include/local_tcp_client_endpoint_impl.hpp" #include "../include/local_tcp_server_endpoint_impl.hpp" -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include "../include/local_uds_client_endpoint_impl.hpp" #include "../include/local_uds_server_endpoint_impl.hpp" #endif @@ -88,7 +88,7 @@ std::shared_ptr endpoint_manager_base::create_local_server( << std::hex << rm_->get_client(); const client_t its_client = rm_->get_client(); -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (is_local_routing_) { if (-1 == ::unlink(its_path.str().c_str()) && errno != ENOENT) { VSOMEIP_ERROR << "endpoint_manager_base::init_receiver unlink failed (" @@ -251,7 +251,7 @@ endpoint_manager_base::create_local_unlocked(client_t _client) { << std::hex << _client; std::shared_ptr its_endpoint; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (is_local_routing_) { VSOMEIP_INFO << "Client [" << std::hex << rm_->get_client() << "] is connecting to [" << std::hex << _client << "] at " << its_path.str(); diff --git a/implementation/endpoints/src/endpoint_manager_impl.cpp b/implementation/endpoints/src/endpoint_manager_impl.cpp index 8eb1e970a..2f3f9ac3f 100644 --- a/implementation/endpoints/src/endpoint_manager_impl.cpp +++ b/implementation/endpoints/src/endpoint_manager_impl.cpp @@ -8,7 +8,7 @@ #include #include "../include/local_tcp_server_endpoint_impl.hpp" -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include "../include/local_uds_server_endpoint_impl.hpp" #endif #include "../include/udp_client_endpoint_impl.hpp" @@ -645,7 +645,7 @@ endpoint_manager_impl::create_routing_root( num_fd = sd_listen_fds(0); #endif -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (num_fd > 1) { VSOMEIP_ERROR << "Too many file descriptors received by systemd socket activation! num_fd: " << num_fd; } else if (num_fd == 1) { diff --git a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp index 9c57d87d9..5bf660d92 100644 --- a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp @@ -370,7 +370,7 @@ void local_tcp_server_endpoint_impl::connection::start() { void local_tcp_server_endpoint_impl::connection::stop() { std::lock_guard its_lock(socket_mutex_); if (socket_.is_open()) { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (-1 == fcntl(socket_.native_handle(), F_GETFD)) { VSOMEIP_ERROR << "lse: socket/handle closed already '" << std::string(std::strerror(errno)) << "' (" << errno << ") " << get_path_local(); diff --git a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp index 283c6df03..3e8fca0ef 100644 --- a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp @@ -11,7 +11,9 @@ #include #include +#ifndef __QNX__ #include "../include/credentials.hpp" +#endif #include "../include/endpoint_host.hpp" #include "../include/local_uds_client_endpoint_impl.hpp" #include "../include/local_uds_server_endpoint_impl.hpp" @@ -125,6 +127,7 @@ void local_uds_client_endpoint_impl::connect() { socket_->connect(remote_, its_connect_error); // Credentials +#ifndef __QNX__ if (!its_connect_error) { auto its_host = endpoint_host_.lock(); if (its_host) { @@ -137,6 +140,7 @@ void local_uds_client_endpoint_impl::connect() { << its_connect_error.message() << " / " << std::dec << its_connect_error.value() << ")"; } +#endif } else { VSOMEIP_WARNING << "local_client_endpoint::connect: Error opening socket: " << its_error.message() << " (" << std::dec << its_error.value() diff --git a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp index 5413bcf96..2875776e0 100644 --- a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp @@ -12,7 +12,9 @@ #include +#ifndef __QNX__ #include "../include/credentials.hpp" +#endif #include "../include/endpoint_host.hpp" #include "../include/local_uds_server_endpoint_impl.hpp" #include "../include/local_server_endpoint_impl_receive_op.hpp" @@ -63,11 +65,13 @@ local_uds_server_endpoint_impl::local_uds_server_endpoint_impl( VSOMEIP_ERROR << __func__ << ": listen failed (" << ec.message() << ")"; +#ifndef __QNX__ if (chmod(_local.path().c_str(), static_cast(_configuration->get_permissions_uds())) == -1) { VSOMEIP_ERROR << __func__ << ": chmod: " << strerror(errno); } credentials::activate_credentials(acceptor_.native_handle()); +#endif } local_uds_server_endpoint_impl::local_uds_server_endpoint_impl( @@ -92,11 +96,13 @@ local_uds_server_endpoint_impl::local_uds_server_endpoint_impl( VSOMEIP_ERROR << __func__ << ": assign failed (" << ec.message() << ")"; +#ifndef __QNX__ if (chmod(_local.path().c_str(), static_cast(_configuration->get_permissions_uds())) == -1) { VSOMEIP_ERROR << __func__ << ": chmod: " << strerror(errno); } credentials::activate_credentials(acceptor_.native_handle()); +#endif } local_uds_server_endpoint_impl::~local_uds_server_endpoint_impl() { @@ -274,6 +280,7 @@ void local_uds_server_endpoint_impl::accept_cbk( } if (!_error) { +#ifndef __QNX__ auto its_host = endpoint_host_.lock(); client_t its_client = 0; std::string its_client_host; @@ -369,6 +376,7 @@ void local_uds_server_endpoint_impl::accept_cbk( _connection->set_bound_client_host(its_client_host); } +#endif _connection->start(); } } diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index 62e1c9000..1572c83b7 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -808,7 +808,7 @@ void server_endpoint_impl::start_dispatch_timer( its_offset = std::chrono::nanoseconds::zero(); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) its_data.dispatch_timer_->expires_from_now(its_offset); #else its_data.dispatch_timer_->expires_from_now( @@ -844,6 +844,10 @@ template class server_endpoint_impl; #endif #endif +#ifdef __QNX__ +template class server_endpoint_impl; +#endif + template class server_endpoint_impl; template class server_endpoint_impl; diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index 3bc0637b9..2eb83d82c 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -174,7 +174,7 @@ void tcp_client_endpoint_impl::connect() { << " remote:" << get_address_port_remote(); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) // If specified, bind to device std::string its_device(configuration_->get_device()); if (its_device != "") { diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp index 05f71ff29..e7606c6a3 100644 --- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp @@ -50,7 +50,7 @@ tcp_server_endpoint_impl::tcp_server_endpoint_impl( VSOMEIP_ERROR << __func__ << ": set reuse address option failed (" << ec.message() << ")"; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) // If specified, bind to device std::string its_device(configuration_->get_device()); if (its_device != "") { diff --git a/implementation/endpoints/src/tp.cpp b/implementation/endpoints/src/tp.cpp index be1b78a3f..4b2d2e50a 100644 --- a/implementation/endpoints/src/tp.cpp +++ b/implementation/endpoints/src/tp.cpp @@ -16,7 +16,7 @@ #include "../../configuration/include/internal.hpp" #endif // ANDROID -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #else #include diff --git a/implementation/endpoints/src/tp_message.cpp b/implementation/endpoints/src/tp_message.cpp index 0824328c0..0d27a90a4 100644 --- a/implementation/endpoints/src/tp_message.cpp +++ b/implementation/endpoints/src/tp_message.cpp @@ -18,7 +18,7 @@ #include "../../configuration/include/internal.hpp" #endif // ANDROID -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #else #include diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp index 68fa07a92..992db4e1f 100644 --- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp @@ -112,7 +112,7 @@ void udp_client_endpoint_impl::connect() { local_.port(0); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) // If specified, bind to device std::string its_device(configuration_->get_device()); if (its_device != "") { diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 9cd587bb8..f1c5f509e 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -66,7 +66,7 @@ udp_server_endpoint_impl::udp_server_endpoint_impl( VSOMEIP_ERROR << __func__ << ": set reuse address option failed (" << ec.message() << ")"; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) // If specified, bind to device std::string its_device(configuration_->get_device()); if (its_device != "") { diff --git a/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp b/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp index b601e1112..ea2767a9f 100644 --- a/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp +++ b/implementation/helper/boost/asio/detail/impl/socket_ops_ext_local.ipp @@ -16,6 +16,16 @@ #include +#ifdef __QNX__ + #define UCRED_T struct sockcred + #define UCRED_UID(x) x->sc_uid + #define UCRED_GID(x) x->sc_gid + + // Reserved memory space to receive credential + // through ancilliary data. + #define CMSG_SIZE 512 +#endif + namespace boost { namespace asio { namespace detail { @@ -27,7 +37,11 @@ signed_size_type recv(socket_type s, buf* bufs, size_t count, { uid = 0xFFFFFFFF; gid = 0xFFFFFFFF; +#ifdef __QNX__ + UCRED_T *ucredp; +#else struct ucred *ucredp; +#endif clear_last_error(); #if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) // Receive some data. @@ -51,13 +65,25 @@ signed_size_type recv(socket_type s, buf* bufs, size_t count, union { struct cmsghdr cmh; +#ifdef __QNX__ + char control[CMSG_SIZE]; +#else char control[CMSG_SPACE(sizeof(struct ucred))]; +#endif } control_un; // Set 'control_un' to describe ancillary data that we want to receive +#ifdef __QNX__ + control_un.cmh.cmsg_len = CMSG_LEN(sizeof(UCRED_T)); +#else control_un.cmh.cmsg_len = CMSG_LEN(sizeof(struct ucred)); +#endif control_un.cmh.cmsg_level = SOL_SOCKET; +#ifdef __QNX__ + control_un.cmh.cmsg_type = SCM_CREDS; +#else control_un.cmh.cmsg_type = SCM_CREDENTIALS; +#endif // Set 'msg' fields to describe 'control_un' msg.msg_control = control_un.control; @@ -72,15 +98,29 @@ signed_size_type recv(socket_type s, buf* bufs, size_t count, cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { +#ifdef __QNX__ + if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_CREDS + || cmsg->cmsg_len != CMSG_LEN(sizeof(UCRED_T))) + continue; +#else if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_CREDENTIALS || cmsg->cmsg_len != CMSG_LEN(sizeof(struct ucred))) continue; +#endif +#ifdef __QNX__ + ucredp = (UCRED_T *) CMSG_DATA(cmsg); + if (ucredp) { + uid = UCRED_UID(ucredp); + gid = UCRED_GID(ucredp); + } +#else ucredp = (struct ucred *) CMSG_DATA(cmsg); if (ucredp) { uid = ucredp->uid; gid = ucredp->gid; } +#endif } } return result; @@ -94,7 +134,11 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count, { uid = 0xFFFFFFFF; gid = 0xFFFFFFFF; +#ifdef __QNX__ + UCRED_T *ucredp; +#else struct ucred *ucredp; +#endif clear_last_error(); #if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) // Receive some data. @@ -122,13 +166,25 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count, union { struct cmsghdr cmh; +#ifdef __QNX__ + char control[CMSG_SIZE]; +#else char control[CMSG_SPACE(sizeof(struct ucred))]; +#endif } control_un; // Set 'control_un' to describe ancillary data that we want to receive +#ifdef __QNX__ + control_un.cmh.cmsg_len = CMSG_LEN(sizeof(UCRED_T)); +#else control_un.cmh.cmsg_len = CMSG_LEN(sizeof(struct ucred)); +#endif control_un.cmh.cmsg_level = SOL_SOCKET; +#ifdef __QNX__ + control_un.cmh.cmsg_type = SCM_CREDS; +#else control_un.cmh.cmsg_type = SCM_CREDENTIALS; +#endif // Set 'msg' fields to describe 'control_un' msg.msg_control = control_un.control; @@ -143,15 +199,29 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count, cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { +#ifdef __QNX__ + if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_CREDS + || cmsg->cmsg_len != CMSG_LEN(sizeof(UCRED_T))) + continue; +#else if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_CREDENTIALS || cmsg->cmsg_len != CMSG_LEN(sizeof(struct ucred))) continue; +#endif +#ifdef __QNX__ + ucredp = (UCRED_T *) CMSG_DATA(cmsg); + if (ucredp) { + uid = UCRED_UID(ucredp); + gid = UCRED_GID(ucredp); + } +#else ucredp = (struct ucred *) CMSG_DATA(cmsg); if (ucredp) { uid = ucredp->uid; gid = ucredp->gid; } +#endif } } return result; diff --git a/implementation/logger/src/logger_impl.cpp b/implementation/logger/src/logger_impl.cpp index 637ea2a2e..0e2aed7fd 100644 --- a/implementation/logger/src/logger_impl.cpp +++ b/implementation/logger/src/logger_impl.cpp @@ -88,7 +88,7 @@ static std::mutex the_logger_mutex__; std::shared_ptr logger_impl::get() { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) std::lock_guard its_lock(the_logger_mutex__); #endif if (the_logger_ptr__ == nullptr) { @@ -103,7 +103,7 @@ logger_impl::get() { return nullptr; } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) static void logger_impl_teardown(void) __attribute__((destructor)); static void logger_impl_teardown(void) { diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index 963193d65..b8cd3871d 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -209,7 +209,11 @@ void * plugin_manager_impl::load_symbol(void * _handle, const std::string &_symb error_message = dlerror(); #endif +#ifdef __QNX__ + VSOMEIP_ERROR << "Cannot load symbol " << std::quoted(_symbol_name.c_str()) << " because: " << error_message; +#else VSOMEIP_ERROR << "Cannot load symbol " << std::quoted(_symbol_name) << " because: " << error_message; +#endif #ifdef _WIN32 // Required to release memory allocated by FormatMessageA() diff --git a/implementation/routing/include/routing_manager_client.hpp b/implementation/routing/include/routing_manager_client.hpp index 5a5ad4e98..5a1912124 100644 --- a/implementation/routing/include/routing_manager_client.hpp +++ b/implementation/routing/include/routing_manager_client.hpp @@ -219,7 +219,7 @@ class routing_manager_client void on_suspend(); -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) void on_net_state_change(bool _is_interface, const std::string &_name, bool _is_available); #endif diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp index d5cb7f349..c427473f1 100644 --- a/implementation/routing/include/routing_manager_stub.hpp +++ b/implementation/routing/include/routing_manager_stub.hpp @@ -36,7 +36,7 @@ namespace vsomeip_v3 { class configuration; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) class netlink_connector; #endif // __linux__ || ANDROID class routing_manager_stub_host; @@ -232,7 +232,7 @@ class routing_manager_stub: public routing_host, void add_pending_security_update_timer( pending_security_update_id_t _id); -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) void on_net_state_change(bool _is_interface, const std::string &_name, bool _is_available); #endif @@ -294,7 +294,7 @@ class routing_manager_stub: public routing_host, > requester_policies_; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) // netlink connector for internal network // (replacement for Unix Domain Sockets if configured) std::shared_ptr local_link_connector_; diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index f748bd41f..3b26ea3f5 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -3,7 +3,7 @@ // License, v. 2.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__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #endif @@ -130,7 +130,7 @@ void routing_manager_client::init() { void routing_manager_client::start() { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (configuration_->is_local_routing()) { #else { @@ -1779,7 +1779,7 @@ void routing_manager_client::on_routing_info( if (its_client == get_client()) { VSOMEIP_INFO << std::hex << "Application/Client " << get_client() << " (" << host_->get_name() << ") is registered."; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (!its_security->check_credentials(get_client(), get_sec_client())) { VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_client::on_routing_info: RIE_ADD_CLIENT: isn't allowed" @@ -2040,7 +2040,7 @@ void routing_manager_client::reconnect(const std::map &_c VSOMEIP_INFO << std::hex << "Application/Client " << get_client() << ": Reconnecting to routing manager."; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (!its_security->check_credentials(get_client(), get_sec_client())) { VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_client::reconnect: isn't allowed" @@ -2418,7 +2418,7 @@ void routing_manager_client::send_pending_commands() { } void routing_manager_client::init_receiver() { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) auto its_security = policy_manager_impl::get(); if (!its_security) return; diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 0c7b152b9..03302b3f1 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -10,7 +10,7 @@ #include #include -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #include #include @@ -252,7 +252,7 @@ void routing_manager_impl::start() { version_log_timer_.async_wait(std::bind(&routing_manager_impl::log_version_timer_cbk, this, std::placeholders::_1)); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (configuration_->log_memory()) { std::lock_guard its_lock(memory_log_timer_mutex_); boost::system::error_code ec; @@ -3916,7 +3916,7 @@ void routing_manager_impl::on_net_interface_or_route_state_changed( } void routing_manager_impl::start_ip_routing() { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__QNX__) if_state_running_ = true; #endif @@ -4367,7 +4367,7 @@ void routing_manager_impl::memory_log_timer_cbk( return; } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) static const std::uint32_t its_pagesize = static_cast(getpagesize() / 1024); std::FILE *its_file = std::fopen("/proc/self/statm", "r"); diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index f3834c01e..a6f4472d1 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -394,7 +394,7 @@ void application_impl::start() { VSOMEIP_INFO << "Starting vsomeip application \"" << name_ << "\" (" << std::hex << std::setw(4) << std::setfill('0') << client_ << ") using " << std::dec << io_thread_count << " threads" -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) << " I/O nice " << io_thread_nice_level #endif ; @@ -1745,7 +1745,7 @@ routing_manager * application_impl::get_routing_manager() const { } void application_impl::main_dispatch() { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) { std::stringstream s; s << std::hex << std::setw(4) << std::setfill('0') @@ -2100,7 +2100,7 @@ void application_impl::shutdown() { << " TID: " << std::dec << static_cast(syscall(SYS_gettid)) #endif ; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) boost::asio::detail::posix_signal_blocker blocker; { std::stringstream s; diff --git a/implementation/security/src/policy_manager_impl.cpp b/implementation/security/src/policy_manager_impl.cpp index 5841ea159..07802e361 100644 --- a/implementation/security/src/policy_manager_impl.cpp +++ b/implementation/security/src/policy_manager_impl.cpp @@ -1266,7 +1266,7 @@ policy_manager_impl::get_security_config_folder(const std::string &its_folder) c std::stringstream its_security_config_folder; its_security_config_folder << its_folder; -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) its_security_config_folder << "/" << getuid() << "_" << getgid(); #endif @@ -1439,7 +1439,7 @@ static std::mutex the_policy_manager_mutex__; std::shared_ptr policy_manager_impl::get() { -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) std::lock_guard its_lock(the_policy_manager_mutex__); #endif if(the_policy_manager_ptr__ == nullptr) { @@ -1454,7 +1454,7 @@ policy_manager_impl::get() { return nullptr; } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) static void security_teardown(void) __attribute__((destructor)); static void security_teardown(void) { diff --git a/implementation/utility/src/wrappers_qnx.cpp b/implementation/utility/src/wrappers_qnx.cpp new file mode 100644 index 000000000..317c55d3d --- /dev/null +++ b/implementation/utility/src/wrappers_qnx.cpp @@ -0,0 +1,161 @@ +// Copyright (C) 2020-2021 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/. + +#ifdef __QNX__ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef enum accept_msg_t { + ACCEPT1=1, + ACCEPT4, +} accept_msg_t; + +struct _io_sock_accept { + struct _io_openfd msg; + accept_msg_t type; + int flags; + socklen_t anamelen; +}; + +typedef union { + struct _io_sock_accept i; +} io_sock_accept_t; + +static int +__accept (int s, struct sockaddr *addr, socklen_t *addrlen, accept_msg_t msg_type, int flags) +{ + /* This is basically _sopenfd specifying a return buffer for dst address */ + int fd2; + int ret, niov; + io_sock_accept_t msg; + struct _io_openfd *open; + struct _server_info info; + iov_t iov[2]; + socklen_t len; + + if ((addrlen) && (*addrlen > 0) && (!addr)) { + /* Prevent addr dereference */ + errno = EINVAL; + return -1; + } + + if (s == -1 || ConnectServerInfo(0, s, &info) != s) { + errno = EBADF; + return -1; + } + + fd2 = ConnectAttach(info.nd, info.pid, info.chid, 0, _NTO_COF_CLOEXEC | _NTO_COF_INSECURE); + if (fd2 == -1) { + return -1; + } + + open = &msg.i.msg; + memset(open, 0x00, sizeof *open); + open->type = _IO_OPENFD; + open->combine_len = sizeof open; + open->ioflag = 0; + open->sflag = 0; + open->xtype = _IO_OPENFD_ACCEPT; + open->info.pid = getpid(); + open->info.chid = info.chid; + open->info.scoid = info.scoid; + open->info.coid = s; + + msg.i.type = msg_type; + msg.i.flags = flags; + if (addr && addrlen && (*addrlen > 0)) { + /* Only send len > 0 if addr is set (accept1() assumption) */ + len = *addrlen; + } else { + len = 0; + } + msg.i.anamelen = len; + + niov = 0; + SETIOV(iov + niov, &msg.i, sizeof(msg.i)); + niov++; + + if (len > 0) { + /* Only send buffer space required */ + SETIOV(iov + niov, addr, len); + niov++; + } + + ret = MsgSendv(fd2, iov, niov, iov, niov); + if (ret == -1) { + if(errno == ENOSYS) { + errno = ENOTSOCK; + } + ConnectDetach(fd2); + return -1; + } + + if (addr && addrlen && (*addrlen > 0)) { + *addrlen = msg.i.anamelen; + } + + ConnectFlags_r(0, fd2, FD_CLOEXEC, (flags & SOCK_CLOEXEC) ? 1 : 0); + + return fd2; +} + +int +accept4 (int s, struct sockaddr *addr, socklen_t *addrlen, int flags) { + return __accept(s, addr, addrlen, ACCEPT4, flags); +} + +/* + * These definitions MUST remain in the global namespace. + */ +extern "C" +{ + /* + * The real socket(2), renamed by GCC. + */ + int __real_socket(int domain, int type, int protocol) noexcept; + + /* + * Overrides socket(2) to set SOCK_CLOEXEC by default. + */ + int __wrap_socket(int domain, int type, int protocol) noexcept + { + return __real_socket(domain, type | SOCK_CLOEXEC, protocol); + } + + /* + * Overrides accept(2) to set SOCK_CLOEXEC by default. + */ + int __wrap_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) + { + return accept4(sockfd, addr, addrlen, SOCK_CLOEXEC); + } + + /* + * The real open(2), renamed by GCC. + */ + int __real_open(const char *pathname, int flags, mode_t mode); + + /* + * Overrides open(2) to set O_CLOEXEC by default. + */ + int __wrap_open(const char *pathname, int flags, mode_t mode) + { + return __real_open(pathname, flags | O_CLOEXEC, mode); + } +} + +#endif diff --git a/interface/compat/vsomeip/primitive_types.hpp b/interface/compat/vsomeip/primitive_types.hpp index 93237d05a..cb3d4fd8a 100644 --- a/interface/compat/vsomeip/primitive_types.hpp +++ b/interface/compat/vsomeip/primitive_types.hpp @@ -9,7 +9,7 @@ #include #include -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #endif diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index 0a9eaa5e1..4a1046618 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -10,7 +10,7 @@ #include #include -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include #endif @@ -56,7 +56,7 @@ typedef std::uint32_t pending_remote_offer_id_t; typedef std::uint32_t pending_security_update_id_t; -#ifdef _WIN32 +#if defined(_WIN32) || defined(__QNX__) typedef std::uint32_t uid_t; typedef std::uint32_t gid_t; #else diff --git a/interface/vsomeip/vsomeip_sec.h b/interface/vsomeip/vsomeip_sec.h index 88c36669f..3b853f630 100644 --- a/interface/vsomeip/vsomeip_sec.h +++ b/interface/vsomeip/vsomeip_sec.h @@ -26,8 +26,13 @@ typedef uint32_t gid_t; #endif typedef struct { +#ifdef __QNX__ + uint32_t user; + uint32_t group; +#else uid_t user; gid_t group; +#endif } vsomeip_sec_uds_client_credentials_t; typedef struct { diff --git a/test/internal_routing_disabled_acceptance_test/CMakeLists.txt b/test/internal_routing_disabled_acceptance_test/CMakeLists.txt index cb6e51a31..574c6981b 100644 --- a/test/internal_routing_disabled_acceptance_test/CMakeLists.txt +++ b/test/internal_routing_disabled_acceptance_test/CMakeLists.txt @@ -20,6 +20,10 @@ 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}) +if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + target_compile_definitions(${PROJECT_NAME} PRIVATE _QNX_SOURCE) +endif() + enable_testing() add_test(NAME ${PROJECT_NAME} COMMAND $) add_dependencies(build_network_tests ${PROJECT_NAME}) diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index 6a1486042..42e4389f7 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -122,6 +122,9 @@ if(NOT ${TESTS_BAT}) ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} ) + if(QNX) + target_compile_definitions(${TEST_APPLICATION_SINGLE_PROCESS_NAME} PRIVATE _QNX_SOURCE) + endif() set(TEST_APPLICATION_AVAILABILITY_NAME ${TEST_APPLICATION}_availability) add_executable(${TEST_APPLICATION_AVAILABILITY_NAME} application_tests/${TEST_APPLICATION_AVAILABILITY_NAME}.cpp) @@ -394,7 +397,11 @@ if(NOT ${TESTS_BAT}) ) # Copy bashscript to start client and server $BUILDDIR/test - set(TEST_LOCAL_ROUTING_STARTER local_routing_test_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_LOCAL_ROUTING_STARTER local_routing_test_starter_qnx.sh) + else() + set(TEST_LOCAL_ROUTING_STARTER local_routing_test_starter.sh) + endif() configure_file( ${NETWORK_TEST_SRC_DIR}/routing_tests/conf/${TEST_LOCAL_ROUTING_STARTER}.in ${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_LOCAL_ROUTING_STARTER} @@ -1431,7 +1438,11 @@ if(NOT ${TESTS_BAT}) ) # copy starter scripts into builddir - set(TEST_CLIENT_ID_MASTER_STARTER ${TEST_CLIENT_ID_NAME}_master_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_CLIENT_ID_MASTER_STARTER ${TEST_CLIENT_ID_NAME}_master_starter_qnx.sh) + else() + set(TEST_CLIENT_ID_MASTER_STARTER ${TEST_CLIENT_ID_NAME}_master_starter.sh) + endif() copy_to_builddir(${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_MASTER_STARTER} ${TEST_CLIENT_ID_SERVICE} @@ -1780,7 +1791,11 @@ if(NOT ${TESTS_BAT}) ) # copy starter scripts into builddir - set(TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_NAME}_master_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_NAME}_master_starter_qnx.sh) + else() + set(TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_NAME}_master_starter.sh) + endif() copy_to_builddir(${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER} ${TEST_SUBSCRIBE_NOTIFY_SERVICE} @@ -2278,7 +2293,11 @@ if(NOT ${TESTS_BAT}) ) # copy starter scripts into builddir - set(TEST_SUBSCRIBE_NOTIFY_ONE_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_master_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_SUBSCRIBE_NOTIFY_ONE_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_master_starter_qnx.sh) + else() + set(TEST_SUBSCRIBE_NOTIFY_ONE_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_master_starter.sh) + endif() copy_to_builddir(${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_MASTER_STARTER} ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} @@ -2664,7 +2683,11 @@ if(NOT ${TESTS_BAT}) ) # copy starter scripts into builddir - set(TEST_INITIAL_EVENT_MASTER_STARTER ${TEST_INITIAL_EVENT_NAME}_master_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_INITIAL_EVENT_MASTER_STARTER ${TEST_INITIAL_EVENT_NAME}_master_starter_qnx.sh) + else() + set(TEST_INITIAL_EVENT_MASTER_STARTER ${TEST_INITIAL_EVENT_NAME}_master_starter.sh) + endif() copy_to_builddir(${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_MASTER_STARTER} ${TEST_INITIAL_EVENT_SERVICE} @@ -2737,7 +2760,11 @@ if(NOT ${TESTS_BAT}) ) # copy starter scripts into builddir - set(TEST_OFFER_LOCAL_STARTER ${TEST_OFFER_NAME}_local_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_OFFER_LOCAL_STARTER ${TEST_OFFER_NAME}_local_starter_qnx.sh) + else() + set(TEST_OFFER_LOCAL_STARTER ${TEST_OFFER_NAME}_local_starter.sh) + endif() copy_to_builddir(${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_LOCAL_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_LOCAL_STARTER} ${TEST_OFFER_SERVICE} @@ -2798,7 +2825,11 @@ if(NOT ${TESTS_BAT}) ) # Copy starter scripts for external test to $BUILDDIR/test - set(TEST_OFFER_EXTERNAL_MASTER_STARTER ${TEST_OFFER_NAME}_external_master_starter.sh) + if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(TEST_OFFER_EXTERNAL_MASTER_STARTER ${TEST_OFFER_NAME}_external_master_starter_qnx.sh) + else() + set(TEST_OFFER_EXTERNAL_MASTER_STARTER ${TEST_OFFER_NAME}_external_master_starter.sh) + endif() configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_EXTERNAL_MASTER_STARTER}.in ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_EXTERNAL_MASTER_STARTER} @@ -3207,7 +3238,7 @@ endif() ############################################################################## # npdu-test ############################################################################## -if(NOT ${TESTS_BAT}) +if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") set(TEST_NPDU_NAME npdu_test) set(TEST_NPDU_DAEMON npdu_test_rmd) @@ -3690,6 +3721,7 @@ if(NOT ${TESTS_BAT}) endif() add_dependencies(${TEST_EVENT_SERVICE} gtest) add_dependencies(${TEST_EVENT_CLIENT} gtest) + if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") add_dependencies(${TEST_NPDU_SERVICE_ONE} gtest) add_dependencies(${TEST_NPDU_SERVICE_TWO} gtest) add_dependencies(${TEST_NPDU_SERVICE_THREE} gtest) @@ -3700,6 +3732,7 @@ if(NOT ${TESTS_BAT}) add_dependencies(${TEST_NPDU_CLIENT_FOUR} gtest) add_dependencies(${TEST_NPDU_DAEMON_CLIENT} gtest) add_dependencies(${TEST_NPDU_DAEMON_SERVICE} gtest) + endif() add_dependencies(${TEST_SOMEIPTP_CLIENT} gtest) add_dependencies(${TEST_SOMEIPTP_SERVICE} gtest) if(${TEST_SECOND_ADDRESS}) @@ -3774,6 +3807,7 @@ if(NOT ${TESTS_BAT}) endif() add_dependencies(build_network_tests ${TEST_EVENT_SERVICE}) add_dependencies(build_network_tests ${TEST_EVENT_CLIENT}) + if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") add_dependencies(build_network_tests ${TEST_NPDU_SERVICE_ONE}) add_dependencies(build_network_tests ${TEST_NPDU_SERVICE_TWO}) add_dependencies(build_network_tests ${TEST_NPDU_SERVICE_THREE}) @@ -3784,6 +3818,7 @@ if(NOT ${TESTS_BAT}) add_dependencies(build_network_tests ${TEST_NPDU_CLIENT_FOUR}) add_dependencies(build_network_tests ${TEST_NPDU_DAEMON_CLIENT}) add_dependencies(build_network_tests ${TEST_NPDU_DAEMON_SERVICE}) + endif() add_dependencies(build_network_tests ${TEST_SOMEIPTP_CLIENT}) add_dependencies(build_network_tests ${TEST_SOMEIPTP_SERVICE}) if(${TEST_SECOND_ADDRESS}) diff --git a/test/network_tests/application_tests/application_test.cpp b/test/network_tests/application_tests/application_test.cpp index c7ad4f8c1..e55d7ec35 100644 --- a/test/network_tests/application_tests/application_test.cpp +++ b/test/network_tests/application_tests/application_test.cpp @@ -466,7 +466,7 @@ TEST_F(someip_application_exception_test, catch_exception_in_invoked_handler) { } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/application_tests/application_test_availability.cpp b/test/network_tests/application_tests/application_test_availability.cpp index 89d94c1c1..48818961f 100644 --- a/test/network_tests/application_tests/application_test_availability.cpp +++ b/test/network_tests/application_tests/application_test_availability.cpp @@ -30,7 +30,7 @@ TEST(someip_application_test_availability, register_availability_handlers) its_daemon.stop(); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/application_tests/application_test_single_process.cpp b/test/network_tests/application_tests/application_test_single_process.cpp index c73889925..f8fbe8e8e 100644 --- a/test/network_tests/application_tests/application_test_single_process.cpp +++ b/test/network_tests/application_tests/application_test_single_process.cpp @@ -38,7 +38,7 @@ TEST(someip_application_test_single_process, notify_increasing_counter) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/big_payload_tests/big_payload_test_client.cpp b/test/network_tests/big_payload_tests/big_payload_test_client.cpp index 55c3ff2f7..db204e09d 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_client.cpp +++ b/test/network_tests/big_payload_tests/big_payload_test_client.cpp @@ -279,7 +279,7 @@ TEST(someip_big_payload_test, send_ten_messages_to_service) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/big_payload_tests/big_payload_test_service.cpp b/test/network_tests/big_payload_tests/big_payload_test_service.cpp index 9d373013c..80983083b 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_service.cpp +++ b/test/network_tests/big_payload_tests/big_payload_test_service.cpp @@ -251,7 +251,7 @@ TEST(someip_big_payload_test, receive_ten_messages_and_send_reply) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh b/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh new file mode 100755 index 000000000..3c46361fa --- /dev/null +++ b/test/network_tests/client_id_tests/client_id_test_master_starter_qnx.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Copyright (C) 2015-2017 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/. + +# Purpose: This script is needed to start the services with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start multiple binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs the services +# and checks that all exit successfully. + +if [ $# -lt 1 ] +then + echo "Please pass a json file to this script." + echo "For example: $0 client_id_test_diff_client_ids_diff_ports_master.json" + exit 1 +fi + +MASTER_JSON_FILE=$1 +CLIENT_JSON_FILE="" + +FAIL=0 + +# Start the services +export VSOMEIP_APPLICATION_NAME=client_id_test_service_one +export VSOMEIP_CONFIGURATION=$1 +./client_id_test_service 1 & +CLIENT_ID_PIDS[1]=$! + +export VSOMEIP_APPLICATION_NAME=client_id_test_service_two +export VSOMEIP_CONFIGURATION=$1 +./client_id_test_service 2 & +CLIENT_ID_PIDS[2]=$! + +export VSOMEIP_APPLICATION_NAME=client_id_test_service_three +export VSOMEIP_CONFIGURATION=$1 +./client_id_test_service 3 & +CLIENT_ID_PIDS[3]=$! + +sleep 1 + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "starting client id test on slave LXC" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./client_id_test_slave_starter.sh $CLIENT_JSON_FILE\"" & +elif [ ! -z "$USE_DOCKER" ]; then + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./client_id_test_slave_starter.sh $CLIENT_JSON_FILE" & +else +cat <(service_number)]); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/client_id_tests/client_id_test_utility.cpp b/test/network_tests/client_id_tests/client_id_test_utility.cpp index a74f92295..3be55e08d 100644 --- a/test/network_tests/client_id_tests/client_id_test_utility.cpp +++ b/test/network_tests/client_id_tests/client_id_test_utility.cpp @@ -600,7 +600,7 @@ TEST_F(client_id_utility_test, request_released_client_id_after_maximum_client_i its_client_ids.clear(); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/test/network_tests/configuration_tests/configuration-test.cpp b/test/network_tests/configuration_tests/configuration-test.cpp index 67f4bcaf5..0082d75c9 100644 --- a/test/network_tests/configuration_tests/configuration-test.cpp +++ b/test/network_tests/configuration_tests/configuration-test.cpp @@ -159,7 +159,7 @@ void check_file(const std::string &_config_file, // 0. Set environment variable to config file and load it -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) setenv("VSOMEIP_CONFIGURATION", _config_file.c_str(), 1); #else _putenv_s("VSOMEIP_CONFIGURATION", _config_file.c_str() @@ -526,7 +526,7 @@ void check_file(const std::string &_config_file, EXPECT_EQ(15001u + 16, its_configuration->get_max_message_size_reliable("10.10.10.11", 7778)); // security -#ifndef VSOMEIP_DISABLE_SECURITY +#if !defined(VSOMEIP_DISABLE_SECURITY) && !defined(__QNX__) vsomeip_sec_client_t its_x123_x456 = utility::create_uds_client(0x123, 0x456); EXPECT_TRUE(its_configuration->check_routing_credentials(0x7788, &its_x123_x456)); diff --git a/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp b/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp index d1d5104e4..9bf74b5cd 100644 --- a/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp +++ b/test/network_tests/cpu_load_tests/cpu_load_test_client.cpp @@ -319,7 +319,7 @@ TEST(someip_load_test, DISABLED_send_messages_and_measure_cpu_load) cpu_load_test_client test_client_(protocol, number_of_calls, payload_size, call_service_sync, shutdown_service); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { int i = 0; diff --git a/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp b/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp index 58c72e782..2003dff7a 100644 --- a/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp +++ b/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp @@ -200,7 +200,7 @@ TEST(someip_payload_test, DISABLED_send_response_for_every_request) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp b/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp index eb375c8ea..32c44f5fb 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp @@ -200,7 +200,7 @@ TEST(someip_e2e_profile_04_test, basic_subscribe_request_response) { } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { diff --git a/test/network_tests/e2e_tests/e2e_test_service.cpp b/test/network_tests/e2e_tests/e2e_test_service.cpp index 25cf60265..236cfc8ca 100644 --- a/test/network_tests/e2e_tests/e2e_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_test_service.cpp @@ -208,7 +208,7 @@ TEST(someip_e2e_test, basic_subscribe_request_response) { } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { /* diff --git a/test/network_tests/event_tests/event_test_client.cpp b/test/network_tests/event_tests/event_test_client.cpp index 8931e676f..2474bb442 100644 --- a/test/network_tests/event_tests/event_test_client.cpp +++ b/test/network_tests/event_tests/event_test_client.cpp @@ -253,7 +253,7 @@ TEST(someip_event_test, subscribe_or_call_method_at_service) event_test_client its_sample(event_test::service, passed_mode, use_tcp); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/event_tests/event_test_service.cpp b/test/network_tests/event_tests/event_test_service.cpp index 6e81a6a25..099b2b511 100644 --- a/test/network_tests/event_tests/event_test_service.cpp +++ b/test/network_tests/event_tests/event_test_service.cpp @@ -185,7 +185,7 @@ TEST(someip_event_test, send_events) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/header_factory_tests/header_factory_test.cpp b/test/network_tests/header_factory_tests/header_factory_test.cpp index 14abf920a..14865cb25 100644 --- a/test/network_tests/header_factory_tests/header_factory_test.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test.cpp @@ -110,7 +110,7 @@ TEST_F(someip_header_factory_test, create_notification_test) ASSERT_EQ(notification_->get_return_code(), vsomeip::return_code_e::E_OK); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.cpp b/test/network_tests/header_factory_tests/header_factory_test_client.cpp index 3435dea90..c653f8a80 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_client.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test_client.cpp @@ -161,7 +161,7 @@ TEST(someip_header_factory_test, send_message_ten_times_test) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); 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 4caca7aa3..742b30db8 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 @@ -161,7 +161,7 @@ TEST(someip_header_factory_test, reveice_message_ten_times_test) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp b/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp index f05b5920b..140649231 100644 --- a/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp +++ b/test/network_tests/initial_event_tests/initial_event_test_availability_checker.cpp @@ -139,7 +139,7 @@ TEST(someip_initial_event_test, wait_for_availability_and_exit) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); 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 a4bb5903a..2197b6a28 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 @@ -564,7 +564,7 @@ TEST(someip_initial_event_test, wait_for_initial_events_of_all_services) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { // Block all signals diff --git a/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh b/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh new file mode 100755 index 000000000..88db07b3e --- /dev/null +++ b/test/network_tests/initial_event_tests/initial_event_test_master_starter_qnx.sh @@ -0,0 +1,163 @@ +#!/bin/sh +# Copyright (C) 2015-2017 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/. + +# Purpose: This script is needed to start the services with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start multiple binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs the services +# and checks that all exit successfully. + +if [ $# -lt 1 ] +then + echo "Please pass a json file to this script." + echo "For example: $0 initial_event_test_diff_client_ids_diff_ports_master.json" + echo "To use the same service id but different instances on the node pass SAME_SERVICE_ID as third parameter" + echo "To ensure the first client only subscribes to one event pass SUBSCRIBE_ONLY_ONE as third/fourth parameter" + exit 1 +fi + +PASSED_JSON_FILE=$1 +# Remove processed options from $@ +shift 1 +REMAINING_OPTIONS="$@" + +print_starter_message () { + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "starting initial event test on slave LXC with params $CLIENT_JSON_FILE $REMAINING_OPTIONS" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./initial_event_test_slave_starter.sh $CLIENT_JSON_FILE $REMAINING_OPTIONS\"" & +elif [ ! -z "$USE_DOCKER" ]; then + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./initial_event_test_slave_starter.sh $CLIENT_JSON_FILE $REMAINING_OPTIONS" & +else +cat < should be rejected as there is already a service instance +# running in the network + +export VSOMEIP_CONFIGURATION=offer_test_external_master.json +# start daemon +../../examples/routingmanagerd/./routingmanagerd & +PID_VSOMEIPD=$! +# Start the services +./offer_test_service 2 & +PID_SERVICE_TWO=$! +echo "SERVICE_TWO pid $PID_SERVICE_TWO" + +./offer_test_client SUBSCRIBE & +CLIENT_PID_ONE=$! +echo "client pid ${CLIENT_PIDS}" + +sleep 1 + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "Waiting for 5s" + sleep 5 + echo "starting offer test on slave LXC offer_test_external_slave_starter.sh" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./offer_test_external_slave_starter.sh\"" & + echo "remote ssh pid: $!" +elif [ ! -z "$USE_DOCKER" ]; then + echo "Waiting for 5s" + sleep 5 + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && sleep 10; ./offer_test_external_slave_starter.sh" & +else +cat < should be +# rejected and an error message should be printed. +# * Message exchange with client application should not be interrupted. + +export VSOMEIP_CONFIGURATION=offer_test_local.json +# Start the services +./offer_test_service 1 & +PID_SERVICE_ONE=$! +./offer_test_client SUBSCRIBE & +CLIENT_PID_ONE=$! +./offer_test_client SUBSCRIBE & +CLIENT_PID_TWO=$! + +./offer_test_service 2 & +PID_SERVICE_TWO=$! + +# Wait until all clients are finished +# Fail gets incremented if a client exits with a non-zero exit code +wait $CLIENT_PID_ONE || FAIL=$(($FAIL+1)) +wait $CLIENT_PID_TWO || FAIL=$(($FAIL+1)) + +# kill the services +kill $PID_SERVICE_TWO +kill $PID_SERVICE_ONE +sleep 1 + + +cat < should be +# rejected and an error message should be printed. +# * Message exchange with client application should not be interrupted. + +export VSOMEIP_CONFIGURATION=offer_test_local.json +# start daemon +../../examples/routingmanagerd/./routingmanagerd & +PID_VSOMEIPD=$! + +# Start the services +./offer_test_service 2 & +PID_SERVICE_TWO=$! +./offer_test_client SUBSCRIBE & +CLIENT_PID_ONE=$! +./offer_test_client SUBSCRIBE & +CLIENT_PID_TWO=$! + +./offer_test_service 3 & +PID_SERVICE_THREE=$! + +# Wait until all clients are finished +# Fail gets incremented if a client exits with a non-zero exit code +wait $CLIENT_PID_ONE || FAIL=$(($FAIL+1)) +wait $CLIENT_PID_TWO || FAIL=$(($FAIL+1)) + +# kill the services +kill $PID_SERVICE_THREE +kill $PID_SERVICE_TWO +sleep 1 +kill $PID_VSOMEIPD +sleep 1 + + +cat < should be +# accepted. +# * start another client which exchanges messages with the service +# * Client should now communicate with new offerer. + +export VSOMEIP_CONFIGURATION=offer_test_local.json +# start daemon +../../examples/routingmanagerd/./routingmanagerd & +PID_VSOMEIPD=$! +# Start the service +./offer_test_service 2 & +PID_SERVICE_TWO=$! + +# Start a client +./offer_test_client METHODCALL & +CLIENT_PID_ONE=$! + +# Kill the service +sleep 1 +kill -KILL $PID_SERVICE_TWO + +# reoffer the service +./offer_test_service 3 & +PID_SERVICE_THREE=$! + +# Start another client +./offer_test_client METHODCALL & +CLIENT_PID_TWO=$! + +# Wait until all clients are finished +# Fail gets incremented if a client exits with a non-zero exit code +wait $CLIENT_PID_ONE || FAIL=$(($FAIL+1)) +wait $CLIENT_PID_TWO || FAIL=$(($FAIL+1)) + +# kill the services +kill $PID_SERVICE_THREE +kill $PID_VSOMEIPD +sleep 1 + +cat < should be +# marked as PENDING_OFFER and a ping should be sent to the paused +# application. +# * After the timeout passed the new offer should be accepted. +# * start client which exchanges messages with the service +# * Client should now communicate with new offerer. + +export VSOMEIP_CONFIGURATION=offer_test_local.json +# start daemon +../../examples/routingmanagerd/./routingmanagerd & +PID_VSOMEIPD=$! +# Start the service +./offer_test_service 2 & +PID_SERVICE_TWO=$! + +# Start a client +./offer_test_client METHODCALL & +CLIENT_PID_ONE=$! + +# Pause the service +sleep 1 +kill -STOP $PID_SERVICE_TWO + +# reoffer the service +./offer_test_service 3 & +PID_SERVICE_THREE=$! + +# Start another client +./offer_test_client METHODCALL & +CLIENT_PID_TWO=$! + +# Wait until all clients are finished +# Fail gets incremented if a client exits with a non-zero exit code +wait $CLIENT_PID_ONE || FAIL=$(($FAIL+1)) +wait $CLIENT_PID_TWO || FAIL=$(($FAIL+1)) + +# kill the services +kill -CONT $PID_SERVICE_TWO +kill $PID_SERVICE_TWO +kill $PID_SERVICE_THREE +kill $PID_VSOMEIPD +sleep 1 + +cat < should be +# marked as PENDING_OFFER and a ping should be sent to the paused +# application. +# * start application which offers the same service again -> should be +# rejected as there is already a PENDING_OFFER pending. +# * After the timeout passed the new offer should be accepted. +# * start client which exchanges messages with the service +# * Client should now communicate with new offerer. + +export VSOMEIP_CONFIGURATION=offer_test_local.json +# start daemon +../../examples/routingmanagerd/./routingmanagerd & +PID_VSOMEIPD=$! +# Start the service +./offer_test_service 2 & +PID_SERVICE_TWO=$! + +# Start a client +./offer_test_client METHODCALL & +CLIENT_PID_ONE=$! + +# Pause the service +sleep 1 +kill -STOP $PID_SERVICE_TWO + +# reoffer the service +./offer_test_service 3 & +PID_SERVICE_THREE=$! + +# reoffer the service again to provoke rejecting as there is +# already a pending offer +./offer_test_service 4 & +PID_SERVICE_FOUR=$! + +# Start another client +./offer_test_client METHODCALL & +CLIENT_PID_TWO=$! + +# Wait until all clients are finished +# Fail gets incremented if a client exits with a non-zero exit code +wait $CLIENT_PID_ONE || FAIL=$(($FAIL+1)) +wait $CLIENT_PID_TWO || FAIL=$(($FAIL+1)) + +# kill the services +kill -CONT $PID_SERVICE_TWO +kill $PID_SERVICE_TWO +kill $PID_SERVICE_THREE +kill $PID_SERVICE_FOUR +kill $PID_VSOMEIPD + + +# Check if everything went well +if [ $FAIL -eq 0 ] +then + exit 0 +else + exit 1 +fi diff --git a/test/network_tests/offer_tests/offer_test_service.cpp b/test/network_tests/offer_tests/offer_test_service.cpp index c160a6fc4..f017f3ea7 100644 --- a/test/network_tests/offer_tests/offer_test_service.cpp +++ b/test/network_tests/offer_tests/offer_test_service.cpp @@ -156,7 +156,7 @@ TEST(someip_offer_test, notify_increasing_counter) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/offer_tests/offer_test_service_external.cpp b/test/network_tests/offer_tests/offer_test_service_external.cpp index 7cd8ad805..624b07f46 100644 --- a/test/network_tests/offer_tests/offer_test_service_external.cpp +++ b/test/network_tests/offer_tests/offer_test_service_external.cpp @@ -140,7 +140,7 @@ TEST(someip_offer_test, notify_increasing_counter) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp b/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp index 4a2ce0e49..2af3d47b3 100644 --- a/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp +++ b/test/network_tests/offered_services_info_test/offered_services_info_test_client.cpp @@ -300,7 +300,7 @@ TEST(someip_offered_services_info_test, check_offered_services) offered_services_info_test_client its_sample(offer_test::service, offer_test::remote_service, passed_mode); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp b/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp index 3e0465c97..3edd721d6 100644 --- a/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp +++ b/test/network_tests/offered_services_info_test/offered_services_info_test_service.cpp @@ -249,7 +249,7 @@ TEST(someip_offered_services_info_test, check_offered_services_as_rm_impl) offer_test_service its_sample(offer_test::service, offer_test::remote_service); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/payload_tests/payload_test_client.cpp b/test/network_tests/payload_tests/payload_test_client.cpp index fd235d8b9..5907c9b6a 100644 --- a/test/network_tests/payload_tests/payload_test_client.cpp +++ b/test/network_tests/payload_tests/payload_test_client.cpp @@ -319,7 +319,7 @@ TEST(someip_payload_test, send_different_payloads) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { std::string tcp_enable("--tcp"); diff --git a/test/network_tests/payload_tests/payload_test_service.cpp b/test/network_tests/payload_tests/payload_test_service.cpp index 5cace1722..92e26922f 100644 --- a/test/network_tests/payload_tests/payload_test_service.cpp +++ b/test/network_tests/payload_tests/payload_test_service.cpp @@ -158,7 +158,7 @@ TEST(someip_payload_test, send_response_for_every_request) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { std::string help("--help"); diff --git a/test/network_tests/payload_tests/stopwatch.cpp b/test/network_tests/payload_tests/stopwatch.cpp index 83506f4b5..59570e46e 100644 --- a/test/network_tests/payload_tests/stopwatch.cpp +++ b/test/network_tests/payload_tests/stopwatch.cpp @@ -29,7 +29,11 @@ stop_watch::usec_t stop_watch::get_total_elapsed_seconds() const { stop_watch::usec_t stop_watch::now() { struct timespec ts; +#ifdef __QNX__ + const int ret = clock_gettime(CLOCK_MONOTONIC, &ts); +#else const int ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts); +#endif assert(!ret); static_cast(ret); // prevent warning in release build diff --git a/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp b/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp index 75fbd1f98..74471a5f5 100644 --- a/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp +++ b/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp @@ -1701,7 +1701,7 @@ TEST_F(pending_subscription, send_request_to_sd_port) udp_socket.close(ec); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); if(argc < 4) { diff --git a/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp b/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp index 53b2cde2c..e754ebd1f 100644 --- a/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp +++ b/test/network_tests/pending_subscription_tests/pending_subscription_test_service.cpp @@ -354,7 +354,7 @@ TEST(someip_pending_subscription_test, block_subscription_handler) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); 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 67621cd1e..8130d6239 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 @@ -125,7 +125,7 @@ TEST(someip_restart_routing_test, send_response_for_every_request) { } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in b/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in new file mode 100755 index 000000000..70a51cafe --- /dev/null +++ b/test/network_tests/routing_tests/conf/local_routing_test_starter_qnx.sh.in @@ -0,0 +1,76 @@ +#!/bin/sh +# Copyright (C) 2015-2017 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/. + +# Purpose: This script is needed to start the client and service with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start two binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs client +# and service and checks that both exit sucessfully. + +FAIL=0 + +# Parameter 1: the pid to check +check_tcp_udp_sockets_are_closed () +{ + # Check that the service does not listen on any TCP/UDP socket + # or has any active connection via a TCP/UDP socket + # awk is used to avoid the case when a inode number is the same as a PID. The awk + # program filters the netstat output down to the protocol (1st field) and + # the PID/Program name (last field) fields. + SERVICE_SOCKETS_LISTENING=$(netstat -tulpen 2> /dev/null | awk '{print $1 "\t" $NF}' | grep $1 | wc -l) + if [ $SERVICE_SOCKETS_LISTENING -ne 0 ] + then + ((FAIL+=1)) + fi + + SERVICE_SOCKETS_CONNECTED=$(netstat -tupen 2> /dev/null | awk '{print $1 "\t" $NF}' | grep $1 | wc -l) + if [ $SERVICE_SOCKETS_CONNECTED -ne 0 ] + then + ((FAIL+=1)) + fi +} + +export VSOMEIP_CONFIGURATION=local_routing_test_service.json +# start daemon +../../examples/routingmanagerd/./routingmanagerd & +PID_VSOMEIPD=$! + +# Start the service +export VSOMEIP_APPLICATION_NAME=local_routing_test_service +./local_routing_test_service & +SERIVCE_PID=$! +WAIT_PID_ONE=$! +sleep 1; + +check_tcp_udp_sockets_are_closed $SERIVCE_PID + +# Start the client +export VSOMEIP_APPLICATION_NAME=local_routing_test_client +export VSOMEIP_CONFIGURATION=local_routing_test_client.json +./local_routing_test_client & +CLIENT_PID=$! +WAIT_PID_TWO=$! + +check_tcp_udp_sockets_are_closed $SERIVCE_PID +check_tcp_udp_sockets_are_closed $CLIENT_PID + +# Wait until client and service are finished +# Fail gets incremented if either client or service exit +# with a non-zero exit code +wait $WAIT_PID_ONE || ((FAIL+=1)) +wait $WAIT_PID_TWO || ((FAIL+=1)) + +kill $PID_VSOMEIPD +sleep 1 + +# Check if client and server both exited successfully and the service didnt't +# have any open +if [ $FAIL -eq 0 ] +then + exit 0 +else + exit 1 +fi diff --git a/test/network_tests/routing_tests/external_local_routing_test_service.cpp b/test/network_tests/routing_tests/external_local_routing_test_service.cpp index 46b8138ff..658e03517 100644 --- a/test/network_tests/routing_tests/external_local_routing_test_service.cpp +++ b/test/network_tests/routing_tests/external_local_routing_test_service.cpp @@ -176,7 +176,7 @@ TEST(someip_external_local_routing_test, receive_ten_messages_over_local_and_ext } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/routing_tests/local_routing_test_client.cpp b/test/network_tests/routing_tests/local_routing_test_client.cpp index d8bdfcb55..d637755f8 100644 --- a/test/network_tests/routing_tests/local_routing_test_client.cpp +++ b/test/network_tests/routing_tests/local_routing_test_client.cpp @@ -158,7 +158,7 @@ TEST(someip_local_routing_test, send_ten_messages_to_service_and_receive_reply) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/routing_tests/local_routing_test_service.cpp b/test/network_tests/routing_tests/local_routing_test_service.cpp index 640805774..9836f68cf 100644 --- a/test/network_tests/routing_tests/local_routing_test_service.cpp +++ b/test/network_tests/routing_tests/local_routing_test_service.cpp @@ -155,7 +155,7 @@ TEST(someip_local_routing_test, receive_ten_messages_over_local_uds_socket) } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/second_address_tests/second_address_test_client.cpp b/test/network_tests/second_address_tests/second_address_test_client.cpp index 9f05706b9..4ebbf2ce7 100644 --- a/test/network_tests/second_address_tests/second_address_test_client.cpp +++ b/test/network_tests/second_address_tests/second_address_test_client.cpp @@ -332,7 +332,7 @@ TEST(someip_event_test, communicate_using_second_address) second_address_test_client its_sample(second_address_test::service, use_tcp); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/second_address_tests/second_address_test_service.cpp b/test/network_tests/second_address_tests/second_address_test_service.cpp index c675eee87..5b8a7a248 100644 --- a/test/network_tests/second_address_tests/second_address_test_service.cpp +++ b/test/network_tests/second_address_tests/second_address_test_service.cpp @@ -243,7 +243,7 @@ TEST(someip_second_address_test, test_communication_with_client) second_address_test_service its_sample(second_address_test::service); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/security_tests/security_test_service.cpp b/test/network_tests/security_tests/security_test_service.cpp index 35e6fbc8b..9007df149 100644 --- a/test/network_tests/security_tests/security_test_service.cpp +++ b/test/network_tests/security_tests/security_test_service.cpp @@ -171,7 +171,7 @@ TEST(someip_security_test, basic_subscribe_request_response) { } } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { std::string test_remote("--remote"); 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 f2e4f9e5c..9599f76ce 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 @@ -1357,7 +1357,7 @@ TEST_P(someip_tp, send_in_mode) udp_server_socket.close(ec); } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); if(argc < 3) { 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 26fdf6de0..54a335a86 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 @@ -382,7 +382,7 @@ TEST(someip_someip_tp_test, echo_requests) } -#if defined(__linux__) || defined(ANDROID) +#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh new file mode 100755 index 000000000..7d11f4b33 --- /dev/null +++ b/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_master_starter_qnx.sh @@ -0,0 +1,79 @@ +#!/bin/sh +# Copyright (C) 2015-2017 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/. + +# Purpose: This script is needed to start the services with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start multiple binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs the services +# and checks that all exit successfully. + +if [ $# -lt 2 ] +then + echo "Please pass a json file and event reliability type to this script." + echo "For example: $0 subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json UDP" + exit 1 +fi + +# replace master with slave to be able display the correct json file to be used +# with the slave script +RELIABILITY_TYPE=$1 +MASTER_JSON_FILE=$2 +CLIENT_JSON_FILE="" + +FAIL=0 + +# Start the services +export VSOMEIP_APPLICATION_NAME=subscribe_notify_one_test_service_one +export VSOMEIP_CONFIGURATION=$MASTER_JSON_FILE +./subscribe_notify_one_test_service 1 $RELIABILITY_TYPE & + +export VSOMEIP_APPLICATION_NAME=subscribe_notify_one_test_service_two +export VSOMEIP_CONFIGURATION=$MASTER_JSON_FILE +./subscribe_notify_one_test_service 2 $RELIABILITY_TYPE & + +export VSOMEIP_APPLICATION_NAME=subscribe_notify_one_test_service_three +export VSOMEIP_CONFIGURATION=$MASTER_JSON_FILE +./subscribe_notify_one_test_service 3 $RELIABILITY_TYPE & + +sleep 3 + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "starting subscribe_notify_one_test_slave_starter.sh on slave LXC with parameters $CLIENT_JSON_FILE" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./subscribe_notify_one_test_slave_starter.sh $RELIABILITY_TYPE $CLIENT_JSON_FILE\"" & + echo "remote ssh job id: $!" +elif [ ! -z "$USE_DOCKER" ]; then + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./subscribe_notify_one_test_slave_starter.sh $RELIABILITY_TYPE $CLIENT_JSON_FILE" & +else + cat <is_policy_update_allowed(valid_uid, policy)) << "Failed to deny policy update with valid user id and invalid request!"; } +#endif TEST(is_policy_update_allowed, null_policy) {