[PATCH v2 18/23] tests/functional: Convert the ppc_amiga avocado test into a standalone test

Thomas Huth posted 23 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH v2 18/23] tests/functional: Convert the ppc_amiga avocado test into a standalone test
Posted by Thomas Huth 1 month, 3 weeks ago
Use the Python standard zipfile module instead of avocado.utils for
extracting the ZIP file that we download here, and use the standard
subprocess module for running the "tail" command.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/meson.build                  |  1 +
 .../test_ppc_amiga.py}                        | 33 ++++++++++---------
 2 files changed, 19 insertions(+), 15 deletions(-)
 rename tests/{avocado/ppc_amiga.py => functional/test_ppc_amiga.py} (54%)
 mode change 100644 => 100755

diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 510dddfc49..74347cf545 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -55,6 +55,7 @@ tests_ppc_quick = [
 tests_ppc_thorough = [
   'ppc_405',
   'ppc_40p',
+  'ppc_amiga',
   'ppc_bamboo',
   'ppc_mpc8544ds',
   'ppc_virtex_ml507',
diff --git a/tests/avocado/ppc_amiga.py b/tests/functional/test_ppc_amiga.py
old mode 100644
new mode 100755
similarity index 54%
rename from tests/avocado/ppc_amiga.py
rename to tests/functional/test_ppc_amiga.py
index b6f866f91d..6fdb334346
--- a/tests/avocado/ppc_amiga.py
+++ b/tests/functional/test_ppc_amiga.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # Test AmigaNG boards
 #
 # Copyright (c) 2023 BALATON Zoltan
@@ -5,34 +7,35 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
-from avocado.utils import archive
-from avocado.utils import process
-from avocado_qemu import QemuSystemTest
-from avocado_qemu import wait_for_console_pattern
+import subprocess
+
+from qemu_test import QemuSystemTest
+from qemu_test import wait_for_console_pattern, run_cmd
+from zipfile import ZipFile
 
 class AmigaOneMachine(QemuSystemTest):
 
     timeout = 90
 
     def test_ppc_amigaone(self):
-        """
-        :avocado: tags=arch:ppc
-        :avocado: tags=machine:amigaone
-        :avocado: tags=device:articia
-        :avocado: tags=accel:tcg
-        """
         self.require_accelerator("tcg")
+        self.set_machine('amigaone')
         tar_name = 'A1Firmware_Floppy_05-Mar-2005.zip'
         tar_url = ('https://www.hyperion-entertainment.com/index.php/'
                    'downloads?view=download&format=raw&file=25')
         tar_hash = 'c52e59bc73e31d8bcc3cc2106778f7ac84f6c755'
-        zip_file = self.fetch_asset(tar_name, locations=tar_url,
-                                    asset_hash=tar_hash)
-        archive.extract(zip_file, self.workdir)
-        cmd = f"tail -c 524288 {self.workdir}/floppy_edition/updater.image >{self.workdir}/u-boot-amigaone.bin"
-        process.run(cmd, shell=True)
+        zip_file = self.fetch_asset(tar_url, asset_hash=tar_hash)
+        with ZipFile(zip_file, 'r') as zf:
+            zf.extractall(path=self.workdir)
+        bios_fh = open(self.workdir + "/u-boot-amigaone.bin", "wb")
+        subprocess.run(['tail', '-c', '524288',
+                        self.workdir + "/floppy_edition/updater.image"],
+                        stdout=bios_fh)
 
         self.vm.set_console()
         self.vm.add_args('-bios', self.workdir + '/u-boot-amigaone.bin')
         self.vm.launch()
         wait_for_console_pattern(self, 'FLASH:')
+
+if __name__ == '__main__':
+    QemuSystemTest.main()
-- 
2.45.2