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>
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;
+}