diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 012f7b77aa..82907970c5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -12,7 +12,7 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This job builds & runs iceoryx tests in ubuntu-18.04 - ubuntu-iceoryx-meta: + iceoryx-ubuntu: # The type of runner that the job will run on runs-on: ubuntu-18.04 @@ -23,60 +23,35 @@ jobs: # https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md run: sudo apt-get update && sudo apt-get install -y libacl1-dev libncurses5-dev - - name : Checkout + - name: Checkout uses: actions/checkout@v2 - name: Build sources run: | - export NUM_CORES=`nproc` - cmake -Bbuild -Hiceoryx_meta -Dtest=ON -Dbinding_c=ON -Dexamples=ON -Dintrospection=ON && cmake --build build -j$NUM_CORES + $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-strict build-all out-of-tree - name: Run timeless tests run: | cd $GITHUB_WORKSPACE/build - make tests + make all_tests - name: Run timing tests run: | cd $GITHUB_WORKSPACE/build make timing_tests - ubuntu-build-script: - # The type of runner that the job will run on - runs-on: ubuntu-18.04 - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - name: Install iceoryx dependencies - # Softwares installed in ubuntu-18.04 instance - # https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md - run: sudo apt-get update && sudo apt-get install -y libacl1-dev libncurses5-dev - - - name : Checkout - uses: actions/checkout@v2 - - - name: Build sources - run: | - export NUM_CORES=`nproc` - $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-test with-dds-gateway clean strict -j $NUM_CORES - - - name: Run tests - run: | - cd $GITHUB_WORKSPACE/build - ../tools/run_all_tests.sh - # This job builds & runs iceoryx tests in macos-10.15 - macos-build-script: - runs-on: macos-10.15 + iceoryx-macos: + runs-on: macos-latest # Softwares installed in macos-10.15 instance # https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name : Checkout + - name: Checkout uses: actions/checkout@v2 - - name: Build ncurses from source + - name: Build and install dependencies # tinfo library which is required by iceoryx_introspection isn't available in mac run: | cd $GITHUB_WORKSPACE @@ -90,15 +65,16 @@ jobs: make install - name: Build sources - run: $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-test clean strict + run: | + $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-strict build-all out-of-tree - name: Run tests run: | cd $GITHUB_WORKSPACE/build - ../tools/run_all_tests.sh disable-timing-tests + make all_tests # This job builds & runs iceoryx tests in Windows 2019 - windows-iceoryx-meta: + iceoryx-windows: runs-on: windows-latest # Softwares installed in windows instance # https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md @@ -110,4 +86,4 @@ jobs: - name: Build sources run: | - cmake -Bbuild -Hiceoryx_meta -Ddds_gateway=OFF -Dtest=ON -Dbinding_c=ON -Dexamples=ON && cmake --build build + cmake -Bbuild -Hiceoryx_meta -DBUILD_TEST=ON -DINTROSPECTION=OFF -DBINDING_C=ON -DEXAMPLES=ON && cmake --build build diff --git a/.github/workflows/build_test_cov.yml b/.github/workflows/coverage_scan.yml similarity index 88% rename from .github/workflows/build_test_cov.yml rename to .github/workflows/coverage_scan.yml index 62a7b0d00f..2dbc558184 100644 --- a/.github/workflows/build_test_cov.yml +++ b/.github/workflows/coverage_scan.yml @@ -12,7 +12,7 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This job builds & runs iceoryx tests in ubuntu-18.04 - build-test-ubuntu: + iceoryx-coverage-ubuntu: # The type of runner that the job will run on runs-on: ubuntu-18.04 @@ -28,9 +28,8 @@ jobs: - name: Build, test and generate gcov report run: | - export NUM_CORES=`nproc` # add flag to include coverage - $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh with-dds-gateway clean strict -j $NUM_CORES -c unit + $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-strict debug build-all out-of-tree -c unit - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: diff --git a/.github/workflows/sanitize.yml b/.github/workflows/sanitize.yml index 0c881bc72d..816fe10e66 100644 --- a/.github/workflows/sanitize.yml +++ b/.github/workflows/sanitize.yml @@ -12,41 +12,40 @@ on: jobs: clang-sanitize: # The type of runner that the job will run on - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Install iceoryx dependencies - # Softwares installed in ubuntu-18.04 instance - # https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md + # Softwares installed in ubuntu-20.04 instance + # https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu2004-README.md run: sudo apt-get update && sudo apt-get install -y libacl1-dev libncurses5-dev - - name : Checkout + - name: Checkout uses: actions/checkout@v2 - name: Build run: | - export NUM_CORES=`nproc` # build tests , dont run them - $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh clang build-test with-dds-gateway strict sanitize clean -j $NUM_CORES + $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-strict build-all sanitize clang - - name : Run tests + - name: Run tests run: | cd $GITHUB_WORKSPACE/build - ../tools/run_all_tests.sh + ../tools/run_all_tests.sh asan-only # This job builds & runs iceoryx tests (with sanitizer) in macos-10.15 clang-sanitize-macos: - runs-on: macos-10.15 + runs-on: macos-latest # Softwares installed in macos-10.15 instance # https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name : Checkout + - name: Checkout uses: actions/checkout@v2 - - name: Build ncurses from source + - name: Build and install dependencies # tinfo library which is required by iceoryx_introspection isn't available in mac run: | cd $GITHUB_WORKSPACE @@ -60,12 +59,13 @@ jobs: make install - name: Build - run: $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-test sanitize clean + run: | + $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh build-strict build-all sanitize - name: Run tests run: | cd $GITHUB_WORKSPACE/build - ../tools/run_all_tests.sh disable-timing-tests + ../tools/run_all_tests.sh asan-only diff --git a/.gitignore b/.gitignore index e238d3449a..2d354f7ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/build*/ +build/ +build_out_of_tree/ install/ /CMakeLists.txt .vscode diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4904a7f30..38b8c050e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,7 +116,7 @@ The folder structure boils down to: * include: public headers with stable API * internal: public headers with unstable API, which might change quite frequently * source: implementation files - * test: unit and integrations tests + * test: unit and integration tests * CMakeLists.txt: Build the component separately * examples_iceoryx: Examples described in [iceoryx_examples](./iceoryx_examples/README.md) @@ -139,27 +139,27 @@ Integration tests are composition of more than one class and test their interact To ensure that the provided testcode covers the productive code you can do a coverage scan with gcov. The reporting is done with lcov and htmlgen. You will need to install the following packages: - ``` - sudo apt install lcov - ``` +``` +sudo apt install lcov +``` In iceoryx we have multiple testlevels for testcoverage: 'unit', 'integration', 'component' and ’all’ for all testlevels together. You can create reports for these different testlevels or for all tests. Coverage is done with gcc. The coverage scan applies to Quality level 3 and partly level 2 with branch coverage. For having a coverage report iceoryx needs to be compiled with coverage flags and the tests needs to be executed. -You can do this with one command like this: - ``` - ./tools/iceoryx_build_test.sh clean -c -j 4 - ``` - +You can do this with one command in iceroyx folder like this: +``` +./tools/iceoryx_build_test.sh clean buildall -c +``` +Optionally you can use buildall option to get coverage for extensions like DDS or C-Binding. The -c flag indicates that you want to have a coverage report and you can pass there the needed testlevel. Per default the testlevel is set to 'all'. example: - ``` - ./tools/iceoryx_build_test.sh clean -c unit -j 4 - ``` -For having only unittest reports. In the script tools/gcov/lcov_generate.sh is the initial scan, filtering and report generation automatically done. +``` +./tools/iceoryx_build_test.sh buildall clean -c unit +``` +For having only reports for unit-test. In the script tools/gcov/lcov_generate.sh is the initial scan, filtering and report generation automatically done. -All reports are stored in build/lcov as html report. +All reports are stored in build/lcov as html report (index.html). ## Legal & Compliance diff --git a/README.md b/README.md index df240e88c0..b196ac56fa 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,10 @@ Please see the dedicated [README.md](tools/docker/README.md) for information on ## Documentation +* [Getting Started](doc/website/getting-started/overview.md) +* [Installation Guide](doc/website/getting-started/installation.md) * [Concepts](doc/conceptual-guide.md) -* [Usage Guide](doc/usage-guide.md) -* [Ice0ryx Utils Hacker Guide](iceoryx_utils/README.md) +* [Iceoryx Utils Hacker Guide](iceoryx_utils/README.md) ### Targeted quality levels & platforms diff --git a/VERSION b/VERSION index 57277d512b..6f34aa6c5d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.17.0.2 \ No newline at end of file +0.90.0.0 \ No newline at end of file diff --git a/cmake/cpptoml/CMakeLists.txt b/cmake/cpptoml/CMakeLists.txt index 424cb226be..b5d5517718 100644 --- a/cmake/cpptoml/CMakeLists.txt +++ b/cmake/cpptoml/CMakeLists.txt @@ -30,7 +30,7 @@ if(WIN32) set(CREATE_PATH_COMMAND mkdir) else() set(CREATE_PATH_COMMAND mkdir -p) -endif(WIN32) +endif() # set download config, source and build paths set(DOWNLOAD_CONFIG_DIR ${CMAKE_BINARY_DIR}/dependencies/cpptoml/download) diff --git a/cmake/cpptoml/cpptoml.cmake.in b/cmake/cpptoml/cpptoml.cmake.in index ea8986a3e6..25563ffafb 100644 --- a/cmake/cpptoml/cpptoml.cmake.in +++ b/cmake/cpptoml/cpptoml.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) project(cpptoml-download NONE) diff --git a/cmake/cyclonedds/cyclonedds-cxx.cmake.in b/cmake/cyclonedds/cyclonedds-cxx.cmake.in index 5e542ead74..e9f3432abf 100644 --- a/cmake/cyclonedds/cyclonedds-cxx.cmake.in +++ b/cmake/cyclonedds/cyclonedds-cxx.cmake.in @@ -19,7 +19,7 @@ project(cyclonedds-cxx-download NONE) include(ExternalProject) ExternalProject_Add(ext_cyclonedds_cxx GIT_REPOSITORY https://github.com/eclipse-cyclonedds/cyclonedds-cxx.git - GIT_TAG ad1154afc6f14b43d37f5bfc4c6995c9c59ffeb3 + GIT_TAG a7285c9d10d2da223d5a2fb8c9c04e591bcb3627 SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/cyclonedds-cxx/src" BINARY_DIR "${CMAKE_BINARY_DIR}/dependencies/cyclonedds-cxx/build" CONFIGURE_COMMAND "" diff --git a/cmake/cyclonedds/cyclonedds.cmake.in b/cmake/cyclonedds/cyclonedds.cmake.in index dc7cf70348..8c89aa53f1 100644 --- a/cmake/cyclonedds/cyclonedds.cmake.in +++ b/cmake/cyclonedds/cyclonedds.cmake.in @@ -19,7 +19,7 @@ project(cyclonedds-download NONE) include(ExternalProject) ExternalProject_Add(ext_cyclonedds GIT_REPOSITORY https://github.com/eclipse-cyclonedds/cyclonedds.git - GIT_TAG 0.6.0 + GIT_TAG 0.7.0 SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/cyclonedds/src" BINARY_DIR "${CMAKE_BINARY_DIR}/dependencies/cyclonedds/build" CONFIGURE_COMMAND "" diff --git a/cmake/googletest/CMakeLists.txt b/cmake/googletest/CMakeLists.txt index 917774c0a4..e4fa4139a3 100644 --- a/cmake/googletest/CMakeLists.txt +++ b/cmake/googletest/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.5) project(googletest-build CXX) -if(test) +if(BUILD_TEST) include(ProcessorCount) ProcessorCount(N) @@ -73,4 +73,4 @@ if(test) list(APPEND CMAKE_PREFIX_PATH ${INSTALL_DIR}) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE INTERNAL "" FORCE) -endif(test) +endif() diff --git a/cmake/googletest/googletest.cmake.in b/cmake/googletest/googletest.cmake.in index 368ddccab0..6f1e6a2672 100644 --- a/cmake/googletest/googletest.cmake.in +++ b/cmake/googletest/googletest.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) project(googletest-download NONE) diff --git a/cpptoml_vendor/CMakeLists.txt b/cpptoml_vendor/CMakeLists.txt index 0d8f67ed72..866545d7a4 100644 --- a/cpptoml_vendor/CMakeLists.txt +++ b/cpptoml_vendor/CMakeLists.txt @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) project(cpptoml_vendor) diff --git a/cpptoml_vendor/cpptoml_vendorConfig.cmake.in b/cpptoml_vendor/cpptoml_vendorConfig.cmake.in index 96e8a025b3..b6d3e29c77 100644 --- a/cpptoml_vendor/cpptoml_vendorConfig.cmake.in +++ b/cpptoml_vendor/cpptoml_vendorConfig.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # include cpptoml config file to make find_package(cpptoml REQUIRED) work include(${CMAKE_CURRENT_LIST_DIR}/../../cpptoml_install/lib/cmake/cpptoml/cpptomlConfig.cmake) diff --git a/cpptoml_vendor/cpptoml_vendorConfigVersion.cmake.in b/cpptoml_vendor/cpptoml_vendorConfigVersion.cmake.in index 2a278e552d..bd8054e9c4 100644 --- a/cpptoml_vendor/cpptoml_vendorConfigVersion.cmake.in +++ b/cpptoml_vendor/cpptoml_vendorConfigVersion.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + set(PACKAGE_VERSION "@cpptoml_vendor_VERSION@") # Check whether the requested PACKAGE_FIND_VERSION is compatible diff --git a/doc/aspice_swe3_4/swe_docu_guidelines.md b/doc/aspice_swe3_4/swe_docu_guidelines.md index 870763d563..e129d3d9fe 100644 --- a/doc/aspice_swe3_4/swe_docu_guidelines.md +++ b/doc/aspice_swe3_4/swe_docu_guidelines.md @@ -34,7 +34,7 @@ ALIASES += "requirement=\xrefitem requirement \"Requirement\" \"Requirements\" " ## Howto document your code * The implementation documentation should never describe what happens, that does already the code for you. It should describe why it is implemented in the way it is. - * Never add fancy lines in your comments like this: (exception is the fileheader which is Bosch-wide standard) + * Never add fancy lines in your comments like this: (exception is the fileheader which is iceoryx-wide standard) ```cpp //================================= // My bad comment diff --git a/doc/website/getting-started/installation.md b/doc/website/getting-started/installation.md index d8a164c0ae..91758a3cb8 100644 --- a/doc/website/getting-started/installation.md +++ b/doc/website/getting-started/installation.md @@ -2,7 +2,8 @@ 1. [Prerequisites](#prerequisites) 2. [Building with CMake](#build-with-cmake) 3. [Building with the build script](#build-with-the-build-script) -3. [Building with colcon](#build-with-colcon) +4. [Building with colcon](#build-with-colcon) +5. [Build and run tests](#build-and-run-tests) iceoryx_utils and iceoryx_posh are deployed as independent cmake packages. Posh is using some functions from utils and is depending on it. You are able to build posh and utils and integrate in into existing cmake projects. @@ -33,50 +34,49 @@ If you would like to use our Cyclone DDS Gateway you have to install Cyclone DDS Although we strive to be fully POSIX-compliant, we recommend using Ubuntu 18.04 and at least GCC 7.5.0 for development. You will need to install the following packages: - ``` - sudo apt install cmake libacl1-dev libncurses5-dev pkg-config - ``` +``` +sudo apt install gcc g++ cmake libacl1-dev libncurses5-dev pkg-config +``` Additionally, there is an optional dependency to the MIT licensed cpptoml library, which is used to parse a RouDi config file for the mempool config. [cpptoml](https://github.com/skystrife/cpptoml) ## Build with CMake -**NOTE:** Requires CMake version 3.5 or higher. +**NOTE:** Requires CMake version 3.5 or higher. Building from CMake is the preferred way, for more complex actions like a coverage scan +is a script available (see chapter below). The `CMakeLists.txt` from `iceoryx_meta` can be used to easily develop iceoryx with an IDE. 1. Clone the repository - ``` + ```bash git clone https://github.com/eclipse/iceoryx.git ``` 2. Generate the necessary build files ```bash cd iceoryx - cmake -Bbuild -Hiceoryx_meta -DTOML_CONFIG=ON + cmake -Bbuild -Hiceoryx_meta #tip: to build all iceoryx components add -DBUILD_ALL to the cmake command # when you have installed external dependencies like ncurses you have to add them # to your prefix path - cmake -Bbuild -Hiceoryx_meta -DTOML_CONFIG=ON -DCMAKE_PREFIX_PATH=$(PWD)/build/dependencies/ + cmake -Bbuild -Hiceoryx_meta -DCMAKE_PREFIX_PATH=$(PWD)/build/dependencies/ ``` 3. Compile the source code - ``` + ```bash cmake --build build ``` + Tip: You can fasten up the build by appending `-j 4` where 4 stands for the number of parallel build processes. + You can choose more or less depending on your available CPU cores on your machine. -### With the following CMake switches you can add additional features +**NOTE:** Iceoryx is build in Release mode with `-O3` optimization by default. If you want to have debug symbols please +set `CMAKE_BUILD_TYPE=Debug`. - | switch | description | - |:---------|:-------------| - | `dds_gateway` | builds the iceoryx dds gateway using the cyclonedds dds stack, cyclonedds will be fetched and built as part of the build, see [cyclonedds](https://github.com/eclipse-cyclonedds/cyclonedds) for details | - | `examples` | builds all examples | - | `one-to-many` | Restricts to 1:n communication. If not set the default communication is n:m | - | `introspection` | the console introspection client which requires an installed ncurses library with terminfo support | - | `test` | enables module-, integration- and component-tests | - | `TOML_CONFIG` | activates config file support by using toml, if this is deactivated the central broker `RouDi` is not being build | +### Build options -### With the following CMake switches you can customize the iceoryx_posh build +Please take a look at the cmake file [build_options.cmake](../iceoryx_meta/build_options.cmake) to get an overview of the available build options for enabling additional features. + +### Available CMake switches you can customize for the iceoryx_posh build | switch | description | |:---------|:-------------| @@ -88,12 +88,13 @@ The `CMakeLists.txt` from `iceoryx_meta` can be used to easily develop iceoryx w | `IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY` | the maximum number of chunks a subscriber can hold at a given time | | `IOX_MAX_INTERFACE_NUMBER` | the maximum number for interface ports, which are used for e.g. gateways | -Have a look at `iceoryx_posh/cmake/iceoryx_posh_deployment.cmake` for the default values of this constants. +Have a look at [iceoryx_posh_deployment.cmake](../iceoryx_posh/cmake/iceoryx_posh_deployment.cmake) for the default values of this constants. -## Build with the build script +## Build with script As an alternative we provide our build-test script which we use to integrate iceoryx into our infrastructure. -This currently only works for Linux and QNX. +The intention of the script is to more than just building with iceoryx. This is for doing a code coverage scan or for using the adress-sanitizer. +The script currently only works for Linux and QNX, it is planned to offer a multi-platform solution. 1. Clone the repository ``` @@ -103,15 +104,13 @@ This currently only works for Linux and QNX. 2. Build everything ``` cd iceoryx - ./tools/iceoryx_build_test.sh + ./tools/iceoryx_build_test.sh build_all ``` -With the following arguments you can add additional features: - - | switch | description | - |:---------|:-------------| - | `clean` | Removes the build directory and performs a clean build. If you have installed ncurses locally into your build directory you have to reinstall it first. | - | `test` | Enables module-, integration- and component-tests. The Googletest-Framework will be automatically fetched from github and the test will be executed and the end of the script. | +You can use the help for getting an overview over the available options: + ``` + ./tools/iceoryx_build_test.sh help + ``` ## Build with colcon @@ -126,3 +125,58 @@ colcon build ``` This build method makes the most sense in combination with [rmw_iceoryx](https://github.com/ros2/rmw_iceoryx.git) + +## Build and run tests + +While developing on iceoryx you want to know if your changes are breaking existing functions or if your newly written googletests are passing. +For that purpose we are generating cmake targets which are executing the tests. But first we need to build them: +``` +cmake -Bbuild -Hiceoryx_meta -DBUILD_TEST=ON +cmake --build build +``` +Cmake is automatically installing googletest as dependency and build the tests against it. Please note that if you want to build tests for extensions like the C-Binding you need to enable that in the cmake build. To build all tests simply add `-DBUILD_ALL` to the cmake command + +Now lets execute the all tests: +``` +cd iceoryx/build +make all_tests +``` +Some of the tests are timing critical and needs a stable environment. We call them timing tests and have them in a separate target available: +``` +make timing_tests +``` +In iceoryx we distinguish between different testlevels. The most important are: Moduletests and Integrationtests. +Moduletests are basically Unit-tests where the focus is on class level with black-box testing. +In Integrationtests are multiple classes within one component (e.g. iceoryx_posh) tested together. +The sourcecode of the tests is placed into the folder `test` within the different iceoryx components. You can find there at least a folder `moduletests` and sometimes ``integrationtests`. + +when you now want to create a new test you can place the sourcefile directly into the right folder. Cmake will automatically detect the new file when doing a clean build and will add it to a executable. There is no need to add a gtest main function because we already provide it. +For every test level are executables created, for example `posh_moduletests`. They are placed into the corresponding build folder (e.g. `iceoryx/build/posh/test/posh_moduletests`). + +If you want to execute only individual testcases then you can use these executables and a gtest filter. Let's assume you want to execute only the `ServiceDescription_test` from the posh_moduletests, then you can do the following: +``` +./build/posh/test/posh_moduletests --gtest_filter="ServiceDescription_test*" +``` + +## Use Sanitizer Scan + +Due to the fact that iceoryx works a lot with system memory it should be ensured that errors like memory leaks are not introduced. +To prevent these, we use the clang toolchain which offers several tools for scanning the codebase. One of them is the Adress-Sanitizer which checks for example on dangling pointers: [https://clang.llvm.org/docs/AddressSanitizer.html](https://clang.llvm.org/docs/AddressSanitizer.html) + +In iceoryx are scripts available to do the scan on your own. Additionally the Scans are running on the CI in every Pull-Request. +As Requirement you should install the clang compiler: +``` +sudo apt install clang +``` + +Then you need to compile the iceoryx with the sanitizer flags: +``` +./tools/iceoryx_build_test.sh build-strict build-all sanitize clang clean +``` +After that we can run the tests with enabled sanitizer options: +``` +cd build +../tools/run_all_tests.sh +``` +When the tests are running without errors then it is fine, else an error report is shown with a stacktrace to find the place where the leak occurs. If the leak comes from an external dependency or shall be handled later then it is possible to set a function on a suppression list. +This should be only rarely used and only in coordination with an iceoryx maintainer. diff --git a/iceoryx_binding_c/CMakeLists.txt b/iceoryx_binding_c/CMakeLists.txt index 3b90d15ffe..b654e678c1 100644 --- a/iceoryx_binding_c/CMakeLists.txt +++ b/iceoryx_binding_c/CMakeLists.txt @@ -17,8 +17,6 @@ cmake_minimum_required(VERSION 3.7) file (STRINGS "../VERSION" iceoryx_binding_c_VERSION) project(iceoryx_binding_c VERSION ${iceoryx_binding_c_VERSION}) -option(test "build test binaries") - find_package(iceoryx_posh REQUIRED) find_package(iceoryx_utils REQUIRED) @@ -78,14 +76,14 @@ target_link_libraries(${PROJECT_NAME} iceoryx_utils::iceoryx_utils ) -target_compile_options(${PROJECT_NAME} PRIVATE ${ICEORYX_WARNINGS}) +target_compile_options(${PROJECT_NAME} PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) # ########## build test executables ########## # -if(test) +if(BUILD_TEST) add_subdirectory(test) -endif(test) +endif() # ########## export library ########## diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/types.h b/iceoryx_binding_c/include/iceoryx_binding_c/types.h index efebdf9e03..0448f2f24d 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/types.h +++ b/iceoryx_binding_c/include/iceoryx_binding_c/types.h @@ -39,7 +39,7 @@ struct iox_user_trigger_storage_t_ #if defined(__APPLE__) uint64_t do_not_touch_me[16]; #else - uint64_t do_not_touch_me[13]; + uint64_t do_not_touch_me[14]; #endif }; typedef struct iox_user_trigger_storage_t_ iox_user_trigger_storage_t; @@ -51,7 +51,7 @@ struct iox_sub_storage_t_ #if defined(__APPLE__) uint64_t do_not_touch_me[16]; #else - uint64_t do_not_touch_me[13]; + uint64_t do_not_touch_me[14]; #endif }; typedef struct iox_sub_storage_t_ iox_sub_storage_t; diff --git a/iceoryx_binding_c/test/CMakeLists.txt b/iceoryx_binding_c/test/CMakeLists.txt index 4b452511f2..342afcdee1 100644 --- a/iceoryx_binding_c/test/CMakeLists.txt +++ b/iceoryx_binding_c/test/CMakeLists.txt @@ -39,9 +39,9 @@ set(TEST_LINK_LIBS if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(TEST_CXX_FLAGS ${ICEORYX_WARNINGS} /W3) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-unused -Wno-pedantic) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-unused -Wno-pedantic) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-unused -Wno-pedantic) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-unused -Wno-pedantic) endif() if(LINUX) diff --git a/iceoryx_binding_c/test/moduletests/test_types.cpp b/iceoryx_binding_c/test/moduletests/test_types.cpp index 20338c23df..41b561de28 100644 --- a/iceoryx_binding_c/test/moduletests/test_types.cpp +++ b/iceoryx_binding_c/test/moduletests/test_types.cpp @@ -31,24 +31,24 @@ using namespace ::testing; TEST(iox_types_test, WaitSetStorageSizeFits) { - EXPECT_THAT(sizeof(WaitSet<>), Eq(sizeof(iox_ws_storage_t))); + EXPECT_THAT(sizeof(WaitSet<>), Le(sizeof(iox_ws_storage_t))); EXPECT_THAT(alignof(WaitSet<>), Le(alignof(iox_ws_storage_t))); } TEST(iox_types_test, UserTriggerStorageSizeFits) { - EXPECT_THAT(sizeof(UserTrigger), Eq(sizeof(iox_user_trigger_storage_t))); + EXPECT_THAT(sizeof(UserTrigger), Le(sizeof(iox_user_trigger_storage_t))); EXPECT_THAT(alignof(UserTrigger), Le(alignof(iox_user_trigger_storage_t))); } TEST(iox_types_test, cpp2c_SubscriberStorageSizeFits) { - EXPECT_THAT(sizeof(cpp2c_Subscriber), Eq(sizeof(iox_sub_storage_t))); + EXPECT_THAT(sizeof(cpp2c_Subscriber), Le(sizeof(iox_sub_storage_t))); EXPECT_THAT(alignof(cpp2c_Subscriber), Le(alignof(iox_sub_storage_t))); } TEST(iox_types_test, cpp2c_PublisherStorageSizeFits) { - EXPECT_THAT(sizeof(cpp2c_Publisher), Eq(sizeof(iox_pub_storage_t))); + EXPECT_THAT(sizeof(cpp2c_Publisher), Le(sizeof(iox_pub_storage_t))); EXPECT_THAT(alignof(cpp2c_Publisher), Le(alignof(iox_pub_storage_t))); } diff --git a/iceoryx_dds/CMakeLists.txt b/iceoryx_dds/CMakeLists.txt index b9f5adfbd5..6321985d3b 100644 --- a/iceoryx_dds/CMakeLists.txt +++ b/iceoryx_dds/CMakeLists.txt @@ -17,8 +17,6 @@ cmake_minimum_required(VERSION 3.7) file (STRINGS "../VERSION" iceoryx_dds_VERSION) project(iceoryx_dds VERSION ${iceoryx_dds_VERSION}) -option(test "build test binaries") - find_package(cpptoml REQUIRED) find_package(iceoryx_posh REQUIRED) find_package(iceoryx_utils REQUIRED) @@ -38,7 +36,7 @@ setup_package_name_and_create_files( # ########## feature flags ########## # -option(USE_CYCLONE_DDS "Bind to CycloneDDS implementation" on) +option(USE_CYCLONE_DDS "Bind to CycloneDDS implementation" ON) if(USE_CYCLONE_DDS) message(INFO " Using CycloneDDS stack") @@ -111,7 +109,7 @@ if(USE_CYCLONE_DDS) ) endif() -target_compile_options(iceoryx_dds PRIVATE ${ICEORYX_WARNINGS}) +target_compile_options(iceoryx_dds PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) # ########## build gateway apps ########## @@ -124,7 +122,7 @@ target_link_libraries(iox-gw-iceoryx2dds ${PROJECT_NAMESPACE}::iceoryx_dds ) -target_compile_options(iox-gw-iceoryx2dds PRIVATE ${ICEORYX_WARNINGS}) +target_compile_options(iox-gw-iceoryx2dds PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-gw-dds2iceoryx source/dds2iceoryx_app/main.cpp @@ -134,7 +132,7 @@ target_link_libraries(iox-gw-dds2iceoryx ${PROJECT_NAMESPACE}::iceoryx_dds ) -target_compile_options(iox-gw-dds2iceoryx PRIVATE ${ICEORYX_WARNINGS}) +target_compile_options(iox-gw-dds2iceoryx PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) set_target_properties(iox-gw-iceoryx2dds iox-gw-dds2iceoryx iceoryx_dds PROPERTIES @@ -145,9 +143,9 @@ set_target_properties(iox-gw-iceoryx2dds iox-gw-dds2iceoryx iceoryx_dds # ########## build test executables ########## # -if(test) +if(BUILD_TEST) add_subdirectory(test) -endif(test) +endif() # ########## export library ########## diff --git a/iceoryx_dds/README.md b/iceoryx_dds/README.md index 077f4a9cd4..2932af0581 100644 --- a/iceoryx_dds/README.md +++ b/iceoryx_dds/README.md @@ -24,17 +24,20 @@ The DDS stack used by the gateway is abstracted and needs to made explicit at co * Maven is installed * CMake is installed +```bash +sudo apt install cmake maven openjdk-14-jdk-headless +``` ## Scripted Build The easiest way to build the gateway is via the script `iceoryx/tools/iceoryx_build_test.sh`. To build, simply run: ```bash -iceoryx/tools/iceoryx_build_test.sh release with-dds-gateway +iceoryx/tools/iceoryx_build_test.sh dds-gateway ``` You may want to specify the build directory, this can be done via a flag. e.g. ```bash -iceoryx/tools/iceoryx_build_test.sh --builddir ./my-build release with-dds-gateway +iceoryx/tools/iceoryx_build_test.sh --build-dir ./my-build dds-gateway ``` Once complete, the gateway binaries can be found in `./my-build/install/prefix/bin`. diff --git a/iceoryx_dds/cmake/Config.cmake.in b/iceoryx_dds/cmake/Config.cmake.in index c0031328ec..acf24dc85b 100644 --- a/iceoryx_dds/cmake/Config.cmake.in +++ b/iceoryx_dds/cmake/Config.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + @PACKAGE_INIT@ include(CMakeFindDependencyMacro) diff --git a/iceoryx_dds/cmake/idlpp-cxx-generate.cmake.in b/iceoryx_dds/cmake/idlpp-cxx-generate.cmake.in index 9a15335170..977948e439 100644 --- a/iceoryx_dds/cmake/idlpp-cxx-generate.cmake.in +++ b/iceoryx_dds/cmake/idlpp-cxx-generate.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # # Generates all message definitions required by iceoryx_dds and packages # them into a single library. @@ -18,10 +33,3 @@ target_link_libraries(iceoryx_dds_messages CycloneDDS-CXX::ddscxx mempool_messages ) - -if(APPLE) - target_include_directories(iceoryx_dds_messages - PUBLIC - /usr/local/include/ - ) -endif(APPLE) diff --git a/iceoryx_dds/test/CMakeLists.txt b/iceoryx_dds/test/CMakeLists.txt index 3a151e4e31..776fea86e5 100644 --- a/iceoryx_dds/test/CMakeLists.txt +++ b/iceoryx_dds/test/CMakeLists.txt @@ -36,9 +36,9 @@ set(TEST_LINK_LIBS if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(TEST_CXX_FLAGS ${ICEORYX_WARNINGS} /W3) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-unused -Wno-pedantic) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-unused -Wno-pedantic) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-unused -Wno-pedantic) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-unused -Wno-pedantic) endif() if(LINUX) diff --git a/iceoryx_examples/ice_multi_publisher/CMakeLists.txt b/iceoryx_examples/ice_multi_publisher/CMakeLists.txt index ea6a209e97..2f2a62050c 100644 --- a/iceoryx_examples/ice_multi_publisher/CMakeLists.txt +++ b/iceoryx_examples/ice_multi_publisher/CMakeLists.txt @@ -23,19 +23,21 @@ get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if(NOT ICEORYX_CXX_STANDARD) include(IceoryxPlatform) -endif(NOT ICEORYX_CXX_STANDARD) +endif() add_executable(iox-multi-publisher ./ice_multi_publisher.cpp) target_link_libraries(iox-multi-publisher iceoryx_posh::iceoryx_posh) +target_compile_options(iox-multi-publisher PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) -add_executable(iox-subscriber ./ice_subscriber.cpp) -target_link_libraries(iox-subscriber iceoryx_posh::iceoryx_posh) +add_executable(iox-multi-subscriber ./ice_subscriber.cpp) +target_link_libraries(iox-multi-subscriber iceoryx_posh::iceoryx_posh) +target_compile_options(iox-multi-subscriber PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) set_target_properties( - iox-subscriber iox-multi-publisher + iox-multi-subscriber iox-multi-publisher PROPERTIES CXX_STANDARD_REQUIRED ON CXX_STANDARD ${ICEORYX_CXX_STANDARD} POSITION_INDEPENDENT_CODE ON) -install(TARGETS iox-multi-publisher iox-subscriber +install(TARGETS iox-multi-publisher iox-multi-subscriber RUNTIME DESTINATION bin) diff --git a/iceoryx_examples/icedelivery/CMakeLists.txt b/iceoryx_examples/icedelivery/CMakeLists.txt index 70af6bb850..e1b4d56e8b 100644 --- a/iceoryx_examples/icedelivery/CMakeLists.txt +++ b/iceoryx_examples/icedelivery/CMakeLists.txt @@ -1,3 +1,18 @@ +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Build icedelivery example cmake_minimum_required(VERSION 3.5) project(example_icedelivery) @@ -9,37 +24,43 @@ find_package(iceoryx_posh CONFIG REQUIRED) get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if ( NOT ICEORYX_CXX_STANDARD ) include(IceoryxPlatform) -endif ( NOT ICEORYX_CXX_STANDARD ) +endif () add_executable(iox-ex-publisher-typed ./iox_publisher_typed.cpp) target_link_libraries(iox-ex-publisher-typed iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-publisher-typed PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-publisher-with-history ./iox_publisher_with_history.cpp) target_link_libraries(iox-ex-publisher-with-history iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-publisher-with-history PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-publisher-untyped ./iox_publisher_untyped.cpp) target_link_libraries(iox-ex-publisher-untyped iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-publisher-untyped PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-subscriber-typed ./iox_subscriber_typed.cpp) target_link_libraries(iox-ex-subscriber-typed iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-subscriber-typed PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-subscriber-with-history ./iox_subscriber_with_history.cpp) target_link_libraries(iox-ex-subscriber-with-history iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-subscriber-with-history PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-subscriber-untyped ./iox_subscriber_untyped.cpp) target_link_libraries(iox-ex-subscriber-untyped iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-subscriber-untyped PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) set_target_properties(iox-ex-subscriber-typed iox-ex-subscriber-untyped iox-ex-publisher-with-history iox-ex-subscriber-with-history diff --git a/iceoryx_examples/icedelivery_on_c/CMakeLists.txt b/iceoryx_examples/icedelivery_on_c/CMakeLists.txt index 00fcbf6844..002febd86f 100644 --- a/iceoryx_examples/icedelivery_on_c/CMakeLists.txt +++ b/iceoryx_examples/icedelivery_on_c/CMakeLists.txt @@ -1,3 +1,18 @@ +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Build icedelivery example cmake_minimum_required(VERSION 3.5) project(example_icedelivery_on_c) @@ -10,7 +25,7 @@ find_package(iceoryx_binding_c CONFIG REQUIRED) get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if ( NOT ICEORYX_CXX_STANDARD ) include(IceoryxPlatform) -endif ( NOT ICEORYX_CXX_STANDARD ) +endif () add_executable(iox-c-publisher ./ice_c_publisher.c) set_source_files_properties(./ice_c_publisher.c PROPERTIES LANGUAGE C) @@ -21,6 +36,7 @@ target_link_libraries(iox-c-publisher set_target_properties(iox-c-publisher PROPERTIES POSITION_INDEPENDENT_CODE ON ) +target_compile_options(iox-c-publisher PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-c-subscriber ./ice_c_subscriber.c) set_source_files_properties(./ice_c_subscriber.c PROPERTIES LANGUAGE C) @@ -31,6 +47,7 @@ target_link_libraries(iox-c-subscriber set_target_properties(iox-c-subscriber PROPERTIES POSITION_INDEPENDENT_CODE ON ) +target_compile_options(iox-c-subscriber PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) install( TARGETS iox-c-publisher iox-c-subscriber diff --git a/iceoryx_examples/iceperf/CMakeLists.txt b/iceoryx_examples/iceperf/CMakeLists.txt index 40c050b6d1..571ed7c824 100644 --- a/iceoryx_examples/iceperf/CMakeLists.txt +++ b/iceoryx_examples/iceperf/CMakeLists.txt @@ -22,34 +22,33 @@ find_package(iceoryx_binding_c CONFIG REQUIRED) get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if ( NOT ICEORYX_CXX_STANDARD ) include(IceoryxPlatform) -endif ( NOT ICEORYX_CXX_STANDARD ) +endif () add_executable(iceperf-laurel iceperf_laurel.cpp base.cpp example_common.cpp iceoryx.cpp iceoryx_c.cpp uds.cpp mq.cpp) -set_target_properties(iceperf-laurel PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_STANDARD ${ICEORYX_CXX_STANDARD} - POSITION_INDEPENDENT_CODE ON -) target_link_libraries(iceperf-laurel iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iceperf-laurel PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) if(CMAKE_SYSTEM_NAME MATCHES QNX) target_link_libraries(iceperf-laurel socket) -endif(CMAKE_SYSTEM_NAME MATCHES QNX) +endif() add_executable(iceperf-hardy iceperf_hardy.cpp base.cpp example_common.cpp iceoryx.cpp iceoryx_c.cpp uds.cpp mq.cpp) -set_target_properties(iceperf-hardy PROPERTIES + +set_target_properties(iceperf-laurel iceperf-hardy PROPERTIES CXX_STANDARD_REQUIRED ON CXX_STANDARD ${ICEORYX_CXX_STANDARD} POSITION_INDEPENDENT_CODE ON ) + target_link_libraries(iceperf-hardy iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iceperf-hardy PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) if(CMAKE_SYSTEM_NAME MATCHES QNX) target_link_libraries(iceperf-hardy socket) diff --git a/iceoryx_examples/iceperf/README.md b/iceoryx_examples/iceperf/README.md index 23233c254a..eff55675c1 100644 --- a/iceoryx_examples/iceperf/README.md +++ b/iceoryx_examples/iceperf/README.md @@ -195,7 +195,7 @@ With `payloadSize` as the payload size used for the current measurement. In case Let's set some constants to prevent magic values. The default number of round trips is set and names for the communication resources that are used. ```cpp constexpr int64_t NUMBER_OF_ROUNDTRIPS{10000}; - constexpr char APP_NAME[] = "/laurel"; + constexpr char APP_NAME[] = "laurel"; constexpr char PUBLISHER[] = "Laurel"; constexpr char SUBSCRIBER[] = "Hardy"; ``` diff --git a/iceoryx_examples/iceperf/mq.cpp b/iceoryx_examples/iceperf/mq.cpp index 56ca2ee90a..f2d93b32dc 100644 --- a/iceoryx_examples/iceperf/mq.cpp +++ b/iceoryx_examples/iceperf/mq.cpp @@ -204,7 +204,6 @@ void MQ::send(const char* buffer, uint32_t length) noexcept void MQ::receive(char* buffer) noexcept { - char message[MAX_MESSAGE_SIZE]; auto mqCall = iox::cxx::makeSmartC(mq_receive, iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {static_cast(ERROR_CODE)}, diff --git a/iceoryx_examples/singleprocess/CMakeLists.txt b/iceoryx_examples/singleprocess/CMakeLists.txt index adc6bc7951..5851a3f3bf 100644 --- a/iceoryx_examples/singleprocess/CMakeLists.txt +++ b/iceoryx_examples/singleprocess/CMakeLists.txt @@ -24,7 +24,7 @@ find_package(cpptoml REQUIRED) get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if ( NOT ICEORYX_CXX_STANDARD ) include(IceoryxPlatform) -endif ( NOT ICEORYX_CXX_STANDARD ) +endif () add_executable(single_process ./single_process.cpp) target_link_libraries(single_process @@ -37,6 +37,7 @@ set_target_properties(single_process PROPERTIES CXX_STANDARD ${ICEORYX_CXX_STANDARD} POSITION_INDEPENDENT_CODE ON ) +target_compile_options(single_process PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) install( TARGETS single_process diff --git a/iceoryx_examples/waitset/CMakeLists.txt b/iceoryx_examples/waitset/CMakeLists.txt index 45d5a1c5b7..2c9cced354 100644 --- a/iceoryx_examples/waitset/CMakeLists.txt +++ b/iceoryx_examples/waitset/CMakeLists.txt @@ -22,37 +22,43 @@ find_package(iceoryx_posh CONFIG REQUIRED) get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if ( NOT ICEORYX_CXX_STANDARD ) include(IceoryxPlatform) -endif ( NOT ICEORYX_CXX_STANDARD ) +endif () add_executable(iox-ex-waitset-publisher ./ice_waitset_publisher.cpp) target_link_libraries(iox-ex-waitset-publisher iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-waitset-publisher PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-waitset-gateway ./ice_waitset_gateway.cpp) target_link_libraries(iox-ex-waitset-gateway iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-waitset-gateway PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-waitset-grouping ./ice_waitset_grouping.cpp) target_link_libraries(iox-ex-waitset-grouping iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-waitset-grouping PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-waitset-individual ./ice_waitset_individual.cpp) target_link_libraries(iox-ex-waitset-individual iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-waitset-individual PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-waitset-sync ./ice_waitset_sync.cpp) target_link_libraries(iox-ex-waitset-sync iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-waitset-sync PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-waitset-trigger ./ice_waitset_trigger.cpp) target_link_libraries(iox-ex-waitset-trigger iceoryx_posh::iceoryx_posh ) +target_compile_options(iox-ex-waitset-trigger PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) set_target_properties( iox-ex-waitset-trigger diff --git a/iceoryx_examples/waitset_on_c/CMakeLists.txt b/iceoryx_examples/waitset_on_c/CMakeLists.txt index 1c179896f7..9a694f6aa0 100644 --- a/iceoryx_examples/waitset_on_c/CMakeLists.txt +++ b/iceoryx_examples/waitset_on_c/CMakeLists.txt @@ -23,37 +23,42 @@ find_package(iceoryx_binding_c CONFIG REQUIRED) get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD) if ( NOT ICEORYX_CXX_STANDARD ) include(IceoryxPlatform) -endif ( NOT ICEORYX_CXX_STANDARD ) +endif () add_executable(iox-ex-c-waitset-publisher ./ice_c_waitset_publisher.c) target_link_libraries(iox-ex-c-waitset-publisher iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iox-ex-c-waitset-publisher PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-c-waitset-gateway ./ice_c_waitset_gateway.c) target_link_libraries(iox-ex-c-waitset-gateway iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iox-ex-c-waitset-gateway PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-c-waitset-grouping ./ice_c_waitset_grouping.c) target_link_libraries(iox-ex-c-waitset-grouping iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iox-ex-c-waitset-grouping PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-c-waitset-individual ./ice_c_waitset_individual.c) target_link_libraries(iox-ex-c-waitset-individual iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iox-ex-c-waitset-individual PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) add_executable(iox-ex-c-waitset-sync ./ice_c_waitset_sync.c) target_link_libraries(iox-ex-c-waitset-sync iceoryx_posh::iceoryx_posh iceoryx_binding_c::iceoryx_binding_c ) +target_compile_options(iox-ex-c-waitset-sync PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) set_source_files_properties( ./ice_c_waitset_sync.c diff --git a/iceoryx_meta/CMakeLists.txt b/iceoryx_meta/CMakeLists.txt index 9c21f45ebb..eae746cee3 100644 --- a/iceoryx_meta/CMakeLists.txt +++ b/iceoryx_meta/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,111 +16,50 @@ cmake_minimum_required(VERSION 3.5) file (STRINGS "../VERSION" iceoryx_VERSION) project(iceoryx_meta VERSION ${iceoryx_VERSION}) -option(TOML_CONFIG "activates or deactivates TOML support - without TOML RouDi will not be build" ON) -option(ONE_TO_MANY_ONLY "Restricts communication to 1:n pattern" OFF) -option(BUILD_STRICT "Build is performed with '-Werror'" OFF) -option(test "Build tests" ON) -option(coverage "Build iceoryx with gcov" OFF) -option(examples "build with iceoryx examples" ON) -option(introspection "builds the introspection client which requires the ncurses library with an activated terminfo feature" OFF) -option(dds_gateway "builds the iceoryx dds gateway - enables internode communication via dds" OFF) -option(binding_c "builds the C language bindings" ON) -option(sanitize "Build with sanitizers" OFF) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif(NOT CMAKE_BUILD_TYPE) + +include(${CMAKE_CURRENT_SOURCE_DIR}/build_options.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/tests.cmake) # ===== Dependencies if(TOML_CONFIG) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/cpptoml/ ${CMAKE_BINARY_DIR}/dependencies/cpptoml/prebuild) -endif(TOML_CONFIG) - -if(coverage) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(test ON) - set(examples OFF) - set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage" CACHE INTERNAL "") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}") - else(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - message( FATAL_ERROR "You need to run gcov with gcc compiler." ) - endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -endif(coverage) - -if(test) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/googletest ${CMAKE_BINARY_DIR}/dependencies/googletest/prebuild) -endif(test) +endif() # ===== Core add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_utils ${CMAKE_BINARY_DIR}/utils) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_posh ${CMAKE_BINARY_DIR}/posh) # ===== Extras -if(introspection) +if(INTROSPECTION) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../tools/introspection ${CMAKE_BINARY_DIR}/iceoryx_introspection) -endif(introspection) +endif() # ===== Gateways -if(dds_gateway) +if(DDS_GATEWAY) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/cyclonedds ${CMAKE_BINARY_DIR}/dependencies/cyclonedds/prebuild) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_dds ${CMAKE_BINARY_DIR}/iceoryx_dds) -endif(dds_gateway) +endif() # ===== Language binding for C -if(binding_c) +if(BINDING_C) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_binding_c ${CMAKE_BINARY_DIR}/iceoryx_binding_c) -endif(binding_c) +endif() # ===== Examples -if(examples) +if(EXAMPLES) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/icedelivery ${CMAKE_BINARY_DIR}/iceoryx_examples/icedelivery) - if(binding_c) + if(BINDING_C) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/icedelivery_on_c ${CMAKE_BINARY_DIR}/iceoryx_examples/icedelivery_on_c) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/waitset_on_c ${CMAKE_BINARY_DIR}/iceoryx_examples/waitset_on_c) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/iceperf ${CMAKE_BINARY_DIR}/iceoryx_examples/iceperf) - endif(binding_c) + endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/waitset ${CMAKE_BINARY_DIR}/iceoryx_examples/waitset) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/singleprocess ${CMAKE_BINARY_DIR}/iceoryx_examples/singleprocess) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/ice_multi_publisher ${CMAKE_BINARY_DIR}/iceoryx_examples/ice_multi_publisher) -endif(examples) - -if (test) - add_custom_target( tests - COMMAND ./posh/test/posh_moduletests --gtest_filter=-*.TimingTest_* - COMMAND ./posh/test/posh_integrationtests --gtest_filter=-*.TimingTest_* - COMMAND ./posh/test/posh_componenttests --gtest_filter=-*.TimingTest_* - COMMAND ./utils/test/utils_moduletests --gtest_filter=-*.TimingTest_* - COMMAND ./utils/test/utils_integrationtests --gtest_filter=-*.TimingTest_* - COMMAND ./utils/test/utils_componenttests --gtest_filter=-*.TimingTest_* - if (binding_c) - COMMAND ./binding_c/test/binding_c_moduletests --gtest_filter=-*.TimingTest_* - endif(binding_c) - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - ) - - add_custom_target( timing_tests - COMMAND ./posh/test/posh_moduletests --gtest_filter=*.TimingTest_* - COMMAND ./posh/test/posh_integrationtests --gtest_filter=*.TimingTest_* - COMMAND ./posh/test/posh_componenttests --gtest_filter=*.TimingTest_* - COMMAND ./utils/test/utils_moduletests --gtest_filter=*.TimingTest_* - COMMAND ./utils/test/utils_integrationtests --gtest_filter=*.TimingTest_* - COMMAND ./utils/test/utils_componenttests --gtest_filter=*.TimingTest_* - if (binding_c) - COMMAND ./binding_c/test/binding_c_moduletests --gtest_filter=*.TimingTest_* - endif(binding_c) - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - ) -endif(test) - - -message("") -message(" Configured Options") -message(" BUILD_STRICT..............: " ${BUILD_STRICT}) -message(" TOML_CONFIG...............: " ${TOML_CONFIG}) -message(" binding_c.................: " ${binding_c}) -message(" dds_gateway...............: " ${dds_gateway}) -message(" examples..................: " ${examples}) -message(" introspection.............: " ${introspection}) -message(" test......................: " ${test}) +endif() message("") message(" Build Properties") diff --git a/iceoryx_meta/build_options.cmake b/iceoryx_meta/build_options.cmake new file mode 100644 index 0000000000..efcdfc907e --- /dev/null +++ b/iceoryx_meta/build_options.cmake @@ -0,0 +1,74 @@ +# Copyright (c) 2020 by Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +cmake_minimum_required(VERSION 3.5) + +option(BUILD_ALL "Build with all extensions and all tests" OFF) +option(TOML_CONFIG "Activates or deactivates TOML support - without TOML RouDi will not be build" ON) +option(ONE_TO_MANY_ONLY "Restricts communication to 1:n pattern" OFF) +option(BUILD_STRICT "Build is performed with '-Werror'" OFF) +option(BUILD_TEST "Build all tests" OFF) +option(COVERAGE "Build iceoryx with gcov flags" OFF) +option(EXAMPLES "Build all iceoryx examples" OFF) +option(INTROSPECTION "Builds the introspection client which requires the ncurses library with an activated terminfo feature" ON) +option(DDS_GATEWAY "Builds the iceoryx dds gateway - enables internode communication via dds" OFF) +option(BINDING_C "Builds the C language bindings" ON) +option(SANITIZE "Build with sanitizers" OFF) +option(CLANG_TIDY "Execute Clang-Tidy" OFF) +option(ROUDI_ENVIRONMENT "Build RouDi Environment for testing, is enabled when building tests" OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # "Create compile_commands.json file" + +if(BUILD_ALL) + set(EXAMPLES ON) + set(INTROSPECTION ON) + set(BUILD_TEST ON) + set(INTROSPECTION ON) + set(BINDING_C ON) + set(DDS_GATEWAY ON) +endif() + +if(COVERAGE) + set(BUILD_TEST ON) +endif() + +if(SANITIZE) + set(BUILD_TEST ON) +endif() + +if(BUILD_TEST) + set(ROUDI_ENVIRONMENT ON) + set(BINDING_C ON) +endif() + +if(EXAMPLES) + set(BINDING_C ON) +endif() + +message("") +message(" Configured Options") +message(" CMAKE_BUILD_TYPE.....................: " ${CMAKE_BUILD_TYPE}) +message(" TOML_CONFIG..........................: " ${TOML_CONFIG}) +message(" BUILD_ALL............................: " ${BUILD_ALL}) +message(" BUILD_STRICT.........................: " ${BUILD_STRICT}) +message(" BUILD_TEST...........................: " ${BUILD_TEST}) +message(" EXAMPLES.............................: " ${EXAMPLES}) +message(" INTROSPECTION........................: " ${INTROSPECTION}) +message(" DDS_GATEWAY..........................: " ${DDS_GATEWAY}) +message(" BINDING_C............................: " ${BINDING_C}) +message(" COVERAGE.............................: " ${COVERAGE}) +message(" SANITIZE.............................: " ${SANITIZE}) +message(" CLANG_TIDY...........................: " ${CLANG_TIDY}) +message(" ROUDI_ENVIRONMENT....................: " ${ROUDI_ENVIRONMENT}) +message(" CMAKE_EXPORT_COMPILE_COMMANDS........: " ${CMAKE_EXPORT_COMPILE_COMMANDS}) +message(" ONE_TO_MANY_ONLY ....................: " ${ONE_TO_MANY_ONLY}) diff --git a/iceoryx_meta/tests.cmake b/iceoryx_meta/tests.cmake new file mode 100644 index 0000000000..afef39fdc7 --- /dev/null +++ b/iceoryx_meta/tests.cmake @@ -0,0 +1,75 @@ +# Copyright (c) 2020 by Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.5) + +if (BUILD_TEST) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/googletest ${CMAKE_BINARY_DIR}/dependencies/googletest/prebuild) + + ### create component list + set(COMPONENTS "posh" "utils") + + ### possible place for more extensions + if (DDS_GATEWAY) + list(APPEND COMPONENTS "dds_gateway") + endif() + if (BINDING_C) + list(APPEND COMPONENTS "binding_c") + endif() + + ### create test targets without Timing tests + foreach(cmp IN ITEMS ${COMPONENTS}) + list(APPEND MODULETEST_CMD COMMAND ./${cmp}/test/${cmp}_moduletests --gtest_filter=-*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_ModuleTestResults.xml) + endforeach() + + foreach(cmp IN ITEMS ${COMPONENTS}) + if(NOT (cmp STREQUAL "dds_gateway" OR cmp STREQUAL "binding_c")) + list(APPEND INTEGRATIONTEST_CMD COMMAND ./${cmp}/test/${cmp}_integrationtests --gtest_filter=-*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_IntegrationTestResults.xml) + endif() + endforeach() + + add_custom_target( all_tests + ${MODULETEST_CMD} + ${INTEGRATIONTEST_CMD} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + ) + + ### we need to create separate test targets for coverage scan + add_custom_target( module_tests + ${MODULETEST_CMD} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + ) + + add_custom_target( integration_tests + ${INTEGRATIONTEST_CMD} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + ) + + ### create test target with Timing tests + foreach(cmp IN ITEMS ${COMPONENTS}) + list(APPEND TIMINGTEST_CMD COMMAND ./${cmp}/test/${cmp}_moduletests --gtest_filter=*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_ModuleTestResults.xml) + if(NOT (cmp STREQUAL "dds_gateway" OR cmp STREQUAL "binding_c")) + list(APPEND TIMINGTEST_CMD COMMAND ./${cmp}/test/${cmp}_integrationtests --gtest_filter=*.TimingTest_* --gtest_output=xml:${CMAKE_BINARY_DIR}/testresults/${cmp}_IntegrationTestResults.xml) + endif() + endforeach() + + add_custom_target( timing_tests + ${TIMINGTEST_CMD} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + ) +endif() diff --git a/iceoryx_posh/.clang-tidy b/iceoryx_posh/.clang-tidy index a8967539b2..726007c908 100644 --- a/iceoryx_posh/.clang-tidy +++ b/iceoryx_posh/.clang-tidy @@ -1,14 +1,14 @@ Checks: '-*, readability-identifier-naming' CheckOptions: - - { key: readability-identifier-naming.ClassCase, value: CamelCase } - - { key: readability-identifier-naming.EnumCase, value: CamelCase } - - { key: readability-identifier-naming.StructCase, value: CamelCase } - - { key: readability-identifier-naming.UnionCase, value: CamelCase } - - { key: readability-identifier-naming.MethodCase, value: camelBack } + - { key: readability-identifier-naming.ClassCase, value: CamelCase } + - { key: readability-identifier-naming.EnumCase, value: CamelCase } + - { key: readability-identifier-naming.StructCase, value: CamelCase } + - { key: readability-identifier-naming.UnionCase, value: CamelCase } + - { key: readability-identifier-naming.MethodCase, value: camelBack } - { key: readability-identifier-naming.NamespaceCase, value: lower_case } - - { key: readability-identifier-naming.MemberPrefix, value: m_ } - - { key: readability-identifier-naming.MemberCase, value: camelBack } - - { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE } - - { key: readability-identifier-naming.EnumCase, value: UPPER_CASE } - - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } - - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } \ No newline at end of file + - { key: readability-identifier-naming.MemberPrefix, value: m_ } + - { key: readability-identifier-naming.MemberCase, value: camelBack } + - { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE } + - { key: readability-identifier-naming.EnumCase, value: UPPER_CASE } + - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } + - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } \ No newline at end of file diff --git a/iceoryx_posh/CMakeLists.txt b/iceoryx_posh/CMakeLists.txt index a17410539b..93baa2b55b 100644 --- a/iceoryx_posh/CMakeLists.txt +++ b/iceoryx_posh/CMakeLists.txt @@ -29,7 +29,7 @@ include(IceoryxPlatform) include(cmake/iceoryx_posh_deployment.cmake) -if( clang-tidy ) +if(CLANG_TIDY) find_program( CLANG_TIDY_EXE NAMES "clang-tidy" @@ -39,8 +39,8 @@ if( clang-tidy ) set(PERFORM_CLANG_TIDY "${CLANG_TIDY_EXE}") else(CLANG_TIDY_EXE) message(WARNING "clang-tidy activated but unable to find clang-tidy executable") - endif(CLANG_TIDY_EXE) -endif( clang-tidy ) + endif() +endif() # ########## set variables for library export ########## @@ -235,7 +235,7 @@ if(PERFORM_CLANG_TIDY) set_target_properties( iceoryx_posh_roudi PROPERTIES CXX_CLANG_TIDY "${PERFORM_CLANG_TIDY}" ) -endif(PERFORM_CLANG_TIDY) +endif() target_include_directories(iceoryx_posh_roudi PRIVATE source/runtime @@ -333,11 +333,11 @@ if(TOML_CONFIG) set_target_properties( iox-roudi PROPERTIES CXX_CLANG_TIDY "${PERFORM_CLANG_TIDY}" ) - endif(PERFORM_CLANG_TIDY) + endif() -endif(TOML_CONFIG) +endif() -if(roudi_environment OR test) +if(ROUDI_ENVIRONMENT OR BUILD_TEST) # ######### posh roudi environment ########## # @@ -367,14 +367,14 @@ if(roudi_environment OR test) target_compile_options(iceoryx_posh_roudi_environment PRIVATE ${ICEORYX_WARNINGS}) -endif(roudi_environment OR test) +endif() # ########## exporting library ########## # if(TOML_CONFIG) set(ROUDI_EXPORT iox-roudi) -endif(TOML_CONFIG) +endif() setup_install_directories_and_export_package( TARGETS iceoryx_posh iceoryx_posh_roudi iceoryx_posh_config iceoryx_posh_gateway ${ROUDI_EXPORT} @@ -387,6 +387,6 @@ install( COMPONENT dev ) -if(test) +if(BUILD_TEST) add_subdirectory(test) -endif(test) +endif() diff --git a/iceoryx_posh/cmake/Config.cmake.in b/iceoryx_posh/cmake/Config.cmake.in index 9d6fd2ba34..a0ad21b769 100644 --- a/iceoryx_posh/cmake/Config.cmake.in +++ b/iceoryx_posh/cmake/Config.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + @PACKAGE_INIT@ include(CMakeFindDependencyMacro) diff --git a/iceoryx_posh/cmake/iceoryx_posh_deployment.cmake b/iceoryx_posh/cmake/iceoryx_posh_deployment.cmake index aa60c7265a..af0a2d5f6e 100644 --- a/iceoryx_posh/cmake/iceoryx_posh_deployment.cmake +++ b/iceoryx_posh/cmake/iceoryx_posh_deployment.cmake @@ -17,7 +17,7 @@ if(ONE_TO_MANY_ONLY) message("[i] Using 1:n communication only!") set(IOX_COMMUNICATION_POLICY OneToManyPolicy) -endif(ONE_TO_MANY_ONLY) +endif() if(NOT IOX_COMMUNICATION_POLICY) set(IOX_COMMUNICATION_POLICY ManyToManyPolicy) diff --git a/iceoryx_posh/cmake/install_help_and_config.cmake b/iceoryx_posh/cmake/install_help_and_config.cmake index eb503a0551..b9a314adea 100644 --- a/iceoryx_posh/cmake/install_help_and_config.cmake +++ b/iceoryx_posh/cmake/install_help_and_config.cmake @@ -21,4 +21,4 @@ if(TOML_CONFIG) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/iceoryx/roudi_config_example.toml DESTINATION etc/ COMPONENT dev) -endif(TOML_CONFIG) +endif() diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl index 30086024f3..ebd1e7e5ad 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl @@ -119,10 +119,10 @@ void MemPoolIntrospection::prepare const posix::PosixGroup& writerGroup, uint32_t id) noexcept { - strncpy(sample.m_readerGroupName, readerGroup.getName().c_str(), MAX_GROUP_NAME_LENGTH - 1); - sample.m_readerGroupName[MAX_GROUP_NAME_LENGTH - 1] = 0; - strncpy(sample.m_writerGroupName, writerGroup.getName().c_str(), MAX_GROUP_NAME_LENGTH - 1); - sample.m_writerGroupName[MAX_GROUP_NAME_LENGTH - 1] = 0; + sample.m_readerGroupName.assign(""); + sample.m_readerGroupName.append(cxx::TruncateToCapacity, readerGroup.getName()); + sample.m_writerGroupName.assign(""); + sample.m_writerGroupName.append(cxx::TruncateToCapacity, writerGroup.getName()); sample.m_id = id; } diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp index 7f363c0061..f2a4eb0700 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp @@ -47,8 +47,8 @@ using MemPoolInfoContainer = cxx::vector; struct MemPoolIntrospectionInfo { uint32_t m_id; - char m_writerGroupName[MAX_GROUP_NAME_LENGTH]; - char m_readerGroupName[MAX_GROUP_NAME_LENGTH]; + cxx::string m_writerGroupName; + cxx::string m_readerGroupName; MemPoolInfoContainer m_mempoolInfo; }; diff --git a/iceoryx_posh/source/popo/trigger.cpp b/iceoryx_posh/source/popo/trigger.cpp index c6f9c76613..6d515320c2 100644 --- a/iceoryx_posh/source/popo/trigger.cpp +++ b/iceoryx_posh/source/popo/trigger.cpp @@ -54,6 +54,7 @@ const EventInfo& Trigger::getEventInfo() const noexcept void Trigger::invalidate() noexcept { m_hasTriggeredCallback = cxx::ConstMethodCallback(); + m_resetCallback = cxx::MethodCallback(); } Trigger::operator bool() const noexcept @@ -88,9 +89,9 @@ Trigger& Trigger::operator=(Trigger&& rhs) noexcept m_eventInfo = std::move(rhs.m_eventInfo); // Trigger - m_resetCallback = rhs.m_resetCallback; - m_hasTriggeredCallback = rhs.m_hasTriggeredCallback; - m_uniqueId = rhs.m_uniqueId; + m_resetCallback = std::move(rhs.m_resetCallback); + m_hasTriggeredCallback = std::move(rhs.m_hasTriggeredCallback); + m_uniqueId = std::move(rhs.m_uniqueId); rhs.invalidate(); } diff --git a/iceoryx_posh/test/CMakeLists.txt b/iceoryx_posh/test/CMakeLists.txt index 7c02efe872..d9e2c35f71 100644 --- a/iceoryx_posh/test/CMakeLists.txt +++ b/iceoryx_posh/test/CMakeLists.txt @@ -1,12 +1,27 @@ +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) set(test_iceoryx_posh_VERSION 0) project(test_iceoryx_posh VERSION ${test_iceoryx_posh_VERSION}) find_package(iceoryx_utils_testing REQUIRED) -if(test AND NOT GTest_FOUND) +if(BUILD_TEST AND NOT GTest_FOUND) find_package(GTest CONFIG REQUIRED) -endif(test AND NOT GTest_FOUND) +endif(BUILD_TEST AND NOT GTest_FOUND) set(PROJECT_PREFIX "posh") @@ -40,9 +55,9 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(TEST_CXX_FLAGS ${ICEORYX_WARNINGS} /W3) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-pedantic -Wno-conversion) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-pedantic -Wno-conversion) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) endif() # unittests @@ -67,14 +82,3 @@ set_target_properties(${PROJECT_PREFIX}_integrationtests PROPERTIES CXX_STANDARD ${ICEORYX_CXX_STANDARD} POSITION_INDEPENDENT_CODE ON ) - -# component tests -add_executable( ${PROJECT_PREFIX}_componenttests ${COMPONENTTESTS_SRC} ${TESTUTILS_SRC} ${MOCKS_SRC}) -target_compile_options(${PROJECT_PREFIX}_componenttests PRIVATE ${TEST_CXX_FLAGS}) -target_include_directories(${PROJECT_PREFIX}_componenttests PRIVATE .) -target_link_libraries(${PROJECT_PREFIX}_componenttests ${TEST_LINK_LIBS}) -set_target_properties(${PROJECT_PREFIX}_componenttests PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_STANDARD ${ICEORYX_CXX_STANDARD} - POSITION_INDEPENDENT_CODE ON -) diff --git a/iceoryx_posh/test/componenttests/test_posh_component.cpp b/iceoryx_posh/test/componenttests/test_posh_component.cpp deleted file mode 100644 index e601cef499..0000000000 --- a/iceoryx_posh/test/componenttests/test_posh_component.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "test.hpp" - -using namespace ::testing; -using ::testing::_; -using ::testing::Return; - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp b/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp index ba03edd7b4..e4062d86ce 100644 --- a/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp +++ b/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp @@ -17,9 +17,11 @@ #include "iceoryx_posh/internal/runtime/message_queue_interface.hpp" #include "iceoryx_posh/internal/runtime/message_queue_message.hpp" +#include "iceoryx_utils/cxx/smart_c.hpp" #include "iceoryx_utils/internal/posix_wrapper/message_queue.hpp" #include "iceoryx_utils/internal/units/duration.hpp" + #include #include #include @@ -128,8 +130,17 @@ TEST_F(CMqInterfaceStartupRace_test, ObsoleteRouDiMq) checkRegRequest(msg); // simulate the restart of RouDi with the mqueue cleanup - system(DeleteRouDiMessageQueue); - auto m_roudiQueue2 = IpcChannelType::create(roudi::MQ_ROUDI_NAME, IpcChannelMode::BLOCKING, IpcChannelSide::SERVER); + auto sysC = iox::cxx::makeSmartC( + system, iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, DeleteRouDiMessageQueue); + + if (sysC.hasErrors()) + { + std::cerr << "system call failed with error: " << sysC.getErrorString(); + exit(EXIT_FAILURE); + } + + auto m_roudiQueue2 = + IpcChannelType::create(roudi::MQ_ROUDI_NAME, IpcChannelMode::BLOCKING, IpcChannelSide::SERVER); // check if the app retries to register at RouDi request = m_roudiQueue2->timedReceive(15_s); @@ -170,7 +181,14 @@ TEST_F(CMqInterfaceStartupRace_test, ObsoleteRouDiMqWithFullMq) std::this_thread::sleep_for(std::chrono::milliseconds(2000)); // simulate the restart of RouDi with the mqueue cleanup - system(DeleteRouDiMessageQueue); + auto sysC = iox::cxx::makeSmartC( + system, iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, DeleteRouDiMessageQueue); + + if (sysC.hasErrors()) + { + std::cerr << "system call failed with error: " << sysC.getErrorString(); + exit(EXIT_FAILURE); + } auto newRoudi = IpcChannelType::create(roudi::MQ_ROUDI_NAME, IpcChannelMode::BLOCKING, IpcChannelSide::SERVER); // check if the app retries to register at RouDi diff --git a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp index 647fce9ee4..54bb00b549 100644 --- a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp +++ b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp @@ -23,6 +23,7 @@ #include "iceoryx_utils/error_handling/error_handling.hpp" #include "iceoryx_utils/internal/concurrent/smart_lock.hpp" #include "test.hpp" +#include "testutils/timing_test.hpp" #include #include @@ -38,19 +39,19 @@ using ::testing::Return; struct DummySample { - uint64_t m_dummy{42}; + uint64_t m_dummy{42U}; }; static const ServiceDescription TEST_SERVICE_DESCRIPTION("x", "y", "z"); static const iox::ProcessName_t TEST_SUBSCRIBER_APP_NAME("mySubscriberApp"); static const iox::ProcessName_t TEST_PUBLISHER_APP_NAME("myPublisherApp"); -static constexpr uint32_t NUMBER_OF_PUBLISHERS = 17u; -static constexpr uint32_t ITERATIONS = 1000u; +static constexpr uint32_t NUMBER_OF_PUBLISHERS = 17U; +static constexpr uint32_t ITERATIONS = 1000U; static constexpr uint32_t NUM_CHUNKS_IN_POOL = NUMBER_OF_PUBLISHERS * ITERATIONS; -static constexpr uint32_t SMALL_CHUNK = 128u; -static constexpr uint32_t CHUNK_META_INFO_SIZE = 256u; +static constexpr uint32_t SMALL_CHUNK = 128U; +static constexpr uint32_t CHUNK_META_INFO_SIZE = 256U; static constexpr size_t MEMORY_SIZE = NUM_CHUNKS_IN_POOL * (SMALL_CHUNK + CHUNK_META_INFO_SIZE); alignas(64) static uint8_t g_memory[MEMORY_SIZE]; @@ -69,7 +70,7 @@ class PortUser_IntegrationTest : public Test void SetUp() { - for (uint32_t i = 0; i < NUMBER_OF_PUBLISHERS; i++) + for (uint32_t i = 0U; i < NUMBER_OF_PUBLISHERS; i++) { std::stringstream publisherAppName; publisherAppName << TEST_PUBLISHER_APP_NAME << i; @@ -85,7 +86,7 @@ class PortUser_IntegrationTest : public Test void TearDown() { - for (uint32_t i = 0; i < NUMBER_OF_PUBLISHERS; i++) + for (uint32_t i = 0U; i < NUMBER_OF_PUBLISHERS; i++) { m_publisherPortUserVector[i].stopOffer(); static_cast(m_publisherPortRouDiVector[i].tryGetCaProMessage()); @@ -98,12 +99,12 @@ class PortUser_IntegrationTest : public Test static_cast(m_subscriberPortRouDiMultiProducer.tryGetCaProMessage()); } - GenericRAII m_uniqueRouDiId{[] { iox::popo::internal::setUniqueRouDiId(0); }, + GenericRAII m_uniqueRouDiId{[] { iox::popo::internal::setUniqueRouDiId(0U); }, [] { iox::popo::internal::unsetUniqueRouDiId(); }}; - uint64_t m_receiveCounter{0}; - std::atomic m_sendCounter{0}; - std::atomic m_publisherRunFinished{0}; + uint64_t m_receiveCounter{0U}; + std::atomic m_sendCounter{0U}; + std::atomic m_publisherRunFinished{0U}; // Memory objects Allocator m_memoryAllocator{g_memory, MEMORY_SIZE}; @@ -135,6 +136,8 @@ class PortUser_IntegrationTest : public Test vector m_publisherPortUserVector; vector m_publisherPortRouDiVector; + vector m_publisherThreadVector; + inline CaproMessage waitForCaproMessage(const ConcurrentCaproMessageVector_t& concurrentCaproMessageVector, const CaproMessageType& caproMessageType) { @@ -149,7 +152,7 @@ class PortUser_IntegrationTest : public Test std::this_thread::sleep_for(std::chrono::microseconds(100)); { auto guardedVector = concurrentCaproMessageVector.GetScopeGuard(); - if (guardedVector->size() != 0) + if (guardedVector->size() != 0U) { caproMessage = guardedVector->back(); @@ -235,7 +238,7 @@ class PortUser_IntegrationTest : public Test // Let RouDi change state and send OFFER to subscriber auto maybeCaproMessage = publisherPortRouDi.tryGetCaProMessage(); - if (publisherThreadIndex == 0) + if (publisherThreadIndex == 0U) { // First publisher thread will sync with subscriber if (maybeCaproMessage.has_value()) @@ -276,7 +279,7 @@ class PortUser_IntegrationTest : public Test { std::this_thread::sleep_for(std::chrono::microseconds(100)); - if (m_concurrentCaproMessageRx->size() != 0) + if (m_concurrentCaproMessageRx->size() != 0U) { caproMessageRouDi = m_concurrentCaproMessageRx->back(); } @@ -287,7 +290,7 @@ class PortUser_IntegrationTest : public Test } // Subscriber is ready to receive -> start sending samples - for (size_t i = 0; i < ITERATIONS; i++) + for (size_t i = 0U; i < ITERATIONS; i++) { publisherPortUser.tryAllocateChunk(sizeof(DummySample)) .and_then([&](auto chunkHeader) { @@ -311,10 +314,9 @@ class PortUser_IntegrationTest : public Test } }; -TEST_F(PortUser_IntegrationTest, SingleProducer) -{ - constexpr uint32_t NUMBER_OF_PUBLISHERS_SINGLE_PRODUCER = 1u; - constexpr uint32_t INDEX_OF_PUBLISHER_SINGLE_PRODUCER = 0u; +TIMING_TEST_F(PortUser_IntegrationTest, SingleProducer, Repeat(5), [&] { + constexpr uint32_t NUMBER_OF_PUBLISHERS_SINGLE_PRODUCER = 1U; + constexpr uint32_t INDEX_OF_PUBLISHER_SINGLE_PRODUCER = 0U; std::thread subscribingThread(std::bind(&PortUser_IntegrationTest::subscriberThread, this, @@ -337,26 +339,26 @@ TEST_F(PortUser_IntegrationTest, SingleProducer) publishingThread.join(); } - EXPECT_EQ(m_sendCounter.load(std::memory_order_relaxed), m_receiveCounter); - EXPECT_EQ(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall(), false); -} + TIMING_TEST_EXPECT_TRUE(m_sendCounter.load(std::memory_order_relaxed) == m_receiveCounter); + TIMING_TEST_EXPECT_FALSE(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall()); +}); -TEST_F(PortUser_IntegrationTest, MultiProducer) -{ +TIMING_TEST_F(PortUser_IntegrationTest, MultiProducer, Repeat(5), [&] { std::thread subscribingThread(std::bind(&PortUser_IntegrationTest::subscriberThread, this, NUMBER_OF_PUBLISHERS, std::ref(PortUser_IntegrationTest::m_subscriberPortRouDiMultiProducer), std::ref(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer))); - vector publisherThreadVector; - for (uint32_t i = 0; i < NUMBER_OF_PUBLISHERS; i++) + + for (uint32_t i = 0U; i < NUMBER_OF_PUBLISHERS; i++) { - publisherThreadVector.emplace_back(std::bind(&PortUser_IntegrationTest::publisherThread, - this, - i, - std::ref(PortUser_IntegrationTest::m_publisherPortRouDiVector[i]), - std::ref(PortUser_IntegrationTest::m_publisherPortUserVector[i]))); + m_publisherThreadVector.emplace_back( + std::bind(&PortUser_IntegrationTest::publisherThread, + this, + i, + std::ref(PortUser_IntegrationTest::m_publisherPortRouDiVector[i]), + std::ref(PortUser_IntegrationTest::m_publisherPortUserVector[i]))); } if (subscribingThread.joinable()) @@ -364,14 +366,14 @@ TEST_F(PortUser_IntegrationTest, MultiProducer) subscribingThread.join(); } - for (uint32_t i = 0; i < NUMBER_OF_PUBLISHERS; i++) + for (uint32_t i = 0U; i < NUMBER_OF_PUBLISHERS; i++) { - if (publisherThreadVector[i].joinable()) + if (m_publisherThreadVector[i].joinable()) { - publisherThreadVector[i].join(); + m_publisherThreadVector[i].join(); } } - EXPECT_EQ(m_sendCounter.load(std::memory_order_relaxed), m_receiveCounter); - EXPECT_EQ(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall(), false); -} + TIMING_TEST_EXPECT_TRUE(m_sendCounter.load(std::memory_order_relaxed) == m_receiveCounter); + TIMING_TEST_EXPECT_FALSE(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall()); +}); diff --git a/iceoryx_posh/test/moduletests/test_popo_trigger.cpp b/iceoryx_posh/test/moduletests/test_popo_trigger.cpp index 981a1589a6..9dca52f325 100644 --- a/iceoryx_posh/test/moduletests/test_popo_trigger.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_trigger.cpp @@ -83,7 +83,7 @@ Trigger_test::TriggerClass* Trigger_test::TriggerClass::m_lastCallbackArgument = TEST_F(Trigger_test, DefaultCTorConstructsEmptyTrigger) { - Trigger sut, sut2; + Trigger sut; EXPECT_EQ(static_cast(sut), false); EXPECT_EQ(sut.isValid(), false); @@ -98,6 +98,25 @@ TEST_F(Trigger_test, TriggerWithValidOriginIsValid) EXPECT_TRUE(static_cast(sut)); } +TEST_F(Trigger_test, MovedConstructedValidTriggerIsValid) +{ + Trigger trigger = createValidTrigger(); + Trigger sut{std::move(trigger)}; + + EXPECT_TRUE(sut.isValid()); + EXPECT_TRUE(static_cast(sut)); +} + +TEST_F(Trigger_test, MovedAssignedValidTriggerIsValid) +{ + Trigger sut; + Trigger trigger = createValidTrigger(); + sut = std::move(trigger); + + EXPECT_TRUE(sut.isValid()); + EXPECT_TRUE(static_cast(sut)); +} + TEST_F(Trigger_test, TriggerWithNullptrOriginIsValid) { uint64_t eventId = 0U; @@ -199,8 +218,8 @@ TEST_F(Trigger_test, HasTriggeredCallbackReturnsAlwaysFalseWhenInvalid) TEST_F(Trigger_test, UpdateOriginLeadsToDifferentHasTriggeredCallback) { - Trigger sut = createValidTrigger(); TriggerClass secondTriggerClass; + Trigger sut = createValidTrigger(); sut.updateOrigin(&secondTriggerClass); diff --git a/iceoryx_utils/.clang-tidy b/iceoryx_utils/.clang-tidy index 9df3dbebd0..69638021a8 100644 --- a/iceoryx_utils/.clang-tidy +++ b/iceoryx_utils/.clang-tidy @@ -1,14 +1,14 @@ Checks: '-*, readability-identifier-naming' CheckOptions: - - { key: readability-identifier-naming.ClassCase, value: CamelCase } - - { key: readability-identifier-naming.EnumCase, value: CamelCase } - - { key: readability-identifier-naming.StructCase, value: CamelCase } - - { key: readability-identifier-naming.FunctionCase, value: camelBack } - - { key: readability-identifier-naming.MethodCase, value: camelBack } - - { key: readability-identifier-naming.NamespaceCase, value: lower_case } - - { key: readability-identifier-naming.MemberPrefix, value: m_ } - - { key: readability-identifier-naming.MemberCase, value: camelBack } - - { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE } - - { key: readability-identifier-naming.EnumCase, value: UPPER_CASE } - - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } - - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } \ No newline at end of file + - { key: readability-identifier-naming.ClassCase, value: CamelCase } + - { key: readability-identifier-naming.EnumCase, value: CamelCase } + - { key: readability-identifier-naming.StructCase, value: CamelCase } + - { key: readability-identifier-naming.FunctionCase, value: camelBack } + - { key: readability-identifier-naming.MethodCase, value: camelBack } + - { key: readability-identifier-naming.NamespaceCase, value: lower_case } + - { key: readability-identifier-naming.MemberPrefix, value: m_ } + - { key: readability-identifier-naming.MemberCase, value: camelBack } + - { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE } + - { key: readability-identifier-naming.EnumCase, value: UPPER_CASE } + - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } + - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } \ No newline at end of file diff --git a/iceoryx_utils/CMakeLists.txt b/iceoryx_utils/CMakeLists.txt index 57a6432d82..b5bed14752 100644 --- a/iceoryx_utils/CMakeLists.txt +++ b/iceoryx_utils/CMakeLists.txt @@ -1,3 +1,18 @@ +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) file (STRINGS "../VERSION" iceoryx_utils_VERSION) project(iceoryx_utils VERSION ${iceoryx_utils_VERSION}) @@ -5,7 +20,7 @@ project(iceoryx_utils VERSION ${iceoryx_utils_VERSION}) include("${CMAKE_CURRENT_LIST_DIR}/cmake/IceoryxPackageHelper.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cmake/IceoryxPlatform.cmake") -if( clang-tidy ) +if(CLANG_TIDY) find_program( CLANG_TIDY_EXE NAMES "clang-tidy" @@ -16,7 +31,7 @@ if( clang-tidy ) else(CLANG_TIDY_EXE) message(WARNING "clang-tidy activated but unable to find clang-tidy executable") endif(CLANG_TIDY_EXE) -endif( clang-tidy ) +endif(CLANG_TIDY) ########## find_package in source tree ########## # @@ -26,20 +41,15 @@ set(${PROJECT_NAME}_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake FORCE ) -# -########## set variables for library export ########## -# - - # ########## set util internal target, needed by tests in components ########## # # TODO: we need something like internal public for internal build dependencies # instead of making the whole source folder public for internal dependency resolution -if(test AND NOT GTest_FOUND) +if(BUILD_TEST AND NOT GTest_FOUND) find_package(GTest CONFIG REQUIRED) -endif(test AND NOT GTest_FOUND) +endif(BUILD_TEST AND NOT GTest_FOUND) if(GTest_FOUND) # only GTest_FOUND, just in case someone want's to use iceoryx_utils_testing without also building the tests @@ -96,11 +106,6 @@ if(GTest_FOUND) # only GTest_FOUND, just in case someone want's to use iceoryx_u target_link_libraries(iceoryx_utils_testing PRIVATE rt) endif() - # install_target_directories_and_header( - # TARGETS iceoryx_utils_testing - # INCLUDE_DIRECTORY testutils/ - # ) - setup_install_directories_and_export_package( TARGETS iceoryx_utils_testing INCLUDE_DIRECTORY testutils/ @@ -255,7 +260,6 @@ install( DESTINATION ${DESTINATION_CONFIGDIR} ) -if(test) +if(BUILD_TEST) add_subdirectory(test) - add_subdirectory(test/stresstests/benchmark_optional_and_expected) -endif(test) +endif(BUILD_TEST) diff --git a/iceoryx_utils/cmake/Config.cmake.in b/iceoryx_utils/cmake/Config.cmake.in index f9bd544386..dfd01c934a 100644 --- a/iceoryx_utils/cmake/Config.cmake.in +++ b/iceoryx_utils/cmake/Config.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + @PACKAGE_INIT@ include(CMakeFindDependencyMacro) diff --git a/iceoryx_utils/cmake/IceoryxPlatform.cmake b/iceoryx_utils/cmake/IceoryxPlatform.cmake index 4e3b15249a..f59460cb67 100644 --- a/iceoryx_utils/cmake/IceoryxPlatform.cmake +++ b/iceoryx_utils/cmake/IceoryxPlatform.cmake @@ -19,7 +19,7 @@ if(UNIX AND NOT APPLE) elseif(CMAKE_SYSTEM_NAME MATCHES QNX) set(QNX true) endif() -endif(UNIX AND NOT APPLE) +endif() if(LINUX) set(ICEORYX_CXX_STANDARD 14) @@ -29,10 +29,11 @@ elseif(WIN32) set(ICEORYX_CXX_STANDARD 14) elseif(APPLE) set(ICEORYX_CXX_STANDARD 17) -endif(LINUX) +endif() if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(ICEORYX_WARNINGS PRIVATE ${ICEORYX_WARNINGS} /W1) + # todo: '/O2' and '/RTC1' (set by default) options are incompatible, elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(ICEORYX_WARNINGS PRIVATE ${ICEORYX_WARNINGS} -W -Wall -Wextra -Wuninitialized -Wpedantic -Wstrict-aliasing -Wcast-align -Wno-noexcept-type -Wconversion) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -46,8 +47,8 @@ if(BUILD_STRICT) set(ICEORYX_WARNINGS ${ICEORYX_WARNINGS} -Werror) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(ICEORYX_WARNINGS ${ICEORYX_WARNINGS} -Werror) - endif ( ) -endif(BUILD_STRICT) + endif() +endif() function(iox_create_asan_compile_time_blacklist BLACKLIST_FILE_PATH) # Suppressing Errors in Recompiled Code (Blacklist) @@ -96,7 +97,7 @@ function(iox_create_lsan_runtime_blacklist BLACKLIST_FILE_PATH) endif() endfunction() -if(sanitize) +if(SANITIZE) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") set(ICEORYX_SANITIZER_BLACKLIST_FILE ${CMAKE_BINARY_DIR}/sanitizer_blacklist/asan_compile_time.txt) iox_create_asan_compile_time_blacklist(${ICEORYX_SANITIZER_BLACKLIST_FILE}) @@ -105,14 +106,14 @@ if(sanitize) # unset local variables , to avoid polluting global space unset(ICEORYX_SANITIZER_BLACKLIST_FILE ) - endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + endif() iox_create_asan_runtime_blacklist(${CMAKE_BINARY_DIR}/sanitizer_blacklist/asan_runtime.txt) iox_create_lsan_runtime_blacklist(${CMAKE_BINARY_DIR}/sanitizer_blacklist/lsan_runtime.txt) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - set(ICEORYX_SANITIZER_COMMON_FLAGS -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -O1) - + set(ICEORYX_SANITIZER_COMMON_FLAGS -fno-omit-frame-pointer -fno-optimize-sibling-calls) + # For using LeakSanitizer in standalone mode # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#stand-alone-mode # Using this mode was a bit unstable @@ -124,10 +125,18 @@ if(sanitize) set(ICEORYX_SANITIZER_FLAGS ${ICEORYX_SANITIZER_COMMON_FLAGS} ${ICEORYX_ADDRESS_SANITIZER_FLAGS} CACHE INTERNAL "") # unset local variables , to avoid polluting global space - unset(ICEORYX_SANITIZER_BLACKLIST ) + unset(ICEORYX_SANITIZER_BLACKLIST) unset(ICEORYX_SANITIZER_COMMON_FLAGS) unset(ICEORYX_ADDRESS_SANITIZER_FLAGS) - else(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + else() message( FATAL_ERROR "You need to run sanitize with gcc/clang compiler." ) - endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") -endif(sanitize) + endif() +endif() + +if(COVERAGE) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(ICEORYX_SANITIZER_FLAGS -fprofile-arcs -ftest-coverage CACHE INTERNAL "") + else(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message( FATAL_ERROR "You need to run gcov with gcc compiler." ) + endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +endif() diff --git a/iceoryx_utils/source/posix_wrapper/shared_memory_object/shared_memory.cpp b/iceoryx_utils/source/posix_wrapper/shared_memory_object/shared_memory.cpp index b6e594ce49..3159801da1 100644 --- a/iceoryx_utils/source/posix_wrapper/shared_memory_object/shared_memory.cpp +++ b/iceoryx_utils/source/posix_wrapper/shared_memory_object/shared_memory.cpp @@ -54,7 +54,7 @@ SharedMemory::SharedMemory(const char* f_name, , m_size(f_size) { // on qnx the current working directory will be added to the /dev/shmem path if the leading slash is missing - if (f_name == nullptr || strlen(f_name) == 0u) + if (f_name == nullptr || strlen(f_name) == 0U) { std::cerr << "No shared memory name specified!" << std::endl; m_isInitialized = false; @@ -70,11 +70,13 @@ SharedMemory::SharedMemory(const char* f_name, if (strlen(f_name) >= NAME_SIZE) { std::clog << "Shared memory name is too long! '" << f_name << "' will be truncated at position " - << NAME_SIZE - 1u << "!" << std::endl; + << NAME_SIZE - 1U << "!" << std::endl; } + /// @note GCC drops here a warning that the destination char buffer length is equal to the max length to copy. + /// This can potentially lead to a char array without null-terminator. We add the null-terminator afterwards. strncpy(m_name, f_name, NAME_SIZE); - m_name[NAME_SIZE - 1u] = '\0'; + m_name[NAME_SIZE - 1U] = '\0'; m_oflags |= (f_accessMode == AccessMode::readOnly) ? O_RDONLY : O_RDWR; m_oflags |= (f_ownerShip == OwnerShip::mine) ? O_CREAT | O_EXCL : 0; @@ -124,7 +126,7 @@ int32_t SharedMemory::getHandle() const bool SharedMemory::open() { // the mask will be applied to the permissions, therefore we need to set it to 0 - mode_t umaskSaved = umask(0u); + mode_t umaskSaved = umask(0U); // if we create the shm, cleanup old resources if (m_oflags & O_CREAT) diff --git a/iceoryx_utils/test/CMakeLists.txt b/iceoryx_utils/test/CMakeLists.txt index 8519c493d8..aad07ebe92 100644 --- a/iceoryx_utils/test/CMakeLists.txt +++ b/iceoryx_utils/test/CMakeLists.txt @@ -1,13 +1,24 @@ +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) set(test_iceoryx_utils_VERSION 0) project(test_iceoryx_utils VERSION ${test_iceoryx_utils_VERSION}) find_package(Threads REQUIRED) -if(test AND NOT GTest_FOUND) - find_package(GTest CONFIG REQUIRED) -endif(test AND NOT GTest_FOUND) - set(PROJECT_PREFIX "utils") file(GLOB_RECURSE MODULETESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/moduletests/*.cpp") @@ -27,11 +38,11 @@ set(TEST_LINK_LIBS if(LINUX) set(TEST_LINK_LIBS ${TEST_LINK_LIBS} acl dl pthread rt) - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-pedantic -Wno-conversion) # -Wpedantic results in errors at the time mocks + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) # -Wpedantic results in errors at the time mocks elseif(QNX) - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-pedantic -Wno-conversion) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) elseif(APPLE) - set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} -Wno-pedantic -Wno-conversion) + set(TEST_CXX_FLAGS PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS} -Wno-pedantic -Wno-conversion) elseif(WIN32) set(TEST_CXX_FLAGS PRIVATE /bigobj) endif() @@ -62,17 +73,6 @@ set_target_properties(${PROJECT_PREFIX}_integrationtests PROPERTIES POSITION_INDEPENDENT_CODE ON ) -# component tests -add_executable( ${PROJECT_PREFIX}_componenttests ${COMPONENTTESTS_SRC} ${TESTUTILS_SRC}) -target_compile_options(${PROJECT_PREFIX}_componenttests PRIVATE ${TEST_CXX_FLAGS}) -target_include_directories(${PROJECT_PREFIX}_componenttests PRIVATE .) -target_link_libraries(${PROJECT_PREFIX}_componenttests ${TEST_LINK_LIBS}) -set_target_properties(${PROJECT_PREFIX}_componenttests PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_STANDARD ${ICEORYX_CXX_STANDARD} - POSITION_INDEPENDENT_CODE ON -) - # stress tests add_executable( test_stress_sofi stresstests/test_stress_sofi.cpp) target_compile_options(test_stress_sofi PUBLIC ${TEST_CXX_FLAGS}) @@ -82,3 +82,5 @@ set_target_properties(test_stress_sofi PROPERTIES CXX_STANDARD ${ICEORYX_CXX_STANDARD} POSITION_INDEPENDENT_CODE ON ) + +add_subdirectory(stresstests/benchmark_optional_and_expected) diff --git a/iceoryx_utils/test/componenttests/test_utils_component.cpp b/iceoryx_utils/test/componenttests/test_utils_component.cpp deleted file mode 100644 index e601cef499..0000000000 --- a/iceoryx_utils/test/componenttests/test_utils_component.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "test.hpp" - -using namespace ::testing; -using ::testing::_; -using ::testing::Return; - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/iceoryx_utils/test/moduletests/test_posix_access_rights.cpp b/iceoryx_utils/test/moduletests/test_posix_access_rights.cpp index 8aeff8c70b..fe76351ced 100644 --- a/iceoryx_utils/test/moduletests/test_posix_access_rights.cpp +++ b/iceoryx_utils/test/moduletests/test_posix_access_rights.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "iceoryx_utils/cxx/smart_c.hpp" #include "iceoryx_utils/posix_wrapper/posix_access_rights.hpp" #include "test.hpp" @@ -35,7 +36,18 @@ class PosixAccessRights_test : public Test fileStream.open(TestFileName, std::fstream::out | std::fstream::trunc); fileStream.close(); - std::system(std::string("groups > " + TestFileName).c_str()); + auto sysC = iox::cxx::makeSmartC(system, + iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, + {-1}, + {}, + std::string("groups > " + TestFileName).c_str()); + + if (sysC.hasErrors()) + { + std::cerr << "system call failed with error: " << sysC.getErrorString(); + exit(EXIT_FAILURE); + } + internal::CaptureStderr(); } diff --git a/iceoryx_utils/test/moduletests/test_relative_pointer.cpp b/iceoryx_utils/test/moduletests/test_relative_pointer.cpp index 99ad9485fa..af32540746 100644 --- a/iceoryx_utils/test/moduletests/test_relative_pointer.cpp +++ b/iceoryx_utils/test/moduletests/test_relative_pointer.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "iceoryx_utils/cxx/smart_c.hpp" #include "iceoryx_utils/internal/relocatable_pointer/relative_ptr.hpp" #include "iceoryx_utils/platform/fcntl.hpp" #include "iceoryx_utils/platform/mman.hpp" @@ -62,14 +63,41 @@ class RelativePointer_test : public Test public: void SetUp() override { - m_fileDescriptor = shm_open("TestShm", OFlags, ShmMode); - ftruncate(m_fileDescriptor, ShmSize); + auto shmOpenC = iox::cxx::makeSmartC( + shm_open, iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, "TestShm", OFlags, ShmMode); + + if (shmOpenC.hasErrors()) + { + std::cerr << "ftruncate failed with error: " << shmOpenC.getErrorString(); + exit(EXIT_FAILURE); + } + + m_fileDescriptor = shmOpenC.getReturnValue(); + + auto trunC = iox::cxx::makeSmartC( + ftruncate, iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, m_fileDescriptor, ShmSize); + + if (trunC.hasErrors()) + { + std::cerr << "ftruncate failed with error: " << trunC.getErrorString(); + exit(EXIT_FAILURE); + } + + internal::CaptureStderr(); } void TearDown() override { - shm_unlink("TestShm"); + auto shmUnlinkC = + iox::cxx::makeSmartC(shm_unlink, iox::cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, "TestShm"); + + if (shmUnlinkC.hasErrors()) + { + std::cerr << "ftruncate failed with error: " << shmUnlinkC.getErrorString(); + exit(EXIT_FAILURE); + } + iox::RelativePointer::unregisterAll(); std::string output = internal::GetCapturedStderr(); if (Test::HasFailure()) @@ -77,7 +105,7 @@ class RelativePointer_test : public Test std::cout << output << std::endl; } } - int m_fileDescriptor; + uint32_t m_fileDescriptor{0U}; }; template diff --git a/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/CMakeLists.txt b/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/CMakeLists.txt index 253ab0393b..30761eeb76 100644 --- a/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/CMakeLists.txt +++ b/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/CMakeLists.txt @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Build icedelivery example cmake_minimum_required(VERSION 3.5) project(benchmark_optional_and_expected) diff --git a/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/README.md b/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/README.md index ffe92fc515..7737c77654 100644 --- a/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/README.md +++ b/iceoryx_utils/test/stresstests/benchmark_optional_and_expected/README.md @@ -12,8 +12,7 @@ done ``` If you compile it with our default cmake settings you would only compile it in -debug mode which is naturally slower since it is optimized for debugging and not -performance. +release mode which is naturally faster than debug mode since it does not inject debug symbols and uses optimization level `-O2`. This shell command on the other hand does compile the benchmark for all 4 optimization levels from `-O0` to `-O3` and prints the result for every level. diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 93983751b8..1d31ef5e19 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020 by Robert Bosch GmbH. All rights reserved. +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -52,29 +52,28 @@ ENV PATH="/root/cmake-3.16.3-Linux-x86_64/bin:${PATH}" # Configuration ## Maven Proxy - required for usage from behind a corporate proxy. Corporate proxy should be bound to the docker network bridge at 172.17.0.1. -## If you are not behind a corporate proxy this can be ignored and shouldn't interfere with regular usage. -RUN mkdir -p /root/.m2 -RUN echo '\n\ - \n\ - \n\ - \n\ - true \n\ - http \n\ - 172.17.0.1 \n\ - 3128 \n\ - 127.0.0.1 \n\ - \n\ - \n\ - \n'\ ->> /root/.m2/settings.xml +#RUN mkdir -p /root/.m2 +#RUN echo '\n\ +# \n\ + # \n\ + # \n\ + #true \n\ + #http \n\ + #172.17.0.1 \n\ + #3128 \n\ + #127.0.0.1 \n\ + # \n\ + # \n\ +# \n'\ +#>> /root/.m2/settings.xml ADD . /iceoryx WORKDIR /iceoryx -RUN ./tools/iceoryx_build_test.sh release with-dds-gateway +RUN ./tools/iceoryx_build_test.sh build-all # ======================================================================================================================== # diff --git a/tools/docker/README.md b/tools/docker/README.md index 81e57a937b..4b70001a5a 100644 --- a/tools/docker/README.md +++ b/tools/docker/README.md @@ -31,30 +31,32 @@ To bind a shell to the container, simply run the following script from any locat You will then be dropped into a bash shell where you can access all iceoryx binaries. All iceoryx binaries are directly available in the $PATH of the shell. -For example, to start the sender application, you need only run the following from the bound bash shell: +For example, to start a sender application, you can run the following from the bound bash shell: ``` -root@b10b3630f6d3:/# ice-publisher-simple -2020-07-02 16:18:58.811 [ Debug ]: Application registered management segment 0x7f9c7fbc4000 with size 71546016 to id 1 -2020-07-02 16:18:58.811 [ Info ]: Application registered payload segment 0x7f9c76d0a000 with size 149655680 to id 2 -Sending: 0 -Sending: 1 -Sending: 2 +root@b10b3630f6d3:/# iox-ex-publisher-untyped +2020-12-18 09:04:12.813 [ Debug ]: Application registered management segment 0x7fa1a47c4000 with size 64244064 to id 1 +2020-12-18 09:04:12.813 [ Info ]: Application registered payload segment 0x7fa19b98a000 with size 149134400 to id 2 ``` -To run the receiver application, bind another shell to the container and run the following: +To run the corresponding receiver application, bind another shell to the container and run the following: ``` -root@b10b3630f6d3:/# ice-subscriber-simple -2020-07-02 16:21:00.242 [ Debug ]: Application registered management segment 0x7f9d8fbc4000 with size 71546016 to id 1 -2020-07-02 16:21:00.242 [ Info ]: Application registered payload segment 0x7f9d86d0a000 with size 149655680 to id 2 -Callback: 1 -Callback: 2 -Callback: 3 +root@b10b3630f6d3:/# iox-ex-subscriber-untyped +2020-12-18 09:04:21.692 [ Debug ]: Application registered management segment 0x7fcda1597000 with size 64244064 to id 1 +2020-12-18 09:04:21.692 [ Info ]: Application registered payload segment 0x7fcd9875d000 with size 149134400 to id 2 +Got value: (10, 10, 10) +Got value: (10, 10, 10) +Got value: (11, 11, 11) +Got value: (11, 11, 11) +Got value: (12, 12, 12) +... ``` The complete communication flow should now be observable. +There are a lot more binaries to test, detailed explanations for each can be found in [iceoryx_examples](./../../iceoryx_examples). + ## Using `screen` Another way of interacting with the daemon and examples is to use [screen](https://www.gnu.org/software/screen/) (also included in the Docker image) to start executables in different virtual screens that you attach to and detach from as your experiments may require. @@ -75,15 +77,9 @@ Again, all iceoryx applications are directly available in the $PATH. To launch an example sender application, run the corresponding binary: ``` -root@3b93f0d3eda2:/iceoryx# screen -#[Enter] -root@3b93f0d3eda2:/iceoryx# ice-publisher-simple -Sending: 0 -Sending: 1 -Sending: 2 -Sending: 3 -Sending: 4 -... +root@b10b3630f6d3 /# iox-ex-publisher-untyped +2020-12-18 09:28:17.541 [ Debug ]: Application registered management segment 0x7f2f615d9000 with size 64244064 to id 1 +2020-12-18 09:28:17.541 [ Info ]: Application registered payload segment 0x7f2f5879f000 with size 149134400 to id 2 ``` Press `[Ctrl]+A D` to detach from this virtual screen. @@ -91,14 +87,17 @@ Press `[Ctrl]+A D` to detach from this virtual screen. Then, the receiver application can be started in a separate virtual screen: ``` -root@3b93f0d3eda2:/iceoryx# screen +root@b10b3630f6d3:/# screen #[Enter] -root@3b93f0d3eda2:/iceoryx# ice-subscriber-simple -Not subscribed -Receiving: 12 -Receiving: 13 -Receiving: 14 -Receiving: 15 +root@b10b3630f6d3 /# iox-ex-subscriber-untyped +2020-12-18 09:29:24.082 [ Debug ]: Application registered management segment 0x7f39fb9fe000 with size 64244064 to id 1 +2020-12-18 09:29:24.083 [ Info ]: Application registered payload segment 0x7f39f2bc4000 with size 149134400 to id 2 +Got value: (14, 14, 14) +Got value: (14, 14, 14) +Got value: (15, 15, 15) +Got value: (15, 15, 15) +Got value: (16, 16, 16) +Got value: (16, 16, 16) ... ``` @@ -110,11 +109,10 @@ As an exercise, you can return to previous screen sessions to observe their curr For examples, here we list all screens and return to the one running the sender: ``` -root@d3e51ca29d56:/iceoryx# screen -r +root@b10b3630f6d3:/# screen -r There are several suitable screens on: - 66.pts-0.d3e51ca29d56 (12/06/19 08:55:00) (Detached) - 35.pts-0.d3e51ca29d56 (12/06/19 08:54:48) (Detached) - 17.pts-0.d3e51ca29d56 (12/06/19 08:53:57) (Detached) + 66.pts-0.b10b3630f6d3 (12/18/20 09:29:24) (Detached) + 35.pts-0.b10b3630f6d3 (12/18/20 09:28:17) (Detached) Type "screen [-d] -r [pid.]tty.host" to resume one of them. ``` @@ -124,41 +122,23 @@ Try the following to return to the sender application (adjust the PID as per you screen -r 35 ``` -You should see again the virtual screen of the sender application: - -``` -Sending: 212 -Sending: 213 -Sending: 214 -Sending: 215 -Sending: 216 -... -``` - -You can stop the sender with `[Ctrl]+C`, and then detach from this screen with `[Ctrl]+A D`, and return to the receiver screen with (adjusting the PID as per your `screen -r` output above): +You should see again the virtual screen of the sender application. You can stop the sender with `[Ctrl]+C`, and then detach +from this screen with `[Ctrl]+A D`, and return to the receiver screen with (adjusting the PID as per your `screen -r` output above): ``` screen -r 66 ``` -and you should see current receiver output such as: - -``` -Not subscribed -Not subscribed -Not subscribed -Not subscribed -Not subscribed -... -``` +and you should see the receiver output again. As an exercise, try return to the sender screen and relaunch the sender, then detach from the sender screen and attach to the receiver screen and see the output based on the new sender: ``` -Receiving: 103 -Receiving: 104 -Receiving: 105 -Receiving: 106 -Receiving: 107 +Got value: (104, 104, 104) +Got value: (104, 104, 104) +Got value: (105, 105, 105) +Got value: (105, 105, 105) +Got value: (106, 106, 106) +Got value: (106, 106, 106) ... ``` diff --git a/tools/gcov/gcovr_html.conf b/tools/gcov/gcovr_html.conf deleted file mode 100644 index db0948b63d..0000000000 --- a/tools/gcov/gcovr_html.conf +++ /dev/null @@ -1,11 +0,0 @@ -exclude = .*build* -exclude = .*test* -exclude = .*moduletest* -exclude = .*integrationtest* -exclude = .*componenttest* -exclude = .*mocks* -exclude = .*testutils* -exclude = .*gmock* -html-details = yes -output = build/gcov/iceoryx_coverage.html -gcov-parallel = 4 diff --git a/tools/gcov/gcovr_sonarqube.conf b/tools/gcov/gcovr_sonarqube.conf deleted file mode 100644 index 4cf8558afe..0000000000 --- a/tools/gcov/gcovr_sonarqube.conf +++ /dev/null @@ -1,10 +0,0 @@ -exclude = .*build* -exclude = .*test* -exclude = .*moduletest* -exclude = .*integrationtest* -exclude = .*componenttest* -exclude = .*mocks* -exclude = .*testutils* -exclude = .*gmock* -sonarqube = build/gcov/iceoryx_coverage.xml -gcov-parallel = 4 diff --git a/tools/gcov/lcov_generate.sh b/tools/gcov/lcov_generate.sh index 569749c358..06b0f4ae37 100755 --- a/tools/gcov/lcov_generate.sh +++ b/tools/gcov/lcov_generate.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2019-2020 by Robert Bosch GmbH. All rights reserved. +# Copyright (c) 2019-2020, 2020 by Robert Bosch GmbH, Apex AI Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,20 +20,20 @@ OUTPUT_FOLDER=$BUILD_FOLDER/build/lcov mkdir -p $OUTPUT_FOLDER -case "$2" in +case "$2" in "initial") lcov -c -i -d $BUILD_FOLDER -o $OUTPUT_FOLDER/iceoryx_init.info --no-external --rc lcov_branch_coverage=1 ;; - "capture") + "capture") lcov -c -d $BUILD_FOLDER -o $OUTPUT_FOLDER/iceoryx_test.info --no-external --rc lcov_branch_coverage=1 ;; - "combine") + "combine") lcov -a $OUTPUT_FOLDER/iceoryx_init.info --add-tracefile $OUTPUT_FOLDER/iceoryx_test.info -o $OUTPUT_FOLDER/iceoryx_full.info --rc lcov_branch_coverage=1 ;; - "remove") - lcov -o $OUTPUT_FOLDER/iceoryx_filter.info --rc lcov_branch_coverage=1 -r $OUTPUT_FOLDER/iceoryx_full.info "*/build/*" "*/test/*" "*/testutils/*" "*/roudi_environment/*" + "remove") + lcov -o $OUTPUT_FOLDER/iceoryx_filter.info --rc lcov_branch_coverage=1 -r $OUTPUT_FOLDER/iceoryx_full.info "*/build/*" "*/test/*" "*/iceoryx_examples/*" "*/testutils/*" "*/roudi_environment/*" ;; - "genhtml") - genhtml $OUTPUT_FOLDER/iceoryx_filter.info -o $OUTPUT_FOLDER --config-file $BUILD_FOLDER/tools/gcov/lcovr_html.conf --legend --show-details --branch-coverage + "genhtml") + genhtml $OUTPUT_FOLDER/iceoryx_filter.info -o $OUTPUT_FOLDER --config-file --legend --show-details --branch-coverage ;; esac diff --git a/tools/iceoryx_build_test.sh b/tools/iceoryx_build_test.sh index 15a2e7df97..93229a4ea6 100755 --- a/tools/iceoryx_build_test.sh +++ b/tools/iceoryx_build_test.sh @@ -32,32 +32,31 @@ BUILD_TYPE="" STRICT_FLAG="OFF" TEST_FLAG="OFF" COV_FLAG="OFF" -GCOV_SCOPE="all" #possible values for gcov test scope: 'all', 'unit', 'integration', 'component' -COV_OUTPUT="$WORKSPACE/tools/gcov/gcovr_html.conf" -QACPP_JSON="OFF" +TEST_SCOPE="all" #possible values for test scope: 'all', 'unit', 'integration' RUN_TEST=false INTROSPECTION_FLAG="ON" DDS_GATEWAY_FLAG="OFF" +BINDING_C_FLAG="ON" ONE_TO_MANY_ONLY_FLAG="OFF" SANITIZE_FLAG="OFF" +ROUDI_ENV_FLAG="OFF" +OUT_OF_TREE_FLAG="OFF" +EXAMPLE_FLAG="OFF" +BUILD_ALL_FLAG="OFF" +EXAMPLES="ice_multi_publisher icedelivery singleprocess waitset" while (( "$#" )); do case "$1" in - -b|--builddir) + -b|--build-dir) BUILD_DIR=$(realpath $2) shift 2 ;; - -j|--jobs) - NUM_JOBS=$2 - shift 2 - ;; -c|--coverage) echo "$2" - GCOV_SCOPE="$2" + TEST_SCOPE="$2" BUILD_TYPE="Debug" RUN_TEST=true COV_FLAG="ON" - if [ -z "$2" ] then shift 1 @@ -77,27 +76,23 @@ while (( "$#" )); do BUILD_TYPE="Debug" shift 1 ;; - "strict") + "build-strict") STRICT_FLAG="ON" shift 1 ;; - "qacpp") - BUILD_TYPE="Release" - QACPP_JSON="ON" - shift 1 - ;; "test") RUN_TEST=true TEST_FLAG="ON" shift 1 ;; - "gcov-sonarqube") - COV_OUTPUT="$WORKSPACE/tools/gcov/gcovr_sonarqube.conf" + "dds-gateway") + echo " [i] Including DDS gateway in build" + DDS_GATEWAY_FLAG="ON" shift 1 ;; - "with-dds-gateway") + "binding-c") echo " [i] Including DDS gateway in build" - DDS_GATEWAY_FLAG="ON" + BINDING_C_FLAG="ON" shift 1 ;; "build-test") @@ -105,25 +100,44 @@ while (( "$#" )); do TEST_FLAG="ON" shift 1 ;; - "skip-introspection") - echo " [i] Not including introspection client in build." - INTROSPECTION_FLAG="OFF" + "roudi-env") + echo " [i] Building RouDi Environment" + ROUDI_ENV_FLAG="ON" + shift 1 + ;; + "introspection") + echo " [i] Building Introspection" + INTROSPECTION_FLAG="ON" + shift 1 + ;; + "build-all") + echo " [i] Build complete iceoryx with all extensions and all examples" + BUILD_ALL_FLAG="ON" + shift 1 + ;; + "examples") + echo " [i] Build iceoryx with all examples" + EXAMPLE_FLAG="ON" shift 1 ;; - "one-to-many") + "out-of-tree") + echo " [i] Out-of-tree build" + OUT_OF_TREE_FLAG="ON" + shift 1 + ;; + "one-to-many-only") echo " [i] Using 1:n communication only" ONE_TO_MANY_ONLY_FLAG="ON" shift 1 ;; "sanitize") - echo "Build with sanitizers" + echo " [i] Build with sanitizers" BUILD_TYPE="Debug" - TEST_FLAG="ON" SANITIZE_FLAG="ON" shift 1 ;; "clang") - echo "Build with clang compiler" + echo " [i] Build with clang compiler" export CC=$(which clang) export CXX=$(which clang++) shift 1 @@ -133,28 +147,30 @@ while (( "$#" )); do echo "By default, iceoryx, the dds gateway and the examples are built." echo "" echo "Usage:" - echo " iceoryx_build_test.sh [--builddir ] []" + echo " iceoryx_build_test.sh [--build-dir ] []" echo "Options:" - echo " -b --builddir Specify a non-default build directory" - echo " -j --jobs Specify the number of jobs to run simultaneously" - echo " -c --coverage Builds gcov and generate a html/xml report. Possible arguments: 'all', 'unit', 'integration', 'component'" + echo " -b --build-dir Specify a non-default build directory" + echo " -c --coverage Builds gcov and generate a html/xml report. Possible arguments: 'all', 'unit', 'integration'" echo "Args:" - echo " clean Cleans the build directory" - echo " release Build release configuration" + echo " clean Deletes the build/ directory before" + echo " relwithdebinfo Build with -O2 -DNDEBUG" echo " debug Build debug configuration" - echo " strict Build is performed with '-Werror'" - echo " qacpp JSON is generated for QACPP" - echo " test Builds and runs the tests" - echo " with-dds-gateway Builds the iceoryx dds gateway" - echo " build-test Builds the tests (doesn't run)" - echo " skip-introspection Skips building iceoryx introspection" - echo " one-to-many Restricts to 1:n communication only" + echo " examples Build all examples" + echo " buildall Build all extensions and all examples" + echo " out-of-tree Out-of-tree build for CI build" + echo " build-strict Build is performed with '-Werror'" + echo " build-test Builds all tests (doesn't run)" + echo " test Builds and runs all tests in all iceoryx components" + echo " dds-gateway Builds the iceoryx dds gateway" + echo " binding-c Builds the iceoryx C-Binding" + echo " one-to-many-only Restricts to 1:n communication only" echo " clang Build with clang compiler (should be installed already)" echo " sanitize Build with sanitizers" + echo " roudi-env Build the roudi environment" echo " help Prints this help" echo "" - echo "e.g. iceoryx_build_test.sh -b ./build-scripted clean test release" - echo "for gcov report: iceoryx_build_test.sh clean -c unit -j 4" + echo "e.g. iceoryx_build_test.sh -b ./build-scripted clean test" + echo "for gcov report: iceoryx_build_test.sh clean -c unit" exit 0 ;; *) @@ -173,14 +189,18 @@ echo " [i] Building in $BUILD_DIR" #==== Step 1 : Build =============================================================================== #==================================================================================================== -# run number of jobs equal to number of available cores unless manually specified -if [ -z $NUM_JOBS ] -then +# set number of cores for building +if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then + NUM_JOBS=$(nproc) +elif [[ "$OSTYPE" == "darwin"* ]]; then + NUM_JOBS=$(sysctl -n hw.ncpu) +else NUM_JOBS=1 fi echo " [i] Building with $NUM_JOBS jobs" -# clean build folder + +# clean build folders if [ $CLEAN_BUILD == true ] then echo " [i] Cleaning build directory" @@ -196,32 +216,37 @@ cd $BUILD_DIR echo " [i] Current working directory: $(pwd)" echo ">>>>>> Start building iceoryx package <<<<<<" -cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_STRICT=$STRICT_FLAG -DCMAKE_INSTALL_PREFIX=$ICEORYX_INSTALL_PREFIX -DCMAKE_EXPORT_COMPILE_COMMANDS=$QACPP_JSON -DTOML_CONFIG=on -Dtest=$TEST_FLAG -Dcoverage=$COV_FLAG -Droudi_environment=on -Dexamples=ON -Dintrospection=$INTROSPECTION_FLAG -Ddds_gateway=$DDS_GATEWAY_FLAG -Dbinding_c=ON -DONE_TO_MANY_ONLY=$ONE_TO_MANY_ONLY_FLAG -Dsanitize=$SANITIZE_FLAG $WORKSPACE/iceoryx_meta +cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_ALL=$BUILD_ALL_FLAG -DBUILD_STRICT=$STRICT_FLAG -DCMAKE_INSTALL_PREFIX=$ICEORYX_INSTALL_PREFIX \ +-DBUILD_TEST=$TEST_FLAG -DCOVERAGE=$COV_FLAG -DROUDI_ENVIRONMENT=$ROUDI_ENV_FLAG -DEXAMPLES=$EXAMPLE_FLAG -DINTROSPECTION=$INTROSPECTION_FLAG \ +-DDDS_GATEWAY=$DDS_GATEWAY_FLAG -DBINDING_C=$BINDING_C_FLAG -DONE_TO_MANY_ONLY=$ONE_TO_MANY_ONLY_FLAG -DSANITIZE=$SANITIZE_FLAG $WORKSPACE/iceoryx_meta + cmake --build . --target install -- -j$NUM_JOBS echo ">>>>>> Finished building iceoryx package <<<<<<" -# Dont build examples when coverage or sanitization is enabled -if [ "$COV_FLAG" == "ON" ] || [ "$SANITIZE_FLAG" == "ON" ] -then - echo ">>>>>> Skip building iceoryx examples <<<<<<" -else - echo ">>>>>> Start building iceoryx examples <<<<<<" - cd $BUILD_DIR - mkdir -p iceoryx_examples - echo ">>>>>>>> icedelivery" - cd $BUILD_DIR/iceoryx_examples - mkdir -p icedelivery - cd icedelivery - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$ICEORYX_INSTALL_PREFIX -DCMAKE_INSTALL_PREFIX=$ICEORYX_INSTALL_PREFIX $WORKSPACE/iceoryx_examples/icedelivery - cmake --build . --target install -- -j$NUM_JOBS - - echo ">>>>>>>> iceperf" - cd $BUILD_DIR/iceoryx_examples - mkdir -p iceperf - cd iceperf - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$ICEORYX_INSTALL_PREFIX -DCMAKE_INSTALL_PREFIX=$ICEORYX_INSTALL_PREFIX $WORKSPACE/iceoryx_examples/iceperf - cmake --build . --target install -- -j$NUM_JOBS +#==================================================================================================== +#==== Step : Out-of-tree build ===================================================================== +#==================================================================================================== + +if [ "$OUT_OF_TREE_FLAG" == "ON" ]; then + rm -rf $WORKSPACE/build_out_of_tree + if [ "$BINDING_C_FLAG" == "ON" ]; then + EXAMPLES="${EXAMPLES} icedelivery_on_c waitset_on_c iceperf" + fi + echo ">>>>>> Start Out-of-tree build <<<<<<" + echo ${EXAMPLES} + cd $WORKSPACE && mkdir -p build_out_of_tree && cd build_out_of_tree + for ex in ${EXAMPLES} ; do + mkdir -p $ex && cd $ex + cmake -DCMAKE_INSTALL_PREFIX=$ICEORYX_INSTALL_PREFIX $WORKSPACE/iceoryx_examples/$ex + cmake --build . --target install -- -j$NUM_JOBS + if [ $? -ne 0 ]; then + echo "Out of tree build failed" + exit 1 + fi + cd .. + done + echo ">>>>>> Finished Out-of-tree build<<<<<<" fi if [ "$COV_FLAG" == "ON" ] @@ -232,21 +257,14 @@ fi #==================================================================================================== #==== Step 2 : Run all Tests ======================================================================= #==================================================================================================== - -if [ $RUN_TEST == true ] -then - # the absolute path of the directory assigned to the build cd $BUILD_DIR mkdir -p tools cp $WORKSPACE/tools/run_all_tests.sh $BUILD_DIR/tools/run_all_tests.sh -echo " [i] Running all tests" -if [ "$DDS_GATEWAY_FLAG" == "ON" ] -then - $BUILD_DIR/tools/run_all_tests.sh $GCOV_SCOPE with-dds-gateway-tests -else - $BUILD_DIR/tools/run_all_tests.sh $GCOV_SCOPE +if [ $RUN_TEST == true ]; then + echo " [i] Running all tests" + $BUILD_DIR/tools/run_all_tests.sh $TEST_SCOPE fi for COMPONENT in $COMPONENTS; do @@ -258,12 +276,6 @@ for COMPONENT in $COMPONENTS; do exit 1 fi ;; - "component" | "all") - if [ ! -f testresults/"$COMPONENT"_ComponenttestTestResults.xml ]; then - echo "xml:"$COMPONENT"_ComponenttestTestResults.xml not found!" - exit 1 - fi - ;; "integration" | "all") if [ ! -f testresults/"$COMPONENT"_IntegrationTestResults.xml ]; then echo "xml:"$COMPONENT"_IntegrationTestResults.xml not found!" @@ -273,9 +285,6 @@ for COMPONENT in $COMPONENTS; do esac done -fi - - if [ "$COV_FLAG" == "ON" ] then echo ">>>>>> Generate Gcov Report <<<<<<" @@ -285,7 +294,4 @@ then $WORKSPACE/tools/gcov/lcov_generate.sh $WORKSPACE remove #exclude all unnecessary files $WORKSPACE/tools/gcov/lcov_generate.sh $WORKSPACE genhtml #generate html echo ">>>>>> Report Generation complete <<<<<<" - #alternative with gcov currently disabled - #mkdir -p $BUILD_DIR/gcov - #gcovr -r $WORKSPACE --config $COV_OUTPUT fi diff --git a/tools/introspection/CMakeLists.txt b/tools/introspection/CMakeLists.txt index bf3a0e42a7..ec0086c4b6 100644 --- a/tools/introspection/CMakeLists.txt +++ b/tools/introspection/CMakeLists.txt @@ -1,5 +1,20 @@ +# Copyright (c) 2019, 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + cmake_minimum_required(VERSION 3.5) -set(iceoryx_introspection_VERSION 0.16.1) +file (STRINGS "../../VERSION" iceoryx_introspection_VERSION) project(iceoryx_introspection VERSION ${iceoryx_introspection_VERSION}) find_package(iceoryx_posh REQUIRED) @@ -63,7 +78,7 @@ target_link_libraries(iceoryx_introspection ncurses ) -target_compile_options(iceoryx_introspection PRIVATE ${ICEORYX_WARNINGS}) +target_compile_options(iceoryx_introspection PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) if(LINUX) set(LIB_TINFO tinfo) @@ -89,7 +104,7 @@ target_link_libraries(iox-introspection-client ${PROJECT_NAMESPACE}::iceoryx_introspection ) -target_compile_options(iox-introspection-client PRIVATE ${ICEORYX_WARNINGS}) +target_compile_options(iox-introspection-client PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) # ########## exporting library ########## diff --git a/tools/introspection/cmake/Config.cmake.in b/tools/introspection/cmake/Config.cmake.in index 0d5de6b24e..45099aaca8 100644 --- a/tools/introspection/cmake/Config.cmake.in +++ b/tools/introspection/cmake/Config.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + @PACKAGE_INIT@ include(CMakeFindDependencyMacro) diff --git a/tools/run_all_tests.sh b/tools/run_all_tests.sh index 17f55056d5..9aeee4124b 100755 --- a/tools/run_all_tests.sh +++ b/tools/run_all_tests.sh @@ -14,15 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This file runs all tests for Ice0ryx +# This file runs all tests for Iceoryx -COMPONENTS="utils posh binding_c" -GTEST_FILTER="*" BASE_DIR=$PWD -GCOV_SCOPE="all" +TEST_SCOPE="all" CONTINUE_ON_ERROR=false +ASAN_ONLY=false -set_sanitizer_options () { +set_sanitizer_options() { # This script runs from build folder cd .. local PROJECT_ROOT=$PWD @@ -30,188 +29,118 @@ set_sanitizer_options () { echo "Project root is PROJECT_ROOT" -# new_delete_type_mismatch is disabled because of the below error -# ==112203==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x622000021100 in thread T0: -# object passed to delete has wrong type: -# size of the allocated type: 5120 bytes; -# size of the deallocated type: 496 bytes. -# #0 0x7fd36deac9d8 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe19d8) -# #1 0x55c8284bcc43 in ReceiverPort_test::~ReceiverPort_test() /home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/iceoryx_posh/test/moduletests/test_posh_receiverport.cpp:49 -# #2 0x55c8284c15d1 in ReceiverPort_test_newdata_Test::~ReceiverPort_test_newdata_Test() /home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/iceoryx_posh/test/moduletests/test_posh_receiverport.cpp:137 -# #3 0x55c8284c15ed in ReceiverPort_test_newdata_Test::~ReceiverPort_test_newdata_Test() /home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/iceoryx_posh/test/moduletests/test_posh_receiverport.cpp:137 -# #4 0x55c82857b2fb in testing::Test::DeleteSelf_() (/home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/build/posh/test/posh_moduletests+0x3432fb) + # new_delete_type_mismatch is disabled because of the below error + # ==112203==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x622000021100 in thread T0: + # object passed to delete has wrong type: + # size of the allocated type: 5120 bytes; + # size of the deallocated type: 496 bytes. + # #0 0x7fd36deac9d8 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe19d8) + # #1 0x55c8284bcc43 in ReceiverPort_test::~ReceiverPort_test() /home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/iceoryx_posh/test/moduletests/test_posh_receiverport.cpp:49 + # #2 0x55c8284c15d1 in ReceiverPort_test_newdata_Test::~ReceiverPort_test_newdata_Test() /home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/iceoryx_posh/test/moduletests/test_posh_receiverport.cpp:137 + # #3 0x55c8284c15ed in ReceiverPort_test_newdata_Test::~ReceiverPort_test_newdata_Test() /home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/iceoryx_posh/test/moduletests/test_posh_receiverport.cpp:137 + # #4 0x55c82857b2fb in testing::Test::DeleteSelf_() (/home/pbt2kor/data/aos/repos/iceoryx_oss/iceoryx/build/posh/test/posh_moduletests+0x3432fb) echo "OSTYPE is $OSTYPE" - if [[ "$OSTYPE" == "linux-gnu"* ]]; then + if [[ "$OSTYPE" == "linux-gnu"* ]] && [[ $ASAN_ONLY == false ]]; then + echo " [i] Leaksanitizer enabled" ASAN_OPTIONS=detect_leaks=1 else - # other OS (Mac here) - # ==23449==AddressSanitizer: detect_leaks is not supported on this platform. + # other OS (Mac here) + # ==23449==AddressSanitizer: detect_leaks is not supported on this platform. + echo " [i] Leaksanitizer disabled" ASAN_OPTIONS=detect_leaks=0 fi ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1:detect_stack_use_after_scope=1:check_initialization_order=true:strict_init_order=true:new_delete_type_mismatch=0:suppressions=$BASE_DIR/sanitizer_blacklist/asan_runtime.txt export ASAN_OPTIONS - export LSAN_OPTIONS=suppressions=$BASE_DIR/sanitizer_blacklist/lsan_runtime.txt + LSAN_OPTIONS=suppressions=$BASE_DIR/sanitizer_blacklist/lsan_runtime.txt + export LSAN_OPTIONS echo "ASAN_OPTIONS : $ASAN_OPTIONS" echo "LSAN_OPTIONS : $LSAN_OPTIONS" } -for arg in "$@" -do +for arg in "$@"; do case "$arg" in - "with-dds-gateway-tests") - COMPONENTS="$COMPONENTS dds_gateway" - ;; - "disable-timing-tests") - GTEST_FILTER="-*.TimingTest_*" - ;; - "only-timing-tests") - GTEST_FILTER="*.TimingTest_*" - ;; - "continue-on-error") - CONTINUE_ON_ERROR=true - ;; - "all" | "component" | "unit" | "integration") - GCOV_SCOPE="$arg" - ;; - *) - echo "" - echo "Test script for iceoryx." - echo "By default all module-, integration- and componenttests are executed." - echo "" - echo "Usage: $0 [OPTIONS]" - echo "Options:" - echo " skip-dds-tests Skips tests for iceoryx_dds" - echo " disable-timing-tests Disables all timing tests" - echo " only-timing-tests Runs only timing tests" - echo " continue-on-error Continue execution upon error" - echo "" - exit -1 - ;; + "only-timing-tests") + TEST_SCOPE="timingtest" + ;; + "asan-only") + ASAN_ONLY=true + TEST_SCOPE="all" + ;; + "continue-on-error") + CONTINUE_ON_ERROR=true + ;; + "all" | "unit" | "integration") + TEST_SCOPE="$arg" + ;; + *) + echo "" + echo "Test script for iceoryx." + echo "By default tests on all levels are executed." + echo "" + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " [all, unit, integration] Testlevel where the test shall run" + echo " only-timing-tests Runs only timing tests" + echo " continue-on-error Continue execution upon error" + echo " asan-only Execute Adress-Sanitizer only" + echo "" + exit -1 + ;; esac -done +done # check if this script is sourced by another script, # if yes then exit properly, so the other script can use this # scripts definitions [[ "${#BASH_SOURCE[@]}" -gt "1" ]] && { return 0; } -if [ -z "$TEST_RESULTS_DIR" ] -then +if [ -z "$TEST_RESULTS_DIR" ]; then TEST_RESULTS_DIR="$(pwd)/testresults" fi mkdir -p "$TEST_RESULTS_DIR" -echo ">>>>>> Running Ice0ryx Tests <<<<<<" +echo ">>>>>> Running Iceoryx Tests <<<<<<" -if [ $CONTINUE_ON_ERROR == true ] -then -# Continue executing tests , when a test fails +if [ $CONTINUE_ON_ERROR == true ]; then + # Continue executing tests , when a test fails set +e else -# Stop executing tests , when a test fails + # Stop executing tests , when a test fails set -e fi -failed_tests=0 -execute_test () { - local component=$1 - local test_scope=$2 - - case $test_scope in - "unit") - test_binary="$component"_moduletests - result_file="$component"_ModuleTestResults.xml - ;; - "component") - test_binary="$component"_componenttests - result_file="$component"_ComponenttestTestResults.xml - ;; - "integration") - test_binary="$component"_integrationtests - result_file="$component"_IntegrationTestResults.xml - ;; - *) - echo "Wrong scope $test_scope!" - ;; - esac - - # Runs only tests available for the given component - if [ -f ./$test_binary ]; then - echo "Executing $test_binary" - ./$test_binary --gtest_filter="${GTEST_FILTER}" --gtest_output="xml:$TEST_RESULTS_DIR/$result_file" - fi - - # return code from test application is non-zero -> some test cases failed - if [ $? != 0 ]; then - ((failed_tests++)) - echo "$test_scope test for $component failed!" - fi -} - set_sanitizer_options -execute_test () { - local component=$1 - local test_scope=$2 +execute_test() { + local test_scope=$1 local test_binary="" + echo ">>>>>> executing tests for $test_scope <<<<<<" + echo "" + case $test_scope in - "unit") - test_binary="$component"_moduletests - result_file="$component"_ModuleTestResults.xml + "all") + make all_tests + ;; + "unit") + make module_tests ;; - "component") - test_binary="$component"_componenttests - result_file="$component"_ComponenttestTestResults.xml + "integration") + make integration_tests ;; - "integration") - test_binary="$component"_integrationtests - result_file="$component"_IntegrationTestResults.xml + "timingtest") + make timing_tests ;; - *) + *) echo "Wrong scope $test_scope!" ;; esac - - # Runs only tests available for the given component - if [ -f ./$test_binary ]; then - echo "Executing $test_binary" - ./$test_binary --gtest_filter="${GTEST_FILTER}" --gtest_output="xml:$TEST_RESULTS_DIR/$result_file" - fi - - if [ $? != 0 ]; then - echo "$test_scope test for $component failed!" - fi } -for COMPONENT in $COMPONENTS; do - echo "" - echo "######################## executing tests for $COMPONENT ########################" - cd $BASE_DIR/$COMPONENT/test - - if [ $GCOV_SCOPE == "unit" ] || [ $GCOV_SCOPE == "all" ]; then - execute_test $COMPONENT unit - fi - if [ $GCOV_SCOPE == "component" ] || [ $GCOV_SCOPE == "all" ]; then - execute_test $COMPONENT component - fi - if [ $GCOV_SCOPE == "integration" ] || [ $GCOV_SCOPE == "all" ]; then - execute_test $COMPONENT integration - fi -done +execute_test $TEST_SCOPE # do not start RouDi while the module and componenttests are running; # they might do things which hurts RouDi, like in the roudi_shm test where named semaphores are opened and closed -if [ $failed_tests != 0 ] -then - echo "$failed_tests tests failed!" -fi -echo ">>>>>> Finished Running Iceoryx Tests <<<<<<" -# set return code to indicate test execution status (code = number of failed tests) -# this return code should not be interpreted as standard unix return code -exit $failed_tests - -