[Libguestfs] [libnbd PATCH v2 3/8] python: Enhance tests of nbd.Buffer

Eric Blake eblake at redhat.com
Tue Jun 7 13:48:50 UTC 2022


On Tue, Jun 07, 2022 at 02:14:36PM +0100, Richard W.M. Jones wrote:
> On Mon, Jun 06, 2022 at 09:08:28PM -0500, Eric Blake wrote:
> > Add some more coverage of existing behavior, so we can better track
> > that we are not introducing unintended changes in upcoming patches.
> > ---
> >  python/t/500-aio-pread.py  | 83 +++++++++++++++++++++++++++++++++++---
> >  python/t/510-aio-pwrite.py |  6 +++
> >  2 files changed, 84 insertions(+), 5 deletions(-)
> > 
> > diff --git a/python/t/500-aio-pread.py b/python/t/500-aio-pread.py
> > index fc1abad..c236163 100644
> > --- a/python/t/500-aio-pread.py

> > +print("%r" % buf1)
> > +
> > +assert buf1 == (b'\x00\x00\x00\x00\x00\x00\x00\x00'
> >                 + b'\x00\x00\x00\x00\x00\x00\x00\x08'
> >                 + b'\x00\x00\x00\x00\x00\x00\x00\x10'
> >                 + b'\x00\x00\x00\x00\x00\x00\x00\x18'
> > @@ -93,3 +101,68 @@ assert buf == (b'\x00\x00\x00\x00\x00\x00\x00\x00'
> >                 + b'\x00\x00\x00\x00\x00\x00\x01\xe8'
> >                 + b'\x00\x00\x00\x00\x00\x00\x01\xf0'
> >                 + b'\x00\x00\x00\x00\x00\x00\x01\xf8')

For this one, I may try to shorten the test by using:

import array from array
a = array('q', range(0, 512, 8))
if sys.byteorder == 'little':
    a.byteswap()
assert buf1 == memoryview(a).cast('B')

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


More information about the Libguestfs mailing list