[PATCH v2] tests: use macros for registering char tests for sockets

Daniel P. Berrangé posted 1 patch 3 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251016133643.1659686-1-berrange@redhat.com
tests/unit/test-char.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH v2] tests: use macros for registering char tests for sockets
Posted by Daniel P. Berrangé 3 months, 3 weeks ago
The test-char.c has a couple of helper macros for registering tests that
need to be repeated for both IP and UNIX sockets. One test case was not
using the macro though.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---

In v2:
 - Placed in the server instead of client macro

 tests/unit/test-char.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c
index f30a39f61f..e156b17329 100644
--- a/tests/unit/test-char.c
+++ b/tests/unit/test-char.c
@@ -1934,7 +1934,9 @@ int main(int argc, char **argv)
     g_test_add_data_func("/char/socket/server/mainloop-fdpass/" # name, \
                          &server3 ##name, char_socket_server_test);     \
     g_test_add_data_func("/char/socket/server/wait-conn-fdpass/" # name, \
-                         &server4 ##name, char_socket_server_test)
+                         &server4 ##name, char_socket_server_test);     \
+    g_test_add_data_func("/char/socket/server/two-clients/" # name,     \
+                         addr, char_socket_server_two_clients_test)
 
 #define SOCKET_CLIENT_TEST(name, addr)                                  \
     static CharSocketClientTestConfig client1 ## name =                 \
@@ -1974,14 +1976,10 @@ int main(int argc, char **argv)
     if (has_ipv4) {
         SOCKET_SERVER_TEST(tcp, &tcpaddr);
         SOCKET_CLIENT_TEST(tcp, &tcpaddr);
-        g_test_add_data_func("/char/socket/server/two-clients/tcp", &tcpaddr,
-                             char_socket_server_two_clients_test);
     }
 #ifndef WIN32
     SOCKET_SERVER_TEST(unix, &unixaddr);
     SOCKET_CLIENT_TEST(unix, &unixaddr);
-    g_test_add_data_func("/char/socket/server/two-clients/unix", &unixaddr,
-                         char_socket_server_two_clients_test);
 #endif
 
     g_test_add_func("/char/udp", char_udp_test);
-- 
2.50.1


Re: [PATCH v2] tests: use macros for registering char tests for sockets
Posted by Peter Maydell 3 months, 3 weeks ago
On Thu, 16 Oct 2025 at 14:37, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> The test-char.c has a couple of helper macros for registering tests that
> need to be repeated for both IP and UNIX sockets. One test case was not
> using the macro though.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>
> In v2:
>  - Placed in the server instead of client macro
>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM