Received: from eggs.gnu.org ([2001:4830:134:3::10]:41916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsTxw-0000P0-40 for qemu-devel@nongnu.org; Fri, 07 Oct 2016 08:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsTxq-0006Nd-Jj for qemu-devel@nongnu.org; Fri, 07 Oct 2016 08:09:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsTxq-0006NC-B5 for qemu-devel@nongnu.org; Fri, 07 Oct 2016 08:09:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC196C00B6EB for ; Fri, 7 Oct 2016 12:09:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u97C9JLR003660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 7 Oct 2016 08:09:20 -0400 From: Markus Armbruster Date: Fri, 7 Oct 2016 14:09:10 +0200 Message-Id: <1475842159-26039-4-git-send-email-armbru@redhat.com> In-Reply-To: <1475842159-26039-1-git-send-email-armbru@redhat.com> References: <1475842159-26039-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PULL 03/12] tests/test-qmp-input-strict: Cover missing struct members List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org These tests would have caught the bug fixed by the previous commit. Signed-off-by: Markus Armbruster Message-Id: <1475594630-24758-1-git-send-email-armbru@redhat.com> --- tests/test-qmp-input-strict.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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", -- 2.5.5