You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
27
vendor/swoole/tests/swoole_event/defer.phpt
vendored
Executable file
27
vendor/swoole/tests/swoole_event/defer.phpt
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
global_function: swoole_event_write
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
swoole_event_defer(function () {
|
||||
echo "defer [1]\n";
|
||||
});
|
||||
swoole_timer_after(100, function () {
|
||||
echo "timer [1]\n";
|
||||
swoole_timer_after(100, function () {
|
||||
echo "timer [2]\n";
|
||||
});
|
||||
swoole_event_defer(function () {
|
||||
echo "defer [2]\n";
|
||||
});
|
||||
});
|
||||
swoole_event_wait();
|
||||
?>
|
||||
|
||||
--EXPECT--
|
||||
defer [1]
|
||||
timer [1]
|
||||
defer [2]
|
||||
timer [2]
|
27
vendor/swoole/tests/swoole_event/swoole_event.phpt
vendored
Executable file
27
vendor/swoole/tests/swoole_event/swoole_event.phpt
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
swoole_event: swoole_event_exit
|
||||
|
||||
--SKIPIF--
|
||||
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
||||
--INI--
|
||||
assert.active=1
|
||||
assert.warning=1
|
||||
assert.bail=0
|
||||
assert.quiet_eval=0
|
||||
|
||||
|
||||
--FILE--
|
||||
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
swoole_timer_tick(1, function() {
|
||||
echo "tick\n";
|
||||
swoole_event_exit();
|
||||
});
|
||||
Swoole\Event::wait();
|
||||
?>
|
||||
--EXPECT--
|
||||
tick
|
||||
|
||||
|
54
vendor/swoole/tests/swoole_event/swoole_event_core.phpt
vendored
Executable file
54
vendor/swoole/tests/swoole_event/swoole_event_core.phpt
vendored
Executable file
@ -0,0 +1,54 @@
|
||||
--TEST--
|
||||
swoole_event: swoole_event_exit coredump
|
||||
|
||||
--SKIPIF--
|
||||
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
||||
--INI--
|
||||
assert.active=1
|
||||
assert.warning=1
|
||||
assert.bail=0
|
||||
assert.quiet_eval=0
|
||||
|
||||
|
||||
--FILE--
|
||||
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
function dnsLookup() {
|
||||
swoole_async_dns_lookup("www.qq.com", function($host, $ip) {
|
||||
swoole_event_exit();
|
||||
exit();
|
||||
});
|
||||
}
|
||||
|
||||
$i = 200;
|
||||
while (--$i) {
|
||||
$pid = pcntl_fork();
|
||||
if ($pid < 0) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pid === 0) {
|
||||
dnsLookup();
|
||||
exit();
|
||||
}
|
||||
|
||||
pcntl_waitpid($pid, $status);
|
||||
if (!pcntl_wifexited($status)) {
|
||||
fprintf(STDERR, "$pid %s exit [exit_status=%d, stop_sig=%d, term_sig=%d]\n",
|
||||
pcntl_wifexited($status) ? "normal": "abnormal",
|
||||
pcntl_wexitstatus($status),
|
||||
pcntl_wstopsig($status),
|
||||
pcntl_wtermsig($status)
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
echo "SUCCESS";
|
||||
?>
|
||||
|
||||
--EXPECT--
|
||||
SUCCESS
|
||||
|
||||
|
27
vendor/swoole/tests/swoole_event/swoole_event_del.phpt
vendored
Executable file
27
vendor/swoole/tests/swoole_event/swoole_event_del.phpt
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
global_function: swoole_event_del
|
||||
--SKIPIF--
|
||||
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
||||
--INI--
|
||||
assert.active=1
|
||||
assert.warning=1
|
||||
assert.bail=0
|
||||
assert.quiet_eval=0
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
$fp = stream_socket_client("tcp://www.qq.com:80", $errno, $errstr, 30);
|
||||
fwrite($fp, "GET / HTTP/1.1\r\nHost: www.qq.com\r\n\r\n");
|
||||
|
||||
swoole_event_add($fp, function($fp) {
|
||||
$resp = fread($fp, 8192);
|
||||
//socket处理完成后,从epoll事件中移除socket
|
||||
swoole_event_del($fp);
|
||||
fclose($fp);
|
||||
});
|
||||
Swoole\Event::wait();
|
||||
?>
|
||||
|
||||
--EXPECT--
|
30
vendor/swoole/tests/swoole_event/swoole_event_isset.phpt
vendored
Executable file
30
vendor/swoole/tests/swoole_event/swoole_event_isset.phpt
vendored
Executable file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
global_function: swoole_event_isset
|
||||
--SKIPIF--
|
||||
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
||||
--INI--
|
||||
assert.active=1
|
||||
assert.warning=1
|
||||
assert.bail=0
|
||||
assert.quiet_eval=0
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
$fp = stream_socket_client("tcp://www.qq.com:80", $errno, $errstr, 30);
|
||||
fwrite($fp, "GET / HTTP/1.1\r\nHost: www.qq.com\r\n\r\n");
|
||||
|
||||
swoole_event_add($fp, function ($fp) {
|
||||
$resp = fread($fp, 8192);
|
||||
//socket处理完成后,从epoll事件中移除socket
|
||||
swoole_event_del($fp);
|
||||
fclose($fp);
|
||||
});
|
||||
|
||||
assert(swoole_event_isset($fp, SWOOLE_EVENT_READ) == true);
|
||||
assert(swoole_event_isset($fp, SWOOLE_EVENT_WRITE) == false);
|
||||
Swoole\Event::wait();
|
||||
?>
|
||||
|
||||
--EXPECT--
|
48
vendor/swoole/tests/swoole_event/swoole_event_set.phpt
vendored
Executable file
48
vendor/swoole/tests/swoole_event/swoole_event_set.phpt
vendored
Executable file
@ -0,0 +1,48 @@
|
||||
--TEST--
|
||||
global_function: swoole_event_set
|
||||
--SKIPIF--
|
||||
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
||||
--INI--
|
||||
assert.active=1
|
||||
assert.warning=1
|
||||
assert.bail=0
|
||||
assert.quiet_eval=0
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
$fp = stream_socket_client("tcp://www.qq.com:80", $errno, $errstr, 30);
|
||||
|
||||
function write_callback($fp) {
|
||||
$resp = fread($fp, 8192);
|
||||
|
||||
//socket处理完成后,从epoll事件中移除socket
|
||||
swoole_event_del($fp);
|
||||
fclose($fp);
|
||||
|
||||
echo "read_callback:SUCCESS\n";
|
||||
}
|
||||
|
||||
swoole_event_add($fp, function($fp) {
|
||||
$resp = fread($fp, 8192);
|
||||
|
||||
//socket处理完成后,从epoll事件中移除socket
|
||||
swoole_event_del($fp);
|
||||
fclose($fp);
|
||||
|
||||
echo "SUCCESS\n";
|
||||
});
|
||||
|
||||
#设置写事件回调函数,这会替换掉原有的写事件回调函数
|
||||
swoole_event_set($fp, null, 'write_callback', SWOOLE_EVENT_WRITE);
|
||||
|
||||
swoole_event_write($fp, "GET / HTTP/1.1\r\nHost: www.qq.com\r\n\r\n");
|
||||
echo "Finish";
|
||||
?>
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Finish
|
||||
|
||||
read_callback:SUCCESS
|
28
vendor/swoole/tests/swoole_event/swoole_event_write.phpt
vendored
Executable file
28
vendor/swoole/tests/swoole_event/swoole_event_write.phpt
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
global_function: swoole_event_write
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
$fp = stream_socket_client("tcp://www.qq.com:80", $errno, $errstr, 30);
|
||||
|
||||
swoole_event_add($fp, function($fp) {
|
||||
$resp = fread($fp, 8192);
|
||||
|
||||
//socket处理完成后,从epoll事件中移除socket
|
||||
swoole_event_del($fp);
|
||||
fclose($fp);
|
||||
|
||||
echo "SUCCESS\n";
|
||||
});
|
||||
|
||||
swoole_event_write($fp, "GET / HTTP/1.1\r\nHost: www.qq.com\r\n\r\n");
|
||||
|
||||
echo "Finish\n";
|
||||
?>
|
||||
|
||||
--EXPECT--
|
||||
Finish
|
||||
|
||||
SUCCESS
|
Reference in New Issue
Block a user