From nobody Mon Feb 9 22:04:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636388282; cv=none; d=zohomail.com; s=zohoarc; b=moRHcwFg074vq/83A/w0a4Q0JS+sl8/iFDtqpn5e40FhHge3Nyw2xN+Nk6XV17tdOfy5a/o2bQRsvQFhA76qTKBP6Et5Y+YWB3Nn2CrrcmnGd3Z9YHD4J/CZqYzR5+TtV1U4Vy/eZegg0CLuVrzAvIKp8Ri7omuCcGjvtEEZKvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636388282; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=SkxNHhX0QyQYxC8RhzB2xljeUh5RuXRUdAlFWY5fKNk=; b=ag64yuyyM/lJEyR1ykxW0Wjq9sHvlBZ1jFJjZYD6m8qZzlzUYabpWwPRPpfLHyNIYDcM6/GCZkIcPmHcZfTr+2hA0PLX+VoJW7NKVEy6Ax5YEkh9NE9+zlHH9CndVkhG5I64grPDbUXMuF8vK7Db/HPIQFVV9NV7RGH1sLu7RlY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636388282023162.70153186612276; Mon, 8 Nov 2021 08:18:02 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-zFvg82QNMcmoU56P2F2alw-1; Mon, 08 Nov 2021 11:17:59 -0500 Received: by mail-wm1-f70.google.com with SMTP id y9-20020a1c7d09000000b003316e18949bso6408516wmc.5 for ; Mon, 08 Nov 2021 08:17:59 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (46.red-193-152-127.dynamicip.rima-tde.net. [193.152.127.46]) by smtp.gmail.com with ESMTPSA id a22sm2510255wme.19.2021.11.08.08.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 08:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636388280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SkxNHhX0QyQYxC8RhzB2xljeUh5RuXRUdAlFWY5fKNk=; b=XY3ZumX6Q5UwtHdIaN6qKhylY328syXBswK81xJPKA1y3uY5kUsptgaaTIYH7CwZxd4f82 wzf10nLJqwlOq7rdHR5eyBhVAIOddW1RaS0aej/eFa1gkwW9ILeirjoMlu3Zu9wSjQs1w9 PLdVbo7PsCec6HEfWJu9nuDjVHgZsuM= X-MC-Unique: zFvg82QNMcmoU56P2F2alw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SkxNHhX0QyQYxC8RhzB2xljeUh5RuXRUdAlFWY5fKNk=; b=SXl7QijTRdF+yU6bs0SS8Yy2x7Vq4cBoMkkCwZlLWLH01s1JTr0iLAWJKd0RgHv+k1 XG4XvR8l89HBIT75QPjQcAG0bexpLD3h0Mdx3rOyPQDaGvCRyWUu/E5cPAg1e4MRBLJM Miq3XReW0E++08sNtvvO5vIbC9yRaJ1s1PG+fCtLxKwTq83Ze8wkhqJnKTaHCiEjZact n+0VAYSdVxodlRJlvqTfrTfui6n1jArVWJHdOw8ruuaasSQ3iwqd1Nq4Nsrkdn+Fr4pg MXyVAKUS/wag6GEHQw+gt/j1RT994ooHoM9QowqtR7n1mAIRnYygi8ZQGZLXb3PBDdpp u38A== X-Gm-Message-State: AOAM533rLhBEv3GS01j1dCZyrgFECe+M9iLeh3KFdZ5+K81l2sT4Zlbp ZxsF+odI9WIwOYLRxWylj7ljSAn1LbNaTAp8lpm/4RpOtnnqlviWPHgeLXA6pHBzbZRXfvyFT8P byaBSlo3W+tDezQ== X-Received: by 2002:a1c:f601:: with SMTP id w1mr52958088wmc.112.1636388278672; Mon, 08 Nov 2021 08:17:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyU1qEb2Tt0PN1PqdGZQvCUOFktUodF1gpcslcUV8/wGW+gwQKWF5jQf9TVB/pKtfVN+BOkmA== X-Received: by 2002:a1c:f601:: with SMTP id w1mr52958068wmc.112.1636388278523; Mon, 08 Nov 2021 08:17:58 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Cleber Rosa , Wainer dos Santos Moschetta , Willian Rampazzo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 3/9] tests/avocado: Extract QemuBaseTest from Test Date: Mon, 8 Nov 2021 17:17:33 +0100 Message-Id: <20211108161739.1371503-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211108161739.1371503-1-philmd@redhat.com> References: <20211108161739.1371503-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636388284349100001 From: Philippe Mathieu-Daud=C3=A9 The Avocado Test::fetch_asset() is handy to download artifacts before running tests. The current class is named Test but only tests system emulation. As we want to test user emulation, refactor the common code as QemuBaseTest. Reviewed-by: Willian Rampazzo Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20211105143416.148332-2-f4bug@amsat.org> --- tests/avocado/avocado_qemu/__init__.py | 72 +++++++++++++++----------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado= _qemu/__init__.py index cd21b59e040..a495e106d03 100644 --- a/tests/avocado/avocado_qemu/__init__.py +++ b/tests/avocado/avocado_qemu/__init__.py @@ -169,7 +169,7 @@ def exec_command_and_wait_for_pattern(test, command, """ _console_interaction(test, success_message, failure_message, command += '\r') =20 -class Test(avocado.Test): +class QemuBaseTest(avocado.Test): def _get_unique_tag_val(self, tag_name): """ Gets a tag value, if unique for a key @@ -179,6 +179,46 @@ def _get_unique_tag_val(self, tag_name): return vals.pop() return None =20 + def setUp(self): + self.arch =3D self.params.get('arch', + default=3Dself._get_unique_tag_val('ar= ch')) + + self.cpu =3D self.params.get('cpu', + default=3Dself._get_unique_tag_val('cpu= ')) + + default_qemu_bin =3D pick_default_qemu_bin(arch=3Dself.arch) + self.qemu_bin =3D self.params.get('qemu_bin', + default=3Ddefault_qemu_bin) + if self.qemu_bin is None: + self.cancel("No QEMU binary defined or found in the build tree= ") + + def fetch_asset(self, name, + asset_hash=3DNone, 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 Test(QemuBaseTest): + """Facilitates system emulation tests. + + TODO: Rename this class as `QemuSystemTest`. + """ + + def setUp(self): + self._vms =3D {} + + super().setUp() + + self.machine =3D self.params.get('machine', + default=3Dself._get_unique_tag_val(= 'machine')) + def require_accelerator(self, accelerator): """ Requires an accelerator to be available for the test to continue @@ -201,24 +241,6 @@ def require_accelerator(self, accelerator): self.cancel("%s accelerator does not seem to be " "available" % accelerator) =20 - def setUp(self): - self._vms =3D {} - - self.arch =3D self.params.get('arch', - default=3Dself._get_unique_tag_val('ar= ch')) - - self.cpu =3D self.params.get('cpu', - default=3Dself._get_unique_tag_val('cpu= ')) - - self.machine =3D self.params.get('machine', - default=3Dself._get_unique_tag_val(= 'machine')) - - default_qemu_bin =3D pick_default_qemu_bin(arch=3Dself.arch) - self.qemu_bin =3D self.params.get('qemu_bin', - default=3Ddefault_qemu_bin) - if self.qemu_bin is None: - self.cancel("No QEMU binary defined or found in the build tree= ") - def _new_vm(self, name, *args): self._sd =3D tempfile.TemporaryDirectory(prefix=3D"avo_qemu_sock_") vm =3D QEMUMachine(self.qemu_bin, base_temp_dir=3Dself.workdir, @@ -272,18 +294,6 @@ def tearDown(self): self._sd =3D None super().tearDown() =20 - def fetch_asset(self, name, - asset_hash=3DNone, 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) - =20 class LinuxSSHMixIn: """Contains utility methods for interacting with a guest via SSH.""" --=20 2.31.1