Bobby R. Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/35257 )

Change subject: tests,misc: Updated TestLib and boot-tests for gzipped imgs
......................................................................

tests,misc: Updated TestLib and boot-tests for gzipped imgs

In efforts to reduce storage costs and download times, the images hosted
by us have been gzipped. The TestLib framework has therefore been
extended to decompress gzipped files after download.

The x86-boot-tests are, at present, the only tests which use the gem5
images. These tests have been updated to download the gzipped image.

Change-Id: I6b2dbe9472a604148834820db8ea70e91e94376f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35257
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
---
M tests/gem5/fixture.py
M tests/gem5/x86-boot-tests/test_linux_boot.py
2 files changed, 20 insertions(+), 5 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/tests/gem5/fixture.py b/tests/gem5/fixture.py
index bb911dd..e21cb88 100644
--- a/tests/gem5/fixture.py
+++ b/tests/gem5/fixture.py
@@ -42,6 +42,7 @@
 import sys
 import socket
 import threading
+import gzip

 from six.moves import urllib

@@ -260,11 +261,11 @@
         and downloads an updated version if it is needed.
     """

-    def __new__(cls, url, path, filename):
+    def __new__(cls, url, path, filename, gzip_decompress=False):
         target = joinpath(path, filename)
         return super(DownloadedProgram, cls).__new__(cls, target)

-    def _init(self, url, path, filename, **kwargs):
+    def _init(self, url, path, filename, gzip_decompress=False, **kwargs):
         """
         url: string
             The url of the archive
@@ -272,12 +273,16 @@
             The absolute path of the directory containing the archive
         filename: string
             The name of the archive
+        gzip_decompress: boolean
+ True if this target resource have been compressed using gzip and
+            is to be decompressed prior to usage.
         """

         self.url = url
         self.path = path
         self.filename = joinpath(path, filename)
         self.name = "Downloaded:" + self.filename
+        self.gzip_decompress = gzip_decompress

     def _download(self):
         import errno
@@ -288,7 +293,17 @@
             except OSError as e:
                 if e.errno != errno.EEXIST:
                     raise
-        urllib.request.urlretrieve(self.url, self.filename)
+        if self.gzip_decompress:
+            gzipped_filename = self.filename + ".gz"
+            urllib.request.urlretrieve(self.url, gzipped_filename)
+
+            with open(self.filename, 'w') as outfile:
+                with gzip.open(gzipped_filename, 'r') as infile:
+                    shutil.copyfileobj(infile, outfile)
+
+            os.remove(gzipped_filename)
+        else:
+            urllib.request.urlretrieve(self.url, self.filename)

     def _getremotetime(self):
         import datetime, time
diff --git a/tests/gem5/x86-boot-tests/test_linux_boot.py b/tests/gem5/x86-boot-tests/test_linux_boot.py
index 0e66659..d73f3a1 100644
--- a/tests/gem5/x86-boot-tests/test_linux_boot.py
+++ b/tests/gem5/x86-boot-tests/test_linux_boot.py
@@ -34,13 +34,13 @@
     base_path = joinpath(absdirpath(__file__), '..', 'resources',
             'ubuntu-boot')

-image_url = config.resource_url + '/images/x86/ubuntu-18-04/base.img'
+image_url = config.resource_url + '/images/x86/ubuntu-18-04/base.img.gz'
 kernel_url = config.resource_url + '/kernels/x86/static/vmlinux-4.19.83'

 image_name = 'ubuntu-18-04-base.img'
 kernel_name = 'vmlinux-4.19.83' # 4.19 is LTS (Projected EOL: Dec, 2020)

-image = DownloadedProgram(image_url, base_path, image_name)
+image = DownloadedProgram(image_url, base_path, image_name, True)
 kernel = DownloadedProgram(kernel_url, base_path, kernel_name)



--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/35257
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: release-staging-v20.1.0.0
Gerrit-Change-Id: I6b2dbe9472a604148834820db8ea70e91e94376f
Gerrit-Change-Number: 35257
Gerrit-PatchSet: 3
Gerrit-Owner: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to