aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-11-13 10:56:41 +0000
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-11-15 17:10:36 +0000
commit9723d0243463e3a32ed11ae1c38298343b4e8818 (patch)
tree336e01c0199657f4a0cf7e71acb056fba2c77a6f
parent87972be8d838f6fde6f6e98dd81c422e85457a5e (diff)
downloadarmnn-9723d0243463e3a32ed11ae1c38298343b4e8818.tar.gz
IVGCVSW-4074 Send Timeline message in RequestCounterDirectoryCommandHandler
* Added call to SendTimelineMessageDirectoryPackage in the handler * Updated the unit tests accordingly * Refactored SendTimelinePacket to remove macro Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I7bb6f8575945b99a0e77ef30ecfe4dee3058669e
-rw-r--r--src/profiling/ProfilingService.hpp1
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.cpp3
-rw-r--r--src/profiling/RequestCounterDirectoryCommandHandler.hpp4
-rw-r--r--src/profiling/SendTimelinePacket.cpp128
-rw-r--r--src/profiling/SendTimelinePacket.hpp42
-rw-r--r--src/profiling/test/ProfilingTests.cpp135
6 files changed, 177 insertions, 136 deletions
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index b68b6524f5..d4ff9085f5 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -148,6 +148,7 @@ protected:
m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(),
m_CounterDirectory,
m_SendCounterPacket,
+ m_SendTimelinePacket,
m_StateMachine)
, m_PeriodicCounterSelectionCommandHandler(0,
4,
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.cpp b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
index b8ac9d9426..2dbab3c1d5 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.cpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.cpp
@@ -34,8 +34,9 @@ void RequestCounterDirectoryCommandHandler::operator()(const Packet& packet)
% packet.GetPacketId()));
}
- // Write a Counter Directory packet to the Counter Stream Buffer
+ // Send all the packet required for the handshake with the external profiling service
m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
+ m_SendTimelinePacket.SendTimelineMessageDirectoryPackage();
// Notify the Send Thread that new data is available in the Counter Stream Buffer
m_SendCounterPacket.SetReadyToRead();
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.hpp b/src/profiling/RequestCounterDirectoryCommandHandler.hpp
index 907be89a22..99c035240c 100644
--- a/src/profiling/RequestCounterDirectoryCommandHandler.hpp
+++ b/src/profiling/RequestCounterDirectoryCommandHandler.hpp
@@ -7,6 +7,7 @@
#include "CommandHandlerFunctor.hpp"
#include "ISendCounterPacket.hpp"
+#include "ISendTimelinePacket.hpp"
#include "Packet.hpp"
#include "ProfilingStateMachine.hpp"
@@ -25,10 +26,12 @@ public:
uint32_t version,
ICounterDirectory& counterDirectory,
ISendCounterPacket& sendCounterPacket,
+ ISendTimelinePacket& sendTimelinePacket,
ProfilingStateMachine& profilingStateMachine)
: CommandHandlerFunctor(familyId, packetId, version)
, m_CounterDirectory(counterDirectory)
, m_SendCounterPacket(sendCounterPacket)
+ , m_SendTimelinePacket(sendTimelinePacket)
, m_StateMachine(profilingStateMachine)
{}
@@ -37,6 +40,7 @@ public:
private:
const ICounterDirectory& m_CounterDirectory;
ISendCounterPacket& m_SendCounterPacket;
+ ISendTimelinePacket& m_SendTimelinePacket;
const ProfilingStateMachine& m_StateMachine;
};
diff --git a/src/profiling/SendTimelinePacket.cpp b/src/profiling/SendTimelinePacket.cpp
index 707bfba5c4..d769b64a05 100644
--- a/src/profiling/SendTimelinePacket.cpp
+++ b/src/profiling/SendTimelinePacket.cpp
@@ -13,99 +13,68 @@ namespace profiling
void SendTimelinePacket::Commit()
{
- if (m_WriteBuffer != nullptr)
+ if (m_WriteBuffer == nullptr)
{
- // Commit the message
- m_BufferManager.Commit(m_WriteBuffer, m_Offset);
- m_WriteBuffer.reset(nullptr);
- m_Offset = 0;
- m_BufferSize = 0;
+ // Can't commit from a null buffer
+ return;
}
+
+ // Commit the message
+ m_BufferManager.Commit(m_WriteBuffer, m_Offset);
+ m_WriteBuffer.reset(nullptr);
+ m_Offset = 0;
+ m_BufferSize = 0;
}
void SendTimelinePacket::ReserveBuffer()
{
- if (m_WriteBuffer == nullptr)
+ if (m_WriteBuffer != nullptr)
{
- uint32_t reserved = 0;
+ // Buffer already reserved
+ return;
+ }
- // Reserve the buffer
- m_WriteBuffer = m_BufferManager.Reserve(MAX_METADATA_PACKET_LENGTH, reserved);
+ uint32_t reserved = 0;
- // Check if there is enough space in the buffer
- if (m_WriteBuffer == nullptr || reserved < m_Offset)
- {
- throw BufferExhaustion("No space left on buffer", CHECK_LOCATION());
- }
- m_BufferSize = reserved;
+ // Reserve the buffer
+ m_WriteBuffer = m_BufferManager.Reserve(MAX_METADATA_PACKET_LENGTH, reserved);
+
+ // Check if there is enough space in the buffer
+ if (m_WriteBuffer == nullptr || reserved < m_Offset)
+ {
+ throw BufferExhaustion("No space left on buffer", CHECK_LOCATION());
}
-}
-#define FORWARD_WRITE_BINARY_FUNC(func, ...) \
-try \
-{ \
- ReserveBuffer(); \
- unsigned int numberOfBytes = 0; \
- while (1) \
- { \
- TimelinePacketStatus result = func(__VA_ARGS__, numberOfBytes); \
- if (result == armnn::profiling::TimelinePacketStatus::BufferExhaustion) \
- { \
- Commit(); \
- ReserveBuffer(); \
- } \
- else if (result == armnn::profiling::TimelinePacketStatus::Error) \
- { \
- throw RuntimeException("Error processing while sending TimelineBinaryPacket.", CHECK_LOCATION()); \
- } \
- else \
- { \
- break; \
- } \
- } \
- m_Offset += numberOfBytes; \
- m_BufferSize -= numberOfBytes; \
-} \
-catch(...) \
-{ \
- throw RuntimeException("Error processing while sending TimelineBinaryPacket.", CHECK_LOCATION()); \
+ m_BufferSize = reserved;
}
void SendTimelinePacket::SendTimelineEntityBinaryPacket(uint64_t profilingGuid)
{
- FORWARD_WRITE_BINARY_FUNC(WriteTimelineEntityBinaryPacket,
- profilingGuid,
- &m_WriteBuffer->GetWritableData()[m_Offset],
- m_BufferSize);
+ ForwardWriteBinaryFunction(WriteTimelineEntityBinaryPacket,
+ profilingGuid);
}
void SendTimelinePacket::SendTimelineEventBinaryPacket(uint64_t timestamp,
std::thread::id threadId,
uint64_t profilingGuid)
{
- FORWARD_WRITE_BINARY_FUNC(WriteTimelineEventBinaryPacket,
- timestamp,
- threadId,
- profilingGuid,
- &m_WriteBuffer->GetWritableData()[m_Offset],
- m_BufferSize);
+ ForwardWriteBinaryFunction(WriteTimelineEventBinaryPacket,
+ timestamp,
+ threadId,
+ profilingGuid);
}
void SendTimelinePacket::SendTimelineEventClassBinaryPacket(uint64_t profilingGuid)
{
- FORWARD_WRITE_BINARY_FUNC(WriteTimelineEventClassBinaryPacket,
- profilingGuid,
- &m_WriteBuffer->GetWritableData()[m_Offset],
- m_BufferSize);
+ ForwardWriteBinaryFunction(WriteTimelineEventClassBinaryPacket,
+ profilingGuid);
}
void SendTimelinePacket::SendTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string& label)
{
- FORWARD_WRITE_BINARY_FUNC(WriteTimelineLabelBinaryPacket,
- profilingGuid,
- label,
- &m_WriteBuffer->GetWritableData()[m_Offset],
- m_BufferSize);
+ ForwardWriteBinaryFunction(WriteTimelineLabelBinaryPacket,
+ profilingGuid,
+ label);
}
void SendTimelinePacket::SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType,
@@ -113,41 +82,38 @@ void SendTimelinePacket::SendTimelineRelationshipBinaryPacket(ProfilingRelations
uint64_t headGuid,
uint64_t tailGuid)
{
- FORWARD_WRITE_BINARY_FUNC(WriteTimelineRelationshipBinaryPacket,
- relationshipType,
- relationshipGuid,
- headGuid,
- tailGuid,
- &m_WriteBuffer->GetWritableData()[m_Offset],
- m_BufferSize);
+ ForwardWriteBinaryFunction(WriteTimelineRelationshipBinaryPacket,
+ relationshipType,
+ relationshipGuid,
+ headGuid,
+ tailGuid);
}
void SendTimelinePacket::SendTimelineMessageDirectoryPackage()
{
try
{
- // Reserve buffer if hasn't already reserved
+ // Reserve buffer if it hasn't already been reserved
ReserveBuffer();
- unsigned int numberOfBytes = 0;
// Write to buffer
+ unsigned int numberOfBytesWritten = 0;
TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(&m_WriteBuffer->GetWritableData()[m_Offset],
m_BufferSize,
- numberOfBytes);
-
+ numberOfBytesWritten);
if (result != armnn::profiling::TimelinePacketStatus::Ok)
{
- throw RuntimeException("Error processing TimelineMessageDirectoryPackage.", CHECK_LOCATION());
+ throw RuntimeException("Error processing TimelineMessageDirectoryPackage", CHECK_LOCATION());
}
// Commit the message
- m_Offset += numberOfBytes;
- m_BufferSize -= numberOfBytes;
- m_BufferManager.Commit(m_WriteBuffer, m_Offset);
+ m_Offset += numberOfBytesWritten;
+ m_BufferSize -= numberOfBytesWritten;
+ Commit();
}
- catch(...)
+ catch (...)
{
- throw RuntimeException("Error processing TimelineMessageDirectoryPackage.", CHECK_LOCATION());
+ throw RuntimeException("Error processing TimelineMessageDirectoryPackage", CHECK_LOCATION());
}
}
diff --git a/src/profiling/SendTimelinePacket.hpp b/src/profiling/SendTimelinePacket.hpp
index 77268a4eb5..4b2e06328b 100644
--- a/src/profiling/SendTimelinePacket.hpp
+++ b/src/profiling/SendTimelinePacket.hpp
@@ -9,6 +9,8 @@
#include "ISendTimelinePacket.hpp"
#include "ProfilingUtils.hpp"
+#include <boost/assert.hpp>
+
#include <memory>
namespace armnn
@@ -54,12 +56,52 @@ private:
/// Reserves maximum packet size from buffer
void ReserveBuffer();
+ template <typename Func, typename ... Params>
+ void ForwardWriteBinaryFunction(Func& func, Params&& ... params);
+
IBufferManager& m_BufferManager;
IPacketBufferPtr m_WriteBuffer;
unsigned int m_Offset;
unsigned int m_BufferSize;
};
+template <typename Func, typename ... Params>
+void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... params)
+{
+ try
+ {
+ ReserveBuffer();
+ BOOST_ASSERT(m_WriteBuffer);
+ unsigned int numberOfBytesWritten = 0;
+ while (true)
+ {
+ TimelinePacketStatus result = func(std::forward<Params>(params)...,
+ &m_WriteBuffer->GetWritableData()[m_Offset],
+ m_BufferSize,
+ numberOfBytesWritten);
+ switch (result)
+ {
+ case TimelinePacketStatus::BufferExhaustion:
+ Commit();
+ ReserveBuffer();
+ continue;
+
+ case TimelinePacketStatus::Error:
+ throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION());
+
+ default:
+ m_Offset += numberOfBytesWritten;
+ m_BufferSize -= numberOfBytesWritten;
+ return;
+ }
+ }
+ }
+ catch (...)
+ {
+ throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION());
+ }
+}
+
} // namespace profiling
} // namespace armnn
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index b197273dc5..9c8c6cdec7 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -2053,10 +2053,12 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
const uint32_t version = 1;
ProfilingStateMachine profilingStateMachine;
CounterDirectory counterDirectory;
- MockBufferManager mockBuffer(1024);
- SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer);
+ MockBufferManager mockBuffer1(1024);
+ SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer1);
+ MockBufferManager mockBuffer2(1024);
+ SendTimelinePacket sendTimelinePacket(mockBuffer2);
RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
- sendCounterPacket, profilingStateMachine);
+ sendCounterPacket, sendTimelinePacket, profilingStateMachine);
const uint32_t wrongPacketId = 47;
const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16;
@@ -2064,32 +2066,43 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1)
Packet wrongPacket(wrongHeader);
profilingStateMachine.TransitionToState(ProfilingState::Uninitialised);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::NotConnected);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::WaitingForAck);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::RuntimeException); // Wrong profiling state
profilingStateMachine.TransitionToState(ProfilingState::Active);
- BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::InvalidArgumentException); // Wrong packet
+ BOOST_CHECK_THROW(commandHandler(wrongPacket), armnn::InvalidArgumentException); // Wrong packet
const uint32_t rightHeader = (packetId & 0x000003FF) << 16;
Packet rightPacket(rightHeader);
- BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet
+ BOOST_CHECK_NO_THROW(commandHandler(rightPacket)); // Right packet
- auto readBuffer = mockBuffer.GetReadableBuffer();
+ auto readBuffer1 = mockBuffer1.GetReadableBuffer();
+
+ uint32_t header1Word0 = ReadUint32(readBuffer1, 0);
+ uint32_t header1Word1 = ReadUint32(readBuffer1, 4);
+
+ // Counter directory packet
+ BOOST_TEST(((header1Word0 >> 26) & 0x0000003F) == 0); // packet family
+ BOOST_TEST(((header1Word0 >> 16) & 0x000003FF) == 2); // packet id
+ BOOST_TEST(header1Word1 == 24); // data length
- uint32_t headerWord0 = ReadUint32(readBuffer, 0);
- uint32_t headerWord1 = ReadUint32(readBuffer, 4);
+ uint32_t bodyHeader1Word0 = ReadUint32(readBuffer1, 8);
+ uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeader1Word0 >> 16);
+ BOOST_TEST(deviceRecordCount == 0); // device_records_count
- BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x000003FF) == 2); // packet id
- BOOST_TEST(headerWord1 == 24); // data length
+ auto readBuffer2 = mockBuffer2.GetReadableBuffer();
- uint32_t bodyHeaderWord0 = ReadUint32(readBuffer, 8);
- uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeaderWord0 >> 16);
- BOOST_TEST(deviceRecordCount == 0); // device_records_count
+ uint32_t header2Word0 = ReadUint32(readBuffer2, 0);
+ uint32_t header2Word1 = ReadUint32(readBuffer2, 4);
+
+ // Timeline message directory packet
+ BOOST_TEST(((header2Word0 >> 26) & 0x0000003F) == 1); // packet family
+ BOOST_TEST(((header2Word0 >> 16) & 0x000003FF) == 0); // packet id
+ BOOST_TEST(header2Word1 == 419); // data length
}
BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
@@ -2101,15 +2114,19 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
const uint32_t version = 1;
ProfilingStateMachine profilingStateMachine;
CounterDirectory counterDirectory;
- MockBufferManager mockBuffer(1024);
- SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer);
+ MockBufferManager mockBuffer1(1024);
+ SendCounterPacket sendCounterPacket(profilingStateMachine, mockBuffer1);
+ MockBufferManager mockBuffer2(1024);
+ SendTimelinePacket sendTimelinePacket(mockBuffer2);
RequestCounterDirectoryCommandHandler commandHandler(familyId, packetId, version, counterDirectory,
- sendCounterPacket, profilingStateMachine);
+ sendCounterPacket, sendTimelinePacket, profilingStateMachine);
const uint32_t header = (packetId & 0x000003FF) << 16;
Packet packet(header);
- const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
+ const Device* device = counterDirectory.RegisterDevice("deviceA", 1);
+ BOOST_CHECK(device != nullptr);
const CounterSet* counterSet = counterDirectory.RegisterCounterSet("countersetA");
+ BOOST_CHECK(counterSet != nullptr);
counterDirectory.RegisterCategory("categoryA", device->m_Uid, counterSet->m_Uid);
counterDirectory.RegisterCounter("categoryA", 0, 1, 2.0f, "counterA", "descA");
counterDirectory.RegisterCounter("categoryA", 1, 1, 3.0f, "counterB", "descB");
@@ -2123,39 +2140,49 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest2)
profilingStateMachine.TransitionToState(ProfilingState::Active);
BOOST_CHECK_NO_THROW(commandHandler(packet));
- auto readBuffer = mockBuffer.GetReadableBuffer();
-
- uint32_t headerWord0 = ReadUint32(readBuffer, 0);
- uint32_t headerWord1 = ReadUint32(readBuffer, 4);
-
- BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x000003FF) == 2); // packet id
- BOOST_TEST(headerWord1 == 240); // data length
-
- uint32_t bodyHeaderWord0 = ReadUint32(readBuffer, 8);
- uint32_t bodyHeaderWord1 = ReadUint32(readBuffer, 12);
- uint32_t bodyHeaderWord2 = ReadUint32(readBuffer, 16);
- uint32_t bodyHeaderWord3 = ReadUint32(readBuffer, 20);
- uint32_t bodyHeaderWord4 = ReadUint32(readBuffer, 24);
- uint32_t bodyHeaderWord5 = ReadUint32(readBuffer, 28);
- uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeaderWord0 >> 16);
- uint16_t counterSetRecordCount = numeric_cast<uint16_t>(bodyHeaderWord2 >> 16);
- uint16_t categoryRecordCount = numeric_cast<uint16_t>(bodyHeaderWord4 >> 16);
- BOOST_TEST(deviceRecordCount == 1); // device_records_count
- BOOST_TEST(bodyHeaderWord1 == 0); // device_records_pointer_table_offset
- BOOST_TEST(counterSetRecordCount == 1); // counter_set_count
- BOOST_TEST(bodyHeaderWord3 == 4); // counter_set_pointer_table_offset
- BOOST_TEST(categoryRecordCount == 1); // categories_count
- BOOST_TEST(bodyHeaderWord5 == 8); // categories_pointer_table_offset
-
- uint32_t deviceRecordOffset = ReadUint32(readBuffer, 32);
+ auto readBuffer1 = mockBuffer1.GetReadableBuffer();
+
+ uint32_t header1Word0 = ReadUint32(readBuffer1, 0);
+ uint32_t header1Word1 = ReadUint32(readBuffer1, 4);
+
+ BOOST_TEST(((header1Word0 >> 26) & 0x0000003F) == 0); // packet family
+ BOOST_TEST(((header1Word0 >> 16) & 0x000003FF) == 2); // packet id
+ BOOST_TEST(header1Word1 == 240); // data length
+
+ uint32_t bodyHeader1Word0 = ReadUint32(readBuffer1, 8);
+ uint32_t bodyHeader1Word1 = ReadUint32(readBuffer1, 12);
+ uint32_t bodyHeader1Word2 = ReadUint32(readBuffer1, 16);
+ uint32_t bodyHeader1Word3 = ReadUint32(readBuffer1, 20);
+ uint32_t bodyHeader1Word4 = ReadUint32(readBuffer1, 24);
+ uint32_t bodyHeader1Word5 = ReadUint32(readBuffer1, 28);
+ uint16_t deviceRecordCount = numeric_cast<uint16_t>(bodyHeader1Word0 >> 16);
+ uint16_t counterSetRecordCount = numeric_cast<uint16_t>(bodyHeader1Word2 >> 16);
+ uint16_t categoryRecordCount = numeric_cast<uint16_t>(bodyHeader1Word4 >> 16);
+ BOOST_TEST(deviceRecordCount == 1); // device_records_count
+ BOOST_TEST(bodyHeader1Word1 == 0); // device_records_pointer_table_offset
+ BOOST_TEST(counterSetRecordCount == 1); // counter_set_count
+ BOOST_TEST(bodyHeader1Word3 == 4); // counter_set_pointer_table_offset
+ BOOST_TEST(categoryRecordCount == 1); // categories_count
+ BOOST_TEST(bodyHeader1Word5 == 8); // categories_pointer_table_offset
+
+ uint32_t deviceRecordOffset = ReadUint32(readBuffer1, 32);
BOOST_TEST(deviceRecordOffset == 0);
- uint32_t counterSetRecordOffset = ReadUint32(readBuffer, 36);
+ uint32_t counterSetRecordOffset = ReadUint32(readBuffer1, 36);
BOOST_TEST(counterSetRecordOffset == 20);
- uint32_t categoryRecordOffset = ReadUint32(readBuffer, 40);
+ uint32_t categoryRecordOffset = ReadUint32(readBuffer1, 40);
BOOST_TEST(categoryRecordOffset == 44);
+
+ auto readBuffer2 = mockBuffer2.GetReadableBuffer();
+
+ uint32_t header2Word0 = ReadUint32(readBuffer2, 0);
+ uint32_t header2Word1 = ReadUint32(readBuffer2, 4);
+
+ // Timeline message directory packet
+ BOOST_TEST(((header2Word0 >> 26) & 0x0000003F) == 1); // packet family
+ BOOST_TEST(((header2Word0 >> 16) & 0x000003FF) == 0); // packet id
+ BOOST_TEST(header2Word1 == 419); // data length
}
BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket)
@@ -2296,9 +2323,8 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodConnectionAcknowledgedPacket)
// Write the packet to the mock profiling connection
mockProfilingConnection->WritePacket(std::move(connectionAcknowledgedPacket));
- // Wait for a bit (must at least be the delay value of the mock profiling connection) to make sure that
- // the Connection Acknowledged packet gets processed by the profiling service
- std::this_thread::sleep_for(std::chrono::seconds(2));
+ // Wait for the Counter Directory packet to be sent
+ helper.WaitForProfilingPacketsSent();
// The Connection Acknowledged Command Handler should have updated the profiling state accordingly
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Active);
@@ -2439,8 +2465,9 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodRequestCounterDirectoryPacket)
// Check that the mock profiling connection contains one Counter Directory packet
const std::vector<uint32_t> writtenData = mockProfilingConnection->GetWrittenData();
- BOOST_TEST(writtenData.size() == 1);
- BOOST_TEST(writtenData[0] == 416); // The size of the expected Counter Directory packet
+ BOOST_TEST(writtenData.size() == 2);
+ BOOST_TEST(writtenData[0] == 427); // The size of the expected Timeline Directory packet
+ BOOST_TEST(writtenData[1] == 416); // The size of the expected Counter Directory packet
// The Request Counter Directory Command Handler should not have updated the profiling state
BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Active);