On Mon, Jul 27, 2020 at 5:41 PM Eric Blake <ebl...@redhat.com> wrote:
>
> On 7/27/20 9:35 AM, Nir Soffer wrote:
>
> >> I guess it's okay that you don't create a real tar file here, but
> >> listing the commands to create it (even as a comment) is better than
> >> just saying "trust me".  And it doesn't seem like that much more work -
> >> it looks like the key to your test is that you created a tar file
> >> containing two files, where the first file was less than 512 bytes and
> >> the second file is your target destination that you will be rewriting.
> >
> > The real code is more complicated, something like:
> >
> >      offset = tar.fileobj.tell() + BLOCK_SIZE
> >
> >      with open(tar.name, "r+") as f:
> >          f.truncate(offset + measure["required"])
> >
> >      convert_image(image, tar.name, offset)
> >
> >      check = check_image(tar.name, offset)
> >      size = check["image-end-offset"]
> >
> >      member = tarfile.TarInfo(name)
> >      member.size = size
> >      tar.addfile(member)
> >
> >      tar_size = offset + round_up(size)
> >
> >      tar.fileobj.seek(tar_size)
> >      with open(tar.name, "r+") as f:
> >          f.truncate(tar_size)
> >
> > I'm not sure it helps qemu developers working on these tests.
>
> The closer the iotest is to reality, the more likely it will serve as a
> good regression test.  Cutting corners risks a test that passes in
> isolation even when we've done something that breaks the overall process
> in one of the corners you cut.

I'll add this code then.

> >>
> >> At any rate, given the urgency of getting pull requests for -rc2 in
> >> before slamming Peter tomorrow, I'll probably try to touch up the issues
> >> Max pointed out and queue it today.
> >
> > Thanks Max and Eric.
> >
> > Should I post a fixed version later today?
>
> A v2 would be helpful.

Will post later today.


Reply via email to