[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 21/26] tests: Cover partial input visit of li
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 21/26] tests: Cover partial input visit of list |
Date: |
Tue, 28 Feb 2017 09:55:11 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 02/26/2017 03:43 PM, Markus Armbruster wrote:
> Demonstrates a design flaw: there is no way to for input visitors to
> report that a list visit didn't visit the complete input list. The
> generated list visits always do, but manual visits needn't.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> tests/test-opts-visitor.c | 41 +++++++++++++++++++++++++++++++++++
> tests/test-qobject-input-visitor.c | 44
> ++++++++++++++++++++++++++++++++++++++
> tests/test-string-input-visitor.c | 22 +++++++++++++++++++
> 3 files changed, 107 insertions(+)
>
>
> +static void
> +test_opts_range_unvisited(void)
> +{
> + intList *list = NULL;
> + intList *tail;
> + QemuOpts *opts;
> + Visitor *v;
> +
> + opts = qemu_opts_parse(qemu_find_opts("userdef"), "ilist=0-2", false,
> + &error_abort);
> +
> + v = opts_visitor_new(opts);
> +
> + visit_start_struct(v, NULL, NULL, 0, &error_abort);
> +
> + /* Would be simpler if the visitor genuinely supported virtual walks */
> + visit_start_list(v, "ilist", (GenericList **)&list, sizeof(*list),
> + &error_abort);
Although the complexity of adding virtual walks to the string visitor
may not be worth the effort.
> +++ b/tests/test-qobject-input-visitor.c
> @@ -923,6 +923,46 @@ static void
> test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
> visit_end_struct(v, NULL);
> }
>
> +static void test_visitor_in_fail_list(TestInputVisitorData *data,
> + const void *unused)
> +{
> + int64_t i64 = -1;
> + Visitor *v;
> +
> + /* Unvisited list tail */
> +
> + v = visitor_input_test_init(data, "[ 1, 2, 3 ]");
> +
> + visit_start_list(v, NULL, NULL, 0, &error_abort);
> + visit_type_int(v, NULL, &i64, &error_abort);
> + g_assert_cmpint(i64, ==, 1);
> + visit_type_int(v, NULL, &i64, &error_abort);
> + g_assert_cmpint(i64, ==, 2);
> + visit_end_list(v, NULL);
> + /* BUG: unvisited tail not reported; actually not reportable by design */
Indeed - the virtual walk is easier. At any rate, good testsuite
addition, and sets the stage for why the next patches fix the design flaw.
> +}
> +
> +static void test_visitor_in_fail_list_nested(TestInputVisitorData *data,
> + const void *unused)
> +{
> + int64_t i64 = -1;
> + Visitor *v;
> +
> + /* Unvisited nested list tail */
> +
> + v = visitor_input_test_init(data, "[ 0, [ 1, 2, 3 ] ]");
In fact, QAPI does not (currently) allow the creation of one list nested
inside another (at least, not without an intervening struct), so this
particular input can only be walked virtually.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v2 09/26] qapi: Improve a QObject input visitor error message, (continued)
- [Qemu-devel] [PATCH v2 09/26] qapi: Improve a QObject input visitor error message, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 05/26] qmp: Clean up how we enforce capability negotiation, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 15/26] qom: Make object_property_set_qobject()'s input visitor strict, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 14/26] qapi: Make string input and opts visitor require non-null input, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 03/26] qmp-test: New, covering basic QMP protocol, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 07/26] qmp: Eliminate silly QERR_QMP_* macros, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 21/26] tests: Cover partial input visit of list, Markus Armbruster, 2017/02/26
- Re: [Qemu-devel] [PATCH v2 21/26] tests: Cover partial input visit of list,
Eric Blake <=
- [Qemu-devel] [PATCH v2 24/26] tests: Cover input visit beyond end of list, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 20/26] test-string-input-visitor: Improve list coverage, Markus Armbruster, 2017/02/26
- [Qemu-devel] [PATCH v2 17/26] qapi: Drop unused non-strict qobject input visitor, Markus Armbruster, 2017/02/26
- Re: [Qemu-devel] [PATCH v2 00/26] qapi: QMP dispatch and input visitor work, no-reply, 2017/02/26