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 <matteo.martincigh@arm.com>
Change-Id: Ice7080bff63199eac84fc4fa1d37fb1a6fcdff89
diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp
index 0323f62..cae02b06 100644
--- a/src/profiling/test/SendCounterPacketTests.hpp
+++ b/src/profiling/test/SendCounterPacketTests.hpp
@@ -19,7 +19,6 @@
namespace profiling
{
-
class MockProfilingConnection : public IProfilingConnection
{
public:
@@ -33,38 +32,20 @@
bool WritePacket(const unsigned char* buffer, uint32_t length) override
{
- return buffer != nullptr && length > 0;
- }
+ if (buffer == nullptr || length == 0)
+ {
+ return false;
+ }
- 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; }
-
- 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<uint32_t> GetWrittenData()
- {
- return m_WrittenData;
- }
+ const std::vector<uint32_t>& GetWrittenData() const { return m_WrittenData; }
+
+ void Clear() { m_WrittenData.clear(); }
private:
bool m_IsOpen;
@@ -497,8 +478,8 @@
class SendCounterPacketTest : public SendCounterPacket
{
public:
- SendCounterPacketTest(IBufferManager& buffer)
- : SendCounterPacket(buffer)
+ SendCounterPacketTest(ProfilingStateMachine& profilingStateMachine, IBufferManager& buffer)
+ : SendCounterPacket(profilingStateMachine, buffer)
{}
bool CreateDeviceRecordTest(const DevicePtr& device,