mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
tests: make dbus-display-test work on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Thomas Huth <thuth@redhat.com> Message-Id: <20230606115658.677673-8-marcandre.lureau@redhat.com>
This commit is contained in:
parent
ed097649b5
commit
306d75815c
2 changed files with 41 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/sockets.h"
|
||||||
#include "qemu/dbus.h"
|
#include "qemu/dbus.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
@ -14,7 +15,11 @@ test_dbus_p2p_from_fd(int fd)
|
||||||
g_autoptr(GSocketConnection) socketc = NULL;
|
g_autoptr(GSocketConnection) socketc = NULL;
|
||||||
GDBusConnection *conn;
|
GDBusConnection *conn;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
socket = g_socket_new_from_fd(_get_osfhandle(fd), &err);
|
||||||
|
#else
|
||||||
socket = g_socket_new_from_fd(fd, &err);
|
socket = g_socket_new_from_fd(fd, &err);
|
||||||
|
#endif
|
||||||
g_assert_no_error(err);
|
g_assert_no_error(err);
|
||||||
|
|
||||||
socketc = g_socket_connection_factory_create_connection(socket);
|
socketc = g_socket_connection_factory_create_connection(socket);
|
||||||
|
@ -126,7 +131,10 @@ test_dbus_console_registered(GObject *source_object,
|
||||||
|
|
||||||
qemu_dbus_display1_console_call_register_listener_finish(
|
qemu_dbus_display1_console_call_register_listener_finish(
|
||||||
QEMU_DBUS_DISPLAY1_CONSOLE(source_object),
|
QEMU_DBUS_DISPLAY1_CONSOLE(source_object),
|
||||||
NULL, res, &err);
|
#ifndef WIN32
|
||||||
|
NULL,
|
||||||
|
#endif
|
||||||
|
res, &err);
|
||||||
g_assert_no_error(err);
|
g_assert_no_error(err);
|
||||||
|
|
||||||
test->listener_conn = g_thread_join(test->thread);
|
test->listener_conn = g_thread_join(test->thread);
|
||||||
|
@ -145,17 +153,25 @@ test_dbus_display_console(void)
|
||||||
g_autoptr(GError) err = NULL;
|
g_autoptr(GError) err = NULL;
|
||||||
g_autoptr(GDBusConnection) conn = NULL;
|
g_autoptr(GDBusConnection) conn = NULL;
|
||||||
g_autoptr(QemuDBusDisplay1ConsoleProxy) console = NULL;
|
g_autoptr(QemuDBusDisplay1ConsoleProxy) console = NULL;
|
||||||
g_autoptr(GUnixFDList) fd_list = NULL;
|
|
||||||
g_autoptr(GMainLoop) loop = NULL;
|
g_autoptr(GMainLoop) loop = NULL;
|
||||||
QTestState *qts = NULL;
|
QTestState *qts = NULL;
|
||||||
int pair[2], idx;
|
int pair[2];
|
||||||
TestDBusConsoleRegister test;
|
TestDBusConsoleRegister test;
|
||||||
|
#ifdef WIN32
|
||||||
|
WSAPROTOCOL_INFOW info;
|
||||||
|
g_autoptr(GVariant) listener = NULL;
|
||||||
|
#else
|
||||||
|
g_autoptr(GUnixFDList) fd_list = NULL;
|
||||||
|
int idx;
|
||||||
|
#endif
|
||||||
|
|
||||||
test_setup(&qts, &conn);
|
test_setup(&qts, &conn);
|
||||||
|
|
||||||
g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
|
g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);
|
||||||
|
#ifndef WIN32
|
||||||
fd_list = g_unix_fd_list_new();
|
fd_list = g_unix_fd_list_new();
|
||||||
idx = g_unix_fd_list_append(fd_list, pair[1], NULL);
|
idx = g_unix_fd_list_append(fd_list, pair[1], NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
console = QEMU_DBUS_DISPLAY1_CONSOLE_PROXY(
|
console = QEMU_DBUS_DISPLAY1_CONSOLE_PROXY(
|
||||||
qemu_dbus_display1_console_proxy_new_sync(
|
qemu_dbus_display1_console_proxy_new_sync(
|
||||||
|
@ -171,12 +187,33 @@ test_dbus_display_console(void)
|
||||||
test.thread = g_thread_new(NULL, test_dbus_p2p_server_setup_thread,
|
test.thread = g_thread_new(NULL, test_dbus_p2p_server_setup_thread,
|
||||||
GINT_TO_POINTER(pair[0]));
|
GINT_TO_POINTER(pair[0]));
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (WSADuplicateSocketW(_get_osfhandle(pair[1]),
|
||||||
|
GetProcessId((HANDLE) qtest_pid(qts)),
|
||||||
|
&info) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
g_autofree char *emsg = g_win32_error_message(WSAGetLastError());
|
||||||
|
g_error("WSADuplicateSocket failed: %s", emsg);
|
||||||
|
}
|
||||||
|
close(pair[1]);
|
||||||
|
listener = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE,
|
||||||
|
&info,
|
||||||
|
sizeof(info),
|
||||||
|
1);
|
||||||
|
#endif
|
||||||
|
|
||||||
qemu_dbus_display1_console_call_register_listener(
|
qemu_dbus_display1_console_call_register_listener(
|
||||||
QEMU_DBUS_DISPLAY1_CONSOLE(console),
|
QEMU_DBUS_DISPLAY1_CONSOLE(console),
|
||||||
|
#ifdef WIN32
|
||||||
|
listener,
|
||||||
|
#else
|
||||||
g_variant_new_handle(idx),
|
g_variant_new_handle(idx),
|
||||||
|
#endif
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
|
#ifndef WIN32
|
||||||
fd_list,
|
fd_list,
|
||||||
|
#endif
|
||||||
NULL,
|
NULL,
|
||||||
test_dbus_console_registered,
|
test_dbus_console_registered,
|
||||||
&test);
|
&test);
|
||||||
|
|
|
@ -104,7 +104,7 @@ qtests_i386 = \
|
||||||
'numa-test'
|
'numa-test'
|
||||||
]
|
]
|
||||||
|
|
||||||
if dbus_display and targetos != 'windows'
|
if dbus_display
|
||||||
qtests_i386 += ['dbus-display-test']
|
qtests_i386 += ['dbus-display-test']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue