[systemd-devel] [PATCH] test-socket-util: Fix tests on machines without ipv6 support

Lennart Poettering lennart at poettering.net
Fri May 15 11:21:20 PDT 2015


On Thu, 30.04.15 10:18, Sjoerd Simons (sjoerd.simons at collabora.co.uk) wrote:

> The test for socket-util already has some code to only do certain tests
> on machines with ipv6 support. However this was incomplete causing the
> test to still fail on such machines, this patch adds the remaining cases
> required to make it pass on machine without ipv6 support.

I have now applied a different patch that should fix the issue:

http://cgit.freedesktop.org/systemd/systemd/commit/?id=7693146dee53a2b0f524e977188347166bf454ca

socket_address_parse() really shouldn't have logegd and failed on
ipv6-less machines anyway. It's a library function, it should be
generic, and leave logging to the caller. I have thus now removed the
logging and the error check, and instead introduced
socket_address_parse_and_warn() which then adds this on top. The test
still uses uses socket_address_parse() and hence should not fail
anymore.

Please check if this fixes all issues for you,

thanks,

Lennart

> ---
>  src/test/test-socket-util.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
> index f257af4..b58f5e3 100644
> --- a/src/test/test-socket-util.c
> +++ b/src/test/test-socket-util.c
> @@ -111,9 +111,11 @@ static void test_socket_address_equal(void) {
>          assert_se(socket_address_parse(&b, "/foo/bar") >= 0);
>          assert_se(socket_address_equal(&a, &b));
>  
> -        assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
> -        assert_se(socket_address_parse(&b, "[::1]:8888") >= 0);
> -        assert_se(socket_address_equal(&a, &b));
> +        if (socket_ipv6_is_supported()) {
> +                assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
> +                assert_se(socket_address_parse(&b, "[::1]:8888") >= 0);
> +                assert_se(socket_address_equal(&a, &b));
> +        }
>  
>          assert_se(socket_address_parse(&a, "@abstract") >= 0);
>          assert_se(socket_address_parse(&b, "@abstract") >= 0);
> @@ -133,8 +135,10 @@ static void test_socket_address_get_path(void) {
>          assert_se(socket_address_parse(&a, "@abstract") >= 0);
>          assert_se(!socket_address_get_path(&a));
>  
> -        assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
> -        assert_se(!socket_address_get_path(&a));
> +        if (socket_ipv6_is_supported()) {
> +                assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
> +                assert_se(!socket_address_get_path(&a));
> +        }
>  
>          assert_se(socket_address_parse(&a, "/foo/bar") >= 0);
>          assert_se(streq(socket_address_get_path(&a), "/foo/bar"));
> -- 
> 2.1.4
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list