Message ID | 20240711115546.40859-3-thuth@redhat.com |
---|---|
State | New |
Headers | show |
Series | Convert avocado tests to normal Python unittests | expand |
On Thu, Jul 11, 2024 at 01:55:40PM +0200, Thomas Huth wrote: > These test are rather simple and don't need any modifications apart > from adjusting the "from avocado_qemu" line. These tests can now > be run directly via "pytest" by setting the PYTHONPATH environment > variable to the python folder of QEMU and by providing the QEMU > binary via the PYTEST_QEMU_BINARY environment variable, and the source > and build directories via the PYTEST_SOURCE_ROOTand PYTEST_BUILD_ROOT > environment variables. > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} | 2 +- > .../empty_cpu_model.py => pytest/test_empty_cpu_model.py} | 2 +- > .../mem-addr-space-check.py => pytest/test_mem_addr_space.py} | 3 +-- > .../virtio_version.py => pytest/test_virtio_version.py} | 2 +- > 4 files changed, 4 insertions(+), 5 deletions(-) > rename tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} (96%) > rename tests/{avocado/empty_cpu_model.py => pytest/test_empty_cpu_model.py} (94%) > rename tests/{avocado/mem-addr-space-check.py => pytest/test_mem_addr_space.py} (99%) > rename tests/{avocado/virtio_version.py => pytest/test_virtio_version.py} (99%) Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> though if you take my suggestion in the previous patch, then this patch should 'chmod +x' all the test files, and add the __main__ magic to call 'unittest.main(). > > diff --git a/tests/avocado/cpu_queries.py b/tests/pytest/test_cpu_queries.py > similarity index 96% > rename from tests/avocado/cpu_queries.py > rename to tests/pytest/test_cpu_queries.py > index d3faa14720..b300447121 100644 > --- a/tests/avocado/cpu_queries.py > +++ b/tests/pytest/test_cpu_queries.py > @@ -8,7 +8,7 @@ > # 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_qemu import QemuSystemTest > +from qemu_pytest import QemuSystemTest > > class QueryCPUModelExpansion(QemuSystemTest): > """ > diff --git a/tests/avocado/empty_cpu_model.py b/tests/pytest/test_empty_cpu_model.py > similarity index 94% > rename from tests/avocado/empty_cpu_model.py > rename to tests/pytest/test_empty_cpu_model.py > index d906ef3d3c..113740bc82 100644 > --- a/tests/avocado/empty_cpu_model.py > +++ b/tests/pytest/test_empty_cpu_model.py > @@ -7,7 +7,7 @@ > # > # 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_qemu import QemuSystemTest > +from qemu_pytest import QemuSystemTest > > class EmptyCPUModel(QemuSystemTest): > def test(self): > diff --git a/tests/avocado/mem-addr-space-check.py b/tests/pytest/test_mem_addr_space.py > similarity index 99% > rename from tests/avocado/mem-addr-space-check.py > rename to tests/pytest/test_mem_addr_space.py > index 85541ea051..6ae7ba5e6b 100644 > --- a/tests/avocado/mem-addr-space-check.py > +++ b/tests/pytest/test_mem_addr_space.py > @@ -8,8 +8,7 @@ > # > # SPDX-License-Identifier: GPL-2.0-or-later > > -from avocado_qemu import QemuSystemTest > -import signal > +from qemu_pytest import QemuSystemTest > import time > > class MemAddrCheck(QemuSystemTest): > diff --git a/tests/avocado/virtio_version.py b/tests/pytest/test_virtio_version.py > similarity index 99% > rename from tests/avocado/virtio_version.py > rename to tests/pytest/test_virtio_version.py > index afe5e828b5..ca3aa806df 100644 > --- a/tests/avocado/virtio_version.py > +++ b/tests/pytest/test_virtio_version.py > @@ -12,7 +12,7 @@ > import os > > from qemu.machine import QEMUMachine > -from avocado_qemu import QemuSystemTest > +from qemu_pytest import QemuSystemTest > > # Virtio Device IDs: > VIRTIO_NET = 1 > -- > 2.45.2 > With regards, Daniel
diff --git a/tests/avocado/cpu_queries.py b/tests/pytest/test_cpu_queries.py similarity index 96% rename from tests/avocado/cpu_queries.py rename to tests/pytest/test_cpu_queries.py index d3faa14720..b300447121 100644 --- a/tests/avocado/cpu_queries.py +++ b/tests/pytest/test_cpu_queries.py @@ -8,7 +8,7 @@ # 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_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest class QueryCPUModelExpansion(QemuSystemTest): """ diff --git a/tests/avocado/empty_cpu_model.py b/tests/pytest/test_empty_cpu_model.py similarity index 94% rename from tests/avocado/empty_cpu_model.py rename to tests/pytest/test_empty_cpu_model.py index d906ef3d3c..113740bc82 100644 --- a/tests/avocado/empty_cpu_model.py +++ b/tests/pytest/test_empty_cpu_model.py @@ -7,7 +7,7 @@ # # 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_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest class EmptyCPUModel(QemuSystemTest): def test(self): diff --git a/tests/avocado/mem-addr-space-check.py b/tests/pytest/test_mem_addr_space.py similarity index 99% rename from tests/avocado/mem-addr-space-check.py rename to tests/pytest/test_mem_addr_space.py index 85541ea051..6ae7ba5e6b 100644 --- a/tests/avocado/mem-addr-space-check.py +++ b/tests/pytest/test_mem_addr_space.py @@ -8,8 +8,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -from avocado_qemu import QemuSystemTest -import signal +from qemu_pytest import QemuSystemTest import time class MemAddrCheck(QemuSystemTest): diff --git a/tests/avocado/virtio_version.py b/tests/pytest/test_virtio_version.py similarity index 99% rename from tests/avocado/virtio_version.py rename to tests/pytest/test_virtio_version.py index afe5e828b5..ca3aa806df 100644 --- a/tests/avocado/virtio_version.py +++ b/tests/pytest/test_virtio_version.py @@ -12,7 +12,7 @@ import os from qemu.machine import QEMUMachine -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest # Virtio Device IDs: VIRTIO_NET = 1
These test are rather simple and don't need any modifications apart from adjusting the "from avocado_qemu" line. These tests can now be run directly via "pytest" by setting the PYTHONPATH environment variable to the python folder of QEMU and by providing the QEMU binary via the PYTEST_QEMU_BINARY environment variable, and the source and build directories via the PYTEST_SOURCE_ROOTand PYTEST_BUILD_ROOT environment variables. Signed-off-by: Thomas Huth <thuth@redhat.com> --- tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} | 2 +- .../empty_cpu_model.py => pytest/test_empty_cpu_model.py} | 2 +- .../mem-addr-space-check.py => pytest/test_mem_addr_space.py} | 3 +-- .../virtio_version.py => pytest/test_virtio_version.py} | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) rename tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} (96%) rename tests/{avocado/empty_cpu_model.py => pytest/test_empty_cpu_model.py} (94%) rename tests/{avocado/mem-addr-space-check.py => pytest/test_mem_addr_space.py} (99%) rename tests/{avocado/virtio_version.py => pytest/test_virtio_version.py} (99%)