summaryrefslogtreecommitdiffstats
path: root/test/test.cpp
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-29 10:32:41 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-29 10:33:05 -0400
commit615b2a8f8cc0cffc5773cb40f7f3d74b8ea1e81f (patch)
tree4d5e6426c3ae5074152a787abe38d033e7cbad2b /test/test.cpp
parent6211a430c196bcecbefb9bf52ab99e372e6006a8 (diff)
downloadphosphor-inventory-manager-615b2a8f8cc0cffc5773cb40f7f3d74b8ea1e81f.tar.gz
phosphor-inventory-manager-615b2a8f8cc0cffc5773cb40f7f3d74b8ea1e81f.zip
Enable clang-format
Fix up problems and enable clang-format during CI builds. Change-Id: Ia5c88281f7090c0aa09ba586d968f1fcd8aba4f1 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'test/test.cpp')
-rw-r--r--test/test.cpp652
1 files changed, 298 insertions, 354 deletions
diff --git a/test/test.cpp b/test/test.cpp
index 5d89f0d..5cadbe0 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -35,16 +35,16 @@ constexpr auto MGR_ROOT = "/testing/inventory";
constexpr auto EXAMPLE_SERVICE = "phosphor.inventory.test.example";
constexpr auto EXAMPLE_ROOT = "/testing";
-const auto trigger1 = sdbusplus::message::object_path(EXAMPLE_ROOT +
- "/trigger1"s);
-const auto trigger2 = sdbusplus::message::object_path(EXAMPLE_ROOT +
- "/trigger2"s);
-const auto trigger3 = sdbusplus::message::object_path(EXAMPLE_ROOT +
- "/trigger3"s);
-const auto trigger4 = sdbusplus::message::object_path(EXAMPLE_ROOT +
- "/trigger4"s);
-const auto trigger5 = sdbusplus::message::object_path(EXAMPLE_ROOT +
- "/trigger5"s);
+const auto trigger1 =
+ sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger1"s);
+const auto trigger2 =
+ sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger2"s);
+const auto trigger3 =
+ sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger3"s);
+const auto trigger4 =
+ sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger4"s);
+const auto trigger5 =
+ sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger5"s);
const sdbusplus::message::object_path relDeleteMeOne{"/deleteme1"};
const sdbusplus::message::object_path relDeleteMeTwo{"/deleteme2"};
@@ -65,8 +65,7 @@ struct ExampleService
{
~ExampleService() = default;
ExampleService() :
- shutdown(false),
- bus(sdbusplus::bus::new_default()),
+ shutdown(false), bus(sdbusplus::bus::new_default()),
objmgr(sdbusplus::server::manager::manager(bus, MGR_ROOT))
{
bus.request_name(EXAMPLE_SERVICE);
@@ -74,16 +73,16 @@ struct ExampleService
void run()
{
- sdbusplus::server::object::object <
- ExampleIface1, ExampleIface2 > t1(bus, trigger1.str.c_str());
- sdbusplus::server::object::object <
- ExampleIface1, ExampleIface2 > t2(bus, trigger2.str.c_str());
- sdbusplus::server::object::object <
- ExampleIface1, ExampleIface2 > t3(bus, trigger3.str.c_str());
- sdbusplus::server::object::object <
- ExampleIface1, ExampleIface2 > t4(bus, trigger4.str.c_str());
- sdbusplus::server::object::object <
- ExampleIface1, ExampleIface2 > t5(bus, trigger5.str.c_str());
+ sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t1(
+ bus, trigger1.str.c_str());
+ sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t2(
+ bus, trigger2.str.c_str());
+ sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t3(
+ bus, trigger3.str.c_str());
+ sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t4(
+ bus, trigger4.str.c_str());
+ sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t5(
+ bus, trigger5.str.c_str());
while (!shutdown)
{
@@ -97,62 +96,56 @@ struct ExampleService
sdbusplus::server::manager::manager objmgr;
};
-
/** @class SignalQueue
* @brief Store DBus signals in a queue.
*/
class SignalQueue
{
- public:
- ~SignalQueue() = default;
- SignalQueue() = delete;
- SignalQueue(const SignalQueue&) = delete;
- SignalQueue(SignalQueue&&) = default;
- SignalQueue& operator=(const SignalQueue&) = delete;
- SignalQueue& operator=(SignalQueue&&) = default;
- explicit SignalQueue(const std::string& match) :
- _bus(sdbusplus::bus::new_default()),
- _match(_bus, match.c_str(), &callback, this),
- _next(nullptr)
- {
- }
+ public:
+ ~SignalQueue() = default;
+ SignalQueue() = delete;
+ SignalQueue(const SignalQueue&) = delete;
+ SignalQueue(SignalQueue&&) = default;
+ SignalQueue& operator=(const SignalQueue&) = delete;
+ SignalQueue& operator=(SignalQueue&&) = default;
+ explicit SignalQueue(const std::string& match) :
+ _bus(sdbusplus::bus::new_default()),
+ _match(_bus, match.c_str(), &callback, this), _next(nullptr)
+ {
+ }
- auto&& pop(unsigned timeout = 1000000)
+ auto&& pop(unsigned timeout = 1000000)
+ {
+ while (timeout > 0 && !_next)
{
- while (timeout > 0 && !_next)
- {
- _bus.process_discard();
- _bus.wait(50000);
- timeout -= 50000;
- }
- return std::move(_next);
+ _bus.process_discard();
+ _bus.wait(50000);
+ timeout -= 50000;
}
+ return std::move(_next);
+ }
- private:
- static int callback(sd_bus_message* m, void* context, sd_bus_error*)
- {
- auto* me = static_cast<SignalQueue*>(context);
- sd_bus_message_ref(m);
- sdbusplus::message::message msg{m};
- me->_next = std::move(msg);
- return 0;
- }
+ private:
+ static int callback(sd_bus_message* m, void* context, sd_bus_error*)
+ {
+ auto* me = static_cast<SignalQueue*>(context);
+ sd_bus_message_ref(m);
+ sdbusplus::message::message msg{m};
+ me->_next = std::move(msg);
+ return 0;
+ }
- sdbusplus::bus::bus _bus;
- sdbusplus::bus::match_t _match;
- sdbusplus::message::message _next;
+ sdbusplus::bus::bus _bus;
+ sdbusplus::bus::match_t _match;
+ sdbusplus::message::message _next;
};
/**@brief Find a subset of interfaces and properties in an object. */
auto hasProperties(const Object& l, const Object& r)
{
Object result;
- std::set_difference(
- r.cbegin(),
- r.cend(),
- l.cbegin(),
- l.cend(),
- std::inserter(result, result.end()));
+ std::set_difference(r.cbegin(), r.cend(), l.cbegin(), l.cend(),
+ std::inserter(result, result.end()));
return result.empty();
}
@@ -160,20 +153,10 @@ auto hasProperties(const Object& l, const Object& r)
auto hasInterfaces(const std::vector<std::string>& l, const Object& r)
{
std::vector<std::string> stripped, interfaces;
- std::transform(
- r.cbegin(),
- r.cend(),
- std::back_inserter(stripped),
- [](auto & p)
- {
- return p.first;
- });
- std::set_difference(
- stripped.cbegin(),
- stripped.cend(),
- l.cbegin(),
- l.cend(),
- std::back_inserter(interfaces));
+ std::transform(r.cbegin(), r.cend(), std::back_inserter(stripped),
+ [](auto& p) { return p.first; });
+ std::set_difference(stripped.cbegin(), stripped.cend(), l.cbegin(),
+ l.cend(), std::back_inserter(interfaces));
return interfaces.empty();
}
@@ -182,35 +165,21 @@ void runTests()
const std::string exampleRoot{EXAMPLE_ROOT};
auto b = sdbusplus::bus::new_default();
- auto notify = [&]()
- {
- return b.new_method_call(
- MGR_SERVICE,
- MGR_ROOT,
- MGR_INTERFACE,
- "Notify");
+ auto notify = [&]() {
+ return b.new_method_call(MGR_SERVICE, MGR_ROOT, MGR_INTERFACE,
+ "Notify");
};
- auto set = [&](const std::string & path)
- {
- return b.new_method_call(
- EXAMPLE_SERVICE,
- path.c_str(),
- "org.freedesktop.DBus.Properties",
- "Set");
+ auto set = [&](const std::string& path) {
+ return b.new_method_call(EXAMPLE_SERVICE, path.c_str(),
+ "org.freedesktop.DBus.Properties", "Set");
};
- Object obj
- {
- {
- "xyz.openbmc_project.Example.Iface1",
- {{"ExampleProperty1", "test1"s}}
- },
- {
- "xyz.openbmc_project.Example.Iface2",
- { {"ExampleProperty2", "test2"s},
- {"ExampleProperty3", static_cast<int64_t>(0ll)}
- }
- },
+ Object obj{
+ {"xyz.openbmc_project.Example.Iface1",
+ {{"ExampleProperty1", "test1"s}}},
+ {"xyz.openbmc_project.Example.Iface2",
+ {{"ExampleProperty2", "test2"s},
+ {"ExampleProperty3", static_cast<int64_t>(0ll)}}},
};
// Validate startup events occurred.
@@ -218,11 +187,9 @@ void runTests()
sdbusplus::message::object_path relCreateMe3{"/createme3"};
std::string createMe3{root + relCreateMe3.str};
- auto get = b.new_method_call(
- MGR_SERVICE,
- createMe3.c_str(),
- "org.freedesktop.DBus.Properties",
- "GetAll");
+ auto get =
+ b.new_method_call(MGR_SERVICE, createMe3.c_str(),
+ "org.freedesktop.DBus.Properties", "GetAll");
get.append("xyz.openbmc_project.Example.Iface1");
auto resp = b.call(get);
@@ -236,8 +203,7 @@ void runTests()
sdbusplus::message::object_path relPath{"/foo"};
std::string path(root + relPath.str);
- SignalQueue queue(
- "path='" + root + "',member='InterfacesAdded'");
+ SignalQueue queue("path='" + root + "',member='InterfacesAdded'");
auto m = notify();
m.append(ObjectMap({{relPath, obj}}));
@@ -256,282 +222,260 @@ void runTests()
}
// Validate the propertyIs filter.
- {
- // Create an object to be deleted.
- {
- auto m = notify();
- m.append(ObjectMap({{relDeleteMeThree, obj}}));
- b.call(m);
- }
+ {// Create an object to be deleted.
+ {auto m = notify();
+ m.append(ObjectMap({{relDeleteMeThree, obj}}));
+ b.call(m);
+}
- // Validate that the action does not run if the property doesn't match.
- {
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("123"));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
- }
+// Validate that the action does not run if the property doesn't match.
+{
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
+ auto m = set(trigger4.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("123"));
+ b.call(m);
+ auto sig{queue.pop()};
+ assert(!sig);
+}
- // Validate that the action does run if the property matches.
- {
- // Set ExampleProperty2 to something else to the 123 filter
- // matches.
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("xyz"));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
- }
- {
- // Set ExampleProperty3 to 99.
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty3");
- m.append(sdbusplus::message::variant<int64_t>(99));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
- }
- {
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("123"));
- b.call(m);
-
- sdbusplus::message::object_path sigpath;
- std::vector<std::string> interfaces;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeThree);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- }
+// Validate that the action does run if the property matches.
+{
+ // Set ExampleProperty2 to something else to the 123 filter
+ // matches.
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
+ auto m = set(trigger4.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("xyz"));
+ b.call(m);
+ auto sig{queue.pop()};
+ assert(!sig);
+}
+{
+ // Set ExampleProperty3 to 99.
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
+ auto m = set(trigger4.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty3");
+ m.append(sdbusplus::message::variant<int64_t>(99));
+ b.call(m);
+ auto sig{queue.pop()};
+ assert(!sig);
+}
+{
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
+ auto m = set(trigger4.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("123"));
+ b.call(m);
+
+ sdbusplus::message::object_path sigpath;
+ std::vector<std::string> interfaces;
+ {
+ std::vector<std::string> interfaces;
+ auto sig{queue.pop()};
+ assert(static_cast<bool>(sig));
+ sig.read(sigpath);
+ assert(sigpath == deleteMeThree);
+ sig.read(interfaces);
+ std::sort(interfaces.begin(), interfaces.end());
+ assert(hasInterfaces(interfaces, obj));
}
+}
+}
- // Make sure DBus signals are handled.
- {
- // Create some objects to be deleted by an action.
- {
- auto m = notify();
- m.append(ObjectMap({{relDeleteMeOne, obj}}));
- b.call(m);
- }
- {
- auto m = notify();
- m.append(ObjectMap({{relDeleteMeTwo, obj}}));
- b.call(m);
- }
- {
- auto m = notify();
- m.append(ObjectMap({{relDeleteMeThree, obj}}));
- b.call(m);
- }
+// Make sure DBus signals are handled.
+{// Create some objects to be deleted by an action.
+ {auto m = notify();
+m.append(ObjectMap({{relDeleteMeOne, obj}}));
+b.call(m);
+}
+{
+ auto m = notify();
+ m.append(ObjectMap({{relDeleteMeTwo, obj}}));
+ b.call(m);
+}
+{
+ auto m = notify();
+ m.append(ObjectMap({{relDeleteMeThree, obj}}));
+ b.call(m);
+}
- // Set some properties that should not trigger due to a filter.
- {
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger1.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("abc123"));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
- }
- {
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger3.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty3");
- m.append(sdbusplus::message::variant<int64_t>(11));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
- }
+// Set some properties that should not trigger due to a filter.
+{
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
+ auto m = set(trigger1.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("abc123"));
+ b.call(m);
+ auto sig{queue.pop()};
+ assert(!sig);
+}
+{
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
+ auto m = set(trigger3.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty3");
+ m.append(sdbusplus::message::variant<int64_t>(11));
+ b.call(m);
+ auto sig{queue.pop()};
+ assert(!sig);
+}
- // Set some properties that should trigger.
- {
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
+// Set some properties that should trigger.
+{
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger1.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("xxxyyy"));
- b.call(m);
+ auto m = set(trigger1.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("xxxyyy"));
+ b.call(m);
- sdbusplus::message::object_path sigpath;
- std::vector<std::string> interfaces;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeOne);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeTwo);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- {
- // Make sure there were only two signals.
- auto sig{queue.pop()};
- assert(!sig);
- }
- }
- {
- SignalQueue queue(
- "path='" + root + "',member='InterfacesRemoved'");
+ sdbusplus::message::object_path sigpath;
+ std::vector<std::string> interfaces;
+ {
+ std::vector<std::string> interfaces;
+ auto sig{queue.pop()};
+ assert(static_cast<bool>(sig));
+ sig.read(sigpath);
+ assert(sigpath == deleteMeOne);
+ sig.read(interfaces);
+ std::sort(interfaces.begin(), interfaces.end());
+ assert(hasInterfaces(interfaces, obj));
+ }
+ {
+ std::vector<std::string> interfaces;
+ auto sig{queue.pop()};
+ assert(static_cast<bool>(sig));
+ sig.read(sigpath);
+ assert(sigpath == deleteMeTwo);
+ sig.read(interfaces);
+ std::sort(interfaces.begin(), interfaces.end());
+ assert(hasInterfaces(interfaces, obj));
+ }
+ {
+ // Make sure there were only two signals.
+ auto sig{queue.pop()};
+ assert(!sig);
+ }
+}
+{
+ SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger3.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty3");
- m.append(sdbusplus::message::variant<int64_t>(10));
- b.call(m);
+ auto m = set(trigger3.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty3");
+ m.append(sdbusplus::message::variant<int64_t>(10));
+ b.call(m);
- sdbusplus::message::object_path sigpath;
- std::vector<std::string> interfaces;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeThree);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- {
- // Make sure there was only one signal.
- auto sig{queue.pop()};
- assert(!sig);
- }
- }
+ sdbusplus::message::object_path sigpath;
+ std::vector<std::string> interfaces;
+ {
+ std::vector<std::string> interfaces;
+ auto sig{queue.pop()};
+ assert(static_cast<bool>(sig));
+ sig.read(sigpath);
+ assert(sigpath == deleteMeThree);
+ sig.read(interfaces);
+ std::sort(interfaces.begin(), interfaces.end());
+ assert(hasInterfaces(interfaces, obj));
+ }
+ {
+ // Make sure there was only one signal.
+ auto sig{queue.pop()};
+ assert(!sig);
}
+}
+}
+
+// Validate the set property action.
+{
+ sdbusplus::message::object_path relChangeMe{"/changeme"};
+ std::string changeMe{root + relChangeMe.str};
- // Validate the set property action.
+ // Create an object to be updated by the set property action.
{
- sdbusplus::message::object_path relChangeMe{"/changeme"};
- std::string changeMe{root + relChangeMe.str};
+ auto m = notify();
+ m.append(ObjectMap({{relChangeMe, obj}}));
+ b.call(m);
+ }
- // Create an object to be updated by the set property action.
- {
- auto m = notify();
- m.append(ObjectMap({{relChangeMe, obj}}));
- b.call(m);
- }
+ // Trigger and validate the change.
+ {
+ SignalQueue queue("path='" + changeMe + "',member='PropertiesChanged'");
+ auto m = set(trigger2.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("yyyxxx"));
+ b.call(m);
- // Trigger and validate the change.
+ std::string sigInterface;
+ std::map<std::string, sdbusplus::message::variant<std::string>>
+ sigProperties;
{
- SignalQueue queue(
- "path='" + changeMe + "',member='PropertiesChanged'");
- auto m = set(trigger2.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("yyyxxx"));
- b.call(m);
-
- std::string sigInterface;
- std::map <
- std::string,
- sdbusplus::message::variant<std::string >> sigProperties;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- sig.read(sigInterface);
- assert(sigInterface == "xyz.openbmc_project.Example.Iface1");
- sig.read(sigProperties);
- assert(sigProperties["ExampleProperty1"] == "changed");
- }
+ std::vector<std::string> interfaces;
+ auto sig{queue.pop()};
+ sig.read(sigInterface);
+ assert(sigInterface == "xyz.openbmc_project.Example.Iface1");
+ sig.read(sigProperties);
+ assert(sigProperties["ExampleProperty1"] == "changed");
}
}
+}
+
+// Validate the create object action.
+{
+ sdbusplus::message::object_path relCreateMe1{"/createme1"};
+ sdbusplus::message::object_path relCreateMe2{"/createme2"};
+ std::string createMe1{root + relCreateMe1.str};
+ std::string createMe2{root + relCreateMe2.str};
- // Validate the create object action.
+ // Trigger the action.
{
- sdbusplus::message::object_path relCreateMe1{"/createme1"};
- sdbusplus::message::object_path relCreateMe2{"/createme2"};
- std::string createMe1{root + relCreateMe1.str};
- std::string createMe2{root + relCreateMe2.str};
+ sdbusplus::message::object_path signalPath;
+ Object signalObject;
+
+ SignalQueue queue("path='" + root + "',member='InterfacesAdded'");
- // Trigger the action.
+ auto m = set(trigger5.str);
+ m.append("xyz.openbmc_project.Example.Iface2");
+ m.append("ExampleProperty2");
+ m.append(sdbusplus::message::variant<std::string>("abc123"));
+ b.call(m);
+ {
+ auto sig{queue.pop()};
+ assert(static_cast<bool>(sig));
+ sig.read(signalPath);
+ assert(createMe1 == signalPath.str);
+ sig.read(signalObject);
+ }
{
- sdbusplus::message::object_path signalPath;
- Object signalObject;
-
- SignalQueue queue(
- "path='" + root + "',member='InterfacesAdded'");
-
- auto m = set(trigger5.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(sdbusplus::message::variant<std::string>("abc123"));
- b.call(m);
- {
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(signalPath);
- assert(createMe1 == signalPath.str);
- sig.read(signalObject);
- }
- {
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(signalPath);
- assert(createMe2 == signalPath.str);
- sig.read(signalObject);
- }
-
- auto moreSignals{queue.pop()};
- assert(!moreSignals);
+ auto sig{queue.pop()};
+ assert(static_cast<bool>(sig));
+ sig.read(signalPath);
+ assert(createMe2 == signalPath.str);
+ sig.read(signalObject);
}
+
+ auto moreSignals{queue.pop()};
+ assert(!moreSignals);
}
}
+}
int main()
{
phosphor::inventory::manager::Manager mgr(
- sdbusplus::bus::new_default(),
- MGR_SERVICE, MGR_ROOT, MGR_INTERFACE);
+ sdbusplus::bus::new_default(), MGR_SERVICE, MGR_ROOT, MGR_INTERFACE);
ExampleService d;
- auto f1 = [](auto mgr)
- {
- mgr->run();
- };
- auto f2 = [](auto d)
- {
- d->run();
- };
+ auto f1 = [](auto mgr) { mgr->run(); };
+ auto f2 = [](auto d) { d->run(); };
auto t1 = std::thread(f1, &mgr);
auto t2 = std::thread(f2, &d);
OpenPOWER on IntegriCloud