thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
7f1c5b
From 39d5761fe1f546e764dedf2ea32c55d8f5222696 Mon Sep 17 00:00:00 2001
7f1c5b
From: Laurent Vivier <lvivier@redhat.com>
7f1c5b
Date: Wed, 18 Jan 2023 13:04:05 +0100
7f1c5b
Subject: [PATCH 1/8] tests/qtest: netdev: test stream and dgram backends
7f1c5b
MIME-Version: 1.0
7f1c5b
Content-Type: text/plain; charset=UTF-8
7f1c5b
Content-Transfer-Encoding: 8bit
7f1c5b
7f1c5b
RH-Author: Laurent Vivier <lvivier@redhat.com>
7f1c5b
RH-MergeRequest: 148: net: stream: add a new option to automatically reconnect
7f1c5b
RH-Bugzilla: 2169232
7f1c5b
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
7f1c5b
RH-Acked-by: Cindy Lu <lulu@redhat.com>
7f1c5b
RH-Acked-by: MST <mst@redhat.com>
7f1c5b
RH-Acked-by: David Gibson (Red Hat) <dgibson@redhat.com>
7f1c5b
RH-Commit: [1/2] 75c71b47eea072e14651a96612d402b50d2b8f1e (lvivier/qemu-kvm-centos)
7f1c5b
7f1c5b
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
7f1c5b
Acked-by: Michael S. Tsirkin <mst@redhat.com>
7f1c5b
Message-Id: <20230118120405.1876329-1-lvivier@redhat.com>
7f1c5b
Signed-off-by: Thomas Huth <thuth@redhat.com>
7f1c5b
(cherry picked from commit c95031a19f0d7f418a597243f6f84b031a858997)
7f1c5b
---
7f1c5b
 tests/qtest/meson.build     |   2 +
7f1c5b
 tests/qtest/netdev-socket.c | 448 ++++++++++++++++++++++++++++++++++++
7f1c5b
 2 files changed, 450 insertions(+)
7f1c5b
 create mode 100644 tests/qtest/netdev-socket.c
7f1c5b
7f1c5b
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
7f1c5b
index 9df3f9f8b9..2e7c6fe5e3 100644
7f1c5b
--- a/tests/qtest/meson.build
7f1c5b
+++ b/tests/qtest/meson.build
7f1c5b
@@ -27,6 +27,7 @@ qtests_generic = [
7f1c5b
   'test-hmp',
7f1c5b
   'qos-test',
7f1c5b
   'readconfig-test',
7f1c5b
+  'netdev-socket',
7f1c5b
 ]
7f1c5b
 if config_host.has_key('CONFIG_MODULES')
7f1c5b
   qtests_generic += [ 'modules-test' ]
7f1c5b
@@ -299,6 +300,7 @@ qtests = {
7f1c5b
   'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
7f1c5b
   'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'],
7f1c5b
   'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
7f1c5b
+  'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'),
7f1c5b
 }
7f1c5b
 
7f1c5b
 gvnc = dependency('gvnc-1.0', required: false)
