blob: 71c6915a8ccd949a221bfd6ebe436086bd5979a1 [file] [log] [blame]
Matteo Martincigh0aed4f92019-10-01 14:25:34 +01001//
Jim Flynn6398a982020-05-27 17:05:21 +01002// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
Matteo Martincigh0aed4f92019-10-01 14:25:34 +01003// SPDX-License-Identifier: MIT
4//
5
Jim Flynn1fdeb992020-07-09 07:28:37 +01006#include <Threads.hpp>
Matteo Martincigh0aed4f92019-10-01 14:25:34 +01007#include <ProfilingUtils.hpp>
8
9#include <boost/test/unit_test.hpp>
10#include <boost/numeric/conversion/cast.hpp>
11
12using namespace armnn::profiling;
13
14BOOST_AUTO_TEST_SUITE(TimelinePacketTests)
15
Keith Davis97da5e22020-03-05 16:25:28 +000016BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestNoBuffer)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010017{
18 const uint64_t profilingGuid = 123456u;
19 const std::string label = "some label";
20 unsigned int numberOfBytesWritten = 789u;
21 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
22 label,
23 nullptr,
24 512u,
25 numberOfBytesWritten);
26 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
27 BOOST_CHECK(numberOfBytesWritten == 0);
28}
29
Keith Davis97da5e22020-03-05 16:25:28 +000030BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionZeroValue)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010031{
32 std::vector<unsigned char> buffer(512, 0);
33
34 const uint64_t profilingGuid = 123456u;
35 const std::string label = "some label";
36 unsigned int numberOfBytesWritten = 789u;
37 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
38 label,
39 buffer.data(),
40 0,
41 numberOfBytesWritten);
42 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
43 BOOST_CHECK(numberOfBytesWritten == 0);
44}
45
Keith Davis97da5e22020-03-05 16:25:28 +000046BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionFixedValue)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010047{
48 std::vector<unsigned char> buffer(10, 0);
49
50 const uint64_t profilingGuid = 123456u;
51 const std::string label = "some label";
52 unsigned int numberOfBytesWritten = 789u;
53 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
54 label,
55 buffer.data(),
56 boost::numeric_cast<unsigned int>(buffer.size()),
57 numberOfBytesWritten);
58 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
59 BOOST_CHECK(numberOfBytesWritten == 0);
60}
61
Keith Davis97da5e22020-03-05 16:25:28 +000062BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestInvalidLabel)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010063{
64 std::vector<unsigned char> buffer(512, 0);
65
66 const uint64_t profilingGuid = 123456u;
67 const std::string label = "s0m€ l@b€l";
68 unsigned int numberOfBytesWritten = 789u;
69 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
70 label,
71 buffer.data(),
72 boost::numeric_cast<unsigned int>(buffer.size()),
73 numberOfBytesWritten);
74 BOOST_CHECK(result == TimelinePacketStatus::Error);
75 BOOST_CHECK(numberOfBytesWritten == 0);
76}
77
Keith Davis97da5e22020-03-05 16:25:28 +000078BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestSingleConstructionOfData)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010079{
80 std::vector<unsigned char> buffer(512, 0);
81
82 const uint64_t profilingGuid = 123456u;
83 const std::string label = "some label";
84 unsigned int numberOfBytesWritten = 789u;
85 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
86 label,
87 buffer.data(),
88 boost::numeric_cast<unsigned int>(buffer.size()),
89 numberOfBytesWritten);
90 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Keith Davis97da5e22020-03-05 16:25:28 +000091 BOOST_CHECK(numberOfBytesWritten == 28);
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010092
93 unsigned int uint32_t_size = sizeof(uint32_t);
94 unsigned int uint64_t_size = sizeof(uint64_t);
95
96 // Check the packet header
97 unsigned int offset = 0;
Jan Eilersb884ea42019-10-16 09:54:15 +010098 uint32_t decl_Id = ReadUint32(buffer.data(), offset);
99 BOOST_CHECK(decl_Id == uint32_t(0));
Matteo Martincigh0aed4f92019-10-01 14:25:34 +0100100
101 // Check the profiling GUID
102 offset += uint32_t_size;
103 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
104 BOOST_CHECK(readProfilingGuid == profilingGuid);
105
106 // Check the SWTrace label
107 offset += uint64_t_size;
108 uint32_t swTraceLabelLength = ReadUint32(buffer.data(), offset);
109 BOOST_CHECK(swTraceLabelLength == 11); // Label length including the null-terminator
110
111 offset += uint32_t_size;
112 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
113 label.data(), // The original label
114 swTraceLabelLength - 1) == 0); // The length of the label
115
116 offset += swTraceLabelLength * uint32_t_size;
117 BOOST_CHECK(buffer[offset] == '\0'); // The null-terminator at the end of the SWTrace label
118}
119
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100120BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketNullBufferTest)
121{
122 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
123 const uint64_t relationshipGuid = 123456u;
124 const uint64_t headGuid = 234567u;
125 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100126 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100127 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000128 TimelinePacketStatus result = WriteTimelineRelationshipBinary(relationshipType,
129 relationshipGuid,
130 headGuid,
131 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100132 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000133 nullptr,
134 512u,
135 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100136 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
137 BOOST_CHECK(numberOfBytesWritten == 0);
138}
139
140BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketZeroBufferSizeTest)
141{
142 std::vector<unsigned char> buffer(512, 0);
143
144 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
145 const uint64_t relationshipGuid = 123456u;
146 const uint64_t headGuid = 234567u;
147 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100148 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100149 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000150 TimelinePacketStatus result = WriteTimelineRelationshipBinary(relationshipType,
151 relationshipGuid,
152 headGuid,
153 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100154 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000155 buffer.data(),
156 0,
157 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100158 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
159 BOOST_CHECK(numberOfBytesWritten == 0);
160}
161
162BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketSmallBufferSizeTest)
163{
164 std::vector<unsigned char> buffer(10, 0);
165
166 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
167 const uint64_t relationshipGuid = 123456u;
168 const uint64_t headGuid = 234567u;
169 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100170 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100171 unsigned int numberOfBytesWritten = 789u;
172 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000173 WriteTimelineRelationshipBinary(relationshipType,
174 relationshipGuid,
175 headGuid,
176 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100177 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000178 buffer.data(),
179 boost::numeric_cast<unsigned int>(buffer.size()),
180 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100181 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
182 BOOST_CHECK(numberOfBytesWritten == 0);
183}
184
185BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketInvalidRelationTest)
186{
187 std::vector<unsigned char> buffer(512, 0);
188 ProfilingRelationshipType relationshipType = static_cast<ProfilingRelationshipType>(5);
189 const uint64_t relationshipGuid = 123456u;
190 const uint64_t headGuid = 234567u;
191 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100192 const uint64_t attributeGuid = 876345u;
193
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100194 unsigned int numberOfBytesWritten = 789u;
195
Keith Davis97da5e22020-03-05 16:25:28 +0000196 BOOST_CHECK_THROW(WriteTimelineRelationshipBinary(relationshipType,
197 relationshipGuid,
198 headGuid,
199 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100200 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000201 buffer.data(),
202 boost::numeric_cast<unsigned int>(buffer.size()),
203 numberOfBytesWritten),
204 armnn::InvalidArgumentException);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100205
206 BOOST_CHECK(numberOfBytesWritten == 0);
207}
208
Keith Davis97da5e22020-03-05 16:25:28 +0000209BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100210{
211 std::vector<unsigned char> buffer(512, 0);
212
213 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::RetentionLink;
214 const uint64_t relationshipGuid = 123456u;
215 const uint64_t headGuid = 234567u;
216 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100217 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100218 unsigned int numberOfBytesWritten = 789u;
219 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000220 WriteTimelineRelationshipBinary(relationshipType,
221 relationshipGuid,
222 headGuid,
223 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100224 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000225 buffer.data(),
226 boost::numeric_cast<unsigned int>(buffer.size()),
227 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100228 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100229 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100230
231 unsigned int uint32_t_size = sizeof(uint32_t);
232 unsigned int uint64_t_size = sizeof(uint64_t);
233
234 // Check the packet header
235 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100236 // Check the decl_id
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100237 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
238 BOOST_CHECK(readDeclId == 3);
239
240 // Check the relationship type
241 offset += uint32_t_size;
242 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
243 BOOST_CHECK(readRelationshipType == 0);
244
245 // Check the relationship GUID
246 offset += uint32_t_size;
247 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
248 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
249
250 // Check the head GUID
251 offset += uint64_t_size;
252 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
253 BOOST_CHECK(readHeadGuid == headGuid);
254
255 // Check the tail GUID
256 offset += uint64_t_size;
257 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
258 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100259
260 // Check the attribute GUID
261 offset += uint64_t_size;
262 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
263 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100264}
265
Keith Davis97da5e22020-03-05 16:25:28 +0000266BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100267{
268 std::vector<unsigned char> buffer(512, 0);
269
270 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::ExecutionLink;
271 const uint64_t relationshipGuid = 123456u;
272 const uint64_t headGuid = 234567u;
273 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100274 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100275 unsigned int numberOfBytesWritten = 789u;
276 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000277 WriteTimelineRelationshipBinary(relationshipType,
278 relationshipGuid,
279 headGuid,
280 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100281 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000282 buffer.data(),
283 boost::numeric_cast<unsigned int>(buffer.size()),
284 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100285 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100286 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100287
288 unsigned int uint32_t_size = sizeof(uint32_t);
289 unsigned int uint64_t_size = sizeof(uint64_t);
290
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100291 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100292 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
293 BOOST_CHECK(readDeclId == 3);
294
295 // Check the relationship type
296 offset += uint32_t_size;
297 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
298 BOOST_CHECK(readRelationshipType == 1);
299
300 // Check the relationship GUID
301 offset += uint32_t_size;
302 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
303 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
304
305 // Check the head GUID
306 offset += uint64_t_size;
307 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
308 BOOST_CHECK(readHeadGuid == headGuid);
309
310 // Check the tail GUID
311 offset += uint64_t_size;
312 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
313 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100314
315 // Check the attribute GUID
316 offset += uint64_t_size;
317 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
318 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100319}
320
321
Keith Davis97da5e22020-03-05 16:25:28 +0000322BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100323{
324 std::vector<unsigned char> buffer(512, 0);
325
326 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
327 const uint64_t relationshipGuid = 123456u;
328 const uint64_t headGuid = 234567u;
329 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100330 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100331 unsigned int numberOfBytesWritten = 789u;
332 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000333 WriteTimelineRelationshipBinary(relationshipType,
334 relationshipGuid,
335 headGuid,
336 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100337 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000338 buffer.data(),
339 boost::numeric_cast<unsigned int>(buffer.size()),
340 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100341 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100342 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100343
344 unsigned int uint32_t_size = sizeof(uint32_t);
345 unsigned int uint64_t_size = sizeof(uint64_t);
346
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100347 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100348 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
349 BOOST_CHECK(readDeclId == 3);
350
351 // Check the relationship type
352 offset += uint32_t_size;
353 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
354 BOOST_CHECK(readRelationshipType == 2);
355
356 // Check the relationship GUID
357 offset += uint32_t_size;
358 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
359 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
360
361 // Check the head GUID
362 offset += uint64_t_size;
363 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
364 BOOST_CHECK(readHeadGuid == headGuid);
365
366 // Check the tail GUID
367 offset += uint64_t_size;
368 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
369 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100370
371 // Check the attribute GUID
372 offset += uint64_t_size;
373 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
374 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100375}
376
377
Keith Davis97da5e22020-03-05 16:25:28 +0000378BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100379{
380 std::vector<unsigned char> buffer(512, 0);
381
382 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::LabelLink;
383 const uint64_t relationshipGuid = 123456u;
384 const uint64_t headGuid = 234567u;
385 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100386 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100387 unsigned int numberOfBytesWritten = 789u;
388 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000389 WriteTimelineRelationshipBinary(relationshipType,
390 relationshipGuid,
391 headGuid,
392 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100393 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000394 buffer.data(),
395 boost::numeric_cast<unsigned int>(buffer.size()),
396 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100397 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100398 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100399
400 unsigned int uint32_t_size = sizeof(uint32_t);
401 unsigned int uint64_t_size = sizeof(uint64_t);
402
403 // Check the packet header
404 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100405 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
406 BOOST_CHECK(readDeclId == 3);
407
408 // Check the relationship type
409 offset += uint32_t_size;
410 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
411 BOOST_CHECK(readRelationshipType == 3);
412
413 // Check the relationship GUID
414 offset += uint32_t_size;
415 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
416 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
417
418 // Check the head GUID
419 offset += uint64_t_size;
420 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
421 BOOST_CHECK(readHeadGuid == headGuid);
422
423 // Check the tail GUID
424 offset += uint64_t_size;
425 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
426 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100427
428 // Check the attribute GUID
429 offset += uint64_t_size;
430 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
431 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100432}
433
Keith Davis97da5e22020-03-05 16:25:28 +0000434BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestNoBuffer)
Sadik Armagan784db772019-10-08 15:05:38 +0100435{
436 unsigned int numberOfBytesWritten = 789u;
437 TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(nullptr,
438 512u,
439 numberOfBytesWritten);
440 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
441 BOOST_CHECK(numberOfBytesWritten == 0);
442}
443
Keith Davis97da5e22020-03-05 16:25:28 +0000444BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestBufferExhausted)
Sadik Armagan784db772019-10-08 15:05:38 +0100445{
446 std::vector<unsigned char> buffer(512, 0);
447
448 unsigned int numberOfBytesWritten = 789u;
449 TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(buffer.data(),
450 0,
451 numberOfBytesWritten);
452 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
453 BOOST_CHECK(numberOfBytesWritten == 0);
454}
455
Keith Davis97da5e22020-03-05 16:25:28 +0000456BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
Sadik Armagan784db772019-10-08 15:05:38 +0100457{
458 std::vector<unsigned char> buffer(512, 0);
459 unsigned int numberOfBytesWritten = 789u;
460 TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(buffer.data(),
461 boost::numeric_cast<unsigned int>(buffer.size()),
462 numberOfBytesWritten);
463 BOOST_CHECK(result == TimelinePacketStatus::Ok);
464
Jim Flynn6398a982020-05-27 17:05:21 +0100465 BOOST_CHECK(numberOfBytesWritten == 451);
Sadik Armagan784db772019-10-08 15:05:38 +0100466
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000467 unsigned int uint8_t_size = sizeof(uint8_t);
Sadik Armagan784db772019-10-08 15:05:38 +0100468 unsigned int uint32_t_size = sizeof(uint32_t);
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000469 unsigned int uint64_t_size = sizeof(uint64_t);
Sadik Armagan784db772019-10-08 15:05:38 +0100470
471 // Check the packet header
472 unsigned int offset = 0;
473 uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
474 uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
475 uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
476 uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
477 uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
478 BOOST_CHECK(packetFamily == 1);
479 BOOST_CHECK(packetClass == 0);
480 BOOST_CHECK(packetType == 0);
481 BOOST_CHECK(streamId == 0);
482
483 offset += uint32_t_size;
484 uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
485 uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
486 uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
487 BOOST_CHECK(sequenceNumbered == 0);
Jim Flynn6398a982020-05-27 17:05:21 +0100488 BOOST_CHECK(dataLength == 443);
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000489
490 // Check the stream header
491 offset += uint32_t_size;
492 uint8_t readStreamVersion = ReadUint8(buffer.data(), offset);
493 BOOST_CHECK(readStreamVersion == 4);
494 offset += uint8_t_size;
495 uint8_t readPointerBytes = ReadUint8(buffer.data(), offset);
496 BOOST_CHECK(readPointerBytes == uint64_t_size);
497 offset += uint8_t_size;
498 uint8_t readThreadIdBytes = ReadUint8(buffer.data(), offset);
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100499 BOOST_CHECK(readThreadIdBytes == ThreadIdSize);
Sadik Armagan784db772019-10-08 15:05:38 +0100500
Finn Williamse63a0262019-10-22 10:30:49 +0100501 // Check the number of declarations
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000502 offset += uint8_t_size;
Finn Williamse63a0262019-10-22 10:30:49 +0100503 uint32_t declCount = ReadUint32(buffer.data(), offset);
504 BOOST_CHECK(declCount == 5);
505
Sadik Armagan784db772019-10-08 15:05:38 +0100506 // Check the decl_id
507 offset += uint32_t_size;
508 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
509 BOOST_CHECK(readDeclId == 0);
510
511 // SWTrace "namestring" format
512 // length of the string (first 4 bytes) + string + null terminator
513
514 // Check the decl_name
515 offset += uint32_t_size;
516 uint32_t swTraceDeclNameLength = ReadUint32(buffer.data(), offset);
517 BOOST_CHECK(swTraceDeclNameLength == 13); // decl_name length including the null-terminator
518
519 std::string label = "declareLabel";
520 offset += uint32_t_size;
521 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000522 label.data(), // The original label
Sadik Armagan784db772019-10-08 15:05:38 +0100523 swTraceDeclNameLength - 1) == 0); // The length of the label
524
525 // Check the ui_name
526 std::vector<uint32_t> swTraceString;
527 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
528 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
529 uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset);
530 BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator
531
532 label = "declare label";
533 offset += uint32_t_size;
534 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
535 label.data(), // The original label
536 swTraceUINameLength - 1) == 0); // The length of the label
537
538 // Check arg_types
539 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
540 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
541 uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset);
542 BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator
543
544 label = "ps";
545 offset += uint32_t_size;
546 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
547 label.data(), // The original label
548 swTraceArgTypesLength - 1) == 0); // The length of the label
549
550 // Check arg_names
551 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
552 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
553 uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset);
554 BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator
555
556 label = "guid,value";
557 offset += uint32_t_size;
558 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
559 label.data(), // The original label
560 swTraceArgNamesLength - 1) == 0); // The length of the label
561
562 // Check second message decl_id
563 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
564 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
565 readDeclId = ReadUint32(buffer.data(), offset);
566 BOOST_CHECK(readDeclId == 1);
567
568 // Check second decl_name
569 offset += uint32_t_size;
570 swTraceDeclNameLength = ReadUint32(buffer.data(), offset);
571 BOOST_CHECK(swTraceDeclNameLength == 14); // decl_name length including the null-terminator
572
573 label = "declareEntity";
574 offset += uint32_t_size;
575 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
576 label.data(), // The original label
577 swTraceDeclNameLength - 1) == 0); // The length of the label
578}
579
Keith Davis97da5e22020-03-05 16:25:28 +0000580BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestNoBuffer)
David Monahanf21f6062019-10-07 15:11:15 +0100581{
582 const uint64_t profilingGuid = 123456u;
583 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000584 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
585 nullptr,
586 512u,
587 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100588 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
589 BOOST_CHECK(numberOfBytesWritten == 0);
590}
591
Keith Davis97da5e22020-03-05 16:25:28 +0000592BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithZeroBufferSize)
David Monahanf21f6062019-10-07 15:11:15 +0100593{
594 std::vector<unsigned char> buffer(512, 0);
595
596 const uint64_t profilingGuid = 123456u;
597 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000598 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
599 buffer.data(),
600 0,
601 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100602 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
603 BOOST_CHECK(numberOfBytesWritten == 0);
604}
605
Keith Davis97da5e22020-03-05 16:25:28 +0000606BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithFixedBufferSize)
David Monahanf21f6062019-10-07 15:11:15 +0100607{
608 std::vector<unsigned char> buffer(10, 0);
609
610 const uint64_t profilingGuid = 123456u;
611 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000612 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
613 buffer.data(),
614 boost::numeric_cast<unsigned int>(buffer.size()),
615 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100616 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
617 BOOST_CHECK(numberOfBytesWritten == 0);
618}
619
Keith Davis97da5e22020-03-05 16:25:28 +0000620BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestFullConstructionOfData)
David Monahanf21f6062019-10-07 15:11:15 +0100621{
622 std::vector<unsigned char> buffer(512, 0);
623
624 const uint64_t profilingGuid = 123456u;
625 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000626 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
627 buffer.data(),
628 boost::numeric_cast<unsigned int>(buffer.size()),
629 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100630 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Keith Davis97da5e22020-03-05 16:25:28 +0000631 BOOST_CHECK(numberOfBytesWritten == 12);
David Monahanf21f6062019-10-07 15:11:15 +0100632
633 unsigned int uint32_t_size = sizeof(uint32_t);
634
David Monahanf21f6062019-10-07 15:11:15 +0100635 unsigned int offset = 0;
Jan Eilersb884ea42019-10-16 09:54:15 +0100636 // Check decl_Id
Jan Eilersb884ea42019-10-16 09:54:15 +0100637 uint32_t decl_Id = ReadUint32(buffer.data(), offset);
638 BOOST_CHECK(decl_Id == uint32_t(1));
639
David Monahanf21f6062019-10-07 15:11:15 +0100640 // Check the profiling GUID
641 offset += uint32_t_size;
642 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
643 BOOST_CHECK(readProfilingGuid == profilingGuid);
644}
645
Keith Davis97da5e22020-03-05 16:25:28 +0000646BOOST_AUTO_TEST_CASE(TimelineEventClassTestNoBuffer)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100647{
648 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100649 const uint64_t profilingNameGuid = 3345u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100650 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000651 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100652 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000653 nullptr,
654 512u,
655 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100656 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
657 BOOST_CHECK(numberOfBytesWritten == 0);
658}
659
Keith Davis97da5e22020-03-05 16:25:28 +0000660BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionZeroValue)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100661{
662 std::vector<unsigned char> buffer(512, 0);
663
664 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100665 const uint64_t profilingNameGuid = 3345u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100666 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000667 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100668 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000669 buffer.data(),
670 0,
671 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100672 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
673 BOOST_CHECK(numberOfBytesWritten == 0);
674}
675
Keith Davis97da5e22020-03-05 16:25:28 +0000676BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionFixedValue)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100677{
678 std::vector<unsigned char> buffer(10, 0);
679
680 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100681 const uint64_t profilingNameGuid = 5564u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100682 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000683 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100684 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000685 buffer.data(),
686 boost::numeric_cast<unsigned int>(buffer.size()),
687 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100688 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
689 BOOST_CHECK(numberOfBytesWritten == 0);
690}
691
Keith Davis97da5e22020-03-05 16:25:28 +0000692BOOST_AUTO_TEST_CASE(TimelineEventClassTestFullConstructionOfData)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100693{
694 std::vector<unsigned char> buffer(512, 0);
695
696 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100697 const uint64_t profilingNameGuid = 654321u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100698 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000699 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100700 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000701 buffer.data(),
702 boost::numeric_cast<unsigned int>(buffer.size()),
703 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100704 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Jim Flynn1892d212020-05-26 21:10:49 +0100705 BOOST_CHECK(numberOfBytesWritten == 20);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100706
707 unsigned int uint32_t_size = sizeof(uint32_t);
Jim Flynn1892d212020-05-26 21:10:49 +0100708 unsigned int uint64_t_size = sizeof(uint64_t);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100709
Jan Eilers92fa15b2019-10-15 15:23:25 +0100710 unsigned int offset = 0;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100711 // Check the decl_id
Jan Eilers92fa15b2019-10-15 15:23:25 +0100712 uint32_t declId = ReadUint32(buffer.data(), offset);
713 BOOST_CHECK(declId == uint32_t(2));
714
715 // Check the profiling GUID
716 offset += uint32_t_size;
717 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
718 BOOST_CHECK(readProfilingGuid == profilingGuid);
Jim Flynn1892d212020-05-26 21:10:49 +0100719
720 offset += uint64_t_size;
721 uint64_t readProfilingNameGuid = ReadUint64(buffer.data(), offset);
722 BOOST_CHECK(readProfilingNameGuid == profilingNameGuid);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100723}
724
Keith Davis97da5e22020-03-05 16:25:28 +0000725BOOST_AUTO_TEST_CASE(TimelineEventPacketTestNoBuffer)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100726{
727 const uint64_t timestamp = 456789u;
Jim Flynn1fdeb992020-07-09 07:28:37 +0100728 const int threadId = armnnUtils::Threads::GetCurrentThreadId();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100729 const uint64_t profilingGuid = 123456u;
730 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000731 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
732 threadId,
733 profilingGuid,
734 nullptr,
735 512u,
736 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100737 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
738 BOOST_CHECK(numberOfBytesWritten == 0);
739}
740
Keith Davis97da5e22020-03-05 16:25:28 +0000741BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionZeroValue)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100742{
743 std::vector<unsigned char> buffer(512, 0);
744
745 const uint64_t timestamp = 456789u;
Jim Flynn1fdeb992020-07-09 07:28:37 +0100746 const int threadId = armnnUtils::Threads::GetCurrentThreadId();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100747 const uint64_t profilingGuid = 123456u;
748 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000749 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
750 threadId,
751 profilingGuid,
752 buffer.data(),
753 0,
754 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100755 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
756 BOOST_CHECK(numberOfBytesWritten == 0);
757}
758
Keith Davis97da5e22020-03-05 16:25:28 +0000759BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionFixedValue)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100760{
761 std::vector<unsigned char> buffer(10, 0);
762
763 const uint64_t timestamp = 456789u;
Jim Flynn1fdeb992020-07-09 07:28:37 +0100764 const int threadId = armnnUtils::Threads::GetCurrentThreadId();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100765 const uint64_t profilingGuid = 123456u;
766 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000767 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
768 threadId,
769 profilingGuid,
770 buffer.data(),
771 boost::numeric_cast<unsigned int>(buffer.size()),
772 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100773 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
774 BOOST_CHECK(numberOfBytesWritten == 0);
775}
776
Keith Davis97da5e22020-03-05 16:25:28 +0000777BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100778{
779 std::vector<unsigned char> buffer(512, 0);
780
781 const uint64_t timestamp = 456789u;
Jim Flynn1fdeb992020-07-09 07:28:37 +0100782 const int threadId = armnnUtils::Threads::GetCurrentThreadId();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100783 const uint64_t profilingGuid = 123456u;
784 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000785 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
786 threadId,
787 profilingGuid,
788 buffer.data(),
789 boost::numeric_cast<unsigned int>(buffer.size()),
790 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100791 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100792
793 unsigned int uint32_t_size = sizeof(uint32_t);
794 unsigned int uint64_t_size = sizeof(uint64_t);
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100795 BOOST_CHECK(numberOfBytesWritten == 20 + ThreadIdSize);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100796
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100797 unsigned int offset = 0;
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100798 // Check the decl_id
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100799 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
800 BOOST_CHECK(readDeclId == 4);
801
802 // Check the timestamp
803 offset += uint32_t_size;
804 uint64_t readTimestamp = ReadUint64(buffer.data(), offset);
805 BOOST_CHECK(readTimestamp == timestamp);
806
807 // Check the thread id
808 offset += uint64_t_size;
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100809 std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
810 ReadBytes(buffer.data(), offset, ThreadIdSize, readThreadId.data());
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100811 BOOST_CHECK(readThreadId == threadId);
812
813 // Check the profiling GUID
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100814 offset += ThreadIdSize;
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100815 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
816 BOOST_CHECK(readProfilingGuid == profilingGuid);
817}
818
819BOOST_AUTO_TEST_SUITE_END()