Skip to content

Commit cd58334

Browse files
authored
ext/curl: speed up tests (#23228)
By waiting shorter for the server to be ready. The first check for output on stderr takes approximately 10ms, so we wait 20ms to make sure its ready. The second check for the open port typically succeeds immediately, so move the sleep to after we have tried. Change the numbers in curl_setopt_ssl.phpt for consistency.
1 parent f0e88c7 commit cd58334

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎ext/curl/tests/curl_setopt_ssl.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if ($process === false) {
7575
try {
7676
// Wait until OpenSSL is actually listening before making the first request.
7777
$ready = false;
78-
for ($i = 0; $i < 100; $i++) {
78+
for ($i = 0; $i < 150; $i++) {
7979
$connection = @stream_socket_client("tcp://127.0.0.1:$port", $errno, $errstr, 0.05);
8080
if ($connection !== false) {
8181
fclose($connection);
@@ -85,7 +85,7 @@ try {
8585
if (!proc_get_status($process)['running']) {
8686
break;
8787
}
88-
usleep(50000);
88+
usleep(20000);
8989
}
9090
if (!$ready) {
9191
stream_set_blocking($pipes[2], false);

‎ext/curl/tests/server.inc‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function curl_cli_server_start() {
1515
// First, wait for the dev server to declare itself ready.
1616
$bound = null;
1717
stream_set_blocking($pipes[2], false);
18-
for ($i = 0; $i < 60; $i++) {
19-
usleep(50000); // 50ms per try
18+
for ($i = 0; $i < 150; $i++) {
19+
usleep(20000); // 20ms per try
2020
$status = proc_get_status($handle);
2121
if (empty($status['running'])) {
2222
echo "Server is not running\n";
@@ -44,8 +44,7 @@ function curl_cli_server_start() {
4444
// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
4545
// it might not be listening yet...need to wait until fsockopen() call returns
4646
$error = "Unable to connect to server\n";
47-
for ($i=0; $i < 60; $i++) {
48-
usleep(50000); // 50ms per try
47+
for ($i=0; $i < 150; $i++) {
4948
$status = proc_get_status($handle);
5049
$fp = @fsockopen("tcp://$bound");
5150
// Failure, the server is no longer running
@@ -58,6 +57,7 @@ function curl_cli_server_start() {
5857
$error = '';
5958
break;
6059
}
60+
usleep(20000); // 20ms per try
6161
}
6262

6363
if ($fp) {
@@ -74,12 +74,12 @@ function curl_cli_server_start() {
7474
function($handle) {
7575
proc_terminate($handle);
7676
/* Wait for server to shutdown */
77-
for ($i = 0; $i < 60; $i++) {
77+
for ($i = 0; $i < 150; $i++) {
7878
$status = proc_get_status($handle);
7979
if (!($status && $status['running'])) {
8080
break;
8181
}
82-
usleep(50000);
82+
usleep(20000);
8383
}
8484
},
8585
$handle

0 commit comments

Comments
 (0)