Skip to content

Commit

Permalink
iox-eclipse-iceoryx#563 move tests in posh moduletests into anonymous…
Browse files Browse the repository at this point in the history
… namespace

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
  • Loading branch information
elBoberido committed May 11, 2021
1 parent 3772a69 commit b7c63c1
Show file tree
Hide file tree
Showing 60 changed files with 293 additions and 132 deletions.
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_base_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "iceoryx_utils/cxx/helplets.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;
using namespace iox::capro;
using namespace iox::popo;
Expand Down Expand Up @@ -175,3 +177,5 @@ TYPED_TEST(BasePort_test, CallingGetRuntimeNameWorks)
using PortData_t = typename TestFixture::PortData_t;
EXPECT_THAT(this->sut.getRuntimeName(), Eq(expectedProcessName<PortData_t>()));
}

} // namespace
5 changes: 5 additions & 0 deletions iceoryx_posh/test/moduletests/test_capro_message.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 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.
Expand All @@ -21,6 +22,8 @@
#include "iceoryx_utils/cxx/generic_raii.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;
using namespace iox::capro;

Expand Down Expand Up @@ -58,3 +61,5 @@ TEST_F(CaproMessage_test, DefaultArgsOfCtor)
EXPECT_EQ(CaproMessageSubType::NOSUBTYPE, testObj.m_subType);
EXPECT_EQ(nullptr, testObj.m_chunkQueueData);
}

} // namespace
5 changes: 5 additions & 0 deletions iceoryx_posh/test/moduletests/test_capro_service.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2019, 2021 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.
Expand All @@ -22,6 +23,8 @@

#include <cstdint>

namespace
{
using namespace ::testing;
using ::testing::Return;

Expand Down Expand Up @@ -672,3 +675,5 @@ TEST_F(ServiceDescription_test, LessThanOperatorReturnsFalseIfEventStringOfFirst
}

/// END SERVICEDESCRIPTION TESTS

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <cstdint>
#include <limits>

namespace
{
using namespace ::testing;
using namespace iox::version;

Expand Down Expand Up @@ -122,3 +124,5 @@ TEST_F(CompatibilityCheckLevel_test, BuildDateLeadsToCorrectString)
EXPECT_THAT(m_loggerMock.m_logs[0].message, Eq("CompatibilityCheckLevel::BUILD_DATE"));
EXPECT_THAT(m_loggerMock.m_logs[0].level, Eq(iox::log::LogLevel::kWarn));
}

} // namespace
7 changes: 6 additions & 1 deletion iceoryx_posh/test/moduletests/test_fixed_size_container.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2019, 2021 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// 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.
Expand All @@ -19,6 +20,8 @@

#include <cstdint>

namespace
{
using namespace ::testing;
using ::testing::Return;

Expand Down Expand Up @@ -201,3 +204,5 @@ TEST_F(FixedSizeContainer_test, removeAndVerifyMultiElementContainer)
}
}
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_gw_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "test.hpp"

namespace
{
using namespace ::testing;
using ::testing::_;

Expand Down Expand Up @@ -58,3 +60,5 @@ TEST_F(ChannelTest, ReturnsEmptyOptionalIfObjectPoolExhausted)
{"", "", ""}, StubbedIceoryxTerminal::Options());
EXPECT_FALSE(channel.has_error());
}

} // namespace
7 changes: 6 additions & 1 deletion iceoryx_posh/test/moduletests/test_gw_gateway_discovery.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2019, 2021 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// Copyright (c) 2019 - 2020 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.
Expand All @@ -19,6 +20,8 @@
#include "iceoryx_posh/gateway/gateway_discovery.hpp"
#include "iceoryx_posh/internal/popo/ports/base_port.hpp"

