[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/36] iotests/257: add Pattern class
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 22/36] iotests/257: add Pattern class |
Date: |
Fri, 16 Aug 2019 19:13:04 -0400 |
Just kidding, this is easier to manage with a full class instead of a
namedtuple.
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
---
tests/qemu-iotests/257 | 58 +++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257
index 39526837499..02f9ae06490 100755
--- a/tests/qemu-iotests/257
+++ b/tests/qemu-iotests/257
@@ -19,7 +19,6 @@
#
# owner=address@hidden
-from collections import namedtuple
import math
import os
@@ -29,10 +28,18 @@ from iotests import log, qemu_img
SIZE = 64 * 1024 * 1024
GRANULARITY = 64 * 1024
-Pattern = namedtuple('Pattern', ['byte', 'offset', 'size'])
-def mkpattern(byte, offset, size=GRANULARITY):
- """Constructor for Pattern() with default size"""
- return Pattern(byte, offset, size)
+
+class Pattern:
+ def __init__(self, byte, offset, size=GRANULARITY):
+ self.byte = byte
+ self.offset = offset
+ self.size = size
+
+ def bits(self, granularity):
+ lower = self.offset // granularity
+ upper = (self.offset + self.size - 1) // granularity
+ return set(range(lower, upper + 1))
+
class PatternGroup:
"""Grouping of Pattern objects. Initialize with an iterable of Patterns."""
@@ -43,40 +50,39 @@ class PatternGroup:
"""Calculate the unique bits dirtied by this pattern grouping"""
res = set()
for pattern in self.patterns:
- lower = pattern.offset // granularity
- upper = (pattern.offset + pattern.size - 1) // granularity
- res = res | set(range(lower, upper + 1))
+ res |= pattern.bits(granularity)
return res
+
GROUPS = [
PatternGroup([
# Batch 0: 4 clusters
- mkpattern('0x49', 0x0000000),
- mkpattern('0x6c', 0x0100000), # 1M
- mkpattern('0x6f', 0x2000000), # 32M
- mkpattern('0x76', 0x3ff0000)]), # 64M - 64K
+ Pattern('0x49', 0x0000000),
+ Pattern('0x6c', 0x0100000), # 1M
+ Pattern('0x6f', 0x2000000), # 32M
+ Pattern('0x76', 0x3ff0000)]), # 64M - 64K
PatternGroup([
# Batch 1: 6 clusters (3 new)
- mkpattern('0x65', 0x0000000), # Full overwrite
- mkpattern('0x77', 0x00f8000), # Partial-left (1M-32K)
- mkpattern('0x72', 0x2008000), # Partial-right (32M+32K)
- mkpattern('0x69', 0x3fe0000)]), # Adjacent-left (64M - 128K)
+ Pattern('0x65', 0x0000000), # Full overwrite
+ Pattern('0x77', 0x00f8000), # Partial-left (1M-32K)
+ Pattern('0x72', 0x2008000), # Partial-right (32M+32K)
+ Pattern('0x69', 0x3fe0000)]), # Adjacent-left (64M - 128K)
PatternGroup([
# Batch 2: 7 clusters (3 new)
- mkpattern('0x74', 0x0010000), # Adjacent-right
- mkpattern('0x69', 0x00e8000), # Partial-left (1M-96K)
- mkpattern('0x6e', 0x2018000), # Partial-right (32M+96K)
- mkpattern('0x67', 0x3fe0000,
- 2*GRANULARITY)]), # Overwrite [(64M-128K)-64M)
+ Pattern('0x74', 0x0010000), # Adjacent-right
+ Pattern('0x69', 0x00e8000), # Partial-left (1M-96K)
+ Pattern('0x6e', 0x2018000), # Partial-right (32M+96K)
+ Pattern('0x67', 0x3fe0000,
+ 2*GRANULARITY)]), # Overwrite [(64M-128K)-64M)
PatternGroup([
# Batch 3: 8 clusters (5 new)
# Carefully chosen such that nothing re-dirties the one cluster
# that copies out successfully before failure in Group #1.
- mkpattern('0xaa', 0x0010000,
- 3*GRANULARITY), # Overwrite and 2x Adjacent-right
- mkpattern('0xbb', 0x00d8000), # Partial-left (1M-160K)
- mkpattern('0xcc', 0x2028000), # Partial-right (32M+160K)
- mkpattern('0xdd', 0x3fc0000)]), # New; leaving a gap to the right
+ Pattern('0xaa', 0x0010000,
+ 3*GRANULARITY), # Overwrite and 2x Adjacent-right
+ Pattern('0xbb', 0x00d8000), # Partial-left (1M-160K)
+ Pattern('0xcc', 0x2028000), # Partial-right (32M+160K)
+ Pattern('0xdd', 0x3fc0000)]), # New; leaving a gap to the right
]
class Drive:
--
2.21.0
- [Qemu-devel] [PULL 14/36] iotests: teach run_job to cancel pending jobs, (continued)
- [Qemu-devel] [PULL 14/36] iotests: teach run_job to cancel pending jobs, John Snow, 2019/08/16
- [Qemu-devel] [PULL 15/36] iotests: teach FilePath to produce multiple paths, John Snow, 2019/08/16
- [Qemu-devel] [PULL 13/36] iotests: add testing shim for script-style python tests, John Snow, 2019/08/16
- [Qemu-devel] [PULL 18/36] block/backup: loosen restriction on readonly bitmaps, John Snow, 2019/08/16
- [Qemu-devel] [PULL 16/36] iotests: Add virtio-scsi device helper, John Snow, 2019/08/16
- [Qemu-devel] [PULL 12/36] block/backup: add 'always' bitmap sync policy, John Snow, 2019/08/16
- [Qemu-devel] [PULL 11/36] block/backup: upgrade copy_bitmap to BdrvDirtyBitmap, John Snow, 2019/08/16
- [Qemu-devel] [PULL 21/36] iotests: test bitmap moving inside 254, John Snow, 2019/08/16
- [Qemu-devel] [PULL 19/36] blockdev: reduce aio_context locked sections in bitmap add/remove, John Snow, 2019/08/16
- [Qemu-devel] [PULL 20/36] qapi: implement block-dirty-bitmap-remove transaction action, John Snow, 2019/08/16
- [Qemu-devel] [PULL 22/36] iotests/257: add Pattern class,
John Snow <=
- [Qemu-devel] [PULL 25/36] block/backup: hoist bitmap check into QMP interface, John Snow, 2019/08/16
- [Qemu-devel] [PULL 23/36] iotests/257: add EmulatedBitmap class, John Snow, 2019/08/16
- [Qemu-devel] [PULL 29/36] block/backup: add backup_is_cluster_allocated, John Snow, 2019/08/16
- [Qemu-devel] [PULL 28/36] block/backup: centralize copy_bitmap initialization, John Snow, 2019/08/16
- [Qemu-devel] [PULL 30/36] block/backup: teach TOP to never copy unallocated regions, John Snow, 2019/08/16
- [Qemu-devel] [PULL 27/36] block/backup: improve sync=bitmap work estimates, John Snow, 2019/08/16
- [Qemu-devel] [PULL 34/36] block/backup: deal with zero detection, John Snow, 2019/08/16
- [Qemu-devel] [PULL 35/36] block/backup: refactor write_flags, John Snow, 2019/08/16
- [Qemu-devel] [PULL 33/36] qapi: add dirty-bitmaps to query-named-block-nodes result, John Snow, 2019/08/16
- [Qemu-devel] [PULL 26/36] iotests/257: test API failures, John Snow, 2019/08/16