[PATCH spice-server v3 17/32] test-channel: Use socket compatibility layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/tests/test-channel.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/server/tests/test-channel.c b/server/tests/test-channel.c
index 1c9148df..fef295a3 100644
--- a/server/tests/test-channel.c
+++ b/server/tests/test-channel.c
@@ -152,7 +152,7 @@ red_test_channel_client_class_init(RedTestChannelClientClass *klass)
  * Main test part
  */
 typedef SpiceWatch *watch_add_t(const SpiceCoreInterfaceInternal *iface,
-                                int fd, int event_mask, SpiceWatchFunc func, void *opaque);
+                                socket_t fd, int event_mask, SpiceWatchFunc func, void *opaque);
 static watch_add_t *old_watch_add = NULL;
 static SpiceWatchFunc old_watch_func = NULL;
 
@@ -170,7 +170,7 @@ static void watch_func_inject(int fd, int event, void *opaque)
 
 static SpiceWatch *
 watch_add_inject(const SpiceCoreInterfaceInternal *iface,
-                 int fd, int event_mask, SpiceWatchFunc func, void *opaque)
+                 socket_t fd, int event_mask, SpiceWatchFunc func, void *opaque)
 {
     g_assert_null(old_watch_func);
     old_watch_func = func;
@@ -178,9 +178,9 @@ watch_add_inject(const SpiceCoreInterfaceInternal *iface,
     return ret;
 }
 
-static int client_socket = -1;
+static socket_t client_socket = SOCKET_INVALID;
 
-static void send_ack_sync(int socket, uint32_t generation)
+static void send_ack_sync(socket_t socket, uint32_t generation)
 {
     struct {
         uint16_t dummy;
@@ -193,7 +193,7 @@ static void send_ack_sync(int socket, uint32_t generation)
     msg.len = GUINT32_TO_LE(sizeof(generation));
     msg.generation = GUINT32_TO_LE(generation);
 
-    g_assert_cmpint(write(socket, &msg.type, 10), ==, 10);
+    g_assert_cmpint(socket_write(socket, &msg.type, 10), ==, 10);
 }
 
 static SpiceTimer *waked_up_timer;
@@ -208,7 +208,7 @@ static void timer_wakeup(void *opaque)
     ssize_t len;
     alarm(1);
     char buffer[256];
-    while ((len=recv(client_socket, buffer, sizeof(buffer), 0)) > 0)
+    while ((len=socket_read(client_socket, buffer, sizeof(buffer))) > 0)
         got_data += len;
     alarm(0);
 
@@ -228,7 +228,7 @@ static void timeout_watch_count(void *opaque)
     // get all pending data
     alarm(1);
     char buffer[256];
-    while (recv(client_socket, buffer, sizeof(buffer), 0) > 0)
+    while (socket_read(client_socket, buffer, sizeof(buffer)) > 0)
         continue;
     alarm(0);
 
@@ -236,7 +236,7 @@ static void timeout_watch_count(void *opaque)
     watch_called_countdown = 20;
 
     // send ack reply, this should unblock data from RedChannelClient
-    g_assert_cmpint(write(client_socket, "\2\0\0\0\0\0", 6), ==, 6);
+    g_assert_cmpint(socket_write(client_socket, "\2\0\0\0\0\0", 6), ==, 6);
 
     // expect data soon
     waked_up_timer = core->timer_add(timer_wakeup, core);
@@ -244,10 +244,10 @@ static void timeout_watch_count(void *opaque)
     // TODO watch
 }
 
-static RedStream *create_dummy_stream(SpiceServer *server, int *p_socket)
+static RedStream *create_dummy_stream(SpiceServer *server, socket_t *p_socket)
 {
-    int sv[2];
-    g_assert_cmpint(socketpair(AF_LOCAL, SOCK_STREAM, 0, sv), ==, 0);
+    socket_t sv[2];
+    g_assert_cmpint(socket_newpair(SOCK_STREAM, 0, sv), ==, 0);
     if (p_socket) {
         *p_socket = sv[1];
     }
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]