libpldm: add API to create entity association PDR

This commit adds an API to make entity association PDR records out of an
input entity association tree (implemented in the previous commit).

Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: Ida7fa5a3040ee14f46da98fff021b6cb8e40b4c4
diff --git a/libpldm/pdr.c b/libpldm/pdr.c
index f2d4aa1..c93bb58 100644
--- a/libpldm/pdr.c
+++ b/libpldm/pdr.c
@@ -470,3 +470,119 @@
 
 	return node->first_child != NULL;
 }
+
+uint8_t pldm_entity_get_num_children(pldm_entity_node *node,
+				     uint8_t association_type)
+{
+	assert(node != NULL);
+	assert(association_type == PLDM_ENTITY_ASSOCIAION_PHYSICAL ||
+	       association_type == PLDM_ENTITY_ASSOCIAION_LOGICAL);
+
+	size_t count = 0;
+	pldm_entity_node *curr = node->first_child;
+	while (curr != NULL) {
+		if (curr->association_type == association_type) {
+			++count;
+		}
+		curr = curr->next_sibling;
+	}
+
+	assert(count < UINT8_MAX);
+	return count;
+}
+
+static void _entity_association_pdr_add_entry(pldm_entity_node *curr,
+					      pldm_pdr *repo, uint16_t size,
+					      uint8_t contained_count,
+					      uint8_t association_type)
+{
+	uint8_t pdr[size];
+	uint8_t *start = pdr;
+
+	struct pldm_pdr_hdr *hdr = (struct pldm_pdr_hdr *)start;
+	hdr->version = 1;
+	hdr->record_handle = 0;
+	hdr->type = PLDM_PDR_ENTITY_ASSOCIATION;
+	hdr->record_change_num = 0;
+	hdr->length = size - sizeof(struct pldm_pdr_hdr);
+	start += sizeof(struct pldm_pdr_hdr);
+
+	uint16_t *container_id = (uint16_t *)start;
+	*container_id = curr->first_child->entity.entity_container_id;
+	start += sizeof(uint16_t);
+	*start = association_type;
+	start += sizeof(uint8_t);
+
+	pldm_entity *entity = (pldm_entity *)start;
+	entity->entity_type = curr->entity.entity_type;
+	entity->entity_instance_num = curr->entity.entity_instance_num;
+	entity->entity_container_id = curr->entity.entity_container_id;
+	start += sizeof(pldm_entity);
+
+	*start = contained_count;
+	start += sizeof(uint8_t);
+
+	pldm_entity_node *node = curr->first_child;
+	while (node != NULL) {
+		if (node->association_type == association_type) {
+			pldm_entity *entity = (pldm_entity *)start;
+			entity->entity_type = node->entity.entity_type;
+			entity->entity_instance_num =
+			    node->entity.entity_instance_num;
+			entity->entity_container_id =
+			    node->entity.entity_container_id;
+			start += sizeof(pldm_entity);
+		}
+		node = node->next_sibling;
+	}
+
+	pldm_pdr_add(repo, pdr, size, 0);
+}
+
+static void entity_association_pdr_add_entry(pldm_entity_node *curr,
+					     pldm_pdr *repo)
+{
+	uint8_t num_logical_children =
+	    pldm_entity_get_num_children(curr, PLDM_ENTITY_ASSOCIAION_LOGICAL);
+	uint8_t num_physical_children =
+	    pldm_entity_get_num_children(curr, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+
+	if (num_logical_children) {
+		uint16_t logical_pdr_size =
+		    sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
+		    sizeof(uint8_t) + sizeof(pldm_entity) + sizeof(uint8_t) +
+		    (num_logical_children * sizeof(pldm_entity));
+		_entity_association_pdr_add_entry(
+		    curr, repo, logical_pdr_size, num_logical_children,
+		    PLDM_ENTITY_ASSOCIAION_LOGICAL);
+	}
+
+	if (num_physical_children) {
+		uint16_t physical_pdr_size =
+		    sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
+		    sizeof(uint8_t) + sizeof(pldm_entity) + sizeof(uint8_t) +
+		    (num_physical_children * sizeof(pldm_entity));
+		_entity_association_pdr_add_entry(
+		    curr, repo, physical_pdr_size, num_physical_children,
+		    PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+	}
+}
+
+static void entity_association_pdr_add(pldm_entity_node *curr, pldm_pdr *repo)
+{
+	if (curr == NULL) {
+		return;
+	}
+	entity_association_pdr_add_entry(curr, repo);
+	entity_association_pdr_add(curr->next_sibling, repo);
+	entity_association_pdr_add(curr->first_child, repo);
+}
+
+void pldm_entity_association_pdr_add(pldm_entity_association_tree *tree,
+				     pldm_pdr *repo)
+{
+	assert(tree != NULL);
+	assert(repo != NULL);
+
+	entity_association_pdr_add(tree->root, repo);
+}
diff --git a/libpldm/pdr.h b/libpldm/pdr.h
index 0e5690d..c08dc59 100644
--- a/libpldm/pdr.h
+++ b/libpldm/pdr.h
@@ -188,7 +188,7 @@
 
 enum entity_association_containment_type {
 	PLDM_ENTITY_ASSOCIAION_PHYSICAL = 0x0,
-	PLDM_ENTITY_ASSOCIAION_LOGICAL = 0x1
+	PLDM_ENTITY_ASSOCIAION_LOGICAL = 0x1,
 };
 
 /** @struct pldm_entity_association_tree
@@ -249,6 +249,24 @@
  */
 bool pldm_entity_is_node_parent(pldm_entity_node *node);
 
+/** @brief Convert entity association tree to PDR
+ *
+ *  @param[in] tree - opaque pointer to entity association tree
+ *  @param[in] repo - PDR repo where entity association records should be added
+ */
+void pldm_entity_association_pdr_add(pldm_entity_association_tree *tree,
+				     pldm_pdr *repo);
+
+/** @brief Get number of children of entity
+ *
+ *  @param[in] node - opaque pointer acting as a handle to an entity node
+ *  @param[in] association_type - relation type filter : logical or physical
+ *
+ *  @return uint8_t number of children
+ */
+uint8_t pldm_entity_get_num_children(pldm_entity_node *node,
+				     uint8_t association_type);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/libpldm/platform.h b/libpldm/platform.h
index 0371d1c..adb6d90 100644
--- a/libpldm/platform.h
+++ b/libpldm/platform.h
@@ -73,6 +73,7 @@
  */
 enum pldm_pdr_types {
 	PLDM_STATE_EFFECTER_PDR = 11,
+	PLDM_PDR_ENTITY_ASSOCIATION = 15,
 	PLDM_PDR_FRU_RECORD_SET = 20,
 };
 
diff --git a/libpldm/tests/libpldm_pdr_test.cpp b/libpldm/tests/libpldm_pdr_test.cpp
index cad64fc..9dd172b 100644
--- a/libpldm/tests/libpldm_pdr_test.cpp
+++ b/libpldm/tests/libpldm_pdr_test.cpp
@@ -539,3 +539,313 @@
     free(out);
     pldm_entity_association_tree_destroy(tree);
 }
+
+TEST(EntityAssociationPDR, testPDR)
+{
+    // e = entity type, c = container id, i = instance num
+
+    //        INPUT
+    //        1(e=1)--1a(e=2)
+    //        |
+    //        2(e=2)--3(e=2)--4(e=2)--5(e=3)
+    //        |
+    //        6(e=4)--7(e=5)--8(e=5)--9(e=5)
+    //        |       |
+    //        11(e=6) 10(e=7)
+
+    //        Expected OUTPUT
+    //        1(e=1,c=0,i=1)
+    //        |
+    //        2(e=2,c=1,i=1)--3(e=2,c=1,i=2)--4(e=3,c=1,i=1)--5(e=3,c=1,i=2)
+    //        |
+    //        6(e=4,c=2,i=1)--7(e=5,c=2,i=1)--8(e=5,c=2,i=2)--9(e=5,c=2,i=3)
+    //        |               |
+    //        10(e=6,c=3,i=1) 11(e=7,c=4,i=1)
+    pldm_entity entities[11]{};
+
+    entities[0].entity_type = 1;
+    entities[1].entity_type = 2;
+    entities[2].entity_type = 3;
+    entities[3].entity_type = 2;
+    entities[4].entity_type = 3;
+    entities[5].entity_type = 4;
+    entities[6].entity_type = 5;
+    entities[7].entity_type = 5;
+    entities[8].entity_type = 5;
+    entities[9].entity_type = 6;
+    entities[10].entity_type = 7;
+
+    auto tree = pldm_entity_association_tree_init();
+
+    auto l1 = pldm_entity_association_tree_add(tree, &entities[0], nullptr,
+                                               PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l1, nullptr);
+    auto l1a = pldm_entity_association_tree_add(
+        tree, &entities[1], nullptr, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l1a, nullptr);
+
+    auto l2a = pldm_entity_association_tree_add(
+        tree, &entities[1], l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l2a, nullptr);
+    auto l2b = pldm_entity_association_tree_add(tree, &entities[2], l1,
+                                                PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    EXPECT_NE(l2b, nullptr);
+    auto l2c = pldm_entity_association_tree_add(
+        tree, &entities[3], l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l2c, nullptr);
+    auto l2d = pldm_entity_association_tree_add(tree, &entities[4], l1,
+                                                PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    EXPECT_NE(l2d, nullptr);
+
+    auto l3a = pldm_entity_association_tree_add(
+        tree, &entities[5], l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l3a, nullptr);
+    auto l3b = pldm_entity_association_tree_add(
+        tree, &entities[6], l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l3b, nullptr);
+    auto l3c = pldm_entity_association_tree_add(tree, &entities[7], l2a,
+                                                PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    EXPECT_NE(l3c, nullptr);
+    auto l3d = pldm_entity_association_tree_add(tree, &entities[8], l2a,
+                                                PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    EXPECT_NE(l3d, nullptr);
+
+    auto l4a = pldm_entity_association_tree_add(
+        tree, &entities[9], l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    EXPECT_NE(l4a, nullptr);
+    auto l4b = pldm_entity_association_tree_add(tree, &entities[10], l3b,
+                                                PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    EXPECT_NE(l4b, nullptr);
+
+    EXPECT_EQ(pldm_entity_get_num_children(l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL),
+              2);
+    EXPECT_EQ(pldm_entity_get_num_children(l1, PLDM_ENTITY_ASSOCIAION_LOGICAL),
+              2);
+    EXPECT_EQ(
+        pldm_entity_get_num_children(l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL), 2);
+    EXPECT_EQ(
+        pldm_entity_get_num_children(l3b, PLDM_ENTITY_ASSOCIAION_PHYSICAL), 0);
+    EXPECT_EQ(pldm_entity_get_num_children(l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL),
+              1);
+
+    auto repo = pldm_pdr_init();
+    pldm_entity_association_pdr_add(tree, repo);
+
+    EXPECT_EQ(pldm_pdr_get_record_count(repo), 6);
+
+    uint32_t currRecHandle{};
+    uint32_t nextRecHandle{};
+    uint8_t* data = nullptr;
+    uint32_t size{};
+    uint32_t commonSize = sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t) +
+                          sizeof(uint8_t) + sizeof(pldm_entity) +
+                          sizeof(uint8_t);
+
+    pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle);
+    EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children(
+                                      l1, PLDM_ENTITY_ASSOCIAION_LOGICAL) *
+                                  sizeof(pldm_entity)));
+    uint8_t* start = data;
+    pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
+    EXPECT_EQ(hdr->record_handle, 1);
+    EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION);
+    EXPECT_EQ(hdr->length, size - sizeof(struct pldm_pdr_hdr));
+    start += sizeof(pldm_pdr_hdr);
+    uint16_t* containerId = reinterpret_cast<uint16_t*>(start);
+    EXPECT_EQ(*containerId, 1);
+    start += sizeof(uint16_t);
+    EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    start += sizeof(uint8_t);
+    pldm_entity* entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 1);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 0);
+    start += sizeof(pldm_entity);
+    EXPECT_EQ(*start,
+              pldm_entity_get_num_children(l1, PLDM_ENTITY_ASSOCIAION_LOGICAL));
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 3);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 1);
+    start += sizeof(pldm_entity);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 3);
+    EXPECT_EQ(entity->entity_instance_num, 2);
+    EXPECT_EQ(entity->entity_container_id, 1);
+    start += sizeof(pldm_entity);
+
+    currRecHandle = nextRecHandle;
+
+    pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle);
+    EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children(
+                                      l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL) *
+                                  sizeof(pldm_entity)));
+    start = data;
+    hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
+    EXPECT_EQ(hdr->record_handle, 2);
+    EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION);
+    EXPECT_EQ(hdr->length, size - sizeof(struct pldm_pdr_hdr));
+    start += sizeof(pldm_pdr_hdr);
+    containerId = reinterpret_cast<uint16_t*>(start);
+    EXPECT_EQ(*containerId, 1);
+    start += sizeof(uint16_t);
+    EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 1);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 0);
+    start += sizeof(pldm_entity);
+    EXPECT_EQ(*start, pldm_entity_get_num_children(
+                          l1, PLDM_ENTITY_ASSOCIAION_PHYSICAL));
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 2);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 1);
+    start += sizeof(pldm_entity);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 2);
+    EXPECT_EQ(entity->entity_instance_num, 2);
+    EXPECT_EQ(entity->entity_container_id, 1);
+    start += sizeof(pldm_entity);
+
+    currRecHandle = nextRecHandle;
+
+    pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle);
+    EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children(
+                                      l2a, PLDM_ENTITY_ASSOCIAION_LOGICAL) *
+                                  sizeof(pldm_entity)));
+    start = data;
+    hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
+    EXPECT_EQ(hdr->record_handle, 3);
+    EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION);
+    EXPECT_EQ(hdr->length, size - sizeof(struct pldm_pdr_hdr));
+    start += sizeof(pldm_pdr_hdr);
+    containerId = reinterpret_cast<uint16_t*>(start);
+    EXPECT_EQ(*containerId, 2);
+    start += sizeof(uint16_t);
+    EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 2);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 1);
+    start += sizeof(pldm_entity);
+    EXPECT_EQ(*start, pldm_entity_get_num_children(
+                          l2a, PLDM_ENTITY_ASSOCIAION_LOGICAL));
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 5);
+    EXPECT_EQ(entity->entity_instance_num, 2);
+    EXPECT_EQ(entity->entity_container_id, 2);
+    start += sizeof(pldm_entity);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 5);
+    EXPECT_EQ(entity->entity_instance_num, 3);
+    EXPECT_EQ(entity->entity_container_id, 2);
+    start += sizeof(pldm_entity);
+
+    currRecHandle = nextRecHandle;
+
+    pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle);
+    EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children(
+                                      l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL) *
+                                  sizeof(pldm_entity)));
+    start = data;
+    hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
+    EXPECT_EQ(hdr->record_handle, 4);
+    EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION);
+    EXPECT_EQ(hdr->length, size - sizeof(struct pldm_pdr_hdr));
+    start += sizeof(pldm_pdr_hdr);
+    containerId = reinterpret_cast<uint16_t*>(start);
+    EXPECT_EQ(*containerId, 2);
+    start += sizeof(uint16_t);
+    EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 2);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 1);
+    start += sizeof(pldm_entity);
+    EXPECT_EQ(*start, pldm_entity_get_num_children(
+                          l2a, PLDM_ENTITY_ASSOCIAION_PHYSICAL));
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 4);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 2);
+    start += sizeof(pldm_entity);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 5);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 2);
+    start += sizeof(pldm_entity);
+
+    currRecHandle = nextRecHandle;
+
+    pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle);
+    EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children(
+                                      l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL) *
+                                  sizeof(pldm_entity)));
+    start = data;
+    hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
+    EXPECT_EQ(hdr->record_handle, 5);
+    EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION);
+    EXPECT_EQ(hdr->length, size - sizeof(struct pldm_pdr_hdr));
+    start += sizeof(pldm_pdr_hdr);
+    containerId = reinterpret_cast<uint16_t*>(start);
+    EXPECT_EQ(*containerId, 3);
+    start += sizeof(uint16_t);
+    EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_PHYSICAL);
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 4);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 2);
+    start += sizeof(pldm_entity);
+    EXPECT_EQ(*start, pldm_entity_get_num_children(
+                          l3a, PLDM_ENTITY_ASSOCIAION_PHYSICAL));
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 6);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 3);
+    start += sizeof(pldm_entity);
+
+    currRecHandle = nextRecHandle;
+
+    pldm_pdr_find_record(repo, currRecHandle, &data, &size, &nextRecHandle);
+    EXPECT_EQ(size, commonSize + (pldm_entity_get_num_children(
+                                      l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL) *
+                                  sizeof(pldm_entity)));
+    start = data;
+    hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
+    EXPECT_EQ(hdr->record_handle, 6);
+    EXPECT_EQ(hdr->type, PLDM_PDR_ENTITY_ASSOCIATION);
+    EXPECT_EQ(hdr->length, size - sizeof(struct pldm_pdr_hdr));
+    start += sizeof(pldm_pdr_hdr);
+    containerId = reinterpret_cast<uint16_t*>(start);
+    EXPECT_EQ(*containerId, 4);
+    start += sizeof(uint16_t);
+    EXPECT_EQ(*start, PLDM_ENTITY_ASSOCIAION_LOGICAL);
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 5);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 2);
+    start += sizeof(pldm_entity);
+    EXPECT_EQ(*start, pldm_entity_get_num_children(
+                          l3b, PLDM_ENTITY_ASSOCIAION_LOGICAL));
+    start += sizeof(uint8_t);
+    entity = reinterpret_cast<pldm_entity*>(start);
+    EXPECT_EQ(entity->entity_type, 7);
+    EXPECT_EQ(entity->entity_instance_num, 1);
+    EXPECT_EQ(entity->entity_container_id, 4);
+
+    EXPECT_EQ(nextRecHandle, 0);
+
+    pldm_pdr_destroy(repo);
+    pldm_entity_association_tree_destroy(tree);
+}