diff options
Diffstat (limited to 'org.genivi.commonapi.core.verification')
75 files changed, 6611 insertions, 2515 deletions
diff --git a/org.genivi.commonapi.core.verification/.gitignore b/org.genivi.commonapi.core.verification/.gitignore index 4df666e..2053e13 100644 --- a/org.genivi.commonapi.core.verification/.gitignore +++ b/org.genivi.commonapi.core.verification/.gitignore @@ -1,21 +1,8 @@ +*~ *.o /.deps -/.libs /.settings -/autom4te.cache -/build-aux /.cproject /.project -/.autotools -/aclocal.m4 -/config.log -/config.status -/configure -/DynamicLoadingVerification.conf -/CommunicationVerification.conf -/libtool -/Makefile -/Makefile.in -/Build (GNU) -/src/DynamicLoadingVerification.cpp -/src/CommunicationVerification.cpp +/build +/src-gen diff --git a/org.genivi.commonapi.core.verification/AUTHORS b/org.genivi.commonapi.core.verification/AUTHORS deleted file mode 100644 index 2708c9d..0000000 --- a/org.genivi.commonapi.core.verification/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -BMW Group
\ No newline at end of file diff --git a/org.genivi.commonapi.core.verification/CMakeLists.txt b/org.genivi.commonapi.core.verification/CMakeLists.txt new file mode 100644 index 0000000..79bb784 --- /dev/null +++ b/org.genivi.commonapi.core.verification/CMakeLists.txt @@ -0,0 +1,383 @@ +cmake_minimum_required (VERSION 2.8.1) + +PROJECT(capi_verification_tests) + +message("Project name: ${PROJECT_NAME}") + +############################################################################## + +# create the commandline variables: +OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON) +message("USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") + +SET(CMAKE_GLUECODE_DBUS_NAME "na" CACHE STRING "The cmake name of the gluecode library without cmake extension e.g. DBusGlue.") +if("${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na") + message(WARNING "The cmake name of the D-Bus gluecode library without cmake extension needs to be specified. Use '-DCMAKE_GLUECODE_DBUS_NAME=' to do so.") +else() + message("CMAKE_GLUECODE_DBUS_NAME specified: ${CMAKE_GLUECODE_DBUS_NAME}") +endif() + +SET(CMAKE_GLUECODE_SOMEIP_NAME "na" CACHE STRING "The cmake name of the gluecode library without cmake extension e.g. DBusGlue.") +if("${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na") + message(WARNING "The cmake name of the SomeIP gluecode library without cmake extension needs to be specified. Use '-DCMAKE_GLUECODE_SOMEIP_NAME=' to do so.") +else() + message("CMAKE_GLUECODE_SOMEIP_NAME specified: ${CMAKE_GLUECODE_SOMEIP_NAME}") +endif() + +if("${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na" AND "${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na") + message(FATAL_ERROR "Please specify at least one of CMAKE_GLUECODE_DBUS_NAME or CMAKE_GLUECODE_SOMEIP_NAME") + return() +endif() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING + "Choose the type of build, options are: Debug Release." FORCE) +endif(NOT CMAKE_BUILD_TYPE) + +message("Build type: ${CMAKE_BUILD_TYPE}") + +############################################################################## +# add COMMONAPI install path to cmake find root path + +message("CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}") + +FIND_PACKAGE(PkgConfig) + +# find gluecode for D-Bus +if(NOT "${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na") + FIND_PACKAGE(${CMAKE_GLUECODE_DBUS_NAME}) + if ("${${CMAKE_GLUECODE_DBUS_NAME}_CONSIDERED_CONFIGS}" STREQUAL "") + message(WARNING "The cmake file for the D-Bus gluecode was not found. Please DBusGlue_DIR. Use '-DDBusGlue_DIR=' to do so.") + else() + message("${CMAKE_GLUECODE_DBUS_NAME}_CONSIDERED_CONFIGS found: ${${CMAKE_GLUECODE_DBUS_NAME}_CONSIDERED_CONFIGS}") + endif() +endif() + +# find gluecode for SomeIP +if(NOT "${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na") + FIND_PACKAGE(${CMAKE_GLUECODE_SOMEIP_NAME}) + if ("${${CMAKE_GLUECODE_SOMEIP_NAME}_CONSIDERED_CONFIGS}" STREQUAL "") + message(WARNING "The cmake file for the SomeIP gluecode was not found. Please specify SomeIPGlue_DIR. Use '-DSomeIPGlue_DIR=' to do so.") + else() + message("${CMAKE_GLUECODE_SOMEIP_NAME}_CONSIDERED_CONFIGS found: ${${CMAKE_GLUECODE_SOMEIP_NAME}_CONSIDERED_CONFIGS}") + endif() +endif() + +# find commonapi +if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") + FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) +else() + FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) +endif() + +message("CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") +message("COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}") + +############################################################################## +# generate code from fidl +file(GLOB FIDL_FILES "fidl/*.fidl") +execute_process(COMMAND ${COMMONAPI_TOOL_GENERATOR} --dest src-gen --skel ${FIDL_FILES} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + +############################################################################## +# get library names + +string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +message("UPPER_CMAKE_BUILD_TYPE: ${UPPER_CMAKE_BUILD_TYPE}") + +# libDBusGLue +if(NOT "${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na") + get_property(GLUECODE_LIB_PATH_NAME_DBUS TARGET ${CMAKE_GLUECODE_DBUS_NAME} PROPERTY IMPORTED_LOCATION_${UPPER_CMAKE_BUILD_TYPE}) + message("GLUECODE_LIB_PATH_NAME_DBUS value: ${GLUECODE_LIB_PATH_NAME_DBUS}") + # Strip the trailing .0.0.0 from the path as otherwise libCommonAPI won't load the .so + string(LENGTH ${GLUECODE_LIB_PATH_NAME_DBUS} GLUECODE_LIB_PATH_NAME_DBUS_LENGTH) + math(EXPR GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_ADJUSTED '${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH}-6') + string(SUBSTRING ${GLUECODE_LIB_PATH_NAME_DBUS} + 0 ${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_ADJUSTED} + GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_CLEAN + ) + # GLUECODE_SO_DBUS is used in commonapi4dbus.ini.in file + SET(GLUECODE_SO_DBUS ${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_CLEAN}) +endif() + +# libSomeIPGlue +if(NOT "${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na") + get_property(GLUECODE_LIB_PATH_NAME_SOMEIP TARGET ${CMAKE_GLUECODE_SOMEIP_NAME} PROPERTY IMPORTED_LOCATION_${UPPER_CMAKE_BUILD_TYPE}) + message("GLUECODE_LIB_PATH_NAME_SOMEIP value: ${GLUECODE_LIB_PATH_NAME_SOMEIP}") + # Strip the trailing .0.0.0 from the path as otherwise libCommonAPI won't load the .so + string(LENGTH ${GLUECODE_LIB_PATH_NAME_SOMEIP} GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH) + math(EXPR GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_ADJUSTED '${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH}-6') + string(SUBSTRING ${GLUECODE_LIB_PATH_NAME_SOMEIP} + 0 ${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_ADJUSTED} + GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_CLEAN + ) + # GLUECODE_SO_SOMEIP is used in commonapi4dbus.ini.in file + SET(GLUECODE_SO_SOMEIP ${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_CLEAN}) +endif() + +############################################################################## +# configure configuration files +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/conf/commonapi4dbus.ini.in + "${PROJECT_BINARY_DIR}/commonapi4dbus.ini" @ONLY) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/conf/commonapi4someip.ini.in + "${PROJECT_BINARY_DIR}/commonapi4someip.ini" @ONLY) + +############################################################################## +# google test + +# check for set environment variable +if(DEFINED ENV{GTEST_ROOT}) + message("GTEST_ROOT is set. GTEST_ROOT = $ENV{GTEST_ROOT}") +else() + message("GTEST_ROOT is not defined. For building the tests environment variable + GTEST_ROOT have to be defined. Tests can not be built.") + # early exit + return() # test can not be build -> make check is not available +endif() + +# build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active +set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) +if ("${BUILD_SHARED_LIBS}" STREQUAL "ON") + set(BUILD_SHARED_LIBS OFF) + set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1) +endif() +add_subdirectory($ENV{GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) +if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1") + set(BUILD_SHARED_LIBS ON) + set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) +endif() + +############################################################################## +# verification tests build section + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wno-reorder -Wno-unused-variable -DCOMMONAPI_INTERNAL_COMPILATION") +set(USE_RT "rt") + +message("Compiler options: ${CMAKE_CXX_FLAGS}") + +include_directories( + src + src-gen + ${COMMONAPI_INCLUDE_DIRS} + ${gtest_SOURCE_DIR}/include +) + +enable_testing() + +set(CMAKE_CTEST_COMMAND ctest -V) +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) + +set(TEST_LINK_LIBRARIES CommonAPI gtest) + +add_executable(RTLoadingRuntime src/RTLoadingRuntime.cpp) +target_link_libraries(RTLoadingRuntime ${TEST_LINK_LIBRARIES}) + +add_executable(RTBuildProxiesAndStubs + src/RTBuildProxiesAndStubs.cpp + src-gen/v1_0/commonapi/runtime/TestInterfaceStubDefault.cpp) +target_link_libraries(RTBuildProxiesAndStubs ${TEST_LINK_LIBRARIES}) + +add_executable(CMMethodCalls + src/CMMethodCalls.cpp + src/stub/CMMethodCallsStub.cpp + src-gen/v1_0/commonapi/communication/TestInterfaceStubDefault.cpp) +target_link_libraries(CMMethodCalls ${TEST_LINK_LIBRARIES}) + +add_executable(CMAttributes + src/CMAttributes.cpp + src/stub/CMAttributesStub.cpp + src-gen/v1_0/commonapi/communication/TestInterfaceStubDefault.cpp) +target_link_libraries(CMAttributes ${TEST_LINK_LIBRARIES}) + +add_executable(CMAttributeSubscription + src/CMAttributeSubscription.cpp + src-gen/v1_0/commonapi/communication/TestInterfaceStubDefault.cpp) +target_link_libraries(CMAttributeSubscription ${TEST_LINK_LIBRARIES}) + +add_executable(DTPrimitive + src/DTPrimitive.cpp + src/stub/DTPrimitiveStub.cpp + src-gen/v1_0/commonapi/datatypes/primitive/TestInterfaceStubDefault.cpp) +target_link_libraries(DTPrimitive ${TEST_LINK_LIBRARIES}) + +add_executable(DTAdvanced + src/DTAdvanced.cpp + src/stub/DTAdvancedStub.cpp + src-gen/v1_0/commonapi/datatypes/advanced/TestInterfaceStubDefault.cpp + src-gen/v1_0/commonapi/datatypes/advanced/TestInterface.cpp) +target_link_libraries(DTAdvanced ${TEST_LINK_LIBRARIES}) + +add_executable(DTDerived + src/DTDerived.cpp + src/stub/DTDerivedStub.cpp + src-gen/v1_0/commonapi/datatypes/derived/TestInterfaceStubDefault.cpp + src-gen/v1_0/commonapi/datatypes/derived/TestInterface.cpp) +target_link_libraries(DTDerived ${TEST_LINK_LIBRARIES}) + +#add_executable(DTCombined +# src/DTCombined.cpp +# src/stub/DTCombinedStub.cpp +# src-gen/v1_0/commonapi/datatypes/combined/TestInterface.cpp +# src-gen/v1_0/commonapi/datatypes/combined/TestInterfaceStubDefault.cpp) +#target_link_libraries(DTCombined ${TEST_LINK_LIBRARIES}) + +add_executable(THMainLoopIntegration + src/THMainLoopIntegration.cpp + src/stub/THMainLoopIntegrationStub.cpp + src-gen/v1_0/commonapi/threading/TestInterfaceStubDefault.cpp) +target_link_libraries(THMainLoopIntegration ${TEST_LINK_LIBRARIES}) + +add_executable(THMainLoopIndependence + src/THMainLoopIndependence.cpp + src-gen/v1_0/commonapi/threading/TestInterfaceStubDefault.cpp) +target_link_libraries(THMainLoopIndependence ${TEST_LINK_LIBRARIES}) + +add_executable(PFPrimitive + src/PFPrimitive.cpp + src/stub/PFPrimitiveStub.cpp + src/utils/StopWatch.cpp + src-gen/v1_0/commonapi/performance/primitive/TestInterfaceStubDefault.cpp) +target_link_libraries(PFPrimitive ${TEST_LINK_LIBRARIES} ${USE_RT}) + +add_executable(PFComplex + src/PFComplex.cpp + src/stub/PFComplexStub.cpp + src/utils/StopWatch.cpp + src-gen/v1_0/commonapi/performance/complex/TestInterface.cpp + src-gen/v1_0/commonapi/performance/complex/TestInterfaceStubDefault.cpp) +target_link_libraries(PFComplex ${TEST_LINK_LIBRARIES} ${USE_RT}) + +add_executable(StabilitySP + src/StabilitySP.cpp + src/stub/StabilitySPStub.cpp + src-gen/v1_0/commonapi/stability/sp/TestInterfaceStubDefault.cpp) +target_link_libraries(StabilitySP ${TEST_LINK_LIBRARIES}) + +add_executable(StabilityMP + src/StabilityMP.cpp + src/stub/StabControlStub.cpp + src/stub/StabilityMPStub.cpp + src-gen/v1_0/commonapi/stability/mp/ControlInterfaceStubDefault.cpp + src-gen/v1_0/commonapi/stability/mp/TestInterfaceStubDefault.cpp) +target_link_libraries(StabilityMP ${TEST_LINK_LIBRARIES}) + +add_dependencies(RTLoadingRuntime gtest) +add_dependencies(RTBuildProxiesAndStubs gtest) +add_dependencies(CMMethodCalls gtest) +add_dependencies(CMAttributes gtest) +add_dependencies(CMAttributeSubscription gtest) +add_dependencies(DTPrimitive gtest) +add_dependencies(DTAdvanced gtest) +add_dependencies(DTDerived gtest) +#add_dependencies(DTCombined gtest) +add_dependencies(THMainLoopIntegration gtest) +add_dependencies(THMainLoopIndependence gtest) +add_dependencies(PFPrimitive gtest) +add_dependencies(PFComplex gtest) +add_dependencies(StabilitySP gtest) +add_dependencies(StabilityMP gtest) + +add_dependencies(check RTLoadingRuntime) +add_dependencies(check RTBuildProxiesAndStubs) +add_dependencies(check CMMethodCalls) +add_dependencies(check CMAttributes) +add_dependencies(check CMAttributeSubscription) +add_dependencies(check DTPrimitive) +add_dependencies(check DTAdvanced) +add_dependencies(check DTDerived) +#add_dependencies(check DTCombined) +add_dependencies(check THMainLoopIntegration) +add_dependencies(check THMainLoopIndependence) +add_dependencies(check PFPrimitive) +add_dependencies(check PFComplex) +add_dependencies(check StabilitySP) +add_dependencies(check StabilityMP) + +# Tests for DBus +if(NOT "${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na") + # Construct the environment for the tests + set(DBUS_COMMONAPI_CONFIG "COMMONAPI_CONFIG=commonapi4dbus.ini") + set(DBUS_TEST_ENVIRONMENT + ${DBUS_COMMONAPI_CONFIG} + ) + + add_test(NAME RTLoadingRuntimeDBus COMMAND RTLoadingRuntime) + set_property(TEST RTLoadingRuntimeDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME RTBuildProxiesAndStubsDBus COMMAND RTBuildProxiesAndStubs) + set_property(TEST RTBuildProxiesAndStubsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME CMMethodCallsDBus COMMAND CMMethodCalls) + set_property(TEST CMMethodCallsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME CMAttributesDBus COMMAND CMAttributes) + set_property(TEST CMAttributesDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME CMAttributeSubscriptionDBus COMMAND CMAttributeSubscription) + set_property(TEST CMAttributeSubscriptionDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME DTPrimitiveDBus COMMAND DTPrimitive) + set_property(TEST DTPrimitiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME DTAdvancedDBus COMMAND DTAdvanced) + set_property(TEST DTAdvancedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME DTDerivedDBus COMMAND DTDerived) + set_property(TEST DTDerivedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + #add_test(NAME DTCombinedDBus COMMAND DTCombined) + #set_property(TEST DTCombinedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME THMainLoopIntegrationDBus COMMAND THMainLoopIntegration) + set_property(TEST THMainLoopIntegrationDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME THMainLoopIndependenceDBus COMMAND THMainLoopIndependence) + set_property(TEST THMainLoopIndependenceDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME PFPrimitiveDBus COMMAND PFPrimitive) + set_property(TEST PFPrimitiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME PFComplexDBus COMMAND PFComplex) + set_property(TEST PFComplexDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME StabilitySPDBus COMMAND StabilitySP) + set_property(TEST StabilitySPDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) + add_test(NAME StabilityMPDBus COMMAND StabilityMP) + set_property(TEST StabilityMPDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT}) +endif() + +# Tests for SomeIP +if(NOT "${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na") + # Construct the environment for the tests + set(SOMEIP_COMMONAPI_CONFIG "COMMONAPI_CONFIG=commonapi4someip.ini") + set(SOMEIP_VSOMEIP_JSON_FILE "VSOMEIP_CONFIGURATION_FILE=../../../ascgit017.CommonAPI-SomeIP-Tools/org.genivi.commonapi.someip.verification/vsomeip.json") + set(SOMEIP_TEST_ENVIRONMENT + ${SOMEIP_COMMONAPI_CONFIG} + ${SOMEIP_VSOMEIP_JSON_FILE} + ) + + add_test(NAME RTLoadingRuntimeSomeIP COMMAND RTLoadingRuntime) + set_property(TEST RTLoadingRuntimeSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME RTBuildProxiesAndStubsSomeIP COMMAND RTBuildProxiesAndStubs) + set_property(TEST RTBuildProxiesAndStubsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME CMMethodCallsSomeIP COMMAND CMMethodCalls) + set_property(TEST CMMethodCallsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME CMAttributesSomeIP COMMAND CMAttributes) + set_property(TEST CMAttributesSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME CMAttributeSubscriptionSomeIP COMMAND CMAttributeSubscription) + set_property(TEST CMAttributeSubscriptionSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME DTPrimitiveSomeIP COMMAND DTPrimitive) + set_property(TEST DTPrimitiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME DTAdvancedSomeIP COMMAND DTAdvanced) + set_property(TEST DTAdvancedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME DTDerivedSomeIP COMMAND DTDerived) + set_property(TEST DTDerivedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + #add_test(NAME DTCombinedSomeIP COMMAND DTCombined) + #set_property(TEST DTCombinedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME THMainLoopIntegrationSomeIP COMMAND THMainLoopIntegration) + set_property(TEST THMainLoopIntegrationSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME THMainLoopIndependenceSomeIP COMMAND THMainLoopIndependence) + set_property(TEST THMainLoopIndependenceSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME PFPrimitiveSomeIP COMMAND PFPrimitive) + set_property(TEST PFPrimitiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME PFComplexSomeIP COMMAND PFComplex) + set_property(TEST PFComplexSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME StabilitySPSomeIP COMMAND StabilitySP) + set_property(TEST StabilitySPSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) + add_test(NAME StabilityMPSomeIP COMMAND StabilityMP) + set_property(TEST StabilityMPSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT}) +endif() + +############################################################################## +# maintainer-clean +add_custom_target(maintainer-clean COMMAND rm -rf *) + diff --git a/org.genivi.commonapi.core.verification/COPYING b/org.genivi.commonapi.core.verification/COPYING deleted file mode 100644 index 94a9ed0..0000000 --- a/org.genivi.commonapi.core.verification/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - <program> Copyright (C) <year> <name of author> - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -<http://www.gnu.org/licenses/>. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/org.genivi.commonapi.core.verification/CommunicationVerification.conf.in b/org.genivi.commonapi.core.verification/CommunicationVerification.conf.in deleted file mode 100644 index 4916c37..0000000 --- a/org.genivi.commonapi.core.verification/CommunicationVerification.conf.in +++ /dev/null @@ -1,5 +0,0 @@ -{binding:@BINDING_NAME@} -libpath=@BINDING_SO@ -alias=TestAlias -genpath=@GLUECODE_SO@ -default diff --git a/org.genivi.commonapi.core.verification/DynamicLoadingVerification.conf.in b/org.genivi.commonapi.core.verification/DynamicLoadingVerification.conf.in deleted file mode 100644 index 4916c37..0000000 --- a/org.genivi.commonapi.core.verification/DynamicLoadingVerification.conf.in +++ /dev/null @@ -1,5 +0,0 @@ -{binding:@BINDING_NAME@} -libpath=@BINDING_SO@ -alias=TestAlias -genpath=@GLUECODE_SO@ -default diff --git a/org.genivi.commonapi.core.verification/LICENSE b/org.genivi.commonapi.core.verification/LICENSE deleted file mode 100644 index 14e2f77..0000000 --- a/org.genivi.commonapi.core.verification/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/org.genivi.commonapi.core.verification/Makefile.am b/org.genivi.commonapi.core.verification/Makefile.am deleted file mode 100644 index db8aa4e..0000000 --- a/org.genivi.commonapi.core.verification/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 - -GLUE_LDFLAGS_FOR_A="-Wl,--whole-archive,${GLUECODE_A},${BINDING_A},--no-whole-archive,${BINDING_EXTRA}" -GLUE_LDFLAGS_FOR_SO="-Wl,--no-as-needed,${GLUECODE_SO},${BINDING_SO},--as-needed,${BINDING_EXTRA}" - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I./src-gen \ - -I$(includedir) \ - ${COMMONAPI_CFLAGS} \ - ${GTEST_CPPFLAGS} - -check_PROGRAMS = \ - DynamicLoadingVerification \ - MainLoopVerification \ - CommunicationVerification - -generated = \ - src-gen/commonapi/tests/DerivedTypeCollection.cpp \ - src-gen/commonapi/tests/TestInterfaceStubDefault.cpp \ - src-gen/commonapi/tests/CommunicationVerification.cpp - -TESTS = ${check_PROGRAMS} - -DynamicLoadingVerification_SOURCES = \ - src/utils/VerificationTestStub.cpp \ - src/DynamicLoadingVerification.cpp - -MainLoopVerification_SOURCES = \ - src/utils/VerificationTestStub.cpp \ - src/MainLoopVerification.cpp - -CommunicationVerification_SOURCES = \ - src/utils/VerificationTestStub.cpp \ - src/CommunicationVerification.cpp - -DynamicLoadingVerification_CPPFLAGS = ${AM_CPPFLAGS} -DynamicLoadingVerification_LDADD = ${COMMONAPI_LIBS} ${GTEST_LIBS} -DynamicLoadingVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_SO} - -MainLoopVerification_CPPFLAGS = ${AM_CPPFLAGS} -MainLoopVerification_LDADD = ${COMMONAPI_LIBS} ${BINDING_A} ${GTEST_LIBS} -MainLoopVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_A} - -CommunicationVerification_CPPFLAGS = ${AM_CPPFLAGS} -CommunicationVerification_LDADD = ${COMMONAPI_LIBS} ${BINDING_A} ${GTEST_LIBS} -CommunicationVerification_LDFLAGS = ${GLUE_LDFLAGS_FOR_A} diff --git a/org.genivi.commonapi.core.verification/README b/org.genivi.commonapi.core.verification/README index 4f3c790..78d03d9 100644 --- a/org.genivi.commonapi.core.verification/README +++ b/org.genivi.commonapi.core.verification/README @@ -1,5 +1,5 @@ GENIVI_org.genivi.commonapi.core.verification -====================== +============================================= :Author: Juergen Gehring - juergen.gehring@bmw.de, Manfred Bathelt - manfred.bathelt@bmw.de :doctitle: GENIVI_org.genivi.commonapi.core.verification @@ -35,32 +35,72 @@ The term "gluecode" refers to a binary that contains the binding specific genera src directory within that project. The gluecode library needs to contain the generated proxy and stub files (Common-API as well as binding specific ones) from the three .fidl files mentioned above. -There are some configure options that allow you to define the binding that should be tested: +There are some cmake options that allow you to define the binding that should be tested: ---with-gluecode=... specifies the path to your gluecode libraries, including name, excluding file ending; .a and .so files with -the given name will be used. ---with-binding-name=... specifies the "well-known" name for the binding to be tested. This is the name which may be used to -dynamically load the binding. ---with-binding=... specifies the path to the binding library, including name, excluding file ending; .a and .so files with -the given name will be used. +* -DCMAKE_GLUECODE_SOMEIP_NAME=SomeIPGlue and -DSomeIPGlue_DIR : + This will enable the verification test for SomeIP in ctest +* -DCMAKE_GLUECODE_DBUS_NAME=DBusGlue and -DDBusGlue_DIR : + This will enable the verifcation tests for DBus in ctest -If your binding needs additional libraries, use --binding-extra=... to specify them. +If the gluecode for both middlewarebindings is defined, there will be two +testcases available for one verification tests. One with postfix `DBus` and one +with `SomeIP`. + +Example: Excerpt of a `ctest -N` call inside the build directory, when both middlewares +were specified in the `cmake` call: +---- +$ ctest -N +Test project ascgit017.CommonAPI-Tools/org.genivi.commonapi.core.verification/build + [...] + Test #6: DTPrimitiveDBus + Test #7: DTAdvancedDBus + Test #8: DTDerivedDBus + [...] + Test #20: DTPrimitiveSomeIP + Test #21: DTAdvancedSomeIP + Test #22: DTDerivedSomeIP + [...] +---- GTest is needed to compile and run the test. Its confuguration script location must be available -in the environment variable GTEST_CONFIG. +in the environment variable `GTEST_CONFIG`. == Usage -1. Generate CommonAPI code for alll .fidl files within /src using the code generator. After that you should find the generated files in /src-gen -2. Run autoreconf -i -3. Configure the project to find the gluecode (see also "Description") -Ensure you have GTEST_CONFIG set to the correct location, e.g. GTEST_CONFIG=/home/user/work/gtest/scripts/gtest-config - Examples: - configure --with-gluecode=/home/user/CommonAPI-D-Bus-Tools/org.genivi.commonapi.dbus.verification/.libs/libDBusGlue \ - --with-binding-name=DBus \ - --with-binding=/home/user/CommonAPI-D-Bus/.libs/libCommonAPI-DBus - --with-binding-extra=/home/user/dbus-1.4.16/dbus/.libs/libdbus-1.so - If you do not need extra libraries, you can omit the --with-binding-extra option -4. Run make check (Ensure that any additional .so which may be required can be found, for example by setting the LD_LIBRARY_PATH variable) -5. Execute ./verification in order to run the test cases once again -
\ No newline at end of file +1. Build needed glue code libraries, e.g. for SomeIP and for DBus. + Instructions how to do so can be found in the corresponding READMEs in the + verification folders of the middlewares. For example + `ascgit017.CommonAPI-SomeIP-Tools/org.genivi.commonapi.someip.verification` + in case of SomeIP. +2. Run `cmake` (see below). + Ensure you have `GTEST_CONFIG` set to the correct location, + e.g. `GTEST_CONFIG=/home/user/work/gtest/scripts/gtest-config` +3. Run `make check` (Ensure that any additional .so, like the patched libdbus, + which may be required can be found, for example by setting the LD_LIBRARY_PATH variable) +4. Call `ctest -N` in the build directory to list the available test cases. + Run `ctest -V` (additional .so must be set in LD_LIBRARY_PATH) to run all tests. + or run `ctest -V -R $TESTCASENAME` to run a single test. + +CMake Example call: +---- +export GTEST_ROOT=$YOUR_PATH_HERE/gtest-1.7.0/ + +cd org.genivi.commonapi.core.verification/ +rm -rf build +rm -rf src-gen +mkdir build +cd build +cmake \ +-DCommonAPI_DIR=$(readlink -f ../../../ascgit017.CommonAPI/build) \ +-DCOMMONAPI_TOOL_GENERATOR=$(readlink -f ../../../ascgit017.CommonAPI-Tools/org.genivi.commonapi.core.cli.product/target/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86_64/commonapi-generator-linux-x86_64) \ +-DCMAKE_GLUECODE_SOMEIP_NAME=SomeIPGlue \ +-DSomeIPGlue_DIR=$(readlink -f ../../../ascgit017.CommonAPI-SomeIP-Tools/org.genivi.commonapi.someip.verification/build) \ +-DCMAKE_GLUECODE_DBUS_NAME=DBusGlue \ +-DDBusGlue_DIR=$(readlink -f ../../../ascgit017.CommonAPI-D-Bus-Tools/org.genivi.commonapi.dbus.verification/build) \ +.. + +make check +ctest -V +---- + + diff --git a/org.genivi.commonapi.core.verification/configure.ac b/org.genivi.commonapi.core.verification/configure.ac deleted file mode 100644 index a091ee5..0000000 --- a/org.genivi.commonapi.core.verification/configure.ac +++ /dev/null @@ -1,189 +0,0 @@ -AC_PREREQ(2.59) -AC_INIT(org.genivi.commonapi.core.verification, 1.0) -AC_USE_SYSTEM_EXTENSIONS -AC_CONFIG_MACRO_DIR([m4]) -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_HEADERS([build-aux/config.h]) -AC_CONFIG_FILES([ - Makefile - DynamicLoadingVerification.conf - src/DynamicLoadingVerification.cpp - CommunicationVerification.conf - src/CommunicationVerification.cpp - ]) - -AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE([foreign]) - - -### Binding definitions ### - -# Well known binding name -AC_MSG_CHECKING(Well known name of the binding that is to be tested) -AC_ARG_WITH([binding-name], [Well known name of the binding that is to be tested], [ - BINDING_NAME=${withval} - AC_MSG_RESULT(${BINDING_NAME}) -],[ - AC_MSG_RESULT(no) - AC_MSG_ERROR([A binding that shall be verified ne eds to be specified! Use '--with-binding=' to do so.]) -]) - -AC_MSG_RESULT([ - $PACKAGE_NAME v$VERSION - - COMMONAPI_CFLAGS: ${COMMONAPI_CFLAGS} - COMMONAPI_LIBS: ${COMMONAPI_LIBS} - - BINDING_FQN: ${BINDING_FQN} - BINDING_SO: ${BINDING_SO} - - BINDING_A: ${BINDING_A} - BINDING_EXTRA: ${BINDING_EXTRA} -]) - - - -# Path to binding libraries -AC_ARG_WITH([binding], [full path to binding library, including name, excluding file ending. The .a and .so files with the given fqn will be used if present and when needed.], [ - BINDING_FQN=${withval} - - AC_MSG_CHECKING(.a binding library) - AS_IF([test -f "${BINDING_FQN}.a"], [ - BINDING_A="${BINDING_FQN}.a" - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ] - ) - - AC_MSG_CHECKING(.so binding library) - AS_IF([test -f "${BINDING_FQN}.so"], [ - BINDING_SO="${BINDING_FQN}.so" - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ] - ) -], [AC_MSG_ERROR([A binding that shall be verified needs to be specified! Use '--with-binding=' to do so.])]) - - -# Additional libraries required by the binding -AC_ARG_WITH([binding-extra], [full path to additional library required by statically linked binding], [ - AC_MSG_CHECKING(required additional libraries for the binding) - AS_IF([test -f "${withval}"], [ - BINDING_EXTRA="${withval}" - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ] - ) -],[]) - - -AM_CONDITIONAL(STATICALLY_LINKED_BINDING, [test -f "${GTEST_CONFIG}" && ${TESTS_CAN_BE_EXECUTED}]) -AM_CONDITIONAL(DYNAMICALLY_LINKED_BINDING, [test -f "${GTEST_CONFIG}" && ${TESTS_CAN_BE_EXECUTED}]) - -#Libraries containing binding specific gluecode -AC_ARG_WITH([gluecode], [full path to gluecode libraries, including name, excluding file ending. The .a and .so files with the given name will be used if present and when needed.], [ - GLUECODE_FQN=${withval} - - AC_MSG_CHECKING(.a gluecode library) - AS_IF([test -f "${GLUECODE_FQN}.a"], [ - GLUECODE_A="${GLUECODE_FQN}.a" - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ] - ) - - AC_MSG_CHECKING(.so gluecode library) - AS_IF([test -f "${GLUECODE_FQN}.so"], [ - GLUECODE_SO="${GLUECODE_FQN}.so" - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ] - ) -], [AC_MSG_WARN([No path to binding specific gluecode library specified. Is this correct? If not, do so with '--with-gluecode='.])]) - - -#Substitutions -AC_SUBST(BINDING_NAME) -AC_SUBST(BINDING_SO) -AC_SUBST(BINDING_A) -AC_SUBST(BINDING_EXTRA) -AC_SUBST(GLUECODE_SO) -AC_SUBST(GLUECODE_A) - - -#Configurations -AC_PROG_CXX -AC_LANG([C++]) -AX_CXX_COMPILE_STDCXX_11([noext]) - -LT_PREREQ(2.2) -LT_INIT - - -#Dependencies -PKG_PROG_PKG_CONFIG -PKG_CHECK_MODULES(COMMONAPI, [CommonAPI >= 2.0]) - -GTEST_MIN_VERSION="1.6.0" -GTEST_URL="http://code.google.com/p/googletest" - -AC_ARG_VAR([GTEST_CONFIG], [The exact path of Google Test's 'gtest-config' script.]) -AC_ARG_VAR([GTEST_CPPFLAGS], [C-like preprocessor flags for Google Test.]) -AC_ARG_VAR([GTEST_CXXFLAGS], [C++ compile flags for Google Test.]) -AC_ARG_VAR([GTEST_LDFLAGS], [Linker path and option flags for Google Test.]) -AC_ARG_VAR([GTEST_LIBS], [Library linking flags for Google Test.]) -AC_ARG_VAR([GTEST_VERSION], [The available version of Google Test.]) - -AS_IF([test -f "${GTEST_CONFIG}"], [ - AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}], - [], - [AC_MSG_ERROR([Found Google Test Version ${GTEST_VERSION}. However ${GTEST_MIN_VERSION} is - required. Please refer to ${GTEST_URL} for a more recent version.])]) - [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`] - [GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`] - [GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`] - [GTEST_LIBS=`${GTEST_CONFIG} --libs`] - [GTEST_VERSION=`${GTEST_CONFIG} --version`] - ], [ - AC_MSG_ERROR([Google Test could not be found! Please provide an environment variable 'GTEST_CONFIG' - pointing to the location of Google Test's 'gtest-config' script]) - ] -) - - -#Result -AC_MSG_RESULT([ - $PACKAGE_NAME v$VERSION - - COMMONAPI_CFLAGS: ${COMMONAPI_CFLAGS} - COMMONAPI_LIBS: ${COMMONAPI_LIBS} - - BINDING_FQN: ${BINDING_FQN} - BINDING_SO: ${BINDING_SO} - - BINDING_A: ${BINDING_A} - BINDING_EXTRA: ${BINDING_EXTRA} - - GLUECODE_FQN: ${GLUECODE_FQN} - GLUECODE_SO: ${GLUECODE_SO} - GLUECODE_A: ${GLUECODE_A} - - GTEST_CONFIG: ${GTEST_CONFIG} - GTEST_CPPFLAGS: ${GTEST_CPPFLAGS} - GTEST_CXXFLAGS: ${GTEST_CXXFLAGS} - GTEST_LDFLAGS: ${GTEST_LDFLAGS} - GTEST_LIBS: ${GTEST_LIBS} - GTEST_VERSION: ${GTEST_VERSION} - - CXXFLAGS: ${CXXFLAGS} - LDFLAGS: ${LDFLAGS} -]) - -AC_OUTPUT - diff --git a/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl b/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl new file mode 100644 index 0000000..50329be --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl @@ -0,0 +1,23 @@ +/* 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/. */ +package commonapi.communication + +interface TestInterface { + version { major 1 minor 0 } + + attribute UInt8 testAttribute + + attribute UInt8 testA readonly + attribute UInt8 testB noSubscriptions + attribute UInt8 testC readonly noSubscriptions + + method testMethod { + in { + UInt8 x + } + out { + UInt8 y + } + } +}
\ No newline at end of file diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl new file mode 100644 index 0000000..65b44a9 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl @@ -0,0 +1,70 @@ +/* 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/. */ +package commonapi.datatypes.advanced + +interface TestInterface { + version { major 1 minor 0 } + + attribute tArray aArray + attribute tEnumeration aEnumeration + attribute tStruct aStruct + attribute tUnion aUnion + attribute tMap aMap + attribute tTypedef aTypedef + + method fTest { + in { + tArray tArrayIn + tEnumeration tEnumerationIn + tStruct tStructIn + tUnion tUnionIn + tMap tMapIn + tTypedef tTypedefIn + } + out { + tArray tArrayOut + tEnumeration tEnumerationOut + tStruct tStructOut + tUnion tUnionOut + tMap tMapOut + tTypedef tTypedefOut + } + } + + broadcast bTest { + out { + tArray tArrayOut + tEnumeration tEnumerationOut + tStruct tStructOut + tUnion tUnionOut + tMap tMapOut + tTypedef tTypedefOut + } + } + + array tArray of String + + enumeration tEnumeration { + VALUE1= "0" + VALUE2= "123" + } + + struct tStruct { + Boolean booleanMember + UInt8 uint8Member + String stringMember + } + + union tUnion { + Boolean booleanMember + UInt8 uint8Member + String stringMember + } + + map tMap { + UInt8 to String + } + + typedef tTypedef is UInt8 +} diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl new file mode 100644 index 0000000..eab2007 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl @@ -0,0 +1,249 @@ +/* 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/. */ +package commonapi.datatypes.combined + +interface TestInterface { + version { major 1 minor 0 } + + attribute tStructL3 aStructL3 + //attribute tUnionL3 aUnionL3 + + method fTest { + in { + tStructL3 tStructL3In + //tUnionL3 tUnionL3In + + } + out { + tStructL3 tStructL3Out + //tUnionL3 tUnionL3Out + } + } + + // Level 0 + + enumeration tEnum { + VALUE1= "0" + VALUE2= "123" + } + + array tArray of String + + struct tStruct { + Boolean booleanMember + UInt8 uint8Member + String stringMember + tEnum enumMember + } + + union tUnion { + Boolean booleanMember + UInt8 uint8Member + String stringMember + tEnum enumMember + } + + map tMap { + UInt8 to String + } + + // Level 1 + + array tArrayEnum of tEnum + array tArrayArray of tArray + array tArrayStruct of tStruct + array tArrayUnion of tUnion + array tArrayMap of tMap + + struct tStructL1 { + tEnum enumMember + tArray arrayMemner + tStruct structMember + tUnion unionMember + tMap mapMember + } + + union tUnionL1 { + tEnum enumMember + tArray arrayMember + tStruct structMember + tUnion unionMember + tMap mapMember + } + + map tMapEnum { + UInt8 to tEnum + } + + map tMapArray { + Double to tArray + } + + map tMapStruct { + String to tStruct + } + + map tMapUnion { + Float to tUnion + } + + map tMapMap { + Int8 to tMap + } + + // Level 2 + + array tArrayArrayEnum of tArrayEnum + array tArrayArrayArray of tArrayArray + array tArrayArrayStruct of tArrayStruct + array tArrayArrayUnion of tArrayUnion + array tArrayArrayMap of tArrayMap + array tArrayStructL1 of tStructL1 + array tArrayUnionL1 of tUnionL1 + array tArrayMapEnum of tMapEnum + array tArrayMapArray of tMapArray + array tArrayMapStruct of tMapStruct + array tArrayMapUnion of tMapUnion + array tArrayMapMap of tMapMap + + struct tStructL2 { + tEnum [] arrayEnumMember + tArray [] arrayArrayMember + tStruct [] arrayStructMember + tUnion [] arrayUnionMember + tMap [] arrayMapMember + tStructL1 structL1Member + tUnionL1 unionL1Member + tMapEnum mapEnumMember + tMapArray mapArrayMember + tMapStruct mapStructMember + tMapUnion mapUnionMember + tMapMap mapMapMember + } + + union tUnionL2 { + tArrayEnum arrayEnumMember + tArrayArray arrayArrayMember + tArrayStruct arrayStructMember + tArrayUnion arrayUnionMember + tArrayMap arrayMapMember + tStructL1 structL1Member + tUnionL1 unionL1Member + tMapEnum mapEnumMember + tMapArray mapArrayMember + tMapStruct mapStructMember + tMapUnion mapUnionMember + tMapMap mapMapMember + } + + map tMapArrayEnum { + String to tArrayEnum + } + + map tMapArrayArray { + String to tArrayArray + } + + map tMapArrayStruct { + String to tArrayStruct + } + + map tMapArrayUnion { + String to tArrayUnion + } + + map tMapArrayMap { + String to tArrayMap + } + + map tMapStructL1 { + String to tStructL1 + } + + map tMapUnionL1 { + String to tUnionL1 + } + + map tMapMapEnum { + String to tMapEnum + } + + map tMapMapArray { + String to tMapArray + } + + map tMapMapStruct { + String to tMapStruct + } + + map tMapMapUnion { + String to tMapUnion + } + + map tMapMapMap { + String to tMapMap + } + + // Level 3 + // Due to the libdbus limit of signature length < DBUS_MAXIMUM_SIGNATURE_LENGTH = 255 the structure cannot be completely used as argument + // see dbus-protocol.h. Simply change this value does not work. + + struct tStructL3 { + tArrayArrayEnum arrayArrayEnumMember + tArrayArrayArray arrayArrayArrayMember + tArrayArrayStruct arrayArrayStructMember + tArrayArrayUnion arrayArrayUnionMember + tArrayArrayMap arrayArrayMapMember + tArrayStructL1 arrayStructL1Member + //tArrayUnionL1 arrayUnionL1Member + //tArrayMapEnum arrayMapEnumMember + //tArrayMapArray arrayMapArrayMember + //tArrayMapStruct arrayMapStructMember + //tArrayMapUnion arrayMapUnionMember + //tArrayMapMap arrayMapMapMember + tStructL2 structL2Member + //tUnionL2 unionL2Member + tMapArrayEnum mapArrayEnumMember + tMapArrayArray mapArrayArrayMember + tMapArrayStruct mapArrayStructMember + tMapArrayUnion mapArrayUnionMember + tMapArrayMap mapArrayMapMember + //tMapStructL1 mapStructL1Member + tMapUnionL1 mapUnionL1Member + tMapMapEnum mapMapEnumMember + tMapMapArray mapMapArrayMember + tMapMapStruct mapMapStructMember + tMapMapUnion mapMapUnionMember + tMapMapMap mapMapMapMember + } + +// union tUnionL3 { +// tArrayArrayEnum arrayArrayEnumMember +// tArrayArrayArray arrayArrayArrayMember +// tArrayArrayStruct arrayArrayStructMember +// tArrayArrayUnion arrayArrayUnionMember +// tArrayArrayMap arrayArrayMapMember +// tArrayStructL1 arrayStructL1Member +// tArrayUnionL1 arrayUnionL1Member +// tArrayMapEnum arrayMapEnumMember +// tArrayMapArray arrayMapArrayMember +// tArrayMapStruct arrayMapStructMember +// tArrayMapUnion arrayMapUnionMember +// tArrayMapMap arrayMapMapMember +// tStructL2 structL2Member +// tUnionL2 unionL2Member +// tMapArrayEnum mapArrayEnumMember +// tMapArrayArray mapArrayArrayMember +// tMapArrayStruct mapArrayStructMember +// tMapArrayUnion mapArrayUnionMember +// tMapArrayMap mapArrayMapMember +// tMapStructL1 mapStructL1Member +// tMapUnionL1 mapUnionL1Member +// tMapMapEnum mapMapEnumMember +// tMapMapArray mapMapArrayMember +// tMapMapStruct mapMapStructMember +// tMapMapUnion mapMapUnionMember +// tMapMapMap mapMapMapMember +// } +} diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl new file mode 100644 index 0000000..d7eede7 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl @@ -0,0 +1,74 @@ +/* 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/. */ +package commonapi.datatypes.derived + +interface TestInterface { + version { major 1 minor 0 } + + attribute tStructExt aStructExt + attribute tEnumExt aEnumExt + attribute tUnionExt aUnionExt + attribute tBaseStruct aBaseStruct + + method fTest { + in { + tStructExt tStructExtIn + tEnumExt tEnumExtIn + tUnionExt tUnionExtIn + tBaseStruct tBaseStructIn + } + out { + tStructExt tStructExtOut + tEnumExt tEnumExtOut + tUnionExt tUnionExtOut + tBaseStruct tBaseStructOut + } + } + + broadcast bTest { + out { + tStructExt tStructExtOut + tEnumExt tEnumExtOut + tUnionExt tUnionExtOut + tBaseStruct tBaseStructOut + } + } + + struct tStruct { + UInt8 baseMember + } + + struct tStructExt extends tStruct { + String extendedMember + } + + enumeration tEnum { + VALUE1= "0" + } + + enumeration tEnumExt extends tEnum { + VALUE2= "1" + } + + union tUnion { + UInt8 baseMember + } + + union tUnionExt extends tUnion { + String extendedMember + } + + struct tBaseStruct polymorphic { + } + + struct tBaseOneStruct extends tBaseStruct { + UInt8 number + } + + struct tBaseTwoStruct extends tBaseStruct { + String name + } + + +} diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl new file mode 100644 index 0000000..57e8be2 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl @@ -0,0 +1,73 @@ +/* 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/. */ +package commonapi.datatypes.primitive + +interface TestInterface { + version { major 1 minor 0 } + + attribute UInt8 aUint8 + attribute Int8 aInt8 + attribute UInt16 aUint16 + attribute Int16 aInt16 + attribute UInt32 aUint32 + attribute Int32 aInt32 + attribute UInt64 aUint64 + attribute Int64 aInt64 + attribute Boolean aBoolean + attribute Float aFloat + attribute Double aDouble + attribute String aString + //attribute ByteBuffer aByteBuffer + + method fTest { + in { + UInt8 uint8In + Int8 int8In + UInt16 uint16In + Int16 int16In + UInt32 uint32In + Int32 int32In + UInt64 uint64In + Int64 int64In + Boolean booleanIn + Float floatIn + Double doubleIn + String stringIn + //ByteBuffer byteBufferIn + } + out { + UInt8 uint8Out + Int8 int8Out + UInt16 uint16Out + Int16 int16Out + UInt32 uint32Out + Int32 int32Out + UInt64 uint64Out + Int64 int64Out + Boolean booleanOut + Float floatOut + Double doubleOut + String stringOut + //ByteBuffer byteBufferOut + } + } + + broadcast bTest { + out { + UInt8 uint8Out + Int8 int8Out + UInt16 uint16Out + Int16 int16Out + UInt32 uint32Out + Int32 int32Out + UInt64 uint64Out + Int64 int64Out + Boolean booleanOut + Float floatOut + Double doubleOut + String stringOut + //ByteBuffer byteBufferOut + } + } +} diff --git a/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl b/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl new file mode 100644 index 0000000..eb80e40 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl @@ -0,0 +1,38 @@ +/* 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/. */ +package commonapi.performance.complex + +interface TestInterface { + version { major 1 minor 0 } + + method testMethod { + in { + tArray x + } + out { + tArray y + } + } + + struct tStruct { + innerStruct iStruct + innerUnion iUnion + } + + struct innerStruct { + UInt32 uint32Member + Boolean booleanMember + UInt8 uint8Member + String stringMember + UInt16 uint16Member + } + + union innerUnion { + Boolean booleanMember + UInt8 uint8Member + String stringMember + } + + array tArray of tStruct +}
\ No newline at end of file diff --git a/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl b/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl new file mode 100644 index 0000000..6d30d29 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl @@ -0,0 +1,19 @@ +/* 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/. */ +package commonapi.performance.primitive + +interface TestInterface { + version { major 1 minor 0 } + + method testMethod { + in { + TestArray x + } + out { + TestArray y + } + } + + array TestArray of UInt8 +}
\ No newline at end of file diff --git a/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl b/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl new file mode 100644 index 0000000..100f086 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl @@ -0,0 +1,11 @@ +/* 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/. */ +package commonapi.runtime + +interface TestInterface { + version { major 1 minor 0 } + + method testMethod { + } +}
\ No newline at end of file diff --git a/org.genivi.commonapi.core.verification/fidl/ti_stability_mp.fidl b/org.genivi.commonapi.core.verification/fidl/ti_stability_mp.fidl new file mode 100644 index 0000000..0b89dcb --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_stability_mp.fidl @@ -0,0 +1,46 @@ +/* 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/. */ +package commonapi.stability.mp + +interface TestInterface { + version { major 1 minor 0 } + + attribute tArray testAttribute + + method testMethod { + in { + tArray x + } + out { + tArray y + } + } + + broadcast testBroadcast { + out { + tArray y + } + } + + array tArray of UInt8 +} + +interface ControlInterface { + version { major 1 minor 0 } + method controlMethod { + in { + UInt8 id + UInt32 data + } + out { + UInt8 command + UInt32 data1 + UInt32 data2 + } + } + + +} + + diff --git a/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl b/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl new file mode 100644 index 0000000..144186a --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl @@ -0,0 +1,28 @@ +/* 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/. */ +package commonapi.stability.sp + +interface TestInterface { + version { major 1 minor 0 } + + attribute tArray testAttribute + + method testMethod { + in { + tArray x + } + out { + tArray y + } + } + + broadcast testBroadcast { + out { + tArray y + } + } + + array tArray of UInt8 +} + diff --git a/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl b/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl new file mode 100644 index 0000000..2e829a4 --- /dev/null +++ b/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl @@ -0,0 +1,23 @@ +/* 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/. */ +package commonapi.threading + +interface TestInterface { + version { major 1 minor 0 } + + method testMethod { + in { + UInt8 x + } + out { + UInt8 y + } + } + + broadcast testBroadcast { + out { + UInt8 y + } + } +}
\ No newline at end of file diff --git a/org.genivi.commonapi.core.verification/m4/.gitignore b/org.genivi.commonapi.core.verification/m4/.gitignore deleted file mode 100644 index 764b428..0000000 --- a/org.genivi.commonapi.core.verification/m4/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/libtool.m4 -/lt~obsolete.m4 -/ltoptions.m4 -/ltsugar.m4 -/ltversion.m4 diff --git a/org.genivi.commonapi.core.verification/m4/ax_cxx_compile_stdcxx_11.m4 b/org.genivi.commonapi.core.verification/m4/ax_cxx_compile_stdcxx_11.m4 deleted file mode 100644 index 0d96c07..0000000 --- a/org.genivi.commonapi.core.verification/m4/ax_cxx_compile_stdcxx_11.m4 +++ /dev/null @@ -1,107 +0,0 @@ -# ============================================================================ -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html -# ============================================================================ -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX_11([ext|noext]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the C++11 -# standard; if necessary, add switches to CXXFLAGS to enable support. -# Errors out if no mode that supports C++11 baseline syntax can be found. -# The argument, if specified, indicates whether you insist on an extended -# mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -std=c++11). -# If neither is specified, you get whatever works, with preference for an -# extended mode. -# -# LICENSE -# -# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> -# Copyright (c) 2012 Zack Weinberg <zackw@panix.com> -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [ - template <typename T> - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - typedef check<check<bool>> right_angle_brackets; - - int a; - decltype(a) b; - - typedef check<int> check_type; - check_type c; - check_type&& cr = static_cast<check_type&&>(c); -]) - -AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl - m4_if([$1], [], [], - [$1], [ext], [], - [$1], [noext], [], - [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl - AC_LANG_ASSERT([C++])dnl - ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++11 features by default, - ax_cv_cxx_compile_cxx11, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], - [ax_cv_cxx_compile_cxx11=yes], - [ax_cv_cxx_compile_cxx11=no])]) - if test x$ax_cv_cxx_compile_cxx11 = xyes; then - ac_success=yes - fi - - m4_if([$1], [noext], [], [dnl - if test x$ac_success = xno; then - for switch in -std=gnu++11 -std=gnu++0x; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, - $cachevar, - [ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXXFLAGS="$ac_save_CXXFLAGS"]) - if eval test x\$$cachevar = xyes; then - CXXFLAGS="$CXXFLAGS $switch" - ac_success=yes - break - fi - done - fi]) - - m4_if([$1], [ext], [], [dnl - if test x$ac_success = xno; then - for switch in -std=c++11 -std=c++0x; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, - $cachevar, - [ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXXFLAGS="$ac_save_CXXFLAGS"]) - if eval test x\$$cachevar = xyes; then - CXXFLAGS="$CXXFLAGS $switch" - ac_success=yes - break - fi - done - fi]) - - if test x$ac_success = xno; then - AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) - fi -]) diff --git a/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp b/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp new file mode 100644 index 0000000..b4af088 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp @@ -0,0 +1,401 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** + * @file Communication + */ + +#include <functional> +#include <fstream> +#include <deque> +#include <mutex> +#include <condition_variable> +#include <thread> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "v1_0/commonapi/communication/TestInterfaceProxy.hpp" +#include "v1_0/commonapi/communication/TestInterfaceStubDefault.hpp" + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.communication.TestInterface"; + +const unsigned int wt = 500000; + +typedef std::shared_ptr<v1_0::commonapi::communication::TestInterfaceProxy<>> ProxyPtr; + +std::mutex mut; +std::deque<uint32_t> data_queue; +std::condition_variable data_cond; + +class SubscriptionHandler { + +public: + + SubscriptionHandler(ProxyPtr pp) : myProxy_(pp) { + availabilityStatus_ = CommonAPI::AvailabilityStatus::UNKNOWN; + callbackTestAttribute_ = std::bind(&SubscriptionHandler::myCallback, this, std::placeholders::_1); + subscriptionStarted_ = false; + testAttribute_ = 0; + } + + void receiveServiceAvailable(CommonAPI::AvailabilityStatus as) { + + availabilityStatus_ = as; + + if (as == CommonAPI::AvailabilityStatus::AVAILABLE) { + + startSubscribe(); + + } else if (as == CommonAPI::AvailabilityStatus::NOT_AVAILABLE) { + + cancelSubscribe(); + } + } + + void myCallback(const uint8_t& val) { + + testAttribute_ = val; + myQueue_.push_back(val); + + /* for test purposes, magic value 99 unsubscribes the attribute. */ + if (val == 99) { + cancelSubscribe(); + } + } + + void startSubscribe() { + if (!subscriptionStarted_) { + subscribedListener_ = + myProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackTestAttribute_); + subscriptionStarted_ = true; + } + } + + void cancelSubscribe() { + if (subscriptionStarted_) { + myProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListener_); + subscriptionStarted_ = false; + } + } + + CommonAPI::AvailabilityStatus getAvailabilityStatus() { + return availabilityStatus_; + } + + + uint8_t getSubscriptedTestAttribute() { + return testAttribute_; + } + + std::deque<uint8_t> myQueue_; + +private: + + bool subscriptionStarted_; + uint8_t testAttribute_; + ProxyPtr myProxy_; + + CommonAPI::AvailabilityStatus availabilityStatus_; + CommonAPI::Event<uint8_t>::Subscription subscribedListener_; + + std::function<void(const uint8_t&)> callbackTestAttribute_; +}; + +void testSubscription(ProxyPtr pp) { + + SubscriptionHandler subscriptionHandler(pp); + + std::function<void(CommonAPI::AvailabilityStatus)> callbackAvailabilityStatus = + std::bind(&SubscriptionHandler::receiveServiceAvailable, &subscriptionHandler, std::placeholders::_1); + + pp->getProxyStatusEvent().subscribe(callbackAvailabilityStatus); + + int cnt = 0; + while (!(subscriptionHandler.getSubscriptedTestAttribute() > 0 + && subscriptionHandler.getAvailabilityStatus() + == CommonAPI::AvailabilityStatus::NOT_AVAILABLE) + && cnt < 1000) { + usleep(10000); + cnt++; + } + + std::lock_guard < std::mutex > lk(mut); + data_queue.push_back(subscriptionHandler.getSubscriptedTestAttribute()); + data_cond.notify_one(); +} + +class CMAttributeSubscription: public ::testing::Test { + +protected: + void SetUp() { + + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + + testProxy_ = runtime_->buildProxy<v1_0::commonapi::communication::TestInterfaceProxy>(domain, testAddress, clientId); + ASSERT_TRUE((bool)testProxy_); + + testStub_ = std::make_shared<v1_0::commonapi::communication::TestInterfaceStubDefault>(); + } + + void TearDown() { + } + + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<v1_0::commonapi::communication::TestInterfaceProxy<>> testProxy_; + std::shared_ptr<v1_0::commonapi::communication::TestInterfaceStubDefault> testStub_; +}; + +class Environment: public ::testing::Environment { + +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } + +private: +}; + +/** + * @test Subscription standard test. + * - Register service and check if proxy is available. + * - Proxy subscribes for TestAttribute (uint8_t). + * - Change attribute in service several times by set method. + * - Callback function in proxy writes the received values in a queue. + * - Check if values in the queue are the same as the values that were set in the service. + * - Unregister test service. + */ +TEST_F(CMAttributeSubscription, SubscriptionStandard) { + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + + for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { + usleep(10000); + } + ASSERT_TRUE(testProxy_->isAvailable()); + + SubscriptionHandler subscriptionHandler(testProxy_); + std::function<void (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1); + //CommonAPI::Event<uint8_t>::Subscription subscribedListener = + testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback); + + const uint8_t testNumber = 10; + for (uint8_t i=1; i<testNumber+1; i++) { + testStub_->setTestAttributeAttribute(i); + } + + usleep(wt); + ASSERT_EQ(subscriptionHandler.myQueue_.size(), testNumber); + + uint8_t t = 1; + for(std::deque<uint8_t>::iterator it = subscriptionHandler.myQueue_.begin(); it != subscriptionHandler.myQueue_.end(); ++it) { + EXPECT_EQ(*it, t); + t++; + } + runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); +} + +/** + * @test Subscription test with subscription on available-event. + * - Subscribe for available-event. + * - Available-callback subscribes for TestPredefinedTypeAttribute if service is available for proxy and + * unsubscribes if service is not available for proxy. + * - Change attribute in service by set method; the new attribute value should be received by the proxy because the service is not registered. + * - Register service and change value again; the value should now be received. + * - Unregister and change value again. + */ +TEST_F(CMAttributeSubscription, SubscriptionOnAvailable) { + + SubscriptionHandler subscriptionHandler(testProxy_); + + std::function<void (CommonAPI::AvailabilityStatus)> callbackAvailabilityStatus = std::bind(&SubscriptionHandler::receiveServiceAvailable, &subscriptionHandler, std::placeholders::_1); + testProxy_->getProxyStatusEvent().subscribe(callbackAvailabilityStatus); + + testStub_->setTestAttributeAttribute(1); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 0); + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + usleep(wt); + testStub_->setTestAttributeAttribute(2); + usleep(wt); + ASSERT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 2); + + bool serviceUnregistered = runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(serviceUnregistered); + usleep(wt); + ASSERT_EQ(subscriptionHandler.getAvailabilityStatus(), CommonAPI::AvailabilityStatus::NOT_AVAILABLE); + + testStub_->setTestAttributeAttribute(3); + usleep(wt); + ASSERT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 2); +} + +/** + * @test Subscription test with several threads. + * - Start several threads. + * - The threads subscribe for the availability status. + * - The available-callback subscribes for TestAttribute if service is available for proxy and + * - unsubscribes if service is not available for proxy. + * - Change attribute in service by set method; the new attribute value should be received by all the threads. + * - The new value is written into a queue. + * - Check if the values of each thread are written into the queue. + */ +TEST_F(CMAttributeSubscription, SubscriptionMultithreading) { + + std::thread t0(testSubscription, testProxy_); + std::thread t1(testSubscription, testProxy_); + std::thread t2(testSubscription, testProxy_); + std::thread t3(testSubscription, testProxy_); + std::thread t4(testSubscription, testProxy_); + std::thread t5(testSubscription, testProxy_); + std::thread t6(testSubscription, testProxy_); + std::thread t7(testSubscription, testProxy_); + std::thread t8(testSubscription, testProxy_); + std::thread t9(testSubscription, testProxy_); + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + + usleep(wt); + testStub_->setTestAttributeAttribute(1); + + usleep(wt); + + bool serviceUnregistered = runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(serviceUnregistered); + + uint32_t data = 0; + unsigned int cnt = 0; + while (cnt<10) { + + std::unique_lock<std::mutex> lk(mut); + data_cond.wait_for(lk, std::chrono::milliseconds(2000), [] {return !data_queue.empty();}); + + if ( !data_queue.empty() ) { + data = data_queue.front(); + data_queue.pop_front(); + } + lk.unlock(); + EXPECT_EQ(static_cast<int32_t>(data), 1); + cnt++; + } + + t0.join(); + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + t6.join(); + t7.join(); + t8.join(); + t9.join(); +} + +/** + * @test Subscription test for cancellable callbacks. + * - Register service and check if proxy is available. + * - Proxy subscribes for TestAttribute (uint8_t) with the subscribeCancellableListener method. + * - Change attribute in service by set method. + * - Check if callback function in proxy received the right value. + * - Set desired subscription status to CANCEL. + * - Change value again; the callback should be called again but with return value CommonAPI::SubscriptionStatus::CANCEL. + * - Change value again; the callback should now be called anymore. + * - Unregister the test service. + */ +/* this test is no longer valid for CommonAPI 3.0. + +TEST_F(CMAttributeSubscription, SubscriptionCancellable) { + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_); + ASSERT_TRUE(serviceRegistered); + + for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { + usleep(10000); + } + ASSERT_TRUE(testProxy_->isAvailable()); + + SubscriptionHandler subscriptionHandler(testProxy_); + + std::function<CommonAPI::SubscriptionStatus (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1); + testProxy_->getTestAttributeAttribute().getChangedEvent().subscribeCancellableListener(myCallback); + subscriptionHandler.setSubscriptionStatus(CommonAPI::SubscriptionStatus::RETAIN); + + testStub_->setTestAttributeAttribute(42); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 42); + + subscriptionHandler.setSubscriptionStatus(CommonAPI::SubscriptionStatus::CANCEL); + + testStub_->setTestAttributeAttribute(99); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); + + testStub_->setTestAttributeAttribute(250); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); + + runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); +} +*/ +/** + * @test Subscription test : unsibscribe from the subscription callback. + * - Register service and check if proxy is available. + * - Proxy subscribes for TestAttribute (uint8_t). + * - Change attribute in service by set method. + * - Check if callback function in proxy received the right value. + * - Change value to the magic value 99: this triggers the callback to unsubscribe. + * - Change value again; the callback should now be called anymore. + * - Unregister the test service. + */ + +TEST_F(CMAttributeSubscription, SubscriptionUnsubscribeFromCallback) { + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + + for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { + usleep(10000); + } + ASSERT_TRUE(testProxy_->isAvailable()); + + SubscriptionHandler subscriptionHandler(testProxy_); + + std::function<void (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1); + subscriptionHandler.startSubscribe(); + + testStub_->setTestAttributeAttribute(42); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 42); + + testStub_->setTestAttributeAttribute(99); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); + + testStub_->setTestAttributeAttribute(250); + usleep(wt); + EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); + + runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/CMAttributes.cpp b/org.genivi.commonapi.core.verification/src/CMAttributes.cpp new file mode 100644 index 0000000..b577770 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/CMAttributes.cpp @@ -0,0 +1,271 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file Communication +*/ + +#include <functional> +#include <condition_variable> +#include <mutex> +#include <thread> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "v1_0/commonapi/communication/TestInterfaceProxy.hpp" +#include "stub/CMAttributesStub.h" + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.communication.TestInterface"; +const int tasync = 100000; + +using namespace v1_0::commonapi::communication; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class CMAttributes: public ::testing::Test { + +public: + void recvValue(const CommonAPI::CallStatus& callStatus, uint8_t y) { + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + value_ = y; + } + + void recvSubscribedValue(uint8_t y) { + value_ = y; + } + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + std::mutex availabilityMutex; + std::unique_lock<std::mutex> lock(availabilityMutex); + std::condition_variable cv; + bool proxyAvailable = false; + + std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() { + testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId); + testProxy_->isAvailableBlocking(); + std::lock_guard<std::mutex> lock(availabilityMutex); + ASSERT_TRUE((bool)testProxy_); + proxyAvailable = true; + cv.notify_one(); + }); + testStub_ = std::make_shared<CMAttributesStub>(); + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + + while(!proxyAvailable) { + cv.wait(lock); + } + t1.join(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + bool serviceUnregistered = + runtime_->unregisterService(domain, CMAttributesStub::StubInterface::getInterface(), + testAddress); + + ASSERT_TRUE(serviceUnregistered); + } + + uint8_t value_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + std::shared_ptr<CMAttributesStub> testStub_; + std::shared_ptr<TestInterfaceProxy<>> testProxy_; +}; + +/** +* @test Test synchronous getValue API function for attributes with combinations of +* additional properties readonly and noSubscriptions (testAttribute, +* testA readonly, testB noSubscriptions, testC readonly noSubscriptions). +* - Set attribute to certain value on stub side. +* - Call getValue. +* - Check if returned call status is CommonAPI::CallStatus::SUCCESS. +* - Check if value of is equal to expected value. +*/ +TEST_F(CMAttributes, AttributeGetSynchronous) { + + CommonAPI::CallStatus callStatus; + + uint8_t x = 5; + uint8_t y = 0; + testStub_->setTestValues(x); + testProxy_->getTestAttributeAttribute().getValue(callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + + x = 6; + y = 0; + testStub_->setTestValues(x); + testProxy_->getTestAAttribute().getValue(callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + + x = 7; + y = 0; + testStub_->setTestValues(x); + testProxy_->getTestBAttribute().getValue(callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + + x = 8; + y = 0; + testStub_->setTestValues(x); + testProxy_->getTestCAttribute().getValue(callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + +} + +/** +* @test Test asynchronous getValue API function for attributes with combinations of +* additional properties readonly and noSubscriptions (testAttribute, +* testA readonly, testB noSubscriptions, testC readonly noSubscriptions). +* - Set attribute to certain value on stub side. +* - Call getValue. +* - Check if returned call status is CommonAPI::CallStatus::SUCCESS. +* - Check if value of is equal to expected value. +*/ +TEST_F(CMAttributes, AttributeGetAsynchronous) { + + CommonAPI::CallStatus callStatus; + std::function<void (const CommonAPI::CallStatus&, uint8_t)> myCallback = + std::bind(&CMAttributes::recvValue, this, std::placeholders::_1, std::placeholders::_2); + + uint8_t x = 5; + testStub_->setTestValues(x); + testProxy_->getTestAttributeAttribute().getValueAsync(myCallback); + usleep(100000); + EXPECT_EQ(x, value_); + + x = 6; + value_ = x; + testStub_->setTestValues(x); + testProxy_->getTestAttributeAttribute().getValueAsync(myCallback); + usleep(100000); + EXPECT_EQ(x, value_); + + x = 7; + value_ = x; + testStub_->setTestValues(x); + testProxy_->getTestAttributeAttribute().getValueAsync(myCallback); + usleep(100000); + EXPECT_EQ(x, value_); + + x = 8; + value_ = x; + testStub_->setTestValues(x); + testProxy_->getTestAttributeAttribute().getValueAsync(myCallback); + usleep(100000); + EXPECT_EQ(x, value_); +} + +/** +* @test Test synchronous setValue API function for attributes with combinations of +* additional properties readonly and noSubscriptions (testAttribute, testB noSubscriptions) +* - Set attribute to certain value on proxy side. +* - Check if returned call status is CommonAPI::CallStatus::SUCCESS. +* - Check if returned value of setValue is equal to expected value. +*/ +TEST_F(CMAttributes, AttributeSetSynchronous) { + + CommonAPI::CallStatus callStatus; + + uint8_t x = 5; + uint8_t y = 0; + testProxy_->getTestAttributeAttribute().setValue(x, callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + + x = 6; + y = 0; + testProxy_->getTestBAttribute().setValue(x, callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + +} + +/** +* @test Test asynchronous setValue API function for attributes with combinations of +* additional properties readonly and noSubscriptions (testAttribute, testB noSubscriptions). +* - Set attribute to certain value on proxy side. +* - Check if returned call status is CommonAPI::CallStatus::SUCCESS. +* - Check if returned value of setValue is equal to expected value. +*/ +TEST_F(CMAttributes, AttributeSetAsynchronous) { + + CommonAPI::CallStatus callStatus; + std::function<void (const CommonAPI::CallStatus&, uint8_t)> myCallback = + std::bind(&CMAttributes::recvValue, this, std::placeholders::_1, std::placeholders::_2); + + testStub_->setTestValues(0); + + uint8_t x = 5; + testProxy_->getTestAttributeAttribute().setValueAsync(x, myCallback); + usleep(100000); + EXPECT_EQ(x, value_); + + x = 6; + testProxy_->getTestBAttribute().setValueAsync(x, myCallback); + usleep(100000); + EXPECT_EQ(x, value_); +} + +/** +* @test Test subscription API function for attributes +* +* - Subscribe on testAttribute. +* - Set attribute to certain value on stub side. +* - Do checks of call status (CommonAPI::CallStatus::SUCCESS) and returned value in callback function. +* - Checks if returned value of setValue is equal to expected value. +* - Set attribute to certain value with synchronous call from proxy. +* - Check again. +*/ +TEST_F(CMAttributes, AttributeSubscription) { + + CommonAPI::CallStatus callStatus; + std::function<void (uint8_t)> myCallback = + std::bind(&CMAttributes::recvSubscribedValue, this, std::placeholders::_1); + + testStub_->setTestValues(0); + + uint8_t y = 0; + uint8_t x = 5; + + value_ = 0; + + testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback); + testStub_->setTestValues(x); + usleep(100000); + EXPECT_EQ(x, value_); + + x = 6; + testProxy_->getTestAttributeAttribute().setValue(x, callStatus, y); + usleep(100000); + EXPECT_EQ(x, value_); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp b/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp new file mode 100644 index 0000000..e3ac255 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp @@ -0,0 +1,116 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file Communication +*/ + +#include <functional> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "v1_0/commonapi/communication/TestInterfaceProxy.hpp" +#include "stub/CMMethodCallsStub.h" + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.communication.TestInterface"; +const int tasync = 100000; + +using namespace v1_0::commonapi::communication; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class CMMethodCalls: public ::testing::Test { + +public: + void recvValue(const CommonAPI::CallStatus& callStatus, uint8_t y) { + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + value_ = y; + } + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + + testStub_ = std::make_shared<CMMethodCallsStub>(); + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + + testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId); + ASSERT_TRUE((bool)testProxy_); + + testProxy_->isAvailableBlocking(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + runtime_->unregisterService(domain, CMMethodCallsStub::StubInterface::getInterface(), testAddress); + } + + uint8_t value_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + std::shared_ptr<TestInterfaceStub> testStub_; + std::shared_ptr<TestInterfaceProxy<>> testProxy_; +}; + +/** +* @test Call test method synchronous and check call status. +* - Test stub sets in-value of test method equal out-value of test method. +* - Make synchronous call of test method. +* - Check if returned call status is CommonAPI::CallStatus::SUCCESS. +* - Check if out value of test method is equal to in value. +*/ +TEST_F(CMMethodCalls, SynchronousMethodCall) { + + uint8_t x = 5; + uint8_t y = 0; + CommonAPI::CallStatus callStatus; + testProxy_->testMethod(x, callStatus, y); + + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); + +} + +/** +* @test Call test method asynchronous and check call status. +* - Test stub sets in-value of test method equal out-value of test method. +* - Make asynchronous call of test method. +* - Do checks of call status (CommonAPI::CallStatus::SUCCESS) and returned value in callback function. +*/ +TEST_F(CMMethodCalls, AsynchronousMethodCall) { + + uint8_t x = 5; + uint8_t y = 0; + CommonAPI::CallStatus callStatus; + + std::function<void (const CommonAPI::CallStatus&, uint8_t)> myCallback = + std::bind(&CMMethodCalls::recvValue, this, std::placeholders::_1, std::placeholders::_2); + + testProxy_->testMethodAsync(x, myCallback); + usleep(tasync); + EXPECT_EQ(x, value_); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in b/org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in deleted file mode 100644 index f20300d..0000000 --- a/org.genivi.commonapi.core.verification/src/CommunicationVerification.cpp.in +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 2013 BMW Group - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) - * Author: Juergen Gehring (juergen.gehring@bmw.de) - * 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/. */ - -/** -* @file Communication -*/ - -#include <functional> -#include <fstream> -#include <gtest/gtest.h> -#include "CommonAPI/CommonAPI.h" -#include "utils/VerificationMainLoop.h" -#include "commonapi/tests/TestInterfaceProxy.h" -#include "utils/VerificationTestStub.h" - -const std::string testAddress = "local:my.test:commonapi.address"; - -const std::string configString = - "{binding:@BINDING_NAME@}\n" - "libpath=@BINDING_SO@\n" - "alias=TestAlias\n" - "genpath=@GLUECODE_SO@\n" - "default" -; - -const std::string COMMONAPI_CONFIG_SUFFIX = ".conf"; - - - -class Environment: public ::testing::Environment { -public: - virtual ~Environment() { - } - - virtual void SetUp() { - configFileName_ = CommonAPI::getCurrentBinaryFileFQN(); - configFileName_ += COMMONAPI_CONFIG_SUFFIX; - std::ofstream configFile(configFileName_); - ASSERT_TRUE(configFile.is_open()); - configFile << configString; - configFile.close(); - } - - virtual void TearDown() { - std::remove(configFileName_.c_str()); - } - - std::string configFileName_; -}; - - - - -class CommunicationTest: public ::testing::Test { - -protected: - void SetUp() { - runtime_ = CommonAPI::Runtime::load(); - ASSERT_TRUE((bool)runtime_); - - proxyFactory_ = runtime_->createFactory(); - ASSERT_TRUE((bool)proxyFactory_); - stubFactory_ = runtime_->createFactory(); - ASSERT_TRUE((bool)stubFactory_); - - servicePublisher_ = runtime_->getServicePublisher(); - ASSERT_TRUE((bool)servicePublisher_); - } - - void TearDown() { - usleep(30000); - } - - std::string configFileName_; - std::shared_ptr<CommonAPI::Runtime> runtime_; - std::shared_ptr<CommonAPI::Factory> proxyFactory_; - std::shared_ptr<CommonAPI::Factory> stubFactory_; - std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher_; -}; - -/** -* @test Builds proxy, registers service, checks if proxy is available, calls test method, checks call status, unregisters service. -* - Calls proxyFactory_->buildProxy(...) and checks if return value is true. -* - Calls servicePublisher_->registerService(...) and checks if return value is true (max. 100 tries every 10 ms). -* - Checks if proxy is available (max. 100 tries every 10 ms). -* - Calls test method and checks if returned call status is CommonAPI::CallStatus::SUCCESS. -* - Unregisters the test service. -*/ -TEST_F(CommunicationTest, RemoteMethodCallSucceeds) { - auto defaultTestProxy = proxyFactory_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress); - ASSERT_TRUE((bool)defaultTestProxy); - - auto stub = std::make_shared<commonapi::tests::TestInterfaceStubDefault>(); - - bool serviceRegistered = servicePublisher_->registerService(stub, testAddress, stubFactory_); - for(unsigned int i = 0; !serviceRegistered && i < 100; ++i) { - serviceRegistered = servicePublisher_->registerService(stub, testAddress, stubFactory_); - usleep(10000); - } - ASSERT_TRUE(serviceRegistered); - - for(unsigned int i = 0; !defaultTestProxy->isAvailable() && i < 100; ++i) { - usleep(10000); - } - ASSERT_TRUE(defaultTestProxy->isAvailable()); - - uint32_t v1 = 5; - std::string v2 = "Ciao ;)"; - CommonAPI::CallStatus stat; - defaultTestProxy->testVoidPredefinedTypeMethod(v1, v2, stat); - - EXPECT_EQ(stat, CommonAPI::CallStatus::SUCCESS); - - servicePublisher_->unregisterService(testAddress); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(new Environment()); - return RUN_ALL_TESTS(); -} diff --git a/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp b/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp new file mode 100644 index 0000000..52b6451 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp @@ -0,0 +1,300 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file DataTypes +*/ + +#include <functional> +#include <condition_variable> +#include <mutex> +#include <thread> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +#include "v1_0/commonapi/datatypes/advanced/TestInterfaceProxy.hpp" +#include "stub/DTAdvancedStub.h" + +const std::string domain = "local"; +const std::string testAddress = "commonapi.datatypes.advanced.TestInterface"; +const std::string connectionIdService = "service-sample"; +const std::string connectionIdClient = "client-sample"; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class DTAdvanced: public ::testing::Test { + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + std::mutex availabilityMutex; + std::unique_lock<std::mutex> lock(availabilityMutex); + std::condition_variable cv; + bool proxyAvailable = false; + + std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() { + testProxy_ = runtime_->buildProxy<v1_0::commonapi::datatypes::advanced::TestInterfaceProxy>(domain, testAddress, connectionIdClient); + testProxy_->isAvailableBlocking(); + std::lock_guard<std::mutex> lock(availabilityMutex); + ASSERT_TRUE((bool)testProxy_); + proxyAvailable = true; + cv.notify_one(); + }); + + testStub_ = std::make_shared<v1_0::commonapi::datatypes::advanced::DTAdvancedStub>(); + serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, connectionIdService); + ASSERT_TRUE(serviceRegistered_); + + while(!proxyAvailable) { + cv.wait(lock); + } + t1.join(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + ASSERT_TRUE(runtime_->unregisterService(domain, v1_0::commonapi::datatypes::advanced::DTAdvancedStub::StubInterface::getInterface(), testAddress)); + } + + bool received_; + bool serviceRegistered_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<v1_0::commonapi::datatypes::advanced::TestInterfaceProxy<>> testProxy_; + std::shared_ptr<v1_0::commonapi::datatypes::advanced::DTAdvancedStub> testStub_; +}; + +/* +* @test Test function call with advanced types +* - Advanced types are: arrays, enumerations, structs, unions, maps, typedefs +* - Function call of a function that has for each advanced type one argument (test values) and one return value +* - The stub copies the test values to the return values +* - On client side the test values are compared with the return values +*/ +TEST_F(DTAdvanced, SendAndReceive) { + + CommonAPI::CallStatus callStatus; + + v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefTestValue; + + arrayTestValue.push_back("Test1"); + arrayTestValue.push_back("Test2"); + arrayTestValue.push_back("Test3"); + + enumerationTestValue = v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::VALUE2; + + structTestValue.setBooleanMember(true); + structTestValue.setUint8Member(42); + structTestValue.setStringMember("Hello World"); + + uint8_t u = 53; + unionTestValue = u; + + mapTestValue[1] = "Hello"; + mapTestValue[2] = "World"; + + typedefTestValue = 64; + + v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefResultValue; + + testProxy_->fTest( + arrayTestValue, + enumerationTestValue, + structTestValue, + unionTestValue, + mapTestValue, + typedefTestValue, + callStatus, + arrayResultValue, + enumerationResultValue, + structResultValue, + unionResultValue, + mapResultValue, + typedefResultValue + ); + + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(arrayTestValue, arrayResultValue); + EXPECT_EQ(enumerationTestValue, enumerationResultValue); + EXPECT_EQ(structTestValue, structResultValue); + EXPECT_EQ(unionTestValue, unionResultValue); + EXPECT_EQ(mapTestValue, mapResultValue); + EXPECT_EQ(typedefTestValue, typedefResultValue); +} + +/** +* @test Test attribute functions with advanced types +* - Call set function of attributes with advanced types +* - Call get function and check if the return value is the same +*/ +TEST_F(DTAdvanced, AttributeSet) { + + CommonAPI::CallStatus callStatus; + + v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefTestValue; + + arrayTestValue.push_back("Test1"); + arrayTestValue.push_back("Test2"); + arrayTestValue.push_back("Test3"); + + enumerationTestValue = v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::VALUE2; + + structTestValue.setBooleanMember(true); + structTestValue.setUint8Member(42); + structTestValue.setStringMember("Hello World"); + + uint8_t u = 53; + unionTestValue = u; + + mapTestValue[1] = "Hello"; + mapTestValue[2] = "World"; + + typedefTestValue = 64; + + v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefResultValue; + + testProxy_->getAArrayAttribute().setValue(arrayTestValue, callStatus, arrayResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(arrayTestValue, arrayResultValue); + + testProxy_->getAEnumerationAttribute().setValue(enumerationTestValue, callStatus, enumerationResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(enumerationTestValue, enumerationResultValue); + + testProxy_->getAStructAttribute().setValue(structTestValue, callStatus, structResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(structTestValue, structResultValue); + + testProxy_->getAUnionAttribute().setValue(unionTestValue, callStatus, unionResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(unionTestValue, unionResultValue); + + testProxy_->getAMapAttribute().setValue(mapTestValue, callStatus, mapResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(mapTestValue, mapResultValue); + + testProxy_->getATypedefAttribute().setValue(typedefTestValue, callStatus, typedefResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(typedefTestValue, typedefResultValue); +} + +/** +* @test Test broadcast with advanced types +* - Subscribe to broadcast which contains advanced types +* - Call function to cause the stub to fire broadcast event with the same content +* - Check if the values in the callback function are as expected +*/ +TEST_F(DTAdvanced, BroadcastReceive) { + + CommonAPI::CallStatus callStatus; + + v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapTestValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefTestValue; + + arrayTestValue.push_back("Test1"); + arrayTestValue.push_back("Test2"); + arrayTestValue.push_back("Test3"); + + enumerationTestValue = v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::VALUE2; + + structTestValue.setBooleanMember(true); + structTestValue.setUint8Member(42); + structTestValue.setStringMember("Hello World"); + + uint8_t u = 53; + unionTestValue = u; + + mapTestValue[1] = "Hello"; + mapTestValue[2] = "World"; + + typedefTestValue = 64; + + v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapResultValue; + v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefResultValue; + + received_ = false; + testProxy_->getBTestEvent().subscribe([&]( + const v1_0::commonapi::datatypes::advanced::TestInterface::tArray& arrayResultValue, + const v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration& enumerationResultValue, + const v1_0::commonapi::datatypes::advanced::TestInterface::tStruct& structResultValue, + const v1_0::commonapi::datatypes::advanced::TestInterface::tUnion& unionResultValue, + const v1_0::commonapi::datatypes::advanced::TestInterface::tMap& mapResultValue, + const v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef& typedefResultValue + ) { + received_ = true; + EXPECT_EQ(arrayTestValue, arrayResultValue); + EXPECT_EQ(enumerationTestValue, enumerationResultValue); + EXPECT_EQ(structTestValue, structResultValue); + EXPECT_EQ(unionTestValue, unionResultValue); + EXPECT_EQ(mapTestValue, mapResultValue); + EXPECT_EQ(typedefTestValue, typedefResultValue); + }); + + testProxy_->fTest( + arrayTestValue, + enumerationTestValue, + structTestValue, + unionTestValue, + mapTestValue, + typedefTestValue, + callStatus, + arrayResultValue, + enumerationResultValue, + structResultValue, + unionResultValue, + mapResultValue, + typedefResultValue + ); + + usleep(100000); + ASSERT_TRUE(received_); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/DTCombined.cpp b/org.genivi.commonapi.core.verification/src/DTCombined.cpp new file mode 100644 index 0000000..08eead6 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/DTCombined.cpp @@ -0,0 +1,232 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file DataTypes +*/ + +#include <functional> +#include <condition_variable> +#include <mutex> +#include <thread> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +#include "v1_0/commonapi/datatypes/combined/TestInterfaceProxy.hpp" +#include "stub/DTCombinedStub.h" + +const std::string domain = "local"; +const std::string testAddress = "commonapi.datatypes.combined.TestInterface"; +const std::string connectionIdService = "service-sample"; +const std::string connectionIdClient = "client-sample"; + +using namespace v1_0::commonapi::datatypes::combined; + +class DTCombinedStub : public TestInterfaceStubDefault { + +public: + DTCombinedStub() {}; + virtual ~DTCombinedStub() {}; + + void fTest(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tStructL3 tStructL3In, + TestInterface::tStructL3& tStructL3Out) { + + tStructL3Out = tStructL3In; + } + +}; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + + } + + virtual void TearDown() { + } +}; + +class DTCombined: public ::testing::Test { + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + std::mutex availabilityMutex; + std::unique_lock<std::mutex> lock(availabilityMutex); + std::condition_variable cv; + bool proxyAvailable = false; + + std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() { + testProxy_ = runtime_->buildProxy<v1_0::commonapi::datatypes::combined::TestInterfaceProxy>(domain, testAddress, connectionIdClient); + testProxy_->isAvailableBlocking(); + std::lock_guard<std::mutex> lock(availabilityMutex); + ASSERT_TRUE((bool)testProxy_); + proxyAvailable = true; + cv.notify_one(); + }); + + testStub_ = std::make_shared<v1_0::commonapi::datatypes::combined::DTCombinedStub>(); + serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, connectionIdService); + ASSERT_TRUE(serviceRegistered_); + + while(!proxyAvailable) { + cv.wait(lock); + } + t1.join(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + ASSERT_TRUE(runtime_->unregisterService(domain, v1_0::commonapi::datatypes::combined::TestInterfaceStub::StubInterface::getInterface(), testAddress)); + } + + bool serviceRegistered_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<v1_0::commonapi::datatypes::combined::TestInterfaceProxy<>> testProxy_; + std::shared_ptr<v1_0::commonapi::datatypes::combined::DTCombinedStub> testStub_; +}; + +/** +* @test Test function call with combined type +* - The combined type is one structure with combinations of advanced and primitive types +* - Function call of a function that has for each advanced type one argument (test values) and one return value +* - The stub copies the test values to the return values +* - On client side the test values are compared with the return values +*/ +TEST_F(DTCombined, SendAndReceive) { + + CommonAPI::CallStatus callStatus; + + // TestValue is TV; start with Level0 + TestInterface::tEnum enumTV0 = TestInterface::tEnum::VALUE1; + TestInterface::tEnum enumTV1 = TestInterface::tEnum::VALUE2; + TestInterface::tArray arrayTV0 = {"Test1", "Test2", "Test3"}; + TestInterface::tArray arrayTV1 = {"Test4", "Test5", "Test6"}; + TestInterface::tArray arrayTV2 = {"Test7", "Test8", "Test9"}; + TestInterface::tStruct structTV0 = {true, 42, "Hello World", TestInterface::tEnum::VALUE1}; + TestInterface::tStruct structTV1 = {false, 53, "ABC", TestInterface::tEnum::VALUE2}; + TestInterface::tUnion unionTV0 = true; + TestInterface::tUnion unionTV1 = (uint8_t)42; + TestInterface::tUnion unionTV2 = std::string("Hello World"); + TestInterface::tUnion unionTV3 = TestInterface::tEnum::VALUE1; + TestInterface::tMap mapTV0 = {{1, "Hello"}, {2, "World"}}; + TestInterface::tMap mapTV1 = {{123, "ABC"}, {456, "DEF"}}; + + // Level1 + TestInterface::tArrayEnum arrayEnumTV0 = {enumTV0, enumTV1, enumTV0}; + TestInterface::tArrayEnum arrayEnumTV1 = {enumTV1, enumTV0, enumTV1}; + TestInterface::tArrayEnum arrayEnumTV2 = {enumTV0, enumTV0, enumTV0}; + TestInterface::tArrayArray arrayArrayTV0 = {arrayTV0, arrayTV1, arrayTV2}; + TestInterface::tArrayArray arrayArrayTV1 = {arrayTV1, arrayTV2}; + TestInterface::tArrayStruct arrayStructTV0 = {structTV0, structTV0}; + TestInterface::tArrayStruct arrayStructTV1 = {structTV1, structTV1}; + TestInterface::tArrayStruct arrayStructTV2 = {structTV0, structTV1}; + TestInterface::tArrayStruct arrayStructTV3 = {structTV1, structTV0}; + TestInterface::tArrayUnion arrayUnionTV0 = {unionTV0, unionTV1, unionTV2, unionTV3}; + TestInterface::tArrayMap arrayMapTV0 = {mapTV0, mapTV1}; + TestInterface::tArrayMap arrayMapTV1 = {mapTV1, mapTV0}; + + TestInterface::tStructL1 structL1TV0 = {enumTV0, arrayTV0, structTV0, unionTV0, mapTV0}; + TestInterface::tStructL1 structL1TV1 = {enumTV1, arrayTV1, structTV1, unionTV1, mapTV1}; + + TestInterface::tUnionL1 unionL1TV0 = enumTV0; + TestInterface::tUnionL1 unionL1TV1 = arrayTV0; + TestInterface::tUnionL1 unionL1TV2 = structTV0; + TestInterface::tUnionL1 unionL1TV3 = unionTV0; + TestInterface::tUnionL1 unionL1TV4 = mapTV0; + + TestInterface::tMapEnum mapEnumTV0 = {{1, TestInterface::tEnum::VALUE1}, {2, TestInterface::tEnum::VALUE2}}; + TestInterface::tMapEnum mapEnumTV1 = {{123, TestInterface::tEnum::VALUE2}, {456, TestInterface::tEnum::VALUE1}}; + TestInterface::tMapArray mapArrayTV0 = {{123456789, arrayTV0}, {987654321, arrayTV1}}; + TestInterface::tMapStruct mapStructTV0 = {{"Hello", structTV0}}; + TestInterface::tMapStruct mapStructTV1 = {{"Hello", structTV0}, {"World", structTV1}}; + TestInterface::tMapStruct mapStructTV2 = {{"Hello", structTV0}, {"World", structTV1}, {"JG", structTV0}}; + TestInterface::tMapUnion mapUnionTV0 = {{1.23456789, unionTV2}, {9.87654321, unionTV3}}; + TestInterface::tMapUnion mapUnionTV1 = {{3.123, unionTV0}, {0.111111, unionTV1}}; + TestInterface::tMapMap mapMapTV0 = {{-1, mapTV0}, {-2, mapTV1}}; + + + // Level2 + TestInterface::tArrayArrayEnum arrayArrayEnumTV = {arrayEnumTV0, arrayEnumTV1, arrayEnumTV2}; + TestInterface::tArrayArrayArray arrayArrayArrayTV = {arrayArrayTV0, arrayArrayTV1}; + TestInterface::tArrayArrayStruct arrayArrayStructTV = {arrayStructTV0, arrayStructTV1, arrayStructTV2, arrayStructTV3}; + TestInterface::tArrayArrayUnion arrayArrayUnionTV = {arrayUnionTV0}; + TestInterface::tArrayArrayMap arrayArrayMapTV = {arrayMapTV0, arrayMapTV1}; + TestInterface::tArrayStructL1 arrayStructL1TV = {structL1TV0, structL1TV1}; + TestInterface::tArrayUnionL1 arrayUnionL1TV = {unionL1TV0, unionL1TV1, unionL1TV2, unionL1TV3, unionL1TV4}; + TestInterface::tArrayMapEnum arrayMapEnumTV = {mapEnumTV0, mapEnumTV1}; + TestInterface::tArrayMapArray arrayMapArrayTV = {mapArrayTV0}; + TestInterface::tArrayMapStruct arrayMapStructTV = {mapStructTV0, mapStructTV1, mapStructTV2}; + TestInterface::tArrayMapUnion arrayMapUnionTV = {mapUnionTV0, mapUnionTV1}; + TestInterface::tArrayMapMap arrayMapMapTV = {mapMapTV0}; + + TestInterface::tStructL2 structL2TV = {arrayEnumTV0, arrayArrayTV0, arrayStructTV0, arrayUnionTV0, arrayMapTV0, + structL1TV0, unionL1TV0, mapEnumTV0, mapArrayTV0, mapStructTV0, mapUnionTV0, mapMapTV0}; + + //TestInterface::tUnionL2 unionL2TV = arrayEnumTV0; + + TestInterface::tMapArrayEnum mapArrayEnumTV = {{"A", arrayEnumTV0}, {"B", arrayEnumTV1}, {"C", arrayEnumTV1}}; + TestInterface::tMapArrayArray mapArrayArrayTV = {{"ABCDEFGHIJK", arrayArrayTV0}, {"LMNOPQRST", arrayArrayTV1}}; + TestInterface::tMapArrayStruct mapArrayStructTV = {{"Z", arrayStructTV3}, {"Y", arrayStructTV2}, {"X", arrayStructTV1}, {"W", arrayStructTV0}}; + TestInterface::tMapArrayUnion mapArrayUnionTV = {{"JG", arrayUnionTV0}}; + TestInterface::tMapArrayMap mapArrayMapTV = {{"0x1", arrayMapTV0}, {"0x2", arrayMapTV0}}; + TestInterface::tMapStructL1 mapStructL1TV = {{"Hello", structL1TV0}, {"World", structL1TV1}}; + TestInterface::tMapUnionL1 mapUnionL1TV = {{"A", unionL1TV0}, {"B", unionL1TV1}, {"C", unionL1TV2}, {"D", unionL1TV3}, {"E", unionL1TV4}}; + TestInterface::tMapMapEnum mapMapEnumTV = {{"Hello", mapEnumTV0}, {"World", mapEnumTV1}}; + TestInterface::tMapMapArray mapMapArrayTV = {{"JG", mapArrayTV0}}; + TestInterface::tMapMapStruct mapMapStructTV = {{"AA", mapStructTV0}, {"BB", mapStructTV1}, {"CC", mapStructTV2}}; + TestInterface::tMapMapUnion mapMapUnionTV = {{"Hello", mapUnionTV0}, {"World", mapUnionTV1}}; + TestInterface::tMapMapMap mapMapMapTV = {{"ABCDEFGHI", mapMapTV0}}; + + TestInterface::tStructL3 tStructL3TV = { + arrayArrayEnumTV, + arrayArrayArrayTV, + arrayArrayStructTV, + arrayArrayUnionTV, + arrayArrayMapTV, + arrayStructL1TV, + //arrayUnionL1TV, + //arrayMapEnumTV, + //arrayMapArrayTV, + //arrayMapStructTV, + //arrayMapUnionTV, + //arrayMapMapTV, + structL2TV, + //tUnionL2TV, + mapArrayEnumTV, + mapArrayArrayTV, + mapArrayStructTV, + mapArrayUnionTV, + mapArrayMapTV, + //mapStructL1TV, + mapUnionL1TV, + mapMapEnumTV, + mapMapArrayTV, + mapMapStructTV, + mapMapUnionTV, + mapMapMapTV + }; + + TestInterface::tStructL3 tStructL3RV; + + testProxy_->fTest(tStructL3TV, callStatus, tStructL3RV); + + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(tStructL3TV, tStructL3RV); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/DTDerived.cpp b/org.genivi.commonapi.core.verification/src/DTDerived.cpp new file mode 100644 index 0000000..bbb1785 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/DTDerived.cpp @@ -0,0 +1,259 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file DataTypes +*/ + +#include <functional> +#include <condition_variable> +#include <mutex> +#include <thread> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +#include "v1_0/commonapi/datatypes/derived/TestInterfaceProxy.hpp" +#include "stub/DTDerivedStub.h" + +const std::string domain = "local"; +const std::string testAddress = "commonapi.datatypes.derived.TestInterface"; +const std::string connectionId_client = "client-sample"; +const std::string connectionId_service = "service-sample"; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class DTDerived: public ::testing::Test { + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + std::mutex availabilityMutex; + std::unique_lock<std::mutex> lock(availabilityMutex); + std::condition_variable cv; + bool proxyAvailable = false; + + std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() { + testProxy_ = runtime_->buildProxy<v1_0::commonapi::datatypes::derived::TestInterfaceProxy>(domain, testAddress, connectionId_client); + testProxy_->isAvailableBlocking(); + std::lock_guard<std::mutex> lock(availabilityMutex); + ASSERT_TRUE((bool)testProxy_); + proxyAvailable = true; + cv.notify_one(); + }); + + testStub_ = std::make_shared<v1_0::commonapi::datatypes::derived::DTDerivedStub>(); + serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, connectionId_service); + ASSERT_TRUE(serviceRegistered_); + + while(!proxyAvailable) { + cv.wait(lock); + } + t1.join(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + runtime_->unregisterService(domain, v1_0::commonapi::datatypes::derived::DTDerivedStub::StubInterface::getInterface(), testAddress); + } + + bool received_; + bool serviceRegistered_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterfaceProxy<>> testProxy_; + std::shared_ptr<v1_0::commonapi::datatypes::derived::DTDerivedStub> testStub_; + +}; + +/* +* @test Test function call with derived types +* - Derived types are: extended struct, extended enumeration, extended union, polymorphic struct +* - Function call of a function that has for each derived type one argument (test values) and one return value +* - The stub copies the test values to the return values +* - On client side the test values are compared with the return values +*/ +TEST_F(DTDerived, SendAndReceive) { + + CommonAPI::CallStatus callStatus; + + v1_0::commonapi::datatypes::derived::TestInterface::tStructExt structExtTestValue; + v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt enumExtTestValue; + v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt unionExtTestValue; + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct> baseStructTestValue; + + structExtTestValue.setBaseMember(42); + structExtTestValue.setExtendedMember("Hello World"); + + enumExtTestValue = v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt::VALUE2; + + std::string u = "Hello World"; + unionExtTestValue = u; + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct> l_two = std::make_shared<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct>(); + l_two->setName("ABC"); + baseStructTestValue = l_two; + + v1_0::commonapi::datatypes::derived::TestInterface::tStructExt structExtResultValue; + v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt enumExtResultValue; + v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt unionExtResultValue; + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct> baseStructResultValue; + + testProxy_->fTest( + structExtTestValue, + enumExtTestValue, + unionExtTestValue, + baseStructTestValue, + callStatus, + structExtResultValue, + enumExtResultValue, + unionExtResultValue, + baseStructResultValue + ); + + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(structExtTestValue, structExtResultValue); + EXPECT_EQ(enumExtTestValue, enumExtResultValue); + EXPECT_EQ(unionExtTestValue, unionExtResultValue); + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct> l_twoResult = + std::dynamic_pointer_cast<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct>(baseStructResultValue); + EXPECT_EQ(l_twoResult->getName(), "ABC"); +} + +/** +* @test Test attribute functions with derived types +* - Call set function of attributes with derived types +* - Call get function and check if the return value is the same +*/ +TEST_F(DTDerived, AttributeSet) { + + CommonAPI::CallStatus callStatus; + + v1_0::commonapi::datatypes::derived::TestInterface::tStructExt structExtTestValue; + v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt enumExtTestValue; + v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt unionExtTestValue; + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct> baseStructTestValue; + + structExtTestValue.setBaseMember(42); + structExtTestValue.setExtendedMember("Hello World"); + + enumExtTestValue = v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt::VALUE2; + + std::string u = "Hello World"; + unionExtTestValue = u; + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct> l_two = std::make_shared<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct>(); + l_two->setName("ABC"); + baseStructTestValue = l_two; + + v1_0::commonapi::datatypes::derived::TestInterface::tStructExt structExtResultValue; + v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt enumExtResultValue; + v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt unionExtResultValue; + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct> baseStructResultValue; + + testProxy_->getAStructExtAttribute().setValue(structExtTestValue, callStatus, structExtResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(structExtTestValue, structExtResultValue); + + testProxy_->getAEnumExtAttribute().setValue(enumExtTestValue, callStatus, enumExtResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(enumExtTestValue, enumExtResultValue); + + testProxy_->getAUnionExtAttribute().setValue(unionExtTestValue, callStatus, unionExtResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(unionExtTestValue, unionExtResultValue); + + testProxy_->getABaseStructAttribute().setValue(baseStructTestValue, callStatus, baseStructResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct> l_twoResult = + std::dynamic_pointer_cast<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct>(baseStructResultValue); + EXPECT_EQ(l_twoResult->getName(), "ABC"); + +} + +/** +* @test Test broadcast with derived types +* - Subscribe to broadcast which contains derived types +* - Call function to cause the stub to fire broadcast event with the same content +* - Check if the values in the callback function are as expected +*/ +TEST_F(DTDerived, BroadcastReceive) { + + CommonAPI::CallStatus callStatus; + + v1_0::commonapi::datatypes::derived::TestInterface::tStructExt structExtTestValue; + v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt enumExtTestValue; + v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt unionExtTestValue; + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct> baseStructTestValue; + + structExtTestValue.setBaseMember(42); + structExtTestValue.setExtendedMember("Hello World"); + + enumExtTestValue = v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt::VALUE2; + + std::string u = "Hello World"; + unionExtTestValue = u; + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct> l_two = std::make_shared<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct>(); + l_two->setName("ABC"); + baseStructTestValue = l_two; + + v1_0::commonapi::datatypes::derived::TestInterface::tStructExt structExtResultValue; + v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt enumExtResultValue; + v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt unionExtResultValue; + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct> baseStructResultValue; + + received_ = false; + testProxy_->getBTestEvent().subscribe([&]( + const v1_0::commonapi::datatypes::derived::TestInterface::tStructExt& structExtResultValue, + const v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt& enumExtResultValue, + const v1_0::commonapi::datatypes::derived::TestInterface::tUnionExt& unionExtResultValue, + const std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseStruct>& baseStructResultValue + ) { + received_ = true; + EXPECT_EQ(structExtTestValue, structExtResultValue); + EXPECT_EQ(enumExtTestValue, enumExtResultValue); + EXPECT_EQ(unionExtTestValue, unionExtResultValue); + + std::shared_ptr<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct> l_twoResult = + std::dynamic_pointer_cast<v1_0::commonapi::datatypes::derived::TestInterface::tBaseTwoStruct>(baseStructResultValue); + EXPECT_EQ(l_twoResult->getName(), "ABC"); + }); + + testProxy_->fTest( + structExtTestValue, + enumExtTestValue, + unionExtTestValue, + baseStructTestValue, + callStatus, + structExtResultValue, + enumExtResultValue, + unionExtResultValue, + baseStructResultValue + ); + + usleep(100000); + ASSERT_TRUE(received_); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp b/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp new file mode 100644 index 0000000..3091b3f --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp @@ -0,0 +1,355 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file DataTypes +*/ + +#include <functional> +#include <condition_variable> +#include <mutex> +#include <thread> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +#include "v1_0/commonapi/datatypes/primitive/TestInterfaceProxy.hpp" +#include "stub/DTPrimitiveStub.h" + +const std::string domain = "local"; +const std::string testAddress = "commonapi.datatypes.primitive.TestInterface"; +const std::string connectionIdService = "service-sample"; +const std::string connectionIdClient = "client-sample"; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class DTPrimitive: public ::testing::Test { + +protected: + void SetUp() { + + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + std::mutex availabilityMutex; + std::unique_lock<std::mutex> lock(availabilityMutex); + std::condition_variable cv; + bool proxyAvailable = false; + + std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() { + testProxy_ = runtime_->buildProxy<v1_0::commonapi::datatypes::primitive::TestInterfaceProxy>(domain, testAddress, connectionIdClient); + testProxy_->isAvailableBlocking(); + std::lock_guard<std::mutex> lock(availabilityMutex); + ASSERT_TRUE((bool)testProxy_); + proxyAvailable = true; + cv.notify_one(); + }); + testStub_ = std::make_shared<v1_0::commonapi::datatypes::primitive::DTPrimitiveStub>(); + serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, connectionIdService); + ASSERT_TRUE(serviceRegistered_); + + while(!proxyAvailable) { + cv.wait(lock); + } + t1.join(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + ASSERT_TRUE(runtime_->unregisterService(domain, v1_0::commonapi::datatypes::primitive::DTPrimitiveStub::StubInterface::getInterface(), testAddress)); + } + + bool received_; + bool serviceRegistered_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<v1_0::commonapi::datatypes::primitive::TestInterfaceProxy<>> testProxy_; + std::shared_ptr<v1_0::commonapi::datatypes::primitive::DTPrimitiveStub> testStub_; +}; + +/** +* @test Test function call with primitive types +* - Primitive types are: uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, bool, float, double, std::string, ByteBuffer +* - Function call of a function that has for each primitive type one argument (test values) and one return value +* - The stub copies the test values to the return values +* - On client side the test values are compared with the return values +*/ +TEST_F(DTPrimitive, SendAndReceive) { + + CommonAPI::CallStatus callStatus; + + uint8_t uint8TestValue = +101; + int8_t int8TestValue = -101; + uint16_t uint16TestValue = +40004; + int16_t int16TestValue = -5005; + uint32_t uint32TestValue = +1000000001; + int32_t int32TestValue = -20002; + uint64_t uint64TestValue = +4000000000000000004; + int64_t int64TestValue = -5000000005; + bool booleanTestValue = true; + float floatTestValue = 1.01; + double doubleTestValue = 12345.12345; + std::string stringTestValue = "∃y ∀x ¬(x ≺ y)"; + //ByteBuffer byteBufferTestValue + + uint8_t uint8ResultValue = 0; + int8_t int8ResultValue = 0; + uint16_t uint16ResultValue = 0; + int16_t int16ResultValue = 0; + uint32_t uint32ResultValue = 0; + int32_t int32ResultValue = 0; + uint64_t uint64ResultValue = 0; + int64_t int64ResultValue = 0; + bool booleanResultValue = false; + float floatResultValue = 0.0; + double doubleResultValue = 0; + std::string stringResultValue = ""; + //ByteBuffer byteBufferTestValue + + testProxy_->fTest( + uint8TestValue, + int8TestValue, + uint16TestValue, + int16TestValue, + uint32TestValue, + int32TestValue, + uint64TestValue, + int64TestValue, + booleanTestValue, + floatTestValue, + doubleTestValue, + stringTestValue, + callStatus, + uint8ResultValue, + int8ResultValue, + uint16ResultValue, + int16ResultValue, + uint32ResultValue, + int32ResultValue, + uint64ResultValue, + int64ResultValue, + booleanResultValue, + floatResultValue, + doubleResultValue, + stringResultValue + ); + + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + EXPECT_EQ(uint8TestValue, uint8ResultValue); + EXPECT_EQ(int8TestValue, int8ResultValue); + EXPECT_EQ(uint16TestValue, uint16ResultValue); + EXPECT_EQ(int16TestValue, int16ResultValue); + EXPECT_EQ(uint32TestValue, uint32ResultValue); + EXPECT_EQ(int32TestValue, int32ResultValue); + EXPECT_EQ(uint64TestValue, uint64ResultValue); + EXPECT_EQ(int64TestValue, int64ResultValue); + EXPECT_EQ(booleanTestValue, booleanResultValue); + EXPECT_EQ(floatTestValue, floatResultValue); + EXPECT_EQ(doubleTestValue, doubleResultValue); + EXPECT_EQ(stringTestValue, stringResultValue); +} + +/** +* @test Test attribute functions with primitive types +* - Call set function of attributes with primitive types +* - Call get function and check if the return value is the same +*/ +TEST_F(DTPrimitive, AttributeSet) { + + CommonAPI::CallStatus callStatus; + + uint8_t uint8TestValue = +101; + int8_t int8TestValue = -101; + uint16_t uint16TestValue = +40004; + int16_t int16TestValue = -5005; + uint32_t uint32TestValue = +1000000001; + int32_t int32TestValue = -20002; + uint64_t uint64TestValue = +4000000000000000004; + int64_t int64TestValue = -5000000005; + bool booleanTestValue = true; + float floatTestValue = 1.01; + double doubleTestValue = 12345.12345; + std::string stringTestValue = "∃y ∀x ¬(x ≺ y)"; + //ByteBuffer byteBufferTestValue + + uint8_t uint8ResultValue = 0; + int8_t int8ResultValue = 0; + uint16_t uint16ResultValue = 0; + int16_t int16ResultValue = 0; + uint32_t uint32ResultValue = 0; + int32_t int32ResultValue = 0; + uint64_t uint64ResultValue = 0; + int64_t int64ResultValue = 0; + bool booleanResultValue = false; + float floatResultValue = 0.0; + double doubleResultValue = 0; + std::string stringResultValue = ""; + //ByteBuffer byteBufferTestValue + + testProxy_->getAUint8Attribute().setValue(uint8TestValue, callStatus, uint8ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(uint8TestValue, uint8ResultValue); + + testProxy_->getAInt8Attribute().setValue(int8TestValue, callStatus, int8ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(int8TestValue, int8ResultValue); + + testProxy_->getAUint16Attribute().setValue(uint16TestValue, callStatus, uint16ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(uint16TestValue, uint16ResultValue); + + testProxy_->getAInt16Attribute().setValue(int16TestValue, callStatus, int16ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(int16TestValue, int16ResultValue); + + testProxy_->getAUint32Attribute().setValue(uint32TestValue, callStatus, uint32ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(uint32TestValue, uint32ResultValue); + + testProxy_->getAInt32Attribute().setValue(int32TestValue, callStatus, int32ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(int32TestValue, int32ResultValue); + + testProxy_->getAUint64Attribute().setValue(uint64TestValue, callStatus, uint64ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(uint64TestValue, uint64ResultValue); + + testProxy_->getAInt64Attribute().setValue(int64TestValue, callStatus, int64ResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(int64TestValue, int64ResultValue); + + testProxy_->getABooleanAttribute().setValue(booleanTestValue, callStatus, booleanResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(booleanTestValue, booleanResultValue); + + testProxy_->getAFloatAttribute().setValue(floatTestValue, callStatus, floatResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(floatTestValue, floatResultValue); + + testProxy_->getADoubleAttribute().setValue(doubleTestValue, callStatus, doubleResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(doubleTestValue, doubleResultValue); + + testProxy_->getAStringAttribute().setValue(stringTestValue, callStatus, stringResultValue); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(stringTestValue, stringResultValue); +} + +/** +* @test Test broadcast with primitive types +* - Subscribe to broadcast which contains primitive types +* - Call function to cause the stub to fire broadcast event with the same content +* - Check if the values in the callback function are as expected +*/ +TEST_F(DTPrimitive, BroadcastReceive) { + + CommonAPI::CallStatus callStatus; + + uint8_t uint8TestValue = +101; + int8_t int8TestValue = -101; + uint16_t uint16TestValue = +40004; + int16_t int16TestValue = -5005; + uint32_t uint32TestValue = +1000000001; + int32_t int32TestValue = -20002; + uint64_t uint64TestValue = +4000000000000000004; + int64_t int64TestValue = -5000000005; + bool booleanTestValue = true; + float floatTestValue = 1.01; + double doubleTestValue = 12345.12345; + std::string stringTestValue = "∃y ∀x ¬(x ≺ y)"; + //ByteBuffer byteBufferTestValue + + uint8_t uint8ResultValue = 0; + int8_t int8ResultValue = 0; + uint16_t uint16ResultValue = 0; + int16_t int16ResultValue = 0; + uint32_t uint32ResultValue = 0; + int32_t int32ResultValue = 0; + uint64_t uint64ResultValue = 0; + int64_t int64ResultValue = 0; + bool booleanResultValue = false; + float floatResultValue = 0.0; + double doubleResultValue = 0; + std::string stringResultValue = ""; + //ByteBuffer byteBufferTestValue + + received_ = false; + testProxy_->getBTestEvent().subscribe([&]( + const uint8_t& uint8ResultValue, + const int8_t& int8ResultValue, + const uint16_t& uint16ResultValue, + const int16_t& int16ResultValue, + const uint32_t& uint32ResultValue, + const int32_t& int32ResultValue, + const uint64_t& uint64ResultValue, + const int64_t& int64ResultValue, + const bool& booleanResultValue, + const float& floatResultValue, + const double& doubleResultValue, + const std::string& stringResultValue + ) { + received_ = true; + EXPECT_EQ(uint8TestValue, uint8ResultValue); + EXPECT_EQ(int8TestValue, int8ResultValue); + EXPECT_EQ(uint16TestValue, uint16ResultValue); + EXPECT_EQ(int16TestValue, int16ResultValue); + EXPECT_EQ(uint32TestValue, uint32ResultValue); + EXPECT_EQ(int32TestValue, int32ResultValue); + EXPECT_EQ(uint64TestValue, uint64ResultValue); + EXPECT_EQ(int64TestValue, int64ResultValue); + EXPECT_EQ(booleanTestValue, booleanResultValue); + EXPECT_EQ(floatTestValue, floatResultValue); + EXPECT_EQ(doubleTestValue, doubleResultValue); + EXPECT_EQ(stringTestValue, stringResultValue); + }); + + testProxy_->fTest( + uint8TestValue, + int8TestValue, + uint16TestValue, + int16TestValue, + uint32TestValue, + int32TestValue, + uint64TestValue, + int64TestValue, + booleanTestValue, + floatTestValue, + doubleTestValue, + stringTestValue, + callStatus, + uint8ResultValue, + int8ResultValue, + uint16ResultValue, + int16ResultValue, + uint32ResultValue, + int32ResultValue, + uint64ResultValue, + int64ResultValue, + booleanResultValue, + floatResultValue, + doubleResultValue, + stringResultValue + ); + + usleep(100000); + ASSERT_TRUE(received_); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/DynamicLoadingVerification.cpp.in b/org.genivi.commonapi.core.verification/src/DynamicLoadingVerification.cpp.in deleted file mode 100644 index a39b544..0000000 --- a/org.genivi.commonapi.core.verification/src/DynamicLoadingVerification.cpp.in +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (C) 2013 BMW Group - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) - * Author: Juergen Gehring (juergen.gehring@bmw.de) - * 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/. */ - -/** -* @file Dynamic Loading -*/ - -#include <functional> -#include <fstream> -#include <gtest/gtest.h> -#include "CommonAPI/CommonAPI.h" -#include "utils/VerificationMainLoop.h" -#include "commonapi/tests/TestInterfaceProxy.h" -#include "utils/VerificationTestStub.h" - -const std::string testAddress = "local:my.test:commonapi.address"; - -const std::string configString = - "{binding:@BINDING_NAME@}\n" - "libpath=@BINDING_SO@\n" - "alias=TestAlias\n" - "genpath=@GLUECODE_SO@\n" - "default" -; - -const std::string COMMONAPI_CONFIG_SUFFIX = ".conf"; - -class Environment: public ::testing::Environment { -public: - virtual ~Environment() { - } - - virtual void SetUp() { - configFileName_ = CommonAPI::getCurrentBinaryFileFQN(); - configFileName_ += COMMONAPI_CONFIG_SUFFIX; - std::ofstream configFile(configFileName_); - ASSERT_TRUE(configFile.is_open()); - configFile << configString; - configFile.close(); - } - - virtual void TearDown() { - std::remove(configFileName_.c_str()); - } - - std::string configFileName_; -}; - -class DynamicLoadingTest: public ::testing::Test { - -protected: - void SetUp() { - } - - void TearDown() { - } - - std::string configFileName_; -}; - -/** -* @test Loads Default Runtime. -* - Calls CommonAPI::Runtime::load(). -* - Success if return value is true. -*/ -TEST_F(DynamicLoadingTest, LoadsDefaultRuntime) { - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load(); - ASSERT_TRUE((bool)runtime); -} - -/** -* @test Loads Runtime By Binding Name. -* - Calls CommonAPI::Runtime::load("@BINDING_NAME@"). -* - Success if return value is true. -*/ -TEST_F(DynamicLoadingTest, LoadsRuntimeByBindingName) { - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load("@BINDING_NAME@"); - ASSERT_TRUE((bool)runtime); -} - -/** -* @test Loads Runtime By Alias. -* - Calls CommonAPI::Runtime::load("TestAlias"). -* - Success if return value is true. -*/ -TEST_F(DynamicLoadingTest, LoadsRuntimeByAlias) { - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load("TestAlias"); - ASSERT_TRUE((bool)runtime); -} - -/** -* @test Loads Runtime and creates facory. -* - Calls CommonAPI::Runtime::load("TestAlias") and checks if return value is true. -* - Calls runtime->createFactory(). -* - Success if return value is true. -*/ -TEST_F(DynamicLoadingTest, LoadedRuntimeCanCreateFactory) { - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load("TestAlias"); - ASSERT_TRUE((bool)runtime); - - std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory(); - ASSERT_TRUE((bool)factory); -} - -/** -* @test Loads Runtime, creates facory and checks if proxies and stubs can be built. -* - Calls CommonAPI::Runtime::load("TestAlias") and checks if return value is true. -* - Calls runtime->createFactory() for proxy and checks if return value is true. -* - Calls runtime->createFactory() for stub and checks if return value is true. -* - Checks if test proxy with test address can be created. -* - Calls runtime->getServicePublisher() checks if return value is true. -* - Checks if test stub with test address can be created. -* - Unregisters the test service. -*/ -TEST_F(DynamicLoadingTest, LoadedRuntimeCanBuildProxiesAndStubs) { - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load("TestAlias"); - ASSERT_TRUE((bool)runtime); - - std::shared_ptr<CommonAPI::Factory> factoryProxy = runtime->createFactory(); - ASSERT_TRUE((bool)factoryProxy); - - std::shared_ptr<CommonAPI::Factory> factoryStub = runtime->createFactory(); - ASSERT_TRUE((bool)factoryStub); - - auto proxy = factoryProxy->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress); - ASSERT_TRUE((bool)proxy); - - auto servicePublisher = runtime->getServicePublisher(); - ASSERT_TRUE((bool) servicePublisher); - - auto stub = std::make_shared<commonapi::verification::VerificationTestStub>(); - ASSERT_TRUE(servicePublisher->registerService(stub, testAddress, factoryStub)); - - servicePublisher->unregisterService(testAddress); - sleep(2); -} - -/** -* @test Loads Runtime, creates facory, if proxies and stubs can be built and checks if they can communicate. -* - Calls CommonAPI::Runtime::load("TestAlias") and checks if return value is true. -* - Calls runtime->createFactory() for proxy and checks if return value is true. -* - Calls runtime->createFactory() for stub and checks if return value is true. -* - Checks if test proxy with test address can be created. -* - Calls runtime->getServicePublisher() checks if return value is true. -* - Checks if test stub with test address can be created. -* - Checks isAvailable flag of proxy. -* - Unregisters the test service. -*/ -TEST_F(DynamicLoadingTest, LoadedRuntimeCanBuildProxiesAndStubsThatCommunicate) { - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load("TestAlias"); - ASSERT_TRUE((bool)runtime); - - std::shared_ptr<CommonAPI::Factory> factoryProxy = runtime->createFactory(); - ASSERT_TRUE((bool)factoryProxy); - - std::shared_ptr<CommonAPI::Factory> factoryStub = runtime->createFactory(); - ASSERT_TRUE((bool)factoryStub); - - auto proxy = factoryProxy->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress); - ASSERT_TRUE((bool)proxy); - - auto servicePublisher = runtime->getServicePublisher(); - ASSERT_TRUE((bool) servicePublisher); - - auto stub = std::make_shared<commonapi::verification::VerificationTestStub>(); - ASSERT_TRUE(servicePublisher->registerService(stub, testAddress, factoryStub)); - - CommonAPI::CallStatus callStatus; - std::string outString; - uint32_t outInt = 0; - - for(int i=0; i<10; i++) - { - if(proxy->isAvailable()) { - break; - } - usleep(50); - } - - ASSERT_TRUE(proxy->isAvailable()); - - proxy->testPredefinedTypeMethod(0, "", callStatus, outInt, outString); - ASSERT_EQ(1, outInt); - - servicePublisher->unregisterService(testAddress); - sleep(2); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(new Environment()); - return RUN_ALL_TESTS(); -} diff --git a/org.genivi.commonapi.core.verification/src/MainLoopVerification.cpp b/org.genivi.commonapi.core.verification/src/MainLoopVerification.cpp deleted file mode 100644 index 4f28cde..0000000 --- a/org.genivi.commonapi.core.verification/src/MainLoopVerification.cpp +++ /dev/null @@ -1,496 +0,0 @@ -/* Copyright (C) 2013 BMW Group - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) - * Author: Juergen Gehring (juergen.gehring@bmw.de) - * 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/. */ - -/** -* @file Main Loop Integration -*/ - -#include <gtest/gtest.h> -#include "CommonAPI/CommonAPI.h" -#include "utils/VerificationMainLoop.h" -#include "commonapi/tests/TestInterfaceProxy.h" -#include "utils/VerificationTestStub.h" -#include <functional> - -const std::string testAddress6 = "local:my.eigth.test:commonapi.address.six"; -const std::string testAddress7 = "local:my.eigth.test:commonapi.address.seven"; -const std::string testAddress8 = "local:my.eigth.test:commonapi.address.eight"; - -class PingPongTestStub : public commonapi::tests::TestInterfaceStubDefault { - virtual void testPredefinedTypeMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, - uint32_t uint32InValue, - std::string stringInValue, - uint32_t& uint32OutValue, - std::string& stringOutValue) { - stringOutValue = stringInValue; - uint32OutValue = uint32InValue; - } -}; - -class MainLoopTest: public ::testing::Test { - -protected: - void SetUp() { - - runtime_ = CommonAPI::Runtime::load(); - ASSERT_TRUE((bool) runtime_); - - contextForProxy_ = runtime_->getNewMainLoopContext(); - contextForStub_ = runtime_->getNewMainLoopContext(); - ASSERT_TRUE((bool) contextForProxy_); - ASSERT_TRUE((bool) contextForStub_); - ASSERT_FALSE(contextForProxy_ == contextForStub_); - - mainLoopForProxy_ = new CommonAPI::VerificationMainLoop(contextForProxy_); - mainLoopForStub_ = new CommonAPI::VerificationMainLoop(contextForStub_); - - mainloopFactoryProxy_ = runtime_->createFactory(contextForProxy_); - mainloopFactoryStub_ = runtime_->createFactory(contextForStub_); - ASSERT_TRUE((bool) mainloopFactoryProxy_); - ASSERT_TRUE((bool) mainloopFactoryStub_); - ASSERT_FALSE(mainloopFactoryProxy_ == mainloopFactoryStub_); - - servicePublisher_ = runtime_->getServicePublisher(); - ASSERT_TRUE((bool) servicePublisher_); - - stub_ = std::make_shared<commonapi::verification::VerificationTestStub>(); - ASSERT_TRUE(servicePublisher_->registerService(stub_, testAddress8, mainloopFactoryStub_)); - - callbackCalled = 0; - lastBroadcastNumber = 0; - outInt = 0; - } - - void TearDown() { - servicePublisher_->unregisterService(testAddress8); - mainLoopForProxy_->stop(); - mainLoopForStub_->stop(); - usleep(200); - delete mainLoopForProxy_; - delete mainLoopForStub_; - } - - std::shared_ptr<CommonAPI::Runtime> runtime_; - - std::shared_ptr<CommonAPI::MainLoopContext> contextForProxy_; - std::shared_ptr<CommonAPI::MainLoopContext> contextForStub_; - std::shared_ptr<CommonAPI::Factory> mainloopFactoryProxy_; - std::shared_ptr<CommonAPI::Factory> mainloopFactoryStub_; - std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher_; - std::shared_ptr<commonapi::verification::VerificationTestStub> stub_; - - CommonAPI::VerificationMainLoop* mainLoopForProxy_; - CommonAPI::VerificationMainLoop* mainLoopForStub_; - - int callbackCalled; - int lastBroadcastNumber; - uint32_t outInt; - CommonAPI::CallStatus callStatus; - -public: - void broadcastCallback(uint32_t intValue, std::string stringValue) { - // check correct order - lastBroadcastNumber++; - ASSERT_EQ(lastBroadcastNumber, intValue); - // check, if broadcast is handled after method call - ASSERT_EQ(outInt, 1); - } -}; - -/** -* @test Verifies Transport Reading When Dispatching Watches. -* - get proxy with available flag = true -* - generate big test data -* - send asynchronous test message -* - dispatch dispatchSource: the message must not be arrived -* - dispatch watches (reads transport). -* - dispatch dispatchSources again: now the message must be arrived. -*/ -TEST_F(MainLoopTest, VerifyTransportReadingWhenDispatchingWatches) { - auto proxy = mainloopFactoryProxy_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress8); - ASSERT_TRUE((bool) proxy); - - std::thread stubThread = std::thread([&](){ mainLoopForStub_->run(); }); - - while (!proxy->isAvailable()) { - mainLoopForProxy_->doSingleIteration(); - usleep(500); - } - - ASSERT_TRUE(proxy->isAvailable()); - - mainLoopForStub_->stop(); - stubThread.join(); - - uint32_t uint32Value = 42; - std::string stringValue = "Hai :)"; - bool running = true; - - commonapi::tests::DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue = - commonapi::tests::DerivedTypeCollection::TestEnumExtended2::E_OK; - commonapi::tests::DerivedTypeCollection::TestMap testMapInValue; - - // Estimated amount of data (differring padding at beginning/end of Map/Array etc. not taken into account): - // 4 + 4 + 500 * (4 + (4 + 4 + 100 * (11 + 1 + 4)) + 4 ) = 811008 - for (uint32_t i = 0; i < 500; ++i) { - commonapi::tests::DerivedTypeCollection::TestArrayTestStruct testArrayTestStruct; - for (uint32_t j = 0; j < 100; ++j) { - commonapi::tests::DerivedTypeCollection::TestStruct testStruct("Hai all (:", j); - testArrayTestStruct.push_back(testStruct); - } - testMapInValue.insert( {i, testArrayTestStruct}); - } - - std::future<CommonAPI::CallStatus> futureStatus = - proxy->testDerivedTypeMethodAsync( - testEnumExtended2InValue, - testMapInValue, - [&] (const CommonAPI::CallStatus& status, - commonapi::tests::DerivedTypeCollection::TestEnumExtended2 testEnumExtended2OutValue, - commonapi::tests::DerivedTypeCollection::TestMap testMapOutValue) { - mainLoopForProxy_->stop(); - callbackCalled++; - } - ); - - mainLoopForProxy_->runVerification(15, true, true); - - // 1. just dispatch dispatchSources - mainLoopForStub_->runVerification(15, false, true); - EXPECT_EQ(stub_->getCalledTestDerivedTypeMethod(), 0); - - // 2. just dispatch watches (reads transport) - mainLoopForStub_->runVerification(20, true, false); - EXPECT_EQ(stub_->getCalledTestDerivedTypeMethod(), 0); - - // 3. just dispatch dispatchSources again. This should dispatch the messages already read from transport in 2. - mainLoopForStub_->doVerificationIteration(false, true); - EXPECT_EQ(stub_->getCalledTestDerivedTypeMethod(), 1); -} - -/** -* @test Verifies Synchronous Call Message Handling Order. -* - get proxy with available flag = true -* - subscribe for broadcast event -* - generate 5 test broadcasts -* - 5 broadcasts should arrive in the right order -*/ -TEST_F(MainLoopTest, VerifySyncCallMessageHandlingOrder) { - auto proxy = mainloopFactoryProxy_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress8); - ASSERT_TRUE((bool) proxy); - - std::thread stubThread = std::thread([&](){ mainLoopForStub_->run(); }); - - while (!proxy->isAvailable()) { - mainLoopForProxy_->doSingleIteration(); - usleep(500); - } - - ASSERT_TRUE(proxy->isAvailable()); - - auto& broadcastEvent = proxy->getTestPredefinedTypeBroadcastEvent(); - broadcastEvent.subscribe(std::bind(&MainLoopTest::broadcastCallback, this, std::placeholders::_1, std::placeholders::_2)); - - CommonAPI::CallStatus callStatus; - std::string outString; - - proxy->testPredefinedTypeMethod(0, "", callStatus, outInt, outString); - ASSERT_EQ(outInt, 1); - - for (int i = 0; i < 10000; i++) { - mainLoopForProxy_->doSingleIteration(100); - } - - sleep(10); - - mainLoopForProxy_->stop(); - mainLoopForStub_->stop(); - - stubThread.join(); - - // in total 5 broadcasts should have been arrived - ASSERT_EQ(lastBroadcastNumber, 5); -} - -/** -* @test Synchronous Calls Do Not Deadlock. -* - get proxy with available flag = true -* - call synchronous test method in syncCallThread -* - 5 broadcasts should arrive in the right order -* - run the mainloop again in order to give the syncCallThread a chance to return -*/ -TEST_F(MainLoopTest, SyncCallsDoNotDeadlock) { - auto proxy = mainloopFactoryProxy_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress8); - ASSERT_TRUE((bool) proxy); - - std::thread stubThread = std::thread([&]() {mainLoopForStub_->run();}); - - // let the proxy become available - while (!proxy->isAvailable()) { - mainLoopForProxy_->doSingleIteration(); - usleep(500); - } - - uint32_t inInt, outInt; - std::string inStr, outStr; - inInt = 1; - outInt = 0; - - callStatus = CommonAPI::CallStatus::REMOTE_ERROR; - - std::thread syncCallThread = std::thread( - [&]() {proxy->testPredefinedTypeMethod(inInt, inStr, callStatus, outInt, outStr);} - ); - sleep(10); - - ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus); - - if (callStatus != CommonAPI::CallStatus::SUCCESS) { - mainLoopForProxy_->runVerification(10, true, true); // run the mainloop again in order to give the syncCallThread a chance to return - } - mainLoopForStub_->stop(); - stubThread.join(); - syncCallThread.join(); -} - -class MainLoopThreadContext { -public: - void setupRuntime(std::promise<bool>& p) { - runtime_ = CommonAPI::Runtime::load(); - p.set_value(true); - } - - void setupMainLoopContext(std::promise<bool>& p) { - mainLoopContext_ = runtime_->getNewMainLoopContext(); - mainLoop_ = new CommonAPI::VerificationMainLoop(mainLoopContext_); - p.set_value(true); - } - - void setupFactory(std::promise<bool>& p) { - factory_ = runtime_->createFactory(mainLoopContext_); - servicePublisher_ = runtime_->getServicePublisher(); - p.set_value(true); - } - - void setAddresses(const std::string own, const std::string other, const std::string thirdParty) { - ownAddress_ = own; - - otherAddress_ = other; - thirdPartyAddress_ = thirdParty; - } - - void createProxyAndStub() { - stub_ = std::make_shared<PingPongTestStub>(); - ASSERT_TRUE(servicePublisher_->registerService(stub_, ownAddress_, factory_)); - proxy_ = factory_->buildProxy<commonapi::tests::TestInterfaceProxy>(otherAddress_); - ASSERT_TRUE((bool)proxy_); - proxyThirdParty_ = factory_->buildProxy<commonapi::tests::TestInterfaceProxy>(thirdPartyAddress_); - ASSERT_TRUE((bool)proxyThirdParty_); - } - - std::shared_ptr<CommonAPI::Runtime> runtime_; - std::shared_ptr<CommonAPI::MainLoopContext> mainLoopContext_; - std::shared_ptr<CommonAPI::Factory> factory_; - std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher_; - std::string ownAddress_, otherAddress_, thirdPartyAddress_; - std::shared_ptr<PingPongTestStub> stub_; - std::shared_ptr<commonapi::tests::TestInterfaceProxy<>> proxy_, proxyThirdParty_; - - CommonAPI::VerificationMainLoop* mainLoop_; -}; - -class MainLoopIndependenceTest: public ::testing::Test { -protected: - void SetUp() { - std::shared_ptr<CommonAPI::Runtime> runtimePtr1_, runtimePtr2_; - - std::promise<bool> promiseRuntime1, promiseRuntime2; - std::future<bool> futureRuntime1 = promiseRuntime1.get_future(); - std::future<bool> futureRuntime2 = promiseRuntime2.get_future(); - - mainLoopThread1_ = std::thread( - std::bind(&MainLoopThreadContext::setupRuntime, &threadCtx1_, std::move(promiseRuntime1))); - mainLoopThread2_ = std::thread( - std::bind(&MainLoopThreadContext::setupRuntime, &threadCtx2_, std::move(promiseRuntime2))); - - mainLoopThread1_.detach(); - mainLoopThread2_.detach(); - - futureRuntime1.wait_for(std::chrono::milliseconds(200)); - futureRuntime2.wait_for(std::chrono::milliseconds(200)); - - // check that both threads have a runtime and it is the same - ASSERT_TRUE((bool)threadCtx1_.runtime_); - ASSERT_TRUE((bool)threadCtx2_.runtime_); - ASSERT_EQ(threadCtx1_.runtime_, threadCtx2_.runtime_); - - std::promise<bool> promiseContext1, promiseContext2; - std::future<bool> futureContext1 = promiseContext1.get_future(); - std::future<bool> futureContext2 = promiseContext2.get_future(); - - mainLoopThread1_ = std::thread( - std::bind( - &MainLoopThreadContext::setupMainLoopContext, - &threadCtx1_, - std::move(promiseContext1))); - mainLoopThread2_ = std::thread( - std::bind( - &MainLoopThreadContext::setupMainLoopContext, - &threadCtx2_, - std::move(promiseContext2))); - mainLoopThread1_.detach(); - mainLoopThread2_.detach(); - - futureContext1.wait_for(std::chrono::milliseconds(200)); - futureContext2.wait_for(std::chrono::milliseconds(200)); - - // check that both threads have an own mainloop context - ASSERT_TRUE((bool)threadCtx1_.mainLoopContext_); - ASSERT_TRUE((bool)threadCtx2_.mainLoopContext_); - ASSERT_NE(threadCtx1_.mainLoopContext_, threadCtx2_.mainLoopContext_); - - std::promise<bool> promiseFactory1, promiseFactory2; - std::future<bool> futureFactory1 = promiseFactory1.get_future(); - std::future<bool> futureFactory2 = promiseFactory2.get_future(); - - mainLoopThread1_ = std::thread(std::bind(&MainLoopThreadContext::setupFactory, &threadCtx1_, std::move(promiseFactory1))); - mainLoopThread2_ = std::thread(std::bind(&MainLoopThreadContext::setupFactory, &threadCtx2_, std::move(promiseFactory2))); - - mainLoopThread1_.detach(); - mainLoopThread2_.detach(); - - futureFactory1.wait_for(std::chrono::milliseconds(200)); - futureFactory2.wait_for(std::chrono::milliseconds(200)); - - // check that both threads have a factory and a service publisher - ASSERT_TRUE((bool)threadCtx1_.factory_); - ASSERT_TRUE((bool)threadCtx2_.factory_); - ASSERT_TRUE((bool)threadCtx1_.servicePublisher_); - ASSERT_TRUE((bool)threadCtx2_.servicePublisher_); - - // set addresses - threadCtx1_.setAddresses(testAddress7, testAddress8, testAddress6); - threadCtx2_.setAddresses(testAddress8, testAddress7, testAddress6); - - threadCtx1_.createProxyAndStub(); - threadCtx2_.createProxyAndStub(); - - mainLoopThread1_ = std::thread([&]() { threadCtx1_.mainLoop_->run(); }); - mainLoopThread2_ = std::thread([&]() { threadCtx2_.mainLoop_->run(); }); - - usleep(200000); - - ASSERT_TRUE(threadCtx1_.proxy_->isAvailable()); - ASSERT_TRUE(threadCtx2_.proxy_->isAvailable()); - - threadCtx1_.mainLoop_->stop(); - threadCtx2_.mainLoop_->stop(); - - mainLoopThread1_.join(); - mainLoopThread2_.join(); - } - - void TearDown() { - threadCtx1_.servicePublisher_->unregisterService(testAddress6); - threadCtx1_.servicePublisher_->unregisterService(testAddress7); - threadCtx2_.servicePublisher_->unregisterService(testAddress8); - usleep(2000); - threadCtx1_.mainLoop_->stop(); - threadCtx2_.mainLoop_->stop(); - - if(mainLoopThread1_.joinable()) { - mainLoopThread1_.join(); - } - if(mainLoopThread2_.joinable()) { - mainLoopThread2_.join(); - } - } - - MainLoopThreadContext threadCtx1_, threadCtx2_; - std::thread mainLoopThread1_, mainLoopThread2_; -}; - -/** -* @test Proxy Receives Answer Only If Stub MainLoop Runs. -* - start proxy in thread 1 and call testPredefinedTypeMethod -* - proxy should not receive answer, if the stub mainloop does not run -* - run mainloop of stub -* - now the stub mainloop also runs, so the proxy should receive the answer -*/ -TEST_F(MainLoopIndependenceTest, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) { - CommonAPI::CallStatus callStatus; - - uint32_t inInt, outInt; - std::string inStr, outStr; - inInt = 1; - outInt = 0; - - std::thread mainLoopRunnerProxy([&]() { threadCtx1_.mainLoop_->runVerification(5, true, true); }); - mainLoopRunnerProxy.detach(); - - mainLoopThread1_ = std::thread([&]() { threadCtx1_.proxy_->testPredefinedTypeMethod(inInt, inStr, callStatus, outInt, outStr); }); - mainLoopThread1_.detach(); - - sleep(1); - // proxy should not receive answer, if the stub mainloop does not run - ASSERT_EQ(0, outInt); - - mainLoopThread2_ = std::thread([&]() { threadCtx2_.mainLoop_->run(); }); - mainLoopThread2_.detach(); - - sleep(1); - - // now the stub mainloop also runs, so the proxy should receive the answer - ASSERT_EQ(1, outInt); -} - -/** -* @test Proxy Receives Just His Own Answers. -* - start 2 proxies in own threads -* - call test method in each proxy -* - now each proxy should have received the answer to his own request -*/ -TEST_F(MainLoopIndependenceTest, ProxyReceivesJustHisOwnAnswers) { - std::shared_ptr<PingPongTestStub> stubThirdParty = std::make_shared<PingPongTestStub>(); - auto runtime = CommonAPI::Runtime::load(); - ASSERT_TRUE(runtime->getServicePublisher()->registerService(stubThirdParty, testAddress6, runtime->createFactory())); - - CommonAPI::CallStatus callStatusProxy1, callStatusProxy2; - - uint32_t inIntProxy1, outIntProxy1, inIntProxy2, outIntProxy2; - std::string inStrProxy1, outStrProxy1, inStrProxy2, outStrProxy2; - inIntProxy1 = 1; - inIntProxy2 = 2; - outIntProxy1 = outIntProxy2 = 0; - - std::thread mainLoopRunnerProxy1([&]() { threadCtx1_.mainLoop_->run(); }); - std::thread mainLoopRunnerProxy2([&]() { threadCtx2_.mainLoop_->run(); }); - mainLoopRunnerProxy1.detach(); - mainLoopRunnerProxy2.detach(); - - while(!(threadCtx1_.proxyThirdParty_->isAvailable() && threadCtx2_.proxyThirdParty_->isAvailable())) { - usleep(5000); - } - - - mainLoopThread1_ = std::thread([&]() { threadCtx1_.proxyThirdParty_->testPredefinedTypeMethod(inIntProxy1, inStrProxy1, callStatusProxy1, outIntProxy1, outStrProxy1); }); - mainLoopThread2_ = std::thread([&]() { threadCtx2_.proxyThirdParty_->testPredefinedTypeMethod(inIntProxy2, inStrProxy2, callStatusProxy2, outIntProxy2, outStrProxy2); }); - mainLoopThread1_.detach(); - mainLoopThread2_.detach(); - - sleep(5); - // now each proxy should have received the answer to his own request - ASSERT_EQ(1, outIntProxy1); - ASSERT_EQ(2, outIntProxy2); - - sleep(1); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/org.genivi.commonapi.core.verification/src/PFComplex.cpp b/org.genivi.commonapi.core.verification/src/PFComplex.cpp new file mode 100644 index 0000000..2730ce1 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/PFComplex.cpp @@ -0,0 +1,224 @@ +/* Copyright (C) 2014 BMW Group + * Copyright (C) 2015 Mentor Graphics + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * Author: Felix Scherzinger (felix_scherzinger@mentor.com) + * 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/. */ + +/** +* @file Performance_Complex +*/ + +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +#include "v1_0/commonapi/performance/complex/TestInterfaceProxy.hpp" +#include "stub/PFComplexStub.h" + +#include "utils/StopWatch.h" + +const int usecPerSecond = 1000000; + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.performance.complex.TestInterface"; +const int tasync = 100000; + +// Define the max. array size to test +const int maxArraySize = 4096 / 16; +// Define the loop count how often the commonAPI test function is called for calculating the mean time +const int loopCountPerPaylod = 1000; + +using namespace v1_0::commonapi::performance::complex; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class PFComplex: public ::testing::Test { +public: + void recvArray(const CommonAPI::CallStatus& callStatus, TestInterface::tArray y) { + // Stop the time & verify call status + watch_.stop(); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + std::unique_lock<std::mutex> uniqueLock(synchLock_); + condVar_.notify_one(); + } + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + + testStub_ = std::make_shared<PFComplexStub>(); + serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, "service-sample"); + ASSERT_TRUE(serviceRegistered_); + + testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, "client-sample"); + ASSERT_TRUE((bool)testProxy_); + + testProxy_->isAvailableBlocking(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + runtime_->unregisterService(domain, PFComplexStub::StubInterface::getInterface(), testAddress); + } + + void printTestValues(size_t payloadSize, size_t objectSize) { + // Get elapsed time, calculate mean time and print out! + StopWatch::usec_t methodCallTime = watch_.getTotalElapsedMicroseconds(); + StopWatch::usec_t meanTime = (methodCallTime / loopCountPerPaylod); + StopWatch::usec_t perByteTime = meanTime / objectSize; + uint32_t callsPerSeconds = usecPerSecond / (methodCallTime / loopCountPerPaylod); + + std::cout << "[MEASURING ] Payload-Size=" << std::setw(7) << std::setfill('.') << payloadSize + << ", Mean-Time=" << std::setw(7) << std::setfill('.') << meanTime + << "us, per-Byte(payload)=" << std::setw(7) << std::setfill('.') + << (perByteTime <= 0 ? ".....<1" : std::to_string(perByteTime)) << "us" + << ", calls/s=" << std::setw(7) << std::setfill('.') << callsPerSeconds + << std::endl; + } + + std::string configFileName_; + bool serviceRegistered_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + std::shared_ptr<TestInterfaceProxy<>> testProxy_; + std::shared_ptr<TestInterfaceStubDefault> testStub_; + + StopWatch watch_; + std::mutex synchLock_; + std::condition_variable condVar_; + uint32_t callCount_; + std::function<void (const CommonAPI::CallStatus&, TestInterface::tArray)> myCallback_; + uint32_t arraySize_ = 1; +}; + +/** +* @test Test synchronous ping pong function call +* - complex array is array of a struct containing an union and another struc with primitive datatypes +* - The stub just set the in array to the out array +* - CallStatus and array content will be used to verify the sync call has succeeded +* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize +* - Doing primitiveLoopSize loops to build the mean time +*/ +TEST_F(PFComplex, Ping_Pong_Complex_Synchronous) { + CommonAPI::CallStatus callStatus; + + watch_.reset(); + + // Loop until maxPrimitiveArraySize + while (arraySize_ <= maxArraySize) { + + // Create in-array with actual arraySize + TestInterface::tArray in; + TestInterface::innerStruct innerTestStruct(123, true, 4, "test", 35); + std::string unionMember = std::string("Hello World"); + TestInterface::innerUnion innerTestUnion = unionMember; + TestInterface::tStruct testStruct(innerTestStruct, innerTestUnion); + for (uint32_t i = 0; i < arraySize_; ++i) { + in.push_back(testStruct); + } + + // Sum up payload size of primitive memebers + size_t payloadSize = sizeof(innerTestStruct.getBooleanMember()) + sizeof(innerTestStruct.getUint8Member()) + + sizeof(innerTestStruct.getUint16Member()) + sizeof(innerTestStruct.getUint32Member()) + + sizeof(innerTestStruct.getStringMember()) + sizeof(unionMember); + + // Call commonAPI method loopCountPerPaylod times to calculate mean time + for (uint32_t i = 0; i < loopCountPerPaylod; ++i) { + + // Create an empty out-array for every commonAPI function call + TestInterface::tArray out; + + // Call commonAPI function and measure time + watch_.start(); + testProxy_->testMethod(in, callStatus, out); + watch_.stop(); + + // Check the call was successful & out array has same elements than in array + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(in, out); + } + + // Printing results + printTestValues(arraySize_ * payloadSize, arraySize_ * sizeof(testStruct)); + + // Increase array size for next iteration + arraySize_ *= 2; + + // Reset StopWatch for next iteration + watch_.reset(); + } +} + +/** +* @test Test asynchronous ping pong function call +* - complex array is array of a struct containing an union and another struc with primitive datatypes +* - The stub just set (copies) the in array to the out array +* - Only the CallStatus will be used to verify the async call has succeeded +* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize +* - Doing loopCountPerPaylod loops to calc the mean time +*/ +TEST_F(PFComplex, Ping_Pong_Complex_Asynchronous) { + myCallback_ = std::bind(&PFComplex::recvArray, this, std::placeholders::_1, std::placeholders::_2); + + std::unique_lock<std::mutex> uniqueLock(synchLock_); + + watch_.reset(); + + // Loop until maxPrimitiveArraySize + while (arraySize_ <= maxArraySize) { + + // Create in-array with actual arraySize + TestInterface::tArray in; + TestInterface::innerStruct innerTestStruct(123, true, 4, "test", 35); + std::string unionMember = std::string("Hello World"); + TestInterface::innerUnion innerTestUnion = unionMember; + TestInterface::tStruct testStruct(innerTestStruct, innerTestUnion); + for (uint32_t i = 0; i < arraySize_; ++i) { + in.push_back(testStruct); + } + + // Sum up payload size of primitive memebers + size_t payloadSize = sizeof(innerTestStruct.getBooleanMember()) + sizeof(innerTestStruct.getUint8Member()) + + sizeof(innerTestStruct.getUint16Member()) + sizeof(innerTestStruct.getUint32Member()) + + sizeof(innerTestStruct.getStringMember()) + sizeof(unionMember); + + // Call commonAPI method loopCountPerPaylod times to calculate mean time + for (uint32_t i = 0; i < loopCountPerPaylod; ++i) { + TestInterface::tArray out; + watch_.start(); + testProxy_->testMethodAsync(in, myCallback_); + condVar_.wait(uniqueLock); + } + + // Printing results + printTestValues(arraySize_ * payloadSize, arraySize_ * sizeof(testStruct)); + + // Increase array size for next iteration + arraySize_ *= 2; + + // Reset StopWatch for next iteration + watch_.reset(); + } +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} + diff --git a/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp b/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp new file mode 100644 index 0000000..ca71952 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp @@ -0,0 +1,196 @@ +/* Copyright (C) 2014 BMW Group + * Copyright (C) 2015 Mentor Graphics + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * Author: Felix Scherzinger (felix_scherzinger@mentor.com) + * 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/. */ + +/** +* @file Performance_Primitive +*/ + +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +#include "v1_0/commonapi/performance/primitive/TestInterfaceProxy.hpp" +#include "stub/PFPrimitiveStub.h" + +#include "utils/StopWatch.h" + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.performance.primitive.TestInterface"; +const int tasync = 100000; + +const int usecPerSecond = 1000000; + +// Define the max. array size to test +const int maxPrimitiveArraySize = 1024*16; +// Define the loop count how often the commonAPI test function is called for calculating the mean time +const int loopCountPerPaylod = 1000; + +using namespace v1_0::commonapi::performance::primitive; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class PFPrimitive: public ::testing::Test { +public: + void recvArray(const CommonAPI::CallStatus& callStatus, TestInterface::TestArray y) { + // Stop the time & verify call status + watch_.stop(); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + std::unique_lock<std::mutex> uniqueLock(synchLock_); + condVar_.notify_one(); + } + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + + testStub_ = std::make_shared<PFPrimitiveStub>(); + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + + testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId); + ASSERT_TRUE((bool)testProxy_); + + testProxy_->isAvailableBlocking(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + bool unregistered = runtime_->unregisterService(domain, PFPrimitiveStub::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(unregistered); + } + + void printTestValues() { + // Get elapsed time, calculate mean time and print out! + StopWatch::usec_t methodCallTime = watch_.getTotalElapsedMicroseconds(); + StopWatch::usec_t meanTime = (methodCallTime / loopCountPerPaylod); + StopWatch::usec_t perByteTime = meanTime / arraySize_; + uint32_t callsPerSeconds = usecPerSecond / (methodCallTime / loopCountPerPaylod); + + std::cout << "[MEASURING ] Size=" << std::setw(7) << std::setfill('.') << arraySize_ + << ", Mean-Time=" << std::setw(7) << std::setfill('.') << meanTime << "us" + << ", per-Byte=" << std::setw(7) << std::setfill('.') + << (perByteTime <= 0 ? ".....<1" : std::to_string(perByteTime)) << "us" + << ", calls/s=" << std::setw(7) << std::setfill('.') << callsPerSeconds + << std::endl; + } + + std::string configFileName_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + std::shared_ptr<TestInterfaceProxy<>> testProxy_; + std::shared_ptr<TestInterfaceStub> testStub_; + + StopWatch watch_; + std::mutex synchLock_; + std::condition_variable condVar_; + uint32_t callCount_; + std::function<void (const CommonAPI::CallStatus&, TestInterface::TestArray)> myCallback_; + uint32_t arraySize_ = 1; +}; + +/** +* @test Test synchronous ping pong function call +* - primitive array is array of UInt_8 +* - The stub just set the in array to the out array +* - CallStatus and array content will be used to verify the sync call has succeeded +* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize +* - Doing primitiveLoopSize loops to build the mean time +*/ +TEST_F(PFPrimitive, DISABLED_Ping_Pong_Primitive_Synchronous) { + CommonAPI::CallStatus callStatus; + + watch_.reset(); + + // Loop until maxPrimitiveArraySize + while (arraySize_ <= maxPrimitiveArraySize) { + + // Create in-array with actual arraySize + TestInterface::TestArray in(arraySize_); + + // Call commonAPI method loopCountPerPaylod times to calculate mean time + for (uint32_t i = 0; i < loopCountPerPaylod; ++i) { + + // Create an empty out-array for every commonAPI function call + TestInterface::TestArray out; + + // Call commonAPI function and measure time + watch_.start(); + testProxy_->testMethod(in, callStatus, out); + watch_.stop(); + + // Check the call was successful & out array has same elements than in array + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(in, out); + } + + // Printing results + printTestValues(); + + // Increase array size for next iteration + arraySize_ *= 2; + + // Reset StopWatch for next iteration + watch_.reset(); + } +} + +/** +* @test Test asynchronous ping pong function call +* - primitive array is array of UInt_8 +* - The stub just set (copies) the in array to the out array +* - Only the CallStatus will be used to verify the async call has succeeded +* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize +* - Doing primitiveLoopSize loops to build the mean time +*/ +TEST_F(PFPrimitive, Ping_Pong_Primitive_Asynchronous) { + myCallback_ = std::bind(&PFPrimitive::recvArray, this, std::placeholders::_1, std::placeholders::_2); + + std::unique_lock<std::mutex> uniqueLock(synchLock_); + + // Loop until maxPrimitiveArraySize + while (arraySize_ <= maxPrimitiveArraySize) { + + watch_.reset(); + + // Initialize testData, call count stop watch for next iteration! + TestInterface::TestArray in(arraySize_); + + for (uint32_t i = 0; i < loopCountPerPaylod; ++i) { + TestInterface::TestArray out; + watch_.start(); + testProxy_->testMethodAsync(in, myCallback_); + condVar_.wait(uniqueLock); + } + + // Printing results + printTestValues(); + + // Increase array size for next iteration + arraySize_ *= 2; + } +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} + diff --git a/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp b/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp new file mode 100644 index 0000000..88e7ff4 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp @@ -0,0 +1,78 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file Runtime +*/ + +#include <functional> +#include <fstream> +#include <thread> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "v1_0/commonapi/runtime/TestInterfaceProxy.hpp" +#include "v1_0/commonapi/runtime/TestInterfaceStubDefault.hpp" + +const std::string domain = "local"; +const std::string testAddress = "commonapi.runtime.TestInterface"; +const std::string applicationNameService = "service-sample"; +const std::string applicationNameClient = "client-sample"; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class RTBuildProxiesAndStubs: public ::testing::Test { + +protected: + void SetUp() { + } + + void TearDown() { + } +}; + +/** +* @test Loads Runtime, creates proxy and stub/service. +* - Calls CommonAPI::Runtime::get() and checks if return value is true. +* - Checks if test proxy with domain and test instance can be created. +* - Checks if test stub can be created. +* - Register the test service. +* - Unregister the test service. +*/ +TEST_F(RTBuildProxiesAndStubs, LoadedRuntimeCanBuildProxiesAndStubs) { + + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime); + + std::thread t1([&runtime](){ + auto testProxy = runtime->buildProxy<v1_0::commonapi::runtime::TestInterfaceProxy>(domain,testAddress, applicationNameClient); + testProxy->isAvailableBlocking(); + ASSERT_TRUE((bool)testProxy); + }); + + + auto testStub = std::make_shared<v1_0::commonapi::runtime::TestInterfaceStubDefault>(); + ASSERT_TRUE((bool)testStub); + + ASSERT_TRUE(runtime->registerService(domain,testAddress,testStub, applicationNameService)); + t1.join(); + ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress)); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp b/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp new file mode 100644 index 0000000..5321418 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp @@ -0,0 +1,52 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file Runtime +*/ + +#include <functional> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class RTLoadingRuntime: public ::testing::Test { + +protected: + void SetUp() { + } + + void TearDown() { + } +}; + +/** +* @test Loads Default Runtime. +* - Calls CommonAPI::Runtime::get(). +* - Success if return value is true. +*/ +TEST_F(RTLoadingRuntime, LoadsDefaultRuntime) { + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/StabilityMP.cpp b/org.genivi.commonapi.core.verification/src/StabilityMP.cpp new file mode 100644 index 0000000..92f61c4 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/StabilityMP.cpp @@ -0,0 +1,648 @@ +/* stability tests, control program. */ +/* this program takes care of setting up a test and then making sure things happen in proper sequence. */ + +#include <functional> +#include <fstream> +#include <algorithm> +#include <gtest/gtest.h> +#include <CommonAPI/CommonAPI.hpp> +#include "v1_0/commonapi/stability/mp/TestInterfaceProxy.hpp" +#include "v1_0/commonapi/stability/mp/ControlInterfaceProxy.hpp" +#include "stub/StabControlStub.h" +#include "stub/StabilityMPStub.h" +#include <unistd.h> +#include <sys/wait.h> + +using namespace v1_0::commonapi::stability::mp; + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.stability.mp.TestInterface"; +const std::string controlAddress = "commonapi.stability.mp.ControlInterface"; +const std::string COMMONAPI_CONFIG_SUFFIX = ".conf"; + +// test magnitude constants - the bigger the numbers, the more stressful the test +const int N_SERVERS = 100; +const int N_THREADS = 100; + +const int MAX_WAIT = 10000; + +const int N_TEST_PROXY_PROCESSES = 3; +const int N_CHILDREN = 2 + 2 * N_TEST_PROXY_PROCESSES; // needs to be large enough to cover for all created processes +pid_t childpids[N_CHILDREN]; +bool idChild; +bool controlServiceRegistered = false; +std::shared_ptr<CommonAPI::Runtime> runtime_; +std::shared_ptr<CommonAPI::Factory> stubFactory_; +std::shared_ptr<StabControlStub> controlServiceStub_; +class Environment: public :: testing::Environment { +public: + virtual ~Environment() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } + +}; + +// server states: +const int WAITING_FOR_CHILDREN = 0; +// commands from child to parent: +const uint32_t QUERY_NEW_ID = 0; +const uint32_t GET_COMMAND = 1; +const uint32_t CMD_DONE = 2; +const uint32_t PROXIES_CONNECTED_OK = 3; +const uint32_t PROXIES_CONNECTED_FAIL = 4; + +// child states: +const int CHILD_SETUP = 1; +const int CHILD_IDLE = 2; +const int CHILD_RESERVED_IDLE = 3; +const int CHILD_PROCESSING_CMD = 4; +const int CONNECTION_STATUS_OK = 5; +const int CONNECTION_STATUS_FAIL = 6; +const int DEAD = 7; + +// commands from parent to child +const uint8_t KEEP_IDLE = 1; +const uint8_t PROXY_CREATE = 2; +const uint8_t WAIT_UNTIL_CONNECTED = 3; +const uint8_t WAIT_UNTIL_DISCONNECTED = 4; +const uint8_t KILL_YOURSELF = 5; +const uint8_t SERVER_CREATE = 6; + +class ControledChild { +public: + uint8_t id; + int state = CHILD_SETUP; + uint8_t next_cmd; +}; + +std::vector<ControledChild *> children; +bool allChildrenRegistered = false; + +bool isFree(ControledChild * pChild) +{ + return (pChild->state == CHILD_IDLE); +} +ControledChild * findFreeChild(void) +{ + std::vector<ControledChild *>::iterator i = std::find_if(children.begin(), children.end(), isFree); + if (i == children.end()) + return 0; + (*i)->state = CHILD_RESERVED_IDLE; + return *i; +} +ControledChild * findChild(uint8_t id) +{ + + std::vector<ControledChild *>::iterator i = children.begin(); + while (i != children.end()) { + if ((*i)->id == id) + return *i; + i++; + } + return 0; +} + +class ProxyThread { +public: + std::shared_ptr<TestInterfaceProxy<>> proxy_[N_SERVERS]; + void createProxies(void) { + // create a proxy for each of the servers + for (unsigned int proxycount = 0; proxycount < N_SERVERS; proxycount++) { + proxy_[proxycount] = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress + std::to_string(proxycount), clientId); + success_ = success_ && (bool)proxy_[proxycount]; + } + } + void pollForAvailability(void) { + success_ = false; + for (int wait = 0; wait < 100; wait++) { + bool allAvailable = true; + for (unsigned int proxycount = 0; proxycount < N_SERVERS; proxycount++) { + if (!proxy_[proxycount]->isAvailable()) { + allAvailable = false; + break; + } + } + if (allAvailable) { + success_ = true; + break; + } + usleep(10000); + } + } + void pollForUnavailability(void) { + success_ = false; + for (int wait = 0; wait < 100; wait++) { + bool allUnAvailable = true; + for (unsigned int proxycount = 0; proxycount < N_SERVERS; proxycount++) { + if (proxy_[proxycount]->isAvailable()) { + allUnAvailable = false; + break; + } + } + if (allUnAvailable) { + success_ = true; + break; + } + usleep(10000); + } + } + void setThread(std::thread *thread) { + thread_ = thread; + } + std::thread * getThread(void) { + return thread_; + } + bool getSuccess(void) { + return success_; + } + std::thread *thread_ = 0; + bool success_ = true; +}; + +class ChildProcess { +public: + bool setup() + { + runtime_ = CommonAPI::Runtime::get(); + testProxy_ = runtime_->buildProxy<ControlInterfaceProxy>(domain, controlAddress, clientId); + while(!testProxy_->isAvailable()) + usleep(10000); + // send register message through command interface + uint8_t cmd; + uint32_t data1, data2; + bool status = sendMessage(0, QUERY_NEW_ID, cmd, data1, data2); + if (!status) + // problems with communication. + return false; + id = cmd; + state = CHILD_IDLE; + return true; + } + + bool sendMessage(const uint8_t &id, + const uint32_t &data, + uint8_t &command, + uint32_t &data1, + uint32_t &data2 + ) + { + CommonAPI::CallStatus callStatus; + testProxy_->controlMethod(id, data, callStatus, command, data1, data2); + if (callStatus == CommonAPI::CallStatus::SUCCESS) + return true; + // on error, exit - the control service has most likely just died. + exit(1); + return false; + } + + void processCommands() + { + ProxyThread * proxyrunners[N_THREADS]; + while (true) { + switch(state) + { + case CHILD_IDLE: + // send polling message + uint8_t cmd; + uint32_t data1, data2; + bool status = sendMessage(id, GET_COMMAND, cmd, data1, data2); + if (cmd == KEEP_IDLE) { + usleep(10000); + break; + } + if (cmd == PROXY_CREATE) { + // create threads with proxies to test services. + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::createProxies, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + + // wait until all threads have completed creating the proxies. + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + + // once done with all, send CMD_DONE message. + sendMessage(id, CMD_DONE, cmd, data1, data2); + // then start polling again. + state = CHILD_IDLE; + } + else if (cmd == SERVER_CREATE) { + // create services for a number of addresses + std::shared_ptr<StabilityMPStub> testMultiRegisterStub_; + testMultiRegisterStub_ = std::make_shared<StabilityMPStub>(); + for (unsigned int regcount = 0; regcount < N_SERVERS; regcount++) { + bool serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + } + + sendMessage(id, CMD_DONE, cmd, data1, data2); + state = CHILD_IDLE; + } + else if (cmd == WAIT_UNTIL_CONNECTED) { + // create threads to test the proxy availability + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + std::thread * thread = new std::thread(std::bind(&ProxyThread::pollForAvailability, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + // wait until all threads have completed + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + // check for succession status + bool success = true; + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + success = success & proxyrunners[threadcount]->getSuccess(); + } + + // send message with the succession status + if (success) + sendMessage(id, PROXIES_CONNECTED_OK, cmd, data1, data2); + else + sendMessage(id, PROXIES_CONNECTED_FAIL, cmd, data1, data2); + + // then start polling again. + state = CHILD_IDLE; + + } + else if (cmd == WAIT_UNTIL_DISCONNECTED) { + // create threads to test the proxy unavailability + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + std::thread * thread = new std::thread(std::bind(&ProxyThread::pollForUnavailability, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + // wait until all threads have completed + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + // check for succession status + bool success = true; + for (unsigned int threadcount = 0; threadcount < N_THREADS; threadcount++) { + success = success & proxyrunners[threadcount]->getSuccess(); + } + + // send message with the succession status + if (success) + sendMessage(id, PROXIES_CONNECTED_OK, cmd, data1, data2); + else + sendMessage(id, PROXIES_CONNECTED_FAIL, cmd, data1, data2); + + // then start polling again. + state = CHILD_IDLE; + + } + else if (cmd == KILL_YOURSELF) { + exit(0); + } + + } + } + return; + } + + + std::shared_ptr<ControlInterfaceProxy<>> testProxy_; + + uint8_t id = 0; + int state = CHILD_SETUP; +}; + +int state = WAITING_FOR_CHILDREN; +static int8_t next_id = 1; + +void listener(uint8_t id,uint32_t data, uint8_t& command, uint32_t& min, uint32_t &max) { + command = 0; + min = 0; + max = 0; + switch(data) { + case QUERY_NEW_ID: + { + // create a child data structure + ControledChild * child = new ControledChild(); + + // add this to the structure + child->id = next_id; + // increment id + next_id++; + child->state = CHILD_IDLE; + // prepare to return id to child + command = child->id; + children.push_back(child); + child->next_cmd = KEEP_IDLE; + } + if (children.size() == N_CHILDREN) + allChildrenRegistered = true; + break; + + case GET_COMMAND: + { + // find the child with this id + ControledChild * child = findChild(id); + ASSERT_TRUE((bool)child); + uint8_t cmd = child->next_cmd; + if (cmd != KEEP_IDLE) { + child->next_cmd = KEEP_IDLE; + child->state = CHILD_PROCESSING_CMD; + } + command = cmd; + } + break; + + case CMD_DONE: + { + // find the child with this id + ControledChild * child = findChild(id); + ASSERT_TRUE((bool)child); + child->state = CHILD_RESERVED_IDLE; + } + break; + + case PROXIES_CONNECTED_OK: + { + // find the child with this id + ControledChild * child = findChild(id); + ASSERT_TRUE((bool)child); + child->state = CONNECTION_STATUS_OK; + } + break; + + case PROXIES_CONNECTED_FAIL: + { + // find the child with this id + ControledChild * child = findChild(id); + ASSERT_TRUE((bool)child); + child->state = CONNECTION_STATUS_FAIL; + } + break; + } +} + + +/* this class is instantiated only for the control process. */ +class Stability: public ::testing::Test { +protected: + void SetUp() { + + } + + void TearDown() { + + } +}; + +TEST_F(Stability, BasicFunctionality) { + ASSERT_TRUE(allChildrenRegistered); +} + + +TEST_F(Stability, ProxyCreation_ProxyFirst) { + /* + DO for N child processes + get free child entry (proxy process) + setup 'proxy c' command + wait until child proc is in 'CMD DONE' + END + get free child entry (server) + setup 'server c' command + wait until server is in 'CMD DONE' + DO for N proxy processes + setup 'query status' c + wait until child proc is in 'CMD DONE' + assert child proc status is okay + END + setup 'kill' command to server + wait until server is in 'CMD SENT' + DO for N proxy processes + setup 'query status' cmd + wait until child proc is in 'CMD DONE' + assert child proc status is okay + setup 'kill' to child + wait until child proc is in CMD SENT + END + */ + ControledChild * proxyprocs[N_TEST_PROXY_PROCESSES]; + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = findFreeChild(); + ASSERT_TRUE((bool)child); + proxyprocs[i] = child; + child->state = CHILD_PROCESSING_CMD; + child->next_cmd = PROXY_CREATE; + } + // wait until children are ready for more commands + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (child->state == CHILD_RESERVED_IDLE) { + break; + } + usleep(100000); + } + ASSERT_TRUE(child->state == CHILD_RESERVED_IDLE); + } + // setup server test proc + ControledChild * srvChild = findFreeChild(); + ASSERT_TRUE((bool)srvChild); + srvChild->state = CHILD_PROCESSING_CMD; + srvChild->next_cmd = SERVER_CREATE; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (srvChild->state == CHILD_RESERVED_IDLE) { + break; + } + usleep(100000); + } + ASSERT_TRUE(srvChild->state == CHILD_RESERVED_IDLE); + // send proxy status query messages + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + child->state = CHILD_PROCESSING_CMD; + child->next_cmd = WAIT_UNTIL_CONNECTED; + } + // wait until children return connection status + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (child->state == CONNECTION_STATUS_OK) { + break; + } + if (child->state == CONNECTION_STATUS_FAIL) { + break; + } + usleep(100000); + } + ASSERT_TRUE(child->state == CONNECTION_STATUS_OK); + } + // kill server + srvChild->next_cmd = KILL_YOURSELF; + srvChild->state = DEAD; + // send proxy status query messages + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + child->next_cmd = WAIT_UNTIL_DISCONNECTED; + } + // wait until children return connection status + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (child->state == CONNECTION_STATUS_OK) { + break; + } + if (child->state == CONNECTION_STATUS_FAIL) { + break; + } + usleep(100000); + } + ASSERT_TRUE(child->state == CONNECTION_STATUS_OK); + } + // kill children + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + child->next_cmd = KILL_YOURSELF; + child->state = DEAD; + } + + +} + +TEST_F(Stability, ProxyCreation_ServerFirst) { + + ControledChild * proxyprocs[N_TEST_PROXY_PROCESSES]; + + // setup server test proc + ControledChild * srvChild = findFreeChild(); + ASSERT_TRUE((bool)srvChild); + srvChild->state = CHILD_PROCESSING_CMD; + srvChild->next_cmd = SERVER_CREATE; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (srvChild->state == CHILD_RESERVED_IDLE) { + break; + } + usleep(100000); + } + ASSERT_TRUE(srvChild->state == CHILD_RESERVED_IDLE); + + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = findFreeChild(); + ASSERT_TRUE((bool)child); + proxyprocs[i] = child; + child->state = CHILD_PROCESSING_CMD; + child->next_cmd = PROXY_CREATE; + } + // wait until children are ready for more commands + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (child->state == CHILD_RESERVED_IDLE) { + break; + } + usleep(100000); + } + ASSERT_TRUE(child->state == CHILD_RESERVED_IDLE); + } + + // send proxy status query messages + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + child->state = CHILD_PROCESSING_CMD; + child->next_cmd = WAIT_UNTIL_CONNECTED; + } + // wait until children return connection status + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (child->state == CONNECTION_STATUS_OK) { + break; + } + if (child->state == CONNECTION_STATUS_FAIL) { + break; + } + usleep(100000); + } + ASSERT_TRUE(child->state == CONNECTION_STATUS_OK); + } + // kill server + srvChild->next_cmd = KILL_YOURSELF; + srvChild->state = DEAD; + // send proxy status query messages + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + child->next_cmd = WAIT_UNTIL_DISCONNECTED; + } + // wait until children return connection status + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + for (int wait = 0; wait < MAX_WAIT; wait++) { + if (child->state == CONNECTION_STATUS_OK) { + break; + } + if (child->state == CONNECTION_STATUS_FAIL) { + break; + } + usleep(100000); + } + ASSERT_TRUE(child->state == CONNECTION_STATUS_OK); + } + // kill children + for (int i = 0; i < N_TEST_PROXY_PROCESSES; i++) { + ControledChild * child = proxyprocs[i]; + child->next_cmd = KILL_YOURSELF; + child->state = DEAD; + } +} + +int main(int argc, char ** argv) +{ + /* create the necessary child processes */ + /* forking is best done before the google test environment is set up */ + bool isChild = false; + for (int i = 0; i < N_CHILDREN; i++) { + pid_t child = fork(); + if (child == 0) { + isChild = true; + break; + } + childpids[i] = child; + } + + /* if we are not a child, set up test environment */ + if (!isChild) { + // do this just once + runtime_ = CommonAPI::Runtime::get(); + // register control service + StabControlStub::registerListener(&listener); + controlServiceStub_ = std::make_shared<StabControlStub>(); + controlServiceRegistered = runtime_->registerService(domain, controlAddress, controlServiceStub_, serviceId); + std::cout << "Control service registered at " << controlAddress << std::endl; + + // wait until children have been registered + while (!allChildrenRegistered) { + usleep(10000); + } + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); + } + /* otherwise, start acting as a child process */ + ChildProcess child; + child.setup(); + child.processCommands(); + + /* TBD */ + + return 0; +} + + diff --git a/org.genivi.commonapi.core.verification/src/StabilitySP.cpp b/org.genivi.commonapi.core.verification/src/StabilitySP.cpp new file mode 100644 index 0000000..34059f8 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/StabilitySP.cpp @@ -0,0 +1,617 @@ +/* Copyright (C) 2015 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * 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/. */ + +/** +* @file StabilitySP +*/ + +#include <functional> +#include <fstream> +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "v1_0/commonapi/stability/sp/TestInterfaceProxy.hpp" +#include "stub/StabilitySPStub.h" + +const std::string serviceId = "service-sample"; +const std::string clientId = "client-sample"; + +const std::string domain = "local"; +const std::string testAddress = "commonapi.stability.sp.TestInterface"; +const std::string COMMONAPI_CONFIG_SUFFIX = ".conf"; +const int MAXSERVERCOUNT = 40; +const int MAXTHREADCOUNT = 40; +const int MAXMETHODCALLS = 80; +const int MAXREGLOOPS = 16; +const int MAXREGCOUNT = 16; +const int MESSAGESIZE = 80; +const int MAXSUBSCRIPTIONSETS = 10; + +using namespace v1_0::commonapi::stability::sp; + +class Environment: public ::testing::Environment { +public: + virtual ~Environment() { + } + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +class StabilitySP: public ::testing::Test { + +protected: + void SetUp() { + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime_); + + testStub_ = std::make_shared<StabilitySPStub>(); + serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + + testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId); + ASSERT_TRUE((bool)testProxy_); + + testProxy_->isAvailableBlocking(); + ASSERT_TRUE(testProxy_->isAvailable()); + } + + void TearDown() { + bool unregistered = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(unregistered); + } + + uint8_t value_; + bool serviceRegistered_; + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<TestInterfaceProxy<>> testProxy_; + std::shared_ptr<TestInterfaceStub> testStub_; +}; +/** +* @test Register and unregister services in a loop. +* - do MAXREGLOOPS times: +* - register MAXREGCOUNT addresses as services +* - unregister the addresses that were just registered +* - check the return code of each register/unregister call +* - test fails if any of the return codes are false +**/ + +TEST_F(StabilitySP, RepeatedRegistrations) { + + std::shared_ptr<TestInterfaceStubDefault> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int loopcount = 0; loopcount < MAXREGLOOPS; loopcount++) { + for (unsigned int regcount = 0; regcount < MAXREGCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + } + for (unsigned int regcount = 0; regcount < MAXREGCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } + } +} + +/* Helper class. Creates proxies for each server and calls a method for each */ +class ProxyThread { +public: + int asyncCounter = 0; + std::shared_ptr<TestInterfaceProxy<>> proxy_[MAXSERVERCOUNT]; + // callback for asynchronous attribute functions. + void recvValue(const CommonAPI::CallStatus& callStatus, TestInterface::tArray arrayResultValue) { + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + asyncCounter++; + + TestInterface::tArray arrayTestValue; + + // check the contents of the attribute. + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + EXPECT_EQ(arrayTestValue, arrayResultValue); + + } + // callback for attribute subscriptions. + void recvSubscribedValue(TestInterface::tArray arrayResultValue) { + asyncCounter++; + TestInterface::tArray arrayTestValue; + + // check the contents of the attribute. + // The first byte may change, so ignore that one. + arrayTestValue.push_back(arrayResultValue[0]); + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + EXPECT_EQ(arrayTestValue, arrayResultValue); + } + + // helper function for creating proxies. + void createProxies(void) { + std::shared_ptr<CommonAPI::Runtime> runtime_; + runtime_ = CommonAPI::Runtime::get(); + + // create a proxy for each of the servers + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + proxy_[proxycount] = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress + std::to_string(proxycount), clientId); + success_ = success_ && (bool)proxy_[proxycount]; + ASSERT_TRUE(success_); + for (unsigned int wait = 0; !proxy_[proxycount]->isAvailable() && wait < 100; ++wait) { + usleep(10000); + } + ASSERT_TRUE(proxy_[proxycount]->isAvailable()); + } + } + + void runMethodCalls(void) { + createProxies(); + for (unsigned int loopcount = 0; loopcount < MAXMETHODCALLS; loopcount++) { + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + exerciseMethod(proxy_[proxycount]); + } + } + } + void runSetAttributes() { + createProxies(); + for (unsigned int loopcount = 0; loopcount < MAXMETHODCALLS; loopcount++) { + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + exerciseSetAttribute(proxy_[proxycount]); + } + } + + } + void runCreateProxiesAndSubscribe() { + std::function<void (TestInterface::tArray)> myCallback = + std::bind(&ProxyThread::recvSubscribedValue, this, std::placeholders::_1); + createProxies(); + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + // subscribe for attributes in that proxy + proxy_[proxycount]->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback); + } + } + + void waitUntilAsyncCountIsFull(int expected) { + int previousCount = asyncCounter; + while (true) { + if (asyncCounter == expected) break; + for (unsigned int wait = 0; wait < 1000; wait++) { + if (previousCount != asyncCounter) { + break; + } + usleep(10000); + } + if (previousCount == asyncCounter) { + break; + } + previousCount = asyncCounter; + } + EXPECT_EQ(expected, asyncCounter); + } + + void runSetSubscribedAttributes(unsigned int id) { + + unsigned char message1 = id; + unsigned char message2 = message1 + MAXTHREADCOUNT; + unsigned char message = message1; + + for (unsigned int loopcount = 0; loopcount < MAXSUBSCRIPTIONSETS; loopcount++) { + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + exerciseSetSubscribedAttribute(proxy_[proxycount], message); + // toggle between two different messages + message = message1 + message2 - message; + } + } + + // now wait until all the callbacks have been called + int EXPECTED_COUNT = MAXSUBSCRIPTIONSETS * MAXSERVERCOUNT * MAXTHREADCOUNT; + waitUntilAsyncCountIsFull(EXPECTED_COUNT); + } + + void runGetAttributes() { + createProxies(); + for (unsigned int loopcount = 0; loopcount < MAXMETHODCALLS; loopcount++) { + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + exerciseGetAttribute(proxy_[proxycount]); + } + } + + } + void runGetAttributesAsync() { + createProxies(); + for (unsigned int loopcount = 0; loopcount < MAXMETHODCALLS; loopcount++) { + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + exerciseGetAttributeAsync(proxy_[proxycount]); + } + } + + // now wait until all the callbacks have been called + int EXPECTED_COUNT = MAXMETHODCALLS * MAXSERVERCOUNT; + waitUntilAsyncCountIsFull(EXPECTED_COUNT); + + } + void runSetAttributesAsync() { + createProxies(); + for (unsigned int loopcount = 0; loopcount < MAXMETHODCALLS; loopcount++) { + for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) { + exerciseSetAttributeAsync(proxy_[proxycount]); + } + } + + // now wait until all the callbacks have been called + int EXPECTED_COUNT = MAXMETHODCALLS * MAXSERVERCOUNT; + waitUntilAsyncCountIsFull(EXPECTED_COUNT); + + } + + + bool getSuccess(void) { + return success_; + } + void setThread(std::thread *thread) { + thread_ = thread; + } + std::thread * getThread(void) { + return thread_; + } + bool exerciseMethod(std::shared_ptr<TestInterfaceProxy<>> proxy) { + TestInterface::tArray arrayTestValue; + TestInterface::tArray arrayResultValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + CommonAPI::CallStatus callStatus; + proxy->testMethod(arrayTestValue, callStatus, arrayResultValue); + + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(arrayTestValue, arrayResultValue); + + return true; + } + bool exerciseSetAttribute(std::shared_ptr<TestInterfaceProxy<>> proxy) { + TestInterface::tArray arrayTestValue; + TestInterface::tArray arrayResultValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + CommonAPI::CallStatus callStatus; + proxy->getTestAttributeAttribute().setValue(arrayTestValue, callStatus, arrayResultValue); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(arrayTestValue, arrayResultValue); + + return true; + } + + bool exerciseSetSubscribedAttribute(std::shared_ptr<TestInterfaceProxy<>> proxy, unsigned char message_number) { + TestInterface::tArray arrayTestValue; + TestInterface::tArray arrayResultValue; + arrayTestValue.push_back(message_number); + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + CommonAPI::CallStatus callStatus; + proxy->getTestAttributeAttribute().setValue(arrayTestValue, callStatus, arrayResultValue); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(arrayTestValue, arrayResultValue); + + return true; + } + + bool exerciseGetAttribute(std::shared_ptr<TestInterfaceProxy<>> proxy) { + TestInterface::tArray arrayTestValue; + TestInterface::tArray arrayResultValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + CommonAPI::CallStatus callStatus; + proxy->getTestAttributeAttribute().getValue(callStatus, arrayResultValue); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(arrayTestValue, arrayResultValue); + + return true; + } + bool exerciseGetAttributeAsync(std::shared_ptr<TestInterfaceProxy<>> proxy) { + std::function<void (const CommonAPI::CallStatus&, TestInterface::tArray)> myCallback = + std::bind(&ProxyThread::recvValue, this, std::placeholders::_1, std::placeholders::_2); + + CommonAPI::CallStatus callStatus; + proxy->getTestAttributeAttribute().getValueAsync(myCallback); + return true; + } + bool exerciseSetAttributeAsync(std::shared_ptr<TestInterfaceProxy<>> proxy) { + TestInterface::tArray arrayTestValue; + std::function<void (const CommonAPI::CallStatus&, TestInterface::tArray)> myCallback = + std::bind(&ProxyThread::recvValue, this, std::placeholders::_1, std::placeholders::_2); + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + + proxy->getTestAttributeAttribute().setValueAsync(arrayTestValue, myCallback); + return true; + } + + std::thread *thread_ = 0; + bool success_ = true; +}; +/** +* @test Create a number of services and proxies and send messages through them. +* - Register MAXSERVERCOUNT addresses as services +* - Create MAXTHREADCOUNT threads, each of which +* creates a proxy for each service address and +* then sends MAXMETHODCALLS messages to each. +* - Each message is MESSAGESIZE bytes long. +* - Test fails if any of the services fail to get registered +* or if any of the proxies won't get available +* or if the return message from the server is not correct +**/ +TEST_F(StabilitySP, MultipleMethodCalls) { + std::shared_ptr<TestInterfaceStubDefault> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + } + ProxyThread * proxyrunners[MAXTHREADCOUNT]; + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::runMethodCalls, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } +} +/** +* @test Create a number of services and proxies and set attributes through them. +* - Register MAXSERVERCOUNT addresses as services +* - Create MAXTHREADCOUNT threads, each of which +* creates a proxy for each service address and +* then sets attributes MAXMETHODCALLS times to each. +* - Each attribute is MESSAGESIZE bytes long. +* - Test fails if any of the services fail to get registered +* or if any of the proxies won't get available +* or if the return attribute from the server is not correct +**/ +TEST_F(StabilitySP, MultipleAttributeSets) { + std::shared_ptr<TestInterfaceStubDefault> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + } + ProxyThread * proxyrunners[MAXTHREADCOUNT]; + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::runSetAttributes, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } +} + +/** +* @test Create a number of services and proxies and get attributes through them. +* - Register MAXSERVERCOUNT addresses as services +* - Set the attribute for service, at the stub side. +* - Create MAXTHREADCOUNT threads, each of which +* creates a proxy for each service address and +* then gets attributes MAXMETHODCALLS times for each. +* - Each attribute is MESSAGESIZE bytes long. +* - Test fails if any of the services fail to get registered +* or if any of the proxies won't get available +* or if the returned attribute from the server is not correct +**/ +TEST_F(StabilitySP, MultipleAttributeGets) { + std::shared_ptr<StabilitySPStub> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + + } + TestInterface::tArray arrayTestValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + testMultiRegisterStub_->setTestValues(arrayTestValue); + + ProxyThread * proxyrunners[MAXTHREADCOUNT]; + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::runGetAttributes, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } +} + +/** +* @test Create a number of services and proxies and get attributes through them. +* - Register MAXSERVERCOUNT addresses as services +* - Set the attribute for service, at the stub side. +* - Create MAXTHREADCOUNT threads, each of which +* creates a proxy for each service address and +* then gets attributes MAXMETHODCALLS times for each asynchronously +* - Each attribute is MESSAGESIZE bytes long. +* - Test fails if any of the services fail to get registered +* or if any of the proxies won't get available +* or if the callbacks are not called correct number of times +**/ +TEST_F(StabilitySP, MultipleAttributeGetAsyncs) { + std::shared_ptr<StabilitySPStub> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + } + TestInterface::tArray arrayTestValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + testMultiRegisterStub_->setTestValues(arrayTestValue); + + ProxyThread * proxyrunners[MAXTHREADCOUNT]; + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::runGetAttributesAsync, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } +} + +/** +* @test Create a number of services and proxies and set attributes through them. +* - Register MAXSERVERCOUNT addresses as services +* - Set the attribute for service, at the stub side. +* - Create MAXTHREADCOUNT threads, each of which +* creates a proxy for each service address and +* then sets attributes MAXMETHODCALLS times for each asynchronously +* - Each attribute is MESSAGESIZE bytes long. +* - Test fails if any of the services fail to get registered +* or if any of the proxies won't get available +* or if the callbacks are not called correct number of times +**/ +TEST_F(StabilitySP, MultipleAttributeSetAsyncs) { + std::shared_ptr<StabilitySPStub> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + } + TestInterface::tArray arrayTestValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + testMultiRegisterStub_->setTestValues(arrayTestValue); + + ProxyThread * proxyrunners[MAXTHREADCOUNT]; + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::runSetAttributesAsync, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } +} + +/** +* @test Create a number of services and proxies and set attributes through them. +* - Register MAXSERVERCOUNT addresses as services +* - Set the attribute for service, at the stub side. +* - Create MAXTHREADCOUNT threads, each of which +* creates a proxy for each service address and +* then sets attributes MAXMETHODCALLS times for each asynchronously +* - Each attribute is MESSAGESIZE bytes long. +* - Test fails if any of the services fail to get registered +* or if any of the proxies won't get available +* or if the callbacks are not called correct number of times +**/ +TEST_F(StabilitySP, MultipleAttributeSubscriptions) { + std::shared_ptr<StabilitySPStub> testMultiRegisterStub_; + + testMultiRegisterStub_ = std::make_shared<StabilitySPStub>(); + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId); + ASSERT_TRUE(serviceRegistered_); + } + TestInterface::tArray arrayTestValue; + + for (unsigned int messageindex = 0; messageindex < MESSAGESIZE; messageindex++) { + arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); + } + testMultiRegisterStub_->setTestValues(arrayTestValue); + + ProxyThread * proxyrunners[MAXTHREADCOUNT]; + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount] = new ProxyThread(); + std::thread * thread = new std::thread(std::bind(&ProxyThread::runCreateProxiesAndSubscribe, proxyrunners[threadcount])); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + + // sleep here a while to let the subscriptions sink in + usleep(100000); + + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + std::thread * thread = new std::thread(std::bind(&ProxyThread::runSetSubscribedAttributes, proxyrunners[threadcount], threadcount)); + proxyrunners[threadcount]->setThread(thread); + } + for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) { + proxyrunners[threadcount]->getThread()->join(); + delete proxyrunners[threadcount]->getThread(); + proxyrunners[threadcount]->setThread(0); + } + for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) { + serviceRegistered_ = runtime_->unregisterService( domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount )); + ASSERT_TRUE(serviceRegistered_); + } +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new Environment()); + return RUN_ALL_TESTS(); +} + + diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp new file mode 100644 index 0000000..ae0ff52 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp @@ -0,0 +1,276 @@ +/* Copyright (C) 2014 - 2015 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file Threading +*/ + +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "utils/VerificationMainLoop.h" +#include "v1_0/commonapi/threading/TestInterfaceProxy.hpp" +#include "v1_0/commonapi/threading/TestInterfaceStubDefault.hpp" +#include "utils/VerificationMainLoop.h" + +const std::string domain = "local"; +const std::string instance6 = "my.test.commonapi.address.six"; +const std::string instance7 = "my.test.commonapi.address.seven"; +const std::string instance8 = "my.test.commonapi.address.eight"; +const std::string mainloopName1 = "client-sample"; +const std::string mainloopName2 = "service-sample"; + +class PingPongTestStub : public v1_0::commonapi::threading::TestInterfaceStubDefault { + virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, + uint8_t _x, + testMethodReply_t _reply) { + + _reply(_x); + } +}; + +class MainLoopThreadContext { +public: + void setupRuntime(std::promise<bool>& p) { + runtime_ = CommonAPI::Runtime::get(); + p.set_value(true); + } + + void setupMainLoopContext(std::promise<bool>& p, std::string mainloopName) { + mainLoopContext_ = std::make_shared<CommonAPI::MainLoopContext>(mainloopName); + mainLoop_ = new CommonAPI::VerificationMainLoop(mainLoopContext_); + p.set_value(true); + } + + void setAddresses(const std::string own, const std::string other, const std::string thirdParty) { + ownAddress_ = own; + + otherAddress_ = other; + thirdPartyAddress_ = thirdParty; + } + + void createProxyAndStub() { + stub_ = std::make_shared<PingPongTestStub>(); + + ASSERT_TRUE(runtime_->registerService(domain, ownAddress_, stub_, mainLoopContext_)); + + proxy_ = runtime_->buildProxy<v1_0::commonapi::threading::TestInterfaceProxy>(domain, otherAddress_, mainLoopContext_); + ASSERT_TRUE((bool)proxy_); + + proxyThirdParty_ = runtime_->buildProxy<v1_0::commonapi::threading::TestInterfaceProxy>(domain, thirdPartyAddress_, mainLoopContext_); + ASSERT_TRUE((bool)proxyThirdParty_); + } + + std::shared_ptr<CommonAPI::Runtime> runtime_; + std::shared_ptr<CommonAPI::MainLoopContext> mainLoopContext_; + + std::string ownAddress_, otherAddress_, thirdPartyAddress_; + std::shared_ptr<PingPongTestStub> stub_; + std::shared_ptr<v1_0::commonapi::threading::TestInterfaceProxy<>> proxy_, proxyThirdParty_; + + CommonAPI::VerificationMainLoop* mainLoop_; +}; + +class THMainLoopIndependence: public ::testing::Test { +protected: + void SetUp() { + std::shared_ptr<CommonAPI::Runtime> runtimePtr1_, runtimePtr2_; + + std::promise<bool> promiseRuntime1, promiseRuntime2; + std::future<bool> futureRuntime1 = promiseRuntime1.get_future(); + std::future<bool> futureRuntime2 = promiseRuntime2.get_future(); + + mainLoopThread1_ = std::thread( + std::bind(&MainLoopThreadContext::setupRuntime, &threadCtx1_, std::move(promiseRuntime1))); + mainLoopThread2_ = std::thread( + std::bind(&MainLoopThreadContext::setupRuntime, &threadCtx2_, std::move(promiseRuntime2))); + + mainLoopThread1_.detach(); + mainLoopThread2_.detach(); + + futureRuntime1.wait_for(std::chrono::milliseconds(200)); + futureRuntime2.wait_for(std::chrono::milliseconds(200)); + + // check that both threads have a runtime and it is the same + ASSERT_TRUE((bool)threadCtx1_.runtime_); + ASSERT_TRUE((bool)threadCtx2_.runtime_); + ASSERT_EQ(threadCtx1_.runtime_, threadCtx2_.runtime_); + + std::promise<bool> promiseContext1, promiseContext2; + std::future<bool> futureContext1 = promiseContext1.get_future(); + std::future<bool> futureContext2 = promiseContext2.get_future(); + + mainLoopThread1_ = std::thread( + std::bind( + &MainLoopThreadContext::setupMainLoopContext, + &threadCtx1_, + std::move(promiseContext1), + mainloopName1)); + mainLoopThread2_ = std::thread( + std::bind( + &MainLoopThreadContext::setupMainLoopContext, + &threadCtx2_, + std::move(promiseContext2), + mainloopName2)); + mainLoopThread1_.detach(); + mainLoopThread2_.detach(); + + futureContext1.wait_for(std::chrono::milliseconds(200)); + futureContext2.wait_for(std::chrono::milliseconds(200)); + + // check that both threads have an own mainloop context + ASSERT_TRUE((bool)threadCtx1_.mainLoopContext_); + ASSERT_TRUE((bool)threadCtx2_.mainLoopContext_); + ASSERT_NE(threadCtx1_.mainLoopContext_, threadCtx2_.mainLoopContext_); + + std::promise<bool> promiseFactory1, promiseFactory2; + std::future<bool> futureFactory1 = promiseFactory1.get_future(); + std::future<bool> futureFactory2 = promiseFactory2.get_future(); + + futureFactory1.wait_for(std::chrono::milliseconds(200)); + futureFactory2.wait_for(std::chrono::milliseconds(200)); + + // set addresses + threadCtx1_.setAddresses(instance7, instance8, instance6); + threadCtx2_.setAddresses(instance8, instance7, instance6); + + threadCtx1_.createProxyAndStub(); + threadCtx2_.createProxyAndStub(); + + mainLoopThread1_ = std::thread([&]() { threadCtx1_.mainLoop_->run(); }); + mainLoopThread2_ = std::thread([&]() { threadCtx2_.mainLoop_->run(); }); + + usleep(200000); + + ASSERT_TRUE(threadCtx1_.proxy_->isAvailable()); + ASSERT_TRUE(threadCtx2_.proxy_->isAvailable()); + + if (threadCtx1_.mainLoop_->isRunning()) { + std::future<bool> threadCtx1MainStopped = threadCtx1_.mainLoop_->stop(); + threadCtx1MainStopped.get(); + } + if (threadCtx2_.mainLoop_->isRunning()) { + std::future<bool> threadCtx2MainStopped = threadCtx2_.mainLoop_->stop(); + threadCtx2MainStopped.get(); + } + + mainLoopThread1_.join(); + mainLoopThread2_.join(); + } + + void TearDown() { + threadCtx1_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance6); + threadCtx1_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance7); + threadCtx2_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance8); + usleep(2000); + threadCtx1_.mainLoop_->stop(); + threadCtx2_.mainLoop_->stop(); + + if (threadCtx1_.mainLoop_->isRunning()) { + std::future<bool> threadCtx1MainStopped = threadCtx1_.mainLoop_->stop(); + threadCtx1MainStopped.get(); + } + if (threadCtx2_.mainLoop_->isRunning()) { + std::future<bool> threadCtx2MainStopped = threadCtx2_.mainLoop_->stop(); + threadCtx2MainStopped.get(); + } + + if(mainLoopThread1_.joinable()) { + mainLoopThread1_.join(); + } + if(mainLoopThread2_.joinable()) { + mainLoopThread2_.join(); + } + } + + MainLoopThreadContext threadCtx1_, threadCtx2_; + std::thread mainLoopThread1_, mainLoopThread2_; +}; + +/** +* @test Proxy Receives Answer Only If Stub MainLoop Runs. +* - start proxy in thread 1 and call testPredefinedTypeMethod +* - proxy should not receive answer, if the stub mainloop does not run +* - run mainloop of stub +* - now the stub mainloop also runs, so the proxy should receive the answer +*/ +TEST_F(THMainLoopIndependence, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) { + + CommonAPI::CallStatus callStatus; + + uint8_t x, y; + x = 1; + y = 0; + + std::thread mainLoopRunnerProxy([&]() { threadCtx1_.mainLoop_->runVerification(5, true, true); }); + mainLoopRunnerProxy.detach(); + + mainLoopThread1_ = std::thread([&]() { threadCtx1_.proxy_->testMethod(x, callStatus, y); }); + mainLoopThread1_.detach(); + + usleep(100000); + // proxy should not receive answer, if the stub mainloop does not run + ASSERT_EQ(0, y); + + mainLoopThread2_ = std::thread([&]() { threadCtx2_.mainLoop_->run(); }); + mainLoopThread2_.detach(); + + sleep(1); + + // now the stub mainloop also runs, so the proxy should receive the answer + ASSERT_EQ(1, y); +} + +/** +* @test Proxy Receives Just His Own Answers. +* - start 2 proxies in own threads +* - call test method in each proxy +* - now each proxy should have received the answer to his own request +*/ +TEST_F(THMainLoopIndependence, ProxyReceivesJustHisOwnAnswers) { + + std::shared_ptr<PingPongTestStub> stubThirdParty = std::make_shared<PingPongTestStub>(); + auto runtime = CommonAPI::Runtime::get(); + //ASSERT_TRUE(runtime->getServicePublisher()->registerService(stubThirdParty, testAddress6, runtime->createFactory())); + ASSERT_TRUE(runtime->registerService(domain, instance6, stubThirdParty)); + + CommonAPI::CallStatus callStatusProxy1, callStatusProxy2; + + uint8_t x1, y1, x2, y2; + x1 = 1; + x2 = 2; + y1 = y2 = 0; + + std::thread mainLoopRunnerProxy1([&]() { threadCtx1_.mainLoop_->run(); }); + std::thread mainLoopRunnerProxy2([&]() { threadCtx2_.mainLoop_->run(); }); + mainLoopRunnerProxy1.detach(); + mainLoopRunnerProxy2.detach(); + + // wait until threads are running + while (!threadCtx1_.mainLoop_->isRunning() || !threadCtx2_.mainLoop_->isRunning()) { + usleep(100); + } + + while(!(threadCtx1_.proxyThirdParty_->isAvailable() && threadCtx2_.proxyThirdParty_->isAvailable())) { + usleep(10000); + } + + mainLoopThread1_ = std::thread([&]() { threadCtx1_.proxyThirdParty_->testMethod(x1, callStatusProxy1, y1); }); + mainLoopThread2_ = std::thread([&]() { threadCtx2_.proxyThirdParty_->testMethod(x2, callStatusProxy2, y2); }); + mainLoopThread1_.detach(); + mainLoopThread2_.detach(); + + usleep(1000000); + // now each proxy should have received the answer to his own request + ASSERT_EQ(1, y1); + ASSERT_EQ(2, y2); + + //sleep(1); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp new file mode 100644 index 0000000..69b6fc0 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp @@ -0,0 +1,244 @@ +/* Copyright (C) 2014 - 2015 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * 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/. */ + +/** +* @file Threading +*/ + +#include <gtest/gtest.h> +#include "CommonAPI/CommonAPI.hpp" +#include "utils/VerificationMainLoop.h" +#include "v1_0/commonapi/threading/TestInterfaceProxy.hpp" +#include "utils/VerificationMainLoop.h" +#include "stub/THMainLoopIntegrationStub.h" + +const std::string domain = "local"; +const std::string instance = "my.test.commonapi.address"; +const std::string connection_client = "client-sample"; +const std::string connection_service = "service-sample"; + +class THMainLoopIntegration: public ::testing::Test { + +protected: + void SetUp() { + + runtime_ = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool) runtime_); + + contextForProxy_ = std::make_shared<CommonAPI::MainLoopContext>(connection_client); + contextForStub_ = std::make_shared<CommonAPI::MainLoopContext>(connection_service); + + ASSERT_TRUE((bool) contextForProxy_); + ASSERT_TRUE((bool) contextForStub_); + ASSERT_FALSE(contextForProxy_ == contextForStub_); + + mainLoopForProxy_ = new CommonAPI::VerificationMainLoop(contextForProxy_); + mainLoopForStub_ = new CommonAPI::VerificationMainLoop(contextForStub_); + + testStub_ = std::make_shared<v1_0::commonapi::threading::THMainLoopIntegrationStub>(); + serviceRegistered_ = runtime_->registerService(domain, instance, testStub_, contextForStub_); + ASSERT_TRUE(serviceRegistered_); + + testProxy_ = runtime_->buildProxy<v1_0::commonapi::threading::TestInterfaceProxy>(domain, instance, contextForProxy_); + ASSERT_TRUE((bool) testProxy_); + + callbackCalled_ = 0; + lastBroadcastNumber_ = 0; + outInt_ = 0; + } + + void TearDown() { + runtime_->unregisterService(domain, v1_0::commonapi::threading::THMainLoopIntegrationStub::StubInterface::getInterface(), instance); + + if (mainLoopForProxy_->isRunning()) { + std::future<bool> proxyStopped = mainLoopForProxy_->stop(); + // synchronisation with stopped mainloop + proxyStopped.get(); + } + if (mainLoopForStub_->isRunning()) { + std::future<bool> stubStopped = mainLoopForStub_->stop(); + // synchronisation with stopped mainloop + stubStopped.get(); + } + + usleep(200); + delete mainLoopForProxy_; + delete mainLoopForStub_; + } + + bool serviceRegistered_; + + std::shared_ptr<CommonAPI::Runtime> runtime_; + + std::shared_ptr<CommonAPI::MainLoopContext> contextForProxy_; + std::shared_ptr<CommonAPI::MainLoopContext> contextForStub_; + std::shared_ptr<CommonAPI::Factory> mainloopFactoryProxy_; + std::shared_ptr<CommonAPI::Factory> mainloopFactoryStub_; + + CommonAPI::VerificationMainLoop* mainLoopForProxy_; + CommonAPI::VerificationMainLoop* mainLoopForStub_; + + std::shared_ptr<v1_0::commonapi::threading::TestInterfaceProxy<>> testProxy_; + std::shared_ptr<v1_0::commonapi::threading::THMainLoopIntegrationStub> testStub_; + + int callbackCalled_; + uint8_t lastBroadcastNumber_; + int outInt_; + +public: + void broadcastCallback(uint8_t value) { + + // check correct order + lastBroadcastNumber_++; + ASSERT_EQ(lastBroadcastNumber_, value); + } +}; + +/** +* @test Verifies Transport Reading When Dispatching Watches. +* - get proxy with available flag = true +* - generate big test data +* - send asynchronous test message +* - dispatch dispatchSource: the message must not be arrived +* - dispatch watches (reads transport). +* - dispatch dispatchSources again: now the message must be arrived. +*/ +TEST_F(THMainLoopIntegration, VerifyCommunicationWithMainLoop) { + + std::thread proxyThread; + std::thread stubThread; + proxyThread = std::thread([&](){ mainLoopForProxy_->run(); }); + stubThread = std::thread([&](){ mainLoopForStub_->run(); }); + proxyThread.detach(); + stubThread.detach(); + + // wait until threads are running + while (!mainLoopForProxy_->isRunning() || !mainLoopForStub_->isRunning()) { + usleep(100); + } + + for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { + usleep(10000); + } + ASSERT_TRUE(testProxy_->isAvailable()); + + uint8_t x = 5; + uint8_t y = 0; + CommonAPI::CallStatus callStatus; + + testProxy_->testMethod(x, callStatus, y); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(x, y); +} + +/** +* @test Verifies Transport Reading When Dispatching Watches. +* - get proxy with available flag = true +* - generate big test data +* - send asynchronous test message +* - dispatch dispatchSource: the message must not be arrived +* - dispatch watches (reads transport). +* - dispatch dispatchSources again: now the message must be arrived. +*/ +TEST_F(THMainLoopIntegration, VerifyTransportReading) { + + std::thread proxyThread = std::thread([&](){ mainLoopForProxy_->run(); }); + std::thread stubThread = std::thread([&](){ mainLoopForStub_->run(); }); + proxyThread.detach(); + + // wait until threads are running + while (!mainLoopForProxy_->isRunning() || !mainLoopForStub_->isRunning()) { + usleep(100); + } + + for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { + usleep(10000); + } + ASSERT_TRUE(testProxy_->isAvailable()); + + if (mainLoopForStub_->isRunning()) { + std::future<bool> stubStopped = mainLoopForStub_->stop(); + // synchronisation with stopped mainloop + stubStopped.get(); + } + if (stubThread.joinable()) { + stubThread.join(); + } + + uint8_t x = 5; + uint8_t y = 0; + + std::future<CommonAPI::CallStatus> futureStatus = testProxy_->testMethodAsync(x, + [&] (const CommonAPI::CallStatus& status, uint8_t y) { + callbackCalled_++; + } + ); + + // 1. just dispatch watches (reads transport) + mainLoopForStub_->runVerification(1, true, false); + usleep(10000); + EXPECT_EQ(testStub_->x_, 0); + + // 2. just dispatch dispatchSources. This should dispatch the messages already read from transport in 1. + mainLoopForStub_->doVerificationIteration(false, true); + EXPECT_EQ(testStub_->x_, x); +} + +/** +* @test Verifies Synchronous Call Message Handling Order. +* - get proxy with available flag = true +* - subscribe for broadcast event +* - generate 5 test broadcasts +* - 5 broadcasts should arrive in the right order +*/ +TEST_F(THMainLoopIntegration, VerifySyncCallMessageHandlingOrder) { + + std::thread stubThread = std::thread([&](){ mainLoopForStub_->run(3000); }); + + // wait until thread is running + while (!mainLoopForStub_->isRunning()) { + usleep(100); + } + + for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { + mainLoopForProxy_->doSingleIteration(3000); + usleep(10000); + } + ASSERT_TRUE(testProxy_->isAvailable()); + + auto& broadcastEvent = testProxy_->getTestBroadcastEvent(); + broadcastEvent.subscribe(std::bind(&THMainLoopIntegration::broadcastCallback, this, std::placeholders::_1)); + + uint8_t x = 5; + uint8_t y = 0; + CommonAPI::CallStatus callStatus; + + testProxy_->testMethod(x, callStatus, y); + + for(unsigned int i = 0; i < 100; ++i) { + mainLoopForProxy_->doSingleIteration(30); + usleep(10000); + } + + sleep(2); + + if (mainLoopForStub_->isRunning()) { + std::future<bool> stubStopped = mainLoopForStub_->stop(); + // synchronisation with stopped mainloop + stubStopped.get(); + } + if (stubThread.joinable()) { + stubThread.join(); + } + + // in total 5 broadcasts should have been arrived + ASSERT_EQ(lastBroadcastNumber_, 5); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in b/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in new file mode 100644 index 0000000..fb35209 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in @@ -0,0 +1,44 @@ +[default] +binding=dbus + +[logging] +console = false +level = warning + +[proxy] +local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.combined.TestInterface:commonapi.datatypes.combined.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.performance.primitive.TestInterface:commonapi.performance.primitive.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.performance.complex.TestInterface:commonapi.performance.complex.TestInterface=@GLUECODE_SO_DBUS@ + +local:commonapi.threading.TestInterface:my.test.commonapi.address=@GLUECODE_SO_DBUS@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.six=@GLUECODE_SO_DBUS@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.seven=@GLUECODE_SO_DBUS@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.eight=@GLUECODE_SO_DBUS@ + +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.stability.mp.TestInterface:commonapi.stability.mp.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.stability.mp.ControlInterface:commonapi.stability.mp.ControlInterface=@GLUECODE_SO_DBUS@ + +[stub] +local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.datatypes.combined.TestInterface:commonapi.datatypes.combined.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.performance.primitive.TestInterface:commonapi.performance.primitive.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.performance.complex.TestInterface:commonapi.performance.complex.TestInterface=@GLUECODE_SO_DBUS@ + +local:commonapi.threading.TestInterface:my.test.commonapi.address=@GLUECODE_SO_DBUS@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.six=@GLUECODE_SO_DBUS@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.seven=@GLUECODE_SO_DBUS@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.eight=@GLUECODE_SO_DBUS@ + +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.stability.mp.TestInterface:commonapi.stability.mp.TestInterface=@GLUECODE_SO_DBUS@ +local:commonapi.stability.mp.ControlInterface:commonapi.stability.mp.ControlInterface=@GLUECODE_SO_DBUS@ diff --git a/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in b/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in new file mode 100644 index 0000000..7bc55f8 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in @@ -0,0 +1,121 @@ +[default] +binding=someip + +[proxy] +local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.combined.TestInterface:commonapi.datatypes.combined.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.performance.primitive.TestInterface:commonapi.performance.primitive.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.performance.complex.TestInterface:commonapi.performance.complex.TestInterface=@GLUECODE_SO_SOMEIP@ + +local:commonapi.threading.TestInterface:my.test.commonapi.address=@GLUECODE_SO_SOMEIP@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.six=@GLUECODE_SO_SOMEIP@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.seven=@GLUECODE_SO_SOMEIP@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.eight=@GLUECODE_SO_SOMEIP@ + +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface0=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface1=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface2=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface3=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface4=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface5=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface6=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface7=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface8=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface9=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface10=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface11=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface12=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface13=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface14=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface15=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface16=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface17=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface18=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface19=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface20=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface21=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface22=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface23=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface24=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface25=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface26=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface27=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface28=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface29=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface30=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface31=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface32=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface33=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface34=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface35=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface36=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface37=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface38=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface39=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.mp.TestInterface:commonapi.stability.mp.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.mp.ControlInterface:commonapi.stability.mp.ControlInterface=@GLUECODE_SO_SOMEIP@ + +[stub] +local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.datatypes.combined.TestInterface:commonapi.datatypes.combined.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.performance.primitive.TestInterface:commonapi.performance.primitive.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.performance.complex.TestInterface:commonapi.performance.complex.TestInterface=@GLUECODE_SO_SOMEIP@ + +local:commonapi.threading.TestInterface:my.test.commonapi.address=@GLUECODE_SO_SOMEIP@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.six=@GLUECODE_SO_SOMEIP@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.seven=@GLUECODE_SO_SOMEIP@ +local:commonapi.threading.TestInterface:my.test.commonapi.address.eight=@GLUECODE_SO_SOMEIP@ + +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface0=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface1=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface2=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface3=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface4=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface5=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface6=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface7=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface8=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface9=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface10=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface11=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface12=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface13=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface14=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface15=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface16=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface17=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface18=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface19=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface20=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface21=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface22=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface23=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface24=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface25=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface26=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface27=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface28=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface29=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface30=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface31=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface32=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface33=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface34=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface35=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface36=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface37=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface38=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.sp.TestInterface:commonapi.stability.sp.TestInterface39=@GLUECODE_SO_SOMEIP@ + +local:commonapi.stability.mp.TestInterface:commonapi.stability.mp.TestInterface=@GLUECODE_SO_SOMEIP@ +local:commonapi.stability.mp.ControlInterface:commonapi.stability.mp.ControlInterface=@GLUECODE_SO_SOMEIP@ diff --git a/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp new file mode 100644 index 0000000..97eb137 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <iostream> +#include "CMAttributesStub.h" + +namespace v1_0 { +namespace commonapi { +namespace communication { + +CMAttributesStub::CMAttributesStub() { +} + +CMAttributesStub::~CMAttributesStub() { +} + +void CMAttributesStub::setTestValues(uint8_t x) { + + setTestAttributeAttribute(x); + setTestAAttribute(x); + setTestBAttribute(x); + setTestCAttribute(x); +} + +} /* namespace v1_0 */ +} /* namespace communication */ +} /* namespace commonapi */ + diff --git a/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h new file mode 100644 index 0000000..3de45f0 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef CMATTRIBUTESSTUB_H_ +#define CMATTRIBUTESSTUB_H_ + +#include "v1_0/commonapi/communication/TestInterfaceStubDefault.hpp" + +namespace v1_0 { +namespace commonapi { +namespace communication { + +class CMAttributesStub : public v1_0::commonapi::communication::TestInterfaceStubDefault { +public: + CMAttributesStub(); + virtual ~CMAttributesStub(); + virtual void setTestValues(uint8_t); +}; + +} /* namespace v1_0 */ +} /* namespace communication */ +} /* namespace commonapi */ + +#endif /* CMATTRIBUTESSTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp new file mode 100644 index 0000000..533f458 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp @@ -0,0 +1,32 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <iostream> +#include "CMMethodCallsStub.h" + +namespace v1_0 { +namespace commonapi { +namespace communication { + +CMMethodCallsStub::CMMethodCallsStub() { +} + +CMMethodCallsStub::~CMMethodCallsStub() { +} + +void CMMethodCallsStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x, + testMethodReply_t _reply) { + uint8_t y; + + std::cout << "testMethod called." << std::endl; + y = x; + _reply(y); +} + +} /* namespace v1_0 */ +} /* namespace communication */ +} /* namespace commonapi */ + diff --git a/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h new file mode 100644 index 0000000..d26d71c --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h @@ -0,0 +1,29 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef CMMETHODCALLSSTUB_H_ +#define CMMETHODCALLSSTUB_H_ + +#include "v1_0/commonapi/communication/TestInterfaceStubDefault.hpp" + +namespace v1_0 { +namespace commonapi { +namespace communication { + +class CMMethodCallsStub : public v1_0::commonapi::communication::TestInterfaceStubDefault { +public: + CMMethodCallsStub(); + virtual ~CMMethodCallsStub(); + + void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x, + testMethodReply_t _reply); +}; + +} /* namespace v1_0 */ +} /* namespace communication */ +} /* namespace commonapi */ + +#endif /* CMMETHODCALLSSTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp new file mode 100644 index 0000000..f21554b --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp @@ -0,0 +1,55 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "DTAdvancedStub.h" +#include <unistd.h> + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace advanced { + +using namespace commonapi::datatypes::advanced; + +DTAdvancedStub::DTAdvancedStub() { +} + +DTAdvancedStub::~DTAdvancedStub() { +} + +void DTAdvancedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tArray tArrayIn, + TestInterface::tEnumeration tEnumerationIn, + TestInterface::tStruct tStructIn, + TestInterface::tUnion tUnionIn, + TestInterface::tMap tMapIn, + TestInterface::tTypedef tTypedefIn, + fTestReply_t _reply) { + + + TestInterface::tArray tArrayOut = tArrayIn; + TestInterface::tEnumeration tEnumerationOut = tEnumerationIn; + TestInterface::tStruct tStructOut = tStructIn; + TestInterface::tUnion tUnionOut = tUnionIn; + TestInterface::tMap tMapOut = tMapIn; + TestInterface::tTypedef tTypedefOut = tTypedefIn; + + _reply(tArrayOut, tEnumerationOut, tStructOut, tUnionOut, tMapOut, tTypedefOut); + + fireBTestEvent( + tArrayOut, + tEnumerationOut, + tStructOut, + tUnionOut, + tMapOut, + tTypedefOut + ); +} + +} /* namespace advanced */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h new file mode 100644 index 0000000..e7e1eb9 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DTADVANCEDSTUB_H_ +#define DTADVANCEDSTUB_H_ + +#include "v1_0/commonapi/datatypes/advanced/TestInterfaceStubDefault.hpp" +#include "v1_0/commonapi/datatypes/advanced/TestInterface.hpp" + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace advanced { + +using namespace v1_0::commonapi::datatypes::advanced; + +class DTAdvancedStub : public TestInterfaceStubDefault { + +public: + DTAdvancedStub(); + virtual ~DTAdvancedStub(); + + virtual void fTest(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tArray tArrayIn, + TestInterface::tEnumeration tEnumerationIn, + TestInterface::tStruct tStructIn, + TestInterface::tUnion tUnionIn, TestInterface::tMap tMapIn, + TestInterface::tTypedef tTypedefIn, + fTestReply_t _reply); +}; + +} /* namespace advanced */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ +#endif /* DTADVANCEDSTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp new file mode 100644 index 0000000..f347026 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "DTCombinedStub.h" + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace combined { + +using namespace v1_0::commonapi::datatypes::combined; + +DTCombinedStub::DTCombinedStub(){ +} + +DTCombinedStub::~DTCombinedStub(){ +} + +void DTCombinedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> _client, + TestInterface::tStructL3 _tStructL3In, fTestReply_t _reply) +{ + _reply(_tStructL3In); +} + +} /* namespace combined */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h new file mode 100644 index 0000000..6d94c39 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DTCOMBINEDSTUB_H_ +#define DTCOMBINEDSTUB_H_ + +#include "v1_0/commonapi/datatypes/combined/TestInterfaceStubDefault.hpp" +#include "v1_0/commonapi/datatypes/combined/TestInterface.hpp" + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace combined { + +using namespace v1_0::commonapi::datatypes::combined; + +class DTCombinedStub : public TestInterfaceStubDefault { + +public: + DTCombinedStub(); + virtual ~DTCombinedStub(); + + virtual void fTest(const std::shared_ptr<CommonAPI::ClientId> _client, + TestInterface::tStructL3 _tStructL3In, + fTestReply_t _reply); +}; + +} /* namespace combined */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ +#endif /* DTCOMBINEDSTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp new file mode 100644 index 0000000..7d6460b --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp @@ -0,0 +1,48 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "DTDerivedStub.h" +#include <unistd.h> + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace derived { + +using namespace v1_0::commonapi::datatypes::derived; + +DTDerivedStub::DTDerivedStub() { +} + +DTDerivedStub::~DTDerivedStub() { +} + +void DTDerivedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tStructExt tStructExtIn, + TestInterface::tEnumExt tEnumExtIn, + TestInterface::tUnionExt tUnionExtIn, + std::shared_ptr<TestInterface::tBaseStruct> tBaseStructIn, + fTestReply_t _reply) { + + TestInterface::tStructExt tStructExtOut = tStructExtIn; + TestInterface::tEnumExt tEnumExtOut = tEnumExtIn; + TestInterface::tUnionExt tUnionExtOut = tUnionExtIn; + std::shared_ptr<TestInterface::tBaseStruct> tBaseStructOut = tBaseStructIn; + + _reply(tStructExtOut, tEnumExtOut, tUnionExtOut, tBaseStructOut); + + fireBTestEvent( + tStructExtOut, + tEnumExtOut, + tUnionExtOut, + tBaseStructOut + ); +} + +} /* namespace derived */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h new file mode 100644 index 0000000..cadd627 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DTDERIVEDSTUB_H_ +#define DTDERIVEDSTUB_H_ + +#include "v1_0/commonapi/datatypes/derived/TestInterfaceStubDefault.hpp" +#include "v1_0/commonapi/datatypes/derived/TestInterface.hpp" + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace derived { + +using namespace v1_0::commonapi::datatypes::derived; + +class DTDerivedStub : public TestInterfaceStubDefault { + +public: + DTDerivedStub(); + virtual ~DTDerivedStub(); + + virtual void fTest(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tStructExt tStructExtIn, + TestInterface::tEnumExt tEnumExtIn, + TestInterface::tUnionExt tUnionExtIn, + std::shared_ptr<TestInterface::tBaseStruct> tBaseStructIn, + fTestReply_t _reply); +}; + +} /* namespace derived */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ +#endif /* DTDERIVEDSTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp new file mode 100644 index 0000000..c040e9a --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp @@ -0,0 +1,67 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "DTPrimitiveStub.h" +#include <unistd.h> + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace primitive { + +DTPrimitiveStub::DTPrimitiveStub() { +} + +DTPrimitiveStub::~DTPrimitiveStub() { +} + +void DTPrimitiveStub::fTest(const std::shared_ptr<CommonAPI::ClientId> _client, + uint8_t _uint8In, + int8_t _int8In, + uint16_t _uint16In, + int16_t _int16In, + uint32_t _uint32In, + int32_t _int32In, + uint64_t _uint64In, + int64_t _int64In, + bool _booleanIn, + float _floatIn, + double _doubleIn, + std::string _stringIn, + fTestReply_t _reply) { + _reply(_uint8In, + _int8In, + _uint16In, + _int16In, + _uint32In, + _int32In, + _uint64In, + _int64In, + _booleanIn, + _floatIn, + _doubleIn, + _stringIn); + + fireBTestEvent( + _uint8In, + _int8In, + _uint16In, + _int16In, + _uint32In, + _int32In, + _uint64In, + _int64In, + _booleanIn, + _floatIn, + _doubleIn, + _stringIn + ); +} + +} /* namespace primitive */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ diff --git a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h new file mode 100644 index 0000000..ddc6b86 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h @@ -0,0 +1,29 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DTPRIMITIVESTUB_H_ +#define DTPRIMITIVESTUB_H_ + +#include "v1_0/commonapi/datatypes/primitive/TestInterfaceStubDefault.hpp" + +namespace v1_0 { +namespace commonapi { +namespace datatypes { +namespace primitive { + +class DTPrimitiveStub : public v1_0::commonapi::datatypes::primitive::TestInterfaceStubDefault { +public: + DTPrimitiveStub(); + virtual ~DTPrimitiveStub(); + + virtual void fTest(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _uint8In, int8_t _int8In, uint16_t _uint16In, int16_t _int16In, uint32_t _uint32In, int32_t _int32In, uint64_t _uint64In, int64_t _int64In, bool _booleanIn, float _floatIn, double _doubleIn, std::string _stringIn, fTestReply_t _reply); +}; + +} /* namespace primitive */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ +#endif /* DTPRIMITIVESTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp new file mode 100644 index 0000000..9a4e64d --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp @@ -0,0 +1,37 @@ +/* Copyright (C) 2015 Mentor Graphics + * Author: Felix Scherzinger (felix_scherzinger@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <iostream> + +#include "PFComplexStub.h" + +namespace v1_0 { +namespace commonapi { +namespace performance { +namespace complex { + + +PFComplexStub::PFComplexStub() { + +} + +PFComplexStub::~PFComplexStub() { + +} + +void PFComplexStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, TestInterface::tArray x, testMethodReply_t _reply) { + + TestInterface::tArray y; + + // Copy array! + y = x; + _reply(y); +} + +} /* namespace complex */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ diff --git a/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h new file mode 100644 index 0000000..e261911 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h @@ -0,0 +1,30 @@ +/* Copyright (C) 2015 Mentor Graphics + * Author: Felix Scherzinger (felix_scherzinger@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef PFCOMPLEXSTUB_H_ +#define PFCOMPLEXSTUB_H_ + +#include "v1_0/commonapi/performance/complex/TestInterfaceStubDefault.hpp" + +namespace v1_0 { +namespace commonapi { +namespace performance { +namespace complex { + +class PFComplexStub : public TestInterfaceStubDefault { +public: + PFComplexStub(); + virtual ~PFComplexStub(); + + virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, TestInterface::tArray x, testMethodReply_t _reply); +}; + +} /* namespace complex */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ + +#endif /* PFCOMPLEXSTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp new file mode 100644 index 0000000..107d04b --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp @@ -0,0 +1,39 @@ +/* Copyright (C) 2015 Mentor Graphics + * Author: Felix Scherzinger (felix_scherzinger@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <iostream> + +#include "PFPrimitiveStub.h" + +namespace v1_0 { +namespace commonapi { +namespace performance { +namespace primitive { + + +PFPrimitiveStub::PFPrimitiveStub() { + +} + +PFPrimitiveStub::~PFPrimitiveStub() { + +} + +void PFPrimitiveStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::TestArray x, testMethodReply_t _reply) { + + TestInterface::TestArray y; + + // Copy array! + y = x; + _reply(y); +} + +} /* namespace primitive */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ + diff --git a/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h new file mode 100644 index 0000000..f6595f6 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h @@ -0,0 +1,30 @@ +/* Copyright (C) 2015 Mentor Graphics + * Author: Felix Scherzinger (felix_scherzinger@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef PFPRIMITIVESTUB_H_ +#define PFPRIMITIVESTUB_H_ + +#include "v1_0/commonapi/performance/primitive/TestInterfaceStubDefault.hpp" + +namespace v1_0 { +namespace commonapi { +namespace performance { +namespace primitive { + +class PFPrimitiveStub : public TestInterfaceStubDefault { +public: + PFPrimitiveStub(); + virtual ~PFPrimitiveStub(); + + virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, TestInterface::TestArray x, testMethodReply_t _reply); +}; + +} /* namespace primitive */ +} /* namespace datatypes */ +} /* namespace commonapi */ +} /* namespace v1_0 */ + +#endif /* PFPRIMITIVESTUB_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp new file mode 100644 index 0000000..35c390d --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp @@ -0,0 +1,55 @@ +/* Copyright (C) 2015 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <iostream> +#include "StabControlStub.h" +#include <unistd.h> + +namespace v1_0 { +namespace commonapi { +namespace stability { +namespace mp { + +using namespace v1_0::commonapi::stability::mp; + +StabControlStub::StabControlStub() { +} + +StabControlStub::~StabControlStub() { +} + +CommandListener StabControlStub::listener_ = 0; + + +void StabControlStub::controlMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + uint8_t id, + uint32_t data, + controlMethodReply_t _reply) +{ + // client sends commands and responses through this interface. + // call the listener with the data. + uint8_t command; + uint32_t min; + uint32_t max; + + if (StabControlStub::listener_) { + StabControlStub::listener_(id, data, command, min, max); + } + _reply(command, min, max); + +} + +void StabControlStub::registerListener(CommandListener listener ) { + StabControlStub::listener_ = listener; +} + +} /* namespace v1_0 */ +} /* namespace mp */ +} /* namespace stability */ +} /* namespace commonapi */ + + + diff --git a/org.genivi.commonapi.core.verification/src/stub/StabControlStub.h b/org.genivi.commonapi.core.verification/src/stub/StabControlStub.h new file mode 100644 index 0000000..7b844a4 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/StabControlStub.h @@ -0,0 +1,45 @@ +/* Copyright (C) 2014 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef STABCONTROLSTUB_H_ +#define STABCONTROLSTUB_H_ + +#include "v1_0/commonapi/stability/mp/ControlInterfaceStubDefault.hpp" +#include "v1_0/commonapi/stability/mp/ControlInterface.hpp" + +namespace v1_0 { +namespace commonapi { +namespace stability { +namespace mp { + +using namespace v1_0::commonapi::stability::mp; + +typedef std::function<void (uint8_t id, uint32_t data, uint8_t& command, uint32_t& data1, uint32_t &data2)> CommandListener; + +class StabControlStub : public ControlInterfaceStubDefault { + +public: + StabControlStub(); + virtual ~StabControlStub(); + + virtual void controlMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + uint8_t id, + uint32_t data, + controlMethodReply_t _reply); + + static void registerListener(CommandListener listener); + + static CommandListener listener_; + +}; + +} /* namespace v1_0 */ +} /* namespace mp */ +} /* namespace stability */ +} /* namespace commonapi */ +#endif /* STABCONTROLSTUB_H_ */ + + diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp new file mode 100644 index 0000000..482acbd --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp @@ -0,0 +1,45 @@ +/* Copyright (C) 2015 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "StabilityMPStub.h" +#include <unistd.h> + +namespace v1_0 { +namespace commonapi { +namespace stability { +namespace mp { + +using namespace v1_0::commonapi::stability::mp; + +StabilityMPStub::StabilityMPStub() { +} + +StabilityMPStub::~StabilityMPStub() { +} + +void StabilityMPStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tArray tArrayIn, + testMethodReply_t _reply) { + + TestInterface::tArray tArrayOut; + tArrayOut = tArrayIn; + + fireTestBroadcastEvent( + tArrayOut + ); + _reply(tArrayOut); +} + +void StabilityMPStub::setTestValues(TestInterface::tArray x) { + setTestAttributeAttribute(x); +} + +} /* namespace v1_0 */ +} /* namespace mp */ +} /* namespace stability */ +} /* namespace commonapi */ + + diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.h b/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.h new file mode 100644 index 0000000..328f047 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2015 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef STABILITYMPSTUB_H_ +#define STABILITYMPSTUB_H_ + +#include "v1_0/commonapi/stability/mp/TestInterfaceStubDefault.hpp" +#include "v1_0/commonapi/stability/mp/TestInterface.hpp" + +namespace v1_0 { +namespace commonapi { +namespace stability { +namespace mp { + +class StabilityMPStub : public TestInterfaceStubDefault { + +public: + StabilityMPStub(); + virtual ~StabilityMPStub(); + + virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tArray tArrayIn, + testMethodReply_t _reply); + virtual void setTestValues(TestInterface::tArray x); +}; + +} /* namespace v1_0 */ +} /* namespace mp */ +} /* namespace stability */ +} /* namespace commonapi */ +#endif /* STABILITYMPSTUB_H_ */ + diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp new file mode 100644 index 0000000..59e89b6 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp @@ -0,0 +1,49 @@ +/* Copyright (C) 2015 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "StabilitySPStub.h" +#include <unistd.h> + +namespace v1_0 { +namespace commonapi { +namespace stability { +namespace sp { + +using namespace v1_0::commonapi::stability::sp; + +StabilitySPStub::StabilitySPStub() { +} + +StabilitySPStub::~StabilitySPStub() { +} + +void StabilitySPStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tArray tArrayIn, + testMethodReply_t _reply) { + + TestInterface::tArray tArrayOut; + + tArrayOut = tArrayIn; + + fireTestBroadcastEvent( + tArrayIn + ); + + _reply(tArrayOut); + + +} + +void StabilitySPStub::setTestValues(TestInterface::tArray x) { + setTestAttributeAttribute(x); +} + +} /* namespace v1_0 */ +} /* namespace sp */ +} /* namespace stability */ +} /* namespace commonapi */ + + diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h new file mode 100644 index 0000000..86b8c3c --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2015 BMW Group + * Author: JP Ikaheimonen (jp_ikaheimonen@mentor.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef STABILITYSPSTUB_H_ +#define STABILITYSPSTUB_H_ + +#include "v1_0/commonapi/stability/sp/TestInterfaceStubDefault.hpp" +#include "v1_0/commonapi/stability/sp/TestInterface.hpp" + +namespace v1_0 { +namespace commonapi { +namespace stability { +namespace sp { + +class StabilitySPStub : public TestInterfaceStubDefault { + +public: + StabilitySPStub(); + virtual ~StabilitySPStub(); + + virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, + TestInterface::tArray _x, + testMethodReply_t _reply); + virtual void setTestValues(TestInterface::tArray x); +}; + +} /* namespace v1_0 */ +} /* namespace sp */ +} /* namespace stability */ +} /* namespace commonapi */ +#endif /* STABILITYSPSTUB_H_ */ + diff --git a/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp new file mode 100644 index 0000000..794f6ab --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp @@ -0,0 +1,43 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <iostream> +#include "THMainLoopIntegrationStub.h" + +namespace v1_0 { +namespace commonapi { +namespace threading { + +THMainLoopIntegrationStub::THMainLoopIntegrationStub() { + x_ = 0; +} + +THMainLoopIntegrationStub::~THMainLoopIntegrationStub() { +} + +void THMainLoopIntegrationStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x, testMethodReply_t _reply) { + + uint8_t y = x; + x_ = x; + + uint8_t broadcastNumber = 0; + broadcastNumber++; + fireTestBroadcastEvent(broadcastNumber); + broadcastNumber++; + fireTestBroadcastEvent(broadcastNumber); + broadcastNumber++; + fireTestBroadcastEvent(broadcastNumber); + broadcastNumber++; + fireTestBroadcastEvent(broadcastNumber); + broadcastNumber++; + fireTestBroadcastEvent(broadcastNumber); + + _reply(y); +} + +} /* namespace threading */ +} /* namespace commonapi */ +} /* namespace v1_0 */ diff --git a/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h new file mode 100644 index 0000000..1747af2 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h @@ -0,0 +1,30 @@ +/* Copyright (C) 2014 BMW Group + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef THMAINLOOPINTEGRATION_H_ +#define THMAINLOOPINTEGRATION_H_ + +#include "v1_0/commonapi/threading/TestInterfaceStubDefault.hpp" + +namespace v1_0 { +namespace commonapi { +namespace threading { + +class THMainLoopIntegrationStub : public TestInterfaceStubDefault { +public: + THMainLoopIntegrationStub(); + virtual ~THMainLoopIntegrationStub(); + + void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x, testMethodReply_t _reply); + + uint8_t x_; +}; + +} /* namespace threading */ +} /* namespace commonapi */ +} /* namespace v1_0 */ + +#endif /* THMAINLOOPINTEGRATION_H_ */ diff --git a/org.genivi.commonapi.core.verification/src/test-derived-types.fidl b/org.genivi.commonapi.core.verification/src/test-derived-types.fidl deleted file mode 100644 index da82e80..0000000 --- a/org.genivi.commonapi.core.verification/src/test-derived-types.fidl +++ /dev/null @@ -1,60 +0,0 @@ -/* 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/. */ -package commonapi.tests - -import commonapi.tests.* from "test-predefined-types.fidl" - -typeCollection DerivedTypeCollection { - - map TestMap { UInt32 to TestArrayTestStruct } - - struct TestStructExtended extends TestStruct { - TestEnumExtended2 testEnumExtended2 - } - - map TestEnumMap { TestEnum to String } - - <** @description : Common errors. **> - enumeration TestEnum { - <** @description : default **> - E_UNKNOWN = "0x00" - <** @description : no error - positive reply **> - E_OK = "0x01" - <** @description : value out of range **> - E_OUT_OF_RANGE = "0x02" - <** @description : not used **> - E_NOT_USED = "0x03" - } - - array TestArrayTestStruct of TestStruct - - enumeration TestEnumExtended2 extends TestEnumExtended { - <** @description : new error **> - E_NEW2 = "0x05" - } - - enumeration TestEnumMissingValue { - <** @description : default **> - E1 = "A" - E2 - E3 = "2" - } - - enumeration TestEnumExtended extends TestEnum { - <** @description : new error **> - E_NEW = "0x04" - } - - array TestArrayUInt64 of UInt64 - - struct TestStruct { - <** @description : the name of the property **> - PredefinedTypeCollection.TestString testString - - <** @description : the actual value **> - UInt16 uintValue - } -} - - diff --git a/org.genivi.commonapi.core.verification/src/test-interface-proxy.fidl b/org.genivi.commonapi.core.verification/src/test-interface-proxy.fidl deleted file mode 100644 index 774c1a8..0000000 --- a/org.genivi.commonapi.core.verification/src/test-interface-proxy.fidl +++ /dev/null @@ -1,61 +0,0 @@ -/* 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/. */ -package commonapi.tests - -import commonapi.tests.* from "test-derived-types.fidl" - -interface TestInterface { - version { major 1 minor 0 } - - attribute UInt32 TestPredefinedTypeAttribute - attribute DerivedTypeCollection.TestStructExtended TestDerivedStructAttribute - attribute DerivedTypeCollection.TestArrayUInt64 TestDerivedArrayAttribute - - method testEmptyMethod { - } - - method testVoidPredefinedTypeMethod { - in { - UInt32 uint32Value - String stringValue - } - } - - method testPredefinedTypeMethod { - in { - UInt32 uint32InValue - String stringInValue - } - out { - UInt32 uint32OutValue - String stringOutValue - } - } - - method testVoidDerivedTypeMethod { - in { - DerivedTypeCollection.TestEnumExtended2 testEnumExtended2Value - DerivedTypeCollection.TestMap testMapValue - } - } - - method testDerivedTypeMethod { - in { - DerivedTypeCollection.TestEnumExtended2 testEnumExtended2InValue - DerivedTypeCollection.TestMap testMapInValue - } - out { - DerivedTypeCollection.TestEnumExtended2 testEnumExtended2OutValue - DerivedTypeCollection.TestMap testMapOutValue - } - } - - broadcast TestPredefinedTypeBroadcast { - out { - UInt32 uint32Value - String stringValue - } - } -} - diff --git a/org.genivi.commonapi.core.verification/src/test-predefined-types.fidl b/org.genivi.commonapi.core.verification/src/test-predefined-types.fidl deleted file mode 100644 index 6226ed2..0000000 --- a/org.genivi.commonapi.core.verification/src/test-predefined-types.fidl +++ /dev/null @@ -1,22 +0,0 @@ -/* 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/. */ -package commonapi.tests - -typeCollection PredefinedTypeCollection { - typedef TestUInt8 is UInt8 - typedef TestUInt16 is UInt16 - typedef TestUInt32 is UInt32 - typedef TestUInt64 is UInt64 - typedef TestInt8 is Int8 - typedef TestInt16 is Int16 - typedef TestInt32 is Int32 - typedef TestInt64 is Int64 - typedef TestBoolean is Boolean - typedef TestByteBuffer is ByteBuffer - typedef TestDouble is Double - typedef TestFloat is Float - typedef TestString is String -} - - diff --git a/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp b/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp new file mode 100644 index 0000000..cd2eef3 --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp @@ -0,0 +1,37 @@ +/* Copyright (C) 2013 BMW Group + * Author: Manfred Bathelt (manfred.bathelt@bmw.de) + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "StopWatch.h" + +#include <cassert> +#include <ctime> + + +#define USEC_PER_SEC 1000000ULL +#define NSEC_PER_USEC 1000ULL + + +StopWatch::usec_t StopWatch::getTotalElapsedMicroseconds() const { + usec_t elapsed = totalElapsed_; + + if (started_) + elapsed += getElapsed(); + + return elapsed; +} + +StopWatch::usec_t StopWatch::getTotalElapsedSeconds() const { + return getTotalElapsedMicroseconds() / USEC_PER_SEC; +} + +StopWatch::usec_t StopWatch::now() { + struct timespec ts; + + assert(!clock_gettime(CLOCK_MONOTONIC, &ts)); + + return (usec_t) ts.tv_sec * USEC_PER_SEC + (usec_t) ts.tv_nsec / NSEC_PER_USEC; +} + diff --git a/org.genivi.commonapi.core.verification/src/utils/StopWatch.h b/org.genivi.commonapi.core.verification/src/utils/StopWatch.h new file mode 100644 index 0000000..be54b9f --- /dev/null +++ b/org.genivi.commonapi.core.verification/src/utils/StopWatch.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2013 BMW Group + * Author: Manfred Bathelt (manfred.bathelt@bmw.de) + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef STOP_WATCH_H_ +#define STOP_WATCH_H_ + +#include <cstdint> + + +class StopWatch { +public: + typedef uint64_t usec_t; + + StopWatch(): + started_(false), + totalElapsed_(0), + startTimePoint_(0) { + } + + inline void reset() { + started_ = false; + totalElapsed_ = 0; + } + + inline void start() { + startTimePoint_ = now(); + started_ = true; + } + + inline void stop() { + totalElapsed_ += getElapsed(); + started_ = false; + } + + usec_t getTotalElapsedMicroseconds() const; + usec_t getTotalElapsedSeconds() const; + +private: + inline usec_t getElapsed() const { + return now() - startTimePoint_; + } + + static usec_t now(); + + bool started_; + usec_t startTimePoint_; + usec_t totalElapsed_; +}; + +#endif // STOP_WATCH_H_ diff --git a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h index 0c29589..2d5b72b 100644 --- a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h +++ b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h @@ -1,5 +1,4 @@ -/* Copyright (C) 2013 BMW Group - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) +/* Copyright (C) 2014 - 2015 BMW Group * Author: Juergen Gehring (juergen.gehring@bmw.de) * 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 @@ -12,7 +11,7 @@ #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif -#include <CommonAPI/MainLoopContext.h> +#include <CommonAPI/MainLoopContext.hpp> #undef COMMONAPI_INTERNAL_COMPILATION #include <vector> @@ -23,7 +22,10 @@ #include <sys/eventfd.h> #include <cassert> #include <chrono> +#include <sys/time.h> +#include <future> +const long maxTimeout = 10; namespace CommonAPI { @@ -54,6 +56,8 @@ class VerificationMainLoop { std::bind(&CommonAPI::VerificationMainLoop::deregisterTimeout, this, std::placeholders::_1)); wakeupListenerSubscription_ = context_->subscribeForWakeupEvents( std::bind(&CommonAPI::VerificationMainLoop::wakeup, this)); + + stopPromise = new std::promise<bool>; } ~VerificationMainLoop() { @@ -65,12 +69,14 @@ class VerificationMainLoop { context_->unsubscribeForWakeupEvents(wakeupListenerSubscription_); close(wakeFd_.fd); + + delete stopPromise; } /** * \brief Runs the mainloop indefinitely until stop() is called. * - * Runs the mainloop indefinitely until stop() is called. The given timeout (milliseconds) + * Runs the mainloop infinitely until stop() is called. The given timeout (milliseconds) * will be overridden if a timeout-event is present that defines an earlier ready time. */ void run(const int64_t& timeoutInterval = TIMEOUT_INFINITE) { @@ -78,25 +84,41 @@ class VerificationMainLoop { while(running_) { doSingleIteration(timeoutInterval); } + + if (stopPromise) { + stopPromise->set_value(true); + } } - void runVerification(const int64_t& timeoutInterval, bool dispatchTimeoutAndWatches = false, bool dispatchDispatchSources = false) { + void runVerification(const long& timeoutInterval, bool dispatchTimeoutAndWatches = false, bool dispatchDispatchSources = false) { running_ = true; - clock_t start = clock(); - while(running_) { - doVerificationIteration(dispatchTimeoutAndWatches, dispatchDispatchSources); + prepare(maxTimeout); + long ti = timeoutInterval*((long)(1000/currentMinimalTimeoutInterval_)); - if(timeoutInterval != TIMEOUT_INFINITE && clock()-start > timeoutInterval*CLOCKS_PER_SEC) - stop(); + while (ti>0) { + ti--; + doVerificationIteration(dispatchTimeoutAndWatches, dispatchDispatchSources); } + running_ = false; + wakeup(); } - void stop() { + std::future<bool> stop() { + // delete old promise to secure, that always a new future object is returned + delete stopPromise; + stopPromise = new std::promise<bool>; + running_ = false; wakeup(); + + return stopPromise->get_future(); } + bool isRunning() { + return running_; + } + /** * \brief Executes a single cycle of the mainloop. * @@ -228,16 +250,16 @@ class VerificationMainLoop { ::write(wakeFd_.fd, &wake, sizeof(int64_t)); } - void dispatchTimeouts() - { + void dispatchTimeouts() { + for (auto timeoutIterator = timeoutsToDispatch_.begin(); timeoutIterator != timeoutsToDispatch_.end(); timeoutIterator++) { std::get<1>(*timeoutIterator)->dispatch(); } } - void dispatchWatches() - { + void dispatchWatches() { + for (auto watchIterator = watchesToDispatch_.begin(); watchIterator != watchesToDispatch_.end(); watchIterator++) { @@ -247,29 +269,32 @@ class VerificationMainLoop { } } - void dispatchSources() - { + void dispatchSources() { + breakLoop_ = false; for (auto dispatchSourceIterator = sourcesToDispatch_.begin(); dispatchSourceIterator != sourcesToDispatch_.end() && !breakLoop_; dispatchSourceIterator++) { while (std::get<1>(*dispatchSourceIterator)->dispatch()) ; - } } - void doVerificationIteration(bool dispatchTimeoutAndWatches, bool dispatchDispatchSources) - { - prepare(TIMEOUT_INFINITE); + void doVerificationIteration(bool dispatchTimeoutAndWatches, bool dispatchDispatchSources) { + + prepare(maxTimeout); poll(); if (dispatchTimeoutAndWatches || dispatchDispatchSources) { + if (check()) { + if (dispatchTimeoutAndWatches) { - dispatchTimeouts(); dispatchWatches(); + dispatchTimeouts(); } - if (dispatchDispatchSources) + + if (dispatchDispatchSources) { dispatchSources(); + } } timeoutsToDispatch_.clear(); sourcesToDispatch_.clear(); @@ -367,6 +392,8 @@ class VerificationMainLoop { bool running_; pollfd wakeFd_; + + std::promise<bool>* stopPromise; }; diff --git a/org.genivi.commonapi.core.verification/src/utils/VerificationTestStub.cpp b/org.genivi.commonapi.core.verification/src/utils/VerificationTestStub.cpp deleted file mode 100644 index 6a17823..0000000 --- a/org.genivi.commonapi.core.verification/src/utils/VerificationTestStub.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2013 BMW Group - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) - * Author: Juergen Gehring (juergen.gehring@bmw.de) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "VerificationTestStub.h" -#include <unistd.h> - -namespace commonapi { -namespace verification { - -void VerificationTestStub::testDerivedTypeMethod( - commonapi::tests::DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue, - commonapi::tests::DerivedTypeCollection::TestMap testMapInValue, - commonapi::tests::DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, - commonapi::tests::DerivedTypeCollection::TestMap& testMapOutValue) { - testEnumExtended2OutValue = testEnumExtended2InValue; - testMapOutValue = testMapInValue; - calledTestDerivedTypeMethod++; -} - -VerificationTestStub::VerificationTestStub() : - TestInterfaceStubDefault(), calledTestDerivedTypeMethod(0) { -} - -void VerificationTestStub::testPredefinedTypeMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, - uint32_t uint32InValue, - std::string stringInValue, - uint32_t& uint32OutValue, - std::string& stringOutValue) { - uint32OutValue = 1; - int broadcastNumber = 1; - - fireTestPredefinedTypeBroadcastEvent(broadcastNumber++, ""); - fireTestPredefinedTypeBroadcastEvent(broadcastNumber++, ""); - fireTestPredefinedTypeBroadcastEvent(broadcastNumber++, ""); - fireTestPredefinedTypeBroadcastEvent(broadcastNumber++, ""); - fireTestPredefinedTypeBroadcastEvent(broadcastNumber++, ""); - sleep(5); -} - -} /* namespace verification */ -} /* namespace commonapi */ diff --git a/org.genivi.commonapi.core.verification/src/utils/VerificationTestStub.h b/org.genivi.commonapi.core.verification/src/utils/VerificationTestStub.h deleted file mode 100644 index 09d9b14..0000000 --- a/org.genivi.commonapi.core.verification/src/utils/VerificationTestStub.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2013 BMW Group - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) - * Author: Juergen Gehring (juergen.gehring@bmw.de) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef VERIFICATIONTESTSTUB_H_ -#define VERIFICATIONTESTSTUB_H_ - -#include "commonapi/tests/TestInterfaceStubDefault.h" - -namespace commonapi { -namespace verification { - -class VerificationTestStub : public commonapi::tests::TestInterfaceStubDefault { -public: - VerificationTestStub(); - - int getCalledTestDerivedTypeMethod() const { - return calledTestDerivedTypeMethod; - } -private: - virtual void testDerivedTypeMethod( - commonapi::tests::DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue, - commonapi::tests::DerivedTypeCollection::TestMap testMapInValue, - commonapi::tests::DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, - commonapi::tests::DerivedTypeCollection::TestMap& testMapOutValue); - - virtual void testPredefinedTypeMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, - uint32_t uint32InValue, - std::string stringInValue, - uint32_t& uint32OutValue, - std::string& stringOutValue); - - int calledTestDerivedTypeMethod; -}; - -} /* namespace verification */ -} /* namespace commonapi */ -#endif /* VERIFICATIONTESTSTUB_H_ */ |