Pino Toscano
2014-Mar-18 14:15 UTC
[Libguestfs] [PATCH 1/2] php: make the test suite failures fatal
So far the failure of some test would have not reported a non-zero return value by run-tests.php. Since now all the PHP tests pass, we can ask for failures to be fatal, by exporting REPORT_EXIT_STATUS=1 for run-tests.php. --- php/run-php-tests.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/php/run-php-tests.sh b/php/run-php-tests.sh index 6f9ae10..e498987 100755 --- a/php/run-php-tests.sh +++ b/php/run-php-tests.sh @@ -44,5 +44,4 @@ printenv | grep -E '^(LIBGUESTFS|LIBVIRT|LIBVIRTD|VIRTLOCKD|LD|MALLOC)_' >> env TESTS=$(echo guestfs_php_*.phpt) echo TESTS: $TESTS -# PHP ignores the result of the tests! -make test TESTS="$TESTS" PHP_EXECUTABLE="$PWD/php-for-tests.sh" +make test TESTS="$TESTS" PHP_EXECUTABLE="$PWD/php-for-tests.sh" REPORT_EXIT_STATUS=1 -- 1.8.3.1
Pino Toscano
2014-Mar-18 14:15 UTC
[Libguestfs] [PATCH 2/2] php: move tests under a tests subdirectory
This eases fixes the classname in the junit output of run-tests.php, which now can be properly handled by junit XML consumers. --- php/extension/guestfs_php_001.phpt | 13 ------------ php/extension/guestfs_php_002.phpt | 36 -------------------------------- php/extension/guestfs_php_003.phpt | 29 ------------------------- php/extension/tests/guestfs_php_001.phpt | 13 ++++++++++++ php/extension/tests/guestfs_php_002.phpt | 36 ++++++++++++++++++++++++++++++++ php/extension/tests/guestfs_php_003.phpt | 29 +++++++++++++++++++++++++ php/run-php-tests.sh | 2 +- 7 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 php/extension/guestfs_php_001.phpt delete mode 100644 php/extension/guestfs_php_002.phpt delete mode 100644 php/extension/guestfs_php_003.phpt create mode 100644 php/extension/tests/guestfs_php_001.phpt create mode 100644 php/extension/tests/guestfs_php_002.phpt create mode 100644 php/extension/tests/guestfs_php_003.phpt diff --git a/php/extension/guestfs_php_001.phpt b/php/extension/guestfs_php_001.phpt deleted file mode 100644 index 013ebb5..0000000 --- a/php/extension/guestfs_php_001.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Load the module and create a handle. ---FILE-- -<?php -$g = guestfs_create (); -if ($g == false) { - echo ("Failed to create guestfs_php handle.\n"); - exit; -} -echo ("Created guestfs_php handle.\n"); -?> ---EXPECT-- -Created guestfs_php handle. diff --git a/php/extension/guestfs_php_002.phpt b/php/extension/guestfs_php_002.phpt deleted file mode 100644 index 91b2067..0000000 --- a/php/extension/guestfs_php_002.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Launch the appliance and run basic tests. ---FILE-- -<?php -$g = guestfs_create (); -if ($g == false) { - echo ("Failed to create guestfs_php handle.\n"); - exit; -} - -if (! guestfs_add_drive_scratch ($g, 100 * 1024 * 1024) || - ! guestfs_launch ($g) || - ! guestfs_part_disk ($g, "/dev/sda", "mbr") || - ! guestfs_pvcreate ($g, "/dev/sda1") || - ! guestfs_vgcreate ($g, "VG", array ("/dev/sda1")) || - ! guestfs_lvcreate ($g, "LV", "VG", 64) || - ! guestfs_mkfs ($g, "ext2", "/dev/VG/LV")) { - die ("Error: ".guestfs_last_error ($g)."\n"); -} - -$version = guestfs_version ($g); -if ($version == false) { - echo ("Error: ".guestfs_last_error ($g)."\n"); - exit; -} -if (!is_int ($version["major"]) || - !is_int ($version["minor"]) || - !is_int ($version["release"]) || - !is_string ($version["extra"])) { - echo ("Error: incorrect return type from guestfs_version\n"); -} - -echo ("OK\n"); -?> ---EXPECT-- -OK diff --git a/php/extension/guestfs_php_003.phpt b/php/extension/guestfs_php_003.phpt deleted file mode 100644 index e268e98..0000000 --- a/php/extension/guestfs_php_003.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Check function with optional arguments. ---FILE-- -<?php -$g = guestfs_create (); -if ($g == false) { - echo ("Failed to create guestfs_php handle.\n"); - exit; -} -if (guestfs_add_drive ($g, "/dev/null") == false) { - echo ("Failed add_drive, no optional arguments: " . guestfs_last_error ($g) . "\n"); - exit; -} -if (guestfs_add_drive ($g, "/dev/null", 0) == false) { - echo ("Failed add_drive, one optional argument: " . guestfs_last_error ($g) . "\n"); - exit; -} -if (guestfs_add_drive ($g, "/dev/null", 1) == false) { - echo ("Failed add_drive, one optional argument: " . guestfs_last_error ($g) . "\n"); - exit; -} -if (guestfs_add_drive ($g, "/dev/null", 1, "raw") == false) { - echo ("Failed add_drive, two optional arguments: " . guestfs_last_error ($g) . "\n"); - exit; -} -echo ("Completed tests OK.\n"); -?> ---EXPECT-- -Completed tests OK. diff --git a/php/extension/tests/guestfs_php_001.phpt b/php/extension/tests/guestfs_php_001.phpt new file mode 100644 index 0000000..013ebb5 --- /dev/null +++ b/php/extension/tests/guestfs_php_001.phpt @@ -0,0 +1,13 @@ +--TEST-- +Load the module and create a handle. +--FILE-- +<?php +$g = guestfs_create (); +if ($g == false) { + echo ("Failed to create guestfs_php handle.\n"); + exit; +} +echo ("Created guestfs_php handle.\n"); +?> +--EXPECT-- +Created guestfs_php handle. diff --git a/php/extension/tests/guestfs_php_002.phpt b/php/extension/tests/guestfs_php_002.phpt new file mode 100644 index 0000000..91b2067 --- /dev/null +++ b/php/extension/tests/guestfs_php_002.phpt @@ -0,0 +1,36 @@ +--TEST-- +Launch the appliance and run basic tests. +--FILE-- +<?php +$g = guestfs_create (); +if ($g == false) { + echo ("Failed to create guestfs_php handle.\n"); + exit; +} + +if (! guestfs_add_drive_scratch ($g, 100 * 1024 * 1024) || + ! guestfs_launch ($g) || + ! guestfs_part_disk ($g, "/dev/sda", "mbr") || + ! guestfs_pvcreate ($g, "/dev/sda1") || + ! guestfs_vgcreate ($g, "VG", array ("/dev/sda1")) || + ! guestfs_lvcreate ($g, "LV", "VG", 64) || + ! guestfs_mkfs ($g, "ext2", "/dev/VG/LV")) { + die ("Error: ".guestfs_last_error ($g)."\n"); +} + +$version = guestfs_version ($g); +if ($version == false) { + echo ("Error: ".guestfs_last_error ($g)."\n"); + exit; +} +if (!is_int ($version["major"]) || + !is_int ($version["minor"]) || + !is_int ($version["release"]) || + !is_string ($version["extra"])) { + echo ("Error: incorrect return type from guestfs_version\n"); +} + +echo ("OK\n"); +?> +--EXPECT-- +OK diff --git a/php/extension/tests/guestfs_php_003.phpt b/php/extension/tests/guestfs_php_003.phpt new file mode 100644 index 0000000..e268e98 --- /dev/null +++ b/php/extension/tests/guestfs_php_003.phpt @@ -0,0 +1,29 @@ +--TEST-- +Check function with optional arguments. +--FILE-- +<?php +$g = guestfs_create (); +if ($g == false) { + echo ("Failed to create guestfs_php handle.\n"); + exit; +} +if (guestfs_add_drive ($g, "/dev/null") == false) { + echo ("Failed add_drive, no optional arguments: " . guestfs_last_error ($g) . "\n"); + exit; +} +if (guestfs_add_drive ($g, "/dev/null", 0) == false) { + echo ("Failed add_drive, one optional argument: " . guestfs_last_error ($g) . "\n"); + exit; +} +if (guestfs_add_drive ($g, "/dev/null", 1) == false) { + echo ("Failed add_drive, one optional argument: " . guestfs_last_error ($g) . "\n"); + exit; +} +if (guestfs_add_drive ($g, "/dev/null", 1, "raw") == false) { + echo ("Failed add_drive, two optional arguments: " . guestfs_last_error ($g) . "\n"); + exit; +} +echo ("Completed tests OK.\n"); +?> +--EXPECT-- +Completed tests OK. diff --git a/php/run-php-tests.sh b/php/run-php-tests.sh index e498987..53216be 100755 --- a/php/run-php-tests.sh +++ b/php/run-php-tests.sh @@ -41,7 +41,7 @@ rm -f env echo "PATH=$PATH" > env printenv | grep -E '^(LIBGUESTFS|LIBVIRT|LIBVIRTD|VIRTLOCKD|LD|MALLOC)_' >> env -TESTS=$(echo guestfs_php_*.phpt) +TESTS=$(echo tests/guestfs_php_*.phpt) echo TESTS: $TESTS make test TESTS="$TESTS" PHP_EXECUTABLE="$PWD/php-for-tests.sh" REPORT_EXIT_STATUS=1 -- 1.8.3.1
Richard W.M. Jones
2014-Mar-18 14:59 UTC
Re: [Libguestfs] [PATCH 2/2] php: move tests under a tests subdirectory
On Tue, Mar 18, 2014 at 03:15:17PM +0100, Pino Toscano wrote:> This eases fixes the classname in the junit output of run-tests.php, > which now can be properly handled by junit XML consumers.This is fine. ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)