From 5d737fb3b06c17ff6b65fb307343ca1c0c680401 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Mon, 7 Oct 2019 13:05:13 +0100 Subject: IVGCVSW-3937 Update the Send thread to send out the Metadata packet * The Send thread now automatically sends out Stream Metadata packets when the Profiling Service is in WaitingForAck state * Added a reference to the profiling state in the SendCounterPacket class * Moving the RuntimeException thrown in the Send thread to the main thread for rethrowing * The Stop method now rethrows the exception occurred in the send thread * The Stop method does not rethrow when destructing the object * Added unit tests Signed-off-by: Matteo Martincigh Change-Id: Ice7080bff63199eac84fc4fa1d37fb1a6fcdff89 --- src/profiling/test/SendCounterPacketTests.hpp | 39 +++++++-------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'src/profiling/test/SendCounterPacketTests.hpp') diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp index 0323f62d80..cae02b064d 100644 --- a/src/profiling/test/SendCounterPacketTests.hpp +++ b/src/profiling/test/SendCounterPacketTests.hpp @@ -19,7 +19,6 @@ namespace armnn namespace profiling { - class MockProfilingConnection : public IProfilingConnection { public: @@ -33,38 +32,20 @@ public: bool WritePacket(const unsigned char* buffer, uint32_t length) override { - return buffer != nullptr && length > 0; - } - - Packet ReadPacket(uint32_t timeout) override { return Packet(); } - -private: - bool m_IsOpen; -}; - -class MockWriteProfilingConnection : public IProfilingConnection -{ -public: - MockWriteProfilingConnection() - : m_IsOpen(true) - {} - - bool IsOpen() override { return m_IsOpen; } - - void Close() override { m_IsOpen = false; } + if (buffer == nullptr || length == 0) + { + return false; + } - bool WritePacket(const unsigned char* buffer, uint32_t length) override - { m_WrittenData.push_back(length); - return buffer != nullptr && length > 0; + return true; } Packet ReadPacket(uint32_t timeout) override { return Packet(); } - std::vector GetWrittenData() - { - return m_WrittenData; - } + const std::vector& GetWrittenData() const { return m_WrittenData; } + + void Clear() { m_WrittenData.clear(); } private: bool m_IsOpen; @@ -497,8 +478,8 @@ private: class SendCounterPacketTest : public SendCounterPacket { public: - SendCounterPacketTest(IBufferManager& buffer) - : SendCounterPacket(buffer) + SendCounterPacketTest(ProfilingStateMachine& profilingStateMachine, IBufferManager& buffer) + : SendCounterPacket(profilingStateMachine, buffer) {} bool CreateDeviceRecordTest(const DevicePtr& device, -- cgit v1.2.1