From patchwork Tue Jun 8 14:09:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cleber Rosa X-Patchwork-Id: 12306913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 129DEC4743D for ; Tue, 8 Jun 2021 14:14:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AED3C61078 for ; Tue, 8 Jun 2021 14:14:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AED3C61078 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqcUq-0000XK-P7 for qemu-devel@archiver.kernel.org; Tue, 08 Jun 2021 10:14:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqcQa-00037F-8i for qemu-devel@nongnu.org; Tue, 08 Jun 2021 10:10:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqcQX-00020X-8Y for qemu-devel@nongnu.org; Tue, 08 Jun 2021 10:10:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623161396; 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=rtFmrjScq88zOKvPHUm1P+vesCV6DL5Zgyq3Gg6bQ38=; b=dBEPs/MTKnJQ2be/ejZrwDig8aXxjnVp9SxMLVemv/mIyeM+18nissSpiEMkRDLaG9Yagd ywc+Vv3P6BwOQ18C7EG9WK7LoSWPlssHhqA+P9H6Oxmm040NdKBAJslJku4npbYf31A2+o U4jtUKgTt4IgseymoTNGsvPzY/a37nQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-CS1jDRo9MmK9epQ0npgE8Q-1; Tue, 08 Jun 2021 10:09:55 -0400 X-MC-Unique: CS1jDRo9MmK9epQ0npgE8Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B91A501F0; Tue, 8 Jun 2021 14:09:53 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-153.phx2.redhat.com [10.3.112.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D03EF5D9DE; Tue, 8 Jun 2021 14:09:51 +0000 (UTC) From: Cleber Rosa To: qemu-devel@nongnu.org Subject: [PATCH 3/4] Acceptance Tests: introduce method to require a feature and option Date: Tue, 8 Jun 2021 10:09:37 -0400 Message-Id: <20210608140938.863580-4-crosa@redhat.com> In-Reply-To: <20210608140938.863580-1-crosa@redhat.com> References: <20210608140938.863580-1-crosa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=crosa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=crosa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.197, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, Erik Skultety , =?utf-8?q?Phili?= =?utf-8?q?ppe_Mathieu-Daud=C3=A9?= , Cleber Rosa , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Andrea Bolognani , Willian Rampazzo , John Snow , Willian Rampazzo , Stefan Hajnoczi , Max Reitz , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In this context, and according to the qemu.utils.list_feature() utility function, a feature is something is available as a QEMU command line option that can take the "help" value. This builds on top of that utility function, and allows test writers to require, for instance, the "x-remote" (option) machine type (feature). This example is actually applied here to the reespective test, given that the option is conditionally built, and the test will ERROR without it. Signed-off-by: Cleber Rosa Reviewed-by: Willian Rampazzo --- tests/acceptance/avocado_qemu/__init__.py | 29 ++++++++++++++++++++++- tests/acceptance/multiprocess.py | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 93c4b9851f..432caff4e6 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -11,6 +11,7 @@ import logging import os import shutil +import subprocess import sys import uuid import tempfile @@ -45,7 +46,8 @@ from qemu.utils import ( get_info_usernet_hostfwd_port, kvm_available, - tcg_available, + list_feature, + tcg_available ) def is_readable_executable_file(path): @@ -182,6 +184,31 @@ def _get_unique_tag_val(self, tag_name): return vals.pop() return None + def require_feature(self, feature, option=None): + """ + Requires a feature to be available for the test to continue + + It takes into account the currently set qemu binary, and only checks + for by running a "qemu -$feature help" command. If the specific option + is given, it checks if it's listed for the given feature. + + If the check fails, the test is canceled. + + :param feature: name of a QEMU feature, such as "accel" or "machine" + :type feature: str + :param option: the specific value for the feature. For instance, + if feature is "machine", option can be "q35". + type option: str + """ + try: + options_available = list_feature(self.qemu_bin, feature) + except subprocess.CalledProcessError: + self.cancel('Feature "%s" does not appear to be present.' % feature) + if option is not None: + if option not in options_available: + self.cancel('Feature "%s" does not have "%s" as an option' % + (feature, option)) + def require_accelerator(self, accelerator): """ Requires an accelerator to be available for the test to continue diff --git a/tests/acceptance/multiprocess.py b/tests/acceptance/multiprocess.py index 96627f022a..4d8a40a510 100644 --- a/tests/acceptance/multiprocess.py +++ b/tests/acceptance/multiprocess.py @@ -22,6 +22,7 @@ def do_test(self, kernel_url, initrd_url, kernel_command_line, machine_type): """Main test method""" self.require_accelerator('kvm') + self.require_feature('machine', 'x-remote') # Create socketpair to connect proxy and remote processes proxy_sock, remote_sock = socket.socketpair(socket.AF_UNIX,