IVGCVSW-4526 Fix UnitTest errors when running on raspberry pi
authorJan Eilers <jan.eilers@arm.com>
Thu, 26 Mar 2020 12:04:54 +0000 (12:04 +0000)
committerJan Eilers <jan.eilers@arm.com>
Thu, 26 Mar 2020 12:04:54 +0000 (12:04 +0000)
* The std::thread::id is included in some timeline packages of the
profiler. But the size of thread::id is platform dependent. That's why
some tests expected a wrong package size

Signed-off-by: Jan Eilers <jan.eilers@arm.com>
Change-Id: I4794ebbdda2d75ed5be7112f6a3bf2e5f14f221b

src/armnn/test/RuntimeTests.cpp
src/profiling/test/ProfilingTestUtils.cpp
src/profiling/test/ProfilingTests.cpp
src/profiling/test/SendTimelinePacketTests.cpp
src/profiling/test/TimelinePacketTests.cpp
src/profiling/test/TimelineUtilityMethodsTests.cpp

index eca4bf8..c115023 100644 (file)
@@ -828,7 +828,8 @@ BOOST_AUTO_TEST_CASE(ProfilingEnableCpuRef)
 
     // Validate inference data
     size = inferenceReadableBuffer->GetSize();
-    BOOST_CHECK(size == 1272);
+    unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent
+    BOOST_CHECK(size == 1208 + 8 * threadId_size);
 
     readableData = inferenceReadableBuffer->GetReadableData();
     BOOST_CHECK(readableData != nullptr);
@@ -836,7 +837,7 @@ BOOST_AUTO_TEST_CASE(ProfilingEnableCpuRef)
     offset = 0;
 
     // Verify Header
-    VerifyTimelineHeaderBinary(readableData, offset, 1264);
+    VerifyTimelineHeaderBinary(readableData, offset, 1200 + 8 * threadId_size);
 
     // Inference timeline trace
     // Inference entity
index 74e140c..244051c 100644 (file)
@@ -909,7 +909,9 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
 
     // Validate inference data
     size = inferenceReadableBuffer->GetSize();
-    BOOST_CHECK(size == 1596);
+
+    unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent
+    BOOST_CHECK(size == 1516 + 10 * threadId_size);
 
     readableData = inferenceReadableBuffer->GetReadableData();
     BOOST_CHECK(readableData != nullptr);
@@ -917,7 +919,7 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
     offset = 0;
 
     // Verify Header
-    VerifyTimelineHeaderBinary(readableData, offset, 1588);
+    VerifyTimelineHeaderBinary(readableData, offset, 1508 + 10 * threadId_size);
 
     // Inference timeline trace
     // Inference entity
index a631cb2..74b93d7 100644 (file)
@@ -692,7 +692,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues)
     ProfilingService* profilingServicePtr = &profilingService;
     std::vector<std::thread> writers;
 
-    for (int i = 0; i < 100; ++i)
+    for (int i = 0; i < 10; ++i)
     {
         // Increment and decrement the first counter
         writers.push_back(std::thread(&ProfilingService::IncrementCounterValue,
@@ -719,7 +719,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterValues)
     BOOST_CHECK(counterValue ==
                (profilingService.GetCounterValue(armnn::profiling::UNREGISTERED_BACKENDS)
                - profilingService.GetCounterValue(armnn::profiling::REGISTERED_BACKENDS)));
-    BOOST_CHECK(profilingService.GetCounterValue(armnn::profiling::INFERENCES_RUN) == 500);
+    BOOST_CHECK(profilingService.GetCounterValue(armnn::profiling::INFERENCES_RUN) == 50);
 
     BOOST_CHECK_NO_THROW(profilingService.SetCounterValue(armnn::profiling::UNREGISTERED_BACKENDS, 4));
     BOOST_CHECK_NO_THROW(counterValue = profilingService.GetCounterValue(armnn::profiling::UNREGISTERED_BACKENDS));
index c03e745..98b161f 100644 (file)
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(SendEventClassAfterTimelineEntityPacketTest)
 {
     unsigned int uint32_t_size = sizeof(uint32_t);
     unsigned int uint64_t_size = sizeof(uint64_t);
-    unsigned int threadId_size = sizeof(std::thread::id);
+    unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent
 
     MockBufferManager bufferManager(512);
     TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
@@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(SendEventClassAfterTimelineEntityPacketTest)
     uint32_t eventBinaryPacketSequenceNumbered = (eventBinaryPacketHeaderWord1 >> 24) & 0x00000001;
     uint32_t eventBinaryPacketDataLength       = (eventBinaryPacketHeaderWord1 >>  0) & 0x00FFFFFF;
     BOOST_CHECK(eventBinaryPacketSequenceNumbered == 0);
-    BOOST_CHECK(eventBinaryPacketDataLength       == 28);
+    BOOST_CHECK(eventBinaryPacketDataLength == 20 + threadId_size);
 
     // Check the decl_id
     offset += uint32_t_size;
index 1d5d451..5401712 100644 (file)
@@ -739,11 +739,12 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData)
                                                            boost::numeric_cast<unsigned int>(buffer.size()),
                                                            numberOfBytesWritten);
     BOOST_CHECK(result == TimelinePacketStatus::Ok);
-    BOOST_CHECK(numberOfBytesWritten == 28);
 
     unsigned int uint32_t_size = sizeof(uint32_t);
     unsigned int uint64_t_size = sizeof(uint64_t);
-    unsigned int threadId_size = sizeof(std::thread::id);
+    unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent
+
+    BOOST_CHECK(numberOfBytesWritten == 20 + threadId_size);
 
     unsigned int offset = 0;
     // Check the decl_id
index 43a5b0a..caffcc7 100644 (file)
@@ -429,7 +429,9 @@ BOOST_AUTO_TEST_CASE(RecordEventTest)
     auto readableBuffer = mockBufferManager.GetReadableBuffer();
     BOOST_CHECK(readableBuffer != nullptr);
     unsigned int size = readableBuffer->GetSize();
-    BOOST_CHECK(size == 100);
+    unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent
+    BOOST_CHECK(size == 92 + threadId_size);
+
     const unsigned char* readableData = readableBuffer->GetReadableData();
     BOOST_CHECK(readableData != nullptr);
 
@@ -437,7 +439,7 @@ BOOST_AUTO_TEST_CASE(RecordEventTest)
     unsigned int offset = 0;
 
     // Verify Header
-    VerifyTimelineHeaderBinary(readableData, offset, 92);
+    VerifyTimelineHeaderBinary(readableData, offset, 84 + threadId_size);
 
     // First dataset sent: TimelineEntityBinaryPacket
     VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);