TestExtOptions, TestExtNetwork, TestExtSocket -> php

Esse commit está contido em:
Jordan DeLong
2013-06-15 18:55:11 -07:00
commit de Sara Golemon
commit 5a17a10cb6
13 arquivos alterados com 420 adições e 1251 exclusões
-3
Ver Arquivo
@@ -39,9 +39,7 @@
#include "hphp/test/ext/test_ext_mcrypt.h"
#include "hphp/test/ext/test_ext_memcached.h"
#include "hphp/test/ext/test_ext_mysql.h"
#include "hphp/test/ext/test_ext_network.h"
#include "hphp/test/ext/test_ext_openssl.h"
#include "hphp/test/ext/test_ext_options.h"
#include "hphp/test/ext/test_ext_output.h"
#include "hphp/test/ext/test_ext_pdo.h"
#include "hphp/test/ext/test_ext_posix.h"
@@ -49,7 +47,6 @@
#include "hphp/test/ext/test_ext_server.h"
#include "hphp/test/ext/test_ext_session.h"
#include "hphp/test/ext/test_ext_soap.h"
#include "hphp/test/ext/test_ext_socket.h"
#include "hphp/test/ext/test_ext_sqlite3.h"
#include "hphp/test/ext/test_ext_stream.h"
#include "hphp/test/ext/test_ext_string.h"
-299
Ver Arquivo
@@ -1,299 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/test/ext/test_ext_network.h"
#include "hphp/runtime/ext/ext_network.h"
#include "hphp/runtime/ext/ext_file.h"
#include "hphp/runtime/ext/ext_string.h"
#include "hphp/runtime/base/util/string_buffer.h"
#include "hphp/runtime/base/server/libevent_transport.h"
///////////////////////////////////////////////////////////////////////////////
bool TestExtNetwork::RunTests(const std::string &which) {
bool ret = true;
RUN_TEST(test_gethostname);
RUN_TEST(test_gethostbyaddr);
RUN_TEST(test_gethostbyname);
RUN_TEST(test_gethostbynamel);
RUN_TEST(test_getprotobyname);
RUN_TEST(test_getprotobynumber);
RUN_TEST(test_getservbyname);
RUN_TEST(test_getservbyport);
RUN_TEST(test_inet_ntop);
RUN_TEST(test_inet_pton);
RUN_TEST(test_ip2long);
RUN_TEST(test_long2ip);
RUN_TEST(test_dns_check_record);
RUN_TEST(test_checkdnsrr);
RUN_TEST(test_dns_get_record);
RUN_TEST(test_dns_get_mx);
RUN_TEST(test_getmxrr);
RUN_TEST(test_fsockopen);
RUN_TEST(test_pfsockopen);
RUN_TEST(test_socket_get_status);
RUN_TEST(test_socket_set_blocking);
RUN_TEST(test_socket_set_timeout);
RUN_TEST(test_header);
RUN_TEST(test_headers_list);
RUN_TEST(test_headers_sent);
RUN_TEST(test_header_register_callback);
RUN_TEST(test_header_remove);
RUN_TEST(test_get_http_request_size);
RUN_TEST(test_setcookie);
RUN_TEST(test_setrawcookie);
RUN_TEST(test_define_syslog_variables);
RUN_TEST(test_openlog);
RUN_TEST(test_closelog);
RUN_TEST(test_syslog);
return ret;
}
///////////////////////////////////////////////////////////////////////////////
bool TestExtNetwork::test_gethostname() {
VERIFY(!equal(f_gethostname(), Variant(false)));
return Count(true);
}
bool TestExtNetwork::test_gethostbyaddr() {
VS(f_gethostbyaddr("127.0.0.1"), "localhost.localdomain");
return Count(true);
}
bool TestExtNetwork::test_gethostbyname() {
VS(f_gethostbyname("localhost"), "127.0.0.1");
return Count(true);
}
bool TestExtNetwork::test_gethostbynamel() {
VS(f_gethostbynamel("localhost"), CREATE_VECTOR1("127.0.0.1"));
return Count(true);
}
bool TestExtNetwork::test_getprotobyname() {
VS(f_getprotobyname("tcp"), 6);
return Count(true);
}
bool TestExtNetwork::test_getprotobynumber() {
VS(f_getprotobynumber(6), "tcp");
return Count(true);
}
bool TestExtNetwork::test_getservbyname() {
VS(f_getservbyname("http", "tcp"), 80);
return Count(true);
}
bool TestExtNetwork::test_getservbyport() {
VS(f_getservbyport(80, "tcp"), "http");
return Count(true);
}
bool TestExtNetwork::test_inet_ntop() {
String packed = f_chr(127) + f_chr(0) + f_chr(0) + f_chr(1);
VS(f_inet_ntop(packed), "127.0.0.1");
packed = f_str_repeat(f_chr(0), 15) + f_chr(1);
VS(f_inet_ntop(packed), "::1");
return Count(true);
}
bool TestExtNetwork::test_inet_pton() {
String packed = f_chr(127) + f_chr(0) + f_chr(0) + f_chr(1);
VS(f_inet_pton("127.0.0.1"), packed);
packed = f_str_repeat(f_chr(0), 15) + f_chr(1);
VS(f_inet_pton("::1"), packed);
VS(f_inet_pton("::1"), f_hex2bin("00000000000000000000000000000001"));
return Count(true);
}
bool TestExtNetwork::test_ip2long() {
VS(f_ip2long("127.0.0.1"), 2130706433);
return Count(true);
}
bool TestExtNetwork::test_long2ip() {
VS(f_long2ip(2130706433), "127.0.0.1");
return Count(true);
}
bool TestExtNetwork::test_dns_check_record() {
VERIFY(f_dns_check_record("facebook.com"));
return Count(true);
}
bool TestExtNetwork::test_checkdnsrr() {
VERIFY(f_checkdnsrr("facebook.com"));
return Count(true);
}
bool TestExtNetwork::test_dns_get_record() {
VERIFY(!f_dns_get_record("facebook.com", k_DNS_A).toArray().empty());
return Count(true);
}
bool TestExtNetwork::test_dns_get_mx() {
Variant hosts;
VERIFY(f_dns_get_mx("facebook.com", ref(hosts)));
VERIFY(!hosts.toArray().empty());
return Count(true);
}
bool TestExtNetwork::test_getmxrr() {
Variant hosts;
VERIFY(f_getmxrr("facebook.com", ref(hosts)));
VERIFY(!hosts.toArray().empty());
return Count(true);
}
bool TestExtNetwork::test_fsockopen() {
{
Variant f = f_fsockopen("facebook.com", 80);
VERIFY(!same(f, false));
f_fputs(f, "GET / HTTP/1.0\n\n");
VERIFY(!f_fread(f, 15).toString().empty());
}
{
Variant f = f_fsockopen("ssl://www.facebook.com", 443);
VERIFY(!same(f, false));
f_fwrite(f,
"GET / HTTP/1.1\r\n"
"Host: www.facebook.com\r\n"
"Connection: Close\r\n"
"\r\n");
StringBuffer response;
while (!f_feof(f)) {
Variant line = f_fgets(f, 128);
response.append(line.toString());
}
VERIFY(!response.detach().empty());
}
return Count(true);
}
bool TestExtNetwork::test_pfsockopen() {
Variant f = f_pfsockopen("facebook.com", 80);
VERIFY(!same(f, false));
f_fputs(f, "GET / HTTP/1.0\n\n");
VERIFY(!f_fread(f, 15).toString().empty());
return Count(true);
}
bool TestExtNetwork::test_socket_get_status() {
VS(f_socket_get_status(Object()), false);
return Count(true);
}
bool TestExtNetwork::test_socket_set_blocking() {
Variant f = f_fsockopen("facebook.com", 80);
VERIFY(!same(f, false));
f_socket_set_blocking(f, 0);
return Count(true);
}
bool TestExtNetwork::test_socket_set_timeout() {
Variant f = f_fsockopen("facebook.com", 80);
VERIFY(!same(f, false));
f_socket_set_timeout(f, 0);
return Count(true);
}
bool TestExtNetwork::test_header() {
f_header("Location: http://www.facebook.com");
return Count(true);
}
bool TestExtNetwork::test_headers_list() {
f_header("Location: http://www.facebook.com");
VS(f_headers_list(), Array());
return Count(true);
}
bool TestExtNetwork::test_headers_sent() {
f_header("Location: http://www.facebook.com");
VERIFY(!f_headers_sent());
return Count(true);
}
bool TestExtNetwork::test_header_register_callback() {
return Count(true);
}
bool TestExtNetwork::test_header_remove() {
f_header_remove("name");
f_header_remove();
return Count(true);
}
bool TestExtNetwork::test_get_http_request_size() {
//because no g_context in unit test,
//instead of testing f_get_http_request_size(),
//we test relevant code directly
evhttp_request* r=evhttp_request_new(nullptr, nullptr);
char* buf = "buffer";
evbuffer_add(r->input_buffer, buf, strlen(buf));
r->type=EVHTTP_REQ_POST;
evhttp_add_header(r->input_headers, "Host", "www.facebook.com");
r->uri = "/index.php";
r->major=1;
r->minor=1;
r->remote_host="127.0.0.1";
r->remote_port=1234;
LibEventTransport t(nullptr, r,0);
VERIFY(t.getRequestSize()==58);
return Count(true);
}
bool TestExtNetwork::test_setcookie() {
VERIFY(!f_setcookie("name", "value"));
VERIFY(!f_setcookie("name", "value", 253402300800LL));
return Count(true);
}
bool TestExtNetwork::test_setrawcookie() {
VERIFY(!f_setrawcookie("name", "value"));
return Count(true);
}
bool TestExtNetwork::test_define_syslog_variables() {
f_define_syslog_variables();
return Count(true);
}
bool TestExtNetwork::test_openlog() {
f_openlog("TestExtNetwork", k_LOG_ODELAY, k_LOG_USER);
f_syslog(k_LOG_INFO, "testing");
f_closelog();
return Count(true);
}
bool TestExtNetwork::test_closelog() {
f_openlog("TestExtNetwork", k_LOG_ODELAY, k_LOG_USER);
f_syslog(k_LOG_INFO, "testing");
f_closelog();
return Count(true);
}
bool TestExtNetwork::test_syslog() {
f_openlog("TestExtNetwork", k_LOG_ODELAY, k_LOG_USER);
f_syslog(k_LOG_INFO, "testing");
f_closelog();
return Count(true);
}
-68
Ver Arquivo
@@ -1,68 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_TEST_EXT_NETWORK_H_
#define incl_HPHP_TEST_EXT_NETWORK_H_
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
#include "hphp/test/ext/test_cpp_ext.h"
///////////////////////////////////////////////////////////////////////////////
class TestExtNetwork : public TestCppExt {
public:
virtual bool RunTests(const std::string &which);
bool test_gethostname();
bool test_gethostbyaddr();
bool test_gethostbyname();
bool test_gethostbynamel();
bool test_getprotobyname();
bool test_getprotobynumber();
bool test_getservbyname();
bool test_getservbyport();
bool test_inet_ntop();
bool test_inet_pton();
bool test_ip2long();
bool test_long2ip();
bool test_dns_check_record();
bool test_checkdnsrr();
bool test_dns_get_record();
bool test_dns_get_mx();
bool test_getmxrr();
bool test_fsockopen();
bool test_pfsockopen();
bool test_socket_get_status();
bool test_socket_set_blocking();
bool test_socket_set_timeout();
bool test_header();
bool test_headers_list();
bool test_headers_sent();
bool test_header_register_callback();
bool test_header_remove();
bool test_get_http_request_size();
bool test_setcookie();
bool test_setrawcookie();
bool test_define_syslog_variables();
bool test_openlog();
bool test_closelog();
bool test_syslog();
};
///////////////////////////////////////////////////////////////////////////////
#endif // incl_HPHP_TEST_EXT_NETWORK_H_
-417
Ver Arquivo
@@ -1,417 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/test/ext/test_ext_options.h"
#include "hphp/runtime/ext/ext_options.h"
///////////////////////////////////////////////////////////////////////////////
bool TestExtOptions::RunTests(const std::string &which) {
bool ret = true;
DECLARE_TEST_FUNCTIONS("");
RUN_TEST(test_assert_options);
RUN_TEST(test_assert);
RUN_TEST(test_dl);
RUN_TEST(test_extension_loaded);
RUN_TEST(test_get_loaded_extensions);
RUN_TEST(test_get_extension_funcs);
RUN_TEST(test_get_cfg_var);
RUN_TEST(test_get_current_user);
RUN_TEST(test_get_defined_constants);
RUN_TEST(test_get_include_path);
RUN_TEST(test_restore_include_path);
RUN_TEST(test_set_include_path);
RUN_TEST(test_get_included_files);
RUN_TEST(test_inclued_get_data);
RUN_TEST(test_get_magic_quotes_gpc);
RUN_TEST(test_get_magic_quotes_runtime);
RUN_TEST(test_get_required_files);
RUN_TEST(test_getenv);
RUN_TEST(test_getlastmod);
RUN_TEST(test_getmygid);
RUN_TEST(test_getmyinode);
RUN_TEST(test_getmypid);
RUN_TEST(test_getmyuid);
RUN_TEST(test_getopt);
RUN_TEST(test_getrusage);
RUN_TEST(test_clock_getres);
RUN_TEST(test_clock_gettime);
RUN_TEST(test_clock_settime);
RUN_TEST(test_cpu_get_count);
RUN_TEST(test_cpu_get_model);
RUN_TEST(test_ini_alter);
RUN_TEST(test_ini_get_all);
RUN_TEST(test_ini_get);
RUN_TEST(test_ini_restore);
RUN_TEST(test_ini_set);
RUN_TEST(test_memory_get_peak_usage);
RUN_TEST(test_memory_get_usage);
RUN_TEST(test_php_ini_scanned_files);
RUN_TEST(test_php_logo_guid);
RUN_TEST(test_php_sapi_name);
RUN_TEST(test_php_uname);
RUN_TEST(test_phpcredits);
RUN_TEST(test_phpinfo);
RUN_TEST(test_phpversion);
RUN_TEST(test_putenv);
RUN_TEST(test_set_magic_quotes_runtime);
RUN_TEST(test_set_time_limit);
RUN_TEST(test_sys_get_temp_dir);
RUN_TEST(test_version_compare);
RUN_TEST(test_zend_logo_guid);
RUN_TEST(test_zend_thread_id);
RUN_TEST(test_zend_version);
return ret;
}
///////////////////////////////////////////////////////////////////////////////
bool TestExtOptions::test_assert_options() {
f_assert_options(1);
return Count(true);
}
bool TestExtOptions::test_assert() {
f_assert(true);
try {
f_assert(false);
} catch (const Assertion& e) {
return Count(true);
}
return Count(true);
}
bool TestExtOptions::test_dl() {
VS(f_dl(""), 0);
return Count(true);
}
bool TestExtOptions::test_extension_loaded() {
VERIFY(f_extension_loaded("phpmcc"));
VERIFY(f_extension_loaded("bcmath"));
VERIFY(f_extension_loaded("curl"));
VERIFY(f_extension_loaded("simplexml"));
VERIFY(f_extension_loaded("mysql"));
return Count(true);
}
bool TestExtOptions::test_get_loaded_extensions() {
VERIFY(!f_get_loaded_extensions().empty());
return Count(true);
}
bool TestExtOptions::test_get_extension_funcs() {
try {
f_get_extension_funcs("");
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_get_cfg_var() {
VERIFY(!f_get_cfg_var(""))
return Count(true);
}
bool TestExtOptions::test_get_current_user() {
f_get_current_user();
return Count(true);
}
bool TestExtOptions::test_get_defined_constants() {
try {
f_get_defined_constants(true);
return Count(false);
} catch (const NotSupportedException& e) {
return Count(true);
}
f_get_defined_constants();
return Count(true);
}
bool TestExtOptions::test_get_include_path() {
f_get_include_path();
return Count(true);
}
bool TestExtOptions::test_restore_include_path() {
f_restore_include_path();
return Count(true);
}
bool TestExtOptions::test_set_include_path() {
f_set_include_path("");
return Count(true);
}
bool TestExtOptions::test_get_included_files() {
VS(f_get_included_files(), Array::Create());
return Count(true);
}
bool TestExtOptions::test_inclued_get_data() {
VS(f_inclued_get_data(), Array::Create());
return Count(true);
}
bool TestExtOptions::test_get_magic_quotes_gpc() {
VS(f_get_magic_quotes_gpc(), 0);
return Count(true);
}
bool TestExtOptions::test_get_magic_quotes_runtime() {
VS(f_get_magic_quotes_runtime(), 0);
return Count(true);
}
bool TestExtOptions::test_get_required_files() {
try {
f_get_required_files();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_getenv() {
VS(f_getenv("NOTTHERE"), false);
return Count(true);
}
bool TestExtOptions::test_getlastmod() {
try {
f_getlastmod();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_getmygid() {
f_getmygid();
return Count(true);
}
bool TestExtOptions::test_getmyinode() {
try {
f_getmyinode();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_getmypid() {
VERIFY(f_getmypid());
return Count(true);
}
bool TestExtOptions::test_getmyuid() {
f_getmyuid();
return Count(true);
}
bool TestExtOptions::test_getopt() {
f_getopt("");
return Count(true);
}
bool TestExtOptions::test_getrusage() {
VERIFY(!f_getrusage().empty());
return Count(true);
}
bool TestExtOptions::test_clock_getres() {
Variant sec, nsec;
VERIFY(f_clock_getres(k_CLOCK_THREAD_CPUTIME_ID, ref(sec), ref(nsec)));
VS(sec, 0);
VS(nsec, 1);
return Count(true);
}
bool TestExtOptions::test_clock_gettime() {
Variant sec, nsec;
VERIFY(f_clock_gettime(k_CLOCK_THREAD_CPUTIME_ID, ref(sec), ref(nsec)));
return Count(true);
}
bool TestExtOptions::test_clock_settime() {
f_clock_settime(k_CLOCK_THREAD_CPUTIME_ID, 100, 100);
return Count(true);
}
bool TestExtOptions::test_cpu_get_count() {
VERIFY(f_cpu_get_count() > 0);
return Count(true);
}
bool TestExtOptions::test_cpu_get_model() {
VERIFY(!f_cpu_get_model().empty());
return Count(true);
}
bool TestExtOptions::test_ini_alter() {
try {
f_ini_alter("", "");
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_ini_get_all() {
try {
f_ini_get_all();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_ini_get() {
VS(f_ini_get(""), "");
f_ini_set("memory_limit", 50000000);
VS(f_ini_get("memory_limit"), "50000000");
f_set_time_limit(30);
VS(f_ini_get("max_execution_time"), "30");
f_ini_set("max_execution_time", 40);
VS(f_ini_get("max_execution_time"), "40");
return Count(true);
}
bool TestExtOptions::test_ini_restore() {
f_ini_restore("");
return Count(true);
}
bool TestExtOptions::test_ini_set() {
f_ini_set("", "");
return Count(true);
}
bool TestExtOptions::test_memory_get_peak_usage() {
f_memory_get_peak_usage();
return Count(true);
}
bool TestExtOptions::test_memory_get_usage() {
f_memory_get_usage();
return Count(true);
}
bool TestExtOptions::test_php_ini_scanned_files() {
try {
f_php_ini_scanned_files();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_php_logo_guid() {
try {
f_php_logo_guid();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_php_sapi_name() {
f_php_sapi_name();
return Count(true);
}
bool TestExtOptions::test_php_uname() {
VERIFY(!f_php_uname().empty());
return Count(true);
}
bool TestExtOptions::test_phpcredits() {
try {
f_phpcredits();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_phpinfo() {
//f_phpinfo();
return Count(true);
}
bool TestExtOptions::test_phpversion() {
VS(f_phpversion(), "5.4.999-hiphop");
return Count(true);
}
bool TestExtOptions::test_putenv() {
VERIFY(f_putenv("FOO=bar"));
VERIFY(!f_putenv("FOO"));
return Count(true);
}
bool TestExtOptions::test_set_magic_quotes_runtime() {
f_set_magic_quotes_runtime(false);
return Count(true);
}
bool TestExtOptions::test_set_time_limit() {
f_set_time_limit(2);
return Count(true);
}
bool TestExtOptions::test_sys_get_temp_dir() {
VERIFY(f_sys_get_temp_dir() == "/tmp");
return Count(true);
}
bool TestExtOptions::test_version_compare() {
VERIFY(!f_version_compare("1.3.0.dev", "1.1.2", "<"));
return Count(true);
}
bool TestExtOptions::test_zend_logo_guid() {
try {
f_zend_logo_guid();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_zend_thread_id() {
try {
f_zend_thread_id();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
bool TestExtOptions::test_zend_version() {
try {
f_zend_version();
} catch (const NotSupportedException& e) {
return Count(true);
}
return Count(false);
}
-86
Ver Arquivo
@@ -1,86 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_TEST_EXT_OPTIONS_H_
#define incl_HPHP_TEST_EXT_OPTIONS_H_
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
#include "hphp/test/ext/test_cpp_ext.h"
///////////////////////////////////////////////////////////////////////////////
class TestExtOptions : public TestCppExt {
public:
virtual bool RunTests(const std::string &which);
bool test_assert_options();
bool test_assert();
bool test_dl();
bool test_extension_loaded();
bool test_get_loaded_extensions();
bool test_get_extension_funcs();
bool test_get_cfg_var();
bool test_get_current_user();
bool test_get_defined_constants();
bool test_get_include_path();
bool test_restore_include_path();
bool test_set_include_path();
bool test_get_included_files();
bool test_inclued_get_data();
bool test_get_magic_quotes_gpc();
bool test_get_magic_quotes_runtime();
bool test_get_required_files();
bool test_getenv();
bool test_getlastmod();
bool test_getmygid();
bool test_getmyinode();
bool test_getmypid();
bool test_getmyuid();
bool test_getopt();
bool test_getrusage();
bool test_clock_getres();
bool test_clock_gettime();
bool test_clock_settime();
bool test_cpu_get_count();
bool test_cpu_get_model();
bool test_ini_alter();
bool test_ini_get_all();
bool test_ini_get();
bool test_ini_restore();
bool test_ini_set();
bool test_memory_get_peak_usage();
bool test_memory_get_usage();
bool test_php_ini_scanned_files();
bool test_php_logo_guid();
bool test_php_sapi_name();
bool test_php_uname();
bool test_phpcredits();
bool test_phpinfo();
bool test_phpversion();
bool test_putenv();
bool test_set_magic_quotes_runtime();
bool test_set_time_limit();
bool test_sys_get_temp_dir();
bool test_version_compare();
bool test_zend_logo_guid();
bool test_zend_thread_id();
bool test_zend_version();
};
///////////////////////////////////////////////////////////////////////////////
#endif // incl_HPHP_TEST_EXT_OPTIONS_H_
-318
Ver Arquivo
@@ -1,318 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/test/ext/test_ext_socket.h"
#include "hphp/runtime/ext/ext_socket.h"
#include "hphp/runtime/ext/ext_network.h"
///////////////////////////////////////////////////////////////////////////////
bool TestExtSocket::RunTests(const std::string &which) {
bool ret = true;
RUN_TEST(test_socket_create);
RUN_TEST(test_socket_create_listen);
RUN_TEST(test_socket_create_pair);
RUN_TEST(test_socket_get_option);
RUN_TEST(test_socket_getpeername);
RUN_TEST(test_socket_getsockname);
RUN_TEST(test_socket_set_block);
RUN_TEST(test_socket_set_nonblock);
RUN_TEST(test_socket_set_option);
RUN_TEST(test_socket_connect);
RUN_TEST(test_socket_bind);
RUN_TEST(test_socket_listen);
RUN_TEST(test_socket_select);
RUN_TEST(test_socket_server);
RUN_TEST(test_socket_accept);
RUN_TEST(test_socket_read);
RUN_TEST(test_socket_write);
RUN_TEST(test_socket_send);
RUN_TEST(test_socket_sendto);
RUN_TEST(test_socket_recv);
RUN_TEST(test_socket_recvfrom);
RUN_TEST(test_socket_shutdown);
RUN_TEST(test_socket_close);
RUN_TEST(test_socket_strerror);
RUN_TEST(test_socket_last_error);
RUN_TEST(test_socket_clear_error);
return ret;
}
// so we run on different range of ports every time
static int get_random_port() {
static int base = -1;
if (base == -1) {
base = 12345 + (int)((time(0) * 100) % 30000);
}
return ++base;
}
static int bind_random_port(CObjRef socket, CStrRef address) {
for (int i = 0; i < 20; i++) {
int port = get_random_port();
if (f_socket_bind(socket, address, port)) return port;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
bool TestExtSocket::test_socket_create() {
VERIFY(!same(f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP), false));
return Count(true);
}
bool TestExtSocket::test_socket_create_listen() {
int port = get_random_port();
f_socket_create_listen(port);
return Count(true);
}
bool TestExtSocket::test_socket_create_pair() {
Variant fds;
VERIFY(f_socket_create_pair(k_AF_UNIX, k_SOCK_STREAM, 0, ref(fds)));
VS(fds.toArray().size(), 2);
VERIFY(more(fds[0], 0));
VERIFY(more(fds[1], 0));
return Count(true);
}
bool TestExtSocket::test_socket_get_option() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VS(f_socket_get_option(s, k_SOL_SOCKET, k_SO_TYPE), k_SOCK_STREAM);
return Count(true);
}
bool TestExtSocket::test_socket_getpeername() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(s, "facebook.com", 80));
Variant address;
VERIFY(f_socket_getpeername(s, ref(address)));
VERIFY(!address.toString().empty());
return Count(true);
}
bool TestExtSocket::test_socket_getsockname() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(s, "facebook.com", 80));
Variant address;
VERIFY(f_socket_getsockname(s, ref(address)));
VERIFY(!address.toString().empty());
return Count(true);
}
bool TestExtSocket::test_socket_set_block() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_set_block(s));
return Count(true);
}
bool TestExtSocket::test_socket_set_nonblock() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_set_nonblock(s));
return Count(true);
}
bool TestExtSocket::test_socket_set_option() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_set_option(s, k_SOL_SOCKET, k_SO_RCVTIMEO,
CREATE_MAP2("sec", 1, "usec", 0)));
return Count(true);
}
bool TestExtSocket::test_socket_connect() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(s, "facebook.com", 80));
return Count(true);
}
bool TestExtSocket::test_socket_bind() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(s, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(s));
return Count(true);
}
bool TestExtSocket::test_socket_listen() {
Variant server = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(server, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(server));
Variant client = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(client, "127.0.0.1", port));
Variant s = f_socket_accept(server);
VERIFY(f_socket_write(client, "testing"));
// this could fail with shorter returns, but it never does...
VS(f_socket_read(s, 100), "testing");
return Count(true);
}
bool TestExtSocket::test_socket_select() {
Variant server = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(server, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(server));
Variant client = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(client, "127.0.0.1", port));
Variant s = f_socket_accept(server);
Variant reads = CREATE_VECTOR1(s);
VS(f_socket_select(ref(reads), uninit_null(), uninit_null(), 1, 0), 0);
VERIFY(f_socket_write(client, "testing"));
reads = CREATE_VECTOR1(s);
VS(f_socket_select(ref(reads), uninit_null(), uninit_null(), 1, 0), 1);
return Count(true);
}
bool TestExtSocket::test_socket_server() {
Variant server;
int port;
for (int i = 0; i < 20; i++) {
port = get_random_port();
server = f_socket_server("127.0.0.1", port);
if (!same(server, false)) break;
}
VERIFY(!same(server, false));
Variant client = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(client, "127.0.0.1", port));
Variant s = f_socket_accept(server);
Variant reads = CREATE_VECTOR1(s);
VS(f_socket_select(ref(reads), uninit_null(), uninit_null(), 1, 0), 0);
VERIFY(f_socket_write(client, "testing"));
reads = CREATE_VECTOR1(s);
VS(f_socket_select(ref(reads), uninit_null(), uninit_null(), 1, 0), 1);
return Count(true);
}
bool TestExtSocket::test_socket_accept() {
// tested with test_socket_listen
return Count(true);
}
bool TestExtSocket::test_socket_read() {
// tested with test_socket_listen
return Count(true);
}
bool TestExtSocket::test_socket_write() {
// tested with test_socket_listen
return Count(true);
}
bool TestExtSocket::test_socket_send() {
Variant server = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(server, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(server));
Variant client = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(client, "127.0.0.1", port));
Variant s = f_socket_accept(server);
String text = "testing";
VERIFY(f_socket_send(client, text, 4, 0));
Variant buffer;
VERIFY(f_socket_recv(s, ref(buffer), 100, 0));
VS(buffer, "test");
return Count(true);
}
bool TestExtSocket::test_socket_sendto() {
Variant server = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(server, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(server));
Variant client = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
VERIFY(f_socket_connect(client, "127.0.0.1", port));
Variant s = f_socket_accept(server);
String text = "testing";
VERIFY(f_socket_sendto(client, text, 4, 0, "127.0.0.1", port));
Variant buffer;
Variant name, vport;
VERIFY(f_socket_recvfrom(s, ref(buffer), 100, 0, ref(name), ref(vport)));
VS(buffer, "test");
return Count(true);
}
bool TestExtSocket::test_socket_recv() {
// tested with test_socket_send
return Count(true);
}
bool TestExtSocket::test_socket_recvfrom() {
// tested with test_socket_sendto
return Count(true);
}
bool TestExtSocket::test_socket_shutdown() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(s, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(s));
VERIFY(f_socket_shutdown(s));
return Count(true);
}
bool TestExtSocket::test_socket_close() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
int port = bind_random_port(s, "127.0.0.1");
VERIFY(port != 0);
VERIFY(f_socket_listen(s));
f_socket_close(s);
return Count(true);
}
bool TestExtSocket::test_socket_strerror() {
Variant s = f_socket_create(k_AF_INET, k_SOCK_STREAM, k_SOL_TCP);
f_socket_bind(s, "127.0.0.1", 80);
if (f_socket_last_error(s) == 13) {
VS(f_socket_strerror(13), "Permission denied");
f_socket_clear_error(s);
}
VS(f_socket_last_error(s), 0);
return Count(true);
}
bool TestExtSocket::test_socket_last_error() {
// tested with test_socket_strerror
return Count(true);
}
bool TestExtSocket::test_socket_clear_error() {
// tested with test_socket_strerror
return Count(true);
}
-60
Ver Arquivo
@@ -1,60 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_TEST_EXT_SOCKET_H_
#define incl_HPHP_TEST_EXT_SOCKET_H_
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
#include "hphp/test/ext/test_cpp_ext.h"
///////////////////////////////////////////////////////////////////////////////
class TestExtSocket : public TestCppExt {
public:
virtual bool RunTests(const std::string &which);
bool test_socket_create();
bool test_socket_create_listen();
bool test_socket_create_pair();
bool test_socket_get_option();
bool test_socket_getpeername();
bool test_socket_getsockname();
bool test_socket_set_block();
bool test_socket_set_nonblock();
bool test_socket_set_option();
bool test_socket_connect();
bool test_socket_bind();
bool test_socket_listen();
bool test_socket_select();
bool test_socket_server();
bool test_socket_accept();
bool test_socket_read();
bool test_socket_write();
bool test_socket_send();
bool test_socket_sendto();
bool test_socket_recv();
bool test_socket_recvfrom();
bool test_socket_shutdown();
bool test_socket_close();
bool test_socket_strerror();
bool test_socket_last_error();
bool test_socket_clear_error();
};
///////////////////////////////////////////////////////////////////////////////
#endif // incl_HPHP_TEST_EXT_SOCKET_H_
+105
Ver Arquivo
@@ -0,0 +1,105 @@
<?php
function VS($x, $y) {
var_dump($x === $y);
if ($x !== $y) { echo "Failed: $y\n"; echo "Got: $x\n";
var_dump(debug_backtrace()); }
}
function VERIFY($x) { VS($x != false, true); }
//////////////////////////////////////////////////////////////////////
VERIFY(gethostname());
VS(gethostbyaddr("127.0.0.1"), "localhost.localdomain");
VS(gethostbyname("localhost"), "127.0.0.1");
VS(gethostbynamel("localhost"), array("127.0.0.1"));
VS(getprotobyname("tcp"), 6);
VS(getprotobynumber(6), "tcp");
VS(getservbyname("http", "tcp"), 80);
VS(getservbyport(80, "tcp"), "http");
$packed = chr(127) . chr(0) . chr(0) . chr(1);
VS(inet_ntop($packed), "127.0.0.1");
$packed = str_repeat(chr(0), 15) . chr(1);
VS(inet_ntop($packed), "::1");
$packed = chr(127) . chr(0) . chr(0) . chr(1);
VS(inet_pton("127.0.0.1"), $packed);
$packed = str_repeat(chr(0), 15) . chr(1);
VS(inet_pton("::1"), $packed);
VS(inet_pton("::1"), hex2bin("00000000000000000000000000000001"));
VS(ip2long("127.0.0.1"), 2130706433);
VS(long2ip(2130706433), "127.0.0.1");
VERIFY(dns_check_record("facebook.com"));
VERIFY(checkdnsrr("facebook.com"));
$x = dns_get_record("facebook.com", DNS_A);
VERIFY(!empty($x));
VERIFY(dns_get_mx("facebook.com", $hosts));
VERIFY(!empty($hosts));
VERIFY(getmxrr("facebook.com", $hosts));
VERIFY(!empty($hosts));
$f = fsockopen("facebook.com", 80);
VERIFY($f);
fputs($f, "GET / HTTP/1.0\n\n");
$r = fread($f, 15);
VERIFY(!empty($r));
$f = fsockopen("ssl://www.facebook.com", 443);
fwrite($f,
"GET / HTTP/1.1\r\n".
"Host: www.facebook.com\r\n".
"Connection: Close\r\n".
"\r\n");
$response = '';
while (!feof($f)) {
$line = fgets($f, 128);
$response .= $line;
}
VERIFY(!empty($response));
VS(socket_get_status(new stdclass), false);
$f = fsockopen("facebook.com", 80);
VERIFY($f);
socket_set_blocking($f, 0);
$f = fsockopen("facebook.com", 80);
VERIFY($f);
socket_set_timeout($f, 0);
header("Location: http://www.facebook.com");
header("Location: http://www.facebook.com");
VS(headers_list(), null);
header("Location: http://www.facebook.com");
VERIFY(!headers_sent());
header_remove("name");
header_remove();
VERIFY(!setcookie("name", "value"));
VERIFY(!setcookie("name", "value", 253402300800));
VERIFY(!setrawcookie("name", "value"));
define_syslog_variables();
openlog("TestExtNetwork", LOG_ODELAY, LOG_USER);
syslog(LOG_INFO, "testing");
closelog();
openlog("TestExtNetwork", LOG_ODELAY, LOG_USER);
syslog(LOG_INFO, "testing");
closelog();
openlog("TestExtNetwork", LOG_ODELAY, LOG_USER);
syslog(LOG_INFO, "testing");
closelog();
@@ -0,0 +1,33 @@
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
+39
Ver Arquivo
@@ -0,0 +1,39 @@
<?php
assert_options(1);
var_dump(dl(""));
var_dump(extension_loaded("phpmcc"));
var_dump(extension_loaded("bcmath"));
var_dump(extension_loaded("curl"));
var_dump(extension_loaded("simplexml"));
var_dump(extension_loaded("mysql"));
$x = get_loaded_extensions();
var_dump(empty($x));
var_dump(get_included_files());
var_dump(inclued_get_data());
var_dump(get_magic_quotes_gpc());
var_dump(get_magic_quotes_runtime());
clock_getres(CLOCK_THREAD_CPUTIME_ID, $sec, $nsec);
var_dump($sec);
var_dump($nsec);
var_dump(ini_get(""));
ini_set("memory_limit", 50000000);
var_dump(ini_get("memory_limit"));
set_time_limit(30);
var_dump(ini_get("max_execution_time"));
ini_set("max_execution_time", 40);
var_dump(ini_get("max_execution_time"));
var_dump(phpversion());
var_dump(putenv("FOO=bar"));
var_dump(!putenv("FOO"));
var_dump(!version_compare("1.3.0.dev", "1.1.2", "<"));
@@ -0,0 +1,23 @@
int(0)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
array(0) {
}
array(0) {
}
int(0)
int(0)
int(0)
int(1)
string(0) ""
string(8) "50000000"
string(2) "30"
string(2) "40"
string(14) "5.4.999-hiphop"
bool(true)
bool(true)
bool(true)
+169
Ver Arquivo
@@ -0,0 +1,169 @@
<?php
function VS($x, $y) {
var_dump($x === $y);
if ($x !== $y) { echo "Failed: $y\n"; echo "Got: $x\n";
var_dump(debug_backtrace()); }
}
function VERIFY($x) { VS($x != false, true); }
//////////////////////////////////////////////////////////////////////
// so we run on different range of ports every time
function get_random_port() {
static $base = -1;
if ($base == -1) {
$base = 12345 + (int)((int)(microtime(false) * 100) % 30000);
}
return ++$base;
}
function bind_random_port($socket, $address) {
for ($i = 0; $i < 20; $i++) {
$port = get_random_port();
if (socket_bind($socket, $address, $port)) return $port;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
VERIFY(socket_create(AF_INET, SOCK_STREAM, SOL_TCP));
$port = get_random_port();
socket_create_listen($port);
VERIFY(socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $fds));
VS(count($fds), 2);
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VS(socket_get_option($s, SOL_SOCKET, SO_TYPE), SOCK_STREAM);
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($s, "facebook.com", 80));
VERIFY(socket_getpeername($s, $address));
VERIFY(!empty($address));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($s, "facebook.com", 80));
VERIFY(socket_getsockname($s, $address));
VERIFY(!empty($address));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_set_block($s));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_set_nonblock($s));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_set_option($s, SOL_SOCKET, SO_RCVTIMEO,
array("sec" => 1, "usec" => 0)));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($s, "facebook.com", 80));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($s, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($s));
$server = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($server, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($server));
$client = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($client, "127.0.0.1", $port));
$s = socket_accept($server);
VERIFY(socket_write($client, "testing"));
// this could fail with shorter returns, but it never does...
VS(socket_read($s, 100), "testing");
$server = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($server, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($server));
$client = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($client, "127.0.0.1", $port));
$s = socket_accept($server);
$reads = array($s);
VS(socket_select($reads, $ignore1, $ignore2, 1, 0), 0);
VERIFY(socket_write($client, "testing"));
$reads = array($s);
VS(socket_select($reads, $ignore1, $ignore2, 1, 0), 1);
for ($i = 0; $i < 20; $i++) {
$port = get_random_port();
$server = socket_server("127.0.0.1", $port);
if ($server !== false) break;
}
VERIFY($server !== false);
$client = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($client, "127.0.0.1", $port));
$s = socket_accept($server);
$reads = array($s);
VS(socket_select($reads, $ignore1, $ignore2, 1, 0), 0);
VERIFY(socket_write($client, "testing"));
$reads = array($s);
VS(socket_select($reads, $ignore1, $ignore2, 1, 0), 1);
$server = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($server, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($server));
$client = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($client, "127.0.0.1", $port));
$s = socket_accept($server);
$text = "testing";
VERIFY(socket_send($client, $text, 4, 0));
VERIFY(socket_recv($s, $buffer, 100, 0));
VS($buffer, "test");
$server = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($server, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($server));
$client = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
VERIFY(socket_connect($client, "127.0.0.1", $port));
$s = socket_accept($server);
$text = "testing";
VERIFY(socket_sendto($client, $text, 4, 0, "127.0.0.1", $port));
VERIFY(socket_recvfrom($s, $buffer, 100, 0, $name, $vport));
VS($buffer, "test");
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($s, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($s));
VERIFY(socket_shutdown($s));
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$port = bind_random_port($s, "127.0.0.1");
VERIFY($port != 0);
VERIFY(socket_listen($s));
socket_close($s);
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($s, "127.0.0.1", 80);
if (socket_last_error($s) == 13) {
VS(socket_strerror(13), "Permission denied");
socket_clear_error($s);
}
VS(socket_last_error($s), 0);
@@ -0,0 +1,51 @@
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)