diff options
author | Ferran Balaguer <ferran.balaguer@arm.com> | 2019-08-28 16:57:18 +0100 |
---|---|---|
committer | Ferran Balaguer <ferran.balaguer@arm.com> | 2019-09-13 09:50:20 +0100 |
commit | 1b941728caa2cd7e2148d0872a6b7dda4947b641 (patch) | |
tree | 0820663b520604256554f55e4f4bf07ebc6a3fa3 /src/profiling/test/SendCounterPacketTests.cpp | |
parent | 9bff14458f9950a5d31b9523c62c0bbf79a65fcf (diff) | |
download | armnn-1b941728caa2cd7e2148d0872a6b7dda4947b641.tar.gz |
IVGCVSW-3436 Create the Periodic Counter Selection Command Handler
Change-Id: Ia6fe19db5aebe82bb00dcbab17e16633befda0a5
Signed-off-by: Ferran Balaguer <ferran.balaguer@arm.com>
Diffstat (limited to 'src/profiling/test/SendCounterPacketTests.cpp')
-rw-r--r-- | src/profiling/test/SendCounterPacketTests.cpp | 90 |
1 files changed, 3 insertions, 87 deletions
diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp index 626a5a6589..4c4620ffca 100644 --- a/src/profiling/test/SendCounterPacketTests.cpp +++ b/src/profiling/test/SendCounterPacketTests.cpp @@ -1,11 +1,12 @@ // -// Copyright © 2017 Arm Ltd. All rights reserved. +// Copyright © 2019 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "../SendCounterPacket.hpp" #include "../ProfilingUtils.hpp" #include "../EncodeVersion.hpp" +#include "../SendCounterPacket.hpp" +#include "SendCounterPacketTests.hpp" #include <armnn/Exceptions.hpp> @@ -17,91 +18,6 @@ BOOST_AUTO_TEST_SUITE(SendCounterPacketTests) -using namespace armnn::profiling; - -class MockBuffer : public IBufferWrapper -{ -public: - MockBuffer(unsigned int size) - : m_BufferSize(size), - m_Buffer(std::make_unique<unsigned char[]>(size)) {} - - unsigned char* Reserve(unsigned int requestedSize, unsigned int& reservedSize) override - { - if (requestedSize > m_BufferSize) - { - reservedSize = m_BufferSize; - } - else - { - reservedSize = requestedSize; - } - - return m_Buffer.get(); - } - - void Commit(unsigned int size) override {} - - const unsigned char* GetReadBuffer(unsigned int& size) override - { - size = static_cast<unsigned int>(strlen(reinterpret_cast<const char*>(m_Buffer.get())) + 1); - return m_Buffer.get(); - } - - void Release( unsigned int size) override {} - -private: - unsigned int m_BufferSize; - std::unique_ptr<unsigned char[]> m_Buffer; -}; - -class MockSendCounterPacket : public ISendCounterPacket -{ -public: - MockSendCounterPacket(IBufferWrapper& sendBuffer) : m_Buffer(sendBuffer) {} - - void SendStreamMetaDataPacket() override - { - std::string message("SendStreamMetaDataPacket"); - unsigned int reserved = 0; - unsigned char* buffer = m_Buffer.Reserve(1024, reserved); - memcpy(buffer, message.c_str(), static_cast<unsigned int>(message.size()) + 1); - } - - void SendCounterDirectoryPacket(const CounterDirectory& counterDirectory) override - { - std::string message("SendCounterDirectoryPacket"); - unsigned int reserved = 0; - unsigned char* buffer = m_Buffer.Reserve(1024, reserved); - memcpy(buffer, message.c_str(), static_cast<unsigned int>(message.size()) + 1); - } - - void SendPeriodicCounterCapturePacket(uint64_t timestamp, - const std::vector<std::pair<uint16_t, uint32_t>>& values) override - { - std::string message("SendPeriodicCounterCapturePacket"); - unsigned int reserved = 0; - unsigned char* buffer = m_Buffer.Reserve(1024, reserved); - memcpy(buffer, message.c_str(), static_cast<unsigned int>(message.size()) + 1); - } - - void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, - const std::vector<uint16_t>& selectedCounterIds) override - { - std::string message("SendPeriodicCounterSelectionPacket"); - unsigned int reserved = 0; - unsigned char* buffer = m_Buffer.Reserve(1024, reserved); - memcpy(buffer, message.c_str(), static_cast<unsigned int>(message.size()) + 1); - m_Buffer.Commit(reserved); - } - - void SetReadyToRead() override - {} - -private: - IBufferWrapper& m_Buffer; -}; - BOOST_AUTO_TEST_CASE(MockSendCounterPacketTest) { unsigned int size = 0; |