aboutsummaryrefslogtreecommitdiff
path: root/tests/test-opts-visitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-opts-visitor.c')
-rw-r--r--tests/test-opts-visitor.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test-opts-visitor.c b/tests/test-opts-visitor.c
index 0a9e75f1bb..d0f764699b 100644
--- a/tests/test-opts-visitor.c
+++ b/tests/test-opts-visitor.c
@@ -172,6 +172,44 @@ expect_u64_max(OptsVisitorFixture *f, gconstpointer test_data)
/* test cases */
+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);
+ tail = list;
+ visit_type_int(v, NULL, &tail->value, &error_abort);
+ g_assert_cmpint(tail->value, ==, 0);
+ tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
+ g_assert(tail);
+ visit_type_int(v, NULL, &tail->value, &error_abort);
+ g_assert_cmpint(tail->value, ==, 1);
+ tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
+ g_assert(tail);
+ visit_end_list(v, (void **)&list);
+ /* BUG: unvisited tail not reported; actually not reportable by design */
+
+ visit_check_struct(v, &error_abort);
+ visit_end_struct(v, NULL);
+
+ qapi_free_intList(list);
+ visit_free(v);
+ qemu_opts_del(opts);
+}
+
int
main(int argc, char **argv)
{
@@ -263,6 +301,9 @@ main(int argc, char **argv)
add_test("/visitor/opts/i64/range/2big/full", &expect_fail,
"i64=-0x8000000000000000-0x7fffffffffffffff");
+ g_test_add_func("/visitor/opts/range/unvisited",
+ test_opts_range_unvisited);
+
g_test_run();
return 0;
}