qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 17/22] tests/functional: generalize archive_extract


From: Daniel P . Berrangé
Subject: Re: [PATCH 17/22] tests/functional: generalize archive_extract
Date: Mon, 2 Dec 2024 12:11:13 +0000
User-agent: Mutt/2.2.13 (2024-03-09)

On Mon, Dec 02, 2024 at 11:20:19AM +0100, Thomas Huth wrote:
> On 29/11/2024 18.31, Daniel P. Berrangé wrote:
> > There are many types of archives that the tests deal with, and
> > 'archive_extract' suggests it can cope with any, rather than only
> > tar files. Rename the existing method to 'tar_extract' and add a
> > new method that can dynamically extract any zip, tar or cpio file
> > based on file extension.
> > 
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >   tests/functional/qemu_test/utils.py | 31 +++++++++++++++++++++++++++--
> >   1 file changed, 29 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tests/functional/qemu_test/utils.py 
> > b/tests/functional/qemu_test/utils.py
> > index bafe7fb80e..8c1df8f8c2 100644
> > --- a/tests/functional/qemu_test/utils.py
> > +++ b/tests/functional/qemu_test/utils.py
> > @@ -14,6 +14,7 @@
> >   import shutil
> >   import subprocess
> >   import tarfile
> > +import zipfile
> >   from .cmd import run_cmd
> > @@ -38,7 +39,33 @@ def image_pow2ceil_expand(path):
> >               with open(path, 'ab+') as fd:
> >                   fd.truncate(size_aligned)
> > -def archive_extract(archive, dest_dir, member=None):
> > +def archive_extract(archive, dest_dir, format=None, member=None):
> 
> Why not doing "if not format: format = guess_archive_format(archive)" here?
> Otherwise this helper function is rather useless - if you have to know the
> format, you could directly call the appropriate function anyway.

That's how I had things at first, but then I hit the problem that
about 80% of the files we're extracting are cached assets, and the
asset filenames are just a hash digest, so there's no file extension
to query.

I guess I could make this work by pushing the Asset object instance
right down into this method, rather than converting from Asset ->
filename in the caller.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]