From nobody Sat Nov 23 22:45:10 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=1728913476; cv=none; d=zohomail.com; s=zohoarc; b=Hc+xU6JJLPhHCo5U14uczkUvFs/Hl52DL9e0EDHXguWxCVxBI1kmslVf27ixoHhf335yjALnyjEgMvQMgTsmZPPTff92SSNaO5v9fwABkr0XwDAbwIt5eKSohhSQfGe0JgisIyEvTBjZJrXpQWt88lVnn6wtKBvFRS12HZlY8+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728913476; 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=AyUPW+hgxyLeiY+qz06cEXiEyTlF8qX9Tc5iczeYORk=; b=QP7kJZkDSit6SIAf/kQhVo6Ui3lQXISCe9SMMcCBOmssH4XQDPJ7XZrwYXKLxE1CUmtRK+8bjXuC3iAJikpmACyXGgOeeQ3scr6SGXD6RVjJBIF246ppmpVE/vfXI59QfVQ+pZ+qP6x+lIUpnISbOM5HeTWykLknxfxOlrNAIlY= 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 1728913476319379.45507999134577; Mon, 14 Oct 2024 06:44:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0LLB-0004Os-CS; Mon, 14 Oct 2024 09:42:29 -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 1t0LKE-0003AQ-8d for qemu-devel@nongnu.org; Mon, 14 Oct 2024 09:41:40 -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 1t0LK9-00046Q-10 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 09:41:28 -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-639-lM-bJmG2OcWLJROQfvXV7w-1; Mon, 14 Oct 2024 09:41:15 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 AF1761955E84; Mon, 14 Oct 2024 13:41:13 +0000 (UTC) Received: from localhost (unknown [10.39.208.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C469A3000198; Mon, 14 Oct 2024 13:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728913279; 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=AyUPW+hgxyLeiY+qz06cEXiEyTlF8qX9Tc5iczeYORk=; b=fT0wCvDaBjl8PfvFgJx5jJSt6xabf5gu2iMpIKRixBwc2jiVPf/MWMcv436569t2vbIrA3 qbEUIvYLyfuAJLDJvXJ8Fz5hNjWdr7oMQH3dzwsqQ5pgnJA1PjohKAZqrpR4bg3GYlKTtT g5A0YviuccyDp99TYulfHJpfUEs9VDw= X-MC-Unique: lM-bJmG2OcWLJROQfvXV7w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 19/20] tests: add basic -display dbus Map.Unix test Date: Mon, 14 Oct 2024 17:39:34 +0400 Message-ID: <20241014133935.470709-20-marcandre.lureau@redhat.com> In-Reply-To: <20241014133935.470709-1-marcandre.lureau@redhat.com> References: <20241014133935.470709-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.4.1 on 10.30.177.4 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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.076, 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_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1728913477693116600 From: Marc-Andr=C3=A9 Lureau Only check we eventually get a shared memory scanout. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Message-ID: <20241008125028.1177932-20-marcandre.lureau@redhat.com> --- 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