[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 6/8] tests/pytest: Convert some tests that download files via
From: |
Thomas Huth |
Subject: |
[RFC PATCH 6/8] tests/pytest: Convert some tests that download files via fetch_asset() |
Date: |
Thu, 11 Jul 2024 13:55:44 +0200 |
Now that we've got a working fetch_asset() function, we can convert
some Avocado tests that use this function for downloading their
required files.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/pytest/meson.build | 16 +++++++++++++++
.../test_machine_arm_n8x0.py} | 20 +++++++------------
.../test_machine_avr6.py} | 7 ++-----
.../test_machine_loongarch.py} | 11 ++++------
.../test_machine_mips_loongson3v.py} | 19 ++++++------------
5 files changed, 35 insertions(+), 38 deletions(-)
rename tests/{avocado/machine_arm_n8x0.py => pytest/test_machine_arm_n8x0.py}
(71%)
rename tests/{avocado/machine_avr6.py => pytest/test_machine_avr6.py} (91%)
rename tests/{avocado/machine_loongarch.py =>
pytest/test_machine_loongarch.py} (89%)
rename tests/{avocado/machine_mips_loongson3v.py =>
pytest/test_machine_mips_loongson3v.py} (59%)
diff --git a/tests/pytest/meson.build b/tests/pytest/meson.build
index 1486628d45..d3607db362 100644
--- a/tests/pytest/meson.build
+++ b/tests/pytest/meson.build
@@ -8,6 +8,22 @@ pytests_generic = [
'version',
]
+pytests_arm = [
+ 'machine_arm_n8x0',
+]
+
+pytests_avr = [
+ 'machine_avr6',
+]
+
+pytests_loongarch64 = [
+ 'machine_loongarch',
+]
+
+pytests_mips64el = [
+ 'machine_mips_loongson3v',
+]
+
pytests_x86_64 = [
'cpu_queries',
'mem_addr_space',
diff --git a/tests/avocado/machine_arm_n8x0.py
b/tests/pytest/test_machine_arm_n8x0.py
similarity index 71%
rename from tests/avocado/machine_arm_n8x0.py
rename to tests/pytest/test_machine_arm_n8x0.py
index 12e9a6803b..082284b975 100644
--- a/tests/avocado/machine_arm_n8x0.py
+++ b/tests/pytest/test_machine_arm_n8x0.py
@@ -10,9 +10,9 @@
import os
-from avocado import skipUnless
-from avocado_qemu import QemuSystemTest
-from avocado_qemu import wait_for_console_pattern
+from unittest import skipUnless
+from qemu_pytest import QemuSystemTest
+from qemu_pytest import wait_for_console_pattern
class N8x0Machine(QemuSystemTest):
"""Boots the Linux kernel and checks that the console is operational"""
@@ -32,18 +32,12 @@ def __do_test_n8x0(self):
self.vm.launch()
wait_for_console_pattern(self, 'TSC2005 driver initializing')
- @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+ @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
def test_n800(self):
- """
- :avocado: tags=arch:arm
- :avocado: tags=machine:n800
- """
+ self.machine = 'n800'
self.__do_test_n8x0()
- @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+ @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
def test_n810(self):
- """
- :avocado: tags=arch:arm
- :avocado: tags=machine:n810
- """
+ self.machine = 'n810'
self.__do_test_n8x0()
diff --git a/tests/avocado/machine_avr6.py b/tests/pytest/test_machine_avr6.py
similarity index 91%
rename from tests/avocado/machine_avr6.py
rename to tests/pytest/test_machine_avr6.py
index 5485db79c6..479038a221 100644
--- a/tests/avocado/machine_avr6.py
+++ b/tests/pytest/test_machine_avr6.py
@@ -19,16 +19,12 @@
import time
-from avocado_qemu import QemuSystemTest
+from qemu_pytest import QemuSystemTest
class AVR6Machine(QemuSystemTest):
timeout = 5
def test_freertos(self):
- """
- :avocado: tags=arch:avr
- :avocado: tags=machine:arduino-mega-2560-v3
- """
"""
https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf
constantly prints out
'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX'
@@ -39,6 +35,7 @@ def test_freertos(self):
rom_hash = '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4'
rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
+ self.machine = 'arduino-mega-2560-v3'
self.vm.add_args('-bios', rom_path)
self.vm.add_args('-nographic')
self.vm.launch()
diff --git a/tests/avocado/machine_loongarch.py
b/tests/pytest/test_machine_loongarch.py
similarity index 89%
rename from tests/avocado/machine_loongarch.py
rename to tests/pytest/test_machine_loongarch.py
index 8de308f2d6..3eb68745ac 100644
--- a/tests/avocado/machine_loongarch.py
+++ b/tests/pytest/test_machine_loongarch.py
@@ -5,9 +5,9 @@
# Copyright (c) 2023 Loongson Technology Corporation Limited
#
-from avocado_qemu import QemuSystemTest
-from avocado_qemu import exec_command_and_wait_for_pattern
-from avocado_qemu import wait_for_console_pattern
+from qemu_pytest import QemuSystemTest
+from qemu_pytest import exec_command_and_wait_for_pattern
+from qemu_pytest import wait_for_console_pattern
class LoongArchMachine(QemuSystemTest):
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
@@ -21,10 +21,7 @@ def wait_for_console_pattern(self, success_message, vm=None):
def test_loongarch64_devices(self):
- """
- :avocado: tags=arch:loongarch64
- :avocado: tags=machine:virt
- """
+ self.machine = 'virt'
kernel_url = ('https://github.com/yangxiaojuan-loongson/qemu-binary/'
'releases/download/2024-05-30/vmlinuz.efi')
diff --git a/tests/avocado/machine_mips_loongson3v.py
b/tests/pytest/test_machine_mips_loongson3v.py
similarity index 59%
rename from tests/avocado/machine_mips_loongson3v.py
rename to tests/pytest/test_machine_mips_loongson3v.py
index 5194cf18c9..189b22c04e 100644
--- a/tests/avocado/machine_mips_loongson3v.py
+++ b/tests/pytest/test_machine_mips_loongson3v.py
@@ -10,28 +10,21 @@
import os
import time
-from avocado import skipUnless
-from avocado_qemu import QemuSystemTest
-from avocado_qemu import wait_for_console_pattern
+from unittest import skipUnless
+from qemu_pytest import QemuSystemTest
+from qemu_pytest import wait_for_console_pattern
class MipsLoongson3v(QemuSystemTest):
timeout = 60
- @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+ @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
def test_pmon_serial_console(self):
- """
- :avocado: tags=arch:mips64el
- :avocado: tags=endian:little
- :avocado: tags=machine:loongson3-virt
- :avocado: tags=cpu:Loongson-3A1000
- :avocado: tags=device:liointc
- :avocado: tags=device:goldfish_rtc
- """
+ self.machine = 'loongson3-virt'
pmon_hash = '7c8b45dd81ccfc55ff28f5aa267a41c3'
pmon_path =
self.fetch_asset('https://github.com/loongson-community/pmon/'
'releases/download/20210112/pmon-3avirt.bin',
- asset_hash=pmon_hash, algorithm='md5')
+ asset_hash=pmon_hash)
self.vm.set_console()
self.vm.add_args('-bios', pmon_path)
--
2.45.2
Re: [RFC PATCH 0/8] Convert avocado tests to normal Python unittests, John Snow, 2024/07/16