Skip to content

Commit 14f5d0b

Browse files
committed
Fix tests on FreeBSD
Adjust tests that relied on behavior that changed on FreeBSD: - lstat_stat_variation18/19/20: rdev is reported as -1 (NODEV), so use %i instead of %d. - 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. - setlocale_variation2: skip, as locale -a lists locales that cannot be set.
1 parent dda4c8a commit 14f5d0b

6 files changed

Lines changed: 21 additions & 18 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/file/lstat_stat_variation18.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ array(26) {
6262
[5]=>
6363
int(%d)
6464
[6]=>
65-
int(%d)
65+
int(%i)
6666
[7]=>
6767
int(%d)
6868
[8]=>
@@ -118,7 +118,7 @@ array(26) {
118118
[5]=>
119119
int(%d)
120120
[6]=>
121-
int(%d)
121+
int(%i)
122122
[7]=>
123123
int(%d)
124124
[8]=>

‎ext/standard/tests/file/lstat_stat_variation19.phpt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ array(26) {
6363
[5]=>
6464
int(%d)
6565
[6]=>
66-
int(%d)
66+
int(%i)
6767
[7]=>
6868
int(%d)
6969
[8]=>
@@ -117,7 +117,7 @@ array(26) {
117117
[5]=>
118118
int(%d)
119119
[6]=>
120-
int(%d)
120+
int(%i)
121121
[7]=>
122122
int(%d)
123123
[8]=>
@@ -173,7 +173,7 @@ array(26) {
173173
[5]=>
174174
int(%d)
175175
[6]=>
176-
int(%d)
176+
int(%i)
177177
[7]=>
178178
int(%d)
179179
[8]=>
@@ -227,7 +227,7 @@ array(26) {
227227
[5]=>
228228
int(%d)
229229
[6]=>
230-
int(%d)
230+
int(%i)
231231
[7]=>
232232
int(%d)
233233
[8]=>

‎ext/standard/tests/file/lstat_stat_variation20.phpt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ array(26) {
7272
[5]=>
7373
int(%d)
7474
[6]=>
75-
int(%d)
75+
int(%i)
7676
[7]=>
7777
int(%d)
7878
[8]=>
@@ -128,7 +128,7 @@ array(26) {
128128
[5]=>
129129
int(%d)
130130
[6]=>
131-
int(%d)
131+
int(%i)
132132
[7]=>
133133
int(%d)
134134
[8]=>
@@ -182,7 +182,7 @@ array(26) {
182182
[5]=>
183183
int(%d)
184184
[6]=>
185-
int(%d)
185+
int(%i)
186186
[7]=>
187187
int(%d)
188188
[8]=>
@@ -236,7 +236,7 @@ array(26) {
236236
[5]=>
237237
int(%d)
238238
[6]=>
239-
int(%d)
239+
int(%i)
240240
[7]=>
241241
int(%d)
242242
[8]=>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ 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 === 'FreeBSD') {
9+
die("skip Some locales listed by locale -a on FreeBSD (e.g. hr_HR.ISO8859-2) are incomplete, cannot test LC_ALL");
10+
}
811
exec("locale -a", $output, $exit_code);
912
if ($exit_code !== 0) {
1013
die("skip locale -a not available");

0 commit comments

Comments
 (0)