Skip to content

Implement support for tests loading all extensions #16251

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

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions Zend/tests/arginfo_zpp_mismatch.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Test that there is no arginfo/zpp mismatch
if (getenv('SKIP_ASAN')) die("skip Intermittently crashes lsan");
if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions");
?>
--EXTENSIONS--
*
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions Zend/tests/arginfo_zpp_mismatch_strict.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Test that there is no arginfo/zpp mismatch in strict mode
if (getenv('SKIP_ASAN')) die("skip Intermittently crashes lsan");
if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions");
?>
--EXTENSIONS--
*
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions Zend/tests/instantiate_all_classes.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Try to instantiate all classes without arguments
--EXTENSIONS--
*
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions Zend/tests/weakrefs/notify.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Object free handler must call zend_weakrefs_notify
--EXTENSIONS--
*
--FILE--
<?php

Expand Down
6 changes: 5 additions & 1 deletion run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ function write_information(array $user_tests, $phpdbg): void
$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)) {
if (preg_match('/^(?:php_)([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this change is not directly related to this PR (although it is required to make this patch work on Windows, at least). If desired, I can provide a separate PR for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I believe that the php_ prefix is specific to windows (at least there is no prefix on linux).

Maybe using a block list would be fine. Otherwise I'm not sure how we can detect that a particular .so/.dll file is an extension. We could check if it defines a ${name}_module_entry symbol but this will not be portable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I believe that the php_ prefix is specific to windows (at least there is no prefix on linux).

Ah, thank you! Maybe we should just used slightly different regexps on Windows and other platforms? Another option would be for Windows builds to put the extension DLLs in the ext/ folder; I'll have a look at this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've pushed a commit separating the regexps (Windows vs. non-Windows). An early draft of putting the extension DLLs in a subfolder is PR #16282.

if (!extension_loaded($matches[1])) {
$exts[] = $matches[1];
}
Expand Down Expand Up @@ -1813,6 +1813,7 @@ function run_test(string $php, $file, array $env): string
global $slow_min_ms;
global $preload, $file_cache;
global $num_repeats;
global $exts_to_test;
// Parallel testing
global $workerID;
global $show_progress;
Expand Down Expand Up @@ -2027,6 +2028,9 @@ function run_test(string $php, $file, array $env): string
$extensions = [];
if ($test->hasSection('EXTENSIONS')) {
$extensions = preg_split("/[\n\r]+/", trim($test->getSection('EXTENSIONS')));
if (in_array("*", $extensions, true)) {
$extensions = $exts_to_test;
}
}
if (is_array($IN_REDIRECT) && $IN_REDIRECT['EXTENSIONS'] != []) {
$extensions = array_merge($extensions, $IN_REDIRECT['EXTENSIONS']);
Expand Down
Loading