summaryrefslogtreecommitdiffstats
path: root/php/extension/guestfs_php_003.phpt
blob: c4eb5b0a337ba47c9002d2dddddffc76363b05aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--TEST--
Create a disk containing LV and filesystem.
--FILE--
<?php

// See comment in php/run-php-tests.sh.
//putenv ('LIBGUESTFS_DEBUG=1');

$g = guestfs_create ();
if ($g == false) {
  die ("Failed to create guestfs_php handle.\n");
}

$tmp = dirname(__FILE__)."/test.img";
$size = 100 * 1024 * 1024;
if (! $fp = fopen ($tmp, 'r+')) {
  die ("Error: cannot create file '".$tmp."'\n");
}
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");
}
echo ("OK\n");
?>
--CLEAN--
<?php
$tmp = dirname(__FILE__)."/test.img";
unlink ($tmp);
?>
--EXPECT--
OK