From nobody Thu Nov 6 16:24:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489239283667790.134755831472; Sat, 11 Mar 2017 05:34:43 -0800 (PST) Received: from localhost ([::1]:43441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmhAP-0002Fv-7v for importer@patchew.org; Sat, 11 Mar 2017 08:34:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmgzu-0002Jc-3F for qemu-devel@nongnu.org; Sat, 11 Mar 2017 08:23:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmgzt-0002fs-7g for qemu-devel@nongnu.org; Sat, 11 Mar 2017 08:23:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cmgzs-0002fL-UY for qemu-devel@nongnu.org; Sat, 11 Mar 2017 08:23:49 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21F67C04B93D; Sat, 11 Mar 2017 13:23:49 +0000 (UTC) Received: from localhost (ovpn-116-13.phx2.redhat.com [10.3.116.13]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2BDNkTD028262; Sat, 11 Mar 2017 08:23:48 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Sat, 11 Mar 2017 17:22:47 +0400 Message-Id: <20170311132256.22951-13-marcandre.lureau@redhat.com> In-Reply-To: <20170311132256.22951-1-marcandre.lureau@redhat.com> References: <20170311132256.22951-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 11 Mar 2017 13:23:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 12/21] test-qga: drop everything until guest-sync X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com, anderson@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , pbonzini@redhat.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the following commits, qemu-ga will emit an event on connect that a real client should treat or ignore and test-qga can skip. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-qga.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/test-qga.c b/tests/test-qga.c index c780f0079a..e1f59b7370 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -13,6 +13,8 @@ typedef struct { GPid pid; } TestFixture; =20 +static void guest_sync_delimited(const TestFixture *fixture); + static int connect_qga(char *path) { int s, ret, len, i =3D 0; @@ -45,12 +47,13 @@ static void qga_watch(GPid pid, gint status, gpointer u= ser_data) g_main_loop_quit(fixture->loop); } =20 + static void fixture_setup(TestFixture *fixture, gconstpointer data) { const gchar *extra_arg =3D data; GError *error =3D NULL; - gchar *cwd, *path, *cmd, **argv =3D NULL; + char *cwd, *path, *cmd, **argv =3D NULL; =20 fixture->loop =3D g_main_loop_new(NULL, FALSE); =20 @@ -77,6 +80,8 @@ fixture_setup(TestFixture *fixture, gconstpointer data) fixture->fd =3D connect_qga(path); g_assert_cmpint(fixture->fd, !=3D, -1); =20 + guest_sync_delimited(fixture); + g_strfreev(argv); g_free(cmd); g_free(cwd); @@ -138,9 +143,8 @@ static void qmp_assertion_message_error(const char = *domain, } \ } while (0) =20 -static void test_qga_sync_delimited(gconstpointer fix) +static void guest_sync_delimited(const TestFixture *fixture) { - const TestFixture *fixture =3D fix; guint32 v, r =3D g_random_int(); unsigned char c; QDict *ret; @@ -148,12 +152,13 @@ static void test_qga_sync_delimited(gconstpointer fix) =20 cmd =3D g_strdup_printf("%c{'execute': 'guest-sync-delimited'," " 'arguments': {'id': %u } }", 0xff, r); + qmp_fd_send(fixture->fd, cmd); - g_free(cmd); =20 - v =3D read(fixture->fd, &c, 1); - g_assert_cmpint(v, =3D=3D, 1); - g_assert_cmpint(c, =3D=3D, 0xff); + do { + v =3D read(fixture->fd, &c, 1); + g_assert_cmpint(v, =3D=3D, 1); + } while (c !=3D 0xff); =20 ret =3D qmp_fd_receive(fixture->fd); g_assert_nonnull(ret); @@ -163,6 +168,14 @@ static void test_qga_sync_delimited(gconstpointer fix) g_assert_cmpint(r, =3D=3D, v); =20 QDECREF(ret); + g_free(cmd); +} + +static void test_qga_sync_delimited(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + + guest_sync_delimited(fixture); } =20 static void test_qga_sync(gconstpointer fix) --=20 2.12.0.191.gc5d8de91d