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

Sjoerd Simons sjoerd.simons at collabora.co.uk
Thu Apr 30 01:18:31 PDT 2015


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.
---
 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



More information about the systemd-devel mailing list