From nobody Tue Feb 10 06:08:23 2026 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 1496853651850675.629198822131; Wed, 7 Jun 2017 09:40:51 -0700 (PDT) Received: from localhost ([::1]:45137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIe0o-0001HI-4p for importer@patchew.org; Wed, 07 Jun 2017 12:40:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIdxR-0006Nl-9M for qemu-devel@nongnu.org; Wed, 07 Jun 2017 12:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIdxN-00070q-Ae for qemu-devel@nongnu.org; Wed, 07 Jun 2017 12:37:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIdxN-00070Q-2P for qemu-devel@nongnu.org; Wed, 07 Jun 2017 12:37:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA0221766AE for ; Wed, 7 Jun 2017 16:37:15 +0000 (UTC) Received: from localhost (ovpn-112-40.ams2.redhat.com [10.36.112.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 131AA7DFE8; Wed, 7 Jun 2017 16:37:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA0221766AE Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EA0221766AE From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Jun 2017 20:35:56 +0400 Message-Id: <20170607163635.17635-5-marcandre.lureau@redhat.com> In-Reply-To: <20170607163635.17635-1-marcandre.lureau@redhat.com> References: <20170607163635.17635-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 07 Jun 2017 16:37:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v3 04/43] tests: add more int/number ranges checks 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-qobject-input-visitor.c | 38 ++++++++++++++++++++++++++++++++++= +++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 83d663d11d..3a6ce2226c 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -107,6 +107,7 @@ static void test_visitor_in_int(TestInputVisitorData *d= ata, const void *unused) { int64_t res =3D 0; + double dbl; int value =3D -42; Visitor *v; =20 @@ -114,6 +115,9 @@ static void test_visitor_in_int(TestInputVisitorData *d= ata, =20 visit_type_int(v, NULL, &res, &error_abort); g_assert_cmpint(res, =3D=3D, value); + + visit_type_number(v, NULL, &dbl, &error_abort); + g_assert_cmpfloat(dbl, =3D=3D, -42.0); } =20 static void test_visitor_in_uint(TestInputVisitorData *data, @@ -121,6 +125,8 @@ static void test_visitor_in_uint(TestInputVisitorData *= data, { Error *err =3D NULL; uint64_t res =3D 0; + int64_t i64; + double dbl; int value =3D 42; Visitor *v; =20 @@ -129,8 +135,13 @@ static void test_visitor_in_uint(TestInputVisitorData = *data, visit_type_uint64(v, NULL, &res, &error_abort); g_assert_cmpuint(res, =3D=3D, (uint64_t)value); =20 - /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */ + visit_type_int(v, NULL, &i64, &error_abort); + g_assert_cmpint(i64, =3D=3D, value); + + visit_type_number(v, NULL, &dbl, &error_abort); + g_assert_cmpfloat(dbl, =3D=3D, value); =20 + /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */ v =3D visitor_input_test_init(data, "%d", -value); =20 visit_type_uint64(v, NULL, &res, &error_abort); @@ -142,6 +153,8 @@ static void test_visitor_in_uint(TestInputVisitorData *= data, =20 visit_type_uint64(v, NULL, &res, &err); error_free_or_abort(&err); + + visit_type_number(v, NULL, &dbl, &error_abort); } =20 static void test_visitor_in_int_overflow(TestInputVisitorData *data, @@ -260,6 +273,27 @@ static void test_visitor_in_number(TestInputVisitorDat= a *data, g_assert_cmpfloat(res, =3D=3D, value); } =20 +static void test_visitor_in_large_number(TestInputVisitorData *data, + const void *unused) +{ + Error *err =3D NULL; + double res =3D 0; + int64_t i64; + uint64_t u64; + Visitor *v; + + v =3D visitor_input_test_init(data, "-18446744073709551616"); /* -2^64= */ + + visit_type_number(v, NULL, &res, &error_abort); + g_assert_cmpfloat(res, =3D=3D, -18446744073709552e3); + + visit_type_int(v, NULL, &i64, &err); + error_free_or_abort(&err); + + visit_type_uint64(v, NULL, &u64, &err); + error_free_or_abort(&err); +} + static void test_visitor_in_number_keyval(TestInputVisitorData *data, const void *unused) { @@ -1253,6 +1287,8 @@ int main(int argc, char **argv) NULL, test_visitor_in_bool_str_fail); input_visitor_test_add("/visitor/input/number", NULL, test_visitor_in_number); + input_visitor_test_add("/visitor/input/large_number", + NULL, test_visitor_in_large_number); input_visitor_test_add("/visitor/input/number_keyval", NULL, test_visitor_in_number_keyval); input_visitor_test_add("/visitor/input/number_str_keyval", --=20 2.13.0.91.g00982b8dd