7f1c5b
diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c
7f1c5b
new file mode 100644
7f1c5b
index 0000000000..6ba256e173
7f1c5b
--- /dev/null
7f1c5b
+++ b/tests/qtest/netdev-socket.c
7f1c5b
@@ -0,0 +1,448 @@
7f1c5b
+/*
7f1c5b
+ * QTest testcase for netdev stream and dgram
7f1c5b
+ *
7f1c5b
+ * Copyright (c) 2022 Red Hat, Inc.
7f1c5b
+ *
7f1c5b
+ * SPDX-License-Identifier: GPL-2.0-or-later
7f1c5b
+ */
7f1c5b
+
7f1c5b
+#include "qemu/osdep.h"
7f1c5b
+#include "qemu/sockets.h"
7f1c5b
+#include <glib/gstdio.h>
7f1c5b
+#include "../unit/socket-helpers.h"
7f1c5b
+#include "libqtest.h"
7f1c5b
+
7f1c5b
+#define CONNECTION_TIMEOUT    5
7f1c5b
+
7f1c5b
+#define EXPECT_STATE(q, e, t)                             \
7f1c5b
+do {                                                      \
7f1c5b
+    char *resp = NULL;                                    \
7f1c5b
+    g_test_timer_start();                                 \
7f1c5b
+    do {                                                  \
7f1c5b
+        g_free(resp);                                     \
7f1c5b
+        resp = qtest_hmp(q, "info network");              \
7f1c5b
+        if (t) {                                          \
7f1c5b
+            strrchr(resp, t)[0] = 0;                      \
7f1c5b
+        }                                                 \
7f1c5b
+        if (g_str_equal(resp, e)) {                       \
7f1c5b
+            break;                                        \
7f1c5b
+        }                                                 \
7f1c5b
+    } while (g_test_timer_elapsed() < CONNECTION_TIMEOUT); \
7f1c5b
+    g_assert_cmpstr(resp, ==, e);                         \
7f1c5b
+    g_free(resp);                                         \
7f1c5b
+} while (0)
7f1c5b
+
7f1c5b
+static gchar *tmpdir;
7f1c5b
+
7f1c5b
+static int inet_get_free_port_socket_ipv4(int sock)
7f1c5b
+{
7f1c5b
+    struct sockaddr_in addr;
7f1c5b
+    socklen_t len;
7f1c5b
+
7f1c5b
+    memset(&addr, 0, sizeof(addr));
7f1c5b
+    addr.sin_family = AF_INET;
7f1c5b
+    addr.sin_addr.s_addr = INADDR_ANY;
7f1c5b
+    addr.sin_port = 0;
7f1c5b
+    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
7f1c5b
+        return -1;
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    len = sizeof(addr);
7f1c5b
+    if (getsockname(sock,  (struct sockaddr *)&addr, &len) < 0) {
7f1c5b
+        return -1;
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    return ntohs(addr.sin_port);
7f1c5b
+}
7f1c5b
+
7f1c5b
+static int inet_get_free_port_socket_ipv6(int sock)
7f1c5b
+{
7f1c5b
+    struct sockaddr_in6 addr;
7f1c5b
+    socklen_t len;
7f1c5b
+
7f1c5b
+    memset(&addr, 0, sizeof(addr));
7f1c5b
+    addr.sin6_family = AF_INET6;
7f1c5b
+    addr.sin6_addr = in6addr_any;
7f1c5b
+    addr.sin6_port = 0;
7f1c5b
+    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
7f1c5b
+        return -1;
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    len = sizeof(addr);
7f1c5b
+    if (getsockname(sock,  (struct sockaddr *)&addr, &len) < 0) {
7f1c5b
+        return -1;
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    return ntohs(addr.sin6_port);
7f1c5b
+}
7f1c5b
+
7f1c5b
+static int inet_get_free_port_multiple(int nb, int *port, bool ipv6)
7f1c5b
+{
7f1c5b
+    int sock[nb];
7f1c5b
+    int i;
7f1c5b
+
7f1c5b
+    for (i = 0; i < nb; i++) {
7f1c5b
+        sock[i] = socket(ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
7f1c5b
+        if (sock[i] < 0) {
7f1c5b
+            break;
7f1c5b
+        }
7f1c5b
+        port[i] = ipv6 ? inet_get_free_port_socket_ipv6(sock[i]) :
7f1c5b
+                         inet_get_free_port_socket_ipv4(sock[i]);
7f1c5b
+        if (port[i] == -1) {
7f1c5b
+            break;
7f1c5b
+        }
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    nb = i;
7f1c5b
+    for (i = 0; i < nb; i++) {
7f1c5b
+        closesocket(sock[i]);
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    return nb;
7f1c5b
+}
7f1c5b
+
7f1c5b
+static int inet_get_free_port(bool ipv6)
7f1c5b
+{
7f1c5b
+    int nb, port;
7f1c5b
+
7f1c5b
+    nb = inet_get_free_port_multiple(1, &port, ipv6);
7f1c5b
+    g_assert_cmpint(nb, ==, 1);
7f1c5b
+
7f1c5b
+    return port;
7f1c5b
+}
7f1c5b
+
7f1c5b
+static void test_stream_inet_ipv4(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    int port;
7f1c5b
+
7f1c5b
+    port = inet_get_free_port(false);
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,server=true,addr.type=inet,"
7f1c5b
+                       "addr.ipv4=on,addr.ipv6=off,"
7f1c5b
+                       "addr.host=127.0.0.1,addr.port=%d", port);
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,server=false,id=st0,addr.type=inet,"
7f1c5b
+                       "addr.ipv4=on,addr.ipv6=off,"
7f1c5b
+                       "addr.host=127.0.0.1,addr.port=%d", port);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=stream,tcp:127.0.0.1:%d\r\n",
7f1c5b
+                             port);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    /* the port is unknown, check only the address */
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:127.0.0.1", ':');
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+}
7f1c5b
+
7f1c5b
+static void test_stream_inet_ipv6(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    int port;
7f1c5b
+
7f1c5b
+    port = inet_get_free_port(true);
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,server=true,addr.type=inet,"
7f1c5b
+                       "addr.ipv4=off,addr.ipv6=on,"
7f1c5b
+                       "addr.host=::1,addr.port=%d", port);
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,server=false,id=st0,addr.type=inet,"
7f1c5b
+                       "addr.ipv4=off,addr.ipv6=on,"
7f1c5b
+                       "addr.host=::1,addr.port=%d", port);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=stream,tcp:::1:%d\r\n",
7f1c5b
+                             port);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    /* the port is unknown, check only the address */
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:::1", ':');
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+}
7f1c5b
+
7f1c5b
+static void test_stream_unix(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    gchar *path;
7f1c5b
+
7f1c5b
+    path = g_strconcat(tmpdir, "/stream_unix", NULL);
7f1c5b
+
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,server=true,"
7f1c5b
+                       "addr.type=unix,addr.path=%s,",
7f1c5b
+                       path);
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,server=false,"
7f1c5b
+                       "addr.type=unix,addr.path=%s",
7f1c5b
+                       path);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=stream,unix:%s\r\n", path);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    EXPECT_STATE(qts0, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+    g_free(path);
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+}
7f1c5b
+
7f1c5b
+#ifdef CONFIG_LINUX
7f1c5b
+static void test_stream_unix_abstract(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    gchar *path;
7f1c5b
+
7f1c5b
+    path = g_strconcat(tmpdir, "/stream_unix_abstract", NULL);
7f1c5b
+
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,server=true,"
7f1c5b
+                       "addr.type=unix,addr.path=%s,"
7f1c5b
+                       "addr.abstract=on",
7f1c5b
+                       path);
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,server=false,"
7f1c5b
+                       "addr.type=unix,addr.path=%s,addr.abstract=on",
7f1c5b
+                       path);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=stream,unix:%s\r\n", path);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    EXPECT_STATE(qts0, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+    g_free(path);
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+}
7f1c5b
+#endif
7f1c5b
+
7f1c5b
+#ifndef _WIN32
7f1c5b
+static void test_stream_fd(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    int sock[2];
7f1c5b
+    int ret;
7f1c5b
+
7f1c5b
+    ret = socketpair(AF_LOCAL, SOCK_STREAM, 0, sock);
7f1c5b
+    g_assert_true(ret == 0);
7f1c5b
+
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,addr.type=fd,addr.str=%d",
7f1c5b
+                       sock[0]);
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,unix:\r\n", 0);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev stream,id=st0,addr.type=fd,addr.str=%d",
7f1c5b
+                       sock[1]);
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts1, "st0: index=0,type=stream,unix:\r\n", 0);
7f1c5b
+    EXPECT_STATE(qts0, "st0: index=0,type=stream,unix:\r\n", 0);
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+
7f1c5b
+    closesocket(sock[0]);
7f1c5b
+    closesocket(sock[1]);
7f1c5b
+}
7f1c5b
+#endif
7f1c5b
+
7f1c5b
+static void test_dgram_inet(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    int port[2];
7f1c5b
+    int nb;
7f1c5b
+
7f1c5b
+    nb = inet_get_free_port_multiple(2, port, false);
7f1c5b
+    g_assert_cmpint(nb, ==, 2);
7f1c5b
+
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev dgram,id=st0,"
7f1c5b
+                       "local.type=inet,local.host=127.0.0.1,local.port=%d,"
7f1c5b
+                       "remote.type=inet,remote.host=127.0.0.1,remote.port=%d",
7f1c5b
+                        port[0], port[1]);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=dgram,"
7f1c5b
+                             "udp=127.0.0.1:%d/127.0.0.1:%d\r\n",
7f1c5b
+                             port[0], port[1]);
7f1c5b
+    EXPECT_STATE(qts0, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev dgram,id=st0,"
7f1c5b
+                       "local.type=inet,local.host=127.0.0.1,local.port=%d,"
7f1c5b
+                       "remote.type=inet,remote.host=127.0.0.1,remote.port=%d",
7f1c5b
+                        port[1], port[0]);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=dgram,"
7f1c5b
+                             "udp=127.0.0.1:%d/127.0.0.1:%d\r\n",
7f1c5b
+                             port[1], port[0]);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+}
7f1c5b
+
7f1c5b
+#ifndef _WIN32
7f1c5b
+static void test_dgram_mcast(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts;
7f1c5b
+
7f1c5b
+    qts = qtest_initf("-nodefaults -M none "
7f1c5b
+                      "-netdev dgram,id=st0,"
7f1c5b
+                      "remote.type=inet,remote.host=230.0.0.1,remote.port=1234");
7f1c5b
+
7f1c5b
+    EXPECT_STATE(qts, "st0: index=0,type=dgram,mcast=230.0.0.1:1234\r\n", 0);
7f1c5b
+
7f1c5b
+    qtest_quit(qts);
7f1c5b
+}
7f1c5b
+
7f1c5b
+static void test_dgram_unix(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    gchar *path0, *path1;
7f1c5b
+
7f1c5b
+    path0 = g_strconcat(tmpdir, "/dgram_unix0", NULL);
7f1c5b
+    path1 = g_strconcat(tmpdir, "/dgram_unix1", NULL);
7f1c5b
+
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev dgram,id=st0,local.type=unix,local.path=%s,"
7f1c5b
+                       "remote.type=unix,remote.path=%s",
7f1c5b
+                       path0, path1);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=dgram,udp=%s:%s\r\n",
7f1c5b
+                             path0, path1);
7f1c5b
+    EXPECT_STATE(qts0, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev dgram,id=st0,local.type=unix,local.path=%s,"
7f1c5b
+                       "remote.type=unix,remote.path=%s",
7f1c5b
+                       path1, path0);
7f1c5b
+
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=dgram,udp=%s:%s\r\n",
7f1c5b
+                             path1, path0);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    unlink(path0);
7f1c5b
+    g_free(path0);
7f1c5b
+    unlink(path1);
7f1c5b
+    g_free(path1);
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+}
7f1c5b
+
7f1c5b
+static void test_dgram_fd(void)
7f1c5b
+{
7f1c5b
+    QTestState *qts0, *qts1;
7f1c5b
+    char *expect;
7f1c5b
+    int ret;
7f1c5b
+    int sv[2];
7f1c5b
+
7f1c5b
+    ret = socketpair(PF_UNIX, SOCK_DGRAM, 0, sv);
7f1c5b
+    g_assert_cmpint(ret, !=, -1);
7f1c5b
+
7f1c5b
+    qts0 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev dgram,id=st0,local.type=fd,local.str=%d",
7f1c5b
+                       sv[0]);
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=dgram,fd=%d unix\r\n", sv[0]);
7f1c5b
+    EXPECT_STATE(qts0, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    qts1 = qtest_initf("-nodefaults -M none "
7f1c5b
+                       "-netdev dgram,id=st0,local.type=fd,local.str=%d",
7f1c5b
+                       sv[1]);
7f1c5b
+
7f1c5b
+
7f1c5b
+    expect = g_strdup_printf("st0: index=0,type=dgram,fd=%d unix\r\n", sv[1]);
7f1c5b
+    EXPECT_STATE(qts1, expect, 0);
7f1c5b
+    g_free(expect);
7f1c5b
+
7f1c5b
+    qtest_quit(qts1);
7f1c5b
+    qtest_quit(qts0);
7f1c5b
+
7f1c5b
+    closesocket(sv[0]);
7f1c5b
+    closesocket(sv[1]);
7f1c5b
+}
7f1c5b
+#endif
7f1c5b
+
7f1c5b
+int main(int argc, char **argv)
7f1c5b
+{
7f1c5b
+    int ret;
7f1c5b
+    bool has_ipv4, has_ipv6, has_afunix;
7f1c5b
+    g_autoptr(GError) err = NULL;
7f1c5b
+
7f1c5b
+    socket_init();
7f1c5b
+    g_test_init(&argc, &argv, NULL);
7f1c5b
+
7f1c5b
+    if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
7f1c5b
+        g_error("socket_check_protocol_support() failed\n");
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    tmpdir = g_dir_make_tmp("netdev-socket.XXXXXX", &err;;
7f1c5b
+    if (tmpdir == NULL) {
7f1c5b
+        g_error("Can't create temporary directory in %s: %s",
7f1c5b
+                g_get_tmp_dir(), err->message);
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    if (has_ipv4) {
7f1c5b
+        qtest_add_func("/netdev/stream/inet/ipv4", test_stream_inet_ipv4);
7f1c5b
+        qtest_add_func("/netdev/dgram/inet", test_dgram_inet);
7f1c5b
+#ifndef _WIN32
7f1c5b
+        qtest_add_func("/netdev/dgram/mcast", test_dgram_mcast);
7f1c5b
+#endif
7f1c5b
+    }
7f1c5b
+    if (has_ipv6) {
7f1c5b
+        qtest_add_func("/netdev/stream/inet/ipv6", test_stream_inet_ipv6);
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    socket_check_afunix_support(&has_afunix);
7f1c5b
+    if (has_afunix) {
7f1c5b
+#ifndef _WIN32
7f1c5b
+        qtest_add_func("/netdev/dgram/unix", test_dgram_unix);
7f1c5b
+#endif
7f1c5b
+        qtest_add_func("/netdev/stream/unix", test_stream_unix);
7f1c5b
+#ifdef CONFIG_LINUX
7f1c5b
+        qtest_add_func("/netdev/stream/unix/abstract",
7f1c5b
+                       test_stream_unix_abstract);
7f1c5b
+#endif
7f1c5b
+#ifndef _WIN32
7f1c5b
+        qtest_add_func("/netdev/stream/fd", test_stream_fd);
7f1c5b
+        qtest_add_func("/netdev/dgram/fd", test_dgram_fd);
7f1c5b
+#endif
7f1c5b
+    }
7f1c5b
+
7f1c5b
+    ret = g_test_run();
7f1c5b
+
7f1c5b
+    g_rmdir(tmpdir);
7f1c5b
+    g_free(tmpdir);
7f1c5b
+
7f1c5b
+    return ret;
7f1c5b
+}
7f1c5b
-- 
7f1c5b
2.31.1
7f1c5b