]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tests/boot_linux_console: add extract_from_rpm method
authorLiam Merwick <liam.merwick@oracle.com>
Wed, 5 Feb 2020 14:56:03 +0000 (14:56 +0000)
committerPhilippe Mathieu-Daudé <philmd@redhat.com>
Fri, 7 Feb 2020 14:12:48 +0000 (15:12 +0100)
Add a method to extract a specified file from an RPM to the test's
working directory and return the path to the extracted file.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <1580914565-19675-5-git-send-email-liam.merwick@oracle.com>
[PMD: Rebased]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
tests/acceptance/boot_linux_console.py

index e40b84651b0bef470b6f5bc11fa17e9cc0bfde4c..16b7503b5f25c42c68f16ea109436af0f062dbfb 100644 (file)
@@ -51,6 +51,22 @@ class BootLinuxConsole(Test):
         os.chdir(cwd)
         return self.workdir + path
 
+    def extract_from_rpm(self, rpm, path):
+        """
+        Extracts a file from an RPM package into the test workdir.
+
+        :param rpm: path to the rpm archive
+        :param path: path within the rpm archive of the file to be extracted
+                     needs to be a relative path (starting with './') because
+                     cpio(1), which is used to extract the file, expects that.
+        :returns: path of the extracted file
+        """
+        cwd = os.getcwd()
+        os.chdir(self.workdir)
+        process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
+        os.chdir(cwd)
+        return os.path.normpath(os.path.join(self.workdir, path))
+
     def test_x86_64_pc(self):
         """
         :avocado: tags=arch:x86_64