2 Launch the appliance and run basic tests.
6 // See comment in php/run-php-tests.sh.
7 //putenv ('LIBGUESTFS_DEBUG=1');
9 $g = guestfs_create ();
11 echo ("Failed to create guestfs_php handle.\n");
15 $tmp = dirname(__FILE__)."/test.img";
16 $size = 100 * 1024 * 1024;
17 if (! $fp = fopen ($tmp, 'w+')) {
18 die ("Error: cannot create file '".$tmp."'\n");
20 ftruncate ($fp, $size);
23 if (! guestfs_add_drive ($g, $tmp) ||
24 ! guestfs_launch ($g) ||
25 ! guestfs_part_disk ($g, "/dev/sda", "mbr") ||
26 ! guestfs_pvcreate ($g, "/dev/sda1") ||
27 ! guestfs_vgcreate ($g, "VG", array ("/dev/sda1")) ||
28 ! guestfs_lvcreate ($g, "LV", "VG", 64) ||
29 ! guestfs_mkfs ($g, "ext2", "/dev/VG/LV")) {
30 die ("Error: ".guestfs_last_error ($g)."\n");
33 $version = guestfs_version ($g);
34 if ($version == false) {
35 echo ("Error: ".guestfs_last_error ($g)."\n");
38 if (!is_int ($version["major"]) ||
39 !is_int ($version["minor"]) ||
40 !is_int ($version["release"]) ||
41 !is_string ($version["extra"])) {
42 echo ("Error: incorrect return type from guestfs_version\n");