aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/test/TimelinePacketTests.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-11-04 14:05:28 +0000
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-11-05 15:34:21 +0000
commit378bbfc0d7e97f7e63dc7e39117751a5ac3f21fe (patch)
tree84567dc58b1c7776adce48008db0f27a3420c0c5 /src/profiling/test/TimelinePacketTests.cpp
parent2ffcc4179648bbd6fb08342969391a2bcd027221 (diff)
downloadarmnn-378bbfc0d7e97f7e63dc7e39117751a5ac3f21fe.tar.gz
IVGCVSW-4065 Use platform-specific thread id size in Timeline packets
* Using std::thread::id as a general data type for thread id * Added new profiling util functions for reading/writing a thread id to/from a buffer * Fixed code and unit tests accordingly Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I1aaa3bdb740c8a97010f655b1e9f7581b52e7aff
Diffstat (limited to 'src/profiling/test/TimelinePacketTests.cpp')
-rw-r--r--src/profiling/test/TimelinePacketTests.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp
index a9ba516e53..6a8aa85fc0 100644
--- a/src/profiling/test/TimelinePacketTests.cpp
+++ b/src/profiling/test/TimelinePacketTests.cpp
@@ -790,7 +790,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventClassTest4)
BOOST_AUTO_TEST_CASE(TimelineEventPacketTest1)
{
const uint64_t timestamp = 456789u;
- const uint32_t threadId = 654321u;
+ const std::thread::id threadId = std::this_thread::get_id();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp,
@@ -808,7 +808,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest2)
std::vector<unsigned char> buffer(512, 0);
const uint64_t timestamp = 456789u;
- const uint32_t threadId = 654321u;
+ const std::thread::id threadId = std::this_thread::get_id();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp,
@@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest3)
std::vector<unsigned char> buffer(10, 0);
const uint64_t timestamp = 456789u;
- const uint32_t threadId = 654321u;
+ const std::thread::id threadId = std::this_thread::get_id();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp,
@@ -844,7 +844,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4)
std::vector<unsigned char> buffer(512, 0);
const uint64_t timestamp = 456789u;
- const uint32_t threadId = 654321u;
+ const std::thread::id threadId = std::this_thread::get_id();
const uint64_t profilingGuid = 123456u;
unsigned int numberOfBytesWritten = 789u;
TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp,
@@ -854,10 +854,11 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4)
boost::numeric_cast<unsigned int>(buffer.size()),
numberOfBytesWritten);
BOOST_CHECK(result == TimelinePacketStatus::Ok);
- BOOST_CHECK(numberOfBytesWritten == 32);
+ BOOST_CHECK(numberOfBytesWritten == 36);
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;
@@ -876,7 +877,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4)
uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
BOOST_CHECK(sequenceNumbered == 0);
- BOOST_CHECK(dataLength == 24);
+ BOOST_CHECK(dataLength == 28);
// Check the decl_id
offset += uint32_t_size;
@@ -890,11 +891,12 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4)
// Check the thread id
offset += uint64_t_size;
- uint32_t readThreadId = ReadUint32(buffer.data(), offset);
+ std::vector<uint8_t> readThreadId(threadId_size, 0);
+ ReadBytes(buffer.data(), offset, threadId_size, readThreadId.data());
BOOST_CHECK(readThreadId == threadId);
// Check the profiling GUID
- offset += uint32_t_size;
+ offset += threadId_size;
uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
BOOST_CHECK(readProfilingGuid == profilingGuid);
}