From 404b27569523f4cdd49752e7ae1633e359ba2190 Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Tue, 24 Sep 2019 17:23:16 +0100 Subject: IVGCVSW-3902 Create IReadOnlyPacketBuffer, IPacketBuffer and IBufferManager interfaces * Create IReadOnlyPacketBuffer, IPacketBuffer and IBufferManager interfaces * Add Read and Write util functions that use IPacketBuffer * Add MockBufferManager using IBufferManager for testing * Modify SendCounterPacket to use IBufferManager * Modify MockStreamCounterBuffer to use IBufferManager * Remove IBufferWrapper and MockBuffer * Add MockPacketBuffer for testing * Modify unit tests to use the new interfaces Signed-off-by: Narumol Prangnawarat Change-Id: Ib86768187e032f07169aa39367a418b7665c9f03 --- src/profiling/test/ProfilingTests.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/profiling/test/ProfilingTests.cpp') diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index 1741160f96..a474c309e8 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -1756,7 +1756,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) Holder holder; TestCaptureThread captureThread; MockProfilingConnection mockProfilingConnection; - MockBuffer mockBuffer(512); + MockBufferManager mockBuffer(512); SendCounterPacket sendCounterPacket(mockProfilingConnection, mockBuffer); uint32_t sizeOfUint32 = numeric_cast(sizeof(uint32_t)); @@ -1789,9 +1789,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) BOOST_TEST(counterIds[0] == 4000); BOOST_TEST(counterIds[1] == 5000); - unsigned int size = 0; - - const unsigned char* readBuffer = mockBuffer.GetReadBuffer(size); + auto readBuffer = mockBuffer.GetReadableBuffer(); offset = 0; @@ -1814,6 +1812,8 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) counterId = ReadUint16(readBuffer, offset); BOOST_TEST(counterId == 5000); + mockBuffer.MarkRead(readBuffer); + // Data with period only uint32_t period2 = 11; uint32_t dataLength2 = 4; @@ -1831,7 +1831,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) BOOST_TEST(holder.GetCaptureData().GetCapturePeriod() == period2); BOOST_TEST(counterIds.size() == 0); - readBuffer = mockBuffer.GetReadBuffer(size); + readBuffer = mockBuffer.GetReadableBuffer(); offset = 0; @@ -2115,7 +2115,7 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread) std::vector captureIds2; MockProfilingConnection mockProfilingConnection; - MockBuffer mockBuffer(512); + MockBufferManager mockBuffer(512); SendCounterPacket sendCounterPacket(mockProfilingConnection, mockBuffer); std::vector counterIds; @@ -2146,9 +2146,7 @@ BOOST_AUTO_TEST_CASE(CheckPeriodicCounterCaptureThread) periodicCounterCapture.Join(); - unsigned int size = 0; - - const unsigned char* buffer = mockBuffer.GetReadBuffer(size); + auto buffer = mockBuffer.GetReadableBuffer(); uint32_t headerWord0 = ReadUint32(buffer, 0); uint32_t headerWord1 = ReadUint32(buffer, 4); @@ -2187,7 +2185,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest0) Packet packetA(packetId, 0, packetData); MockProfilingConnection mockProfilingConnection; - MockBuffer mockBuffer(1024); + MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockProfilingConnection, mockBuffer); CounterDirectory counterDirectory; @@ -2195,8 +2193,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest0) RequestCounterDirectoryCommandHandler commandHandler(packetId, version, counterDirectory, sendCounterPacket); commandHandler(packetA); - unsigned int size = 0; - const unsigned char* readBuffer = mockBuffer.GetReadBuffer(size); + auto readBuffer = mockBuffer.GetReadableBuffer(); uint32_t headerWord0 = ReadUint32(readBuffer, 0); uint32_t headerWord1 = ReadUint32(readBuffer, 4); @@ -2222,7 +2219,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) Packet packetA(packetId, 0, packetData); MockProfilingConnection mockProfilingConnection; - MockBuffer mockBuffer(1024); + MockBufferManager mockBuffer(1024); SendCounterPacket sendCounterPacket(mockProfilingConnection, mockBuffer); CounterDirectory counterDirectory; @@ -2235,8 +2232,7 @@ BOOST_AUTO_TEST_CASE(RequestCounterDirectoryCommandHandlerTest1) RequestCounterDirectoryCommandHandler commandHandler(packetId, version, counterDirectory, sendCounterPacket); commandHandler(packetA); - unsigned int size = 0; - const unsigned char* readBuffer = mockBuffer.GetReadBuffer(size); + auto readBuffer = mockBuffer.GetReadableBuffer(); uint32_t headerWord0 = ReadUint32(readBuffer, 0); uint32_t headerWord1 = ReadUint32(readBuffer, 4); -- cgit v1.2.1