namespace
{
using namespace ::testing;
using ::testing::Return;

Expand Down Expand Up @@ -65,3 +68,5 @@ TEST_F(GatewayDiscovery_test, GetCaproMessage)
EXPECT_EQ(iox::capro::CaproMessageType::ACK, msg.m_type);
EXPECT_EQ(iox::capro::ServiceDescription(), msg.m_serviceDescription);
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_gw_gateway_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "stubs/stub_gateway_generic.hpp"

namespace
{
using namespace ::testing;
using namespace iox::units::duration_literals;
using ::testing::_;
Expand Down Expand Up @@ -259,3 +261,5 @@ TEST_F(GatewayGenericTest, ForEachChannelExecutesGivenFunctionForAllStoredChanne

EXPECT_EQ(3U, count);
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "iceoryx_utils/internal/posix_wrapper/shared_memory_object/allocator.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;
using namespace iox::mepoo;

Expand Down Expand Up @@ -217,3 +219,5 @@ TEST_F(MemPool_test, dieWhenMempoolChunkSizeIsNotPowerOf32)
{
EXPECT_DEATH({ iox::mepoo::MemPool sut(333, 10, allocator, allocator); }, ".*");
}

} // namespace
13 changes: 9 additions & 4 deletions iceoryx_posh/test/moduletests/test_mepoo_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
#include <functional>
#include <memory>

using namespace ::testing;
using namespace iox::mepoo;
using namespace iox::posix;

namespace iox
{
namespace cxx
Expand All @@ -48,6 +44,13 @@ struct ErrorTypeAdapter<int>
};
} // namespace cxx
} // namespace iox

