Received: from eggs.gnu.org ([2001:4830:134:3::10]:54162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnWb1-0001Ro-PL for qemu-devel@nongnu.org; Fri, 23 Sep 2016 15:57:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnWaz-0001u8-3a for qemu-devel@nongnu.org; Fri, 23 Sep 2016 15:57:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnWay-0001tn-TR for qemu-devel@nongnu.org; Fri, 23 Sep 2016 15:57:17 -0400 Date: Fri, 23 Sep 2016 22:57:15 +0300 From: "Michael S. Tsirkin" Message-ID: <1474658051-18617-2-git-send-email-mst@redhat.com> References: <1474658051-18617-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1474658051-18617-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 01/19] tests: add /vhost-user/connect-fail test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?iso-8859-1?Q?Marc-Andr=E9?= Lureau , Eric Blake , Paolo Bonzini From: Marc-Andr=E9 Lureau Check early connection failure and resume. Signed-off-by: Marc-Andr=E9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/vhost-user-test.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index b89a551..ab91e16 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -135,6 +135,7 @@ typedef struct TestServer { CompatGCond data_cond; int log_fd; uint64_t rings; + bool test_fail; } TestServer; =20 static const char *tmpfs; @@ -249,6 +250,12 @@ static void chr_read(void *opaque, const uint8_t *bu= f, int size) uint8_t *p =3D (uint8_t *) &msg; int fd; =20 + if (s->test_fail) { + qemu_chr_disconnect(chr); + /* now switch to non-failure */ + s->test_fail =3D false; + } + if (size !=3D VHOST_USER_HDR_SIZE) { g_test_message("Wrong message size received %d\n", size); return; @@ -715,6 +722,35 @@ static void test_reconnect(void) g_test_trap_assert_passed(); g_free(path); } + +static void test_connect_fail_subprocess(void) +{ + TestServer *s =3D test_server_new("connect-fail"); + char *cmd; + + s->test_fail =3D true; + g_thread_new("connect", connect_thread, s); + cmd =3D GET_QEMU_CMDE(s, 2, ",server", ""); + qtest_start(cmd); + g_free(cmd); + + init_virtio_dev(s); + wait_for_fds(s); + wait_for_rings_started(s, 2); + + qtest_end(); + test_server_free(s); +} + +static void test_connect_fail(void) +{ + gchar *path =3D g_strdup_printf("/%s/vhost-user/connect-fail/subproc= ess", + qtest_get_arch()); + g_test_trap_subprocess(path, 0, 0); + g_test_trap_assert_passed(); + g_free(path); +} + #endif =20 int main(int argc, char **argv) @@ -766,6 +802,9 @@ int main(int argc, char **argv) qtest_add_func("/vhost-user/reconnect/subprocess", test_reconnect_subprocess); qtest_add_func("/vhost-user/reconnect", test_reconnect); + qtest_add_func("/vhost-user/connect-fail/subprocess", + test_connect_fail_subprocess); + qtest_add_func("/vhost-user/connect-fail", test_connect_fail); #endif =20 ret =3D g_test_run(); --=20 MST