Commit 37c51cddb7 for qemu.org
commit 37c51cddb7f184f3c936fdf2d672369d98152c06
Author: Roman Bogorodskiy <bogorodskiy@gmail.com>
Date: Tue Sep 29 17:01:00 2026 +0200
tests/unit/test-qga: enable on FreeBSD
FreeBSD has all necessary commands implemented,
so enable test-qga for it.
Requires only minimal portability fixes for sockets
in connect_qga().
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260929150100.66035-1-bogorodskiy@gmail.com
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index d17435c187..295df1a7eb 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -169,7 +169,7 @@ if have_system
tests += {'test-qdev': [qom, hwcore]}
endif
-if have_ga and host_os == 'linux'
+if have_ga and host_os in ['freebsd', 'linux']
tests += {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']}
test_deps += {'test-qga': qga}
endif
diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index 01ccf826e6..b1c84c188b 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -18,7 +18,7 @@ typedef struct {
static int connect_qga(char *path)
{
int s, ret, len, i = 0;
- struct sockaddr_un remote;
+ struct sockaddr_un remote = { 0 };
s = socket(AF_UNIX, SOCK_STREAM, 0);
g_assert(s != -1);
@@ -26,7 +26,7 @@ static int connect_qga(char *path)
remote.sun_family = AF_UNIX;
do {
strcpy(remote.sun_path, path);
- len = strlen(remote.sun_path) + sizeof(remote.sun_family);
+ len = sizeof(remote);
ret = connect(s, (struct sockaddr *)&remote, len);
if (ret == -1) {
g_usleep(G_USEC_PER_SEC);