namespace
{
using namespace ::testing;
using namespace iox::mepoo;
using namespace iox::posix;

class MePooSegment_test : public Test
{
public:
Expand Down Expand Up @@ -205,3 +208,5 @@ TEST_F(MePooSegment_test, ADD_TEST_WITH_ADDITIONAL_USER(GetMemoryManager))
auto chunk = sut.getMemoryManager().getChunk(chunkSettings);
EXPECT_THAT(chunk.getChunkHeader()->userPayloadSize(), Eq(USER_PAYLOAD_SIZE));
}

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "test.hpp"


namespace
{
using namespace ::testing;
using namespace iox::mepoo;
using namespace iox::posix;
Expand Down Expand Up @@ -196,3 +198,5 @@ TEST_F(SegmentManager_test, ADD_TEST_WITH_ADDITIONAL_USER(addingMaximumNumberOfS
SegmentConfig segmentConfig = getSegmentConfigWithMaximumNumberOfSegements();
SegmentManager<MePooSegmentMock> sut{segmentConfig, &allocator};
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_mepoo_shared_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "iceoryx_utils/internal/posix_wrapper/shared_memory_object/allocator.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;

using namespace iox::mepoo;
Expand Down Expand Up @@ -270,3 +272,5 @@ TEST_F(SharedChunk_Test, MultipleChunksCleanup)
EXPECT_THAT(mempool.getUsedChunks(), Eq(1));
EXPECT_THAT(chunkMgmtPool.getUsedChunks(), Eq(1));
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_mepoo_shared_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "iceoryx_utils/internal/relocatable_pointer/base_relative_pointer.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;

using namespace iox::mepoo;
Expand Down Expand Up @@ -361,3 +363,5 @@ TEST_F(SharedPointer_Test, SharedPointerWithContentIsValid)
auto sut3 = SharedPointer<TestClass>::create(chunk3, 1, 2).value();
EXPECT_THAT(static_cast<bool>(sut3), Eq(true));
}

} // namespace
36 changes: 20 additions & 16 deletions iceoryx_posh/test/moduletests/test_mepoo_typed_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@

#include "test.hpp"

namespace iox
{
namespace cxx
{
template <>
struct ErrorTypeAdapter<cxx::variant<mepoo::TypedMemPoolError, posix::SemaphoreError>>
{
static variant<mepoo::TypedMemPoolError, posix::SemaphoreError> getInvalidState()
{
return variant<mepoo::TypedMemPoolError, posix::SemaphoreError>(iox::cxx::in_place_index<0>(),
mepoo::TypedMemPoolError::INVALID_STATE);
};
};
} // namespace cxx
} // namespace iox

namespace
{
using namespace ::testing;
using namespace iox::mepoo;
class TypedMemPool_test : public Test
Expand Down Expand Up @@ -61,22 +79,6 @@ class TypedMemPool_test : public Test
TypedMemPool<TestClass> sut;
};

namespace iox
{
namespace cxx
{
template <>
struct ErrorTypeAdapter<cxx::variant<mepoo::TypedMemPoolError, posix::SemaphoreError>>
{
static variant<mepoo::TypedMemPoolError, posix::SemaphoreError> getInvalidState()
{
return variant<mepoo::TypedMemPoolError, posix::SemaphoreError>(iox::cxx::in_place_index<0>(),
mepoo::TypedMemPoolError::INVALID_STATE);
};
};
} // namespace cxx
} // namespace iox

TEST_F(TypedMemPool_test, GetOneObject)
{
auto object = sut.createObject(1, 223);
Expand Down Expand Up @@ -148,3 +150,5 @@ TEST_F(TypedMemPool_Semaphore_test, CreateInvalidSemaphore)
iox::posix::CreateNamedSemaphore, "", S_IRUSR | S_IWUSR, 10);
EXPECT_THAT(semaphorePtr.has_error(), Eq(true));
}

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "test.hpp"

namespace
{
using namespace ::testing;
using namespace iox::roudi;

Expand Down Expand Up @@ -62,3 +64,5 @@ TEST_F(MonitoringModeLogStreamTest, MonitoringModeOnLeadsToCorrectString)
EXPECT_THAT(m_loggerMock.m_logs[0].message, Eq("MonitoringMode::ON"));
EXPECT_THAT(m_loggerMock.m_logs[0].level, Eq(iox::log::LogLevel::kWarn));
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_mq_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "iceoryx_utils/testing/mocks/time_mock.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;

using iox::runtime::IpcMessage;
Expand Down Expand Up @@ -434,3 +436,5 @@ TEST_F(IpcMessage_test, setMessage)
EXPECT_THAT(message1.isValid(), Eq(false));
}
#endif

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_popo_base_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "test.hpp"

namespace
{
using namespace ::testing;
using ::testing::_;

Expand Down Expand Up @@ -109,3 +111,5 @@ TEST_F(BasePublisherTest, DestroysUnderlyingPortOnDestruction)
{
EXPECT_CALL(sut.port(), destroy).Times(1);
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <memory>

namespace
{
using namespace ::testing;
using ::testing::Return;
using namespace iox::popo;
Expand Down Expand Up @@ -645,3 +647,5 @@ TYPED_TEST(ChunkDistributor_test, MultipleBlockingQueuesWillBeFilledWhenThereBec
EXPECT_THAT(this->getSharedChunkValue(*maybeSharedChunk), Eq(1152U));
}
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include "test.hpp"

namespace
{
using namespace ::testing;
using ::testing::Return;

Expand Down Expand Up @@ -381,3 +383,5 @@ TYPED_TEST(ChunkQueueSoFi_test, LostChunkInfoIsResetAfterRead)

EXPECT_FALSE(this->m_popper.hasLostChunks());
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include <memory>

namespace
{
using namespace ::testing;

struct DummySample
Expand Down Expand Up @@ -229,3 +231,5 @@ TEST_F(ChunkReceiver_test, Cleanup)

EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(0U));
}

} // namespace
4 changes: 4 additions & 0 deletions iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include <memory>

namespace
{
using namespace ::testing;

struct DummySample
Expand Down Expand Up @@ -628,3 +630,5 @@ TEST_F(ChunkSender_test, Cleanup)

EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(0U));
}

} // namespace
Loading

0 comments on commit b7c63c1

Please sign in to comment.