diff mbox series

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

Message ID 20240724175248.1389201-19-thuth@redhat.com (mailing list archive)
State New, archived
Headers show
Series Convert avocado tests to normal Python unittests | expand

Commit Message

Thomas Huth July 24, 2024, 5:52 p.m. UTC
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 mbox series

Patch

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()