aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2016-10-04 17:23:50 +0200
committerMarkus Armbruster <armbru@redhat.com>2016-10-06 14:47:41 +0200
commitbce3035a44c40bd3ec29d3162025fd350f2d8dbf (patch)
tree6100a0eb7c443c696287b3330ab1df484e5b5e55
parentc489780203f9b22aca5539ec7589b7140bdc951f (diff)
downloadqemu-bce3035a44c40bd3ec29d3162025fd350f2d8dbf.zip
qemu-bce3035a44c40bd3ec29d3162025fd350f2d8dbf.tar.gz
qemu-bce3035a44c40bd3ec29d3162025fd350f2d8dbf.tar.bz2
tests/test-qmp-input-strict: Cover missing struct members
These tests would have caught the bug fixed by the previous commit. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1475594630-24758-1-git-send-email-armbru@redhat.com>
-rw-r--r--tests/test-qmp-input-strict.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c
index 814550a..d87f8b8 100644
--- a/tests/test-qmp-input-strict.c
+++ b/tests/test-qmp-input-strict.c
@@ -193,6 +193,50 @@ static void test_validate_fail_struct_nested(TestInputVisitorData *data,
g_assert(!udp);
}
+static void test_validate_fail_struct_missing(TestInputVisitorData *data,
+ const void *unused)
+{
+ Error *err = NULL;
+ Visitor *v;
+ QObject *any;
+ GenericAlternate *alt;
+ bool present;
+ int en;
+ int64_t i64;
+ uint32_t u32;
+ int8_t i8;
+ char *str;
+ double dbl;
+
+ v = validate_test_init(data, "{}");
+ visit_start_struct(v, NULL, NULL, 0, &error_abort);
+ visit_start_struct(v, "struct", NULL, 0, &err);
+ error_free_or_abort(&err);
+ visit_start_list(v, "list", NULL, 0, &err);
+ error_free_or_abort(&err);
+ visit_start_alternate(v, "alternate", &alt, sizeof(*alt), false, &err);
+ error_free_or_abort(&err);
+ visit_optional(v, "optional", &present);
+ g_assert(!present);
+ visit_type_enum(v, "enum", &en, EnumOne_lookup, &err);
+ error_free_or_abort(&err);
+ visit_type_int(v, "i64", &i64, &err);
+ error_free_or_abort(&err);
+ visit_type_uint32(v, "u32", &u32, &err);
+ error_free_or_abort(&err);
+ visit_type_int8(v, "i8", &i8, &err);
+ error_free_or_abort(&err);
+ visit_type_str(v, "i8", &str, &err);
+ error_free_or_abort(&err);
+ visit_type_number(v, "dbl", &dbl, &err);
+ error_free_or_abort(&err);
+ visit_type_any(v, "any", &any, &err);
+ error_free_or_abort(&err);
+ visit_type_null(v, "null", &err);
+ error_free_or_abort(&err);
+ visit_end_struct(v, NULL);
+}
+
static void test_validate_fail_list(TestInputVisitorData *data,
const void *unused)
{
@@ -316,6 +360,8 @@ int main(int argc, char **argv)
&testdata, test_validate_fail_struct);
validate_test_add("/visitor/input-strict/fail/struct-nested",
&testdata, test_validate_fail_struct_nested);
+ validate_test_add("/visitor/input-strict/fail/struct-missing",
+ &testdata, test_validate_fail_struct_missing);
validate_test_add("/visitor/input-strict/fail/list",
&testdata, test_validate_fail_list);
validate_test_add("/visitor/input-strict/fail/union-flat",