diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-05-19 14:10:00 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-05-19 14:10:01 +0100 |
commit | c5fa6c86d0765f837515d1c10654c621724a77e0 (patch) | |
tree | f7d52e821b4983ef18a57dce08c7b7c6cf97f115 /tests | |
parent | 5bc8f026dd5eb76c89395933d38dc5b0cebf5763 (diff) | |
parent | 24fd848950b44de7e2d71fb69ba52b90d6acb220 (diff) |
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp:
qapi: skip redundant includes
monitor: Add netdev_del id argument completion.
monitor: Add netdev_add type argument completion.
monitor: Add set_link arguments completion.
monitor: Add chardev-add backend argument completion.
monitor: Add chardev-remove command completion.
monitor: Convert sendkey to use command_completion.
qapi: Show qapi-commands.py invocation in qapi-code-gen.txt
qapi: Replace uncommon use of the error API by the common one
tests: Don't call visit_end_struct() after visit_start_struct() fails
hw: Don't call visit_end_struct() after visit_start_struct() fails
hmp: Call visit_end_struct() after visit_start_struct() succeeds
qapi: Un-inline visit of implicit struct
qapi-visit.py: Clean up a sloppy use of field prefix
qapi: Clean up shadowing of parameters and locals in inner scopes
qapi-visit.py: Clean up confusing push_indent() / pop_indent() use
qapi: Replace start_optional()/end_optional() by optional()
qapi: Remove unused Visitor callbacks start_handle(), end_handle()
qapi: Normalize marshalling's visitor initialization and cleanup
qapi: Update qapi-code-gen.txt example to match current code
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 3 | ||||
-rw-r--r-- | tests/qapi-schema/include-repetition-sub.json | 2 | ||||
-rw-r--r-- | tests/qapi-schema/include-repetition.err | 0 | ||||
-rw-r--r-- | tests/qapi-schema/include-repetition.exit | 1 | ||||
-rw-r--r-- | tests/qapi-schema/include-repetition.json | 3 | ||||
-rw-r--r-- | tests/qapi-schema/include-repetition.out | 3 | ||||
-rw-r--r-- | tests/test-qmp-input-strict.c | 28 | ||||
-rw-r--r-- | tests/test-qmp-input-visitor.c | 26 | ||||
-rw-r--r-- | tests/test-qmp-output-visitor.c | 28 | ||||
-rw-r--r-- | tests/test-visitor-serialization.c | 26 |
10 files changed, 93 insertions, 27 deletions
diff --git a/tests/Makefile b/tests/Makefile index 6b8b6f273a..9f7ca61ae3 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -193,7 +193,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \ flat-union-string-discriminator.json \ include-simple.json include-relpath.json include-format-err.json \ include-non-file.json include-no-file.json include-before-err.json \ - include-nested-err.json include-self-cycle.json include-cycle.json) + include-nested-err.json include-self-cycle.json include-cycle.json \ + include-repetition.json) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h diff --git a/tests/qapi-schema/include-repetition-sub.json b/tests/qapi-schema/include-repetition-sub.json new file mode 100644 index 0000000000..6bfffdfd55 --- /dev/null +++ b/tests/qapi-schema/include-repetition-sub.json @@ -0,0 +1,2 @@ +{ 'include': 'comments.json' } +{ 'include': 'comments.json' } diff --git a/tests/qapi-schema/include-repetition.err b/tests/qapi-schema/include-repetition.err new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/qapi-schema/include-repetition.err diff --git a/tests/qapi-schema/include-repetition.exit b/tests/qapi-schema/include-repetition.exit new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/qapi-schema/include-repetition.exit @@ -0,0 +1 @@ +0 diff --git a/tests/qapi-schema/include-repetition.json b/tests/qapi-schema/include-repetition.json new file mode 100644 index 0000000000..ec329dde58 --- /dev/null +++ b/tests/qapi-schema/include-repetition.json @@ -0,0 +1,3 @@ +{ 'include': 'comments.json' } +{ 'include': 'include-repetition-sub.json' } +{ 'include': 'comments.json' } diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/include-repetition.out new file mode 100644 index 0000000000..4ce3dcf12f --- /dev/null +++ b/tests/qapi-schema/include-repetition.out @@ -0,0 +1,3 @@ +[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])] +[{'enum_name': 'Status', 'enum_values': ['good', 'bad', 'ugly']}] +[] diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c index 449d285e56..0f770034b1 100644 --- a/tests/test-qmp-input-strict.c +++ b/tests/test-qmp-input-strict.c @@ -72,14 +72,30 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { - visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), - errp); + Error *err = NULL; - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), + &err); + if (err) { + goto out; + } - visit_end_struct(v, errp); + visit_type_int(v, &(*obj)->integer, "integer", &err); + if (err) { + goto out_end; + } + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + if (err) { + goto out_end; + } + visit_type_str(v, &(*obj)->string, "string", &err); + +out_end: + error_propagate(errp, err); + err = NULL; + visit_end_struct(v, &err); +out: + error_propagate(errp, err); } static void test_validate_struct(TestInputVisitorData *data, diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index a58a3e6fdb..1c8e87295c 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -199,16 +199,24 @@ static void visit_type_TestStruct(Visitor *v, TestStruct **obj, visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), &err); - if (!err) { - visit_type_int(v, &(*obj)->integer, "integer", &err); - visit_type_bool(v, &(*obj)->boolean, "boolean", &err); - visit_type_str(v, &(*obj)->string, "string", &err); - - /* Always call end_struct if start_struct succeeded. */ - error_propagate(errp, err); - err = NULL; - visit_end_struct(v, &err); + if (err) { + goto out; } + visit_type_int(v, &(*obj)->integer, "integer", &err); + if (err) { + goto out_end; + } + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + if (err) { + goto out_end; + } + visit_type_str(v, &(*obj)->string, "string", &err); + +out_end: + error_propagate(errp, err); + err = NULL; + visit_end_struct(v, &err); +out: error_propagate(errp, err); } diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 2580f3debf..9c154581d7 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -176,14 +176,30 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { - visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), - errp); + Error *err = NULL; - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), + &err); + if (err) { + goto out; + } - visit_end_struct(v, errp); + visit_type_int(v, &(*obj)->integer, "integer", &err); + if (err) { + goto out_end; + } + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + if (err) { + goto out_end; + } + visit_type_str(v, &(*obj)->string, "string", &err); + +out_end: + error_propagate(errp, err); + err = NULL; + visit_end_struct(v, &err); +out: + error_propagate(errp, err); } static void test_visitor_out_struct(TestOutputVisitorData *data, diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index 8166cf1b05..74d6481992 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -195,13 +195,29 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { - visit_start_struct(v, (void **)obj, NULL, name, sizeof(TestStruct), errp); + Error *err = NULL; - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_start_struct(v, (void **)obj, NULL, name, sizeof(TestStruct), &err); + if (err) { + goto out; + } - visit_end_struct(v, errp); + visit_type_int(v, &(*obj)->integer, "integer", &err); + if (err) { + goto out_end; + } + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + if (err) { + goto out_end; + } + visit_type_str(v, &(*obj)->string, "string", &err); + +out_end: + error_propagate(errp, err); + err = NULL; + visit_end_struct(v, &err); +out: + error_propagate(errp, err); } static TestStruct *struct_create(void) |