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

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 5, 2024

When running the tests, extensions are already loaded, or are requested via the --EXTENSIONS-- section explicitly. Some tests, though, would benefit from loading and testing all available extension. We make that possible by adding support for the * wildcard.

run-tests.php Outdated
@@ -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 = array_diff($exts_to_test, ["php8apache2_4", "php8phpdbg", "php8ts_debug"]);
Copy link
Member Author

Choose a reason for hiding this comment

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

The list of exclusions doesn't belong here; this needs to be handled otherwise. Maybe somebody has an idea (except for using dl()).

Copy link
Member Author

Choose a reason for hiding this comment

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

Could probably require the php_ prefix:

if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {

Or is that an issue on non Windows platforms?

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of * manual list with ? prefix - loaded only if present?

Copy link
Member Author

Choose a reason for hiding this comment

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

The whole point is to load all available extensions (even for external extensions).

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean * can be dangerous as it can load unwanted non-php-src extensions.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean by "dangerous"? Security related, or just that even external extensions would be tested as well. If the latter, in my opinion, this is a good thing, since all extensions should conform to the contracts established by these tests. If some extensions don't, it will be noticed, and the extensions can be fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the latter, if it is wanted to load/run unknown extension at all.

cmb69 added 3 commits October 6, 2024 15:53
When running the tests, extensions are already loaded, or are requested
via the `--EXTENSIONS--` section explicitly.  Some tests, though, would
benefit from loading and testing all available extension.  We make that
possible by adding support for the `*` wildcard.
@cmb69 cmb69 force-pushed the cmb/extensions-wildcard branch from 646b851 to becf31f Compare October 6, 2024 13:54
@cmb69
Copy link
Member Author

cmb69 commented Oct 6, 2024

It works – Windows segfaults as expected. Now on to PR #10278.

Copy link
Member Author

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

I'm going to open for review. The failing Windows tests are to be expected and should be fixed via PR #10278.

run-tests.php Outdated
@@ -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.

@cmb69 cmb69 marked this pull request as ready for review October 6, 2024 23:29
@iluuu1994
Copy link
Member

Do we need this for Zend/tests/new_oom.phpt?

@cmb69
Copy link
Member Author

cmb69 commented Oct 7, 2024

Do we need this for Zend/tests/new_oom.phpt?

Would probably make sense.

@cmb69
Copy link
Member Author

cmb69 commented Oct 8, 2024

Okay, apparently all extensions are loaded now on all platforms; however, I'm not sure what would happen if a zend_extension would be loaded (probably a bad idea). Need to think about that; converting to draft for the time being.

@cmb69 cmb69 marked this pull request as draft October 8, 2024 09:30
@DanielEScherzer
Copy link
Member

Just going to cross-link #16317 as another case where a test for all extensions would be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants