summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-10-10 11:45:09 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-10-10 11:45:09 +0100
commit0cb0155711ccfdb7c0ebc0e58af071850e7e2f1f (patch)
tree5941abfcc7930c45c39dfef98e2e18d4fcf868a2 /tests
parent86e121ae75d10d0aa4ef76150e94a2e83bdac3e9 (diff)
parent77a6da267c37781331c2dc8c4ac7f68d46a2a461 (diff)
downloadqemu-0cb0155711ccfdb7c0ebc0e58af071850e7e2f1f.tar.gz
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2016-10-07' into staging
QAPI patches for 2016-10-07 # gpg: Signature made Fri 07 Oct 2016 18:55:40 BST # gpg: using RSA key 0x3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2016-10-07: docs: Belatedly update for move of QMP/* to docs/ docs: Belatedly update for move of qmp-commands.txt qmp: Disable query-cpu-* commands when they're unavailable MAINTAINERS: Pass the QObject staff from Luiz to Markus MAINTAINERS: Pass the HMP staff from Luiz to David qapi: return a 'missing parameter' error qapi: assert list entry has a value qapi: add assert about root value tests/test-qmp-input-strict: Cover missing struct members qapi: Fix crash when 'any' or 'null' parameter is missing qmp: fix object-add assert() without props Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/087.out2
-rw-r--r--tests/test-qmp-input-strict.c46
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out
index cd02eaed4c..dc6baf9366 100644
--- a/tests/qemu-iotests/087.out
+++ b/tests/qemu-iotests/087.out
@@ -56,7 +56,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on
Testing: -S
QMP_VERSION
{"return": {}}
-{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'driver', expected: string"}}
+{"error": {"class": "GenericError", "desc": "Parameter 'driver' is missing"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c
index 814550ac71..d87f8b89a7 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",