summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Geissler <geissonator@yahoo.com>2019-02-21 15:07:27 -0600
committerMatt Spinler <spinler@us.ibm.com>2019-04-05 15:05:32 +0000
commite4ab6c90baf1e32df55a729055d9a5838905ad0d (patch)
tree5f60d0cd70d2f987564d79b4008f5a19eac11a22
parent7f1c44dc342662987086519c256fed6ba4d0d764 (diff)
downloadphosphor-objmgr-e4ab6c90baf1e32df55a729055d9a5838905ad0d.tar.gz
phosphor-objmgr-e4ab6c90baf1e32df55a729055d9a5838905ad0d.zip
unit-test: Test checkAssociationEndpointRemoves()
Testing: 100% coverage of associations.cpp Change-Id: I311af1c868416e8e898a25e593d399cd8297ccf9 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r--src/test/associations.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/test/associations.cpp b/src/test/associations.cpp
index 8edb0de..8b2fadf 100644
--- a/src/test/associations.cpp
+++ b/src/test/associations.cpp
@@ -96,3 +96,69 @@ TEST_F(TestAssociations, PathIsInAssociatedInterfacesExtraEndpoints)
intfEndpoints = std::get<endpointsPos>(assocInterfaces[DEFAULT_REV_PATH]);
EXPECT_EQ(intfEndpoints.size(), 0);
}
+
+// Verify no associations or endpoints removed when the change is identical
+TEST_F(TestAssociations, checkAssociationEndpointRemovesNoEpRemove)
+{
+
+ AssociationPaths newAssocPaths = {
+ {DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT}},
+ {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH}}};
+
+ auto assocOwners = createDefaultOwnerAssociation();
+ auto assocInterfaces = createDefaultInterfaceAssociation(server);
+
+ checkAssociationEndpointRemoves(DEFAULT_SOURCE_PATH, DEFAULT_DBUS_SVC,
+ newAssocPaths, *server, assocOwners,
+ assocInterfaces);
+
+ // Verify endpoints were not deleted because they matche with what was
+ // in the original
+ auto intfEndpoints =
+ std::get<endpointsPos>(assocInterfaces[DEFAULT_FWD_PATH]);
+ EXPECT_EQ(intfEndpoints.size(), 1);
+ intfEndpoints = std::get<endpointsPos>(assocInterfaces[DEFAULT_REV_PATH]);
+ EXPECT_EQ(intfEndpoints.size(), 1);
+}
+
+// Verify endpoint is removed when assoc path is different
+TEST_F(TestAssociations, checkAssociationEndpointRemovesEpRemoveApDiff)
+{
+ AssociationPaths newAssocPaths = {{"/different/path", {DEFAULT_ENDPOINT}}};
+
+ auto assocOwners = createDefaultOwnerAssociation();
+ auto assocInterfaces = createDefaultInterfaceAssociation(server);
+
+ checkAssociationEndpointRemoves(DEFAULT_SOURCE_PATH, DEFAULT_DBUS_SVC,
+ newAssocPaths, *server, assocOwners,
+ assocInterfaces);
+
+ // Verify initial endpoints were deleted because the new path
+ auto intfEndpoints =
+ std::get<endpointsPos>(assocInterfaces[DEFAULT_FWD_PATH]);
+ EXPECT_EQ(intfEndpoints.size(), 0);
+ intfEndpoints = std::get<endpointsPos>(assocInterfaces[DEFAULT_REV_PATH]);
+ EXPECT_EQ(intfEndpoints.size(), 0);
+}
+
+// Verify endpoint is removed when endpoint is different
+TEST_F(TestAssociations, checkAssociationEndpointRemovesEpRemoveEpChanged)
+{
+ AssociationPaths newAssocPaths = {
+ {DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT + "/different"}},
+ {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH + "/different"}}};
+
+ auto assocOwners = createDefaultOwnerAssociation();
+ auto assocInterfaces = createDefaultInterfaceAssociation(server);
+
+ checkAssociationEndpointRemoves(DEFAULT_SOURCE_PATH, DEFAULT_DBUS_SVC,
+ newAssocPaths, *server, assocOwners,
+ assocInterfaces);
+
+ // Verify initial endpoints were deleted because of different endpoints
+ auto intfEndpoints =
+ std::get<endpointsPos>(assocInterfaces[DEFAULT_FWD_PATH]);
+ EXPECT_EQ(intfEndpoints.size(), 0);
+ intfEndpoints = std::get<endpointsPos>(assocInterfaces[DEFAULT_REV_PATH]);
+ EXPECT_EQ(intfEndpoints.size(), 0);
+}
OpenPOWER on IntegriCloud