[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 24/24] tests: add /vhost-user/connect-fail test
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 24/24] tests: add /vhost-user/connect-fail test |
Date: |
Tue, 21 Jun 2016 12:02:52 +0200 |
From: Marc-André Lureau <address@hidden>
Check early connection failure and resume.
Signed-off-by: Marc-André Lureau <address@hidden>
---
tests/vhost-user-test.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 8b2164b..7fe12e6 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -131,6 +131,7 @@ typedef struct TestServer {
GCond data_cond;
int log_fd;
uint64_t rings;
+ bool test_fail;
} TestServer;
#if !GLIB_CHECK_VERSION(2, 32, 0)
@@ -234,6 +235,12 @@ static void chr_read(void *opaque, const uint8_t *buf, int
size)
uint8_t *p = (uint8_t *) &msg;
int fd;
+ if (s->test_fail) {
+ qemu_chr_disconnect(chr);
+ /* now switch to non-failure */
+ s->test_fail = false;
+ }
+
if (size != VHOST_USER_HDR_SIZE) {
g_test_message("Wrong message size received %d\n", size);
return;
@@ -697,6 +704,33 @@ static void test_reconnect(void)
g_test_trap_subprocess(path, 0, 0);
g_test_trap_assert_passed();
}
+
+static void test_connect_fail_subprocess(void)
+{
+ TestServer *s = test_server_new("reconnect");
+ char *cmd;
+
+ s->test_fail = true;
+ g_thread_new("connect", connect_thread, s);
+ cmd = GET_QEMU_CMDE(s, 2, ",server", "");
+ qtest_start(cmd);
+ g_free(cmd);
+
+ wait_for_fds(s);
+ wait_for_rings_started(s, 2);
+
+ qtest_end();
+ test_server_free(s);
+}
+
+static void test_connect_fail(void)
+{
+ gchar *path = g_strdup_printf("/%s/vhost-user/connect-fail/subprocess",
+ qtest_get_arch());
+ g_test_trap_subprocess(path, 0, 0);
+ g_test_trap_assert_passed();
+}
+
#endif
int main(int argc, char **argv)
@@ -747,6 +781,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
ret = g_test_run();
--
2.7.4
- [Qemu-devel] [PATCH 16/24] vhost-user: keep vhost_net after a disconnection, (continued)
- [Qemu-devel] [PATCH 16/24] vhost-user: keep vhost_net after a disconnection, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 21/24] char: add chr_wait_connected callback, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 18/24] get_vhost_net() should be != null after vhost_user_init, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 22/24] char: add and use tcp_chr_wait_connected, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 17/24] Revert "vhost-net: do not crash if backend is not present", marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 23/24] vhost-user: wait until link is up, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 19/24] vhost-net: success if backend has no ops->vhost_migration_done, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 24/24] tests: add /vhost-user/connect-fail test,
marcandre . lureau <=
- [Qemu-devel] [PATCH 20/24] vhost: add assert() to check runtime behaviour, marcandre . lureau, 2016/06/21
- Re: [Qemu-devel] [PATCH 00/24] vhost-user reconnect fixes, Michael S. Tsirkin, 2016/06/23
Re: [Qemu-devel] [PATCH 00/24] vhost-user reconnect fixes, Michael S. Tsirkin, 2016/06/23