16 #include <boost/polymorphic_cast.hpp> 17 #include <boost/test/unit_test.hpp> 48 , m_BackupBuffer(m_Stream.rdbuf(newStreamBuffer))
56 if (m_BackupBuffer !=
nullptr )
58 m_Stream.rdbuf(m_BackupBuffer);
59 m_BackupBuffer =
nullptr;
64 std::ostream& m_Stream;
65 std::streambuf* m_BackupBuffer;
74 bool IsOpen()
const override {
return true; }
78 bool WritePacket(
const unsigned char* buffer, uint32_t length)
override 80 boost::ignore_unused(buffer, length);
96 std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
101 bool m_FirstCall =
true;
114 if (m_ReadRequests % 3 == 0)
116 std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
126 return m_ReadRequests.load();
130 std::atomic<int> m_ReadRequests;
142 boost::ignore_unused(timeout);
149 return m_ReadRequests.load();
153 std::atomic<int> m_ReadRequests;
161 boost::ignore_unused(timeout);
167 uint32_t packetFamily = 0;
168 uint32_t packetId = 37;
169 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
184 boost::ignore_unused(packet);
194 using TestFunctorA::TestFunctorA;
199 using TestFunctorA::TestFunctorA;
210 , m_BackupProfilingConnectionFactory(nullptr)
214 m_MockProfilingConnectionFactory.get(),
215 m_BackupProfilingConnectionFactory);
223 m_BackupProfilingConnectionFactory,
230 return boost::polymorphic_downcast<MockProfilingConnection*>(profilingConnection);
241 uint32_t timeout = 1000)
246 while(packetCount == 0 && timeout != 0)
248 std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
252 std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
255 uint32_t elapsedTime =
static_cast<uint32_t
>(
256 std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
258 packetCount = mockProfilingConnection->
CheckForPacket({packetType, length});
260 if (elapsedTime > timeout)
265 timeout -= elapsedTime;
std::unique_ptr< MockProfilingConnectionFactory > MockProfilingConnectionFactoryPtr
TestProfilingConnectionArmnnError()
Packet ReadPacket(uint32_t timeout) override
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
~SwapProfilingConnectionFactoryHelper()
Packet ReadPacket(uint32_t timeout) override
long CheckForPacket(const std::pair< PacketType, uint32_t > packetInfo)
TestProfilingConnectionTimeoutError()
long WaitForPacketsSent(MockProfilingConnection *mockProfilingConnection, MockProfilingConnection::PacketType packetType, uint32_t length=0, uint32_t timeout=1000)
void ForceTransitionToState(ProfilingState newState)
void operator()(const Packet &packet) override
MockProfilingConnection * GetMockProfilingConnection()
Packet ReadPacket(uint32_t timeout) override
bool IsOpen() const override
bool WritePacket(const unsigned char *buffer, uint32_t length) override
LogLevelSwapper(armnn::LogSeverity severity)
CommandHandlerFunctor(uint32_t familyId, uint32_t packetId, uint32_t version)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
SwapProfilingConnectionFactoryHelper()
Base class for all ArmNN exceptions so that users can filter to just those.
static ProfilingService & Instance()
bool WaitForPacketSent(ProfilingService &instance, uint32_t timeout=1000)
StreamRedirector(std::ostream &stream, std::streambuf *newStreamBuffer)
Packet ReadPacket(uint32_t timeout) override