diff options
author | Anatol Belski <ab@php.net> | 2016-01-18 17:02:23 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2016-01-18 17:02:23 +0100 |
commit | 71dbad172fad8612046dadbfd0536c759559e40d (patch) | |
tree | 32bd00b3cce681a507ecbea15a7132cf4102b7b6 /ext/sockets/tests | |
parent | d7fc3be99ea2df4405845a16d6cd5c80d9a4f79f (diff) | |
parent | fa0dd6006d7ea2ac2b8e0d8e9caa82b11d4f9fe1 (diff) | |
download | php-git-71dbad172fad8612046dadbfd0536c759559e40d.tar.gz |
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
fork test
fix test
fork test
fork test for win32
fork test
Diffstat (limited to 'ext/sockets/tests')
-rw-r--r-- | ext/sockets/tests/socket_clear_error-win32.phpt | 32 | ||||
-rw-r--r-- | ext/sockets/tests/socket_clear_error.phpt | 3 | ||||
-rw-r--r-- | ext/sockets/tests/socket_send.phpt | 3 | ||||
-rw-r--r-- | ext/sockets/tests/socket_send_win32.phpt | 43 | ||||
-rw-r--r-- | ext/sockets/tests/socket_shutdown-win32.phpt | 59 | ||||
-rw-r--r-- | ext/sockets/tests/socket_shutdown.phpt | 3 |
6 files changed, 143 insertions, 0 deletions
diff --git a/ext/sockets/tests/socket_clear_error-win32.phpt b/ext/sockets/tests/socket_clear_error-win32.phpt new file mode 100644 index 0000000000..3a0b1ea162 --- /dev/null +++ b/ext/sockets/tests/socket_clear_error-win32.phpt @@ -0,0 +1,32 @@ +--TEST-- +void socket_clear_error ([ resource $socket ] ) ; +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('SKIP sockets extension not available.'); +} +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +?> +--FILE-- +<?php +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, "127.0.0.1", 21248); +var_dump(socket_last_error($socket)); +socket_clear_error($socket); +var_dump(socket_last_error($socket)); +?> +--CLEAN-- +<?php +socket_close($socket); +unset($socket); +unset($socketConn); +?> +--EXPECTF-- +Warning: socket_connect(): unable to connect [%d]: No connection could be made because the target machine actively refused it. + in %s on line %d +int(%d) +int(%d) diff --git a/ext/sockets/tests/socket_clear_error.phpt b/ext/sockets/tests/socket_clear_error.phpt index af9acaa9bf..273f7a0ca8 100644 --- a/ext/sockets/tests/socket_clear_error.phpt +++ b/ext/sockets/tests/socket_clear_error.phpt @@ -7,6 +7,9 @@ marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao p if (!extension_loaded('sockets')) { die('SKIP sockets extension not available.'); } +if(substr(PHP_OS, 0, 3) == 'WIN' ) { + die('skip windows only test'); +} ?> --FILE-- <?php diff --git a/ext/sockets/tests/socket_send.phpt b/ext/sockets/tests/socket_send.phpt index 1411868c4b..ceeb397979 100644 --- a/ext/sockets/tests/socket_send.phpt +++ b/ext/sockets/tests/socket_send.phpt @@ -7,6 +7,9 @@ marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao p if (!extension_loaded('sockets')) { die('SKIP sockets extension not available.'); } +if(substr(PHP_OS, 0, 3) == 'WIN' ) { + die('skip not for windows'); +} ?> --FILE-- <?php diff --git a/ext/sockets/tests/socket_send_win32.phpt b/ext/sockets/tests/socket_send_win32.phpt new file mode 100644 index 0000000000..04a985c781 --- /dev/null +++ b/ext/sockets/tests/socket_send_win32.phpt @@ -0,0 +1,43 @@ +--TEST-- +int socket_send ( resource $socket , string $buf , int $len , int $flags ); +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('SKIP sockets extension not available.'); +} +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +?> +--FILE-- +<?php +$port = 80; +$host = "yahoo.com"; +$stringSocket = "send_socket_to_connected_socket"; +$stringSocketLenght = strlen($stringSocket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); + +if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_OOB)===$stringSocketLenght){ + print("okey\n"); +} + +if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_DONTROUTE)===$stringSocketLenght){ + print("okey\n"); +} +?> +<?php +socket_close($socket); +unset($port); +unset($host); +unset($stringSocket); +unset($stringSocketLenght); +unset($socket); +unset($socketConn); +?> +--EXPECTF-- +okey +okey diff --git a/ext/sockets/tests/socket_shutdown-win32.phpt b/ext/sockets/tests/socket_shutdown-win32.phpt new file mode 100644 index 0000000000..6280e61044 --- /dev/null +++ b/ext/sockets/tests/socket_shutdown-win32.phpt @@ -0,0 +1,59 @@ +--TEST-- +bool socket_shutdown ( resource $socket [, int $how = 2 ] ) ; +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('SKIP sockets extension not available.'); +} +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +?> +--FILE-- +<?php +$host = "yahoo.com"; +$port = 80; + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,0)); +socket_close($socket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,1)); +socket_close($socket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,2)); +socket_close($socket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +var_dump(socket_shutdown($socket,0)); + +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,-1)); +socket_close($socket); +?> +--CLEAN-- +<?php +unset($host); +unset($port); +unset($socket); +unset($socketConn); +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) + +Warning: socket_shutdown(): unable to shutdown socket [%d]: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied. + in %s on line %d +bool(false) + +Warning: socket_shutdown(): unable to shutdown socket [%d]: An invalid argument was supplied. + in %s on line %d +bool(false) diff --git a/ext/sockets/tests/socket_shutdown.phpt b/ext/sockets/tests/socket_shutdown.phpt index 09f5ac73fc..77cbc8f32c 100644 --- a/ext/sockets/tests/socket_shutdown.phpt +++ b/ext/sockets/tests/socket_shutdown.phpt @@ -7,6 +7,9 @@ marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao p if (!extension_loaded('sockets')) { die('SKIP sockets extension not available.'); } +if(substr(PHP_OS, 0, 3) == 'WIN' ) { + die('skip not for windows'); +} ?> --FILE-- <?php |