From nobody Mon Apr 29 01:01:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490118347123211.13477324020107; Tue, 21 Mar 2017 10:45:47 -0700 (PDT) Received: from localhost ([::1]:41689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqNqq-0004U8-5t for importer@patchew.org; Tue, 21 Mar 2017 13:45:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqNq8-0004BC-01 for qemu-devel@nongnu.org; Tue, 21 Mar 2017 13:45:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cqNq4-0000j0-Pj for qemu-devel@nongnu.org; Tue, 21 Mar 2017 13:45:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41590) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cqNq4-0000ib-Jn for qemu-devel@nongnu.org; Tue, 21 Mar 2017 13:44:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 446272DD2EB; Tue, 21 Mar 2017 17:44:56 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C49424F6BB; Tue, 21 Mar 2017 17:44:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 406CC1138645; Tue, 21 Mar 2017 18:44:50 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 446272DD2EB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 446272DD2EB From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 21 Mar 2017 18:44:50 +0100 Message-Id: <1490118290-6133-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 21 Mar 2017 17:44:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] test-qobject-input-visitor: Cover visit_type_uint64() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The new test demonstrates known bugs: integers between INT64_MAX+1 and UINT64_MAX rejected, and integers between INT64_MIN and -1 are accepted modulo 2^64. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-qobject-input-visitor.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 6eb48fe..f965743 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -116,6 +116,34 @@ static void test_visitor_in_int(TestInputVisitorData *= data, g_assert_cmpint(res, =3D=3D, value); } =20 +static void test_visitor_in_uint(TestInputVisitorData *data, + const void *unused) +{ + Error *err =3D NULL; + uint64_t res =3D 0; + int value =3D 42; + Visitor *v; + + v =3D visitor_input_test_init(data, "%d", value); + + visit_type_uint64(v, NULL, &res, &error_abort); + g_assert_cmpuint(res, =3D=3D, (uint64_t)value); + + /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */ + + v =3D visitor_input_test_init(data, "%d", -value); + + visit_type_uint64(v, NULL, &res, &error_abort); + g_assert_cmpuint(res, =3D=3D, (uint64_t)-value); + + /* BUG: value between INT64_MAX+1 and UINT64_MAX rejected */ + + v =3D visitor_input_test_init(data, "18446744073709551574"); + + visit_type_uint64(v, NULL, &res, &err); + error_free_or_abort(&err); +} + static void test_visitor_in_int_overflow(TestInputVisitorData *data, const void *unused) { @@ -1225,6 +1253,8 @@ int main(int argc, char **argv) =20 input_visitor_test_add("/visitor/input/int", NULL, test_visitor_in_int); + input_visitor_test_add("/visitor/input/uint", + NULL, test_visitor_in_uint); input_visitor_test_add("/visitor/input/int_overflow", NULL, test_visitor_in_int_overflow); input_visitor_test_add("/visitor/input/int_keyval", --=20 2.7.4