qtest: simplify socket_send()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 20 Apr 2022 13:26:15 +0000 (17:26 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 21 Apr 2022 13:09:09 +0000 (17:09 +0400)
Reuse qemu_write_full().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220420132624.2439741-33-marcandre.lureau@redhat.com>

tests/qtest/libqtest.c

index 7b5890dcc487d31b571c4f0b9f5ff9b52978304b..2b9bdb947d6fb17c17018d7810b9c823e2796370 100644 (file)
@@ -414,21 +414,9 @@ void qtest_quit(QTestState *s)
 
 static void socket_send(int fd, const char *buf, size_t size)
 {
-    size_t offset;
-
-    offset = 0;
-    while (offset < size) {
-        ssize_t len;
+    size_t res = qemu_write_full(fd, buf, size);
 
-        len = write(fd, buf + offset, size - offset);
-        if (len == -1 && errno == EINTR) {
-            continue;
-        }
-
-        g_assert_cmpint(len, >, 0);
-
-        offset += len;
-    }
+    assert(res == size);
 }
 
 static void qtest_client_socket_send(QTestState *s, const char *buf)