Skip to content

Commit

Permalink
Merge pull request #1589 from ApexAI/iox-#1196-activate-clang-tidy-fo…
Browse files Browse the repository at this point in the history
…r-concurrent

Iox #1196 activate clang tidy for concurrent
  • Loading branch information
elfenpiff authored Aug 24, 2022
2 parents 1c1e519 + 57c62b0 commit fdee1d6
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 40 deletions.
15 changes: 7 additions & 8 deletions .clang-tidy-diff-scans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@
./iceoryx_hoofs/test/moduletests/test_relative_pointer*
./iceoryx_hoofs/source/relocatable_pointer/*

./iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/sofi.hpp
./iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/sofi.inl
./iceoryx_hoofs/test/moduletests/test_concurrent_sofi.cpp
./iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/*
./iceoryx_hoofs/include/iceoryx_hoofs/concurrent/*
./iceoryx_hoofs/source/concurrent/*
./iceoryx_hoofs/test/moduletests/test_concurrent_*
./iceoryx_hoofs/test/stresstests/test_stress_sofi.cpp
./iceoryx_hoofs/source/relocatable_pointer/relative_pointer_data.cpp

./iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/*
./iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/*

./iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp

./iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/*
./iceoryx_hoofs/source/posix_wrapper/*
./iceoryx_hoofs/source/posix_wrapper/shared_memory_object/*
./iceoryx_hoofs/test/moduletests/test_posix*

./iceoryx_dust/include/iceoryx_dust/test/moduletests/test_relocatable_ptr.cpp
./iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp

./iceoryx_dust/test/moduletests/test_relocatable_ptr.cpp

# IMPORTANT:
# after the first # everything is considered a comment, add new files and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class IndexQueueTest : public ::testing::Test
using Queue = T;
using index_t = typename Queue::value_t;

protected:
IndexQueueTest() = default;

~IndexQueueTest() override = default;

Queue queue;
Queue fullQueue{Queue::ConstructFull};
};
Expand Down Expand Up @@ -82,6 +77,10 @@ TYPED_TEST(IndexQueueTest, queueIsNotEmptyAfterPush)
auto& q = this->queue;
auto index = this->fullQueue.pop();

ASSERT_TRUE(index.has_value());
// NOLINTJUSTIFICATION false positive, we checked that index.has_value() and the fullQueue has initialized every
// value with Queue::ConstructFull
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
q.push(index.value());
EXPECT_FALSE(q.empty());
}
Expand All @@ -93,6 +92,10 @@ TYPED_TEST(IndexQueueTest, queueIsEmptyAgainAfterPushFollowedByPop)

auto index = this->fullQueue.pop();

ASSERT_TRUE(index.has_value());
// NOLINTJUSTIFICATION false positive, we checked that index.has_value() and the fullQueue has initialized every
// value with Queue::ConstructFull
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
q.push(index.value());
EXPECT_FALSE(q.empty());
q.pop();
Expand Down Expand Up @@ -153,6 +156,10 @@ TYPED_TEST(IndexQueueTest, pushAndPopSingleElement)
auto& q = this->queue;
auto index = this->fullQueue.pop();

ASSERT_TRUE(index.has_value());
// NOLINTJUSTIFICATION false positive, we checked that index.has_value() and the fullQueue has initialized every
// value with Queue::ConstructFull
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign)
index_t rawIndex = index.value();

EXPECT_TRUE(index.has_value());
Expand All @@ -177,6 +184,7 @@ TYPED_TEST(IndexQueueTest, poppedElementsAreInFifoOrder)
for (uint64_t i = 0U; i < capacity; ++i)
{
auto index = this->fullQueue.pop();
ASSERT_TRUE(index.has_value());
EXPECT_EQ(index.value(), expected++);
q.push(index.value());
}
Expand Down Expand Up @@ -255,6 +263,9 @@ TYPED_TEST(IndexQueueTest, popIfSizeIsAtLeastZeroReturnsIndexIfQueueContainsOneE
auto& q = this->queue;
auto index = this->fullQueue.pop();
ASSERT_TRUE(index.has_value());
// NOLINTJUSTIFICATION false positive, we checked that index.has_value() and the fullQueue has initialized every
// value with Queue::ConstructFull
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
q.push(*index);

index = q.popIfSizeIsAtLeast(0U);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ struct Integer
template <typename Config>
class LockFreeQueueTest : public ::testing::Test
{
protected:
LockFreeQueueTest() = default;

~LockFreeQueueTest() override = default;

public:
void SetUp() override
{
// reduce capacity before running the tests if required by config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ class LockFreeQueueBufferTest : public ::testing::Test
{
public:
using Buffer = T;

protected:
LockFreeQueueBufferTest() = default;

~LockFreeQueueBufferTest() override = default;

Buffer buffer;
Buffer buffer{};

void fillBuffer(int startValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class LockFreeQueueCyclicIndexTest : public ::testing::Test
{
public:
using Index = T;

protected:
LockFreeQueueCyclicIndexTest() = default;

~LockFreeQueueCyclicIndexTest() override = default;
};

typedef ::testing::Types<CyclicIndex<1>, CyclicIndex<2>, CyclicIndex<10>, CyclicIndex<1000>> TestIndices;
Expand Down
8 changes: 4 additions & 4 deletions iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LoFFLi_test : public Test
public:
void SetUp() override
{
m_loffli.init(m_memoryLoFFLi, Size);
m_loffli.init(&m_memoryLoFFLi[0], Size);
}

void TearDown() override
Expand All @@ -53,7 +53,7 @@ class LoFFLi_test : public Test

using LoFFLiIndex_t = typename LoFFLiType::Index_t;
// NOLINTNEXTLINE(hicpp-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) needed for LoFFLi::init
LoFFLiIndex_t m_memoryLoFFLi[LoFFLiType::requiredIndexMemorySize(Size)];
LoFFLiIndex_t m_memoryLoFFLi[LoFFLiType::requiredIndexMemorySize(Size)]{0};
LoFFLiType m_loffli;
};

Expand All @@ -74,7 +74,7 @@ TYPED_TEST(LoFFLi_test, Misuse_ZeroSize)
decltype(this->m_loffli) loFFLi;
// todo #1196 remove EXPECT_DEATH
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
EXPECT_DEATH(loFFLi.init(memoryLoFFLi, 0), ".*");
EXPECT_DEATH(loFFLi.init(&memoryLoFFLi[0], 0), ".*");
}

TYPED_TEST(LoFFLi_test, Misuse_SizeToLarge)
Expand All @@ -85,7 +85,7 @@ TYPED_TEST(LoFFLi_test, Misuse_SizeToLarge)
decltype(this->m_loffli) loFFLi;
// todo #1196 remove EXPECT_DEATH
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-avoid-goto, cert-err33-c)
EXPECT_DEATH(loFFLi.init(memoryLoFFLi, UINT32_MAX - 1), ".*");
EXPECT_DEATH(loFFLi.init(&memoryLoFFLi[0], UINT32_MAX - 1), ".*");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ struct Integer
template <typename T>
class ResizeableLockFreeQueueTest : public ::testing::Test
{
protected:
ResizeableLockFreeQueueTest() = default;

~ResizeableLockFreeQueueTest() override = default;

public:
void fillQueue(uint64_t start = 0)
{
uint64_t element{start};
Expand Down
2 changes: 2 additions & 0 deletions iceoryx_hoofs/test/moduletests/test_concurrent_smart_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ TEST_F(smart_lock_test, MoveConstructionOfUnderlyinObjectWorks)
SmartLockTester tester(CTOR_VALUE);
m_sut.emplace(ForwardArgsToCTor, std::move(tester));
EXPECT_THAT((*m_sut)->getA(), Eq(CTOR_VALUE));
/// NOLINTJUSTIFICATION we want to test defined behavior of a moved smart_lock
/// NOLINTNEXTLINE(bugprone-use-after-move,hicpp-invalid-access-moved,clang-analyzer-cplusplus.Move)
EXPECT_TRUE(tester.isMoved());
}

Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/ice_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ create_docker() {
--shm-size $CONTAINER_SHM_MEMORY_SIZE ${OS_VERSION}
echo -e " ${COLOR_CYAN}setting up iceoryx development environment${COLOR_RESET} [${FONT_BOLD}$CONTAINER_NAME${COLOR_RESET}]"

docker exec -it $CONTAINER_NAME /iceoryx/$(git rev-parse --show-prefix)/$0 setup $OS_VERSION
docker exec -it $CONTAINER_NAME /iceoryx/$(realpath $0 --relative-to=$ICEORYX_PATH) setup $OS_VERSION
}

startup_docker() {
Expand Down

0 comments on commit fdee1d6

Please sign in to comment.