From nobody Sun Dec 22 06:31:10 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675160035; cv=none; d=zohomail.com; s=zohoarc; b=SLNSzK/5vIuwnntGYA0yW+UP14+s0tp2mo/DHGCDrHjYb5Pvayvxea1T4gdsH8kbzSnGhfagfIJF8Qhre7vrOUcK9LM8GyJ4fsRpRa4TxflXJhJSABNzd5Id3OTRK0qXrB8dXN3zNSj/y1XcfFodESuckSHTv4efA+je5WlRCXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675160035; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HeWFkRxfcxQMc61g1xzfAoV9kGBJf7mMc3cHqdqbuYY=; b=SwamTv9XQbIiWfV+Vo4erY919/QZOPoFw87UFoKYwz+OB6R4PNHTsq5MRGhOlVK4I570c6Z1KZuKy5Opa6PjjDbSiudTHGzlueNzzlK1EnMixR1ZpWBVLGrrfg4y4IVKysQ6m876Gbc/6GgHWEk/k9Vi3CquyCF7SLwwMg+e1TA= 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+importer2=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 1675160035863481.97454533802477; Tue, 31 Jan 2023 02:13:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMndI-0002ps-3c; Tue, 31 Jan 2023 05:12:56 -0500 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 1pMndE-0002nX-SJ for qemu-devel@nongnu.org; Tue, 31 Jan 2023 05:12:52 -0500 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 1pMndD-0002bN-AC for qemu-devel@nongnu.org; Tue, 31 Jan 2023 05:12:52 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-YjZHqIwANKSb6EsO0O6ccw-1; Tue, 31 Jan 2023 05:12:46 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 095F8885622; Tue, 31 Jan 2023 10:12:46 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 459A9C15BAE; Tue, 31 Jan 2023 10:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675159970; 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=HeWFkRxfcxQMc61g1xzfAoV9kGBJf7mMc3cHqdqbuYY=; b=N6sr3Qxwf9Mt1cfNsC81VuJZWGmNvhRWF3NL7msgxTuV2pj3d5/+RtbAo1HZ/y08ovp/uo njBfjrVkVGs0CPpC1zi9EB8ohUiU6CgQMto9YlTlD8wMAvzSBDA7zcWOrljpIvk6mz2jLn RcbzV16TUarDYieaIRFz1Q0Wo+OMuo4= X-MC-Unique: YjZHqIwANKSb6EsO0O6ccw-1 From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 26/27] tests/qtest/display-vga-test: Add proper checks if a device is available Date: Tue, 31 Jan 2023 11:12:04 +0100 Message-Id: <20230131101205.1499867-27-thuth@redhat.com> In-Reply-To: <20230131101205.1499867-1-thuth@redhat.com> References: <20230131101205.1499867-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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+importer2=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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675160037952100002 Content-Type: text/plain; charset="utf-8" display-vga-test currently tries to guess the usable VGA devices according to the target architecture that is used for the test. This of course does not work if QEMU has been built with the "--without-default-devices" configure switch. To fix this, use the qtest_has_device() function for the decision instead. This way we can also consolidate most of the test functions into one single function (that takes a parameter with the device name now), except for the multihead test that tries to instantiate two devices and thus is a little bit different. Message-Id: <20230130104446.1286773-4-thuth@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth --- tests/qtest/display-vga-test.c | 65 +++++++++++++--------------------- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/tests/qtest/display-vga-test.c b/tests/qtest/display-vga-test.c index ace3bb28e0..75b341a9c6 100644 --- a/tests/qtest/display-vga-test.c +++ b/tests/qtest/display-vga-test.c @@ -8,61 +8,46 @@ */ =20 #include "qemu/osdep.h" -#include "libqtest-single.h" - -static void pci_cirrus(void) -{ - qtest_start("-vga none -device cirrus-vga"); - qtest_end(); -} - -static void pci_stdvga(void) -{ - qtest_start("-vga none -device VGA"); - qtest_end(); -} - -static void pci_secondary(void) -{ - qtest_start("-vga none -device secondary-vga"); - qtest_end(); -} +#include "libqtest.h" =20 static void pci_multihead(void) { - qtest_start("-vga none -device VGA -device secondary-vga"); - qtest_end(); -} + QTestState *qts; =20 -static void pci_virtio_gpu(void) -{ - qtest_start("-vga none -device virtio-gpu-pci"); - qtest_end(); + qts =3D qtest_init("-vga none -device VGA -device secondary-vga"); + qtest_quit(qts); } =20 -static void pci_virtio_vga(void) +static void test_vga(gconstpointer data) { - qtest_start("-vga none -device virtio-vga"); - qtest_end(); + QTestState *qts; + + qts =3D qtest_initf("-vga none -device %s", (const char *)data); + qtest_quit(qts); } =20 int main(int argc, char **argv) { - const char *arch =3D qtest_get_arch(); + static const char *devices[] =3D { + "cirrus-vga", + "VGA", + "secondary-vga", + "virtio-gpu-pci", + "virtio-vga" + }; =20 g_test_init(&argc, &argv, NULL); =20 - if (strcmp(arch, "alpha") =3D=3D 0 || strcmp(arch, "i386") =3D=3D 0 || - strcmp(arch, "mips") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - qtest_add_func("/display/pci/cirrus", pci_cirrus); + for (int i =3D 0; i < ARRAY_SIZE(devices); i++) { + if (qtest_has_device(devices[i])) { + char *testpath =3D g_strdup_printf("/display/pci/%s", devices[= i]); + qtest_add_data_func(testpath, devices[i], test_vga); + g_free(testpath); + } } - qtest_add_func("/display/pci/stdvga", pci_stdvga); - qtest_add_func("/display/pci/secondary", pci_secondary); - qtest_add_func("/display/pci/multihead", pci_multihead); - qtest_add_func("/display/pci/virtio-gpu", pci_virtio_gpu); - if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64") || - g_str_equal(arch, "hppa") || g_str_equal(arch, "ppc64")) { - qtest_add_func("/display/pci/virtio-vga", pci_virtio_vga); + + if (qtest_has_device("secondary-vga")) { + qtest_add_func("/display/pci/multihead", pci_multihead); } =20 return g_test_run(); --=20 2.31.1