From nobody Sun Nov 24 00:47:56 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=1728392162; cv=none; d=zohomail.com; s=zohoarc; b=FO+v+PXrZhlkO9NwOLVHdd4pTC3USt/7FnKfq89sYpqDkcupHMSJvcHR1q4W9ZcebQeoLN777rBZD09R5BTnbtfI6BHPJ2GM0k6P2WU6sUz4H3puCpZZkYL/MkJR03376GK3fy88oNI27s/BgctGG6JUrn9ngF8ehuvq2owGjL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728392162; h=Content-Type: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=hclchx3jalMZQuxqhsObBRpnRuPNQdCL1Ni5QfLAgzs=; b=PuRdNUUHEpx5R5tbSqcdPovGrOHtubUiDoJPOHk4bmcnWw9eoRpL4UUetASyZBakDxzKVkqk1C67F151eouF2bEg1kUkWGJ/0qQuPJhwFEc31boWYF867qry1ZmnwQTJPxErgtqzRi6mF2wvGFYvgP3m0w1Eu6nw9Nza69JxR4s= 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 1728392162600425.5415646648538; Tue, 8 Oct 2024 05:56:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sy9hP-0000WO-R1; Tue, 08 Oct 2024 08:52:26 -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 1sy9hJ-0000KF-Iz for qemu-devel@nongnu.org; Tue, 08 Oct 2024 08:52:18 -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 1sy9hH-0002Ye-Us for qemu-devel@nongnu.org; Tue, 08 Oct 2024 08:52:17 -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-267-u--QS1doPh6BveFxhRXmkw-1; Tue, 08 Oct 2024 08:52:12 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 369D619792F9; Tue, 8 Oct 2024 12:52:11 +0000 (UTC) Received: from localhost (unknown [10.39.208.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F27E719560A3; Tue, 8 Oct 2024 12:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728391935; 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=hclchx3jalMZQuxqhsObBRpnRuPNQdCL1Ni5QfLAgzs=; b=VmnrJQK8U/XjMxy7Gict9eptvOVDeJJ98tltzLfYQA6/wOsw/+B2ISoJRzlh4EthlPrLRn 6FO2MwbKeEzCKjRQZywlFnHKb9fQfdK6Yb7sb1HUFjzUG2/hmjIT6f4jq4bCkSIwfM/HHN 1skF0kcL/8Qcz1U6og751LpdNLHPru0= X-MC-Unique: u--QS1doPh6BveFxhRXmkw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , belmouss@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Thomas Huth , Paolo Bonzini , Gerd Hoffmann , Laurent Vivier Subject: [PATCH v2 19/19] tests: add basic -display dbus Map.Unix test Date: Tue, 8 Oct 2024 16:50:28 +0400 Message-ID: <20241008125028.1177932-20-marcandre.lureau@redhat.com> In-Reply-To: <20241008125028.1177932-1-marcandre.lureau@redhat.com> References: <20241008125028.1177932-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=marcandre.lureau@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.151, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1728392164218116600 From: Marc-Andr=C3=A9 Lureau Only check we eventually get a shared memory scanout. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/dbus-display-test.c | 72 ++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-tes= t.c index 0390bdcb41..f7fc873bfb 100644 --- a/tests/qtest/dbus-display-test.c +++ b/tests/qtest/dbus-display-test.c @@ -2,9 +2,14 @@ #include "qemu/sockets.h" #include "qemu/dbus.h" #include "qemu/sockets.h" +#include "glib.h" +#include "glibconfig.h" #include #include #include "libqtest.h" +#ifndef WIN32 +#include +#endif #include "ui/dbus-display1.h" =20 static GDBusConnection* @@ -82,6 +87,7 @@ typedef struct TestDBusConsoleRegister { GThread *thread; GDBusConnection *listener_conn; GDBusObjectManagerServer *server; + bool with_map; } TestDBusConsoleRegister; =20 static gboolean listener_handle_scanout( @@ -94,13 +100,49 @@ static gboolean listener_handle_scanout( GVariant *arg_data, TestDBusConsoleRegister *test) { + if (!test->with_map) { + g_main_loop_quit(test->loop); + } + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +#ifndef WIN32 +static gboolean listener_handle_scanout_map( + QemuDBusDisplay1ListenerUnixMap *object, + GDBusMethodInvocation *invocation, + GUnixFDList *fd_list, + GVariant *arg_handle, + guint arg_offset, + guint arg_width, + guint arg_height, + guint arg_stride, + guint arg_pixman_format, + TestDBusConsoleRegister *test) +{ + int fd =3D -1; + gint32 handle =3D g_variant_get_handle(arg_handle); + g_autoptr(GError) error =3D NULL; + void *addr =3D NULL; + size_t len =3D arg_height * arg_stride; + + g_assert_cmpuint(g_unix_fd_list_get_length(fd_list), =3D=3D, 1); + fd =3D g_unix_fd_list_get(fd_list, handle, &error); + g_assert_no_error(error); + + addr =3D mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, arg_offset); + g_assert_no_errno(addr =3D=3D MAP_FAILED ? -1 : 0); + g_assert_no_errno(munmap(addr, len)); + g_main_loop_quit(test->loop); =20 + close(fd); return DBUS_METHOD_INVOCATION_HANDLED; } +#endif =20 static void -test_dbus_console_setup_listener(TestDBusConsoleRegister *test) +test_dbus_console_setup_listener(TestDBusConsoleRegister *test, bool with_= map) { g_autoptr(GDBusObjectSkeleton) listener =3D NULL; g_autoptr(QemuDBusDisplay1ListenerSkeleton) iface =3D NULL; @@ -114,6 +156,25 @@ test_dbus_console_setup_listener(TestDBusConsoleRegist= er *test) NULL); g_dbus_object_skeleton_add_interface(listener, G_DBUS_INTERFACE_SKELETON(iface)); + if (with_map) { +#ifdef WIN32 + g_test_skip("map test lacking on win32"); + return; +#else + g_autoptr(QemuDBusDisplay1ListenerUnixMapSkeleton) iface_map =3D + QEMU_DBUS_DISPLAY1_LISTENER_UNIX_MAP_SKELETON( + qemu_dbus_display1_listener_unix_map_skeleton_new()); + + g_object_connect(iface_map, + "signal::handle-scanout-map", listener_handle_sca= nout_map, test, + NULL); + g_dbus_object_skeleton_add_interface(listener, + G_DBUS_INTERFACE_SKELETON(ifa= ce_map)); + g_object_set(iface, "interfaces", + (const gchar *[]) { "org.qemu.Display1.Listener.Unix.Map", NUL= L }, + NULL); +#endif + } g_dbus_object_manager_server_export(test->server, listener); g_dbus_object_manager_server_set_connection(test->server, test->listener_conn); @@ -145,7 +206,7 @@ test_dbus_console_registered(GObject *source_object, g_assert_no_error(err); =20 test->listener_conn =3D g_thread_join(test->thread); - test_dbus_console_setup_listener(test); + test_dbus_console_setup_listener(test, test->with_map); } =20 static gpointer @@ -155,7 +216,7 @@ test_dbus_p2p_server_setup_thread(gpointer data) } =20 static void -test_dbus_display_console(void) +test_dbus_display_console(const void* data) { g_autoptr(GError) err =3D NULL; g_autoptr(GDBusConnection) conn =3D NULL; @@ -163,7 +224,7 @@ test_dbus_display_console(void) g_autoptr(GMainLoop) loop =3D NULL; QTestState *qts =3D NULL; int pair[2]; - TestDBusConsoleRegister test =3D { 0, }; + TestDBusConsoleRegister test =3D { 0, .with_map =3D GPOINTER_TO_INT(da= ta) }; #ifdef WIN32 WSAPROTOCOL_INFOW info; g_autoptr(GVariant) listener =3D NULL; @@ -299,7 +360,8 @@ main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 qtest_add_func("/dbus-display/vm", test_dbus_display_vm); - qtest_add_func("/dbus-display/console", test_dbus_display_console); + qtest_add_data_func("/dbus-display/console", GINT_TO_POINTER(false), t= est_dbus_display_console); + qtest_add_data_func("/dbus-display/console/map", GINT_TO_POINTER(true)= , test_dbus_display_console); qtest_add_func("/dbus-display/keyboard", test_dbus_display_keyboard); =20 return g_test_run(); --=20 2.47.0