aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/test/SendCounterPacketTests.hpp
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-09-30 16:20:20 +0100
committerNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-10-04 10:13:25 +0100
commit0ec068f220daf03049a9ffb5ac53118162f50106 (patch)
treebf0673657c6ff328a70346f7fb4f714143af17b6 /src/profiling/test/SendCounterPacketTests.hpp
parent6b0f3c6d7025fb26bd2a7733dbfba02afaa44313 (diff)
downloadarmnn-0ec068f220daf03049a9ffb5ac53118162f50106.tar.gz
IVGCVSW-3904 Add more unit tests for send thread with BufferManager
* Add timeout parameter to wait for readable data * Write all readable data to the profiling connection when ready to read * Set ready to read when buffer exhaust * Ensure that readable data get written to profiling connection before the send thread is stopped * Add MockWriteProfilingConnection to be able to test WritePacket * Refactor BufferManager and the unit tests Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com> Change-Id: I80ae01bd8d0119a3a3a957069ae8ac521c005a12
Diffstat (limited to 'src/profiling/test/SendCounterPacketTests.hpp')
-rw-r--r--src/profiling/test/SendCounterPacketTests.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp
index 3c3427c4c7..584df5e520 100644
--- a/src/profiling/test/SendCounterPacketTests.hpp
+++ b/src/profiling/test/SendCounterPacketTests.hpp
@@ -42,6 +42,35 @@ 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; }
+
+ bool WritePacket(const unsigned char* buffer, uint32_t length) override
+ {
+ m_WrittenData.push_back(length);
+ return buffer != nullptr && length > 0;
+ }
+
+ Packet ReadPacket(uint32_t timeout) override { return Packet(); }
+
+ std::vector<uint32_t> GetWrittenData()
+ {
+ return m_WrittenData;
+ }
+
+private:
+ bool m_IsOpen;
+ std::vector<uint32_t> m_WrittenData;
+};
+
class MockPacketBuffer : public IPacketBuffer
{
public: