From nobody Thu Nov 6 06:16:03 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153961325029831.459753373576973; Mon, 15 Oct 2018 07:20:50 -0700 (PDT) Received: from localhost ([::1]:52584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gC3jk-0003xC-Ua for importer@patchew.org; Mon, 15 Oct 2018 10:20:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gC3eV-00006r-Re for qemu-devel@nongnu.org; Mon, 15 Oct 2018 10:15:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gC3eO-0007SG-4H for qemu-devel@nongnu.org; Mon, 15 Oct 2018 10:15:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gC3eF-0007MC-1T; Mon, 15 Oct 2018 10:15:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 646BC86671; Mon, 15 Oct 2018 14:15:06 +0000 (UTC) Received: from localhost (ovpn-204-236.brq.redhat.com [10.40.204.236]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BF8878DA9; Mon, 15 Oct 2018 14:15:05 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 15 Oct 2018 16:14:48 +0200 Message-Id: <20181015141453.32632-5-mreitz@redhat.com> In-Reply-To: <20181015141453.32632-1-mreitz@redhat.com> References: <20181015141453.32632-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 15 Oct 2018 14:15:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/9] iotests: Use // for Python integer division 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: Kevin Wolf , Cleber Rosa , qemu-devel@nongnu.org, Eduardo Habkost , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In Python 3, / is always a floating-point division. We usually do not want this, and as Python 2.7 understands // as well, change all integer divisions to use that. Signed-off-by: Max Reitz Reviewed-by: Eduardo Habkost --- tests/qemu-iotests/040 | 4 ++-- tests/qemu-iotests/044 | 2 +- tests/qemu-iotests/093 | 18 +++++++++--------- tests/qemu-iotests/149 | 6 +++--- tests/qemu-iotests/151 | 12 ++++++------ tests/qemu-iotests/163 | 2 +- tests/qemu-iotests/iotests.py | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 1cb1ceeb33..b81133a474 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -195,7 +195,7 @@ class TestSingleDrive(ImageCommitTestCase): =20 self.assert_no_active_block_jobs() result =3D self.vm.qmp('block-commit', device=3D'drive0', top=3Dmi= d_img, - base=3Dbacking_img, speed=3D(self.image_len /= 4)) + base=3Dbacking_img, speed=3D(self.image_len /= / 4)) self.assert_qmp(result, 'return', {}) result =3D self.vm.qmp('device_del', id=3D'scsi0') self.assert_qmp(result, 'return', {}) @@ -225,7 +225,7 @@ class TestSingleDrive(ImageCommitTestCase): =20 self.assert_no_active_block_jobs() result =3D self.vm.qmp('block-commit', device=3D'drive0', top=3Dmi= d_img, - base=3Dbacking_img, speed=3D(self.image_len /= 4)) + base=3Dbacking_img, speed=3D(self.image_len /= / 4)) self.assert_qmp(result, 'return', {}) =20 result =3D self.vm.qmp('query-block') diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044 index 69e736f687..7ef5e46fe9 100755 --- a/tests/qemu-iotests/044 +++ b/tests/qemu-iotests/044 @@ -86,7 +86,7 @@ class TestRefcountTableGrowth(iotests.QMPTestCase): off =3D off + 1024 * 512 =20 table =3D b''.join(struct.pack('>Q', (1 << 63) | off + 512 * j) - for j in xrange(0, remaining / 512)) + for j in xrange(0, remaining // 512)) fd.write(table) =20 =20 diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093 index 9d1971a56c..d88fbc182e 100755 --- a/tests/qemu-iotests/093 +++ b/tests/qemu-iotests/093 @@ -69,18 +69,18 @@ class ThrottleTestCase(iotests.QMPTestCase): # in. The throttled requests won't be executed until we # advance the virtual clock. rq_size =3D 512 - rd_nr =3D max(params['bps'] / rq_size / 2, - params['bps_rd'] / rq_size, - params['iops'] / 2, + rd_nr =3D max(params['bps'] // rq_size // 2, + params['bps_rd'] // rq_size, + params['iops'] // 2, params['iops_rd']) rd_nr *=3D seconds * 2 - rd_nr /=3D ndrives - wr_nr =3D max(params['bps'] / rq_size / 2, - params['bps_wr'] / rq_size, - params['iops'] / 2, + rd_nr //=3D ndrives + wr_nr =3D max(params['bps'] // rq_size // 2, + params['bps_wr'] // rq_size, + params['iops'] // 2, params['iops_wr']) wr_nr *=3D seconds * 2 - wr_nr /=3D ndrives + wr_nr //=3D ndrives =20 # Send I/O requests to all drives for i in range(rd_nr): @@ -196,7 +196,7 @@ class ThrottleTestCase(iotests.QMPTestCase): self.configure_throttle(ndrives, settings) =20 # Wait for the bucket to empty so we can do bursts - wait_ns =3D nsec_per_sec * burst_length * burst_rate / rate + wait_ns =3D nsec_per_sec * burst_length * burst_rate // rate self.vm.qtest("clock_step %d" % wait_ns) =20 # Test I/O at the max burst rate diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index 1225334cb8..4f363f295f 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -314,13 +314,13 @@ def test_once(config, qemu_img=3DFalse): image_size =3D 4 * oneTB if qemu_img: iotests.log("# Create image") - qemu_img_create(config, image_size / oneMB) + qemu_img_create(config, image_size // oneMB) else: iotests.log("# Create image") - create_image(config, image_size / oneMB) + create_image(config, image_size // oneMB) =20 lowOffsetMB =3D 100 - highOffsetMB =3D 3 * oneTB / oneMB + highOffsetMB =3D 3 * oneTB // oneMB =20 try: if not qemu_img: diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151 index fe53b9f446..1bb74d67c4 100755 --- a/tests/qemu-iotests/151 +++ b/tests/qemu-iotests/151 @@ -67,9 +67,9 @@ class TestActiveMirror(iotests.QMPTestCase): 'write -P 1 0 %i' % self.image_len); =20 # Start some background requests - for offset in range(1 * self.image_len / 8, 3 * self.image_len / 8= , 1024 * 1024): + for offset in range(1 * self.image_len // 8, 3 * self.image_len //= 8, 1024 * 1024): self.vm.hmp_qemu_io('source', 'aio_write -P 2 %i 1M' % offset) - for offset in range(2 * self.image_len / 8, 3 * self.image_len / 8= , 1024 * 1024): + for offset in range(2 * self.image_len // 8, 3 * self.image_len //= 8, 1024 * 1024): self.vm.hmp_qemu_io('source', 'aio_write -z %i 1M' % offset) =20 # Start the block job @@ -83,9 +83,9 @@ class TestActiveMirror(iotests.QMPTestCase): self.assert_qmp(result, 'return', {}) =20 # Start some more requests - for offset in range(3 * self.image_len / 8, 5 * self.image_len / 8= , 1024 * 1024): + for offset in range(3 * self.image_len // 8, 5 * self.image_len //= 8, 1024 * 1024): self.vm.hmp_qemu_io('source', 'aio_write -P 3 %i 1M' % offset) - for offset in range(4 * self.image_len / 8, 5 * self.image_len / 8= , 1024 * 1024): + for offset in range(4 * self.image_len // 8, 5 * self.image_len //= 8, 1024 * 1024): self.vm.hmp_qemu_io('source', 'aio_write -z %i 1M' % offset) =20 # Wait for the READY event @@ -95,9 +95,9 @@ class TestActiveMirror(iotests.QMPTestCase): # the source) should be settled using the active mechanism. # The mirror code itself asserts that the source BDS's dirty # bitmap will stay clean between READY and COMPLETED. - for offset in range(5 * self.image_len / 8, 7 * self.image_len / 8= , 1024 * 1024): + for offset in range(5 * self.image_len // 8, 7 * self.image_len //= 8, 1024 * 1024): self.vm.hmp_qemu_io('source', 'aio_write -P 3 %i 1M' % offset) - for offset in range(6 * self.image_len / 8, 7 * self.image_len / 8= , 1024 * 1024): + for offset in range(6 * self.image_len // 8, 7 * self.image_len //= 8, 1024 * 1024): self.vm.hmp_qemu_io('source', 'aio_write -z %i 1M' % offset) =20 if sync_source_and_target: diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163 index 403842354e..5fd424761b 100755 --- a/tests/qemu-iotests/163 +++ b/tests/qemu-iotests/163 @@ -38,7 +38,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): entry_bits =3D 3 entry_size =3D 1 << entry_bits l1_mask =3D 0x00fffffffffffe00 - div_roundup =3D lambda n, d: (n + d - 1) / d + div_roundup =3D lambda n, d: (n + d - 1) // d =20 def split_by_n(data, n): for x in xrange(0, len(data), n): diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7290c0b159..7ca94e9278 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -199,7 +199,7 @@ def create_image(name, size): file =3D open(name, 'wb') i =3D 0 while i < size: - sector =3D struct.pack('>l504xl', i / 512, i / 512) + sector =3D struct.pack('>l504xl', i // 512, i // 512) file.write(sector) i =3D i + 512 file.close() --=20 2.17.1