aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/libqtest.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qtest/libqtest.c')
-rw-r--r--tests/qtest/libqtest.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 7c9fc07de4..4f4b2d6477 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -97,7 +97,7 @@ static int socket_accept(int sock)
(void *)&timeout, sizeof(timeout))) {
fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
__func__, strerror(errno));
- close(sock);
+ closesocket(sock);
return -1;
}
@@ -108,7 +108,7 @@ static int socket_accept(int sock)
if (ret == -1) {
fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno));
}
- close(sock);
+ closesocket(sock);
return ret;
}
@@ -265,8 +265,10 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
s = g_new(QTestState, 1);
- socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
- qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
+ socket_path = g_strdup_printf("%s/qtest-%d.sock",
+ g_get_tmp_dir(), getpid());
+ qmp_socket_path = g_strdup_printf("%s/qtest-%d.qmp",
+ g_get_tmp_dir(), getpid());
/* It's possible that if an earlier test run crashed it might
* have left a stale unix socket lying around. Delete any
@@ -390,10 +392,12 @@ QTestState *qtest_initf(const char *fmt, ...)
QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)
{
int sock_fd_init;
- char *sock_path, sock_dir[] = "/tmp/qtest-serial-XXXXXX";
+ g_autofree char *sock_dir = NULL;
+ char *sock_path;
QTestState *qts;
- g_assert_true(g_mkdtemp(sock_dir) != NULL);
+ sock_dir = g_dir_make_tmp("qtest-serial-XXXXXX", NULL);
+ g_assert_true(sock_dir != NULL);
sock_path = g_strdup_printf("%s/sock", sock_dir);
sock_fd_init = init_socket(sock_path);
@@ -417,8 +421,8 @@ void qtest_quit(QTestState *s)
qtest_remove_abrt_handler(s);
qtest_kill_qemu(s);
- close(s->fd);
- close(s->qmp_fd);
+ closesocket(s->fd);
+ closesocket(s->qmp_fd);
g_string_free(s->rx, true);
for (GList *it = s->pending_events; it != NULL; it = it->next) {
@@ -588,17 +592,20 @@ int qtest_socket_server(const char *socket_path)
return sock;
}
+#ifndef _WIN32
void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
const char *fmt, va_list ap)
{
qmp_fd_vsend_fds(s->qmp_fd, fds, fds_num, fmt, ap);
}
+#endif
void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
{
- qmp_fd_vsend_fds(s->qmp_fd, NULL, 0, fmt, ap);
+ qmp_fd_vsend(s->qmp_fd, fmt, ap);
}
+#ifndef _WIN32
QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
const char *fmt, va_list ap)
{
@@ -607,6 +614,7 @@ QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
/* Receive reply */
return qtest_qmp_receive(s);
}
+#endif
QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
{
@@ -616,6 +624,7 @@ QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
return qtest_qmp_receive(s);
}
+#ifndef _WIN32
QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
const char *fmt, ...)
{
@@ -627,6 +636,7 @@ QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
va_end(ap);
return response;
}
+#endif
QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
{
@@ -1323,6 +1333,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
qobject_unref(args);
}
+#ifndef _WIN32
void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd)
{
QDict *resp;
@@ -1342,6 +1353,7 @@ void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd)
g_assert(!qdict_haskey(resp, "error"));
qobject_unref(resp);
}
+#endif
/*
* Generic hot-unplugging test via the device_del QMP command.