On 04/19/2018 12:46 PM, Philippe Mathieu-Daudé wrote: > Booting an Alpha DP264 machine. > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > tests/avocado/test_linux-boot-console.py | 88 +++++++++++++++++++ > .../parameters.yaml | 3 + > 2 files changed, 91 insertions(+) > create mode 100644 tests/avocado/test_linux-boot-console.py > create mode 100644 > tests/avocado/test_linux-boot-console.py.data/parameters.yaml > > diff --git a/tests/avocado/test_linux-boot-console.py > b/tests/avocado/test_linux-boot-console.py > new file mode 100644 > index 0000000000..f54d10dd79 > --- /dev/null > +++ b/tests/avocado/test_linux-boot-console.py > @@ -0,0 +1,88 @@ > +# -*- coding: utf-8 -*- > +# > +# Boot a Linux kernel on the Malta board and check the serial console output > +# > +# Copyright (C) 2018 Philippe Mathieu-Daudé > +# > +# SPDX-License-Identifier: GPL-2.0-or-later > +# > +# Run with: > +# > +# avocado run test_linux-boot-console.py \ > +# --mux-yaml test_linux-boot-console.py.data/parameters.yaml > +# [--filter-by-tags arch_alpha ...] > + > +import os > +import tempfile > +import hashlib > +import urllib2 > +import gzip > +import shutil > + > +from avocado import skipUnless > +from avocado_qemu import test > + > +# XXX Use a cleaner CacheStorage or avocado.utils.[archive|kernel]? > +def cachedfile(url, cachedir='/tmp/mycachedir', gzip_compressed=False): > + if not os.path.isdir(cachedir): > + os.mkdir(cachedir) > + key = hashlib.md5(url).hexdigest() > + fbin = cachedir + "/" + key + ".bin" > + if not os.path.isfile(fbin): > + with open(cachedir + "/" + key + ".url", "w") as f: > + f.write(url + '\n') > + with open(fbin, "wb") as f: > + content = urllib2.urlopen(url).read() > + f.write(content) > + if gzip_compressed: > + fgz = cachedir + "/" + key + ".gz" > + shutil.move(fbin, fgz) > + with gzip.open(fgz, 'rb') as f_in, open(fbin, 'wb') as f_out: > + shutil.copyfileobj(f_in, f_out) > + return fbin > + > +
As pointed on my reply to PATCH 0, Avocado has a downloading/caching system, but the "uncompress if needed" does not exist yet. We're tracking the implementation of such a utility function here: https://trello.com/c/LQFOMPgV/1308-avocadoutilsarchive-add-uncompress-if-necessary - Cleber.