Skip to content

Commit 3d2d785

Browse files
committed
test(http): isolate Unix socket path --filter=[unit]
1 parent 1e053c1 commit 3d2d785

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/swoole_http_server/unixsocket2.phpt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@ require __DIR__ . '/../include/bootstrap.php';
99
use Swoole\Http\Server;
1010
use Swoole\Http\Response;
1111

12-
const SOCKET = __DIR__ . '/server.sock';
12+
$socket = tempnam(sys_get_temp_dir(), 'swoole-http-server-');
13+
unlink($socket);
1314

1415
$pm = new SwooleTest\ProcessManager;
1516

16-
$pm->parentFunc = function ($pid) use ($pm) {
17+
$pm->parentFunc = function ($pid) use ($pm, $socket) {
1718
$ch = curl_init();
18-
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, SOCKET);
19+
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, $socket);
1920
curl_setopt($ch, CURLOPT_URL, "http://localhost/?a=hello&b=12345&test=world");
2021
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
2122
$output = curl_exec($ch);
2223
var_dump($output);
2324
$pm->kill();
2425
};
2526

26-
$pm->childFunc = function () use ($pm) {
27-
$serv = new Server(SOCKET, 0, SWOOLE_PROCESS, SWOOLE_SOCK_UNIX_STREAM);
27+
$pm->childFunc = function () use ($pm, $socket) {
28+
$serv = new Server($socket, 0, SWOOLE_PROCESS, SWOOLE_SOCK_UNIX_STREAM);
2829
$serv->set([
2930
'log_file' => '/dev/null',
3031
]);
@@ -39,6 +40,7 @@ $pm->childFunc = function () use ($pm) {
3940

4041
$pm->childFirst();
4142
$pm->run();
43+
@unlink($socket);
4244
?>
4345
--EXPECT--
4446
string(40) "{"a":"hello","b":"12345","test":"world"}"

0 commit comments

Comments
 (0)