Skip to content

Commit ce8c07e

Browse files
authored
ext/sockets/tests/mcast_ipv6_*.phpt: suppress no-ipv6 warning (#11651)
These three tests try to create an ipv6 socket with socket_create() to determine if they should be skipped. On certain systems lacking ipv6 support, however, the call to socket_create() itself raises a warning: BORK Warning: socket_create(): Unable to create socket [97]: Address family not supported by protocol in ... The output is "borked" because the return value (false) is expected but the text of the warning is not. This commit uses the error control operator (@) to hide the warning. Afterwards the tests are skipped normally on such a system.
1 parent f6d7537 commit ce8c07e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ext/sockets/tests/mcast_ipv6_recv.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ sockets
88
if (!defined('IPPROTO_IPV6')) {
99
die('skip IPv6 not available.');
1010
}
11-
$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
11+
// hide the output from socket_create() because it can raise
12+
// a warning if (for example) the linux kernel is lacking ipv6
13+
$s = @socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
1214
if ($s === false) {
1315
die("skip unable to create socket");
1416
}

ext/sockets/tests/mcast_ipv6_recv_limited.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ sockets
88
if (!defined('IPPROTO_IPV6')) {
99
die('skip IPv6 not available.');
1010
}
11-
$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
11+
// hide the output from socket_create() because it can raise
12+
// a warning if (for example) the linux kernel is lacking ipv6
13+
$s = @socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
14+
if ($s === false) {
15+
die("skip unable to create socket");
16+
}
1217
$br = socket_bind($s, '::', 3000);
1318
/* On Linux, there is no route ff00::/8 by default on lo, which makes it
1419
* troublesome to send multicast traffic from lo, which we must since

ext/sockets/tests/mcast_ipv6_send.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ if (getenv('CI_NO_IPV6') || !defined('IPPROTO_IPV6')) {
99
die('skip IPv6 not available.');
1010
}
1111
$level = IPPROTO_IPV6;
12-
$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("skip Cannot create socket");
12+
13+
// hide the output from socket_create() because it can raise
14+
// a warning if (for example) the linux kernel is lacking ipv6
15+
$s = @socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("skip Cannot create socket");
1316
if (socket_set_option($s, $level, IPV6_MULTICAST_IF, 1) === false) {
1417
die("skip interface 1 either doesn't exist or has no ipv6 address");
1518
}

0 commit comments

Comments
 (0)