diff options
author | Colm Donelan <Colm.Donelan@arm.com> | 2020-05-12 16:36:46 +0100 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-05-13 06:57:07 +0000 |
commit | 5bb3d8a1edeab3f4fdbeb9baf7922cc52bd815fb (patch) | |
tree | dde9b2ebeeccb81e089d1f4281dfbc3092bd626b /src/profiling/test | |
parent | 0c8cb99db6dd8b1ea073ef7227b2872a3cb0b269 (diff) | |
download | armnn-5bb3d8a1edeab3f4fdbeb9baf7922cc52bd815fb.tar.gz |
IVGCVSW-4775 Centralizing definition of ThreadIdSize to fix MLCE-189
* Introduce a constant definition of the size of a POSIX thread ID.
* Update all code to use the new constant definition.
* Update all unit tests to use the new constant definition.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I836ab1a77ed13f774e66fd7b425923c24b9a6dab
Diffstat (limited to 'src/profiling/test')
-rw-r--r-- | src/profiling/test/ProfilingTestUtils.cpp | 12 | ||||
-rw-r--r-- | src/profiling/test/SendTimelinePacketTests.cpp | 12 | ||||
-rw-r--r-- | src/profiling/test/TimelinePacketTests.cpp | 13 | ||||
-rw-r--r-- | src/profiling/test/TimelineUtilityMethodsTests.cpp | 6 |
4 files changed, 18 insertions, 25 deletions
diff --git a/src/profiling/test/ProfilingTestUtils.cpp b/src/profiling/test/ProfilingTestUtils.cpp index c1386820e8..73dbf881b3 100644 --- a/src/profiling/test/ProfilingTestUtils.cpp +++ b/src/profiling/test/ProfilingTestUtils.cpp @@ -263,7 +263,6 @@ void VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp, // Utils unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - unsigned int threadId_size = sizeof(std::thread::id); // Reading TimelineEventBinaryPacket // Check the decl_id @@ -284,8 +283,8 @@ void VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp, // Check the thread id offset += uint64_t_size; - std::vector<uint8_t> readThreadId(threadId_size, 0); - ReadBytes(readableData, offset, threadId_size, readThreadId.data()); + std::vector<uint8_t> readThreadId(ThreadIdSize, 0); + ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data()); if (threadId.has_value()) { BOOST_CHECK(readThreadId == threadId.value()); @@ -296,7 +295,7 @@ void VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp, } // Check the event GUID - offset += threadId_size; + offset += ThreadIdSize; uint64_t readEventGuid = ReadUint64(readableData, offset); if (eventGuid.has_value()) { @@ -936,8 +935,7 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) // Validate inference data size = inferenceReadableBuffer->GetSize(); - unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent - BOOST_CHECK(size == 1516 + 10 * threadId_size); + BOOST_CHECK(size == 1516 + 10 * ThreadIdSize); readableData = inferenceReadableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); @@ -945,7 +943,7 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) offset = 0; // Verify Header - VerifyTimelineHeaderBinary(readableData, offset, 1508 + 10 * threadId_size); + VerifyTimelineHeaderBinary(readableData, offset, 1508 + 10 * ThreadIdSize); // Inference timeline trace // Inference entity diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp index 4a13ebf824..6d5bf490a8 100644 --- a/src/profiling/test/SendTimelinePacketTests.cpp +++ b/src/profiling/test/SendTimelinePacketTests.cpp @@ -35,7 +35,6 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) unsigned int uint8_t_size = sizeof(uint8_t); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - unsigned int threadId_size = sizeof(std::thread::id); // Check the packet header unsigned int offset = 0; @@ -65,7 +64,7 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(readPointerBytes == uint64_t_size); offset += uint8_t_size; uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readThreadIdBytes == threadId_size); + BOOST_CHECK(readThreadIdBytes == ThreadIdSize); offset += uint8_t_size; uint32_t DeclCount = ReadUint32(packetBuffer, offset); @@ -211,7 +210,6 @@ 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); // Is platform dependent MockBufferManager bufferManager(512); TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -338,7 +336,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 == 20 + threadId_size); + BOOST_CHECK(eventBinaryPacketDataLength == 20 + ThreadIdSize); // Check the decl_id offset += uint32_t_size; @@ -352,12 +350,12 @@ BOOST_AUTO_TEST_CASE(SendEventClassAfterTimelineEntityPacketTest) // Check the thread id offset += uint64_t_size; - std::vector<uint8_t> readThreadId(threadId_size, 0); - ReadBytes(packetBuffer, offset, threadId_size, readThreadId.data()); + std::vector<uint8_t> readThreadId(ThreadIdSize, 0); + ReadBytes(packetBuffer, offset, ThreadIdSize, readThreadId.data()); BOOST_CHECK(readThreadId == threadId); // Check the profiling GUID - offset += threadId_size; + offset += ThreadIdSize; readProfilingGuid = ReadUint64(packetBuffer, offset); BOOST_CHECK(readProfilingGuid == eventProfilingGuid); } diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp index 5401712205..e57ed2a652 100644 --- a/src/profiling/test/TimelinePacketTests.cpp +++ b/src/profiling/test/TimelinePacketTests.cpp @@ -429,7 +429,6 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) unsigned int uint8_t_size = sizeof(uint8_t); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - unsigned int threadId_size = sizeof(std::thread::id); // Check the packet header unsigned int offset = 0; @@ -459,7 +458,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) BOOST_CHECK(readPointerBytes == uint64_t_size); offset += uint8_t_size; uint8_t readThreadIdBytes = ReadUint8(buffer.data(), offset); - BOOST_CHECK(readThreadIdBytes == threadId_size); + BOOST_CHECK(readThreadIdBytes == ThreadIdSize); // Check the number of declarations offset += uint8_t_size; @@ -742,9 +741,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData) unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent - - BOOST_CHECK(numberOfBytesWritten == 20 + threadId_size); + BOOST_CHECK(numberOfBytesWritten == 20 + ThreadIdSize); unsigned int offset = 0; // Check the decl_id @@ -758,12 +755,12 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData) // Check the thread id offset += uint64_t_size; - std::vector<uint8_t> readThreadId(threadId_size, 0); - ReadBytes(buffer.data(), offset, threadId_size, readThreadId.data()); + std::vector<uint8_t> readThreadId(ThreadIdSize, 0); + ReadBytes(buffer.data(), offset, ThreadIdSize, readThreadId.data()); BOOST_CHECK(readThreadId == threadId); // Check the profiling GUID - offset += threadId_size; + offset += ThreadIdSize; uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset); BOOST_CHECK(readProfilingGuid == profilingGuid); } diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp index caffcc74b0..388d38acc4 100644 --- a/src/profiling/test/TimelineUtilityMethodsTests.cpp +++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp @@ -429,8 +429,8 @@ BOOST_AUTO_TEST_CASE(RecordEventTest) auto readableBuffer = mockBufferManager.GetReadableBuffer(); BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - unsigned int threadId_size = sizeof(std::thread::id); // Is platform dependent - BOOST_CHECK(size == 92 + threadId_size); + + BOOST_CHECK(size == 92 + ThreadIdSize); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); @@ -439,7 +439,7 @@ BOOST_AUTO_TEST_CASE(RecordEventTest) unsigned int offset = 0; // Verify Header - VerifyTimelineHeaderBinary(readableData, offset, 84 + threadId_size); + VerifyTimelineHeaderBinary(readableData, offset, 84 + ThreadIdSize); // First dataset sent: TimelineEntityBinaryPacket VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |