From 1625efc870f1a8b7c6e6382277ddbb245f91a294 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 10 Jun 2021 18:24:34 +0100 Subject: IVGCVSW-5963 'Move unit tests to new framework' * Used doctest in ArmNN unit tests Signed-off-by: Sadik Armagan Change-Id: Ia9cf5fc72775878885c5f864abf2c56b3a935f1a --- .../src/timelineDecoder/tests/TimelineTests.cpp | 105 ++++++++++----------- 1 file changed, 52 insertions(+), 53 deletions(-) (limited to 'profiling/server/src/timelineDecoder') diff --git a/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp index e7797061c9..4fcd7a0a9c 100644 --- a/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp +++ b/profiling/server/src/timelineDecoder/tests/TimelineTests.cpp @@ -15,11 +15,10 @@ #include #include -#include -#include - -BOOST_AUTO_TEST_SUITE(TimelineDecoderTests) +#include +TEST_SUITE("TimelineDecoderTests") +{ void SendTimelinePacketToCommandHandler(const unsigned char* packetBuffer, arm::pipe::CommandHandlerFunctor& CommandHandler) { @@ -38,7 +37,7 @@ void SendTimelinePacketToCommandHandler(const unsigned char* packetBuffer, arm::pipe::Packet packet(header[0], PacketDataLength, uniquePacketData); - BOOST_CHECK(std::memcmp(packetBuffer + offset, packet.GetData(), packet.GetLength()) == 0); + CHECK(std::memcmp(packetBuffer + offset, packet.GetData(), packet.GetLength()) == 0); CommandHandler(packet); } @@ -69,7 +68,7 @@ void PushRelationship(arm::pipe::TimelineDecoder::Model& model, model.m_Relationships.emplace_back(relationship); } -BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) +TEST_CASE("TimelineDirectoryTest") { uint32_t uint8_t_size = sizeof(uint8_t); uint32_t uint32_t_size = sizeof(uint32_t); @@ -101,13 +100,13 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) std::unique_ptr packetBuffer = bufferManager.GetReadableBuffer(); uint8_t readStreamVersion = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readStreamVersion == 4); + CHECK(readStreamVersion == 4); offset += uint8_t_size; uint8_t readPointerBytes = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readPointerBytes == uint64_t_size); + CHECK(readPointerBytes == uint64_t_size); offset += uint8_t_size; uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readThreadIdBytes == armnn::profiling::ThreadIdSize); + CHECK(readThreadIdBytes == armnn::profiling::ThreadIdSize); offset += uint8_t_size; uint32_t declarationSize = arm::pipe::ReadUint32(packetBuffer->GetReadableData(), offset); @@ -126,25 +125,25 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) arm::pipe::SwTraceMessage& bufferMessage = swTraceBufferMessages[index]; arm::pipe::SwTraceMessage& handlerMessage = timelineDirectoryCaptureCommandHandler.m_SwTraceMessages[index]; - BOOST_CHECK(bufferMessage.m_Name == handlerMessage.m_Name); - BOOST_CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName); - BOOST_CHECK(bufferMessage.m_Id == handlerMessage.m_Id); + CHECK(bufferMessage.m_Name == handlerMessage.m_Name); + CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName); + CHECK(bufferMessage.m_Id == handlerMessage.m_Id); - BOOST_CHECK(bufferMessage.m_ArgTypes.size() == handlerMessage.m_ArgTypes.size()); + CHECK(bufferMessage.m_ArgTypes.size() == handlerMessage.m_ArgTypes.size()); for(uint32_t i = 0; i < bufferMessage.m_ArgTypes.size(); ++i) { - BOOST_CHECK(bufferMessage.m_ArgTypes[i] == handlerMessage.m_ArgTypes[i]); + CHECK(bufferMessage.m_ArgTypes[i] == handlerMessage.m_ArgTypes[i]); } - BOOST_CHECK(bufferMessage.m_ArgNames.size() == handlerMessage.m_ArgNames.size()); + CHECK(bufferMessage.m_ArgNames.size() == handlerMessage.m_ArgNames.size()); for(uint32_t i = 0; i < bufferMessage.m_ArgNames.size(); ++i) { - BOOST_CHECK(bufferMessage.m_ArgNames[i] == handlerMessage.m_ArgNames[i]); + CHECK(bufferMessage.m_ArgNames[i] == handlerMessage.m_ArgNames[i]); } } } -BOOST_AUTO_TEST_CASE(TimelineCaptureTest) +TEST_CASE("TimelineCaptureTest") { armnn::profiling::BufferManager bufferManager(50); armnn::profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -163,11 +162,11 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest) armnn::profiling::ThreadIdSize); using Status = arm::pipe::ITimelineDecoder::TimelineStatus; - BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetEventClassCallback(PushEventClass) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetEventCallback(PushEvent) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetLabelCallback(PushLabel) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetRelationshipCallback(PushRelationship) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetEventClassCallback(PushEventClass) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetEventCallback(PushEvent) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetLabelCallback(PushLabel) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetRelationshipCallback(PushRelationship) == Status::TimelineStatus_Success); const uint64_t entityGuid = 111111u; const uint64_t eventClassGuid = 22222u; @@ -241,26 +240,26 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest) for (unsigned long i = 0; i < 10; ++i) { - BOOST_CHECK(model.m_Entities[i].m_Guid == entityGuid); + CHECK(model.m_Entities[i].m_Guid == entityGuid); - BOOST_CHECK(model.m_EventClasses[i].m_Guid == eventClassGuid); + CHECK(model.m_EventClasses[i].m_Guid == eventClassGuid); - BOOST_CHECK(model.m_Events[i].m_TimeStamp == timestamp); - BOOST_CHECK(model.m_Events[i].m_ThreadId == uint64ThreadId); - BOOST_CHECK(model.m_Events[i].m_Guid == eventGuid); + CHECK(model.m_Events[i].m_TimeStamp == timestamp); + CHECK(model.m_Events[i].m_ThreadId == uint64ThreadId); + CHECK(model.m_Events[i].m_Guid == eventGuid); - BOOST_CHECK(model.m_Labels[i].m_Guid == labelGuid); - BOOST_CHECK(model.m_Labels[i].m_Name == labelName); + CHECK(model.m_Labels[i].m_Guid == labelGuid); + CHECK(model.m_Labels[i].m_Name == labelName); - BOOST_CHECK(model.m_Relationships[i].m_RelationshipType == + CHECK(model.m_Relationships[i].m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::DataLink); - BOOST_CHECK(model.m_Relationships[i].m_Guid == relationshipGuid); - BOOST_CHECK(model.m_Relationships[i].m_HeadGuid == headGuid); - BOOST_CHECK(model.m_Relationships[i].m_TailGuid == tailGuid); + CHECK(model.m_Relationships[i].m_Guid == relationshipGuid); + CHECK(model.m_Relationships[i].m_HeadGuid == headGuid); + CHECK(model.m_Relationships[i].m_TailGuid == tailGuid); } } -BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer) +TEST_CASE("TimelineCaptureTestMultipleStringsInBuffer") { armnn::profiling::BufferManager bufferManager(50); armnn::profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -278,11 +277,11 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer) armnn::profiling::ThreadIdSize); using Status = arm::pipe::TimelineDecoder::TimelineStatus; - BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetEventClassCallback(PushEventClass) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetEventCallback(PushEvent) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetLabelCallback(PushLabel) == Status::TimelineStatus_Success); - BOOST_CHECK(timelineDecoder.SetRelationshipCallback(PushRelationship) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetEventClassCallback(PushEventClass) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetEventCallback(PushEvent) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetLabelCallback(PushLabel) == Status::TimelineStatus_Success); + CHECK(timelineDecoder.SetRelationshipCallback(PushRelationship) == Status::TimelineStatus_Success); const uint64_t entityGuid = 111111u; const uint64_t eventClassGuid = 22222u; @@ -346,28 +345,28 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer) for ( unsigned long i = 0; i < 9; ++i ) { - BOOST_CHECK(model.m_Entities[i].m_Guid == entityGuid); + CHECK(model.m_Entities[i].m_Guid == entityGuid); - BOOST_CHECK(model.m_EventClasses[i].m_Guid == eventClassGuid); + CHECK(model.m_EventClasses[i].m_Guid == eventClassGuid); - BOOST_CHECK(model.m_Labels[i].m_Guid == labelGuid); + CHECK(model.m_Labels[i].m_Guid == labelGuid); - BOOST_CHECK(model.m_Events[i].m_TimeStamp == timestamp); - BOOST_CHECK(model.m_Events[i].m_ThreadId == uint64ThreadId); - BOOST_CHECK(model.m_Events[i].m_Guid == eventGuid); + CHECK(model.m_Events[i].m_TimeStamp == timestamp); + CHECK(model.m_Events[i].m_ThreadId == uint64ThreadId); + CHECK(model.m_Events[i].m_Guid == eventGuid); - BOOST_CHECK(model.m_Relationships[i].m_RelationshipType == + CHECK(model.m_Relationships[i].m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::DataLink); - BOOST_CHECK(model.m_Relationships[i].m_Guid == relationshipGuid); - BOOST_CHECK(model.m_Relationships[i].m_HeadGuid == headGuid); - BOOST_CHECK(model.m_Relationships[i].m_TailGuid == tailGuid); + CHECK(model.m_Relationships[i].m_Guid == relationshipGuid); + CHECK(model.m_Relationships[i].m_HeadGuid == headGuid); + CHECK(model.m_Relationships[i].m_TailGuid == tailGuid); } for ( unsigned long i = 0; i < 9; i += 3 ) { - BOOST_CHECK(model.m_Labels[i].m_Name == labelName); - BOOST_CHECK(model.m_Labels[i+1].m_Name == labelName2); - BOOST_CHECK(model.m_Labels[i+2].m_Name == labelName3); + CHECK(model.m_Labels[i].m_Name == labelName); + CHECK(model.m_Labels[i+1].m_Name == labelName2); + CHECK(model.m_Labels[i+2].m_Name == labelName3); } } -BOOST_AUTO_TEST_SUITE_END() +} -- cgit v1.2.1