unit tests for PECL extensions and how to make them work
Recently I’ve been installing a few PECL extensions, I dev on Snow Leopard which is PHP 5.3 but my colod server is Ubuntu 8.04 LTS which is PHP 5.2, so being me I ignored the various warnings on the sqlite3 page of php.net ( Note: This extension was briefly a PECL extension but that version is only recommended for experimental use. ).
I managed to get the extension installed fine ( phpize, ./configure, sudo make, sudo make install )
wget http://pecl.php.net/get/sqlite3-0.6.tgz
tar xvzf sqlite3-0.6.tgz
cd sqlite3-0.6/
phpize
./configure
sudo make
sudo make install
Now the last line for make install asks you kindly to “Don’t forget to run ‘make test’.”
So let’s do that
Lots of output
make test
gabriel@daughterofseabiscuit:~/sqlite3-0.6$ make test
Build complete.
Don't forget to run 'make test'.
Warning: PHP Startup: Unable to load dynamic library 'modules/runkit.so' - modules/runkit.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/mcrypt.so' - modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/ffmpeg.so' - modules/ffmpeg.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/mysql.so' - modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/mysqli.so' - modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_sqlite.so' - modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/snmp.so' - modules/snmp.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/sqlite.so' - modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/tidy.so' - modules/tidy.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: Module 'sqlite3' already loaded in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/runkit.so' - modules/runkit.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/mcrypt.so' - modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/ffmpeg.so' - modules/ffmpeg.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/mysql.so' - modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/mysqli.so' - modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_sqlite.so' - modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/snmp.so' - modules/snmp.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/sqlite.so' - modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'modules/tidy.so' - modules/tidy.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: Module 'sqlite3' already loaded in Unknown on line 0
=====================================================================
CWD : /home/gabriel/sqlite3-0.6
PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.2.4-2ubuntu5.9
ZEND_VERSION: 2.2.0
PHP_OS : Linux - Linux daughterofseabiscuit.angelhosts.org 2.6.24-25-server #1 SMP Tue Oct 20 08:12:40 UTC 2009 i686
INI actual : /etc/php5/cli/php.ini
More .INIs : /etc/php5/cli/conf.d/ffmpeg.ini,/etc/php5/cli/conf.d/gd.ini,/etc/php5/cli/conf.d/mysql.ini,/etc/php5/cli/conf.d/mysqli.ini,/etc/php5/cli/conf.d/pdo.ini,/etc/php5/cli/conf.d/pdo_mysql.ini,/etc/php5/cli/conf.d/pdo_sqlite.ini,/etc/php5/cli/conf.d/snmp.ini,/etc/php5/cli/conf.d/sqlite.ini,/etc/php5/cli/conf.d/sqlite3.ini,/etc/php5/cli/conf.d/tidy.ini
Extra dirs :
=====================================================================
Running selected tests.
FAIL SQLite3::open/close tests [tests/sqlite3_01_open.phpt]
FAIL SQLite3::query CREATE tests [tests/sqlite3_02_create.phpt]
FAIL SQLite3::query INSERT tests [tests/sqlite3_03_insert.phpt]
FAIL SQLite3::query UPDATE tests [tests/sqlite3_04_update.phpt]
FAIL SQLite3::query DELETE tests [tests/sqlite3_05_delete.phpt]
FAIL SQLite3::prepare Bound Variable test [tests/sqlite3_06_prepared_stmt.phpt]
FAIL SQLite3::prepare Bound Value test [tests/sqlite3_07_prepared_stmt.phpt]
FAIL SQLite3::createFunction [tests/sqlite3_08_udf.phpt]
FAIL SQLite3::prepare Bound Variable Blob test [tests/sqlite3_09_blob_bound_param.phpt]
FAIL SQLite3::prepare Bound Value test [tests/sqlite3_10_bound_value_name.phpt]
SKIP SQLite3::prepare number of rows [tests/sqlite3_11_numrows.phpt]
FAIL SQLite3::query Unfinalized statement tests [tests/sqlite3_12_unfinalized_stmt_cleanup.phpt]
FAIL SQLite3::query Skip all cleanup [tests/sqlite3_13_skip_all_cleanup.phpt]
FAIL SQLite3::querySingle tests [tests/sqlite3_14_querysingle.phpt]
=====================================================================
Number of tests : 14 13
Tests skipped : 1 ( 7.1%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 13 ( 92.9%) (100.0%)
Tests passed : 0 ( 0.0%) ( 0.0%)
---------------------------------------------------------------------
Time taken : 2 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
SQLite3::open/close tests [tests/sqlite3_01_open.phpt]
SQLite3::query CREATE tests [tests/sqlite3_02_create.phpt]
SQLite3::query INSERT tests [tests/sqlite3_03_insert.phpt]
SQLite3::query UPDATE tests [tests/sqlite3_04_update.phpt]
SQLite3::query DELETE tests [tests/sqlite3_05_delete.phpt]
SQLite3::prepare Bound Variable test [tests/sqlite3_06_prepared_stmt.phpt]
SQLite3::prepare Bound Value test [tests/sqlite3_07_prepared_stmt.phpt]
SQLite3::createFunction [tests/sqlite3_08_udf.phpt]
SQLite3::prepare Bound Variable Blob test [tests/sqlite3_09_blob_bound_param.phpt]
SQLite3::prepare Bound Value test [tests/sqlite3_10_bound_value_name.phpt]
SQLite3::query Unfinalized statement tests [tests/sqlite3_12_unfinalized_stmt_cleanup.phpt]
SQLite3::query Skip all cleanup [tests/sqlite3_13_skip_all_cleanup.phpt]
SQLite3::querySingle tests [tests/sqlite3_14_querysingle.phpt]
=====================================================================
Variations on that line appear about 20 times, it seems to be looking in a directory relative to the sqlite3-0.6 directory for the modules
The lovely Cyberspice has made an entry about this already
building php c extensions on ubuntu 9.10
unfortunately I didn’t see this until after I went my own, different route.
Thanks to Derick in #php.pecl on efnet I came up with this bit of code
TEST_PHP_EXECUTABLE=`which php` php /home/gabriel/sqlite3-0.6/run-tests.php /home/gabriel/sqlite3-0.6/tests/*.phpt
which then outputs
Lots of output
gabriel@daughterofseabiscuit:~/sqlite3-0.6$ TEST_PHP_EXECUTABLE=`which php` php /home/gabriel/sqlite3-0.6/run-tests.php /home/gabriel/sqlite3-0.6/tests/*.phpt
=====================================================================
CWD : /home/gabriel/sqlite3-0.6
PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.2.4-2ubuntu5.9
ZEND_VERSION: 2.2.0
PHP_OS : Linux - Linux daughterofseabiscuit.angelhosts.org 2.6.24-25-server #1 SMP Tue Oct 20 08:12:40 UTC 2009 i686
INI actual : /etc/php5/cli/php.ini
More .INIs : /etc/php5/cli/conf.d/ffmpeg.ini,/etc/php5/cli/conf.d/gd.ini,/etc/php5/cli/conf.d/mysql.ini,/etc/php5/cli/conf.d/mysqli.ini,/etc/php5/cli/conf.d/pdo.ini,/etc/php5/cli/conf.d/pdo_mysql.ini,/etc/php5/cli/conf.d/pdo_sqlite.ini,/etc/php5/cli/conf.d/snmp.ini,/etc/php5/cli/conf.d/sqlite.ini,/etc/php5/cli/conf.d/sqlite3.ini,/etc/php5/cli/conf.d/tidy.ini
Extra dirs :
=====================================================================
Running selected tests.
PASS SQLite3::open/close tests [tests/sqlite3_01_open.phpt]
PASS SQLite3::query CREATE tests [tests/sqlite3_02_create.phpt]
PASS SQLite3::query INSERT tests [tests/sqlite3_03_insert.phpt]
PASS SQLite3::query UPDATE tests [tests/sqlite3_04_update.phpt]
PASS SQLite3::query DELETE tests [tests/sqlite3_05_delete.phpt]
PASS SQLite3::prepare Bound Variable test [tests/sqlite3_06_prepared_stmt.phpt]
PASS SQLite3::prepare Bound Value test [tests/sqlite3_07_prepared_stmt.phpt]
PASS SQLite3::createFunction [tests/sqlite3_08_udf.phpt]
PASS SQLite3::prepare Bound Variable Blob test [tests/sqlite3_09_blob_bound_param.phpt]
PASS SQLite3::prepare Bound Value test [tests/sqlite3_10_bound_value_name.phpt]
SKIP SQLite3::prepare number of rows [tests/sqlite3_11_numrows.phpt]
PASS SQLite3::query Unfinalized statement tests [tests/sqlite3_12_unfinalized_stmt_cleanup.phpt]
PASS SQLite3::query Skip all cleanup [tests/sqlite3_13_skip_all_cleanup.phpt]
PASS SQLite3::querySingle tests [tests/sqlite3_14_querysingle.phpt]
=====================================================================
Number of tests : 14 13
Tests skipped : 1 ( 7.1%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Tests passed : 13 ( 92.9%) (100.0%)
---------------------------------------------------------------------
Time taken : 4 seconds
=====================================================================
gabriel@daughterofseabiscuit:~/sqlite3-0.6$
So I’d chalk that up as a win, there might be things that get missed running it like this, but I’m not sure.
You can either just run that line of code in the shell or have it in a bash script and then build the bash script to accept parameters so it becomes a lot more customisable.