On 7/9/19 7:25 PM, John Snow wrote:
> Signed-off-by: John Snow <js...@redhat.com>
> ---
> tests/qemu-iotests/257 | 416 +++++++
> tests/qemu-iotests/257.out | 2247 ++++++++++++++++++++++++++++++++++++
> tests/qemu-iotests/group | 1 +
> 3 files changed, 2664 insertions(+)
> create mode 100755 tests/qemu-iotests/257
> create mode 100644 tests/qemu-iotests/257.out
>
> diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257
> new file mode 100755
> index 0000000000..75a651c7c3
> --- /dev/null
> +++ b/tests/qemu-iotests/257
> @@ -0,0 +1,416 @@
> +#!/usr/bin/env python
> +#
> +# Test bitmap-sync backups (incremental, differential, and partials)
> +#
> +# Copyright (c) 2019 John Snow for Red Hat, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +#
> +# owner=js...@redhat.com
> +
> +from collections import namedtuple
> +import math
> +import os
> +
> +import iotests
> +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 PatternGroup:
> + """Grouping of Pattern objects. Initialize with an iterable of
> Patterns."""
> + def __init__(self, patterns):
> + self.patterns = patterns
> +
> + def bits(self, granularity):
> + """Calculate the unique bits dirtied by this pattern grouping"""
> + res = set()
> + for pattern in self.patterns:
> + lower = math.floor(pattern.offset / granularity)
> + upper = math.floor((pattern.offset + pattern.size - 1) /
> granularity)
> + res = res | set(range(lower, upper + 1))
> + return res
> +
Squashing in:
- lower = math.floor(pattern.offset / granularity)
- upper = math.floor((pattern.offset + pattern.size - 1) /
granularity)
+ lower = pattern.offset // granularity
+ upper = (pattern.offset + pattern.size - 1) // granularity
To quiet the Python2 beast.
--js