[Qemu-devel] [PATCH v3 6/6] test: skip tests if socket_check_protocol_support() failed

Marc-André Lureau posted 6 patches 6 years, 7 months ago
Maintainers: "Daniel P. Berrangé" <berrange@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Fam Zheng <fam@euphon.net>
[Qemu-devel] [PATCH v3 6/6] test: skip tests if socket_check_protocol_support() failed
Posted by Marc-André Lureau 6 years, 7 months ago
Skip the tests if socket_check_protocol_support() failed, but do run
g_test_run() to keep TAP harness happy.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-char.c              | 4 +++-
 tests/test-io-channel-socket.c | 4 +++-
 tests/test-util-sockets.c      | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/test-char.c b/tests/test-char.c
index 2dde620afc..b56e43c1eb 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -1365,7 +1365,8 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
 
     if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
-        return -1;
+        g_printerr("socket_check_protocol_support() failed\n");
+        goto end;
     }
 
     module_call_init(MODULE_INIT_QOM);
@@ -1465,5 +1466,6 @@ int main(int argc, char **argv)
     g_test_add_func("/char/hotswap", char_hotswap_test);
     g_test_add_func("/char/websocket", char_websock_test);
 
+end:
     return g_test_run();
 }
diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
index d2053c464c..d172f3070f 100644
--- a/tests/test-io-channel-socket.c
+++ b/tests/test-io-channel-socket.c
@@ -566,7 +566,8 @@ int main(int argc, char **argv)
      * with either IPv4 or IPv6 disabled.
      */
     if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
-        return 1;
+        g_printerr("socket_check_protocol_support() failed\n");
+        goto end;
     }
 
     if (has_ipv4) {
@@ -595,5 +596,6 @@ int main(int argc, char **argv)
                     test_io_channel_unix_listen_cleanup);
 #endif /* _WIN32 */
 
+end:
     return g_test_run();
 }
diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
index f1ebffee5a..e2a3a8a093 100644
--- a/tests/test-util-sockets.c
+++ b/tests/test-util-sockets.c
@@ -242,7 +242,8 @@ int main(int argc, char **argv)
      * with either IPv4 or IPv6 disabled.
      */
     if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
-        return 1;
+        g_printerr("socket_check_protocol_support() failed\n");
+        goto end;
     }
 
     if (has_ipv4) {
@@ -264,5 +265,6 @@ int main(int argc, char **argv)
                         test_socket_fd_pass_num_nocli);
     }
 
+end:
     return g_test_run();
 }
-- 
2.22.0.428.g6d5b264208


Re: [Qemu-devel] [PATCH v3 6/6] test: skip tests if socket_check_protocol_support() failed
Posted by Daniel P. Berrangé 6 years, 6 months ago
On Sat, Jul 13, 2019 at 06:33:11PM +0400, Marc-André Lureau wrote:
> Skip the tests if socket_check_protocol_support() failed, but do run
> g_test_run() to keep TAP harness happy.

Did you actually find a scenario in which it failed, or is this just
doing the change for the sake of strict correctness ?

In any case

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


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH v3 6/6] test: skip tests if socket_check_protocol_support() failed
Posted by Marc-André Lureau 6 years, 6 months ago
Hi

On Mon, Jul 15, 2019 at 1:40 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Sat, Jul 13, 2019 at 06:33:11PM +0400, Marc-André Lureau wrote:
> > Skip the tests if socket_check_protocol_support() failed, but do run
> > g_test_run() to keep TAP harness happy.
>
> Did you actually find a scenario in which it failed, or is this just
> doing the change for the sake of strict correctness ?

It fails under podman atm (https://github.com/containers/libpod/issues/3535)

>
> In any case
>
>   Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>

thanks

>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH v3 6/6] test: skip tests if socket_check_protocol_support() failed
Posted by Daniel P. Berrangé 6 years, 6 months ago
On Mon, Jul 15, 2019 at 02:25:03PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Mon, Jul 15, 2019 at 1:40 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Sat, Jul 13, 2019 at 06:33:11PM +0400, Marc-André Lureau wrote:
> > > Skip the tests if socket_check_protocol_support() failed, but do run
> > > g_test_run() to keep TAP harness happy.
> >
> > Did you actually find a scenario in which it failed, or is this just
> > doing the change for the sake of strict correctness ?
> 
> It fails under podman atm (https://github.com/containers/libpod/issues/3535)

Oh i see. I wonder if a better strategy is to simply set

  has_ipv4 = has_ipv6 = false

if getaddrinfo() returns an error and make socket_check_protocol_support
return void.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|