From nobody Tue May 13 07:22:35 2025 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=1675075615; cv=none; d=zohomail.com; s=zohoarc; b=TfFTuVdlyl4x7V92pZneqyPd/Q6lP64bCJNH40hog6VQDZQXQAci8GOBNOKZvQDjH3+8KllCYKU0G//rF7aEF12cPF9L68k3goKNwnyxMGT0p2kOOr2Hu3/+JtSO34q6JAkFbD5TULmu+kb4CDejOF2RsxYHnfgk5Txaqs18FDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675075615; 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=HJElCQr2nWuSL3iyN67l61u7vM5kM2BGZVBIaN/UN4I=; b=AAcKewJt7NzzdIY2cKfsaY4vQ4U23QDkQrTOHDaq20VQhIZQtyca6HOn8qZjksLmnwDjJ1iWGSPjfx4dyY25ACUYSy55fDI9781qJn6wnztfD1tBkmdFxlUODYtFW07mFUoB+Oumb+C7Nrsh92Jfdm0eNy4HseJdn9zkEo2VuJs= 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 1675075615847292.88492934229237; Mon, 30 Jan 2023 02:46:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMRfI-0006zK-0i; Mon, 30 Jan 2023 05:45:32 -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 1pMRen-0006wo-1C for qemu-devel@nongnu.org; Mon, 30 Jan 2023 05:45:04 -0500 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 1pMRel-0001aP-KL for qemu-devel@nongnu.org; Mon, 30 Jan 2023 05:45:00 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-DHVYQjLgOXqtFKUSdTfhKw-1; Mon, 30 Jan 2023 05:44:54 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F41021C07552; Mon, 30 Jan 2023 10:44:53 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id C535D492B02; Mon, 30 Jan 2023 10:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675075498; 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=HJElCQr2nWuSL3iyN67l61u7vM5kM2BGZVBIaN/UN4I=; b=eFIukChBfwcDc71aJG4YQoD7WDEQlyz6mXdXOK5AbPhczJX0Geea5yBauzT8ypoDt0leBs imUEmts8XZoPDeUTUMlRXaukNC/FbbS4m0JL+eMdtazsciFXtVLc+rCwB+MtzHLt4Fg9Mj eQLpGQaaFAE7rTsGleOFx54Jvr/UbSs= X-MC-Unique: DHVYQjLgOXqtFKUSdTfhKw-1 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Richard Henderson Subject: [PATCH 3/6] tests/qtest/display-vga-test: Add proper checks if a device is available Date: Mon, 30 Jan 2023 11:44:43 +0100 Message-Id: <20230130104446.1286773-4-thuth@redhat.com> In-Reply-To: <20230130104446.1286773-1-thuth@redhat.com> References: <20230130104446.1286773-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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.133.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: 1675075617250100005 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. Signed-off-by: Thomas Huth Reviewed-by: Richard Henderson --- 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..1a26a66061 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(); + 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