blob: 96e9bf24004b46561c66baad25aa96b4bde93607 [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
6#include <ProfilingUtils.hpp>
7
8#include <boost/test/unit_test.hpp>
9#include <boost/numeric/conversion/cast.hpp>
10
11using namespace armnn::profiling;
12
13BOOST_AUTO_TEST_SUITE(TimelinePacketTests)
14
Keith Davis97da5e22020-03-05 16:25:28 +000015BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestNoBuffer)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010016{
17 const uint64_t profilingGuid = 123456u;
18 const std::string label = "some label";
19 unsigned int numberOfBytesWritten = 789u;
20 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
21 label,
22 nullptr,
23 512u,
24 numberOfBytesWritten);
25 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
26 BOOST_CHECK(numberOfBytesWritten == 0);
27}
28
Keith Davis97da5e22020-03-05 16:25:28 +000029BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionZeroValue)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010030{
31 std::vector<unsigned char> buffer(512, 0);
32
33 const uint64_t profilingGuid = 123456u;
34 const std::string label = "some label";
35 unsigned int numberOfBytesWritten = 789u;
36 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
37 label,
38 buffer.data(),
39 0,
40 numberOfBytesWritten);
41 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
42 BOOST_CHECK(numberOfBytesWritten == 0);
43}
44
Keith Davis97da5e22020-03-05 16:25:28 +000045BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionFixedValue)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010046{
47 std::vector<unsigned char> buffer(10, 0);
48
49 const uint64_t profilingGuid = 123456u;
50 const std::string label = "some label";
51 unsigned int numberOfBytesWritten = 789u;
52 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
53 label,
54 buffer.data(),
55 boost::numeric_cast<unsigned int>(buffer.size()),
56 numberOfBytesWritten);
57 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
58 BOOST_CHECK(numberOfBytesWritten == 0);
59}
60
Keith Davis97da5e22020-03-05 16:25:28 +000061BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestInvalidLabel)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010062{
63 std::vector<unsigned char> buffer(512, 0);
64
65 const uint64_t profilingGuid = 123456u;
66 const std::string label = "s0m€ l@b€l";
67 unsigned int numberOfBytesWritten = 789u;
68 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
69 label,
70 buffer.data(),
71 boost::numeric_cast<unsigned int>(buffer.size()),
72 numberOfBytesWritten);
73 BOOST_CHECK(result == TimelinePacketStatus::Error);
74 BOOST_CHECK(numberOfBytesWritten == 0);
75}
76
Keith Davis97da5e22020-03-05 16:25:28 +000077BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestSingleConstructionOfData)
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010078{
79 std::vector<unsigned char> buffer(512, 0);
80
81 const uint64_t profilingGuid = 123456u;
82 const std::string label = "some label";
83 unsigned int numberOfBytesWritten = 789u;
84 TimelinePacketStatus result = WriteTimelineLabelBinaryPacket(profilingGuid,
85 label,
86 buffer.data(),
87 boost::numeric_cast<unsigned int>(buffer.size()),
88 numberOfBytesWritten);
89 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Keith Davis97da5e22020-03-05 16:25:28 +000090 BOOST_CHECK(numberOfBytesWritten == 28);
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010091
92 unsigned int uint32_t_size = sizeof(uint32_t);
93 unsigned int uint64_t_size = sizeof(uint64_t);
94
95 // Check the packet header
96 unsigned int offset = 0;
Jan Eilersb884ea42019-10-16 09:54:15 +010097 uint32_t decl_Id = ReadUint32(buffer.data(), offset);
98 BOOST_CHECK(decl_Id == uint32_t(0));
Matteo Martincigh0aed4f92019-10-01 14:25:34 +010099
100 // Check the profiling GUID
101 offset += uint32_t_size;
102 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
103 BOOST_CHECK(readProfilingGuid == profilingGuid);
104
105 // Check the SWTrace label
106 offset += uint64_t_size;
107 uint32_t swTraceLabelLength = ReadUint32(buffer.data(), offset);
108 BOOST_CHECK(swTraceLabelLength == 11); // Label length including the null-terminator
109
110 offset += uint32_t_size;
111 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
112 label.data(), // The original label
113 swTraceLabelLength - 1) == 0); // The length of the label
114
115 offset += swTraceLabelLength * uint32_t_size;
116 BOOST_CHECK(buffer[offset] == '\0'); // The null-terminator at the end of the SWTrace label
117}
118
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100119BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketNullBufferTest)
120{
121 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
122 const uint64_t relationshipGuid = 123456u;
123 const uint64_t headGuid = 234567u;
124 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100125 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100126 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000127 TimelinePacketStatus result = WriteTimelineRelationshipBinary(relationshipType,
128 relationshipGuid,
129 headGuid,
130 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100131 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000132 nullptr,
133 512u,
134 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100135 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
136 BOOST_CHECK(numberOfBytesWritten == 0);
137}
138
139BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketZeroBufferSizeTest)
140{
141 std::vector<unsigned char> buffer(512, 0);
142
143 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
144 const uint64_t relationshipGuid = 123456u;
145 const uint64_t headGuid = 234567u;
146 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100147 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100148 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000149 TimelinePacketStatus result = WriteTimelineRelationshipBinary(relationshipType,
150 relationshipGuid,
151 headGuid,
152 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100153 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000154 buffer.data(),
155 0,
156 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100157 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
158 BOOST_CHECK(numberOfBytesWritten == 0);
159}
160
161BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketSmallBufferSizeTest)
162{
163 std::vector<unsigned char> buffer(10, 0);
164
165 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
166 const uint64_t relationshipGuid = 123456u;
167 const uint64_t headGuid = 234567u;
168 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100169 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100170 unsigned int numberOfBytesWritten = 789u;
171 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000172 WriteTimelineRelationshipBinary(relationshipType,
173 relationshipGuid,
174 headGuid,
175 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100176 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000177 buffer.data(),
178 boost::numeric_cast<unsigned int>(buffer.size()),
179 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100180 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
181 BOOST_CHECK(numberOfBytesWritten == 0);
182}
183
184BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketInvalidRelationTest)
185{
186 std::vector<unsigned char> buffer(512, 0);
187 ProfilingRelationshipType relationshipType = static_cast<ProfilingRelationshipType>(5);
188 const uint64_t relationshipGuid = 123456u;
189 const uint64_t headGuid = 234567u;
190 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100191 const uint64_t attributeGuid = 876345u;
192
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100193 unsigned int numberOfBytesWritten = 789u;
194
Keith Davis97da5e22020-03-05 16:25:28 +0000195 BOOST_CHECK_THROW(WriteTimelineRelationshipBinary(relationshipType,
196 relationshipGuid,
197 headGuid,
198 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100199 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000200 buffer.data(),
201 boost::numeric_cast<unsigned int>(buffer.size()),
202 numberOfBytesWritten),
203 armnn::InvalidArgumentException);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100204
205 BOOST_CHECK(numberOfBytesWritten == 0);
206}
207
Keith Davis97da5e22020-03-05 16:25:28 +0000208BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100209{
210 std::vector<unsigned char> buffer(512, 0);
211
212 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::RetentionLink;
213 const uint64_t relationshipGuid = 123456u;
214 const uint64_t headGuid = 234567u;
215 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100216 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100217 unsigned int numberOfBytesWritten = 789u;
218 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000219 WriteTimelineRelationshipBinary(relationshipType,
220 relationshipGuid,
221 headGuid,
222 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100223 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000224 buffer.data(),
225 boost::numeric_cast<unsigned int>(buffer.size()),
226 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100227 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100228 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100229
230 unsigned int uint32_t_size = sizeof(uint32_t);
231 unsigned int uint64_t_size = sizeof(uint64_t);
232
233 // Check the packet header
234 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100235 // Check the decl_id
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100236 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
237 BOOST_CHECK(readDeclId == 3);
238
239 // Check the relationship type
240 offset += uint32_t_size;
241 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
242 BOOST_CHECK(readRelationshipType == 0);
243
244 // Check the relationship GUID
245 offset += uint32_t_size;
246 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
247 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
248
249 // Check the head GUID
250 offset += uint64_t_size;
251 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
252 BOOST_CHECK(readHeadGuid == headGuid);
253
254 // Check the tail GUID
255 offset += uint64_t_size;
256 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
257 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100258
259 // Check the attribute GUID
260 offset += uint64_t_size;
261 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
262 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100263}
264
Keith Davis97da5e22020-03-05 16:25:28 +0000265BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100266{
267 std::vector<unsigned char> buffer(512, 0);
268
269 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::ExecutionLink;
270 const uint64_t relationshipGuid = 123456u;
271 const uint64_t headGuid = 234567u;
272 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100273 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100274 unsigned int numberOfBytesWritten = 789u;
275 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000276 WriteTimelineRelationshipBinary(relationshipType,
277 relationshipGuid,
278 headGuid,
279 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100280 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000281 buffer.data(),
282 boost::numeric_cast<unsigned int>(buffer.size()),
283 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100284 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100285 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100286
287 unsigned int uint32_t_size = sizeof(uint32_t);
288 unsigned int uint64_t_size = sizeof(uint64_t);
289
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100290 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100291 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
292 BOOST_CHECK(readDeclId == 3);
293
294 // Check the relationship type
295 offset += uint32_t_size;
296 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
297 BOOST_CHECK(readRelationshipType == 1);
298
299 // Check the relationship GUID
300 offset += uint32_t_size;
301 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
302 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
303
304 // Check the head GUID
305 offset += uint64_t_size;
306 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
307 BOOST_CHECK(readHeadGuid == headGuid);
308
309 // Check the tail GUID
310 offset += uint64_t_size;
311 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
312 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100313
314 // Check the attribute GUID
315 offset += uint64_t_size;
316 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
317 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100318}
319
320
Keith Davis97da5e22020-03-05 16:25:28 +0000321BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100322{
323 std::vector<unsigned char> buffer(512, 0);
324
325 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::DataLink;
326 const uint64_t relationshipGuid = 123456u;
327 const uint64_t headGuid = 234567u;
328 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100329 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100330 unsigned int numberOfBytesWritten = 789u;
331 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000332 WriteTimelineRelationshipBinary(relationshipType,
333 relationshipGuid,
334 headGuid,
335 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100336 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000337 buffer.data(),
338 boost::numeric_cast<unsigned int>(buffer.size()),
339 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100340 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100341 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100342
343 unsigned int uint32_t_size = sizeof(uint32_t);
344 unsigned int uint64_t_size = sizeof(uint64_t);
345
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100346 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100347 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
348 BOOST_CHECK(readDeclId == 3);
349
350 // Check the relationship type
351 offset += uint32_t_size;
352 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
353 BOOST_CHECK(readRelationshipType == 2);
354
355 // Check the relationship GUID
356 offset += uint32_t_size;
357 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
358 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
359
360 // Check the head GUID
361 offset += uint64_t_size;
362 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
363 BOOST_CHECK(readHeadGuid == headGuid);
364
365 // Check the tail GUID
366 offset += uint64_t_size;
367 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
368 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100369
370 // Check the attribute GUID
371 offset += uint64_t_size;
372 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
373 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100374}
375
376
Keith Davis97da5e22020-03-05 16:25:28 +0000377BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTestDataConstruction)
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100378{
379 std::vector<unsigned char> buffer(512, 0);
380
381 ProfilingRelationshipType relationshipType = ProfilingRelationshipType::LabelLink;
382 const uint64_t relationshipGuid = 123456u;
383 const uint64_t headGuid = 234567u;
384 const uint64_t tailGuid = 345678u;
Finn Williams0a336dc2020-05-11 15:39:58 +0100385 const uint64_t attributeGuid = 876345u;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100386 unsigned int numberOfBytesWritten = 789u;
387 TimelinePacketStatus result =
Keith Davis97da5e22020-03-05 16:25:28 +0000388 WriteTimelineRelationshipBinary(relationshipType,
389 relationshipGuid,
390 headGuid,
391 tailGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100392 attributeGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000393 buffer.data(),
394 boost::numeric_cast<unsigned int>(buffer.size()),
395 numberOfBytesWritten);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100396 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Finn Williams0a336dc2020-05-11 15:39:58 +0100397 BOOST_CHECK(numberOfBytesWritten == 40);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100398
399 unsigned int uint32_t_size = sizeof(uint32_t);
400 unsigned int uint64_t_size = sizeof(uint64_t);
401
402 // Check the packet header
403 unsigned int offset = 0;
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100404 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
405 BOOST_CHECK(readDeclId == 3);
406
407 // Check the relationship type
408 offset += uint32_t_size;
409 uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
410 BOOST_CHECK(readRelationshipType == 3);
411
412 // Check the relationship GUID
413 offset += uint32_t_size;
414 uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
415 BOOST_CHECK(readRelationshipGuid == relationshipGuid);
416
417 // Check the head GUID
418 offset += uint64_t_size;
419 uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
420 BOOST_CHECK(readHeadGuid == headGuid);
421
422 // Check the tail GUID
423 offset += uint64_t_size;
424 uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
425 BOOST_CHECK(readTailGuid == tailGuid);
Finn Williams0a336dc2020-05-11 15:39:58 +0100426
427 // Check the attribute GUID
428 offset += uint64_t_size;
429 uint64_t readAttributeGuid = ReadUint64(buffer.data(), offset);
430 BOOST_CHECK(readAttributeGuid == attributeGuid);
Narumol Prangnawarat7e5eec72019-10-16 12:16:26 +0100431}
432
Keith Davis97da5e22020-03-05 16:25:28 +0000433BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestNoBuffer)
Sadik Armagan784db772019-10-08 15:05:38 +0100434{
435 unsigned int numberOfBytesWritten = 789u;
436 TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(nullptr,
437 512u,
438 numberOfBytesWritten);
439 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
440 BOOST_CHECK(numberOfBytesWritten == 0);
441}
442
Keith Davis97da5e22020-03-05 16:25:28 +0000443BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestBufferExhausted)
Sadik Armagan784db772019-10-08 15:05:38 +0100444{
445 std::vector<unsigned char> buffer(512, 0);
446
447 unsigned int numberOfBytesWritten = 789u;
448 TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(buffer.data(),
449 0,
450 numberOfBytesWritten);
451 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
452 BOOST_CHECK(numberOfBytesWritten == 0);
453}
454
Keith Davis97da5e22020-03-05 16:25:28 +0000455BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction)
Sadik Armagan784db772019-10-08 15:05:38 +0100456{
457 std::vector<unsigned char> buffer(512, 0);
458 unsigned int numberOfBytesWritten = 789u;
459 TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(buffer.data(),
460 boost::numeric_cast<unsigned int>(buffer.size()),
461 numberOfBytesWritten);
462 BOOST_CHECK(result == TimelinePacketStatus::Ok);
463
Jim Flynn6398a982020-05-27 17:05:21 +0100464 BOOST_CHECK(numberOfBytesWritten == 451);
Sadik Armagan784db772019-10-08 15:05:38 +0100465
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000466 unsigned int uint8_t_size = sizeof(uint8_t);
Sadik Armagan784db772019-10-08 15:05:38 +0100467 unsigned int uint32_t_size = sizeof(uint32_t);
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000468 unsigned int uint64_t_size = sizeof(uint64_t);
Sadik Armagan784db772019-10-08 15:05:38 +0100469
470 // Check the packet header
471 unsigned int offset = 0;
472 uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
473 uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
474 uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
475 uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
476 uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
477 BOOST_CHECK(packetFamily == 1);
478 BOOST_CHECK(packetClass == 0);
479 BOOST_CHECK(packetType == 0);
480 BOOST_CHECK(streamId == 0);
481
482 offset += uint32_t_size;
483 uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
484 uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
485 uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
486 BOOST_CHECK(sequenceNumbered == 0);
Jim Flynn6398a982020-05-27 17:05:21 +0100487 BOOST_CHECK(dataLength == 443);
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000488
489 // Check the stream header
490 offset += uint32_t_size;
491 uint8_t readStreamVersion = ReadUint8(buffer.data(), offset);
492 BOOST_CHECK(readStreamVersion == 4);
493 offset += uint8_t_size;
494 uint8_t readPointerBytes = ReadUint8(buffer.data(), offset);
495 BOOST_CHECK(readPointerBytes == uint64_t_size);
496 offset += uint8_t_size;
497 uint8_t readThreadIdBytes = ReadUint8(buffer.data(), offset);
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100498 BOOST_CHECK(readThreadIdBytes == ThreadIdSize);
Sadik Armagan784db772019-10-08 15:05:38 +0100499
Finn Williamse63a0262019-10-22 10:30:49 +0100500 // Check the number of declarations
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000501 offset += uint8_t_size;
Finn Williamse63a0262019-10-22 10:30:49 +0100502 uint32_t declCount = ReadUint32(buffer.data(), offset);
503 BOOST_CHECK(declCount == 5);
504
Sadik Armagan784db772019-10-08 15:05:38 +0100505 // Check the decl_id
506 offset += uint32_t_size;
507 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
508 BOOST_CHECK(readDeclId == 0);
509
510 // SWTrace "namestring" format
511 // length of the string (first 4 bytes) + string + null terminator
512
513 // Check the decl_name
514 offset += uint32_t_size;
515 uint32_t swTraceDeclNameLength = ReadUint32(buffer.data(), offset);
516 BOOST_CHECK(swTraceDeclNameLength == 13); // decl_name length including the null-terminator
517
518 std::string label = "declareLabel";
519 offset += uint32_t_size;
520 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
Matteo Martincigh34a407d2019-11-06 15:30:54 +0000521 label.data(), // The original label
Sadik Armagan784db772019-10-08 15:05:38 +0100522 swTraceDeclNameLength - 1) == 0); // The length of the label
523
524 // Check the ui_name
525 std::vector<uint32_t> swTraceString;
526 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
527 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
528 uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset);
529 BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator
530
531 label = "declare label";
532 offset += uint32_t_size;
533 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
534 label.data(), // The original label
535 swTraceUINameLength - 1) == 0); // The length of the label
536
537 // Check arg_types
538 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
539 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
540 uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset);
541 BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator
542
543 label = "ps";
544 offset += uint32_t_size;
545 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
546 label.data(), // The original label
547 swTraceArgTypesLength - 1) == 0); // The length of the label
548
549 // Check arg_names
550 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
551 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
552 uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset);
553 BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator
554
555 label = "guid,value";
556 offset += uint32_t_size;
557 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
558 label.data(), // The original label
559 swTraceArgNamesLength - 1) == 0); // The length of the label
560
561 // Check second message decl_id
562 StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
563 offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
564 readDeclId = ReadUint32(buffer.data(), offset);
565 BOOST_CHECK(readDeclId == 1);
566
567 // Check second decl_name
568 offset += uint32_t_size;
569 swTraceDeclNameLength = ReadUint32(buffer.data(), offset);
570 BOOST_CHECK(swTraceDeclNameLength == 14); // decl_name length including the null-terminator
571
572 label = "declareEntity";
573 offset += uint32_t_size;
574 BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
575 label.data(), // The original label
576 swTraceDeclNameLength - 1) == 0); // The length of the label
577}
578
Keith Davis97da5e22020-03-05 16:25:28 +0000579BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestNoBuffer)
David Monahanf21f6062019-10-07 15:11:15 +0100580{
581 const uint64_t profilingGuid = 123456u;
582 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000583 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
584 nullptr,
585 512u,
586 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100587 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
588 BOOST_CHECK(numberOfBytesWritten == 0);
589}
590
Keith Davis97da5e22020-03-05 16:25:28 +0000591BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithZeroBufferSize)
David Monahanf21f6062019-10-07 15:11:15 +0100592{
593 std::vector<unsigned char> buffer(512, 0);
594
595 const uint64_t profilingGuid = 123456u;
596 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000597 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
598 buffer.data(),
599 0,
600 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100601 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
602 BOOST_CHECK(numberOfBytesWritten == 0);
603}
604
Keith Davis97da5e22020-03-05 16:25:28 +0000605BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithFixedBufferSize)
David Monahanf21f6062019-10-07 15:11:15 +0100606{
607 std::vector<unsigned char> buffer(10, 0);
608
609 const uint64_t profilingGuid = 123456u;
610 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000611 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
612 buffer.data(),
613 boost::numeric_cast<unsigned int>(buffer.size()),
614 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100615 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
616 BOOST_CHECK(numberOfBytesWritten == 0);
617}
618
Keith Davis97da5e22020-03-05 16:25:28 +0000619BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestFullConstructionOfData)
David Monahanf21f6062019-10-07 15:11:15 +0100620{
621 std::vector<unsigned char> buffer(512, 0);
622
623 const uint64_t profilingGuid = 123456u;
624 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000625 TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid,
626 buffer.data(),
627 boost::numeric_cast<unsigned int>(buffer.size()),
628 numberOfBytesWritten);
David Monahanf21f6062019-10-07 15:11:15 +0100629 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Keith Davis97da5e22020-03-05 16:25:28 +0000630 BOOST_CHECK(numberOfBytesWritten == 12);
David Monahanf21f6062019-10-07 15:11:15 +0100631
632 unsigned int uint32_t_size = sizeof(uint32_t);
633
David Monahanf21f6062019-10-07 15:11:15 +0100634 unsigned int offset = 0;
Jan Eilersb884ea42019-10-16 09:54:15 +0100635 // Check decl_Id
Jan Eilersb884ea42019-10-16 09:54:15 +0100636 uint32_t decl_Id = ReadUint32(buffer.data(), offset);
637 BOOST_CHECK(decl_Id == uint32_t(1));
638
David Monahanf21f6062019-10-07 15:11:15 +0100639 // Check the profiling GUID
640 offset += uint32_t_size;
641 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
642 BOOST_CHECK(readProfilingGuid == profilingGuid);
643}
644
Keith Davis97da5e22020-03-05 16:25:28 +0000645BOOST_AUTO_TEST_CASE(TimelineEventClassTestNoBuffer)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100646{
647 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100648 const uint64_t profilingNameGuid = 3345u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100649 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000650 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100651 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000652 nullptr,
653 512u,
654 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100655 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
656 BOOST_CHECK(numberOfBytesWritten == 0);
657}
658
Keith Davis97da5e22020-03-05 16:25:28 +0000659BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionZeroValue)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100660{
661 std::vector<unsigned char> buffer(512, 0);
662
663 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100664 const uint64_t profilingNameGuid = 3345u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100665 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000666 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100667 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000668 buffer.data(),
669 0,
670 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100671 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
672 BOOST_CHECK(numberOfBytesWritten == 0);
673}
674
Keith Davis97da5e22020-03-05 16:25:28 +0000675BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionFixedValue)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100676{
677 std::vector<unsigned char> buffer(10, 0);
678
679 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100680 const uint64_t profilingNameGuid = 5564u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100681 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000682 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100683 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000684 buffer.data(),
685 boost::numeric_cast<unsigned int>(buffer.size()),
686 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100687 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
688 BOOST_CHECK(numberOfBytesWritten == 0);
689}
690
Keith Davis97da5e22020-03-05 16:25:28 +0000691BOOST_AUTO_TEST_CASE(TimelineEventClassTestFullConstructionOfData)
Jan Eilers92fa15b2019-10-15 15:23:25 +0100692{
693 std::vector<unsigned char> buffer(512, 0);
694
695 const uint64_t profilingGuid = 123456u;
Jim Flynn1892d212020-05-26 21:10:49 +0100696 const uint64_t profilingNameGuid = 654321u;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100697 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000698 TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid,
Jim Flynn1892d212020-05-26 21:10:49 +0100699 profilingNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000700 buffer.data(),
701 boost::numeric_cast<unsigned int>(buffer.size()),
702 numberOfBytesWritten);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100703 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Jim Flynn1892d212020-05-26 21:10:49 +0100704 BOOST_CHECK(numberOfBytesWritten == 20);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100705
706 unsigned int uint32_t_size = sizeof(uint32_t);
Jim Flynn1892d212020-05-26 21:10:49 +0100707 unsigned int uint64_t_size = sizeof(uint64_t);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100708
Jan Eilers92fa15b2019-10-15 15:23:25 +0100709 unsigned int offset = 0;
Jan Eilers92fa15b2019-10-15 15:23:25 +0100710 // Check the decl_id
Jan Eilers92fa15b2019-10-15 15:23:25 +0100711 uint32_t declId = ReadUint32(buffer.data(), offset);
712 BOOST_CHECK(declId == uint32_t(2));
713
714 // Check the profiling GUID
715 offset += uint32_t_size;
716 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
717 BOOST_CHECK(readProfilingGuid == profilingGuid);
Jim Flynn1892d212020-05-26 21:10:49 +0100718
719 offset += uint64_t_size;
720 uint64_t readProfilingNameGuid = ReadUint64(buffer.data(), offset);
721 BOOST_CHECK(readProfilingNameGuid == profilingNameGuid);
Jan Eilers92fa15b2019-10-15 15:23:25 +0100722}
723
Keith Davis97da5e22020-03-05 16:25:28 +0000724BOOST_AUTO_TEST_CASE(TimelineEventPacketTestNoBuffer)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100725{
726 const uint64_t timestamp = 456789u;
Matteo Martincigh378bbfc2019-11-04 14:05:28 +0000727 const std::thread::id threadId = std::this_thread::get_id();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100728 const uint64_t profilingGuid = 123456u;
729 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000730 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
731 threadId,
732 profilingGuid,
733 nullptr,
734 512u,
735 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100736 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
737 BOOST_CHECK(numberOfBytesWritten == 0);
738}
739
Keith Davis97da5e22020-03-05 16:25:28 +0000740BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionZeroValue)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100741{
742 std::vector<unsigned char> buffer(512, 0);
743
744 const uint64_t timestamp = 456789u;
Matteo Martincigh378bbfc2019-11-04 14:05:28 +0000745 const std::thread::id threadId = std::this_thread::get_id();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100746 const uint64_t profilingGuid = 123456u;
747 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000748 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
749 threadId,
750 profilingGuid,
751 buffer.data(),
752 0,
753 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100754 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
755 BOOST_CHECK(numberOfBytesWritten == 0);
756}
757
Keith Davis97da5e22020-03-05 16:25:28 +0000758BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionFixedValue)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100759{
760 std::vector<unsigned char> buffer(10, 0);
761
762 const uint64_t timestamp = 456789u;
Matteo Martincigh378bbfc2019-11-04 14:05:28 +0000763 const std::thread::id threadId = std::this_thread::get_id();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100764 const uint64_t profilingGuid = 123456u;
765 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000766 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
767 threadId,
768 profilingGuid,
769 buffer.data(),
770 boost::numeric_cast<unsigned int>(buffer.size()),
771 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100772 BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
773 BOOST_CHECK(numberOfBytesWritten == 0);
774}
775
Keith Davis97da5e22020-03-05 16:25:28 +0000776BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData)
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100777{
778 std::vector<unsigned char> buffer(512, 0);
779
780 const uint64_t timestamp = 456789u;
Matteo Martincigh378bbfc2019-11-04 14:05:28 +0000781 const std::thread::id threadId = std::this_thread::get_id();
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100782 const uint64_t profilingGuid = 123456u;
783 unsigned int numberOfBytesWritten = 789u;
Keith Davis97da5e22020-03-05 16:25:28 +0000784 TimelinePacketStatus result = WriteTimelineEventBinary(timestamp,
785 threadId,
786 profilingGuid,
787 buffer.data(),
788 boost::numeric_cast<unsigned int>(buffer.size()),
789 numberOfBytesWritten);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100790 BOOST_CHECK(result == TimelinePacketStatus::Ok);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100791
792 unsigned int uint32_t_size = sizeof(uint32_t);
793 unsigned int uint64_t_size = sizeof(uint64_t);
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100794 BOOST_CHECK(numberOfBytesWritten == 20 + ThreadIdSize);
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100795
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100796 unsigned int offset = 0;
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100797 // Check the decl_id
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100798 uint32_t readDeclId = ReadUint32(buffer.data(), offset);
799 BOOST_CHECK(readDeclId == 4);
800
801 // Check the timestamp
802 offset += uint32_t_size;
803 uint64_t readTimestamp = ReadUint64(buffer.data(), offset);
804 BOOST_CHECK(readTimestamp == timestamp);
805
806 // Check the thread id
807 offset += uint64_t_size;
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100808 std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
809 ReadBytes(buffer.data(), offset, ThreadIdSize, readThreadId.data());
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100810 BOOST_CHECK(readThreadId == threadId);
811
812 // Check the profiling GUID
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100813 offset += ThreadIdSize;
Matteo Martincigh8844c2f2019-10-16 10:29:17 +0100814 uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
815 BOOST_CHECK(readProfilingGuid == profilingGuid);
816}
817
818BOOST_AUTO_TEST_SUITE_END()