Sadik Armagan | 7bbdf9d | 2019-10-24 10:26:05 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "SendCounterPacketTests.hpp" |
| 7 | |
| 8 | #include <BufferManager.hpp> |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 9 | #include <ProfilingService.hpp> |
Sadik Armagan | 7bbdf9d | 2019-10-24 10:26:05 +0100 | [diff] [blame] | 10 | #include <ProfilingUtils.hpp> |
| 11 | #include <SendTimelinePacket.hpp> |
| 12 | #include <TimelinePacketWriterFactory.hpp> |
| 13 | |
| 14 | #include <boost/test/unit_test.hpp> |
| 15 | |
| 16 | using namespace armnn::profiling; |
| 17 | |
| 18 | BOOST_AUTO_TEST_SUITE(SendTimelinePacketTests) |
| 19 | |
| 20 | BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) |
| 21 | { |
| 22 | MockBufferManager mockBuffer(512); |
| 23 | TimelinePacketWriterFactory timelinePacketWriterFactory(mockBuffer); |
| 24 | std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket(); |
| 25 | |
| 26 | sendTimelinePacket->SendTimelineMessageDirectoryPackage(); |
| 27 | |
| 28 | // Get the readable buffer |
| 29 | auto packetBuffer = mockBuffer.GetReadableBuffer(); |
| 30 | |
| 31 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 32 | // Check the packet header |
| 33 | unsigned int offset = 0; |
| 34 | uint32_t packetHeaderWord0 = ReadUint32(packetBuffer, offset); |
| 35 | uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; |
| 36 | uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; |
| 37 | uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; |
| 38 | uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; |
| 39 | |
| 40 | BOOST_CHECK(packetFamily == 1); |
| 41 | BOOST_CHECK(packetClass == 0); |
| 42 | BOOST_CHECK(packetType == 0); |
| 43 | BOOST_CHECK(streamId == 0); |
| 44 | |
| 45 | offset += uint32_t_size; |
| 46 | uint32_t packetHeaderWord1 = ReadUint32(packetBuffer, offset); |
| 47 | uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; |
| 48 | uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; |
| 49 | BOOST_CHECK(sequenceNumbered == 0); |
| 50 | BOOST_CHECK(dataLength == 416); |
| 51 | |
| 52 | offset += uint32_t_size; |
| 53 | SwTraceMessage swTraceMessage = ReadSwTraceMessage(packetBuffer, offset); |
| 54 | |
| 55 | BOOST_CHECK(swTraceMessage.id == 0); |
| 56 | BOOST_CHECK(swTraceMessage.name == "declareLabel"); |
| 57 | BOOST_CHECK(swTraceMessage.uiName == "declare label"); |
| 58 | BOOST_CHECK(swTraceMessage.argTypes.size() == 2); |
| 59 | BOOST_CHECK(swTraceMessage.argTypes[0] == 'p'); |
| 60 | BOOST_CHECK(swTraceMessage.argTypes[1] == 's'); |
| 61 | BOOST_CHECK(swTraceMessage.argNames.size() == 2); |
| 62 | BOOST_CHECK(swTraceMessage.argNames[0] == "guid"); |
| 63 | BOOST_CHECK(swTraceMessage.argNames[1] == "value"); |
| 64 | |
| 65 | swTraceMessage = ReadSwTraceMessage(packetBuffer, offset); |
| 66 | |
| 67 | BOOST_CHECK(swTraceMessage.id == 1); |
| 68 | BOOST_CHECK(swTraceMessage.name == "declareEntity"); |
| 69 | BOOST_CHECK(swTraceMessage.uiName == "declare entity"); |
| 70 | BOOST_CHECK(swTraceMessage.argTypes.size() == 1); |
| 71 | BOOST_CHECK(swTraceMessage.argTypes[0] == 'p'); |
| 72 | BOOST_CHECK(swTraceMessage.argNames.size() == 1); |
| 73 | BOOST_CHECK(swTraceMessage.argNames[0] == "guid"); |
| 74 | |
| 75 | swTraceMessage = ReadSwTraceMessage(packetBuffer, offset); |
| 76 | |
| 77 | BOOST_CHECK(swTraceMessage.id == 2); |
| 78 | BOOST_CHECK(swTraceMessage.name == "declareEventClass"); |
| 79 | BOOST_CHECK(swTraceMessage.uiName == "declare event class"); |
| 80 | BOOST_CHECK(swTraceMessage.argTypes.size() == 1); |
| 81 | BOOST_CHECK(swTraceMessage.argTypes[0] == 'p'); |
| 82 | BOOST_CHECK(swTraceMessage.argNames.size() == 1); |
| 83 | BOOST_CHECK(swTraceMessage.argNames[0] == "guid"); |
| 84 | |
| 85 | swTraceMessage = ReadSwTraceMessage(packetBuffer, offset); |
| 86 | |
| 87 | BOOST_CHECK(swTraceMessage.id == 3); |
| 88 | BOOST_CHECK(swTraceMessage.name == "declareRelationship"); |
| 89 | BOOST_CHECK(swTraceMessage.uiName == "declare relationship"); |
| 90 | BOOST_CHECK(swTraceMessage.argTypes.size() == 4); |
| 91 | BOOST_CHECK(swTraceMessage.argTypes[0] == 'I'); |
| 92 | BOOST_CHECK(swTraceMessage.argTypes[1] == 'p'); |
| 93 | BOOST_CHECK(swTraceMessage.argTypes[2] == 'p'); |
| 94 | BOOST_CHECK(swTraceMessage.argTypes[3] == 'p'); |
| 95 | BOOST_CHECK(swTraceMessage.argNames.size() == 4); |
| 96 | BOOST_CHECK(swTraceMessage.argNames[0] == "relationshipType"); |
| 97 | BOOST_CHECK(swTraceMessage.argNames[1] == "relationshipGuid"); |
| 98 | BOOST_CHECK(swTraceMessage.argNames[2] == "headGuid"); |
| 99 | BOOST_CHECK(swTraceMessage.argNames[3] == "tailGuid"); |
| 100 | |
| 101 | swTraceMessage = ReadSwTraceMessage(packetBuffer, offset); |
| 102 | |
| 103 | BOOST_CHECK(swTraceMessage.id == 4); |
| 104 | BOOST_CHECK(swTraceMessage.name == "declareEvent"); |
| 105 | BOOST_CHECK(swTraceMessage.uiName == "declare event"); |
| 106 | BOOST_CHECK(swTraceMessage.argTypes.size() == 3); |
| 107 | BOOST_CHECK(swTraceMessage.argTypes[0] == '@'); |
| 108 | BOOST_CHECK(swTraceMessage.argTypes[1] == 't'); |
| 109 | BOOST_CHECK(swTraceMessage.argTypes[2] == 'p'); |
| 110 | BOOST_CHECK(swTraceMessage.argNames.size() == 3); |
| 111 | BOOST_CHECK(swTraceMessage.argNames[0] == "timestamp"); |
| 112 | BOOST_CHECK(swTraceMessage.argNames[1] == "threadId"); |
| 113 | BOOST_CHECK(swTraceMessage.argNames[2] == "eventGuid"); |
| 114 | } |
| 115 | |
| 116 | BOOST_AUTO_TEST_CASE(SendTimelineEntityPlusEventClassBinaryPacketTest) |
| 117 | { |
| 118 | MockBufferManager bufferManager(40); |
| 119 | TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); |
| 120 | std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket(); |
| 121 | |
| 122 | const uint64_t entityBinaryPacketProfilingGuid = 123456u; |
| 123 | sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid); |
| 124 | |
| 125 | const uint64_t eventClassBinaryPacketProfilingGuid = 789123u; |
| 126 | sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid); |
| 127 | |
| 128 | // Commit the messages |
| 129 | sendTimelinePacket->Commit(); |
| 130 | |
| 131 | // Get the readable buffer |
| 132 | auto packetBuffer = bufferManager.GetReadableBuffer(); |
| 133 | |
| 134 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 135 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 136 | |
| 137 | // Check the packet header |
| 138 | unsigned int offset = 0; |
| 139 | |
| 140 | // Reading TimelineEntityClassBinaryPacket |
| 141 | uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); |
| 142 | uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; |
| 143 | uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; |
| 144 | uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; |
| 145 | uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; |
| 146 | |
| 147 | BOOST_CHECK(entityBinaryPacketFamily == 1); |
| 148 | BOOST_CHECK(entityBinaryPacketClass == 0); |
| 149 | BOOST_CHECK(entityBinaryPacketType == 1); |
| 150 | BOOST_CHECK(entityBinaryPacketStreamId == 0); |
| 151 | |
| 152 | offset += uint32_t_size; |
| 153 | uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); |
| 154 | uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; |
| 155 | uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; |
| 156 | BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0); |
| 157 | BOOST_CHECK(entityBinaryPacketDataLength == 8); |
| 158 | |
| 159 | // Check the decl_id |
| 160 | offset += uint32_t_size; |
| 161 | uint32_t entitytDecId = ReadUint32(packetBuffer, offset); |
| 162 | |
| 163 | BOOST_CHECK(entitytDecId == uint32_t(1)); |
| 164 | |
| 165 | // Check the profiling GUID |
| 166 | offset += uint32_t_size; |
| 167 | uint64_t readProfilingGuid = ReadUint64(packetBuffer, offset); |
| 168 | |
| 169 | BOOST_CHECK(readProfilingGuid == entityBinaryPacketProfilingGuid); |
| 170 | |
| 171 | // Reading TimelineEventClassBinaryPacket |
| 172 | offset += uint64_t_size; |
| 173 | uint32_t eventClassBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); |
| 174 | uint32_t eventClassBinaryPacketFamily = (eventClassBinaryPacketHeaderWord0 >> 26) & 0x0000003F; |
| 175 | uint32_t eventClassBinaryPacketClass = (eventClassBinaryPacketHeaderWord0 >> 19) & 0x0000007F; |
| 176 | uint32_t eventClassBinaryPacketType = (eventClassBinaryPacketHeaderWord0 >> 16) & 0x00000007; |
| 177 | uint32_t eventClassBinaryPacketStreamId = (eventClassBinaryPacketHeaderWord0 >> 0) & 0x00000007; |
| 178 | |
| 179 | BOOST_CHECK(eventClassBinaryPacketFamily == 1); |
| 180 | BOOST_CHECK(eventClassBinaryPacketClass == 0); |
| 181 | BOOST_CHECK(eventClassBinaryPacketType == 1); |
| 182 | BOOST_CHECK(eventClassBinaryPacketStreamId == 0); |
| 183 | |
| 184 | offset += uint32_t_size; |
| 185 | uint32_t eventClassBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); |
| 186 | uint32_t eventClassBinaryPacketSequenceNumbered = (eventClassBinaryPacketHeaderWord1 >> 24) & 0x00000001; |
| 187 | uint32_t eventClassBinaryPacketDataLength = (eventClassBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; |
| 188 | BOOST_CHECK(eventClassBinaryPacketSequenceNumbered == 0); |
| 189 | BOOST_CHECK(eventClassBinaryPacketDataLength == 12); |
| 190 | |
| 191 | offset += uint32_t_size; |
| 192 | uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset); |
| 193 | BOOST_CHECK(eventClassDeclId == uint32_t(2)); |
| 194 | |
| 195 | // Check the profiling GUID |
| 196 | offset += uint32_t_size; |
| 197 | readProfilingGuid = ReadUint64(packetBuffer, offset); |
| 198 | BOOST_CHECK(readProfilingGuid == eventClassBinaryPacketProfilingGuid); |
| 199 | |
| 200 | bufferManager.MarkRead(packetBuffer); |
| 201 | } |
| 202 | |
| 203 | BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1) |
| 204 | { |
| 205 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 206 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 207 | |
| 208 | MockBufferManager bufferManager(512); |
| 209 | TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); |
| 210 | std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket(); |
| 211 | |
| 212 | // Send TimelineEntityClassBinaryPacket |
| 213 | const uint64_t entityBinaryPacketProfilingGuid = 123456u; |
| 214 | sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid); |
| 215 | |
| 216 | // Commit the buffer |
| 217 | sendTimelinePacket->Commit(); |
| 218 | |
| 219 | // Get the readable buffer |
| 220 | auto packetBuffer = bufferManager.GetReadableBuffer(); |
| 221 | |
| 222 | // Check the packet header |
| 223 | unsigned int offset = 0; |
| 224 | |
| 225 | // Reading TimelineEntityClassBinaryPacket |
| 226 | uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); |
| 227 | uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; |
| 228 | uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; |
| 229 | uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; |
| 230 | uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; |
| 231 | |
| 232 | BOOST_CHECK(entityBinaryPacketFamily == 1); |
| 233 | BOOST_CHECK(entityBinaryPacketClass == 0); |
| 234 | BOOST_CHECK(entityBinaryPacketType == 1); |
| 235 | BOOST_CHECK(entityBinaryPacketStreamId == 0); |
| 236 | |
| 237 | offset += uint32_t_size; |
| 238 | uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); |
| 239 | uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; |
| 240 | uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; |
| 241 | BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0); |
| 242 | BOOST_CHECK(entityBinaryPacketDataLength == 8); |
| 243 | |
| 244 | // Check the decl_id |
| 245 | offset += uint32_t_size; |
| 246 | uint32_t entitytDecId = ReadUint32(packetBuffer, offset); |
| 247 | |
| 248 | BOOST_CHECK(entitytDecId == uint32_t(1)); |
| 249 | |
| 250 | // Check the profiling GUID |
| 251 | offset += uint32_t_size; |
| 252 | uint64_t readProfilingGuid = ReadUint64(packetBuffer, offset); |
| 253 | |
| 254 | BOOST_CHECK(readProfilingGuid == entityBinaryPacketProfilingGuid); |
| 255 | |
| 256 | bufferManager.MarkRead(packetBuffer); |
| 257 | |
| 258 | // Send TimelineEventClassBinaryPacket |
| 259 | const uint64_t eventClassBinaryPacketProfilingGuid = 789123u; |
| 260 | sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid); |
| 261 | |
| 262 | // Commit the buffer |
| 263 | sendTimelinePacket->Commit(); |
| 264 | |
| 265 | // Get the readable buffer |
| 266 | packetBuffer = bufferManager.GetReadableBuffer(); |
| 267 | |
| 268 | // Check the packet header |
| 269 | offset = 0; |
| 270 | |
| 271 | // Reading TimelineEventClassBinaryPacket |
| 272 | uint32_t eventClassBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); |
| 273 | uint32_t eventClassBinaryPacketFamily = (eventClassBinaryPacketHeaderWord0 >> 26) & 0x0000003F; |
| 274 | uint32_t eventClassBinaryPacketClass = (eventClassBinaryPacketHeaderWord0 >> 19) & 0x0000007F; |
| 275 | uint32_t eventClassBinaryPacketType = (eventClassBinaryPacketHeaderWord0 >> 16) & 0x00000007; |
| 276 | uint32_t eventClassBinaryPacketStreamId = (eventClassBinaryPacketHeaderWord0 >> 0) & 0x00000007; |
| 277 | |
| 278 | BOOST_CHECK(eventClassBinaryPacketFamily == 1); |
| 279 | BOOST_CHECK(eventClassBinaryPacketClass == 0); |
| 280 | BOOST_CHECK(eventClassBinaryPacketType == 1); |
| 281 | BOOST_CHECK(eventClassBinaryPacketStreamId == 0); |
| 282 | |
| 283 | offset += uint32_t_size; |
| 284 | uint32_t eventClassBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); |
| 285 | uint32_t eventClassBinaryPacketSequenceNumbered = (eventClassBinaryPacketHeaderWord1 >> 24) & 0x00000001; |
| 286 | uint32_t eventClassBinaryPacketDataLength = (eventClassBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; |
| 287 | BOOST_CHECK(eventClassBinaryPacketSequenceNumbered == 0); |
| 288 | BOOST_CHECK(eventClassBinaryPacketDataLength == 12); |
| 289 | |
| 290 | offset += uint32_t_size; |
| 291 | uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset); |
| 292 | BOOST_CHECK(eventClassDeclId == uint32_t(2)); |
| 293 | |
| 294 | // Check the profiling GUID |
| 295 | offset += uint32_t_size; |
| 296 | readProfilingGuid = ReadUint64(packetBuffer, offset); |
| 297 | BOOST_CHECK(readProfilingGuid == eventClassBinaryPacketProfilingGuid); |
| 298 | |
| 299 | bufferManager.MarkRead(packetBuffer); |
| 300 | |
| 301 | // Send TimelineEventBinaryPacket |
| 302 | const uint64_t timestamp = 456789u; |
| 303 | const uint32_t threadId = 654321u; |
| 304 | const uint64_t eventProfilingGuid = 123456u; |
| 305 | sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventProfilingGuid); |
| 306 | |
| 307 | // Commit the buffer |
| 308 | sendTimelinePacket->Commit(); |
| 309 | |
| 310 | // Get the readable buffer |
| 311 | packetBuffer = bufferManager.GetReadableBuffer(); |
| 312 | |
| 313 | // Check the packet header |
| 314 | offset = 0; |
| 315 | |
| 316 | // Reading TimelineEventBinaryPacket |
| 317 | uint32_t eventBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); |
| 318 | uint32_t eventBinaryPacketFamily = (eventBinaryPacketHeaderWord0 >> 26) & 0x0000003F; |
| 319 | uint32_t eventBinaryPacketClass = (eventBinaryPacketHeaderWord0 >> 19) & 0x0000007F; |
| 320 | uint32_t eventBinaryPacketType = (eventBinaryPacketHeaderWord0 >> 16) & 0x00000007; |
| 321 | uint32_t eventBinaryPacketStreamId = (eventBinaryPacketHeaderWord0 >> 0) & 0x00000007; |
| 322 | |
| 323 | BOOST_CHECK(eventBinaryPacketFamily == 1); |
| 324 | BOOST_CHECK(eventBinaryPacketClass == 0); |
| 325 | BOOST_CHECK(eventBinaryPacketType == 1); |
| 326 | BOOST_CHECK(eventBinaryPacketStreamId == 0); |
| 327 | |
| 328 | offset += uint32_t_size; |
| 329 | uint32_t eventBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); |
| 330 | uint32_t eventBinaryPacketSequenceNumbered = (eventBinaryPacketHeaderWord1 >> 24) & 0x00000001; |
| 331 | uint32_t eventBinaryPacketDataLength = (eventBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; |
| 332 | BOOST_CHECK(eventBinaryPacketSequenceNumbered == 0); |
| 333 | BOOST_CHECK(eventBinaryPacketDataLength == 24); |
| 334 | |
| 335 | // Check the decl_id |
| 336 | offset += uint32_t_size; |
| 337 | uint32_t eventDeclId = ReadUint32(packetBuffer, offset); |
| 338 | BOOST_CHECK(eventDeclId == 4); |
| 339 | |
| 340 | // Check the timestamp |
| 341 | offset += uint32_t_size; |
| 342 | uint64_t eventTimestamp = ReadUint64(packetBuffer, offset); |
| 343 | BOOST_CHECK(eventTimestamp == timestamp); |
| 344 | |
| 345 | // Check the thread id |
| 346 | offset += uint64_t_size; |
| 347 | uint32_t readThreadId = ReadUint32(packetBuffer, offset); |
| 348 | BOOST_CHECK(readThreadId == threadId); |
| 349 | |
| 350 | // Check the profiling GUID |
| 351 | offset += uint32_t_size; |
| 352 | readProfilingGuid = ReadUint64(packetBuffer, offset); |
| 353 | BOOST_CHECK(readProfilingGuid == eventProfilingGuid); |
| 354 | } |
| 355 | |
| 356 | BOOST_AUTO_TEST_CASE(SendTimelinePacketTests2) |
| 357 | { |
| 358 | MockBufferManager bufferManager(40); |
| 359 | TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); |
| 360 | std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket(); |
| 361 | |
| 362 | BOOST_CHECK_THROW(sendTimelinePacket->SendTimelineMessageDirectoryPackage(), |
| 363 | armnn::RuntimeException); |
| 364 | } |
| 365 | |
| 366 | BOOST_AUTO_TEST_CASE(SendTimelinePacketTests3) |
| 367 | { |
| 368 | MockBufferManager bufferManager(512); |
| 369 | TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); |
| 370 | std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket(); |
| 371 | |
| 372 | // Send TimelineEntityClassBinaryPacket |
| 373 | const uint64_t entityBinaryPacketProfilingGuid = 123456u; |
| 374 | sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid); |
| 375 | |
| 376 | // Commit the buffer |
| 377 | sendTimelinePacket->Commit(); |
| 378 | |
| 379 | // Get the readable buffer |
| 380 | auto packetBuffer = bufferManager.GetReadableBuffer(); |
| 381 | |
| 382 | // Send TimelineEventClassBinaryPacket |
| 383 | const uint64_t eventClassBinaryPacketProfilingGuid = 789123u; |
| 384 | BOOST_CHECK_THROW(sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid), |
| 385 | armnn::RuntimeException); |
| 386 | } |
| 387 | |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 388 | BOOST_AUTO_TEST_CASE(GetGuidsFromProfilingService) |
| 389 | { |
| 390 | armnn::Runtime::CreationOptions::ExternalProfilingOptions options; |
| 391 | options.m_EnableProfiling = true; |
| 392 | ProfilingService& profilingService = ProfilingService::Instance(); |
| 393 | profilingService.ResetExternalProfilingOptions(options, true); |
| 394 | ProfilingStaticGuid staticGuid = profilingService.GenerateStaticId("dummy"); |
| 395 | // TODO when actual value gets generated verify its correctness |
| 396 | ProfilingStaticGuid expectedStaticValue(0); |
| 397 | BOOST_CHECK(staticGuid == expectedStaticValue); |
| 398 | ProfilingDynamicGuid dynamicGuid = profilingService.NextGuid(); |
| 399 | // TODO when actual value gets generated verify its correctness by verifying |
| 400 | // it is in the correct range i.e. > x and that if NextGuid is invoked |
| 401 | // again it is equal to the previous + 1 |
| 402 | ProfilingDynamicGuid expectedDynamicValue(0); |
| 403 | BOOST_CHECK(dynamicGuid == expectedDynamicValue); |
| 404 | } |
| 405 | |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 406 | BOOST_AUTO_TEST_CASE(GetTimelinePackerWriterFromProfilingService) |
| 407 | { |
| 408 | armnn::Runtime::CreationOptions::ExternalProfilingOptions options; |
| 409 | options.m_EnableProfiling = true; |
| 410 | ProfilingService& profilingService = ProfilingService::Instance(); |
| 411 | profilingService.ResetExternalProfilingOptions(options, true); |
| 412 | |
| 413 | std::unique_ptr<ISendTimelinePacket> writer = profilingService.GetSendTimelinePacket(); |
| 414 | BOOST_CHECK(writer != nullptr); |
| 415 | } |
| 416 | |
Sadik Armagan | 7bbdf9d | 2019-10-24 10:26:05 +0100 | [diff] [blame] | 417 | BOOST_AUTO_TEST_SUITE_END() |