aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/test/TimelineUtilityMethodsTests.cpp
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-10-30 12:48:31 +0000
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-30 17:36:27 +0000
commit94a3088479694ee1dfdd2e321a353ffcc79f4126 (patch)
treeec92c438c1f7b8d16fd57c21fa36b372d08c4e70 /src/profiling/test/TimelineUtilityMethodsTests.cpp
parentd034e087d9b48a7541aa588b5cad1373693a8e95 (diff)
downloadarmnn-94a3088479694ee1dfdd2e321a353ffcc79f4126.tar.gz
IVGCVSW-4037 Add a CreateNamedTypedChildEntity method
* Added new method to the TimelineUtilityMethods class * Added unit tests * Code refactoring * Skipped the 0 when generating a dynamic GUID for testing purposes Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: Ic2c8033ad010e07b0f8b7971ce653263e21c6f97
Diffstat (limited to 'src/profiling/test/TimelineUtilityMethodsTests.cpp')
-rw-r--r--src/profiling/test/TimelineUtilityMethodsTests.cpp101
1 files changed, 93 insertions, 8 deletions
diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp
index 6c5ce634a4..c2be6e5c46 100644
--- a/src/profiling/test/TimelineUtilityMethodsTests.cpp
+++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp
@@ -231,9 +231,9 @@ void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationsh
offset += uint64_t_size;
}
-void VerifyTimelineEntityPacket(Optional<ProfilingGuid> guid,
- const unsigned char* readableData,
- unsigned int& offset)
+void VerifyTimelineEntityBinaryPacket(Optional<ProfilingGuid> guid,
+ const unsigned char* readableData,
+ unsigned int& offset)
{
BOOST_ASSERT(readableData);
@@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE(SendWellKnownLabelsAndEventClassesTest)
readableData,
offset);
- // First "well-known" event class: END OF LIFE
+ // Second "well-known" event class: END OF LIFE
VerifyTimelineEventClassBinaryPacket(LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
readableData,
offset);
@@ -389,6 +389,94 @@ BOOST_AUTO_TEST_CASE(SendWellKnownLabelsAndEventClassesTest)
mockBufferManager.MarkRead(readableBuffer);
}
+BOOST_AUTO_TEST_CASE(CreateNamedTypedChildEntityTest)
+{
+ MockBufferManager mockBufferManager(1024);
+ SendTimelinePacket sendTimelinePacket(mockBufferManager);
+ TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
+
+ ProfilingGuid parentEntityGuid(123);
+ const std::string entityName = "some entity";
+ const std::string entityType = "some type";
+
+ BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, "", entityType),
+ InvalidArgumentException);
+ BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, entityName, ""),
+ InvalidArgumentException);
+
+ ProfilingGuid childEntityGuid(0);
+ BOOST_CHECK_NO_THROW(childEntityGuid = timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
+ entityName,
+ entityType));
+ BOOST_CHECK(childEntityGuid != ProfilingGuid(0));
+
+ // Commit all packets at once
+ sendTimelinePacket.Commit();
+
+ // Get the readable buffer
+ auto readableBuffer = mockBufferManager.GetReadableBuffer();
+ BOOST_CHECK(readableBuffer != nullptr);
+ unsigned int size = readableBuffer->GetSize();
+ BOOST_CHECK(size == 292);
+ const unsigned char* readableData = readableBuffer->GetReadableData();
+ BOOST_CHECK(readableData != nullptr);
+
+ // Utils
+ unsigned int offset = 0;
+
+ // First packet sent: TimelineEntityBinaryPacket
+ VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset);
+
+ // Second packet sent: TimelineLabelBinaryPacket
+ VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityName, readableData, offset);
+
+ // Third packet sent: TimelineRelationshipBinaryPacket
+ VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink,
+ EmptyOptional(),
+ EmptyOptional(),
+ EmptyOptional(),
+ readableData,
+ offset);
+
+ // Fourth packet sent: TimelineRelationshipBinaryPacket
+ VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink,
+ EmptyOptional(),
+ EmptyOptional(),
+ LabelsAndEventClasses::NAME_GUID,
+ readableData,
+ offset);
+
+ // Fifth packet sent: TimelineLabelBinaryPacket
+ VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityType, readableData, offset);
+
+ // Sixth packet sent: TimelineRelationshipBinaryPacket
+ VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink,
+ EmptyOptional(),
+ EmptyOptional(),
+ EmptyOptional(),
+ readableData,
+ offset);
+
+ // Seventh packet sent: TimelineRelationshipBinaryPacket
+ VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink,
+ EmptyOptional(),
+ EmptyOptional(),
+ LabelsAndEventClasses::TYPE_GUID,
+ readableData,
+ offset);
+
+ // Eighth packet sent: TimelineRelationshipBinaryPacket
+ VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink,
+ EmptyOptional(),
+ parentEntityGuid,
+ EmptyOptional(),
+ readableData,
+ offset);
+
+ // Mark the buffer as read
+ mockBufferManager.MarkRead(readableBuffer);
+}
+
BOOST_AUTO_TEST_CASE(DeclareLabelTest)
{
MockBufferManager mockBufferManager(1024);
@@ -439,9 +527,6 @@ BOOST_AUTO_TEST_CASE(CreateNameTypeEntitylTest)
const std::string entityName = "Entity0";
const std::string entityType = "Type0";
- // Generate first guid to ensure that the named typed entity guid is not 0 on local single test.
- ProfilingService::Instance().NextGuid();
-
ProfilingDynamicGuid guid = timelineUtilityMethods.CreateNamedTypedEntity(entityName, entityType);
BOOST_CHECK(guid != ProfilingGuid(0));
@@ -460,7 +545,7 @@ BOOST_AUTO_TEST_CASE(CreateNameTypeEntitylTest)
unsigned int offset = 0;
// First packet sent: TimelineEntityBinaryPacket
- VerifyTimelineEntityPacket(guid, readableData, offset);
+ VerifyTimelineEntityBinaryPacket(guid, readableData, offset);
// Packets for Name Entity
// First packet sent: TimelineLabelBinaryPacket