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 +++++++++++----------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'profiling/server/src/basePipeServer/tests') 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 -- cgit v1.2.1