diff --git a/.github/workflows/lint_pull_request.yml b/.github/workflows/lint_pull_request.yml index 5b00140ea9..15b92f8926 100644 --- a/.github/workflows/lint_pull_request.yml +++ b/.github/workflows/lint_pull_request.yml @@ -53,7 +53,7 @@ jobs: retention-days: 7 - name: Link Checker - uses: lycheeverse/lychee-action@v1.5.4 + uses: lycheeverse/lychee-action@v1.8.0 with: fail: true args: --cache --insecure --max-cache-age 7d --verbose --no-progress './**/*.md' --github-token ${{secrets.GITHUB_TOKEN}} --max-concurrency 1 diff --git a/.github/workflows/release_build_publish.yml b/.github/workflows/release_build_publish.yml index b641cd682e..4510206812 100644 --- a/.github/workflows/release_build_publish.yml +++ b/.github/workflows/release_build_publish.yml @@ -47,7 +47,7 @@ jobs: $GITHUB_WORKSPACE/tools/iceoryx_build_test.sh clean package - name: Upload release artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: release_artifacts path: ./build_package/iceoryx*.deb @@ -59,7 +59,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: release_artifacts diff --git a/doc/design/diagrams/iceoryx_components_diagram_v3_0_0.puml b/doc/design/diagrams/iceoryx_components_diagram_v3_0_0.puml index 8e63edf34d..71062cc8b1 100644 --- a/doc/design/diagrams/iceoryx_components_diagram_v3_0_0.puml +++ b/doc/design/diagrams/iceoryx_components_diagram_v3_0_0.puml @@ -24,7 +24,6 @@ skinparam frame { ' @todo #539 ' RouDi split, separate files and namespaces for static/dynamic discovery ' Implement exported libraries (add_library in iceoryx_posh/CMakeLists.txt) -' RouDiEnvironment shall not be in roudi namespace, but in testing header Eclipse iceoryx component overview diff --git a/doc/website/images/iceoryx_components_diagram_v3_0_0.svg b/doc/website/images/iceoryx_components_diagram_v3_0_0.svg index d6d7c10d38..d133986b01 100644 --- a/doc/website/images/iceoryx_components_diagram_v3_0_0.svg +++ b/doc/website/images/iceoryx_components_diagram_v3_0_0.svg @@ -86,7 +86,6 @@ skinparam frame { ' @todo #539 ' RouDi split, separate files and namespaces for static/dynamic discovery ' Implement exported libraries (add_library in iceoryx_posh/CMakeLists.txt) -' RouDiEnvironment shall not be in roudi namespace, but in testing header Eclipse iceoryx component overview @@ -329,4 +328,4 @@ JVM: Java HotSpot(TM) 64-Bit Server VM Default Encoding: UTF-8 Language: en Country: US ---> \ No newline at end of file +--> diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index c10166e02b..24e225637e 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -160,6 +160,7 @@ - Better align `iox::expected` with `std::expected` [\#1969](https://github.com/eclipse-iceoryx/iceoryx/issues/1969) - Use logger for "RouDi is ready for clients" message [\#1994](https://github.com/eclipse-iceoryx/iceoryx/issues/1994) - Speed up posh tests [#1030](https://github.com/eclipse-iceoryx/iceoryx/issues/1030) +- Roudi Environment independent from Googletest [#1533](https://github.com/eclipse-iceoryx/iceoryx/issues/1533) **Workflow:** @@ -1181,3 +1182,33 @@ }; ``` + +53. `iox::roudi::RouDiEnvironment` is moved to `iox::roudi_env::RouDiEnv` and in a separate library + + There is still an alias on the old location with a deprecation warning. The API also changed a bit. + ```cpp + // before + #include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" + iox::roudi::RouDiEnvironment roudiEnv{/*config*/}; + + // after + #include "iceoryx_posh/roudi_env/roudi_environment.hpp" + iox::roudi_env::RouDiEnv roudiEnv{/*config*/}; + + + // before + roudiEnv.InterOpWait(); + + // after + roudiEnv.triggerDiscoveryLoopAndWaitToFinish(); + + + // before + roudiEnv.SetInterOpWaitingTime(/*chrono*/); + + // after + roudiEnv.setDiscoveryLoopWaitToFinishTimeout(/*units::Duration*/); + + ``` + + It is now also possible to directly link to `iceoryx_posh::iceoryx_posh_roudi_env` which has no dependency to gTest. diff --git a/iceoryx_binding_c/test/BUILD.bazel b/iceoryx_binding_c/test/BUILD.bazel index 2ca0ca472a..30d61cb296 100644 --- a/iceoryx_binding_c/test/BUILD.bazel +++ b/iceoryx_binding_c/test/BUILD.bazel @@ -43,6 +43,7 @@ cc_test( "//iceoryx_binding_c", "//iceoryx_hoofs:iceoryx_hoofs_testing", "//iceoryx_posh", + "//iceoryx_posh:iceoryx_posh_roudi_env", "//iceoryx_posh:iceoryx_posh_testing", ], ) diff --git a/iceoryx_binding_c/test/moduletests/test_chunk.cpp b/iceoryx_binding_c/test/moduletests/test_chunk.cpp index cc0864db4e..7491ee78b3 100644 --- a/iceoryx_binding_c/test/moduletests/test_chunk.cpp +++ b/iceoryx_binding_c/test/moduletests/test_chunk.cpp @@ -22,13 +22,15 @@ extern "C" { #include "iceoryx_hoofs/error_handling/error_handling.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" namespace { +using namespace ::testing; using namespace iox; using namespace iox::mepoo; +using namespace iox::roudi_env; using namespace iox::testing; class Chunk_test : public RouDi_GTest diff --git a/iceoryx_binding_c/test/moduletests/test_node.cpp b/iceoryx_binding_c/test/moduletests/test_node.cpp index 7dc156b68f..d1f57f287c 100644 --- a/iceoryx_binding_c/test/moduletests/test_node.cpp +++ b/iceoryx_binding_c/test/moduletests/test_node.cpp @@ -17,8 +17,8 @@ #include "iceoryx_hoofs/error_handling/error_handling.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" #include @@ -29,8 +29,10 @@ extern "C" { namespace { +using namespace ::testing; using namespace iox; using namespace iox::runtime; +using namespace iox::roudi_env; using namespace iox::testing; class iox_node_test : public RouDi_GTest diff --git a/iceoryx_binding_c/test/moduletests/test_publisher.cpp b/iceoryx_binding_c/test/moduletests/test_publisher.cpp index 7b0ddf7f86..25a851cee3 100644 --- a/iceoryx_binding_c/test/moduletests/test_publisher.cpp +++ b/iceoryx_binding_c/test/moduletests/test_publisher.cpp @@ -24,8 +24,8 @@ #include "iceoryx_posh/internal/popo/ports/publisher_port_roudi.hpp" #include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" using namespace iox; using namespace iox::popo; @@ -42,6 +42,7 @@ namespace { using namespace ::testing; using namespace iox::testing; +using namespace iox::roudi_env; using namespace iox::capro; using namespace iox::cxx; using namespace iox::mepoo; @@ -143,7 +144,7 @@ TEST(iox_pub_test_DeathTest, initPublisherWithNotInitializedPublisherOptionsTerm TEST_F(iox_pub_test, initPublisherWithDefaultOptionsWorks) { ::testing::Test::RecordProperty("TEST_ID", "d2e677cd-2fcc-47a2-80e6-2d08245b7c1a"); - iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()}; + iox::roudi_env::RouDiEnv roudiEnv{MinimalRouDiConfigBuilder().create()}; iox_runtime_init("hypnotoad"); diff --git a/iceoryx_binding_c/test/moduletests/test_runtime.cpp b/iceoryx_binding_c/test/moduletests/test_runtime.cpp index 11fb1ce848..fe54a12bb8 100644 --- a/iceoryx_binding_c/test/moduletests/test_runtime.cpp +++ b/iceoryx_binding_c/test/moduletests/test_runtime.cpp @@ -21,13 +21,15 @@ extern "C" { #include "iceoryx_hoofs/error_handling/error_handling.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" #include "iceoryx_posh/iceoryx_posh_types.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" namespace { +using namespace ::testing; using namespace iox; using namespace iox::runtime; +using namespace iox::roudi_env; using namespace iox::testing; class BindingC_Runtime_test : public RouDi_GTest diff --git a/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp b/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp index db97aa233d..2df97f6922 100644 --- a/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp +++ b/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp @@ -16,12 +16,13 @@ #include "iceoryx_hoofs/error_handling/error_handling.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/runtime/service_discovery.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" using namespace iox; using namespace iox::runtime; +using namespace iox::roudi_env; using namespace iox::testing; extern "C" { @@ -83,7 +84,7 @@ TEST_F(iox_service_discovery_test, ::testing::Test::RecordProperty("TEST_ID", "09a2cd6c-fba9-4b9d-af96-c5a6cc168d98"); // let the roudi discovery loop run at least once - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); iox_service_discovery_find_service_apply_callable_with_context_data( sut, nullptr, nullptr, nullptr, findHandler, &searchResult, MessagingPattern_PUB_SUB); @@ -103,7 +104,7 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableAndContextDataReturnsO ASSERT_NE(publisher, nullptr); const iox_service_description_t SERVICE_DESCRIPTION = iox_pub_get_service_description(publisher); - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); iox_service_discovery_find_service_apply_callable_with_context_data(sut, SERVICE_DESCRIPTION.serviceString, @@ -124,7 +125,7 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableWithNullptrsForService { ::testing::Test::RecordProperty("TEST_ID", "ec565ca3-7494-42d7-9440-2000f1513759"); - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); auto findHandler = [](const iox_service_description_t s) { EXPECT_THAT(s.instanceString, StrEq("RouDi_ID")); }; iox_service_discovery_find_service_apply_callable( @@ -140,7 +141,7 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableReturnsFindsCorrectSer auto* publisher = iox_pub_init(&storage, "service", "instance", "event", &options); ASSERT_NE(publisher, nullptr); - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); auto findHandler = [](const iox_service_description_t s) { EXPECT_THAT(s.serviceString, StrEq("service")); @@ -157,7 +158,7 @@ TEST_F(iox_service_discovery_test, FindServiceWithNullptrsForServiceInstanceEven { ::testing::Test::RecordProperty("TEST_ID", "75b411d7-b8c7-42d5-8acd-3916fd172081"); - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); const uint64_t SERVICE_CONTAINER_CAPACITY = 10U; iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY]; @@ -189,7 +190,7 @@ TEST_F(iox_service_discovery_test, FindServiceReturnsOfferedService) ASSERT_NE(publisher, nullptr); const iox_service_description_t SERVICE_DESCRIPTION = iox_pub_get_service_description(publisher); - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); const uint64_t SERVICE_CONTAINER_CAPACITY = 10U; iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY]; @@ -216,7 +217,7 @@ TEST_F(iox_service_discovery_test, FindServiceReturnsCorrectNumberOfServicesWhen { ::testing::Test::RecordProperty("TEST_ID", "01047b88-f257-447c-8c5e-9bef7c358433"); - InterOpWait(); + triggerDiscoveryLoopAndWaitToFinish(); const uint64_t SERVICE_CONTAINER_CAPACITY = 3U; iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY]; diff --git a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp index 64d32f6aaa..8eaff88ae1 100644 --- a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp +++ b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp @@ -26,12 +26,13 @@ #include "iceoryx_posh/internal/popo/ports/subscriber_port_single_producer.hpp" #include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include "mocks/wait_set_mock.hpp" using namespace iox; using namespace iox::popo; +using namespace iox::roudi_env; using namespace iox::testing; extern "C" { @@ -148,7 +149,7 @@ TEST_F(iox_sub_test, initSubscriberWithNotInitializedSubscriberOptionsTerminates TEST_F(iox_sub_test, initSubscriberWithDefaultOptionsWorks) { ::testing::Test::RecordProperty("TEST_ID", "40eaa006-4781-46cd-bde3-40fa7d572f29"); - iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()}; + RouDiEnv roudiEnv{MinimalRouDiConfigBuilder().create()}; iox_runtime_init("hypnotoad"); @@ -405,7 +406,7 @@ TEST_F(iox_sub_test, hasDataTriggersWaitSetWithCorrectCallback) TEST_F(iox_sub_test, deinitSubscriberDetachesTriggerFromWaitSet) { ::testing::Test::RecordProperty("TEST_ID", "93e350fb-5430-43ff-982b-b43c6ae9b890"); - iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()}; + RouDiEnv roudiEnv{MinimalRouDiConfigBuilder().create()}; iox_runtime_init("hypnotoad"); iox_sub_storage_t storage; diff --git a/iceoryx_hoofs/test/moduletests/test_unix_domain_sockets.cpp b/iceoryx_hoofs/test/moduletests/test_unix_domain_sockets.cpp index 013264582a..8ccc40f947 100644 --- a/iceoryx_hoofs/test/moduletests/test_unix_domain_sockets.cpp +++ b/iceoryx_hoofs/test/moduletests/test_unix_domain_sockets.cpp @@ -115,14 +115,14 @@ class UnixDomainSocket_test : public Test .maxMsgSize(UnixDomainSocket::MAX_MESSAGE_SIZE) .maxMsgNumber(MaxMsgNumber) .create() - .expect("Valid UnixDomainSocket")}; + .expect("Failed to create UnixDomainSocket")}; UnixDomainSocket client{UnixDomainSocketBuilder() .name(goodName) .channelSide(IpcChannelSide::CLIENT) .maxMsgSize(UnixDomainSocket::MAX_MESSAGE_SIZE) .maxMsgNumber(MaxMsgNumber) .create() - .expect("Valid UnixDomainSocket")}; + .expect("Failed to create UnixDomainSocket")}; }; constexpr uint64_t UnixDomainSocket_test::MaxMsgNumber; diff --git a/iceoryx_posh/BUILD.bazel b/iceoryx_posh/BUILD.bazel index 153a46b4ab..a131e22ba1 100644 --- a/iceoryx_posh/BUILD.bazel +++ b/iceoryx_posh/BUILD.bazel @@ -190,6 +190,22 @@ cc_binary( ], ) +# +########## build iceoryx posh roudi env lib ########## +# +cc_library( + name = "iceoryx_posh_roudi_env", + srcs = glob(["roudi_env/**/*.cpp"]), + hdrs = glob(["roudi_env/include/**"]), + strip_include_prefix = "roudi_env/include", + visibility = ["//visibility:public"], + deps = [ + ":iceoryx_posh", + ":iceoryx_posh_roudi", + "//iceoryx_hoofs", + ], +) + # ########## build iceoryx posh testing lib ########## # @@ -202,6 +218,7 @@ cc_library( deps = [ ":iceoryx_posh", ":iceoryx_posh_roudi", + ":iceoryx_posh_roudi_env", "//iceoryx_hoofs:iceoryx_hoofs_testing", "@googletest//:gtest", ], diff --git a/iceoryx_posh/CMakeLists.txt b/iceoryx_posh/CMakeLists.txt index ee16919595..6280e5cfc3 100644 --- a/iceoryx_posh/CMakeLists.txt +++ b/iceoryx_posh/CMakeLists.txt @@ -299,8 +299,12 @@ setup_install_directories_and_export_package( INCLUDE_DIRECTORIES include/ ) -add_subdirectory(testing) + +if(ROUDI_ENVIRONMENT OR BUILD_TEST) + add_subdirectory(roudi_env) +endif() if(BUILD_TEST) + add_subdirectory(testing) add_subdirectory(test) endif() diff --git a/iceoryx_posh/cmake/iceoryx_posh_roudi_env.cmake b/iceoryx_posh/cmake/iceoryx_posh_roudi_env.cmake new file mode 100644 index 0000000000..143b0daf07 --- /dev/null +++ b/iceoryx_posh/cmake/iceoryx_posh_roudi_env.cmake @@ -0,0 +1,27 @@ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 + +# +########## dummyConfig.cmake to be able to use find_package with the source tree ########## +# + +if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND_PRINTED) + message(STATUS "The package '${CMAKE_FIND_PACKAGE_NAME}' is used in source code version.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND_PRINTED true CACHE INTERNAL "") +endif() + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp index 1b5abc52e8..a6d038aa08 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp @@ -25,6 +25,11 @@ namespace iox { +namespace roudi_env +{ +class RouDiEnv; +} + namespace popo { /// @brief Struct to signal the constructor to create an invalid id @@ -74,6 +79,11 @@ class UniquePortId : public NewType name, diff --git a/iceoryx_posh/include/iceoryx_posh/runtime/posh_runtime.hpp b/iceoryx_posh/include/iceoryx_posh/runtime/posh_runtime.hpp index 58730d0462..59685fe76a 100644 --- a/iceoryx_posh/include/iceoryx_posh/runtime/posh_runtime.hpp +++ b/iceoryx_posh/include/iceoryx_posh/runtime/posh_runtime.hpp @@ -38,10 +38,10 @@ namespace iox { -namespace roudi +namespace roudi_env { class RuntimeTestInterface; -} // namespace roudi +} // namespace roudi_env namespace runtime { @@ -159,7 +159,7 @@ class PoshRuntime virtual bool sendRequestToRouDi(const IpcMessage& msg, IpcMessage& answer) noexcept = 0; protected: - friend class roudi::RuntimeTestInterface; + friend class roudi_env::RuntimeTestInterface; using factory_t = PoshRuntime& (*)(optional); // Protected constructor for derived classes diff --git a/iceoryx_posh/roudi_env/CMakeLists.txt b/iceoryx_posh/roudi_env/CMakeLists.txt new file mode 100644 index 0000000000..65e6977088 --- /dev/null +++ b/iceoryx_posh/roudi_env/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +# Copyright (c) 2020 - 2022 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. +# +# SPDX-License-Identifier: Apache-2.0 + +# NOTE +# This package must NOT depend in any way on gtest or any other testing framework since +# it will be used from other languages like Rust for integration testing. + +# +######### posh roudi env ########## +# +iox_add_library( + STATIC + TARGET iceoryx_posh_roudi_env + NAMESPACE iceoryx_posh + PROJECT_PREFIX ${PREFIX} + BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include + INSTALL_INTERFACE include/${PREFIX} + EXPORT_INCLUDE_DIRS include/ + PRIVATE_LIBS iceoryx_posh::iceoryx_posh + iceoryx_hoofs::iceoryx_hoofs + iceoryx_posh::iceoryx_posh_roudi + FILES + source/minimal_roudi_config.cpp + source/roudi_env.cpp + source/runtime_test_interface.cpp +) diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp similarity index 87% rename from iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp rename to iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp index d0714e8bbc..7035694d32 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp +++ b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp @@ -14,15 +14,15 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_POSH_ROUDI_ENVIRONMENT_MINIMAL_ROUDI_CONFIG_HPP -#define IOX_POSH_ROUDI_ENVIRONMENT_MINIMAL_ROUDI_CONFIG_HPP +#ifndef IOX_POSH_ROUDI_ENV_MINIMAL_ROUDI_CONFIG_HPP +#define IOX_POSH_ROUDI_ENV_MINIMAL_ROUDI_CONFIG_HPP #include "iceoryx_posh/iceoryx_posh_config.hpp" #include "iox/builder.hpp" namespace iox { -namespace testing +namespace roudi_env { /// @brief Builder for a minimal RouDiConfig_t with only one MemPool. This significantly speeds up tests which create a /// shared memory. @@ -44,7 +44,7 @@ class MinimalRouDiConfigBuilder /// @brief creates the previously configured RouDiConfig_t RouDiConfig_t create() const noexcept; }; -} // namespace testing +} // namespace roudi_env } // namespace iox -#endif // IOX_POSH_ROUDI_ENVIRONMENT_MINIMAL_ROUDI_CONFIG_HPP +#endif // IOX_POSH_ROUDI_ENV_MINIMAL_ROUDI_CONFIG_HPP diff --git a/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/roudi_env.hpp b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/roudi_env.hpp new file mode 100644 index 0000000000..224d6319d8 --- /dev/null +++ b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/roudi_env.hpp @@ -0,0 +1,81 @@ +// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 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. +// +// SPDX-License-Identifier: Apache-2.0 + +#ifndef IOX_POSH_ROUDI_ENV_ROUDI_ENV_HPP +#define IOX_POSH_ROUDI_ENV_ROUDI_ENV_HPP + +#include "iceoryx_posh/iceoryx_posh_config.hpp" +#include "iceoryx_posh/iceoryx_posh_types.hpp" +#include "iceoryx_posh/internal/roudi/roudi.hpp" +#include "iceoryx_posh/roudi/iceoryx_roudi_components.hpp" +#include "iceoryx_posh/roudi/memory/iceoryx_roudi_memory_manager.hpp" +#include "iceoryx_posh/roudi_env/runtime_test_interface.hpp" +#include "iox/duration.hpp" + +namespace iox +{ +namespace roudi +{ +class RouDi; +} +namespace roudi_env +{ + +class RouDiEnv +{ + public: + RouDiEnv(const RouDiConfig_t& roudiConfig = RouDiConfig_t().setDefaults(), + roudi::MonitoringMode monitoringMode = roudi::MonitoringMode::OFF, + const uint16_t uniqueRouDiId = 0u) noexcept; + virtual ~RouDiEnv() noexcept; + + RouDiEnv(RouDiEnv&& rhs) noexcept = default; + RouDiEnv& operator=(RouDiEnv&& rhs) noexcept = default; + + RouDiEnv(const RouDiEnv&) = delete; + RouDiEnv& operator=(const RouDiEnv&) = delete; + + void setDiscoveryLoopWaitToFinishTimeout(const units::Duration timeout) noexcept; + void triggerDiscoveryLoopAndWaitToFinish() noexcept; + + void cleanupAppResources(const RuntimeName_t& name) noexcept; + + protected: + /// @note this is due to ambiguity of the cTor with the default parameter + struct MainCTor + { + }; + /// @brief for implementations on top of RouDiEnv + RouDiEnv(MainCTor, const uint16_t uniqueRouDiId = 0u) noexcept; + + void cleanupRuntimes() noexcept; + + private: + RuntimeTestInterface m_runtimes; +#if defined(__APPLE__) + iox::units::Duration m_discoveryLoopWaitToFinishTimeout{iox::units::Duration::fromMilliseconds(1000)}; +#else + iox::units::Duration m_discoveryLoopWaitToFinishTimeout{iox::units::Duration::fromMilliseconds(200)}; +#endif + std::unique_ptr m_roudiComponents; + std::unique_ptr m_roudiApp; +}; + +} // namespace roudi_env +} // namespace iox + +#endif // IOX_POSH_ROUDI_ENV_ROUDI_ENV_HPP diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/runtime_test_interface.hpp b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/runtime_test_interface.hpp similarity index 97% rename from iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/runtime_test_interface.hpp rename to iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/runtime_test_interface.hpp index 3ea1e960b0..bf4d9270f9 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/runtime_test_interface.hpp +++ b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/runtime_test_interface.hpp @@ -29,11 +29,11 @@ namespace runtime { class PoshRuntime; } -namespace roudi +namespace roudi_env { class RuntimeTestInterface { - friend class RouDiEnvironment; + friend class RouDiEnv; private: bool m_doCleanupOnDestruction{true}; @@ -83,7 +83,7 @@ class RuntimeTestInterface void eraseRuntime(const RuntimeName_t& name); }; -} // namespace roudi +} // namespace roudi_env } // namespace iox #endif // IOX_POSH_ROUDI_ENVIRONMENT_RUNTIME_TEST_INTERFACE_HPP diff --git a/iceoryx_posh/testing/roudi_environment/minimal_roudi_config.cpp b/iceoryx_posh/roudi_env/source/minimal_roudi_config.cpp similarity index 91% rename from iceoryx_posh/testing/roudi_environment/minimal_roudi_config.cpp rename to iceoryx_posh/roudi_env/source/minimal_roudi_config.cpp index 21ecf03152..8b615e6309 100644 --- a/iceoryx_posh/testing/roudi_environment/minimal_roudi_config.cpp +++ b/iceoryx_posh/roudi_env/source/minimal_roudi_config.cpp @@ -14,11 +14,11 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" namespace iox { -namespace testing +namespace roudi_env { RouDiConfig_t MinimalRouDiConfigBuilder::create() const noexcept { @@ -33,5 +33,5 @@ RouDiConfig_t MinimalRouDiConfigBuilder::create() const noexcept return roudiConfig; } -} // namespace testing +} // namespace roudi_env } // namespace iox diff --git a/iceoryx_posh/roudi_env/source/roudi_env.cpp b/iceoryx_posh/roudi_env/source/roudi_env.cpp new file mode 100644 index 0000000000..13afe107b9 --- /dev/null +++ b/iceoryx_posh/roudi_env/source/roudi_env.cpp @@ -0,0 +1,77 @@ +// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 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. +// +// SPDX-License-Identifier: Apache-2.0 + +#include "iceoryx_posh/roudi_env/roudi_env.hpp" +#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp" +#include "iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp" +#include "iceoryx_posh/internal/roudi/roudi.hpp" +#include "iceoryx_posh/runtime/posh_runtime.hpp" + +#include + +namespace iox +{ +namespace roudi_env +{ +RouDiEnv::RouDiEnv(MainCTor, const uint16_t uniqueRouDiId) noexcept +{ + popo::UniquePortId::rouDiEnvOverrideUniqueRouDiId(uniqueRouDiId); +} + +RouDiEnv::RouDiEnv(const RouDiConfig_t& roudiConfig, + const roudi::MonitoringMode monitoringMode, + const uint16_t uniqueRouDiId) noexcept + : RouDiEnv(MainCTor{}, uniqueRouDiId) +{ + m_roudiComponents = std::unique_ptr(new roudi::IceOryxRouDiComponents(roudiConfig)); + m_roudiApp = + std::unique_ptr(new roudi::RouDi(m_roudiComponents->rouDiMemoryManager, + m_roudiComponents->portManager, + roudi::RouDi::RoudiStartupParameters{monitoringMode, false})); +} + +RouDiEnv::~RouDiEnv() noexcept +{ + if (m_runtimes.m_doCleanupOnDestruction) + { + popo::UniquePortId::rouDiEnvOverrideUniqueRouDiId(roudi::DEFAULT_UNIQUE_ROUDI_ID); + } + cleanupRuntimes(); +} + +void RouDiEnv::setDiscoveryLoopWaitToFinishTimeout(const units::Duration timeout) noexcept +{ + m_discoveryLoopWaitToFinishTimeout = timeout; +} + +void RouDiEnv::triggerDiscoveryLoopAndWaitToFinish() noexcept +{ + m_roudiApp->triggerDiscoveryLoopAndWaitToFinish(m_discoveryLoopWaitToFinishTimeout); +} + +void RouDiEnv::cleanupAppResources(const RuntimeName_t& name) noexcept +{ + m_runtimes.eraseRuntime(name); +} + +void RouDiEnv::cleanupRuntimes() noexcept +{ + m_runtimes.cleanupRuntimes(); +} + +} // namespace roudi_env +} // namespace iox diff --git a/iceoryx_posh/testing/roudi_environment/runtime_test_interface.cpp b/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp similarity index 97% rename from iceoryx_posh/testing/roudi_environment/runtime_test_interface.cpp rename to iceoryx_posh/roudi_env/source/runtime_test_interface.cpp index 74b6b726e8..114cff2380 100644 --- a/iceoryx_posh/testing/roudi_environment/runtime_test_interface.cpp +++ b/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp @@ -15,12 +15,12 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_posh/testing/roudi_environment/runtime_test_interface.hpp" +#include "iceoryx_posh/roudi_env/runtime_test_interface.hpp" #include "iceoryx_posh/internal/runtime/posh_runtime_impl.hpp" namespace iox { -namespace roudi +namespace roudi_env { using runtime::PoshRuntime; @@ -124,5 +124,5 @@ PoshRuntime& RuntimeTestInterface::runtimeFactoryGetInstance(optionaldiscoveryMemoryManager(); - if (!maybediscoveryMemoryManager.has_value()) + auto maybeDiscoveryMemoryManager = m_roudiMemoryInterface->discoveryMemoryManager(); + if (!maybeDiscoveryMemoryManager.has_value()) { IOX_LOG(FATAL) << "Could not get MemoryManager for discovery!"; errorHandler(PoshError::PORT_MANAGER__DISCOVERY_MEMORY_MANAGER_UNAVAILABLE, iox::ErrorLevel::FATAL); } - auto& discoveryMemoryManager = maybediscoveryMemoryManager.value(); + auto& discoveryMemoryManager = maybeDiscoveryMemoryManager.value(); popo::PublisherOptions registryPortOptions; registryPortOptions.historyCapacity = 1U; diff --git a/iceoryx_posh/source/roudi/roudi.cpp b/iceoryx_posh/source/roudi/roudi.cpp index 12e2fb37ef..3b82b5b07b 100644 --- a/iceoryx_posh/source/roudi/roudi.cpp +++ b/iceoryx_posh/source/roudi/roudi.cpp @@ -210,7 +210,7 @@ void RouDi::monitorAndDiscoveryUpdate() noexcept popo::ConditionVariableData conditionVariableData; DiscoveryWaitSet discoveryLoopWaitset{conditionVariableData}; - discoveryLoopWaitset.attachEvent(m_discoveryLoopTrigger).expect("Successfully attaching a single event"); + discoveryLoopWaitset.attachEvent(m_discoveryLoopTrigger).expect("Failed to attach a single event"); bool manuallyTriggered{false}; while (m_runMonitoringAndDiscoveryThread) diff --git a/iceoryx_posh/source/runtime/posh_runtime_impl.cpp b/iceoryx_posh/source/runtime/posh_runtime_impl.cpp index 7f967578cc..20d065d6be 100644 --- a/iceoryx_posh/source/runtime/posh_runtime_impl.cpp +++ b/iceoryx_posh/source/runtime/posh_runtime_impl.cpp @@ -49,7 +49,7 @@ PoshRuntimeImpl::PoshRuntimeImpl(optional name, const Runt .isInterProcessCapable(false) .mutexType(posix::MutexType::NORMAL) .create(m_appIpcRequestMutex) - .expect("Valid Mutex"); + .expect("Failed to create Mutex"); } PoshRuntimeImpl::~PoshRuntimeImpl() noexcept diff --git a/iceoryx_posh/test/BUILD.bazel b/iceoryx_posh/test/BUILD.bazel index d11ab33c75..1cf21cba51 100644 --- a/iceoryx_posh/test/BUILD.bazel +++ b/iceoryx_posh/test/BUILD.bazel @@ -46,6 +46,7 @@ cc_test( "//iceoryx_hoofs:iceoryx_hoofs_testing", "//iceoryx_posh", "//iceoryx_posh:iceoryx_posh_config", + "//iceoryx_posh:iceoryx_posh_roudi_env", "//iceoryx_posh:iceoryx_posh_testing", "@cpptoml", ], @@ -77,6 +78,7 @@ cc_test( "//iceoryx_hoofs:iceoryx_hoofs_testing", "//iceoryx_posh", "//iceoryx_posh:iceoryx_posh_gateway", + "//iceoryx_posh:iceoryx_posh_roudi_env", "//iceoryx_posh:iceoryx_posh_testing", ], ) diff --git a/iceoryx_posh/test/integrationtests/test_client_server.cpp b/iceoryx_posh/test/integrationtests/test_client_server.cpp index 9540b09af9..7ca80fcd78 100644 --- a/iceoryx_posh/test/integrationtests/test_client_server.cpp +++ b/iceoryx_posh/test/integrationtests/test_client_server.cpp @@ -20,8 +20,8 @@ #include "iceoryx_posh/popo/server.hpp" #include "iceoryx_posh/popo/untyped_client.hpp" #include "iceoryx_posh/popo/untyped_server.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" #include "test.hpp" @@ -33,7 +33,7 @@ using namespace ::testing; using namespace iox::popo; using namespace iox::capro; using namespace iox::runtime; -using namespace iox::testing; +using namespace iox::roudi_env; class DummyRequest { diff --git a/iceoryx_posh/test/integrationtests/test_interface_port_stack_blowup.cpp b/iceoryx_posh/test/integrationtests/test_interface_port_stack_blowup.cpp index 0c2f822789..7bf2a7a19f 100644 --- a/iceoryx_posh/test/integrationtests/test_interface_port_stack_blowup.cpp +++ b/iceoryx_posh/test/integrationtests/test_interface_port_stack_blowup.cpp @@ -17,8 +17,8 @@ #include "iceoryx_posh/gateway/gateway_base.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" #include "test.hpp" @@ -28,6 +28,7 @@ namespace using namespace ::testing; using namespace iox::gw; +using namespace iox::roudi_env; using namespace iox::testing; class InterfacePortRequestStackBlowup_test : public RouDi_GTest diff --git a/iceoryx_posh/test/integrationtests/test_popo_pub_sub_listener.cpp b/iceoryx_posh/test/integrationtests/test_popo_pub_sub_listener.cpp index 4658d1c4e7..e0e4f6f1da 100644 --- a/iceoryx_posh/test/integrationtests/test_popo_pub_sub_listener.cpp +++ b/iceoryx_posh/test/integrationtests/test_popo_pub_sub_listener.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/popo/untyped_subscriber.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" #include "test.hpp" @@ -30,6 +30,7 @@ using namespace ::testing; using namespace iox::popo; using namespace iox::capro; using namespace iox::runtime; +using namespace iox::roudi_env; using namespace iox::testing; void onSampleReceivedCallback(Subscriber* subscriber IOX_MAYBE_UNUSED) diff --git a/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp b/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp index 813f2568f2..7839e2a14f 100644 --- a/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp +++ b/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp @@ -23,8 +23,8 @@ #include "iceoryx_posh/popo/wait_set.hpp" #include "iceoryx_posh/roudi/introspection_types.hpp" #include "iceoryx_posh/roudi/roudi_app.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" #include "iox/duration.hpp" #include "iox/optional.hpp" @@ -38,8 +38,8 @@ namespace { using namespace ::testing; using namespace iox::units::duration_literals; +using namespace iox::roudi_env; using iox::mepoo::MePooConfig; -using iox::roudi::RouDiEnvironment; class Mepoo_IntegrationTest : public Test { @@ -115,7 +115,7 @@ class Mepoo_IntegrationTest : public Test const configType defaultconf = configType::DEFAULT) { auto config = createRouDiConfig(memPoolTestContainer, testMempoolConfig, defaultconf); - m_roudiEnv = iox::optional(config); + m_roudiEnv.emplace(config); ASSERT_THAT(m_roudiEnv.has_value(), Eq(true)); @@ -133,7 +133,7 @@ class Mepoo_IntegrationTest : public Test const configType defaultconf = configType::DEFAULT) { auto config = createRouDiConfig(memPoolTestContainer, testMempoolConfig, defaultconf); - m_roudiEnv = iox::optional(config); + m_roudiEnv.emplace(config); ASSERT_THAT(m_roudiEnv.has_value(), Eq(true)); } @@ -347,7 +347,7 @@ class Mepoo_IntegrationTest : public Test iox::optional publisherPort; iox::optional subscriberPort; - iox::optional m_roudiEnv; + iox::optional m_roudiEnv; }; constexpr uint32_t Mepoo_IntegrationTest::DEFAULT_NUMBER_OF_CHUNKS; diff --git a/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp b/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp index 3c4b4d1a79..2090f6e8a1 100644 --- a/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp +++ b/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp @@ -21,8 +21,8 @@ #include "iceoryx_hoofs/testing/watch_dog.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" #include "iox/optional.hpp" #include "iox/stack.hpp" @@ -39,6 +39,7 @@ using namespace ::testing; using namespace iox; using namespace iox::popo; using namespace iox::cxx; +using namespace iox::roudi_env; using namespace iox::testing; template diff --git a/iceoryx_posh/test/integrationtests/test_roudi_roudi_environment.cpp b/iceoryx_posh/test/integrationtests/test_roudi_env.cpp similarity index 62% rename from iceoryx_posh/test/integrationtests/test_roudi_roudi_environment.cpp rename to iceoryx_posh/test/integrationtests/test_roudi_env.cpp index 1a93101897..ebc462336c 100644 --- a/iceoryx_posh/test/integrationtests/test_roudi_roudi_environment.cpp +++ b/iceoryx_posh/test/integrationtests/test_roudi_env.cpp @@ -15,31 +15,23 @@ // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include "test.hpp" namespace { using namespace ::testing; -using namespace iox::roudi; -using namespace iox::testing; +using namespace iox::roudi_env; -class RouDiEnvironment_test : public Test -{ - public: - void SetUp(){}; - void TearDown(){}; -}; - -TEST_F(RouDiEnvironment_test, StartingRouDiTwiceLeadsToError) +TEST(RouDiEnv_test, StartingRouDiTwiceLeadsToError) { ::testing::Test::RecordProperty("TEST_ID", "38075292-7897-4db5-b20e-f06ab324ad31"); - RouDiEnvironment m_sut{MinimalRouDiConfigBuilder().create()}; + RouDiEnv m_sut{MinimalRouDiConfigBuilder().create()}; GTEST_FLAG(death_test_style) = "threadsafe"; - EXPECT_DEATH({ RouDiEnvironment m_sut2{MinimalRouDiConfigBuilder().create()}; }, ".*"); + EXPECT_DEATH({ RouDiEnv m_sut2{MinimalRouDiConfigBuilder().create()}; }, ".*"); } } // namespace diff --git a/iceoryx_posh/test/integrationtests/test_service_discovery.cpp b/iceoryx_posh/test/integrationtests/test_service_discovery.cpp index d6a4d455e0..8378dfb1e8 100644 --- a/iceoryx_posh/test/integrationtests/test_service_discovery.cpp +++ b/iceoryx_posh/test/integrationtests/test_service_discovery.cpp @@ -22,10 +22,10 @@ #include "iceoryx_posh/popo/untyped_publisher.hpp" #include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/popo/wait_set.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iceoryx_posh/runtime/service_discovery.hpp" #include "iceoryx_posh/testing/mocks/posh_runtime_mock.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" #include "iceoryx_posh/testing/roudi_gtest.hpp" #include "test.hpp" @@ -43,11 +43,10 @@ using namespace iox::runtime; using namespace iox::cxx; using namespace iox::popo; using namespace iox::capro; -using namespace iox::testing; +using namespace iox::roudi_env; using iox::capro::IdString_t; using iox::capro::ServiceDescription; using iox::popo::MessagingPattern; -using iox::roudi::RouDiEnvironment; using ServiceContainer = std::vector; @@ -197,7 +196,7 @@ TYPED_TEST(ServiceDiscovery_test, ReofferedServiceCanBeFound) const iox::capro::ServiceDescription SERVICE_DESCRIPTION("service", "instance", "event"); typename TestFixture::CommunicationKind::Producer producer(SERVICE_DESCRIPTION); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->findService(SERVICE_DESCRIPTION); @@ -206,7 +205,7 @@ TYPED_TEST(ServiceDiscovery_test, ReofferedServiceCanBeFound) producer.stopOffer(); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->findService(SERVICE_DESCRIPTION); @@ -214,7 +213,7 @@ TYPED_TEST(ServiceDiscovery_test, ReofferedServiceCanBeFound) producer.offer(); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->findService(SERVICE_DESCRIPTION); @@ -229,7 +228,7 @@ TYPED_TEST(ServiceDiscovery_test, ServiceOfferedMultipleTimesCanBeFound) const iox::capro::ServiceDescription SERVICE_DESCRIPTION("service", "instance", "event"); typename TestFixture::CommunicationKind::Producer producer(SERVICE_DESCRIPTION); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->findService(SERVICE_DESCRIPTION); @@ -238,7 +237,7 @@ TYPED_TEST(ServiceDiscovery_test, ServiceOfferedMultipleTimesCanBeFound) producer.offer(); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->findService(SERVICE_DESCRIPTION); @@ -806,7 +805,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindWhenNothingOffered) ::testing::Test::RecordProperty("TEST_ID", "7f0bf2c0-5e96-4da6-b282-f84917bb5243"); // ensure the discovery loop ran at least once - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); // Checks whether the reference implementation result matches the sut result if we call // findService({"a"}, {"b"}, {"c"}). @@ -820,7 +819,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindWhenSingleServiceOffered) ::testing::Test::RecordProperty("TEST_ID", "aab09c10-8b1e-4f25-8f72-bd762b69f2cb"); this->add({"a", "b", "c"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"a"}, {"b"}, {"c"}); } @@ -831,7 +830,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindWhenSingleServiceIsOfferedMulti this->add({"a", "b", "c"}); this->add({"a", "b", "c"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"a"}, {"b"}, {"c"}); } @@ -844,7 +843,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindWhenMultipleServicesAreOffered) this->add({"aa", "a", "c"}); this->add({"a", "ab", "a"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"aa"}, {"a"}, {"c"}); } @@ -855,7 +854,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindWhenMultipleInstancesOfTheSameS this->add({"a", "b", "c"}); this->add({"a", "d", "c"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"a"}, {"d"}, {"c"}); } @@ -868,7 +867,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, RepeatedSearchYieldsSameResult) this->add({"aa", "a", "c"}); this->add({"a", "ab", "a"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"a"}, {"b"}, {"aa"}); auto previousResult = serviceContainer; @@ -882,7 +881,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindNonExistingService) ::testing::Test::RecordProperty("TEST_ID", "6f953d0d-bae3-45a1-82e7-c78a32b6d365"); this->add({"a", "b", "c"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); // those are all representatives of equivalence classes of mismatches // that hould not be found @@ -907,7 +906,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindNonExistingServiceAmongMultiple this->add({"x", "b", "x"}); this->add({"x", "x", "x"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"a"}, {"b"}, {"c"}); } @@ -957,7 +956,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindInMaximumServices) EXPECT_EQ(created, MAX); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); // search for specific services we inserted at various times (includes wildcard searches etc.): // find first offered service, last offered service and some service offered inbetween @@ -976,7 +975,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, SameServerAndPublisherCanBeFound) this->add({"Ferdinand", "Schnüffel", "Spitz"}); this->addOther({"Ferdinand", "Schnüffel", "Spitz"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"Ferdinand"}, {"Schnüffel"}, {"Spitz"}); } @@ -987,7 +986,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, OtherServiceKindWithMatchingNameIsN this->add({"Schnüffel", "Ferdinand", "Spitz"}); this->addOther({"Ferdinand", "Schnüffel", "Spitz"}); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); this->testFindService({"Ferdinand"}, {"Schnüffel"}, {"Spitz"}); } @@ -1067,7 +1066,7 @@ TYPED_TEST(ServiceDiscoveryFindService_test, FindInMaximumMixedServices) EXPECT_EQ(created, OTHER_MAX); - this->InterOpWait(); + this->triggerDiscoveryLoopAndWaitToFinish(); // now we have the maximum of services of both kinds with semi-random services diff --git a/iceoryx_posh/test/moduletests/test_posh_runtime.cpp b/iceoryx_posh/test/moduletests/test_posh_runtime.cpp index 8cf0bcaacc..f37c82c078 100644 --- a/iceoryx_posh/test/moduletests/test_posh_runtime.cpp +++ b/iceoryx_posh/test/moduletests/test_posh_runtime.cpp @@ -25,10 +25,10 @@ #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/popo/untyped_client.hpp" #include "iceoryx_posh/popo/untyped_server.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iceoryx_posh/testing/mocks/posh_runtime_mock.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" #include "test.hpp" #include @@ -41,8 +41,7 @@ using namespace iox::capro; using namespace iox::cxx; using namespace iox; using namespace iox::popo; -using namespace iox::testing; -using iox::roudi::RouDiEnvironment; +using namespace iox::roudi_env; class PoshRuntime_test : public Test { @@ -106,7 +105,7 @@ class PoshRuntime_test : public Test } const iox::RuntimeName_t m_runtimeName{"publisher"}; - RouDiEnvironment m_roudiEnv{MinimalRouDiConfigBuilder().create()}; + RouDiEnv m_roudiEnv{MinimalRouDiConfigBuilder().create()}; PoshRuntime* m_runtime{&iox::runtime::PoshRuntime::initRuntime(m_runtimeName)}; IpcMessage m_sendBuffer; IpcMessage m_receiveBuffer; diff --git a/iceoryx_posh/test/moduletests/test_posh_runtime_node.cpp b/iceoryx_posh/test/moduletests/test_posh_runtime_node.cpp index bf3d7db4ac..11eb3c888b 100644 --- a/iceoryx_posh/test/moduletests/test_posh_runtime_node.cpp +++ b/iceoryx_posh/test/moduletests/test_posh_runtime_node.cpp @@ -15,10 +15,10 @@ // // SPDX-License-Identifier: Apache-2.0 +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include "iceoryx_posh/runtime/node.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" #include "test.hpp" @@ -27,7 +27,7 @@ namespace using namespace ::testing; using namespace iox::runtime; using namespace iox::roudi; -using namespace iox::testing; +using namespace iox::roudi_env; using namespace iox; /// @brief Test goal: This test suit verifies class node @@ -48,7 +48,7 @@ class PoshRuntimeNode_test : public Test virtual void TearDown(){}; const RuntimeName_t m_runtimeName{"App"}; - RouDiEnvironment m_roudiEnv{MinimalRouDiConfigBuilder().create()}; + RouDiEnv m_roudiEnv{MinimalRouDiConfigBuilder().create()}; PoshRuntime* m_runtime{&iox::runtime::PoshRuntime::initRuntime(m_runtimeName)}; }; diff --git a/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp b/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp index d33d5a0fee..c3727919a6 100644 --- a/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp +++ b/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp @@ -15,9 +15,9 @@ // // SPDX-License-Identifier: Apache-2.0 +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include "iceoryx_posh/runtime/posh_runtime_single_process.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" #include "test.hpp" @@ -26,7 +26,7 @@ namespace using namespace ::testing; using namespace iox::runtime; using namespace iox::roudi; -using namespace iox::testing; +using namespace iox::roudi_env; using namespace iox; /// @brief Test goal: This test suit verifies class posh_runtime_single_process @@ -66,7 +66,7 @@ TEST_F(PoshRuntimeSingleProcess_test, ConstructorPoshRuntimeSingleProcessIsSucce TEST_F(PoshRuntimeSingleProcess_test, ConstructorPoshRuntimeSingleProcessMultipleProcessIsFound) { ::testing::Test::RecordProperty("TEST_ID", "1cc7ad5d-5878-454a-94ba-5cf412c22682"); - RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()}; + RouDiEnv roudiEnv{MinimalRouDiConfigBuilder().create()}; const RuntimeName_t runtimeName{"App"}; diff --git a/iceoryx_posh/test/moduletests/test_roudi_iceoyx_roudi_memory_manager.cpp b/iceoryx_posh/test/moduletests/test_roudi_iceoyx_roudi_memory_manager.cpp index 2eb3bd003d..54943988ba 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_iceoyx_roudi_memory_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_iceoyx_roudi_memory_manager.cpp @@ -18,13 +18,13 @@ #include "test.hpp" #include "iceoryx_posh/roudi/memory/iceoryx_roudi_memory_manager.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" namespace { using namespace ::testing; -using namespace iox::testing; +using namespace iox::roudi_env; using iox::roudi::IceOryxRouDiMemoryManager; /// @brief This test file verifies that the BaseClass IceoryxRouDiMemoryManager is tested diff --git a/iceoryx_posh/test/moduletests/test_roudi_portmanager_fixture.hpp b/iceoryx_posh/test/moduletests/test_roudi_portmanager_fixture.hpp index 46c2f29cf5..f0f63469d6 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_portmanager_fixture.hpp +++ b/iceoryx_posh/test/moduletests/test_roudi_portmanager_fixture.hpp @@ -29,7 +29,7 @@ #include "iceoryx_posh/popo/client_options.hpp" #include "iceoryx_posh/popo/server_options.hpp" #include "iceoryx_posh/roudi/memory/iceoryx_roudi_memory_manager.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "test.hpp" @@ -44,7 +44,7 @@ using namespace iox::capro; using namespace iox::cxx; using namespace iox::popo; using namespace iox::roudi; -using namespace iox::testing; +using namespace iox::roudi_env; using iox::runtime::PortConfigInfo; diff --git a/iceoryx_posh/test/moduletests/test_roudi_process_manager.cpp b/iceoryx_posh/test/moduletests/test_roudi_process_manager.cpp index 19af8e3572..3eab6aea06 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_process_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_process_manager.cpp @@ -23,7 +23,7 @@ #include "iceoryx_posh/mepoo/mepoo_config.hpp" #include "iceoryx_posh/roudi/memory/iceoryx_roudi_memory_manager.hpp" #include "iceoryx_posh/roudi/memory/roudi_memory_interface.hpp" -#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp" +#include "iceoryx_posh/roudi_env/minimal_roudi_config.hpp" #include "iceoryx_posh/version/compatibility_check_level.hpp" #include "iox/string.hpp" #include "test.hpp" @@ -35,7 +35,7 @@ using namespace iox::roudi; using namespace iox::popo; using namespace iox::runtime; using namespace iox::posix; -using namespace iox::testing; +using namespace iox::roudi_env; using namespace iox::version; class ProcessManager_test : public Test diff --git a/iceoryx_posh/testing/CMakeLists.txt b/iceoryx_posh/testing/CMakeLists.txt index 1e55c62304..2e50caf9c3 100644 --- a/iceoryx_posh/testing/CMakeLists.txt +++ b/iceoryx_posh/testing/CMakeLists.txt @@ -15,29 +15,25 @@ # # SPDX-License-Identifier: Apache-2.0 -if(ROUDI_ENVIRONMENT OR BUILD_TEST) - # - ######### posh roudi environment ########## - # - find_package(GTest CONFIG REQUIRED) - find_package(iceoryx_hoofs_testing REQUIRED) - iox_add_library( - STATIC - TARGET iceoryx_posh_testing - NAMESPACE iceoryx_posh_testing - PROJECT_PREFIX ${PREFIX} - BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include - INSTALL_INTERFACE include/${PREFIX} - EXPORT_INCLUDE_DIRS include/ - PUBLIC_LIBS GTest::gtest - GTest::gmock - PRIVATE_LIBS iceoryx_posh::iceoryx_posh - iceoryx_hoofs::iceoryx_hoofs - iceoryx_posh::iceoryx_posh_roudi - iceoryx_hoofs_testing::iceoryx_hoofs_testing - FILES - roudi_environment/minimal_roudi_config.cpp - roudi_environment/runtime_test_interface.cpp - roudi_environment/roudi_environment.cpp - ) -endif() +# +######### posh testing ########## +# +find_package(GTest CONFIG REQUIRED) +find_package(iceoryx_hoofs_testing REQUIRED) +iox_add_library( + STATIC + TARGET iceoryx_posh_testing + NAMESPACE iceoryx_posh_testing + PROJECT_PREFIX ${PREFIX} + BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include + INSTALL_INTERFACE include/${PREFIX} + EXPORT_INCLUDE_DIRS include/ + PUBLIC_LIBS GTest::gtest + GTest::gmock + iceoryx_posh::iceoryx_posh_roudi_env + PRIVATE_LIBS iceoryx_posh::iceoryx_posh + iceoryx_hoofs::iceoryx_hoofs + iceoryx_hoofs_testing::iceoryx_hoofs_testing + FILES + source/roudi_gtest.cpp +) diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp index 39f5390122..142081490c 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp @@ -14,68 +14,48 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 + #ifndef IOX_POSH_ROUDI_ENVIRONMENT_ROUDI_ENVIRONMENT_HPP #define IOX_POSH_ROUDI_ENVIRONMENT_ROUDI_ENVIRONMENT_HPP -#include "iceoryx_posh/iceoryx_posh_config.hpp" -#include "iceoryx_posh/iceoryx_posh_types.hpp" -#include "iceoryx_posh/internal/roudi/roudi.hpp" -#include "iceoryx_posh/roudi/iceoryx_roudi_components.hpp" -#include "iceoryx_posh/roudi/memory/iceoryx_roudi_memory_manager.hpp" -#include "iceoryx_posh/testing/roudi_environment/runtime_test_interface.hpp" -#include "iox/duration.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" -#include -#include -#include +#include namespace iox { namespace roudi { -class RouDi; - -class RouDiEnvironment +/// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'iox::roudi_env::RouDiEnv' +class [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'iox::roudi_env::RouDiEnv'")]] RouDiEnvironment + : public roudi_env::RouDiEnv { public: - RouDiEnvironment(const RouDiConfig_t& roudiConfig = RouDiConfig_t().setDefaults(), - roudi::MonitoringMode monitoringMode = roudi::MonitoringMode::OFF, - const uint16_t uniqueRouDiId = 0u); - virtual ~RouDiEnvironment(); - - RouDiEnvironment(RouDiEnvironment&& rhs) = default; - RouDiEnvironment& operator=(RouDiEnvironment&& rhs) = default; - - RouDiEnvironment(const RouDiEnvironment&) = delete; - RouDiEnvironment& operator=(const RouDiEnvironment&) = delete; - - void SetInterOpWaitingTime(const std::chrono::milliseconds& v); - void InterOpWait(); + using ParentType = roudi_env::RouDiEnv; + using ParentType::ParentType; + using ParentType::operator=; - void CleanupAppResources(const RuntimeName_t& name); - - protected: - /// @note this is due to ambiguity of the cTor with the default parameter - enum class BaseCTor + /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout' + [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout'")]] void + SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept { - BASE, - }; - /// @brief for implementations on top of RouDiEnvironment - RouDiEnvironment(BaseCTor, const uint16_t uniqueRouDiId = 0u); + setDiscoveryLoopWaitToFinishTimeout(units::Duration::fromMilliseconds(v.count())); + } - void CleanupRuntimes(); + /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish' + [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish'")]] void + InterOpWait() noexcept + { + triggerDiscoveryLoopAndWaitToFinish(); + } - private: - RuntimeTestInterface m_runtimes; -#if defined(__APPLE__) - iox::units::Duration m_interOpWaitingTimeout{iox::units::Duration::fromMilliseconds(1000)}; -#else - iox::units::Duration m_interOpWaitingTimeout{iox::units::Duration::fromMilliseconds(200)}; -#endif - std::unique_ptr m_roudiComponents; - std::unique_ptr m_roudiApp; + /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources' + [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources'")]] void CleanupAppResources( + const RuntimeName_t& name) noexcept + { + cleanupAppResources(name); + } }; - } // namespace roudi } // namespace iox diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp index 1845946a3e..50a6dea74a 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp @@ -17,21 +17,38 @@ #ifndef IOX_POSH_TESTUTILS_ROUDI_GTEST_HPP #define IOX_POSH_TESTUTILS_ROUDI_GTEST_HPP -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" +#include "iceoryx_posh/roudi_env/roudi_env.hpp" #include #include -using namespace ::testing; - -class RouDi_GTest : public iox::roudi::RouDiEnvironment, public Test +namespace iox +{ +namespace testing +{ +class RouDi_GTest : public iox::roudi_env::RouDiEnv, public ::testing::Test { public: RouDi_GTest() = default; - RouDi_GTest(const iox::RouDiConfig_t& roudiConfig) - : iox::roudi::RouDiEnvironment(roudiConfig) - { - } + RouDi_GTest(const iox::RouDiConfig_t& roudiConfig) noexcept; + + /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout' + [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout'")]] void + SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept; + + /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish' + [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish'")]] void + InterOpWait() noexcept; + + /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources' + [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources'")]] void + CleanupAppResources(const RuntimeName_t& name) noexcept; }; +} // namespace testing +} // namespace iox + +/// @deprecated Deprecated in 3.0, removed in 4.0, please use 'RouDi_GTest' with the 'iox::testing' namespace +using RouDi_GTest = iox::testing::RouDi_GTest; + #endif // IOX_POSH_TESTUTILS_ROUDI_GTEST_HPP diff --git a/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp b/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp deleted file mode 100644 index 5ad459cbdd..0000000000 --- a/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 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. -// -// SPDX-License-Identifier: Apache-2.0 - -#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp" -#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp" -#include "iceoryx_hoofs/testing/mocks/error_handler_mock.hpp" -#include "iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp" -#include "iceoryx_posh/internal/roudi/roudi.hpp" -#include "iceoryx_posh/runtime/posh_runtime.hpp" - -namespace iox -{ -namespace roudi -{ -RouDiEnvironment::RouDiEnvironment(BaseCTor, const uint16_t uniqueRouDiId) -{ - // setUniqueRouDiId is called multiple times but it is okay for the tests - auto errorHandlerGuard = iox::ErrorHandlerMock::setTemporaryErrorHandler([](auto, auto) {}); - iox::popo::UniquePortId::setUniqueRouDiId(uniqueRouDiId); -} - -RouDiEnvironment::RouDiEnvironment(const RouDiConfig_t& roudiConfig, - const roudi::MonitoringMode monitoringMode, - const uint16_t uniqueRouDiId) - : RouDiEnvironment(BaseCTor::BASE, uniqueRouDiId) -{ - m_roudiComponents = std::unique_ptr(new IceOryxRouDiComponents(roudiConfig)); - m_roudiApp = std::unique_ptr(new RouDi(m_roudiComponents->rouDiMemoryManager, - m_roudiComponents->portManager, - RouDi::RoudiStartupParameters{monitoringMode, false})); -} - -RouDiEnvironment::~RouDiEnvironment() -{ - if (m_runtimes.m_doCleanupOnDestruction) - { - // setUniqueRouDiId is called multiple times but it is okay for the tests - auto errorHandlerGuard = iox::ErrorHandlerMock::setTemporaryErrorHandler([](auto, auto) {}); - popo::UniquePortId::setUniqueRouDiId(roudi::DEFAULT_UNIQUE_ROUDI_ID); - } - CleanupRuntimes(); -} - -void RouDiEnvironment::SetInterOpWaitingTime(const std::chrono::milliseconds& v) -{ - m_interOpWaitingTimeout = units::Duration::fromMilliseconds(v.count()); -} - -void RouDiEnvironment::InterOpWait() -{ - m_roudiApp->triggerDiscoveryLoopAndWaitToFinish(m_interOpWaitingTimeout); -} - -void RouDiEnvironment::CleanupAppResources(const RuntimeName_t& name) -{ - m_runtimes.eraseRuntime(name); -} - -void RouDiEnvironment::CleanupRuntimes() -{ - m_runtimes.cleanupRuntimes(); -} - -} // namespace roudi -} // namespace iox diff --git a/iceoryx_posh/testing/source/roudi_gtest.cpp b/iceoryx_posh/testing/source/roudi_gtest.cpp new file mode 100644 index 0000000000..65b4579230 --- /dev/null +++ b/iceoryx_posh/testing/source/roudi_gtest.cpp @@ -0,0 +1,46 @@ +// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 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. +// +// SPDX-License-Identifier: Apache-2.0 + +#include "iceoryx_posh/testing/roudi_gtest.hpp" + +namespace iox +{ +namespace testing +{ + +RouDi_GTest::RouDi_GTest(const iox::RouDiConfig_t& roudiConfig) noexcept + : iox::roudi_env::RouDiEnv(roudiConfig) +{ +} + +void RouDi_GTest::SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept +{ + setDiscoveryLoopWaitToFinishTimeout(units::Duration::fromMilliseconds(v.count())); +} + +void RouDi_GTest::InterOpWait() noexcept +{ + triggerDiscoveryLoopAndWaitToFinish(); +} + +void RouDi_GTest::CleanupAppResources(const RuntimeName_t& name) noexcept +{ + cleanupAppResources(name); +} + +} // namespace testing +} // namespace iox