Skip to content

Commit c1dd260

Browse files
committed
Fix tests on FreeBSD
Adjust tests that relied on behavior that changed in FreeBSD 14: - socket_tcp_congestion: set the currently active congestion algorithm instead of hard-coding newreno, which is no longer loaded by default. - socket_sentto_recvfrom_unix: don't expect a warning for an AF_UNIX datagram socket with an explicit protocol. - gh20532: use AI_NUMERICHOST so the family mismatch is resolved locally instead of via DNS. - setlocale_variation2: skip on FreeBSD, where locale -a lists locales that cannot be set.
1 parent dda4c8a commit c1dd260

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎ext/sockets/tests/socket_sentto_recvfrom_unix.phpt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
99
}
1010
--FILE--
1111
<?php
12-
$socket = socket_create(AF_UNIX, SOCK_DGRAM, SOL_UDP); // cause warning
12+
// Whether this conflicting combination emits a warning is platform-dependent
13+
// (FreeBSD 14 accepts it), so suppress it; the result is discarded right away.
14+
@socket_create(AF_UNIX, SOCK_DGRAM, SOL_UDP);
1315
$socket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
1416
if (!$socket) {
1517
die('Unable to create AF_UNIX socket');
@@ -50,7 +52,6 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
5052
@unlink($address);
5153
?>
5254
--EXPECTF--
53-
Warning: socket_create(): Unable to create socket [%d]: Protocol not supported in %s on line %d
5455
bool(false)
5556
bool(false)
5657
Received Ping!

‎ext/sockets/tests/socket_tcp_congestion.phpt‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ if (!defined('TCP_CONGESTION')) {
1010
--FILE--
1111
<?php
1212

13-
if (str_contains(PHP_OS, 'Linux')) {
14-
$algo = 'cubic';
15-
} else {
16-
$algo = 'newreno';
17-
}
1813
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
1914
if (!$socket) die ("socket failed");
2015
$r = socket_get_option($socket, SOL_TCP, TCP_CONGESTION);
21-
echo "current tcp congestion algo " . $r['name'] . "\n";
16+
/* Use the algorithm currently in effect: it is guaranteed to be available and
17+
* allowed for unprivileged accounts, unlike hard-coded names such as "newreno"
18+
* which is no longer loaded by default on FreeBSD 14. */
19+
$algo = $r['name'];
20+
echo "current tcp congestion algo " . $algo . "\n";
2221
var_dump(socket_set_option($socket, SOL_TCP, TCP_CONGESTION, $algo));
2322
$r = socket_get_option($socket, SOL_TCP, TCP_CONGESTION);
2423
echo "new tcp congestion algo " . $r['name'];

‎ext/standard/tests/strings/setlocale_variation2.phpt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Test setlocale() function : usage variations - Setting all available locales in
55
if (substr(PHP_OS, 0, 3) == 'WIN') {
66
die('skip Not valid for windows');
77
}
8+
if (PHP_OS_FAMILY === 'Solaris') {
9+
die("skip Some locales on Solaris (e.g. iso_8859_1) are incomplete, cannot test LC_ALL");
10+
}
11+
if (PHP_OS === 'FreeBSD') {
12+
die("skip Some locales listed by locale -a on FreeBSD (e.g. hr_HR.ISO8859-2) are incomplete, cannot test LC_ALL");
13+
}
814
exec("locale -a", $output, $exit_code);
915
if ($exit_code !== 0) {
1016
die("skip locale -a not available");

0 commit comments

Comments
 (0)