--TEST--
-Launch the appliance.
+Launch the appliance and run basic tests.
--FILE--
<?php
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");
!is_string ($version["extra"])) {
echo ("Error: incorrect return type from guestfs_version\n");
}
+
+unlink ($tmp);
+
echo ("OK\n");
?>
--EXPECT--
--TEST--
-Create a disk containing LV and filesystem.
+Check function with optional arguments.
--FILE--
<?php
$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.
+++ /dev/null
---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.