Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1030 Use minimal RouDiConfig_t where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Sep 5, 2023
1 parent 9bebe98 commit 76efb6f
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 22 deletions.
6 changes: 6 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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/testing/roudi_gtest.hpp"

namespace
Expand All @@ -33,6 +34,11 @@ using namespace iox::testing;
class Chunk_test : public RouDi_GTest
{
public:
Chunk_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp() override
{
iox_runtime_init("hypnotoad");
Expand Down
6 changes: 6 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
#include "iceoryx_hoofs/testing/fatal_failure.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 <gtest/gtest.h>

Expand All @@ -35,6 +36,11 @@ using namespace iox::testing;
class iox_node_test : public RouDi_GTest
{
public:
iox_node_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp()
{
iox_runtime_init(m_runtimeName.c_str());
Expand Down
3 changes: 2 additions & 1 deletion iceoryx_binding_c/test/moduletests/test_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#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"

using namespace iox;
Expand Down Expand Up @@ -142,7 +143,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;
iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};

iox_runtime_init("hypnotoad");

Expand Down
6 changes: 6 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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/testing/roudi_gtest.hpp"

namespace
Expand All @@ -32,6 +33,11 @@ using namespace iox::testing;
class BindingC_Runtime_test : public RouDi_GTest
{
public:
BindingC_Runtime_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp()
{
}
Expand Down
5 changes: 3 additions & 2 deletions iceoryx_binding_c/test/moduletests/test_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#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 "mocks/wait_set_mock.hpp"

Expand Down Expand Up @@ -147,7 +148,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;
iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};

iox_runtime_init("hypnotoad");

Expand Down Expand Up @@ -404,7 +405,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;
iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};
iox_runtime_init("hypnotoad");

iox_sub_storage_t storage;
Expand Down
7 changes: 7 additions & 0 deletions iceoryx_posh/test/integrationtests/test_client_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "iceoryx_posh/popo/untyped_client.hpp"
#include "iceoryx_posh/popo/untyped_server.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"
Expand All @@ -32,6 +33,7 @@ using namespace ::testing;
using namespace iox::popo;
using namespace iox::capro;
using namespace iox::runtime;
using namespace iox::testing;

class DummyRequest
{
Expand Down Expand Up @@ -60,6 +62,11 @@ class DummyResponse
class ClientServer_test : public RouDi_GTest
{
public:
ClientServer_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp() override
{
PoshRuntime::initRuntime("together");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "iceoryx_posh/gateway/gateway_base.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"
Expand All @@ -27,10 +28,16 @@ namespace
using namespace ::testing;

using namespace iox::gw;
using namespace iox::testing;

class InterfacePortRequestStackBlowup_test : public RouDi_GTest
{
public:
InterfacePortRequestStackBlowup_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp(){};
void TearDown(){};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +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/testing/roudi_gtest.hpp"

#include "test.hpp"
Expand All @@ -29,6 +30,7 @@ using namespace ::testing;
using namespace iox::popo;
using namespace iox::capro;
using namespace iox::runtime;
using namespace iox::testing;

void onSampleReceivedCallback(Subscriber<int>* subscriber IOX_MAYBE_UNUSED)
{
Expand All @@ -41,6 +43,11 @@ void onSampleReceivedCallbackForUntypedSub(UntypedSubscriber* subscriber IOX_MAY
class PubSubListener_IntegrationTest : public RouDi_GTest
{
public:
PubSubListener_IntegrationTest()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp() override
{
PoshRuntime::initRuntime("PubSubListener_IntegrationTest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// 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 "test.hpp"
Expand All @@ -23,6 +24,7 @@ namespace
{
using namespace ::testing;
using namespace iox::roudi;
using namespace iox::testing;

class RouDiEnvironment_test : public Test
{
Expand All @@ -34,8 +36,8 @@ class RouDiEnvironment_test : public Test
TEST_F(RouDiEnvironment_test, StartingRouDiTwiceLeadsToError)
{
::testing::Test::RecordProperty("TEST_ID", "38075292-7897-4db5-b20e-f06ab324ad31");
RouDiEnvironment m_sut{iox::RouDiConfig_t().setDefaults()};
EXPECT_DEATH({ RouDiEnvironment m_sut2{iox::RouDiConfig_t().setDefaults()}; }, ".*");
RouDiEnvironment m_sut{MinimalRouDiConfigBuilder().create()};
EXPECT_DEATH({ RouDiEnvironment m_sut2{MinimalRouDiConfigBuilder().create()}; }, ".*");
}

} // namespace
20 changes: 14 additions & 6 deletions iceoryx_posh/test/moduletests/test_popo_trigger_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
#include "iceoryx_posh/popo/trigger_handle.hpp"
#include "iox/deadline_timer.hpp"

#include "test.hpp"
#include <thread>
Expand Down Expand Up @@ -122,18 +123,25 @@ TEST_F(TriggerHandle_test, triggerNotifiesConditionVariable)
::testing::Test::RecordProperty("TEST_ID", "11e752c8-d473-4bfd-b973-869c3b2d9fbc");
std::atomic_int stage{0};

iox::deadline_timer timeout{100_ms};

std::thread t([&] {
ConditionListener(m_condVar).wait();
stage.store(1);
ConditionListener(m_condVar).wait();
});

std::this_thread::sleep_for(std::chrono::milliseconds(100));
EXPECT_EQ(stage.load(), 0);
while (!timeout.hasExpired() && stage.load() < 1)
{
std::this_thread::yield();
}
ASSERT_FALSE(timeout.hasExpired());
EXPECT_THAT(stage.load(), Eq(1));
std::this_thread::sleep_for(std::chrono::milliseconds(10));
EXPECT_THAT(stage.load(), Eq(1));
m_sut.trigger();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
EXPECT_EQ(stage.load(), 1);

t.join();

EXPECT_FALSE(timeout.hasExpired());
}

TEST_F(TriggerHandle_test, wasTriggeredReturnsFalseAfterCreation)
Expand Down
4 changes: 3 additions & 1 deletion iceoryx_posh/test/moduletests/test_posh_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "iceoryx_posh/popo/untyped_server.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"

Expand All @@ -40,6 +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;

class PoshRuntime_test : public Test
Expand Down Expand Up @@ -104,7 +106,7 @@ class PoshRuntime_test : public Test
}

const iox::RuntimeName_t m_runtimeName{"publisher"};
RouDiEnvironment m_roudiEnv{iox::RouDiConfig_t().setDefaults()};
RouDiEnvironment m_roudiEnv{MinimalRouDiConfigBuilder().create()};
PoshRuntime* m_runtime{&iox::runtime::PoshRuntime::initRuntime(m_runtimeName)};
IpcMessage m_sendBuffer;
IpcMessage m_receiveBuffer;
Expand Down
4 changes: 3 additions & 1 deletion iceoryx_posh/test/moduletests/test_posh_runtime_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#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"
Expand All @@ -26,6 +27,7 @@ namespace
using namespace ::testing;
using namespace iox::runtime;
using namespace iox::roudi;
using namespace iox::testing;
using namespace iox;

/// @brief Test goal: This test suit verifies class node
Expand All @@ -46,7 +48,7 @@ class PoshRuntimeNode_test : public Test
virtual void TearDown(){};

const RuntimeName_t m_runtimeName{"App"};
RouDiEnvironment m_roudiEnv{iox::RouDiConfig_t().setDefaults()};
RouDiEnvironment m_roudiEnv{MinimalRouDiConfigBuilder().create()};
PoshRuntime* m_runtime{&iox::runtime::PoshRuntime::initRuntime(m_runtimeName)};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// SPDX-License-Identifier: Apache-2.0

#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"
Expand All @@ -25,6 +26,7 @@ namespace
using namespace ::testing;
using namespace iox::runtime;
using namespace iox::roudi;
using namespace iox::testing;
using namespace iox;

/// @brief Test goal: This test suit verifies class posh_runtime_single_process
Expand All @@ -48,8 +50,8 @@ class PoshRuntimeSingleProcess_test : public Test
TEST_F(PoshRuntimeSingleProcess_test, ConstructorPoshRuntimeSingleProcessIsSuccess)
{
::testing::Test::RecordProperty("TEST_ID", "9faf7053-86af-4d26-b3a7-fb3c6319ab86");
iox::RouDiConfig_t defaultRouDiConfig = iox::RouDiConfig_t().setDefaults();
std::unique_ptr<IceOryxRouDiComponents> roudiComponents{new IceOryxRouDiComponents(defaultRouDiConfig)};
std::unique_ptr<IceOryxRouDiComponents> roudiComponents{
new IceOryxRouDiComponents(MinimalRouDiConfigBuilder().create())};

std::unique_ptr<RouDi> roudi{new RouDi(roudiComponents->rouDiMemoryManager,
roudiComponents->portManager,
Expand All @@ -64,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{iox::RouDiConfig_t().setDefaults()};
RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};

const RuntimeName_t runtimeName{"App"};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +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"

namespace
{
using namespace ::testing;

using namespace iox::testing;
using iox::roudi::IceOryxRouDiMemoryManager;

/// @brief This test file verifies that the BaseClass IceoryxRouDiMemoryManager is tested
Expand All @@ -33,8 +35,8 @@ class IceoryxRoudiMemoryManager_test : public Test

void SetUp() override
{
auto config = iox::RouDiConfig_t().setDefaults();
m_roudiMemoryManagerTest = std::unique_ptr<IceOryxRouDiMemoryManager>(new IceOryxRouDiMemoryManager(config));
m_roudiMemoryManagerTest = std::unique_ptr<IceOryxRouDiMemoryManager>(
new IceOryxRouDiMemoryManager(MinimalRouDiConfigBuilder().create()));
}

void TearDown() override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +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 "test.hpp"

Expand All @@ -43,6 +44,7 @@ using namespace iox::capro;
using namespace iox::cxx;
using namespace iox::popo;
using namespace iox::roudi;
using namespace iox::testing;

using iox::runtime::PortConfigInfo;

Expand Down Expand Up @@ -84,8 +86,7 @@ class PortManager_test : public Test
m_eventIdCounter = 0;
// starting at {1,1,1}

auto config = iox::RouDiConfig_t().setDefaults();
m_roudiMemoryManager = new IceOryxRouDiMemoryManager(config);
m_roudiMemoryManager = new IceOryxRouDiMemoryManager(MinimalRouDiConfigBuilder().create());
EXPECT_FALSE(m_roudiMemoryManager->createAndAnnounceMemory().has_error());
m_portManager = new PortManagerTester(m_roudiMemoryManager);

Expand Down
Loading

0 comments on commit 76efb6f

Please sign in to comment.