aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-02-21 16:48:01 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-03-13 15:39:31 +0400
commit25657fc6c1b693096e2ceadaa53cd10c1e81c8d9 (patch)
tree02de623f13a1d265022ddbdbf7433eb33f929d23 /tests
parentb7e5374637daffa49657be2c559a0566836a172f (diff)
win32: replace closesocket() with close() wrapper
Use a close() wrapper instead, so that we don't need to worry about closesocket() vs close() anymore, let's hope. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Message-Id: <20230221124802.4103554-17-marcandre.lureau@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/libqtest.c8
-rw-r--r--tests/qtest/microbit-test.c2
-rw-r--r--tests/qtest/netdev-socket.c10
-rw-r--r--tests/unit/socket-helpers.c8
4 files changed, 14 insertions, 14 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 2bfd460531..dee2032331 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -124,7 +124,7 @@ static int socket_accept(int sock)
(void *)&timeout, sizeof(timeout))) {
fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
__func__, strerror(errno));
- closesocket(sock);
+ close(sock);
return -1;
}
@@ -135,7 +135,7 @@ static int socket_accept(int sock)
if (ret == -1) {
fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno));
}
- closesocket(sock);
+ close(sock);
return ret;
}
@@ -564,8 +564,8 @@ void qtest_quit(QTestState *s)
qtest_remove_abrt_handler(s);
qtest_kill_qemu(s);
- closesocket(s->fd);
- closesocket(s->qmp_fd);
+ close(s->fd);
+ close(s->qmp_fd);
g_string_free(s->rx, true);
for (GList *it = s->pending_events; it != NULL; it = it->next) {
diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c
index 4bc267020b..6022a92b6a 100644
--- a/tests/qtest/microbit-test.c
+++ b/tests/qtest/microbit-test.c
@@ -107,7 +107,7 @@ static void test_nrf51_uart(void)
g_assert_true(recv(sock_fd, s, 10, 0) == 5);
g_assert_true(memcmp(s, "world", 5) == 0);
- closesocket(sock_fd);
+ close(sock_fd);
qtest_quit(qts);
}
diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c
index 270e424bee..9cf1b0698e 100644
--- a/tests/qtest/netdev-socket.c
+++ b/tests/qtest/netdev-socket.c
@@ -99,7 +99,7 @@ static int inet_get_free_port_multiple(int nb, int *port, bool ipv6)
nb = i;
for (i = 0; i < nb; i++) {
- closesocket(sock[i]);
+ close(sock[i]);
}
return nb;
@@ -361,8 +361,8 @@ static void test_stream_fd(void)
qtest_quit(qts1);
qtest_quit(qts0);
- closesocket(sock[0]);
- closesocket(sock[1]);
+ close(sock[0]);
+ close(sock[1]);
}
#endif
@@ -487,8 +487,8 @@ static void test_dgram_fd(void)
qtest_quit(qts1);
qtest_quit(qts0);
- closesocket(sv[0]);
- closesocket(sv[1]);
+ close(sv[0]);
+ close(sv[1]);
}
#endif
diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c
index 914b3aa0cf..6de27baee2 100644
--- a/tests/unit/socket-helpers.c
+++ b/tests/unit/socket-helpers.c
@@ -117,13 +117,13 @@ static int socket_can_bind_connect(const char *hostname, int family)
cleanup:
if (afd != -1) {
- closesocket(afd);
+ close(afd);
}
if (cfd != -1) {
- closesocket(cfd);
+ close(cfd);
}
if (lfd != -1) {
- closesocket(lfd);
+ close(lfd);
}
if (res) {
freeaddrinfo(res);
@@ -160,7 +160,7 @@ void socket_check_afunix_support(bool *has_afunix)
int fd;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
- closesocket(fd);
+ close(fd);
#ifdef _WIN32
*has_afunix = (fd != (int)INVALID_SOCKET);