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>
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 @@
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);