Skip to content

Commit 9d97524

Browse files
committed
splits tests into 32-bit and 64-bit variants, UINT_MAX > PHP_INT_MAX on 32-bit systems
1 parent 51cac49 commit 9d97524

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

ext/sockets/tests/socket_setoption_tcpusertimeout.phpt renamed to ext/sockets/tests/socket_setoption_tcpusertimeout_32bit.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sockets
55
--SKIPIF--
66
<?php
77
if (!defined('TCP_USER_TIMEOUT')) { die('skip TCP_USER_TIMEOUT is not defined'); }
8+
if (PHP_INT_SIZE != 4) { die("skip 32-bit only") };
89
?>
910
--FILE--
1011
<?php
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Test if socket_set_option() works, option:TCP_USER_TIMEOUT
3+
--EXTENSIONS--
4+
sockets
5+
--SKIPIF--
6+
<?php
7+
if (!defined('TCP_USER_TIMEOUT')) { die('skip TCP_USER_TIMEOUT is not defined'); }
8+
if (PHP_INT_SIZE != 8) { die("skip 64-bit only") };
9+
?>
10+
--FILE--
11+
<?php
12+
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
13+
if (!$socket) {
14+
die('Unable to create AF_INET socket [socket]');
15+
}
16+
socket_set_block($socket);
17+
18+
try {
19+
socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, -1);
20+
} catch (\ValueError $e) {
21+
echo $e->getMessage(), PHP_EOL;
22+
}
23+
24+
try {
25+
socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, PHP_INT_MAX);
26+
} catch (\ValueError $e) {
27+
echo $e->getMessage(), PHP_EOL;
28+
}
29+
30+
$timeout = 200;
31+
$retval_2 = socket_set_option($socket, SOL_TCP, TCP_USER_TIMEOUT, $timeout);
32+
$retval_3 = socket_get_option($socket, SOL_TCP, TCP_USER_TIMEOUT);
33+
var_dump($retval_2);
34+
var_dump($retval_3 === $timeout);
35+
socket_close($socket);
36+
?>
37+
--EXPECTF--
38+
socket_setopt(): Argument #4 ($value) must be of between 0 and %d
39+
socket_setopt(): Argument #4 ($value) must be of between 0 and %d
40+
bool(true)
41+
bool(true)

0 commit comments

Comments
 (0)