diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-03-22 10:59:07 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
commit | 0a560a5c4f6447e2c8b4ba7216abebebe9aea0dd (patch) | |
tree | 503771d9cf331c6bca156193194136015f47e20c | |
parent | 491f9ac3d2579779a0cec3d4d52e19f1ce908bad (diff) | |
download | phosphor-objmgr-0a560a5c4f6447e2c8b4ba7216abebebe9aea0dd.tar.gz phosphor-objmgr-0a560a5c4f6447e2c8b4ba7216abebebe9aea0dd.zip |
unit-test: Fix bug when endpoint empty
Could debate the proper handling of this situations but this commit at
least makes it consistent for the forward and reverse path
Change-Id: If0a8a16473c150f4d4361f9ca9aad9f06c391157
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r-- | src/associations.cpp | 11 | ||||
-rw-r--r-- | src/test/associations.cpp | 8 |
2 files changed, 7 insertions, 12 deletions
diff --git a/src/associations.cpp b/src/associations.cpp index 6982b52..b4c0fae 100644 --- a/src/associations.cpp +++ b/src/associations.cpp @@ -156,18 +156,17 @@ void associationChanged(sdbusplus::asio::object_server& objectServer, std::string endpoint; std::tie(forward, reverse, endpoint) = association; + if (endpoint.empty()) + { + std::cerr << "Found invalid association on path " << path << "\n"; + continue; + } if (forward.size()) { objects[path + "/" + forward].emplace(endpoint); } if (reverse.size()) { - if (endpoint.empty()) - { - std::cerr << "Found invalid association on path " << path - << "\n"; - continue; - } objects[endpoint + "/" + reverse].emplace(path); } } diff --git a/src/test/associations.cpp b/src/test/associations.cpp index 20d7ba7..1b6a348 100644 --- a/src/test/associations.cpp +++ b/src/test/associations.cpp @@ -176,14 +176,10 @@ TEST_F(TestAssociations, associationChangedEmptyEndpoint) associationChanged(*server, associations, DEFAULT_SOURCE_PATH, DEFAULT_DBUS_SVC, assocOwners, assocInterfaces); - // TODO - This test case found a bug where the endpoint validity - // is not checked on the FWD path and is used by default, resulting - // in there being a "" endpoint value. Will fix this in next commit - // to keep the refactor of the code separate from the fix - // (i.e. both of these should be 0 since we have an invalid endpoint) + // Both of these should be 0 since we have an invalid endpoint auto intfEndpoints = std::get<endpointsPos>(assocInterfaces[DEFAULT_FWD_PATH]); - EXPECT_EQ(intfEndpoints.size(), 1); + EXPECT_EQ(intfEndpoints.size(), 0); intfEndpoints = std::get<endpointsPos>(assocInterfaces[DEFAULT_REV_PATH]); EXPECT_EQ(intfEndpoints.size(), 0); } |