diff options
| author | Patrick Williams <patrick@stwcx.xyz> | 2016-11-04 17:44:04 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2016-11-04 17:44:06 -0500 |
| commit | f101ee28c7e8badfd6db3fdc40db1bf7ab73a091 (patch) | |
| tree | 3208de0ce54ac2130bf2fdbddb2c48167fe8c173 | |
| parent | 75538a7b1cf6e592dc68614c0bd7543ed406b891 (diff) | |
| download | sdbusplus-f101ee28c7e8badfd6db3fdc40db1bf7ab73a091.tar.gz sdbusplus-f101ee28c7e8badfd6db3fdc40db1bf7ab73a091.zip | |
message: testcase to read missing variant type
Commit ac52113 fixed an issue where reading a variant from a
message when the C++ variant did not contain the type of the
dbus variant caused the message to get into an invalid state.
Add a testcase for this condition.
Change-Id: Iea58a4440d72a1d2969d80f782ec1f316cb5ff29
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
| -rw-r--r-- | test/message/read.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/message/read.cpp b/test/message/read.cpp index e430d61..59898b3 100644 --- a/test/message/read.cpp +++ b/test/message/read.cpp @@ -325,6 +325,32 @@ void runTests() b.call_noreply(m); } + // Test variant with missing/wrong type. + { + auto m = newMethodCall__test(b); + sdbusplus::message::variant<uint64_t, double> a1{3.1}, a2{uint64_t(4)}; + m.append(1, a1, a2, 2); + verifyTypeString = "ivvi"; + + struct verify + { + static void op(sdbusplus::message::message& m) + { + int32_t a, b; + sdbusplus::message::variant<uint8_t, double> a1{}, a2{}; + + m.read(a, a1, a2, b); + assert(a == 1); + assert(a1 == 3.1); + assert(a2 == uint8_t()); + assert(b == 2); + } + }; + verifyCallback = &verify::op; + + b.call_noreply(m); + } + // Test map-variant. { auto m = newMethodCall__test(b); |

