diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-02-27 09:46:40 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
commit | 7264d90dca3b7796b305e282aaad7ab19ce933ec (patch) | |
tree | 75e485636e0f2e44eb1d6ffc012fe479becafeda | |
parent | ea80c33dec0e331703e44f0f1d1286138c87cbcf (diff) | |
download | phosphor-objmgr-7264d90dca3b7796b305e282aaad7ab19ce933ec.tar.gz phosphor-objmgr-7264d90dca3b7796b305e282aaad7ab19ce933ec.zip |
unit-test: Debug functions to dump data structures
Visualizing the key data structures in objmgr can be very useful for
debug and for writing test cases
Example output when new function called:
##### interface_map_type #####
------------------------------------
OBJ PATH: /xyz/openbmc_project/test
DBUS SERVICE: xyz.openbmc_project.Test
INTERFACE: org.freedesktop.DBus.Introspectable
INTERFACE: org.freedesktop.DBus.Peer
INTERFACE: org.freedesktop.DBus.Properties
------------------------------------
##### AssociationOwnersType #####
------------------------------------
OBJ PATH: /xyz/openbmc_project/test/xyz
DBUS SERVICE: xyz.openbmc_project.Test
ASSOC PATH: /xyz/openbmc_project/inventory/system/chassis/error
ENDPOINT: /xyz/openbmc_project/test/xyz
ASSOC PATH: /xyz/openbmc_project/test/xyz/inventory
ENDPOINT: /xyz/openbmc_project/inventory/system/chassis
-----------------------------------
##### AssociationInterfaces #####
------------------------------------
OBJ PATH: /xyz/openbmc_project/inventory/system/chassis/error
ENDPOINTS: /xyz/openbmc_project/test/xyz
------------------------------------
Change-Id: I947ccdb071d887683c3998c6020677833579100c
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r-- | src/test/util/debug_output.hpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/test/util/debug_output.hpp b/src/test/util/debug_output.hpp new file mode 100644 index 0000000..460f01f --- /dev/null +++ b/src/test/util/debug_output.hpp @@ -0,0 +1,72 @@ +#include "src/associations.hpp" + +#include <iostream> + +// Some debug functions for dumping out the main data structures in objmgr + +void dump_AssociationOwnersType(AssociationOwnersType& assocOwners) +{ + using namespace std; + cout << "##### AssociationOwnersType #####" << endl; + for (auto i : assocOwners) + { + cout << "------------------------------------" << endl; + cout << setw(15) << left << "OBJ PATH:" << i.first << endl; + + for (auto j : i.second) + { + cout << setw(16) << left << "DBUS SERVICE:" << j.first << endl; + + for (auto k : j.second) + { + cout << setw(17) << left << "ASSOC PATH:" << k.first << endl; + + for (auto l : k.second) + { + cout << setw(18) << left << "ENDPOINT:" << l << endl; + } + } + } + cout << "------------------------------------" << endl; + } +} + +void dump_AssociationInterfaces(AssociationInterfaces& assocInterfaces) +{ + using namespace std; + cout << "##### AssociationInterfaces #####" << endl; + for (auto i : assocInterfaces) + { + cout << "------------------------------------" << endl; + cout << setw(15) << left << "OBJ PATH:" << i.first << endl; + auto intfEndpoints = std::get<endpointsPos>(i.second); + + for (auto k : intfEndpoints) + { + cout << setw(16) << left << "ENDPOINTS:" << k << endl; + } + cout << "------------------------------------" << endl; + } +} + +void dump_InterfaceMapType(interface_map_type& intfMap) +{ + using namespace std; + cout << "##### interface_map_type #####" << endl; + for (auto i : intfMap) + { + cout << "------------------------------------" << endl; + cout << setw(15) << left << "OBJ PATH:" << i.first << endl; + + for (auto j : i.second) + { + cout << setw(16) << left << "DBUS SERVICE:" << j.first << endl; + + for (auto k : j.second) + { + cout << setw(18) << left << "INTERFACE:" << k << endl; + } + } + } + cout << "------------------------------------" << endl; +} |