From 5bb3d8a1edeab3f4fdbeb9baf7922cc52bd815fb Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Tue, 12 May 2020 16:36:46 +0100 Subject: 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 Change-Id: I836ab1a77ed13f774e66fd7b425923c24b9a6dab --- src/timelineDecoder/tests/TimelineTests.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/timelineDecoder/tests') diff --git a/src/timelineDecoder/tests/TimelineTests.cpp b/src/timelineDecoder/tests/TimelineTests.cpp index 1f55515758..bff25367fd 100644 --- a/src/timelineDecoder/tests/TimelineTests.cpp +++ b/src/timelineDecoder/tests/TimelineTests.cpp @@ -73,7 +73,6 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) uint32_t uint8_t_size = sizeof(uint8_t); uint32_t uint32_t_size = sizeof(uint32_t); uint32_t uint64_t_size = sizeof(uint64_t); - uint32_t threadId_size = sizeof(std::thread::id); profiling::BufferManager bufferManager(5); profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -107,7 +106,7 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) BOOST_CHECK(readPointerBytes == uint64_t_size); offset += uint8_t_size; uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readThreadIdBytes == threadId_size); + BOOST_CHECK(readThreadIdBytes == armnn::profiling::ThreadIdSize); offset += uint8_t_size; uint32_t declarationSize = profiling::ReadUint32(packetBuffer, offset); @@ -144,7 +143,6 @@ BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) BOOST_AUTO_TEST_CASE(TimelineCaptureTest) { - unsigned int threadIdSize = sizeof(std::thread::id); profiling::BufferManager bufferManager(50); profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -158,7 +156,8 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest) TimelineCaptureCommandHandler timelineCaptureCommandHandler( - 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder, threadIdSize); + 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder, + armnn::profiling::ThreadIdSize); using Status = ITimelineDecoder::TimelineStatus; BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success); @@ -175,16 +174,16 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest) const std::thread::id threadId = std::this_thread::get_id(); // need to do a bit of work here to extract the value from threadId - unsigned char* uCharThreadId = new unsigned char[threadIdSize]();; + unsigned char* uCharThreadId = new unsigned char[armnn::profiling::ThreadIdSize]();; uint64_t uint64ThreadId; - profiling::WriteBytes(uCharThreadId, 0, &threadId, threadIdSize); + profiling::WriteBytes(uCharThreadId, 0, &threadId, armnn::profiling::ThreadIdSize); - if (threadIdSize == 4) + if (armnn::profiling::ThreadIdSize == 4) { uint64ThreadId = profiling::ReadUint32(uCharThreadId, 0); } - else if (threadIdSize == 8) + else if (armnn::profiling::ThreadIdSize == 8) { uint64ThreadId = profiling::ReadUint64(uCharThreadId, 0); } @@ -256,7 +255,6 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTest) BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer) { - unsigned int threadIdSize = sizeof(std::thread::id); profiling::BufferManager bufferManager(50); profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -269,7 +267,8 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer) const TimelineDecoder::Model& model = timelineDecoder.GetModel(); TimelineCaptureCommandHandler timelineCaptureCommandHandler( - 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder, threadIdSize); + 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder, + armnn::profiling::ThreadIdSize); using Status = ITimelineDecoder::TimelineStatus; BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == Status::TimelineStatus_Success); @@ -286,15 +285,16 @@ BOOST_AUTO_TEST_CASE(TimelineCaptureTestMultipleStringsInBuffer) const std::thread::id threadId = std::this_thread::get_id(); // need to do a bit of work here to extract the value from threadId - unsigned char* uCharThreadId = new unsigned char[threadIdSize]();; + unsigned char* uCharThreadId = new unsigned char[armnn::profiling::ThreadIdSize](); uint64_t uint64ThreadId; - profiling::WriteBytes(uCharThreadId, 0, &threadId, threadIdSize); + profiling::WriteBytes(uCharThreadId, 0, &threadId, armnn::profiling::ThreadIdSize); - if ( threadIdSize == 4 ) + if ( armnn::profiling::ThreadIdSize == 4 ) { uint64ThreadId = profiling::ReadUint32(uCharThreadId, 0); - } else if ( threadIdSize == 8 ) + } + else if ( armnn::profiling::ThreadIdSize == 8 ) { uint64ThreadId = profiling::ReadUint64(uCharThreadId, 0); } -- cgit v1.2.1