diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2010-11-30 14:17:37 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-11-30 14:18:34 +0000 |
commit | b79e075d637f669ce5e4aa2e9b7f578ac8de0839 (patch) | |
tree | 16b79a1352af3ae6c16397e96dc9625f14cefcfc /php | |
parent | 2860b21ee1b86d6c944308a8be181c91bc07fd03 (diff) | |
download | libguestfs-b79e075d637f669ce5e4aa2e9b7f578ac8de0839.tar.gz libguestfs-b79e075d637f669ce5e4aa2e9b7f578ac8de0839.tar.xz libguestfs-b79e075d637f669ce5e4aa2e9b7f578ac8de0839.zip |
php: Combine tests to reduce number of launches.
Diffstat (limited to 'php')
-rw-r--r-- | php/extension/guestfs_php_002.phpt | 28 | ||||
-rw-r--r-- | php/extension/guestfs_php_003.phpt | 44 | ||||
-rw-r--r-- | php/extension/guestfs_php_004.phpt | 33 |
3 files changed, 40 insertions, 65 deletions
diff --git a/php/extension/guestfs_php_002.phpt b/php/extension/guestfs_php_002.phpt index 48ee0b60..2417a7e0 100644 --- a/php/extension/guestfs_php_002.phpt +++ b/php/extension/guestfs_php_002.phpt @@ -1,5 +1,5 @@ --TEST-- -Launch the appliance. +Launch the appliance and run basic tests. --FILE-- <?php @@ -11,14 +11,25 @@ if ($g == false) { echo ("Failed to create guestfs_php handle.\n"); exit; } -if (guestfs_add_drive ($g, "/dev/null") == false) { - echo ("Error: ".guestfs_last_error ($g)."\n"); - exit; + +$tmp = dirname(__FILE__)."/test.img"; +$size = 100 * 1024 * 1024; +if (! $fp = fopen ($tmp, 'w+')) { + die ("Error: cannot create file '".$tmp."'\n"); } -if (guestfs_launch ($g) == false) { - echo ("Error: ".guestfs_last_error ($g)."\n"); - exit; +ftruncate ($fp, $size); +fclose ($fp); + +if (! guestfs_add_drive ($g, $tmp) || + ! guestfs_launch ($g) || + ! guestfs_part_disk ($g, "/dev/sda", "mbr") || + ! guestfs_pvcreate ($g, "/dev/sda") || + ! guestfs_vgcreate ($g, "VG", array ("/dev/sda")) || + ! 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"); @@ -30,6 +41,9 @@ if (!is_int ($version["major"]) || !is_string ($version["extra"])) { echo ("Error: incorrect return type from guestfs_version\n"); } + +unlink ($tmp); + echo ("OK\n"); ?> --EXPECT-- diff --git a/php/extension/guestfs_php_003.phpt b/php/extension/guestfs_php_003.phpt index c7c155cb..08e53a37 100644 --- a/php/extension/guestfs_php_003.phpt +++ b/php/extension/guestfs_php_003.phpt @@ -1,5 +1,5 @@ --TEST-- -Create a disk containing LV and filesystem. +Check function with optional arguments. --FILE-- <?php @@ -8,32 +8,26 @@ Create a disk containing LV and filesystem. $g = guestfs_create (); if ($g == false) { - die ("Failed to create guestfs_php handle.\n"); + echo ("Failed to create guestfs_php handle.\n"); + exit; } - -$tmp = dirname(__FILE__)."/test.img"; -$size = 100 * 1024 * 1024; -if (! $fp = fopen ($tmp, 'w+')) { - die ("Error: cannot create file '".$tmp."'\n"); +if (guestfs_add_drive_opts ($g, "/dev/null") == false) { + echo ("Failed add_drive_opts, no optional arguments.\n"); + exit; } -ftruncate ($fp, $size); -fclose ($fp); - -if (! guestfs_add_drive ($g, "test.img") || - ! guestfs_launch ($g) || - ! guestfs_part_disk ($g, "/dev/sda", "mbr") || - ! guestfs_pvcreate ($g, "/dev/sda") || - ! guestfs_vgcreate ($g, "VG", array ("/dev/sda")) || - ! guestfs_lvcreate ($g, "LV", "VG", 64) || - ! guestfs_mkfs ($g, "ext2", "/dev/VG/LV")) { - die ("Error: ".guestfs_last_error ($g)."\n"); +if (guestfs_add_drive_opts ($g, "/dev/null", 0) == false) { + echo ("Failed add_drive_opts, one optional argument.\n"); + exit; } -echo ("OK\n"); -?> ---CLEAN-- -<?php -$tmp = dirname(__FILE__)."/test.img"; -unlink ($tmp); +if (guestfs_add_drive_opts ($g, "/dev/null", 1) == false) { + echo ("Failed add_drive_opts, one optional argument.\n"); + exit; +} +if (guestfs_add_drive_opts ($g, "/dev/null", 1, "qcow2") == false) { + echo ("Failed add_drive_opts, two optional arguments.\n"); + exit; +} +echo ("Completed tests OK.\n"); ?> --EXPECT-- -OK +Completed tests OK. diff --git a/php/extension/guestfs_php_004.phpt b/php/extension/guestfs_php_004.phpt deleted file mode 100644 index 08e53a37..00000000 --- a/php/extension/guestfs_php_004.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Check function with optional arguments. ---FILE-- -<?php - -// See comment in php/run-php-tests.sh. -//putenv ('LIBGUESTFS_DEBUG=1'); - -$g = guestfs_create (); -if ($g == false) { - echo ("Failed to create guestfs_php handle.\n"); - exit; -} -if (guestfs_add_drive_opts ($g, "/dev/null") == false) { - echo ("Failed add_drive_opts, no optional arguments.\n"); - exit; -} -if (guestfs_add_drive_opts ($g, "/dev/null", 0) == false) { - echo ("Failed add_drive_opts, one optional argument.\n"); - exit; -} -if (guestfs_add_drive_opts ($g, "/dev/null", 1) == false) { - echo ("Failed add_drive_opts, one optional argument.\n"); - exit; -} -if (guestfs_add_drive_opts ($g, "/dev/null", 1, "qcow2") == false) { - echo ("Failed add_drive_opts, two optional arguments.\n"); - exit; -} -echo ("Completed tests OK.\n"); -?> ---EXPECT-- -Completed tests OK. |