summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2016-12-01 08:38:06 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-01-12 16:53:38 -0500
commit22ecacc18c3b3623f98aa7e7efec659dd3593b7d (patch)
tree01c8c103b40bb116c95f43eb88a527ac6d281895
parente2e402f323d0ffb0e0581650712b083504efde34 (diff)
downloadphosphor-inventory-manager-22ecacc18c3b3623f98aa7e7efec659dd3593b7d.tar.gz
phosphor-inventory-manager-22ecacc18c3b3623f98aa7e7efec659dd3593b7d.zip
Add a testcase for setProperty
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> Change-Id: Ifade8963ebc8d18dbdca46ece16800cf8ea8a6ad
-rw-r--r--example/events.d/match1.yaml17
-rw-r--r--test/test.cpp48
2 files changed, 62 insertions, 3 deletions
diff --git a/example/events.d/match1.yaml b/example/events.d/match1.yaml
index 3a08305..19d501a 100644
--- a/example/events.d/match1.yaml
+++ b/example/events.d/match1.yaml
@@ -4,20 +4,31 @@ description: >
events:
- name: Example Match(1)
description: >
- Matches any PropertiesChanged signal.
+ Sets the value of ExampleProperty1 on /changeme
+ when the value of ExampleProperty2 on
+ /testing/inventory/trigger2 changes to yyyxxx.
type: match
signatures:
- type: signal
interface: org.freedesktop.DBus.Properties
+ path: /testing/inventory/trigger2
member: PropertiesChanged
+ filters:
+ - name: propertyChangedTo
+ args:
+ interface: xyz.openbmc_project.Example.Iface2
+ property: ExampleProperty2
+ value:
+ type: string
+ value: yyyxxx
actions:
- name: setProperty
args:
interface: xyz.openbmc_project.Example.Iface1
property: ExampleProperty1
- path: /test
+ path: /changeme
value:
type: string
- value: test
+ value: changed
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test.cpp b/test/test.cpp
index 0a1fbd9..13b8934 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -261,6 +261,54 @@ void runTests(phosphor::inventory::manager::Manager &mgr)
}
}
+ // Validate the set property action.
+ {
+ ObjectPath relChangeMe{"/changeme"};
+ ObjectPath relTriggerTwo{"/trigger2"};
+ ObjectPath changeMe{root + relChangeMe};
+ ObjectPath triggerTwo{root + relTriggerTwo};
+
+ // Create an object to be updated by the set property action.
+ {
+ auto m = notify();
+ m.append(relChangeMe);
+ m.append(obj);
+ b.call(m);
+ }
+
+ // Create the triggering object.
+ {
+ auto m = notify();
+ m.append(relTriggerTwo);
+ m.append(obj);
+ b.call(m);
+ }
+
+ // Trigger and validate the change.
+ {
+ SignalQueue queue(
+ "path='" + changeMe + "',member='PropertiesChanged'");
+ auto m = set(triggerTwo);
+ 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");
+ }
+ }
+ }
+
mgr.shutdown();
std::cout << "Success!" << std::endl;
}
OpenPOWER on IntegriCloud