From 0f4742d2e809d96a94bbc0a963bb097a9701c100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 13 Apr 2022 15:25:34 +0200 Subject: [PATCH 01/13] List skipped extensions explicitly --- run-tests.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/run-tests.php b/run-tests.php index f351564bff978..6c0e84bea5981 100755 --- a/run-tests.php +++ b/run-tests.php @@ -735,9 +735,9 @@ function main(): void } else { // Compile a list of all test files (*.phpt). $test_files = []; - $exts_tested = count($exts_to_test); - $exts_skipped = 0; - $ignored_by_ext = 0; + $exts_tested = $exts_to_test; + $exts_skipped = []; + $ignored_by_ext = []; sort($exts_to_test); $test_dirs = []; $optionals = ['Zend', 'tests', 'ext', 'sapi']; @@ -1053,7 +1053,7 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false) if (is_dir("{$dir}/{$name}") && !in_array($name, ['.', '..', '.svn'])) { $skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test)); if ($skip_ext) { - $exts_skipped++; + $exts_skipped[] = $name; } find_files("{$dir}/{$name}", false, $ignore || $skip_ext); } @@ -1068,10 +1068,10 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false) // (but not those starting with a dot, which are hidden on // many platforms) if (substr($name, -5) == '.phpt' && substr($name, 0, 1) !== '.') { + $testfile = realpath("{$dir}/{$name}"); if ($ignore) { - $ignored_by_ext++; + $ignored_by_ext[] = $testfile; } else { - $testfile = realpath("{$dir}/{$name}"); $test_files[] = $testfile; } } @@ -3042,7 +3042,7 @@ function compute_summary(): void global $n_total, $test_results, $ignored_by_ext, $sum_results, $percent_results; $n_total = count($test_results); - $n_total += $ignored_by_ext; + $n_total += count($ignored_by_ext); $sum_results = [ 'PASSED' => 0, 'WARNED' => 0, @@ -3058,7 +3058,7 @@ function compute_summary(): void $sum_results[$v]++; } - $sum_results['SKIPPED'] += $ignored_by_ext; + $sum_results['SKIPPED'] += count($ignored_by_ext); $percent_results = []; foreach ($sum_results as $v => $n) { @@ -3090,8 +3090,8 @@ function get_summary(bool $show_ext_summary): string ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- -Exts skipped : ' . sprintf('%4d', $exts_skipped) . ' -Exts tested : ' . sprintf('%4d', $exts_tested) . ' +Exts skipped : ' . sprintf('%4d', count($exts_skipped)) . ($exts_skipped ? ' (' . implode(', ', $exts_skipped) . ')' : '') . ' +Exts tested : ' . sprintf('%4d', count($exts_tested)) . ' --------------------------------------------------------------------- '; } From 8f8a708d5a80058e80aa586080ed96bac157446f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 17 Apr 2022 10:39:01 +0200 Subject: [PATCH 02/13] fix silenced opcache loadable error --- run-tests.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/run-tests.php b/run-tests.php index 6c0e84bea5981..c21fe1f5000ec 100755 --- a/run-tests.php +++ b/run-tests.php @@ -880,17 +880,21 @@ function write_information(): void // load list of enabled and loadable extensions save_text($info_file, <<<'PHP' 'opcache'][$ext] ?? $ext; + } + $ext_dir = ini_get('extension_dir'); foreach (scandir($ext_dir) as $file) { if (!preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { continue; } $ext = $matches[1]; - if (!extension_loaded($ext) && @dl($file)) { - echo ",", $ext; + if (!in_array($ext, $exts) && !extension_loaded($ext) && @dl($file)) { + $exts[] = $ext; } } + echo implode(',', $exts); ?> PHP); $exts_to_test = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"")); From 36470192cd188a4c04193fcbb41a694833450a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 10 Sep 2022 15:11:31 +0200 Subject: [PATCH 03/13] dedup loaded ext names remap --- run-tests.php | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/run-tests.php b/run-tests.php index c21fe1f5000ec..39169d45e33b2 100755 --- a/run-tests.php +++ b/run-tests.php @@ -880,24 +880,19 @@ function write_information(): void // load list of enabled and loadable extensions save_text($info_file, <<<'PHP' 'opcache'][$ext] ?? $ext; - } + $exts = get_loaded_extensions(); $ext_dir = ini_get('extension_dir'); foreach (scandir($ext_dir) as $file) { - if (!preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { - continue; - } - $ext = $matches[1]; - if (!in_array($ext, $exts) && !extension_loaded($ext) && @dl($file)) { - $exts[] = $ext; + if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { + if (@dl($matches[1])) { + $exts[] = $matches[1]; + } } } echo implode(',', $exts); - ?> - PHP); - $exts_to_test = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"")); + PHP); + $extensionsNames = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"")); + $exts_to_test = array_unique(remap_loaded_extensions_names($extensionsNames)); // check for extensions that need special handling and regenerate $info_params_ex = [ 'session' => ['session.auto_start=0'], @@ -2789,6 +2784,22 @@ function run_test(string $php, $file, array $env): string return $restype[0] . 'ED'; } +/** + * Map "Zend OPcache" to "opcache" and convert all ext names to lowercase. + */ +function remap_loaded_extensions_names(array $names): array +{ + $exts = []; + foreach ($names as $name) { + if ($name === 'Core') { + continue; + } + $exts[] = ['Zend OPcache' => 'opcache'][$name] ?? strtolower($name); + } + + return $exts; +} + /** * @return bool|int */ @@ -3686,11 +3697,8 @@ public function getExtensions(string $php): array } $extDir = shell_exec("$php -d display_errors=0 -r \"echo ini_get('extension_dir');\""); - $extensions = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\"")); - $extensions = array_map('strtolower', $extensions); - if (in_array('zend opcache', $extensions)) { - $extensions[] = 'opcache'; - } + $extensionsNames = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\"")); + $extensions = remap_loaded_extensions_names($extensionsNames); $result = [$extDir, $extensions]; $this->extensions[$php] = $result; From 43eef20141773dceb44a770307d59410923498d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 10 Sep 2022 11:58:10 +0200 Subject: [PATCH 04/13] always lowercased already --- run-tests.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/run-tests.php b/run-tests.php index 39169d45e33b2..3b846ec396e3d 100755 --- a/run-tests.php +++ b/run-tests.php @@ -748,11 +748,6 @@ function main(): void } } - // Convert extension names to lowercase - foreach ($exts_to_test as $key => $val) { - $exts_to_test[$key] = strtolower($val); - } - foreach ($test_dirs as $dir) { find_files(TEST_PHP_SRCDIR . "/{$dir}", $dir == 'ext'); } From b40100128d03987bd5b0cebf922ddf9b5fe59468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 10 Sep 2022 12:00:45 +0200 Subject: [PATCH 05/13] always require EXTENSIONS to be specified in LC --- run-tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 3b846ec396e3d..cc2d6121a93bd 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2020,7 +2020,7 @@ function run_test(string $php, $file, array $env): string $ext_prefix = IS_WINDOWS ? "php_" : ""; $missing = []; foreach ($extensions as $req_ext) { - if (!in_array(strtolower($req_ext), $loaded)) { + if (!in_array($req_ext, $loaded, true)) { if ($req_ext == 'opcache' || $req_ext == 'xdebug') { $ext_file = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX; $ini_settings['zend_extension'][] = $ext_file; From 8488fccc7e38ce561e6feae803bcf464cfbdd5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 10 Sep 2022 15:31:09 +0200 Subject: [PATCH 06/13] fix align for 10k+ tests --- run-tests.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/run-tests.php b/run-tests.php index cc2d6121a93bd..acca6a40efae1 100755 --- a/run-tests.php +++ b/run-tests.php @@ -3100,43 +3100,43 @@ function get_summary(bool $show_ext_summary): string ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- -Exts skipped : ' . sprintf('%4d', count($exts_skipped)) . ($exts_skipped ? ' (' . implode(', ', $exts_skipped) . ')' : '') . ' -Exts tested : ' . sprintf('%4d', count($exts_tested)) . ' +Exts skipped : ' . sprintf('%5d', count($exts_skipped)) . ($exts_skipped ? ' (' . implode(', ', $exts_skipped) . ')' : '') . ' +Exts tested : ' . sprintf('%5d', count($exts_tested)) . ' --------------------------------------------------------------------- '; } $summary .= ' -Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total); +Number of tests : ' . sprintf('%5d', $n_total) . ' ' . sprintf('%8d', $x_total); if ($sum_results['BORKED']) { $summary .= ' -Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------'; +Tests borked : ' . sprintf('%5d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------'; } $summary .= ' -Tests skipped : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' -------- -Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . ' -Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed); +Tests skipped : ' . sprintf('%5d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' -------- +Tests warned : ' . sprintf('%5d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . ' +Tests failed : ' . sprintf('%5d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed); if ($sum_results['XFAILED']) { $summary .= ' -Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed); +Expected fail : ' . sprintf('%5d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed); } if ($valgrind) { $summary .= ' -Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked); +Tests leaked : ' . sprintf('%5d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked); if ($sum_results['XLEAKED']) { $summary .= ' -Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked); +Expected leak : ' . sprintf('%5d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked); } } $summary .= ' -Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . ' +Tests passed : ' . sprintf('%5d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . ' --------------------------------------------------------------------- -Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . ' +Time taken : ' . sprintf('%5d seconds', $end_time - $start_time) . ' ===================================================================== '; $failed_test_summary = ''; From 0ed4ec5de5912b818f24f9d6bcda7ebb9922aca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 Sep 2022 14:08:25 +0200 Subject: [PATCH 07/13] no "$id" header --- run-tests.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index acca6a40efae1..d9115a66cb8e3 100755 --- a/run-tests.php +++ b/run-tests.php @@ -23,8 +23,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - /* Temporary variables while this file is being refactored. */ /** @var ?JUnit */ $junit = null; From 4a0dfde22d31490ab49f58014b70bdb6637fa8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 Sep 2022 14:10:52 +0200 Subject: [PATCH 08/13] DEBUG win ZTS + perf --- run-tests.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index d9115a66cb8e3..f2e683ad3024c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -877,14 +877,17 @@ function write_information(): void $ext_dir = ini_get('extension_dir'); foreach (scandir($ext_dir) as $file) { if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { - if (@dl($matches[1])) { + $t = microtime(true); + if (dl($matches[1])) { $exts[] = $matches[1]; + $exts[] = microtime(true) - $t; } } } echo implode(',', $exts); PHP); $extensionsNames = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"")); + print_r($extensionsNames);echo "\nxxxxxx\n\n\n"; $exts_to_test = array_unique(remap_loaded_extensions_names($extensionsNames)); // check for extensions that need special handling and regenerate $info_params_ex = [ From 447dfe5b5fb1214b10942753a62314f1ca19bba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 Sep 2022 16:34:27 +0200 Subject: [PATCH 09/13] DEBUG var_dump problematic ext --- run-tests.php | 1 + 1 file changed, 1 insertion(+) diff --git a/run-tests.php b/run-tests.php index f2e683ad3024c..a47ec64d0f873 100755 --- a/run-tests.php +++ b/run-tests.php @@ -878,6 +878,7 @@ function write_information(): void foreach (scandir($ext_dir) as $file) { if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { $t = microtime(true); + var_dump($matches[1]); if (dl($matches[1])) { $exts[] = $matches[1]; $exts[] = microtime(true) - $t; From 7d0f525289b2d2b59649a4aee476659d6c13810a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 Sep 2022 16:43:28 +0200 Subject: [PATCH 10/13] readd extension_loaded() to mitigate the issue --- run-tests.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index a47ec64d0f873..5bdf4fea1be29 100755 --- a/run-tests.php +++ b/run-tests.php @@ -877,8 +877,12 @@ function write_information(): void $ext_dir = ini_get('extension_dir'); foreach (scandir($ext_dir) as $file) { if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { - $t = microtime(true); - var_dump($matches[1]); + // remove once https://github.com/php/php-src/issues/9196 is fixed + // @dl() is fast (about 1 ms / dl() call) + if (extension_loaded($matches[1])) { + continue; + } + if (dl($matches[1])) { $exts[] = $matches[1]; $exts[] = microtime(true) - $t; From 1c78850e9de889af17a421cfbff6238848b07a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 13 Sep 2022 17:23:03 +0200 Subject: [PATCH 11/13] fix dl fatal error --- run-tests.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/run-tests.php b/run-tests.php index 5bdf4fea1be29..6d988b2e87c21 100755 --- a/run-tests.php +++ b/run-tests.php @@ -877,22 +877,20 @@ function write_information(): void $ext_dir = ini_get('extension_dir'); foreach (scandir($ext_dir) as $file) { if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { + // workaround dl('mysqli') fatal error // remove once https://github.com/php/php-src/issues/9196 is fixed - // @dl() is fast (about 1 ms / dl() call) - if (extension_loaded($matches[1])) { + if ($matches[1] === 'mysqli') { continue; } - if (dl($matches[1])) { + if (@dl($matches[1])) { $exts[] = $matches[1]; - $exts[] = microtime(true) - $t; } } } echo implode(',', $exts); PHP); $extensionsNames = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"")); - print_r($extensionsNames);echo "\nxxxxxx\n\n\n"; $exts_to_test = array_unique(remap_loaded_extensions_names($extensionsNames)); // check for extensions that need special handling and regenerate $info_params_ex = [ From ce48880483ec7cac1a7a0e0ae5767d8a4bcd2055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 13 Sep 2022 17:34:30 +0200 Subject: [PATCH 12/13] strtolower not needed --- run-tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 6d988b2e87c21..d4e6aad92434d 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1049,7 +1049,7 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false) while (($name = readdir($o)) !== false) { if (is_dir("{$dir}/{$name}") && !in_array($name, ['.', '..', '.svn'])) { - $skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test)); + $skip_ext = ($is_ext_dir && !in_array($name, $exts_to_test)); if ($skip_ext) { $exts_skipped[] = $name; } From 7f85bf68d3669f0e9918af094e6bc8a3b14ea2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 22 Sep 2022 12:14:00 +0200 Subject: [PATCH 13/13] mysqli fixed in GH-9557 --- run-tests.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/run-tests.php b/run-tests.php index d4e6aad92434d..7475533aad4b8 100755 --- a/run-tests.php +++ b/run-tests.php @@ -877,13 +877,7 @@ function write_information(): void $ext_dir = ini_get('extension_dir'); foreach (scandir($ext_dir) as $file) { if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) { - // workaround dl('mysqli') fatal error - // remove once https://github.com/php/php-src/issues/9196 is fixed - if ($matches[1] === 'mysqli') { - continue; - } - - if (@dl($matches[1])) { + if (!extension_loaded($matches[1]) && @dl($matches[1])) { $exts[] = $matches[1]; } }