diff options
author | Finn Williams <Finn.Williams@arm.com> | 2019-12-19 17:05:18 +0000 |
---|---|---|
committer | Finn Williams <Finn.Williams@arm.com> | 2020-01-14 12:39:05 +0000 |
commit | 09ad6f909f25aef02b7f53bba320b534b9260786 (patch) | |
tree | e69f6d9d4b15b0c7e106c5f6749dd77586247a75 /src/profiling/test/ProfilingTests.hpp | |
parent | f90c56d72de4848a2dc5844a97458aaf09df07c2 (diff) | |
download | armnn-09ad6f909f25aef02b7f53bba320b534b9260786.tar.gz |
IVGCVSW-4229 Fix Intermittent failures in ExternalProfiling
* Added a BufferManager.Reset() method to prevent packets being retained after a test
* Fixed a bug causing the send thread to wait needlessly before moving to active state
* Refactored SendCoundPacketTests and ProfilingTests test helper classes
* Fixed issue where WaitForPacketSent could miss a notification and timeout
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I353a652260c2f7dd465baa9e979e22f50f3ca6a7
Diffstat (limited to 'src/profiling/test/ProfilingTests.hpp')
-rw-r--r-- | src/profiling/test/ProfilingTests.hpp | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp index 208fb80865..d6300e6429 100644 --- a/src/profiling/test/ProfilingTests.hpp +++ b/src/profiling/test/ProfilingTests.hpp @@ -153,6 +153,25 @@ private: std::atomic<int> m_ReadRequests; }; +class TestProfilingConnectionBadAckPacket : public TestProfilingConnectionBase +{ +public: + Packet ReadPacket(uint32_t timeout) override + { + boost::ignore_unused(timeout); + // Connection Acknowledged Packet header (word 0, word 1 is always zero): + // 26:31 [6] packet_family: Control Packet Family, value 0b000000 + // 16:25 [10] packet_id: Packet identifier, value 0b0000000001 + // 8:15 [8] reserved: Reserved, value 0b00000000 + // 0:7 [8] reserved: Reserved, value 0b00000000 + uint32_t packetFamily = 0; + uint32_t packetId = 37; // Wrong packet id!!! + uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16); + + return Packet(header); + } +}; + class TestFunctorA : public CommandHandlerFunctor { public: @@ -216,17 +235,36 @@ public: TransitionToState(ProfilingService::Instance(), newState); } - void WaitForProfilingPacketsSent(MockProfilingConnection* mockProfilingConnection, uint32_t timeout = 1000) + long WaitForPacketsSent(MockProfilingConnection* mockProfilingConnection, + MockProfilingConnection::PacketType packetType, + uint32_t length = 0, + uint32_t timeout = 1000) { - if (!mockProfilingConnection->HasWrittenData()) + long packetCount = mockProfilingConnection->CheckForPacket({packetType, length}); + // The first packet we receive may not be the one we are looking for, so keep looping until till we find it, + // or until WaitForPacketsSent times out + while(packetCount == 0 && timeout != 0) { - WaitForPacketSent(ProfilingService::Instance(), timeout); - // It's possible the wait has timed out. Check there is some data. - if (!mockProfilingConnection->HasWrittenData()) + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + // Wait for a notification from the send thread + ProfilingService::WaitForPacketSent(ProfilingService::Instance(), timeout); + + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + + // We need to make sure the timeout does not reset each time we call WaitForPacketsSent + uint32_t elapsedTime = static_cast<uint32_t>( + std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()); + + packetCount = mockProfilingConnection->CheckForPacket({packetType, length}); + + if (elapsedTime > timeout) { - throw RuntimeException("ProfilingTests::WaitForProfilingPacketsSent timeout waiting for packet."); + break; } + + timeout -= elapsedTime; } + return packetCount; } private: |