From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720698987; cv=none; d=zohomail.com; s=zohoarc; b=aMHVwVSBJm0YxNq7KYz/QA2LEOqTpASp21ER509eDuZGL3/lO37jBk8vLfdQf2hiXxyIhmPrR0gJjRHZM7WH4g3koS9Guvajfxb1lD9/uh++z0jI+aQ+AXtUyVdCNPzzwr4yarebmi4J+ox4Y/UWYmAhnLD0rZv/RAKSUXWMCDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720698987; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=erdYB82SWsESpyIDAkDTJBDapAsUIM7zIcvc71btW3U=; b=kFqtGQkqqI8Spz+PPsFOv+u/NypnNlClMFiIpInNH/0nRGqA02P95gLu7fM/GDQu5ub4TlWMS38Pl1xHOtEm0cki9S6OM3obrONPrjLSof8na+ScXx6mij04yvzMdgVI9wK3vNN8VyYLiwxV/OonlnmXk7o56hkLGKJG/yd289o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720698987212718.8768801633281; Thu, 11 Jul 2024 04:56:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsPB-0002H9-4l; Thu, 11 Jul 2024 07:56:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsP9-0002By-Mz for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsP6-00046k-AB for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:07 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-Z4fZMx5wMqGIwaEd7ThW8A-1; Thu, 11 Jul 2024 07:56:00 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 924FB1935843; Thu, 11 Jul 2024 11:55:58 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C1251954219; Thu, 11 Jul 2024 11:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=erdYB82SWsESpyIDAkDTJBDapAsUIM7zIcvc71btW3U=; b=R4x9K/bB6grztvZJad2kBHvYkphtr1HwUmElvkHpiy6+yGfCaMOaFtg/MfZSKIEpFcwSy+ D1rzjsdVcPmQxgnCj4wsOGTFF2qgYHmM0MKHVEIr6qDRJjRcXHJD4MOQ3aw4kfUunyhS3N Lanp/1bRS+gi/qebTMu2BpEwkXW1i+s= X-MC-Unique: Z4fZMx5wMqGIwaEd7ThW8A-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 1/8] tests/pytest: Add base classes for the upcoming pytest-based tests Date: Thu, 11 Jul 2024 13:55:39 +0200 Message-ID: <20240711115546.40859-2-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720698988500116600 Content-Type: text/plain; charset="utf-8" The file is a copy of the tests/avocado/avocado_qemu/__init__.py file with some adjustments to get rid of the Avocado dependencies (i.e. we also have to drop the LinuxSSHMixIn and LinuxTest for now). The emulator binary, source and build directory are now passed via environment variables that will be set via meson.build later. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/__init__.py | 344 +++++++++++++++++++++++++++ 1 file changed, 344 insertions(+) create mode 100644 tests/pytest/qemu_pytest/__init__.py diff --git a/tests/pytest/qemu_pytest/__init__.py b/tests/pytest/qemu_pytes= t/__init__.py new file mode 100644 index 0000000000..e3ed32e3de --- /dev/null +++ b/tests/pytest/qemu_pytest/__init__.py @@ -0,0 +1,344 @@ +# Test class and utilities for functional tests +# +# Copyright 2018, 2024 Red Hat, Inc. +# +# Original Author (Avocado-based tests): +# Cleber Rosa +# +# Adaption for pytest based version: +# Thomas Huth +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import logging +import os +import shutil +import subprocess +import sys +import tempfile +import time +import uuid +import unittest + +from qemu.machine import QEMUMachine +from qemu.utils import (get_info_usernet_hostfwd_port, kvm_available, + tcg_available) + +BUILD_DIR =3D os.getenv('PYTEST_BUILD_ROOT') +SOURCE_DIR =3D os.getenv('PYTEST_SOURCE_ROOT') + +def has_cmd(name, args=3DNone): + """ + This function is for use in a @skipUnless decorator, e.g.: + + @skipUnless(*has_cmd('sudo -n', ('sudo', '-n', 'true'))) + def test_something_that_needs_sudo(self): + ... + """ + + if args is None: + args =3D ('which', name) + + try: + _, stderr, exitcode =3D run_cmd(args) + except Exception as e: + exitcode =3D -1 + stderr =3D str(e) + + if exitcode !=3D 0: + cmd_line =3D ' '.join(args) + err =3D f'{name} required, but "{cmd_line}" failed: {stderr.strip(= )}' + return (False, err) + else: + return (True, '') + +def has_cmds(*cmds): + """ + This function is for use in a @skipUnless decorator and + allows checking for the availability of multiple commands, e.g.: + + @skipUnless(*has_cmds(('cmd1', ('cmd1', '--some-parameter')), + 'cmd2', 'cmd3')) + def test_something_that_needs_cmd1_and_cmd2(self): + ... + """ + + for cmd in cmds: + if isinstance(cmd, str): + cmd =3D (cmd,) + + ok, errstr =3D has_cmd(*cmd) + if not ok: + return (False, errstr) + + return (True, '') + +def run_cmd(args): + subp =3D subprocess.Popen(args, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.PIPE, + universal_newlines=3DTrue) + stdout, stderr =3D subp.communicate() + ret =3D subp.returncode + + return (stdout, stderr, ret) + +def is_readable_executable_file(path): + return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK) + +def _console_interaction(test, success_message, failure_message, + send_string, keep_sending=3DFalse, vm=3DNone): + assert not keep_sending or send_string + if vm is None: + vm =3D test.vm + console =3D vm.console_file + console_logger =3D logging.getLogger('console') + while True: + if send_string: + vm.console_socket.sendall(send_string.encode()) + if not keep_sending: + send_string =3D None # send only once + try: + msg =3D console.readline().decode().strip() + except UnicodeDecodeError: + msg =3D None + if not msg: + continue + console_logger.debug(msg) + if success_message is None or success_message in msg: + break + if failure_message and failure_message in msg: + console.close() + fail =3D 'Failure message found in console: "%s". Expected: "%= s"' % \ + (failure_message, success_message) + test.fail(fail) + +def interrupt_interactive_console_until_pattern(test, success_message, + failure_message=3DNone, + interrupt_string=3D'\r'): + """ + Keep sending a string to interrupt a console prompt, while logging the + console output. Typical use case is to break a boot loader prompt, suc= h: + + Press a key within 5 seconds to interrupt boot process. + 5 + 4 + 3 + 2 + 1 + Booting default image... + + :param test: a test containing a VM that will have its console + read and probed for a success or failure message + :type test: :class:`qemu_pytest.QemuSystemTest` + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + :param interrupt_string: a string to send to the console before trying + to read a new line + """ + _console_interaction(test, success_message, failure_message, + interrupt_string, True) + +def wait_for_console_pattern(test, success_message, failure_message=3DNone, + vm=3DNone): + """ + Waits for messages to appear on the console, while logging the content + + :param test: a test containing a VM that will have its console + read and probed for a success or failure message + :type test: :class:`qemu_pytest.QemuSystemTest` + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + _console_interaction(test, success_message, failure_message, None, vm= =3Dvm) + +def exec_command(test, command): + """ + Send a command to a console (appending CRLF characters), while logging + the content. + + :param test: a test containing a VM. + :type test: :class:`qemu_pytest.QemuSystemTest` + :param command: the command to send + :type command: str + """ + _console_interaction(test, None, None, command + '\r') + +def exec_command_and_wait_for_pattern(test, command, + success_message, failure_message=3DN= one): + """ + Send a command to a console (appending CRLF characters), then wait + for success_message to appear on the console, while logging the. + content. Mark the test as failed if failure_message is found instead. + + :param test: a test containing a VM that will have its console + read and probed for a success or failure message + :type test: :class:`qemu_pytest.QemuSystemTest` + :param command: the command to send + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + _console_interaction(test, success_message, failure_message, command += '\r') + +class QemuBaseTest(unittest.TestCase): + + # default timeout for all tests, can be overridden + timeout =3D 120 + + qemu_bin =3D os.getenv('PYTEST_QEMU_BINARY') + + workdir =3D os.path.join(BUILD_DIR, 'tests/pytest') + logdir =3D os.path.join(BUILD_DIR, 'tests/pytest') + + cpu =3D None + machine =3D None + + log =3D logging.getLogger('qemu-pytest') + + def setUp(self, bin_prefix): + self.assertIsNotNone(BUILD_DIR, 'PYTEST_BUILD_ROOT must be set') + self.assertIsNotNone(SOURCE_DIR,'PYTEST_SOURCE_ROOT must be set') + self.assertIsNotNone(self.qemu_bin, 'PYTEST_QEMU_BINARY must be se= t') + + def fetch_asset(self, name, + asset_hash, algorithm=3DNone, + locations=3DNone, expire=3DNone, + find_only=3DFalse, cancel_on_missing=3DTrue): + return super().fetch_asset(name, + asset_hash=3Dasset_hash, + algorithm=3Dalgorithm, + locations=3Dlocations, + expire=3Dexpire, + find_only=3Dfind_only, + cancel_on_missing=3Dcancel_on_missing) + + +class QemuSystemTest(QemuBaseTest): + """Facilitates system emulation tests.""" + + def setUp(self): + self._vms =3D {} + + super().setUp('qemu-system-') + + def require_accelerator(self, accelerator): + """ + Requires an accelerator to be available for the test to continue + + It takes into account the currently set qemu binary. + + If the check fails, the test is canceled. If the check itself + for the given accelerator is not available, the test is also + canceled. + + :param accelerator: name of the accelerator, such as "kvm" or "tcg" + :type accelerator: str + """ + checker =3D {'tcg': tcg_available, + 'kvm': kvm_available}.get(accelerator) + if checker is None: + self.cancel("Don't know how to check for the presence " + "of accelerator %s" % accelerator) + if not checker(qemu_bin=3Dself.qemu_bin): + self.cancel("%s accelerator does not seem to be " + "available" % accelerator) + + def require_netdev(self, netdevname): + netdevhelp =3D run_cmd([self.qemu_bin, + '-M', 'none', '-netdev', 'help'])[0]; + if netdevhelp.find('\n' + netdevname + '\n') < 0: + self.cancel('no support for user networking') + + def require_multiprocess(self): + """ + Test for the presence of the x-pci-proxy-dev which is required + to support multiprocess. + """ + devhelp =3D run_cmd([self.qemu_bin, + '-M', 'none', '-device', 'help'])[0]; + if devhelp.find('x-pci-proxy-dev') < 0: + self.cancel('no support for multiprocess device emulation') + + def _new_vm(self, name, *args): + self._sd =3D tempfile.TemporaryDirectory(prefix=3D"qemu_") + vm =3D QEMUMachine(self.qemu_bin, base_temp_dir=3Dself.workdir, + log_dir=3Dself.logdir) + self.log.debug('QEMUMachine "%s" created', name) + self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir) + self.log.debug('QEMUMachine "%s" log_dir: %s', name, vm.log_dir) + if args: + vm.add_args(*args) + return vm + + def get_qemu_img(self): + self.log.debug('Looking for and selecting a qemu-img binary') + + # If qemu-img has been built, use it, otherwise the system wide one + # will be used. + qemu_img =3D os.path.join(BUILD_DIR, 'qemu-img') + if not os.path.exists(qemu_img): + qemu_img =3D find_command('qemu-img', False) + if qemu_img is False: + self.cancel('Could not find "qemu-img"') + + return qemu_img + + @property + def vm(self): + return self.get_vm(name=3D'default') + + def get_vm(self, *args, name=3DNone): + if not name: + name =3D str(uuid.uuid4()) + if self._vms.get(name) is None: + self._vms[name] =3D self._new_vm(name, *args) + if self.cpu is not None: + self._vms[name].add_args('-cpu', self.cpu) + if self.machine is not None: + self._vms[name].set_machine(self.machine) + return self._vms[name] + + def set_vm_arg(self, arg, value): + """ + Set an argument to list of extra arguments to be given to the QEMU + binary. If the argument already exists then its value is replaced. + + :param arg: the QEMU argument, such as "-cpu" in "-cpu host" + :type arg: str + :param value: the argument value, such as "host" in "-cpu host" + :type value: str + """ + if not arg or not value: + return + if arg not in self.vm.args: + self.vm.args.extend([arg, value]) + else: + idx =3D self.vm.args.index(arg) + 1 + if idx < len(self.vm.args): + self.vm.args[idx] =3D value + else: + self.vm.args.append(value) + + def tearDown(self): + for vm in self._vms.values(): + vm.shutdown() + self._sd =3D None + super().tearDown() + + +class QemuUserTest(QemuBaseTest): + """Facilitates user-mode emulation tests.""" + + def setUp(self): + self._ldpath =3D [] + super().setUp('qemu-') + + def add_ldpath(self, ldpath): + self._ldpath.append(os.path.abspath(ldpath)) + + def run(self, bin_path, args=3D[]): + qemu_args =3D " ".join(["-L %s" % ldpath for ldpath in self._ldpat= h]) + bin_args =3D " ".join(args) + return process.run("%s %s %s %s" % (self.qemu_bin, qemu_args, + bin_path, bin_args)) --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720699021; cv=none; d=zohomail.com; s=zohoarc; b=lwdpB7/ohdyQ01hksXWoM5Tf4uNmIzrLNP8lltplwMpPcXv+AwZ7dyf8LVDhUjmRssIbSXG1Hw99yZjTRlCEYxnIMgc/HEx+ZXxq1O6gv9yC8BB78uDziAcXFVLmDa1LhCL0h8FL9njDNgsnq22H5xhuI2LfiTczhZFAihu23Gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720699021; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kFDx3AzhkOo696BWjrSPKvBIZNzTiUauoq2tCa2FXRQ=; b=hSP73r9a8Dp1XJJzEFDuVgt6B6KN+244F4t//uVoI6hzmCGYLpFpcxireZ0GLSYB6MfF6vwtC5/ceNgRetMqD/ar4uJ+tsUGGQrVAXUCiVOHgIWc5NHNrWBzP5TqDf7iiHNo3BOSnUBZpQ8FtrXQVyACR4SvzsgAYsopDyX6LkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172069902165562.56940289110662; Thu, 11 Jul 2024 04:57:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsPe-00042I-1v; Thu, 11 Jul 2024 07:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPN-00036U-5w for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPA-000477-WB for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:20 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-lSR4S4ZyOLmSRa-sjdVGsw-1; Thu, 11 Jul 2024 07:56:05 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 38D6518B65CA; Thu, 11 Jul 2024 11:56:04 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A6DD1955E85; Thu, 11 Jul 2024 11:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kFDx3AzhkOo696BWjrSPKvBIZNzTiUauoq2tCa2FXRQ=; b=LpGvFQ1hnuWsJxizmWhbYZFZ8eBud0pnnNeY1tWWaZdBS8AxXcLx5KQIlzIWjQHzVKiljB N218YeQFO6LD6DFRlnJt2JanbQaGNHJwBLdhGr6eJKeYNyau2tmd4/YMk8I1Di+2EF8w4h EtoixkGnLdTCyv0HY5oPC7c1qRgLcfU= X-MC-Unique: lSR4S4ZyOLmSRa-sjdVGsw-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 2/8] tests/pytest: Convert some simple avocado tests into pytests Date: Thu, 11 Jul 2024 13:55:40 +0200 Message-ID: <20240711115546.40859-3-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699022597116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/{avocado/cpu_queries.py =3D> pytest/test_cpu_queries.py} | 2 +- .../empty_cpu_model.py =3D> pytest/test_empty_cpu_model.py} | 2 +- .../mem-addr-space-check.py =3D> pytest/test_mem_addr_space.py} | 3 +-- .../virtio_version.py =3D> pytest/test_virtio_version.py} | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) rename tests/{avocado/cpu_queries.py =3D> pytest/test_cpu_queries.py} (96%) rename tests/{avocado/empty_cpu_model.py =3D> pytest/test_empty_cpu_model.= py} (94%) rename tests/{avocado/mem-addr-space-check.py =3D> pytest/test_mem_addr_sp= ace.py} (99%) rename tests/{avocado/virtio_version.py =3D> pytest/test_virtio_version.py= } (99%) 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. =20 -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest =20 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 =20 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 =20 -from avocado_qemu import QemuSystemTest -import signal +from qemu_pytest import QemuSystemTest import time =20 class MemAddrCheck(QemuSystemTest): diff --git a/tests/avocado/virtio_version.py b/tests/pytest/test_virtio_ver= sion.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 =20 from qemu.machine import QEMUMachine -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest =20 # Virtio Device IDs: VIRTIO_NET =3D 1 --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720698999; cv=none; d=zohomail.com; s=zohoarc; b=m+Nf4VYU42RUxZCVevkiXulpCfLwx00Vq3sr5OdyJ3uhJcAq2sD6oaU+hdK/qFkH9i4nHr8Tyxjg8Mz38dlBg+ufs4gorDW6Ygb2A2nj2qrnv2vEOfGnJzw+vJlIs/8wJWjTIHDUCfbpdHjFl04cwdFX3B2F+NZgX2X5wD9ALy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720698999; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5fu+46QJHWywwyFBmzBK0M1K/+VQFbUkdqggpGNG6nA=; b=Il/TOUSG6wyQBgB5QgqUDkUUkeidoWyvKjhmVX7BawokYSUvWDCgEnNPOZa9VxQizvpizYXPDVPbB7rBs67GoV5pnhaAobWB9enaBMYryS3NUL4uf/TFvibTQtMNqIIWut45RZvXEBkAVPXF3HjoxFI0fWSbVmSHV2JH7StO8bo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172069899995074.80588177800723; Thu, 11 Jul 2024 04:56:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsPX-0003Hf-VM; Thu, 11 Jul 2024 07:56:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPI-0002kb-Ho for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPG-000499-1F for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:16 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-5Aret1sqNmuU2q5FhBmxEA-1; Thu, 11 Jul 2024 07:56:09 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 17A481954B3E; Thu, 11 Jul 2024 11:56:08 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A5F761955BD4; Thu, 11 Jul 2024 11:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5fu+46QJHWywwyFBmzBK0M1K/+VQFbUkdqggpGNG6nA=; b=eeu79MPMnYBVh77vjljDrdIe2dzcdRvZ4zMdAhMp4r8y92Gi7huBFNMULH4Ik17EhDjhga oCBFeVOniOMn+971TQ0k6/1nh7edenoJrDTdhFSi+oZfXZkhCAoIeRm1qTuVxOlGzhswgs nUEiNou3C6pid7voWhXQmm/J2HUzFhk= X-MC-Unique: 5Aret1sqNmuU2q5FhBmxEA-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 3/8] tests/pytest: Convert info_usernet and version test with small adjustments Date: Thu, 11 Jul 2024 13:55:41 +0200 Message-ID: <20240711115546.40859-4-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699000497116600 Content-Type: text/plain; charset="utf-8" These two simple tests can be converted to a pytest quite easily, we just have to set the machine to 'none' now manually since we don't support the avocado tags here yet. Signed-off-by: Thomas Huth Reviewed-by: Daniel P. Berrang=C3=A9 --- .../info_usernet.py =3D> pytest/test_info_usernet.py} | 6 ++---- tests/{avocado/version.py =3D> pytest/test_version.py} | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) rename tests/{avocado/info_usernet.py =3D> pytest/test_info_usernet.py} (9= 1%) rename tests/{avocado/version.py =3D> pytest/test_version.py} (82%) diff --git a/tests/avocado/info_usernet.py b/tests/pytest/test_info_usernet= .py similarity index 91% rename from tests/avocado/info_usernet.py rename to tests/pytest/test_info_usernet.py index e1aa7a6e0a..0cc3697c0b 100644 --- a/tests/avocado/info_usernet.py +++ b/tests/pytest/test_info_usernet.py @@ -8,18 +8,16 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest =20 from qemu.utils import get_info_usernet_hostfwd_port =20 =20 class InfoUsernet(QemuSystemTest): - """ - :avocado: tags=3Dmachine:none - """ =20 def test_hostfwd(self): self.require_netdev('user') + self.machine =3D 'none' self.vm.add_args('-netdev', 'user,id=3Dvnet,hostfwd=3D:127.0.0.1:0= -:22') self.vm.launch() res =3D self.vm.cmd('human-monitor-command', diff --git a/tests/avocado/version.py b/tests/pytest/test_version.py similarity index 82% rename from tests/avocado/version.py rename to tests/pytest/test_version.py index c6139568a1..2d16b4075d 100644 --- a/tests/avocado/version.py +++ b/tests/pytest/test_version.py @@ -9,15 +9,13 @@ # later. See the COPYING file in the top-level directory. =20 =20 -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest =20 =20 class Version(QemuSystemTest): - """ - :avocado: tags=3Dquick - :avocado: tags=3Dmachine:none - """ + def test_qmp_human_info_version(self): + self.machine =3D 'none' self.vm.add_args('-nodefaults') self.vm.launch() res =3D self.vm.cmd('human-monitor-command', --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720699073; cv=none; d=zohomail.com; s=zohoarc; b=VawfXQycTdWUEo//P9yRCv6J5o3fpSAAJUH73QNfj7MGpM465h4FY/pCpLCMtTREXTCNeX+bO4xvrPCuCjTr9YP7lUgUP7LkD8rPE/ew8XavU62qfxPoLzLYf149lwpUQz1dIy1uwY/ib+9heZ+k3BGVL6iEDqrauv/ZdAnoVdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720699073; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BzwkZqC9qi7v/FxNIMeqQtAlpjf1dJrzDsFE1tBNDhQ=; b=SQIkvTppN1D19QgBkM6vGvq6C8oHT4nw1i3zatNkXgcrfxa3FNcWNqtbwWyw1sI5Y40VADwAQ/5t5wVLSY7KzzQmTNV64qH2zGfHk/pJnCDIwzq/gp8VuiKM4PdOQE8I86i1iDyPnblGuVDQsM3eOoEG9ux6mUwOdb384razZ5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720699073334608.7309225809615; Thu, 11 Jul 2024 04:57:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsPo-00050E-NK; Thu, 11 Jul 2024 07:56:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPL-0002xz-Li for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPJ-00049T-Dx for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:19 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-w-RpeTIWNEWJ0u0oPU7Slw-1; Thu, 11 Jul 2024 07:56:13 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4CE7519773FE; Thu, 11 Jul 2024 11:56:12 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BA4A61955E85; Thu, 11 Jul 2024 11:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BzwkZqC9qi7v/FxNIMeqQtAlpjf1dJrzDsFE1tBNDhQ=; b=K9h6r2i1CKpcclCM6oKCDoj9b0KRMFTHVj0lAtXc6cD98XsHobnbu/A2+PBQ30g3QJLM4Q D8f77gdvcam8Ufl+RnawvIJkKqLpYvL/aMHJ/rOA9aKz+ET2FJcYMaT6MlHGJTqJ0rTHbZ 0Eam+btOI0iAKhgjA17WHdqJhkvHfH4= X-MC-Unique: w-RpeTIWNEWJ0u0oPU7Slw-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 4/8] tests/pytest: add pytest to the meson build system Date: Thu, 11 Jul 2024 13:55:42 +0200 Message-ID: <20240711115546.40859-5-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699074860116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha Integrate the pytest framework with the meson build system. This will make meson run all the pytests under the pytest directory. Signed-off-by: Ani Sinha [thuth: Removed the acpi-bits and adjusted for converted avocado tests inst= ead] Signed-off-by: Thomas Huth --- tests/Makefile.include | 4 ++- tests/meson.build | 1 + tests/pytest/meson.build | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/pytest/meson.build diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..68151717d7 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -3,12 +3,14 @@ .PHONY: check-help check-help: @echo "Regression testing targets:" - @echo " $(MAKE) check Run block, qapi-schema, unit, soft= float, qtest and decodetree tests" + @echo " $(MAKE) check Run block, qapi-schema, unit, soft= float, qtest, pytest and decodetree tests" @echo " $(MAKE) bench Run speed tests" @echo @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtest Run qtest tests" + @echo " $(MAKE) check-pytest Run pytest tests" + @echo " $(MAKE) check-pytest-TARGET Run pytest for a given target" @echo " $(MAKE) check-unit Run qobject tests" @echo " $(MAKE) check-qapi-schema Run QAPI schema tests" @echo " $(MAKE) check-block Run block tests" diff --git a/tests/meson.build b/tests/meson.build index acb6807094..17510a468e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -85,3 +85,4 @@ subdir('unit') subdir('qapi-schema') subdir('qtest') subdir('migration') +subdir('pytest') diff --git a/tests/pytest/meson.build b/tests/pytest/meson.build new file mode 100644 index 0000000000..1486628d45 --- /dev/null +++ b/tests/pytest/meson.build @@ -0,0 +1,53 @@ +slow_pytests =3D { + 'mem_addr_space' : 90, +} + +pytests_generic =3D [ + 'empty_cpu_model', + 'info_usernet', + 'version', +] + +pytests_x86_64 =3D [ + 'cpu_queries', + 'mem_addr_space', + 'virtio_version', +] + +pytest =3D find_program('pytest', required: false) +if not pytest.found() + message('pytest not available =3D=3D> Disabled the qemu-pytests.') + subdir_done() +endif + +foreach dir : target_dirs + if not dir.endswith('-softmmu') + continue + endif + + target_base =3D dir.split('-')[0] + pytest_emulator =3D emulators['qemu-system-' + target_base] + target_pytests =3D get_variable('pytests_' + target_base, []) + pytests_= generic + + test_deps =3D roms + pytest_env =3D environment() + if have_tools + pytest_env.set('PYTEST_QEMU_IMG', './qemu-img') + test_deps +=3D [qemu_img] + endif + pytest_env.set('PYTEST_QEMU_BINARY', meson.global_build_root() / 'qemu-s= ystem-' + target_base) + pytest_env.set('PYTEST_SOURCE_ROOT', meson.project_source_root()) + pytest_env.set('PYTEST_BUILD_ROOT', meson.project_build_root()) + pytest_env.set('PYTHONPATH', meson.project_source_root() / 'python') + + foreach test : target_pytests + test('pytest-@0@/@1@'.format(target_base, test), + pytest, + depends: [test_deps, pytest_emulator, emulator_modules], + env: pytest_env, + args: [meson.current_source_dir() / 'test_' + test + '.py'], + timeout: slow_pytests.get(test, 60), + priority: slow_pytests.get(test, 60), + suite: ['pytest', 'pytest-' + target_base]) + endforeach +endforeach --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720699063; cv=none; d=zohomail.com; s=zohoarc; b=eH8y/I1FRQr15gEAkbylHj+eLFfe7JMPQeVfzkYoTB3tvLwD6A06XY1RHoHSdVPDkE5ecNnPfQ4GMFpF12qFCwkGP1Z81NEu43xrX9KQ8hQ569Hp1zaFa+qcxprq+OeYnuOLRP8ESEDYp9AVOcPtRa35muiwEMppbieyfgKlQWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720699063; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UTuTKKfgydqIlWwz40hk1KYERihdyi4iwi8ncTl+GqU=; b=DAOpP/v94nY2hv91VNK7HfX4wABsdCSyM0YQ+Shonp5AZdPZgPraHYFfkMs+lTYMQkY7PmAOpiyolExtaObJEEFieOnAgutxOJD4DBSftaloAtaP2AsSey0WSGF8OnpKPkVwV45Y9UR5NxsUdW1/72LgsH9+26cIgzQJpzrud9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720699063237868.5743811281617; Thu, 11 Jul 2024 04:57:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsPj-0004bG-1P; Thu, 11 Jul 2024 07:56:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPQ-0003Ir-6j for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPO-0004A1-CA for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:23 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-8fKPfOauNiqQ3xuDW3yjlg-1; Thu, 11 Jul 2024 07:56:18 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EBA6419792FB; Thu, 11 Jul 2024 11:56:16 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D2ECA1955BD4; Thu, 11 Jul 2024 11:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UTuTKKfgydqIlWwz40hk1KYERihdyi4iwi8ncTl+GqU=; b=EVbmz/EN2IgMvg9p9Xde9wSgZ2ZCSwp+lOOaDYsJxO8nGAl3Mg2bnyjR2sfBQA/4/vHnYw tmPrtzDuktIU2wNgSHcsxs7zot5FtCoXtufAKJSHvnsOXp4iPfDDp8K3+Q1o0ErIBqQwEl Hkyh/yll4OtjaMOc1AO6itBW0WkkA8o= X-MC-Unique: 8fKPfOauNiqQ3xuDW3yjlg-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 5/8] tests_pytest: Implement fetch_asset() method for downloading assets Date: Thu, 11 Jul 2024 13:55:43 +0200 Message-ID: <20240711115546.40859-6-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699064836116600 Content-Type: text/plain; charset="utf-8" In the pytests, we cannot use the fetch_asset() function from Avocado anymore, so we have to provide our own implementation now instead. Thus add such a function based on the _download_with_cache() function from tests/vm/basevm.py for this purpose. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/__init__.py | 40 ++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/pytest/qemu_pytest/__init__.py b/tests/pytest/qemu_pytes= t/__init__.py index e3ed32e3de..73d80b3828 100644 --- a/tests/pytest/qemu_pytest/__init__.py +++ b/tests/pytest/qemu_pytest/__init__.py @@ -11,6 +11,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. =20 +import hashlib import logging import os import shutil @@ -201,17 +202,34 @@ def setUp(self, bin_prefix): self.assertIsNotNone(SOURCE_DIR,'PYTEST_SOURCE_ROOT must be set') self.assertIsNotNone(self.qemu_bin, 'PYTEST_QEMU_BINARY must be se= t') =20 - def fetch_asset(self, name, - asset_hash, algorithm=3DNone, - locations=3DNone, expire=3DNone, - find_only=3DFalse, cancel_on_missing=3DTrue): - return super().fetch_asset(name, - asset_hash=3Dasset_hash, - algorithm=3Dalgorithm, - locations=3Dlocations, - expire=3Dexpire, - find_only=3Dfind_only, - cancel_on_missing=3Dcancel_on_missing) + def check_hash(self, file_name, expected_hash): + if not expected_hash: + return True + if len(expected_hash) =3D=3D 32: + sum_prog =3D 'md5sum' + elif len(expected_hash) =3D=3D 40: + sum_prog =3D 'sha1sum' + elif len(expected_hash) =3D=3D 64: + sum_prog =3D 'sha256sum' + elif len(expected_hash) =3D=3D 128: + sum_prog =3D 'sha512sum' + else: + raise Exception("unknown hash type") + checksum =3D subprocess.check_output([sum_prog, file_name]).split(= )[0] + return expected_hash =3D=3D checksum.decode("utf-8") + + def fetch_asset(self, url, asset_hash): + cache_dir =3D os.path.expanduser("~/.cache/qemu/download") + if not os.path.exists(cache_dir): + os.makedirs(cache_dir) + fname =3D os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) + if os.path.exists(fname) and self.check_hash(fname, asset_hash): + return fname + logging.debug("Downloading %s to %s...", url, fname) + subprocess.check_call(["wget", "-c", url, "-O", fname + ".download= "]) + os.rename(fname + ".download", fname) + return fname =20 =20 class QemuSystemTest(QemuBaseTest): --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720699059; cv=none; d=zohomail.com; s=zohoarc; b=NeN4ejPeFaH/kvFiNYMqkgQKNmXBIIRh4NLlxQ7eMFoRM5R1XIzhsTideWk5Yl07peryysyo9e4lhhu/GWSznJXeKwD4mjYQRk6BHPjfTYL3WSC5I09k5u79wx6Ca7rvqQ0TGdHNnhB92thmod86LxtGbVJ5TRrrHO5YB8Sv0Yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720699059; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h18LYbjBJTgvDMDvH+3FMrTXwPHvgF54cOWbiPgrN0I=; b=JUjYlTDmfW7zvkPqk5m+AGgvJstTCdkpJTFWu+SRcPEZk+NC2aOyjPwEeaGtAvhXOebClJiBU/tZ7VZCgwifeJNy+FGznO9OJKeYU2OWdr7dL981K3mIXguCIrs0JnnakqnzV4K7bKI0m1+u0yW37bG652Q+TXOrog9xVI3het8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720699059858385.15740129510846; Thu, 11 Jul 2024 04:57:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsQ7-0006P3-OP; Thu, 11 Jul 2024 07:57:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPZ-00040n-Ro for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPU-0004Ad-BP for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:32 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-M5v_Oe42NuKpmiTR4JIW3Q-1; Thu, 11 Jul 2024 07:56:23 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C9BA1954B3F; Thu, 11 Jul 2024 11:56:22 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 375F21954219; Thu, 11 Jul 2024 11:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h18LYbjBJTgvDMDvH+3FMrTXwPHvgF54cOWbiPgrN0I=; b=ckfJVyoDa2WtiDi5YaeyQoCWy5QDeUbZkDHodejKbKC9P00r3fgQlfp9h4cSK0mFTtk7fM g6yYa+y0wmG509Hx94OwVie6ZY1A2laBhR8fWu5U6bI8hk6pRpIJH7UV6gGSBS4ouWH2F5 LiveEfLDym0RqdiI49uhkYQEmMEeFKU= X-MC-Unique: M5v_Oe42NuKpmiTR4JIW3Q-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow 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 Message-ID: <20240711115546.40859-7-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699060845116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 =3D> pytest/test_machine_arm_n8x= 0.py} (71%) rename tests/{avocado/machine_avr6.py =3D> pytest/test_machine_avr6.py} (9= 1%) rename tests/{avocado/machine_loongarch.py =3D> pytest/test_machine_loonga= rch.py} (89%) rename tests/{avocado/machine_mips_loongson3v.py =3D> 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 =3D [ 'version', ] =20 +pytests_arm =3D [ + 'machine_arm_n8x0', +] + +pytests_avr =3D [ + 'machine_avr6', +] + +pytests_loongarch64 =3D [ + 'machine_loongarch', +] + +pytests_mips64el =3D [ + 'machine_mips_loongson3v', +] + pytests_x86_64 =3D [ '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 @@ =20 import os =20 -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 =20 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') =20 - @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code= ') + @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted co= de') def test_n800(self): - """ - :avocado: tags=3Darch:arm - :avocado: tags=3Dmachine:n800 - """ + self.machine =3D 'n800' self.__do_test_n8x0() =20 - @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code= ') + @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted co= de') def test_n810(self): - """ - :avocado: tags=3Darch:arm - :avocado: tags=3Dmachine:n810 - """ + self.machine =3D '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 @@ =20 import time =20 -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest =20 class AVR6Machine(QemuSystemTest): timeout =3D 5 =20 def test_freertos(self): - """ - :avocado: tags=3Darch:avr - :avocado: tags=3Dmachine:arduino-mega-2560-v3 - """ """ https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/De= mo/AVR_ATMega2560_GCC/demo.elf constantly prints out 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRS= TUVWX' @@ -39,6 +35,7 @@ def test_freertos(self): rom_hash =3D '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4' rom_path =3D self.fetch_asset(rom_url, asset_hash=3Drom_hash) =20 + self.machine =3D '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 # =20 -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 =20 class LoongArchMachine(QemuSystemTest): KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D0 ' @@ -21,10 +21,7 @@ def wait_for_console_pattern(self, success_message, vm= =3DNone): =20 def test_loongarch64_devices(self): =20 - """ - :avocado: tags=3Darch:loongarch64 - :avocado: tags=3Dmachine:virt - """ + self.machine =3D 'virt' =20 kernel_url =3D ('https://github.com/yangxiaojuan-loongson/qemu-bin= ary/' 'releases/download/2024-05-30/vmlinuz.efi') diff --git a/tests/avocado/machine_mips_loongson3v.py b/tests/pytest/test_m= achine_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 =20 -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 =20 class MipsLoongson3v(QemuSystemTest): timeout =3D 60 =20 - @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code= ') + @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted co= de') def test_pmon_serial_console(self): - """ - :avocado: tags=3Darch:mips64el - :avocado: tags=3Dendian:little - :avocado: tags=3Dmachine:loongson3-virt - :avocado: tags=3Dcpu:Loongson-3A1000 - :avocado: tags=3Ddevice:liointc - :avocado: tags=3Ddevice:goldfish_rtc - """ + self.machine =3D 'loongson3-virt' =20 pmon_hash =3D '7c8b45dd81ccfc55ff28f5aa267a41c3' pmon_path =3D self.fetch_asset('https://github.com/loongson-commun= ity/pmon/' 'releases/download/20210112/pmon-3avir= t.bin', - asset_hash=3Dpmon_hash, algorithm=3D'= md5') + asset_hash=3Dpmon_hash) =20 self.vm.set_console() self.vm.add_args('-bios', pmon_path) --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720699074; cv=none; d=zohomail.com; s=zohoarc; b=i5UvMqKbSGd6ixTytpakM9CbFv1717x+oHW0BOjOWD08RWsN8qewnsDceTVu56nppeTdBMD/WGoe5DPdpNFUp6eP4dn3TAuu6CiD9xt7Sohvn/hMuS/IQBGPoU5Cy+6PrxZRy6KtLqfMMctgtvHTkobRYMzW/NBwriTnYUS3EzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720699074; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L9XVptoyfJC1s3k6W3dh/KudkasKHfThFVX6ebRGQmU=; b=azyFPuGDhysecCYcw+FTH36djUmtTevwRq5E4c+zE2EeisToN/spgDJpVj04eVgRfkwzDXgzeHTVr5lIzOtgcZcf/p7oMQb/30/nr0iHO7WBoOCOwSKQ9HGr6Wnp+R/Hy4YVcb6NMk5J0Dw8PQ7rtjaNHTjVi62EbnSXWtbEdqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720699074210156.8647213250573; Thu, 11 Jul 2024 04:57:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsQA-0006gO-D2; Thu, 11 Jul 2024 07:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPb-00048J-NX for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPZ-0004Do-Js for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:35 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-6zsrmp6PObmI4rS45OLNbw-1; Thu, 11 Jul 2024 07:56:27 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 707F619331B2; Thu, 11 Jul 2024 11:56:26 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D79471954225; Thu, 11 Jul 2024 11:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L9XVptoyfJC1s3k6W3dh/KudkasKHfThFVX6ebRGQmU=; b=K78Y8fiyYjc7EerJpk2vGgoTCEeEjgroC0EnkqJoClXgTadKyl7639c3r2fayAh0SNqnKh vAh3peML+EagCXfMXI0+m02ryUs4qSPSbs2/GiNNrFhMmc6NvDJpbGnHmG/2h+DjYOh/pB 7cem5Xhxu8faE2ScWGJhup4UsfVimkI= X-MC-Unique: 6zsrmp6PObmI4rS45OLNbw-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 7/8] tests/pytest: Add a function for extracting files from an archive Date: Thu, 11 Jul 2024 13:55:45 +0200 Message-ID: <20240711115546.40859-8-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699074841116600 Content-Type: text/plain; charset="utf-8" Some Avocado-based tests use the "archive" module from avocado.utils to extract files from an archive. To be able to use these tests without Avocado, we have to provide our own function for extracting files. Fortunately, there is already the tarfile module that will provide us with this functionality, so let's just add a nice wrapper function around that. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/pytest/qemu_pytest/utils.py diff --git a/tests/pytest/qemu_pytest/utils.py b/tests/pytest/qemu_pytest/u= tils.py new file mode 100644 index 0000000000..4eb5e5d5e5 --- /dev/null +++ b/tests/pytest/qemu_pytest/utils.py @@ -0,0 +1,21 @@ +# Utilities for python-based QEMU tests +# +# Copyright 2024 Red Hat, Inc. +# +# Authors: +# Thomas Huth +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import tarfile + +def archive_extract(archive, dest_dir, member=3DNone): + with tarfile.open(archive) as tf: + if hasattr(tarfile, 'data_filter'): + tf.extraction_filter =3D getattr(tarfile, 'data_filter', + (lambda member, path: member)) + if member: + tf.extract(member=3Dmember, path=3Ddest_dir) + else: + tf.extractall(path=3Ddest_dir) --=20 2.45.2 From nobody Sun Nov 24 19:00:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720699030; cv=none; d=zohomail.com; s=zohoarc; b=Uv7wUMAYMvt+8MiPviQuVliAqTUzeZjZAY06O1MlbG6oCK9RUkRhn3m4/odHPgNimcSUlPrMLk1MErhO3Hz9Hx0xPK/NcassXguJX8nb/kZRO3mC7/lWEc6qIfXJUY0MK+G3UyQzJwVgdPTsboMuIKLD02R274IoV2D4twaDd2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720699030; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L5PcsCgL2IcK8j5iQ5rWgADeldCnm0hNp0IysS8YInY=; b=akbpwRe4nOpY+pVUuGtnQCXA6WFdNrDLQpqnwSS0FvyI3QNeNMrNYG5j0XI7o/+TPzgOPaDZK1WcxFwXmmAM49YH4FaNVkL0pnFAkM60aX5Lx5HifkFTuP7mF2rwFX3nlGY9PvL2NQdFaMmmhh2ty8ngqh4GazltXmQyunWhBoQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720699030769779.6046351698845; Thu, 11 Jul 2024 04:57:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRsPz-00059L-VZ; Thu, 11 Jul 2024 07:57:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPd-0004GY-ME for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRsPa-0004ER-Un for qemu-devel@nongnu.org; Thu, 11 Jul 2024 07:56:37 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-X1AUam9sNcW5Bpm4uk_6dg-1; Thu, 11 Jul 2024 07:56:32 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 308251944DFE; Thu, 11 Jul 2024 11:56:31 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.193.118]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E636D1955E85; Thu, 11 Jul 2024 11:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720698994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L5PcsCgL2IcK8j5iQ5rWgADeldCnm0hNp0IysS8YInY=; b=cPIGj1Gn959lUGaSMsAig1mQsB+/2ZRVGCBs5+AJYXpYfY5L2GmOdrpuVjSJG+Cznne3n9 KsMxsOPOHN3xSlffNSHCl8LED3wxw0Z+vD5m0KesXSektp8+6Sa8fuWDswTdJ9VnohGncI G5QCwde7RcCt482ilj2d3JjZrANewpE= X-MC-Unique: X1AUam9sNcW5Bpm4uk_6dg-1 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Ani Sinha , Richard Henderson , Paolo Bonzini , "Daniel P . Berrange" , John Snow Subject: [RFC PATCH 8/8] tests/pytest: Convert avocado test that needed avocado.utils.archive Date: Thu, 11 Jul 2024 13:55:46 +0200 Message-ID: <20240711115546.40859-9-thuth@redhat.com> In-Reply-To: <20240711115546.40859-1-thuth@redhat.com> References: <20240711115546.40859-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720699032758116600 Content-Type: text/plain; charset="utf-8" Instead of using the "archive" module from avocado.utils, switch these tests to use the new wrapper function that is based on the "tarfile" module instead. Signed-off-by: Thomas Huth --- tests/pytest/meson.build | 5 +++++ .../test_arm_canona1100.py} | 16 +++++++--------- .../test_ppc_bamboo.py} | 18 ++++++------------ 3 files changed, 18 insertions(+), 21 deletions(-) rename tests/{avocado/machine_arm_canona1100.py =3D> pytest/test_arm_canon= a1100.py} (74%) rename tests/{avocado/ppc_bamboo.py =3D> pytest/test_ppc_bamboo.py} (75%) diff --git a/tests/pytest/meson.build b/tests/pytest/meson.build index d3607db362..baaacf00cc 100644 --- a/tests/pytest/meson.build +++ b/tests/pytest/meson.build @@ -9,6 +9,7 @@ pytests_generic =3D [ ] =20 pytests_arm =3D [ + 'arm_canona1100', 'machine_arm_n8x0', ] =20 @@ -24,6 +25,10 @@ pytests_mips64el =3D [ 'machine_mips_loongson3v', ] =20 +pytests_ppc =3D [ + 'ppc_bamboo', +] + pytests_x86_64 =3D [ 'cpu_queries', 'mem_addr_space', diff --git a/tests/avocado/machine_arm_canona1100.py b/tests/pytest/test_ar= m_canona1100.py similarity index 74% rename from tests/avocado/machine_arm_canona1100.py rename to tests/pytest/test_arm_canona1100.py index a42d8b0f2b..296df41a06 100644 --- a/tests/avocado/machine_arm_canona1100.py +++ b/tests/pytest/test_arm_canona1100.py @@ -8,9 +8,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado.utils import archive +from qemu_pytest import QemuSystemTest +from qemu_pytest import wait_for_console_pattern +from qemu_pytest.utils import archive_extract =20 class CanonA1100Machine(QemuSystemTest): """Boots the barebox firmware and checks that the console is operation= al""" @@ -18,16 +18,14 @@ class CanonA1100Machine(QemuSystemTest): timeout =3D 90 =20 def test_arm_canona1100(self): - """ - :avocado: tags=3Darch:arm - :avocado: tags=3Dmachine:canon-a1100 - :avocado: tags=3Ddevice:pflash_cfi02 - """ + self.machine =3D 'canon-a1100' + tar_url =3D ('https://qemu-advcal.gitlab.io' '/qac-best-of-multiarch/download/day18.tar.xz') tar_hash =3D '068b5fc4242b29381acee94713509f8a876e9db6' file_path =3D self.fetch_asset(tar_url, asset_hash=3Dtar_hash) - archive.extract(file_path, self.workdir) + archive_extract(file_path, dest_dir=3Dself.workdir, + member=3D"day18/barebox.canon-a1100.bin") self.vm.set_console() self.vm.add_args('-bios', self.workdir + '/day18/barebox.canon-a1100.bin') diff --git a/tests/avocado/ppc_bamboo.py b/tests/pytest/test_ppc_bamboo.py similarity index 75% rename from tests/avocado/ppc_bamboo.py rename to tests/pytest/test_ppc_bamboo.py index a81be3d608..4964dedbfe 100644 --- a/tests/avocado/ppc_bamboo.py +++ b/tests/pytest/test_ppc_bamboo.py @@ -5,30 +5,24 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 -from avocado.utils import archive -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado_qemu import exec_command_and_wait_for_pattern +from qemu_pytest.utils import archive_extract +from qemu_pytest import QemuSystemTest +from qemu_pytest import wait_for_console_pattern +from qemu_pytest import exec_command_and_wait_for_pattern =20 class BambooMachine(QemuSystemTest): =20 timeout =3D 90 =20 def test_ppc_bamboo(self): - """ - :avocado: tags=3Darch:ppc - :avocado: tags=3Dmachine:bamboo - :avocado: tags=3Dcpu:440epb - :avocado: tags=3Ddevice:rtl8139 - :avocado: tags=3Daccel:tcg - """ + self.machine =3D 'bamboo' self.require_accelerator("tcg") self.require_netdev('user') tar_url =3D ('http://landley.net/aboriginal/downloads/binaries/' 'system-image-powerpc-440fp.tar.gz') tar_hash =3D '53e5f16414b195b82d2c70272f81c2eedb39bad9' file_path =3D self.fetch_asset(tar_url, asset_hash=3Dtar_hash) - archive.extract(file_path, self.workdir) + archive_extract(file_path, self.workdir) self.vm.set_console() self.vm.add_args('-kernel', self.workdir + '/system-image-powerpc-440fp/linux', --=20 2.45.2