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 --- .../basePipeServer/tests/BasePipeServerTests.cpp | 52 +++++----- .../src/timelineDecoder/tests/TimelineTests.cpp | 105 ++++++++++----------- 2 files changed, 77 insertions(+), 80 deletions(-) (limited to 'profiling') diff --git a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp index 091792782f..f307d98668 100644 --- a/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp +++ b/profiling/server/src/basePipeServer/tests/BasePipeServerTests.cpp @@ -8,37 +8,35 @@ #include #include -#include -#include - - -BOOST_AUTO_TEST_SUITE(BasePipeServerTests) +#include +TEST_SUITE("BasePipeServerTests") +{ using namespace armnn; using namespace arm::pipe; -BOOST_AUTO_TEST_CASE(BasePipeServerTest) +TEST_CASE("BasePipeServerTest") { // Setup the mock service to bind to the UDS. std::string udsNamespace = "gatord_namespace"; // Try to initialize a listening socket through the ConnectionHandler - BOOST_CHECK_NO_THROW(ConnectionHandler connectionHandler(udsNamespace, true)); + CHECK_NOTHROW(ConnectionHandler connectionHandler(udsNamespace, true)); - // The socket should close once we leave the scope of BOOST_CHECK_NO_THROW + // The socket should close once we leave the scope of CHECK_NOTHROW // and socketProfilingConnection should fail to connect - BOOST_CHECK_THROW(profiling::SocketProfilingConnection socketProfilingConnection, + CHECK_THROWS_AS(profiling::SocketProfilingConnection socketProfilingConnection, arm::pipe::SocketConnectionException); // Try to initialize a listening socket through the ConnectionHandler again ConnectionHandler connectionHandler(udsNamespace, true); // socketProfilingConnection should connect now profiling::SocketProfilingConnection socketProfilingConnection; - BOOST_TEST(socketProfilingConnection.IsOpen()); + CHECK(socketProfilingConnection.IsOpen()); auto basePipeServer = connectionHandler.GetNewBasePipeServer(false); // GetNewBasePipeServer will return null if it fails to create a socket - BOOST_TEST(basePipeServer.get()); + CHECK(basePipeServer.get()); profiling::BufferManager bufferManager; profiling::SendCounterPacket sendCounterPacket(bufferManager); @@ -50,15 +48,15 @@ BOOST_AUTO_TEST_CASE(BasePipeServerTest) const unsigned char* readBuffer = packetBuffer->GetReadableData(); unsigned int readBufferSize = packetBuffer->GetSize(); - BOOST_TEST(readBuffer); - BOOST_TEST(readBufferSize > 0u); + CHECK(readBuffer); + CHECK(readBufferSize > 0u); socketProfilingConnection.WritePacket(readBuffer,readBufferSize); bufferManager.MarkRead(packetBuffer); - BOOST_TEST(basePipeServer.get()->WaitForStreamMetaData()); - BOOST_TEST(basePipeServer.get()->GetStreamMetadataPid() == armnnUtils::Processes::GetCurrentId()); - BOOST_TEST(basePipeServer.get()->GetStreamMetadataMaxDataLen() == MAX_METADATA_PACKET_LENGTH); + CHECK(basePipeServer.get()->WaitForStreamMetaData()); + CHECK(basePipeServer.get()->GetStreamMetadataPid() == armnnUtils::Processes::GetCurrentId()); + CHECK(basePipeServer.get()->GetStreamMetadataMaxDataLen() == MAX_METADATA_PACKET_LENGTH); // Now try a simple PeriodicCounterSelectionPacket sendCounterPacket.SendPeriodicCounterSelectionPacket(50, {1,2,3,4,5}); @@ -67,18 +65,18 @@ BOOST_AUTO_TEST_CASE(BasePipeServerTest) readBuffer = packetBuffer->GetReadableData(); readBufferSize = packetBuffer->GetSize(); - BOOST_TEST(readBuffer); - BOOST_TEST(readBufferSize > 0u); + CHECK(readBuffer); + CHECK(readBufferSize > 0u); socketProfilingConnection.WritePacket(readBuffer,readBufferSize); bufferManager.MarkRead(packetBuffer); auto packet1 = basePipeServer.get()->WaitForPacket(500); - BOOST_TEST(!packet1.IsEmpty()); - BOOST_TEST(packet1.GetPacketFamily() == 0); - BOOST_TEST(packet1.GetPacketId() == 4); - BOOST_TEST(packet1.GetLength() == 14); + CHECK(!packet1.IsEmpty()); + CHECK(packet1.GetPacketFamily() == 0); + CHECK(packet1.GetPacketId() == 4); + CHECK(packet1.GetLength() == 14); // Try and send the packet back to the client basePipeServer.get()->SendPacket(packet1.GetPacketFamily(), @@ -88,12 +86,12 @@ BOOST_AUTO_TEST_CASE(BasePipeServerTest) auto packet2 = socketProfilingConnection.ReadPacket(500); - BOOST_TEST(!packet2.IsEmpty()); - BOOST_TEST(packet2.GetPacketFamily() == 0); - BOOST_TEST(packet2.GetPacketId() == 4); - BOOST_TEST(packet2.GetLength() == 14); + CHECK(!packet2.IsEmpty()); + CHECK(packet2.GetPacketFamily() == 0); + CHECK(packet2.GetPacketId() == 4); + CHECK(packet2.GetLength() == 14); socketProfilingConnection.Close(); } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +} \ No newline at end of file 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