Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions modules/jarnax/source/cyphal/O1HeapPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ O1HeapPool& O1HeapPool::Instance() {
}

void* O1HeapPool::allocate(std::size_t bytes, std::size_t alignment) {
if (alignment > O1HEAP_ALIGNMENT) {
return nullptr;
}
(void)alignment;
return o1heapAllocate(&HeapInstance(), bytes);
}

Expand Down
20 changes: 10 additions & 10 deletions modules/jarnax/tests/gtest-cyphal-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ class CyphalNodeTest : public ::testing::Test {
};

TEST_F(CyphalNodeTest, ConstructorStoresAnonymousNodeIdentity) {
Node node{timer, interface, NodeId{0u}, unique_id};
Node constructed_node{timer, interface, NodeId{0u}, unique_id};

EXPECT_EQ(node.GetId(), NodeId{0U});
EXPECT_EQ(node.GetUniqueId(), unique_id);
EXPECT_EQ(constructed_node.GetId(), NodeId{0U});
EXPECT_EQ(constructed_node.GetUniqueId(), unique_id);
}

TEST_F(CyphalNodeTest, ConstructorStoresNodeIdentity) {
NodeId const node_id{42U};
Node node{timer, interface, node_id, unique_id};
Node constructed_node{timer, interface, node_id, unique_id};

EXPECT_EQ(node.GetId(), node_id);
EXPECT_EQ(node.GetUniqueId(), unique_id);
EXPECT_EQ(constructed_node.GetId(), node_id);
EXPECT_EQ(constructed_node.GetUniqueId(), unique_id);
}

TEST_F(CyphalNodeTest, RunOnceRemainsActiveAsTimeAdvances) {
Expand Down Expand Up @@ -364,7 +364,7 @@ TEST_F(CyphalNodeTest, PublishSendsBroadcastSubject) {
TEST_F(CyphalNodeTest, RequestSendsTargetedServiceRequest) {
ServiceId const service_id{23U};
NodeId const recipient{9U};
Node node{timer, interface, NodeId{7U}, unique_id};
Node constructed_node{timer, interface, NodeId{7U}, unique_id};
jarnax::cyphal::mock::MockClient client{};
EXPECT_CALL(interface, Send(testing::_, testing::_))
.WillOnce(
Expand All @@ -379,15 +379,15 @@ TEST_F(CyphalNodeTest, RequestSendsTargetedServiceRequest) {
Return(core::Status{})
)
);
core::Status const actual = node.Request(service_id, recipient, client, message);
core::Status const actual = constructed_node.Request(service_id, recipient, client, message);

ASSERT_STATUS_EQ(actual, core::Result::Success, core::Cause::Unknown);
}

TEST_F(CyphalNodeTest, RespondSendsTargetedServiceResponse) {
ServiceId const service_id{23U};
NodeId const recipient{9U};
Node node{timer, interface, NodeId{7U}, unique_id};
Node constructed_node{timer, interface, NodeId{7U}, unique_id};
EXPECT_CALL(interface, Send(testing::_, testing::_))
.WillOnce(
testing::DoAll(
Expand All @@ -402,7 +402,7 @@ TEST_F(CyphalNodeTest, RespondSendsTargetedServiceResponse) {
)
);

core::Status const actual = node.Respond(service_id, recipient, message);
core::Status const actual = constructed_node.Respond(service_id, recipient, message);

ASSERT_STATUS_EQ(actual, core::Result::Success, core::Cause::Unknown);
}
Expand Down
6 changes: 4 additions & 2 deletions modules/jarnax/tests/gtest-cyphal-o1heappool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ TEST_F(O1HeapPoolTest, AllocatesAndDeallocatesThroughAllocatorInterface) {
TEST_F(O1HeapPoolTest, OverAlignedAllocationsAreServedAtMaxAlignment) {
// o1heap does not reject alignment requests beyond max_align_t; it serves the
// block at its own (max_align_t) granularity instead.
void* const pointer = allocator_.allocate(1U, 2U * alignof(std::max_align_t));
// O1HEAP_ALIGNMENT is sizeof(void*) * 2 on every platform, so requesting
// sizeof(void*) * 4 is always beyond the pool's granularity.
void* const pointer = allocator_.allocate(1U, sizeof(void*) * 4U);
ASSERT_NE(pointer, nullptr);
EXPECT_EQ(reinterpret_cast<std::uintptr_t>(pointer) % alignof(std::max_align_t), 0U);
allocator_.deallocate(pointer, 1U, 2U * alignof(std::max_align_t));
allocator_.deallocate(pointer, 1U, sizeof(void*) * 4U);
}

TEST_F(O1HeapPoolTest, ProvidesUdpardMemoryCallbacks) {
Expand Down
Loading