# run-tests.php and dynamic extension dependencies

- Thread: https://externals.io/message/56643
- Original archive: https://news-web.php.net/php.internals/56643
- Started by Derick Rethans on 2011-11-28T13:11:37+00:00
- Messages: 13
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #56643 — Derick Rethans — 2011-11-28T13:11:37+00:00

URL: https://externals.io/message/56643#56643

Hi,

I'm currently writing a shared extension thta depends on another shared 
extension (igbinary). "make test" doesn't handle this at the moment, 
because it removes every extension= line from it's temporary php.ini.
This means that the dependent extension (igbinary) now isn't loaded, 
which means my extension doesn't load either and obviously all the tests 
fail.

I've attached a patch that adds a new --EXTENSIONS-- section to the PHPT 
format. The run-tests.php script makes sure that all extensions in that 
last are added to the PHP command with -dextension=... , but only if 
they're not build in (or already loaded in some other way).

The patch is simple, and it doesn't touch any other section or 
functionality so I'm suggesting to commit it to PHP 5.3/5.4 and trunk 
some time soon.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

---

## #56644 — Ferenc Kovacs — 2011-11-28T13:28:33+00:00

URL: https://externals.io/message/56643#56644 · In reply to: #56643

> Hi,
>
> I'm currently writing a shared extension thta depends on another shared
> extension (igbinary). "make test" doesn't handle this at the moment,
> because it removes every extension= line from it's temporary php.ini.
> This means that the dependent extension (igbinary) now isn't loaded,
> which means my extension doesn't load either and obviously all the tests
> fail.
>
> I've attached a patch that adds a new --EXTENSIONS-- section to the PHPT
> format. The run-tests.php script makes sure that all extensions in that
> last are added to the PHP command with -dextension=... , but only if
> they're not build in (or already loaded in some other way).
>
> The patch is simple, and it doesn't touch any other section or
> functionality so I'm suggesting to commit it to PHP 5.3/5.4 and trunk
> some time soon.
>

wouldn't  --INI-- + extension do the same?

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #56645 — Derick Rethans — 2011-11-28T13:36:26+00:00

URL: https://externals.io/message/56643#56645 · In reply to: #56644

> 
> 
> > […]
> 
> wouldn't  --INI-- + extension do the same?

No, as the run-tests.php framework changes "extension_dir" to 
"./modules/". It would also cause issues if you try to load an extension 
that is built-in. And it's not portable because not on every platform 
the extension name = extension.so

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

---

## #56646 — Richard Quadling — 2011-11-28T13:41:15+00:00

URL: https://externals.io/message/56643#56646 · In reply to: #56645

> 
>
> > […]
>
> No, as the run-tests.php framework changes "extension_dir" to
> "./modules/". It would also cause issues if you try to load an extension
> that is built-in. And it's not portable because not on every platform
> the extension name = extension.so

Can you use PHP_SHLIB_SUFFIX?




-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

---

## #56647 — Derick Rethans — 2011-11-28T13:44:36+00:00

URL: https://externals.io/message/56643#56647 · In reply to: #56646

> 
> > […]
> 
> Can you use PHP_SHLIB_SUFFIX?

I am using that in my patch, but obviously that doesn't work with 
extension= on the command line, which is how run-tests.php passes in 
arguments from --INI--.

derick@whisky:~$ php -dextension=igbinary.PHP_SHLIB_SUFFIX
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php/5.3dev/lib/php/extensions/debug-non-zts-20090626/igbinary.PHP_SHLIB_SUFFIX' - /usr/local/php/5.3dev/lib/php/extensions/debug-non-zts-20090626/igbinary.PHP_SHLIB_SUFFIX: cannot open shared object file: No such file or directory in Unknown on line 0

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

---

## #56648 — Pierre Joye — 2011-11-28T14:05:42+00:00

URL: https://externals.io/message/56643#56648 · In reply to: #56643

hi Derick,



> I'm currently writing a shared extension thta depends on another shared
> extension (igbinary). "make test" doesn't handle this at the moment,
> because it removes every extension= line from it's temporary php.ini.
> This means that the dependent extension (igbinary) now isn't loaded,
> which means my extension doesn't load either and obviously all the tests
> fail.

It could be handy yes, the idea until now was to create a custom
php.ini to load (non core) extensions.

> I've attached a patch that adds a new --EXTENSIONS-- section to the PHPT
> format. The run-tests.php script makes sure that all extensions in that
> last are added to the PHP command with -dextension=... , but only if
> they're not build in (or already loaded in some other way).
>
> The patch is simple, and it doesn't touch any other section or
> functionality so I'm suggesting to commit it to PHP 5.3/5.4 and trunk
> some time soon.

Patch looks fine, I've to test on win tho'. I would suggest to call
once php -m instead of the foreach and check the result/

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

---

## #56649 — Ferenc Kovacs — 2011-11-28T14:18:40+00:00

URL: https://externals.io/message/56643#56649 · In reply to: #56647

