[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 2/5] vhost-user-test: extract read-guest-mem test
From: |
Maxime Coquelin |
Subject: |
[Qemu-devel] [PATCH v3 2/5] vhost-user-test: extract read-guest-mem test from main loop |
Date: |
Thu, 21 Dec 2017 22:21:22 +0100 |
This patch makes read-guest-test consistent with other tests,
i.e. create the test server in the test function.
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Maxime Coquelin <address@hidden>
---
tests/vhost-user-test.c | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 43c6528644..df567248ae 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -617,6 +617,28 @@ GSourceFuncs test_migrate_source_funcs = {
.check = test_migrate_source_check,
};
+static void test_read_guest_mem(void)
+{
+ TestServer *server = NULL;
+ char *qemu_cmd = NULL;
+ QTestState *s = NULL;
+
+ server = test_server_new("test");
+ test_server_listen(server);
+
+ qemu_cmd = GET_QEMU_CMD(server);
+
+ s = qtest_start(qemu_cmd);
+ g_free(qemu_cmd);
+
+ init_virtio_dev(server);
+
+ read_guest_mem(server);
+
+ qtest_quit(s);
+ test_server_free(server);
+}
+
static void test_migrate(void)
{
TestServer *s = test_server_new("src");
@@ -919,10 +941,7 @@ static void test_multiqueue(void)
int main(int argc, char **argv)
{
- QTestState *s = NULL;
- TestServer *server = NULL;
const char *hugefs;
- char *qemu_cmd = NULL;
int ret;
char template[] = "/tmp/vhost-test-XXXXXX";
GMainLoop *loop;
@@ -947,20 +966,11 @@ int main(int argc, char **argv)
root = tmpfs;
}
- server = test_server_new("test");
- test_server_listen(server);
-
loop = g_main_loop_new(NULL, FALSE);
/* run the main loop thread so the chardev may operate */
thread = g_thread_new(NULL, thread_function, loop);
- qemu_cmd = GET_QEMU_CMD(server);
-
- s = qtest_start(qemu_cmd);
- g_free(qemu_cmd);
- init_virtio_dev(server);
-
- qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem);
+ qtest_add_func("/vhost-user/read-guest-mem", test_read_guest_mem);
qtest_add_func("/vhost-user/migrate", test_migrate);
qtest_add_func("/vhost-user/multiqueue", test_multiqueue);
@@ -978,12 +988,7 @@ int main(int argc, char **argv)
ret = g_test_run();
- if (s) {
- qtest_quit(s);
- }
-
/* cleanup */
- test_server_free(server);
/* finish the helper thread and dispatch pending sources */
g_main_loop_quit(loop);
--
2.14.3
- [Qemu-devel] [PATCH v3 0/5] vhost-user-test: Fixes & code clean-up, Maxime Coquelin, 2017/12/21
- [Qemu-devel] [PATCH v3 2/5] vhost-user-test: extract read-guest-mem test from main loop,
Maxime Coquelin <=
- [Qemu-devel] [PATCH v3 1/5] vhost-user-test: fix features mask, Maxime Coquelin, 2017/12/21
- [Qemu-devel] [PATCH v3 3/5] vhost-user-test: setup virtqueues in all tests, Maxime Coquelin, 2017/12/21
- [Qemu-devel] [PATCH v3 4/5] vhost-user-test: make features mask an init_virtio_dev() argument, Maxime Coquelin, 2017/12/21
- [Qemu-devel] [PATCH v3 5/5] vhost-user-test: use init_virtio_dev in multiqueue test, Maxime Coquelin, 2017/12/21
- Re: [Qemu-devel] [PATCH v3 0/5] vhost-user-test: Fixes & code clean-up, Michael S. Tsirkin, 2017/12/21