Pino Toscano
2014-Mar-13 09:35 UTC
[Libguestfs] [PATCH 1/3] php: add a custom PHP runner for tests
Since the default PHP test runner ignores a good number of environment variables to potentially tampering the test suite execution, create a custom php-for-tests.sh script which does nothing more than sourcing the custom environment that our run-php-tests.sh outputs and running the actual "php" executable (the one found by configure). This fixes the loading of the guestfs_php.so module in the test suite, as the libguestfs.so.0 library can be found by that module. --- .gitignore | 1 + configure.ac | 2 ++ php/extension/php-for-tests.sh.in | 4 ++++ php/run-php-tests.sh | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 php/extension/php-for-tests.sh.in diff --git a/.gitignore b/.gitignore index 0c61b5b..830a40d 100644 --- a/.gitignore +++ b/.gitignore @@ -360,6 +360,7 @@ Makefile.in /php/extension/mkinstalldirs /php/extension/missing /php/extension/modules/ +/php/extension/php-for-tests.sh /php/extension/php_guestfs_php.h /php/extension/run-tests.php /php/extension/tmp-php.ini diff --git a/configure.ac b/configure.ac index 35460e2..daa5236 100644 --- a/configure.ac +++ b/configure.ac @@ -1595,6 +1595,8 @@ AC_CONFIG_FILES([appliance/libguestfs-make-fixed-appliance], [chmod +x,-w appliance/libguestfs-make-fixed-appliance]) AC_CONFIG_FILES([inspector/test-xmllint.sh], [chmod +x,-w inspector/test-xmllint.sh]) +AC_CONFIG_FILES([php/extension/php-for-tests.sh], + [chmod +x,-w php/extension/php-for-tests.sh]) AC_CONFIG_FILES([pick-guests.pl], [chmod +x,-w pick-guests.pl]) AC_CONFIG_FILES([podwrapper.pl], diff --git a/php/extension/php-for-tests.sh.in b/php/extension/php-for-tests.sh.in new file mode 100755 index 0000000..0639ce3 --- /dev/null +++ b/php/extension/php-for-tests.sh.in @@ -0,0 +1,4 @@ +#!/bin/sh + +. ./env +@PHP@ $@ diff --git a/php/run-php-tests.sh b/php/run-php-tests.sh index 63701e9..6f9ae10 100755 --- a/php/run-php-tests.sh +++ b/php/run-php-tests.sh @@ -45,4 +45,4 @@ TESTS=$(echo guestfs_php_*.phpt) echo TESTS: $TESTS # PHP ignores the result of the tests! -make test TESTS="$TESTS" +make test TESTS="$TESTS" PHP_EXECUTABLE="$PWD/php-for-tests.sh" -- 1.8.3.1
Pino Toscano
2014-Mar-13 09:35 UTC
[Libguestfs] [PATCH 2/3] php: remove the custom "env" loading in tests
Other than being too late for changing environment variables like LD_LIBRARY_PATH, now it is no more needed. --- php/extension/guestfs_php_001.phpt | 14 -------------- php/extension/guestfs_php_002.phpt | 14 -------------- php/extension/guestfs_php_003.phpt | 14 -------------- 3 files changed, 42 deletions(-) diff --git a/php/extension/guestfs_php_001.phpt b/php/extension/guestfs_php_001.phpt index 65723a6..013ebb5 100644 --- a/php/extension/guestfs_php_001.phpt +++ b/php/extension/guestfs_php_001.phpt @@ -2,20 +2,6 @@ Load the module and create a handle. --FILE-- <?php - -// See comment in php/run-php-tests.sh. -//putenv ('LIBGUESTFS_DEBUG=1'); -if (! $fp = fopen ("env", "r")) { - die ("Error: cannot open environment file 'env'\n"); -} -while (($buffer = fgets ($fp)) != false) { - putenv (chop ($buffer, "\n")); -} -if (!feof ($fp)) { - die ("Error: unexpected failure of fgets\n"); -} -fclose ($fp); - $g = guestfs_create (); if ($g == false) { echo ("Failed to create guestfs_php handle.\n"); diff --git a/php/extension/guestfs_php_002.phpt b/php/extension/guestfs_php_002.phpt index e4d3faf..91b2067 100644 --- a/php/extension/guestfs_php_002.phpt +++ b/php/extension/guestfs_php_002.phpt @@ -2,20 +2,6 @@ Launch the appliance and run basic tests. --FILE-- <?php - -// See comment in php/run-php-tests.sh. -//putenv ('LIBGUESTFS_DEBUG=1'); -if (! $fp = fopen ("env", "r")) { - die ("Error: cannot open environment file 'env'\n"); -} -while (($buffer = fgets ($fp)) != false) { - putenv (chop ($buffer, "\n")); -} -if (!feof ($fp)) { - die ("Error: unexpected failure of fgets\n"); -} -fclose ($fp); - $g = guestfs_create (); if ($g == false) { echo ("Failed to create guestfs_php handle.\n"); diff --git a/php/extension/guestfs_php_003.phpt b/php/extension/guestfs_php_003.phpt index 8cb78da..e268e98 100644 --- a/php/extension/guestfs_php_003.phpt +++ b/php/extension/guestfs_php_003.phpt @@ -2,20 +2,6 @@ Check function with optional arguments. --FILE-- <?php - -// See comment in php/run-php-tests.sh. -//putenv ('LIBGUESTFS_DEBUG=1'); -if (! $fp = fopen ("env", "r")) { - die ("Error: cannot open environment file 'env'\n"); -} -while (($buffer = fgets ($fp)) != false) { - putenv (chop ($buffer, "\n")); -} -if (!feof ($fp)) { - die ("Error: unexpected failure of fgets\n"); -} -fclose ($fp); - $g = guestfs_create (); if ($g == false) { echo ("Failed to create guestfs_php handle.\n"); -- 1.8.3.1
Pino Toscano
2014-Mar-13 09:35 UTC
[Libguestfs] [PATCH 3/3] php: fix crash with OStringList optional arguments
Properly initialize the variables for them to NULL, so there is no crash because of trying to use rubbish pointers. Kind of followup of commit 289fd29f0bfbb94566d9780dd8ac3fe15e55541d. --- generator/php.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/php.ml b/generator/php.ml index 580b10f..c7e0a27 100644 --- a/generator/php.ml +++ b/generator/php.ml @@ -224,7 +224,7 @@ PHP_FUNCTION (guestfs_last_error) pr " char *optargs_t_%s = NULL;\n" n; pr " int optargs_t_%s_size = -1;\n" n | OStringList n -> - pr " zval *optargs_t_%s;\n" n + pr " zval *optargs_t_%s = NULL;\n" n ) optargs ); -- 1.8.3.1
Richard W.M. Jones
2014-Mar-13 10:56 UTC
Re: [Libguestfs] [PATCH 1/3] php: add a custom PHP runner for tests
ACK to series. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top