Skip to content

add SKIP_SLOW_TEST's + slow locator script #11647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions benchmark/find_slow_tests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

use function var_dump as d;
use function arsort as arrsort;

define("IS_WINDOWS", PHP_OS_FAMILY === "Windows");
$php_binary = implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'sapi', 'cli', 'php']);
if (IS_WINDOWS) {
$php_binary .= '.exe';
}
if (!is_executable($php_binary)) {
echo "Error: Cannot find php binary at '{$php_binary}'\n";
exit(1);
}
$php_binary = realpath($php_binary);
$php_src_dir = realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..']));
$php_src_dir_relative_cutoff = strlen($php_src_dir) + strlen(DIRECTORY_SEPARATOR);
$test_files = (function () use ($php_src_dir): array {
$test_files = [];
$dir = new RecursiveDirectoryIterator($php_src_dir);
$iterator = new RecursiveIteratorIterator($dir);
foreach ($iterator as $file) {
/** @var SplFileInfo $file */
if ($file->getExtension() !== 'phpt') {
continue;
}
$test_files[] = $file->getPathname();
}
return $test_files;
})();
$results_raw = [];
$cmd_template = implode(" ", array(
escapeshellarg($php_binary),
escapeshellarg(realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'run-tests.php']))),
// '-p ' . escapeshellarg($php_binary),
'--no-color',
'--no-progress',
'-q',
'-x', // SKIP_SLOW_TESTS
'',
));
$total = count($test_files);
$null_path = IS_WINDOWS ? 'NUL' : '/dev/null'; // funfact, on Windows, every single directory has a null device file named "NUL" ...
foreach ($test_files as $test_no => $test_file) {
$test_file_relative = substr($test_file, $php_src_dir_relative_cutoff);
echo "Running test " . ($test_no + 1) . "/{$total}: {$test_file_relative}\n";
$best_time = INF;
$cmd = $cmd_template . escapeshellarg($test_file) . " > {$null_path} 2>&1";
for ($testrun = 0; $testrun < 3; ++$testrun) {
$start = microtime(true);
passthru($cmd);
$end = microtime(true);
$best_time = min($best_time, $end - $start);
}
echo "Best time: {$best_time}s\n";
$results_raw[$test_file_relative] = $best_time;
}
$results_sorted = $results_raw;
arrsort($results_sorted, SORT_NUMERIC);
var_export($results_sorted);
7 changes: 7 additions & 0 deletions ext/curl/tests/bug48203_multi.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Variation of bug #48203 with curl_multi_exec (Crash when file pointers passed to curl are closed before calling curl_multi_exec)
--EXTENSIONS--
curl
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.34s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php
include 'server.inc';
Expand Down
4 changes: 4 additions & 0 deletions ext/curl/tests/bug54798-unix.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ curl
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
die('skip not for Windows');
}
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.37s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php
Expand Down
7 changes: 7 additions & 0 deletions ext/curl/tests/bug54798.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Bug #54798 (Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec)
--EXTENSIONS--
curl
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.34s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
7 changes: 7 additions & 0 deletions ext/curl/tests/curl_pause_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Test CURL_READFUNC_PAUSE and curl_pause()
--EXTENSIONS--
curl
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.32s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php
include 'server.inc';
Expand Down
4 changes: 4 additions & 0 deletions ext/curl/tests/curl_setopt_ssl.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ CURLOPT_SSL* basic client auth tests
curl
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.57s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
if (!function_exists("proc_open")) die("skip no proc_open");
exec('openssl version', $out, $code);
if ($code > 0) die("skip couldn't locate openssl binary");
Expand Down
7 changes: 7 additions & 0 deletions ext/pdo_sqlite/tests/common.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
SQLite
--EXTENSIONS--
pdo_sqlite
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 2.22s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--REDIRECTTEST--
return array(
'ENV' => array(
Expand Down
7 changes: 7 additions & 0 deletions ext/standard/tests/general_functions/proc_open_pipes1.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
proc_open() with > 16 pipes
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.14s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
7 changes: 7 additions & 0 deletions ext/standard/tests/general_functions/proc_open_pipes2.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
proc_open() with no pipes
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.14s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
7 changes: 7 additions & 0 deletions ext/standard/tests/general_functions/proc_open_pipes3.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
proc_open() with invalid pipes
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.15s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
proc_open() with output socketpairs
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 2.14s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
proc_open() with IO socketpairs
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.15s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
proc_open() with socket and pipe
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) {
// finished in 1.15s in a best-of-3 on an idle Intel Xeon X5670 on PHP 8.3.0-dev
die("skip slow test");
}
?>
--FILE--
<?php

Expand Down
2 changes: 1 addition & 1 deletion run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ function main(): void
$argc = count($argv);
}

for ($i = 1; $i < $argc; $i++) {
for ($i = 1; $i < $argc; ++$i) {
$is_switch = false;
$switch = substr($argv[$i], 1, 1);
$repeat = substr($argv[$i], 0, 1) == '-';
Expand Down