diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-02-27 10:14:31 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
commit | 7f838376084fb8f5c00b8926013891cb58389033 (patch) | |
tree | 9c00f8498eacd99f61336506d9a6cad8923909ec | |
parent | 70461896775208bbe400cc23786ce4d17a0c07f7 (diff) | |
download | phosphor-objmgr-7f838376084fb8f5c00b8926013891cb58389033.tar.gz phosphor-objmgr-7f838376084fb8f5c00b8926013891cb58389033.zip |
unit-test: Test interfaces added function
Tested:
- processing.cpp at 94% coverage
- Verified QEMU booted to standby and mapper command line worked
- Verified hardware CI (witherspoon) passed with this patch series
Change-Id: I73e5feb3495ed0aa974acd521fefd8d0193fc1b3
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r-- | src/test/Makefile.am.include | 6 | ||||
-rw-r--r-- | src/test/interfaces_added.cpp | 57 |
2 files changed, 62 insertions, 1 deletions
diff --git a/src/test/Makefile.am.include b/src/test/Makefile.am.include index 394c610..0ca04b8 100644 --- a/src/test/Makefile.am.include +++ b/src/test/Makefile.am.include @@ -10,8 +10,12 @@ src_test_associations_SOURCES = %reldir%/associations.cpp \ src_test_name_change_SOURCES = %reldir%/name_change.cpp \ src/associations.cpp src/processing.cpp +src_test_interfaces_added_SOURCES = %reldir%/interfaces_added.cpp \ + src/associations.cpp src/processing.cpp + check_PROGRAMS += \ %reldir%/well_known \ %reldir%/need_to_introspect \ %reldir%/associations \ - %reldir%/name_change + %reldir%/name_change \ + %reldir%/interfaces_added diff --git a/src/test/interfaces_added.cpp b/src/test/interfaces_added.cpp new file mode 100644 index 0000000..6fbeead --- /dev/null +++ b/src/test/interfaces_added.cpp @@ -0,0 +1,57 @@ +#include "src/processing.hpp" +#include "src/test/util/asio_server_class.hpp" +#include "src/test/util/association_objects.hpp" +#include "src/test/util/debug_output.hpp" + +#include <sdbusplus/asio/connection.hpp> +#include <sdbusplus/asio/object_server.hpp> + +#include <gtest/gtest.h> + +class TestInterfacesAdded : public AsioServerClassTest +{ +}; +sdbusplus::asio::object_server* + TestInterfacesAdded::AsioServerClassTest::server = nullptr; + +// This is the data structure that comes in via the InterfacesAdded +// signal +InterfacesAdded createInterfacesAdded() +{ + std::vector<Association> associations = { + {"inventory", "error", + "/xyz/openbmc_project/inventory/system/chassis"}}; + sdbusplus::message::variant<std::vector<Association>> sdbVecAssoc = { + associations}; + std::vector<std::pair< + std::string, sdbusplus::message::variant<std::vector<Association>>>> + vecMethToAssoc = {{"associations", sdbVecAssoc}}; + InterfacesAdded intfAdded = {{ASSOCIATIONS_INTERFACE, vecMethToAssoc}}; + return intfAdded; +} + +// Verify good path of interfaces added function +TEST_F(TestInterfacesAdded, InterfacesAddedGoodPath) +{ + interface_map_type interfaceMap; + AssociationOwnersType assocOwners; + AssociationInterfaces assocInterfaces; + auto intfAdded = createInterfacesAdded(); + + processInterfaceAdded(interfaceMap, DEFAULT_SOURCE_PATH, intfAdded, + DEFAULT_DBUS_SVC, assocOwners, assocInterfaces, + *server); + + // Interface map will get the following: + // /logging/entry/1 /logging/entry /logging/ / + // dump_InterfaceMapType(interfaceMap); + EXPECT_EQ(interfaceMap.size(), 4); + + // New association ower created so ensure it now contains a single entry + // dump_AssociationOwnersType(assocOwners); + EXPECT_EQ(assocOwners.size(), 1); + + // Ensure the 2 association interfaces were created + // dump_AssociationInterfaces(assocInterfaces); + EXPECT_EQ(assocInterfaces.size(), 2); +} |