> 
>
> > […]
> wrote:
> > […]
> extension
> > […]
>
> I am using that in my patch, but obviously that doesn't work with
> extension= on the command line, which is how run-tests.php passes in
> arguments from --INI--.
>
> derick@whisky:~$ php -dextension=igbinary.PHP_SHLIB_SUFFIX
> PHP Warning:  PHP Startup: Unable to load dynamic library
> '/usr/local/php/5.3dev/lib/php/extensions/debug-non-zts-20090626/igbinary.PHP_SHLIB_SUFFIX'
> -
> /usr/local/php/5.3dev/lib/php/extensions/debug-non-zts-20090626/igbinary.PHP_SHLIB_SUFFIX:
> cannot open shared object file: No such file or directory in Unknown on
> line 0


thanks for the answer, in this case I think this would be a worthwhile
improvement.

+ foreach ($extensions as $req_ext) {
+ $loaded = `$php -n -r 'echo (int) extension_loaded("$req_ext");'`;
+ if ($loaded == '0') {

it would be more efficient to get all the loaded modules at
once(get_loaded_extensions or php -m)

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #56650 — johannes@schlueters.de — 2011-11-28T14:58:27+00:00

URL: https://externals.io/message/56643#56650 · In reply to: #56649

> + foreach ($extensions as $req_ext) {
> + $loaded = `$php -n -r 'echo (int) extension_loaded("$req_ext");'`;
> + if ($loaded == '0') { 

This should use the tmp-php.ini as that might already load the required
extension if it was built in the same built. A configure line like

    ./configure --enable-igbinary=shared --enable-new-fancy-extension=shared

should add both to the tmp-php.ini.


I'm also not sure if we really want to cover all these cases in extra
sections, the user can do

    run-tests.php -d extension=/path/to/extname.so

this would also work for extensions outside the default extension_dir
and one could test against different versions of the other extension,
while I agree it's more annoying ... for the individual case.

johannes

---

## #56651 — Derick Rethans — 2011-11-28T15:02:46+00:00

URL: https://externals.io/message/56643#56651 · In reply to: #56650

> 
> > […]
> 
> This should use the tmp-php.ini as that might already load the required
> extension if it was built in the same built. A configure line like

the tmp-php.ini has no extension= lines in it, they're stripped out.

> 
>     ./configure --enable-igbinary=shared --enable-new-fancy-extension=shared
> 
> should add both to the tmp-php.ini.

But that is not doing anything from the phpized directory... where you'd 
just run ./configure.

Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

---

## #56652 — Ferenc Kovacs — 2011-11-28T15:04:52+00:00

URL: https://externals.io/message/56643#56652 · In reply to: #56650

2011/11/28 Johannes Schlüter <johannes@schlueters.de>

> 
> > […]
>
> This should use the tmp-php.ini as that might already load the required
> extension if it was built in the same built. A configure line like
>
>    ./configure --enable-igbinary=shared --enable-new-fancy-extension=shared
>
> should add both to the tmp-php.ini.
>

uhm, based on the code:
http://svn.php.net/viewvc/php/php-src/trunk/Makefile.global?view=markup#l99
http://svn.php.net/viewvc/php/php-src/trunk/Makefile.global?view=markup#l86
the extension lines will be stripped/omitted from the tmp-php.ini



>
> I'm also not sure if we really want to cover all these cases in extra
> sections, the user can do
>
>    run-tests.php -d extension=/path/to/extname.so
>

yeah, but we advertise make test as the official/endorsed way to run the
test suite, so that should work.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #56653 — Pierre Joye — 2011-11-28T15:09:06+00:00

URL: https://externals.io/message/56643#56653 · In reply to: #56652

2011/11/28 Ferenc Kovacs <tyra3l@gmail.com>:

> > […]
>
> yeah, but we advertise make test as the official/endorsed way to run the
> test suite, so that should work.

any reliable tests cannot be done using make test as long as there
some random php.ini's in the system, or other install. We have been
there already and the whole idea of testing random configuration to
provide reliable results has failed, too many false positive. I've
been using run-tests.php only for a while now and I feel much more
comfortable with the results.

---

## #56654 — johannes@schlueters.de — 2011-11-28T15:25:34+00:00

URL: https://externals.io/message/56643#56654 · In reply to: #56651

> 
> 
> > […]
> 
> the tmp-php.ini has no extension= lines in it, they're stripped out.

Ah indeed, it adds -d extension=... directives, I thought they would be
added on to the ini file. My mistake.

> > […]
> 
> But that is not doing anything from the phpized directory... where you'd 
> just run ./configure.

People might, for whatever reason, built the extension as part of the
PHP build. For instance one might think about using this feature with
PDO drivers. And build PDO shared (not saying that makes sense, but it
is a supported thing)

johannes

---

## #56655 — Derick Rethans — 2011-11-28T15:48:34+00:00

URL: https://externals.io/message/56643#56655 · In reply to: #56649

> thanks for the answer, in this case I think this would be a worthwhile
> improvement.
> 
> + foreach ($extensions as $req_ext) {
> + $loaded = `$php -n -r 'echo (int) extension_loaded("$req_ext");'`;
> + if ($loaded == '0') {
> 
> it would be more efficient to get all the loaded modules at
> once(get_loaded_extensions or php -m)

Yup, good catch. Patch attached again.

Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
