teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0541-test-fix-failing-test-socket-util-when-running-with-.patch

ecbff1
From 4fbaa65aff7eda3b3965e9c482b08532f3491800 Mon Sep 17 00:00:00 2001
ecbff1
From: Marcin Bachry <hegel666@gmail.com>
ecbff1
Date: Wed, 11 Nov 2015 15:45:26 +0100
ecbff1
Subject: [PATCH] test: fix failing test-socket-util when running with
ecbff1
 ipv6.disable=1 kernel param
ecbff1
ecbff1
The ability to use inet_pton(AF_INET6, ...) doesn't depend on kernel
ecbff1
ipv6 support (inet_pton is a pure libc function), so make ipv6 address
ecbff1
parsing tests unconditional.
ecbff1
ecbff1
(cherry picked from commit 4ebc62ec87162aaa11e077f8693316ecf2d5c58d)
ecbff1
ecbff1
Resolves: #1497639
ecbff1
---
de8967
 src/test/test-socket-util.c | 41 +++++++++++++++++--------------------
ecbff1
 1 file changed, 19 insertions(+), 22 deletions(-)
ecbff1
ecbff1
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
ecbff1
index 6fb4a4094..85f222993 100644
ecbff1
--- a/src/test/test-socket-util.c
ecbff1
+++ b/src/test/test-socket-util.c
ecbff1
@@ -38,28 +38,25 @@ static void test_socket_address_parse(void) {
ecbff1
 
ecbff1
         assert_se(socket_address_parse(&a, "65535") >= 0);
ecbff1
 
ecbff1
-        if (socket_ipv6_is_supported()) {
ecbff1
-                assert_se(socket_address_parse(&a, "[::1]") < 0);
ecbff1
-                assert_se(socket_address_parse(&a, "[::1]8888") < 0);
ecbff1
-                assert_se(socket_address_parse(&a, "::1") < 0);
ecbff1
-                assert_se(socket_address_parse(&a, "[::1]:0") < 0);
ecbff1
-                assert_se(socket_address_parse(&a, "[::1]:65536") < 0);
ecbff1
-                assert_se(socket_address_parse(&a, "[a:b:1]:8888") < 0);
ecbff1
-
ecbff1
-                assert_se(socket_address_parse(&a, "8888") >= 0);
ecbff1
-                assert_se(a.sockaddr.sa.sa_family == AF_INET6);
ecbff1
-
ecbff1
-                assert_se(socket_address_parse(&a, "[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:8888") >= 0);
ecbff1
-                assert_se(a.sockaddr.sa.sa_family == AF_INET6);
ecbff1
-
ecbff1
-                assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
ecbff1
-                assert_se(a.sockaddr.sa.sa_family == AF_INET6);
ecbff1
-        } else {
ecbff1
-                assert_se(socket_address_parse(&a, "[::1]:8888") < 0);
ecbff1
-
ecbff1
-                assert_se(socket_address_parse(&a, "8888") >= 0);
ecbff1
-                assert_se(a.sockaddr.sa.sa_family == AF_INET);
ecbff1
-        }
ecbff1
+        /* The checks below will pass even if ipv6 is disabled in
ecbff1
+         * kernel. The underlying glibc's inet_pton() is just a string
ecbff1
+         * parser and doesn't make any syscalls. */
ecbff1
+
ecbff1
+        assert_se(socket_address_parse(&a, "[::1]") < 0);
ecbff1
+        assert_se(socket_address_parse(&a, "[::1]8888") < 0);
ecbff1
+        assert_se(socket_address_parse(&a, "::1") < 0);
ecbff1
+        assert_se(socket_address_parse(&a, "[::1]:0") < 0);
ecbff1
+        assert_se(socket_address_parse(&a, "[::1]:65536") < 0);
ecbff1
+        assert_se(socket_address_parse(&a, "[a:b:1]:8888") < 0);
ecbff1
+
ecbff1
+        assert_se(socket_address_parse(&a, "8888") >= 0);
ecbff1
+        assert_se(a.sockaddr.sa.sa_family == (socket_ipv6_is_supported() ? AF_INET6 : AF_INET));
ecbff1
+
ecbff1
+        assert_se(socket_address_parse(&a, "[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:8888") >= 0);
ecbff1
+        assert_se(a.sockaddr.sa.sa_family == AF_INET6);
ecbff1
+
ecbff1
+        assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
ecbff1
+        assert_se(a.sockaddr.sa.sa_family == AF_INET6);
ecbff1
 
ecbff1
         assert_se(socket_address_parse(&a, "192.168.1.254:8888") >= 0);
ecbff1
         assert_se(a.sockaddr.sa.sa_family == AF_INET);