Files
libguestfs/php/extension/tests/guestfs_100_launch.phpt
Pino Toscano 7a598a0c02 php: restructure and expand tests
Rename the existing tests according to the naming/numbering described in
guestfs-hacking(1), and improve the current ones:
- guestfs_php_001.phpt: rename to guestfs_020_create.phpt
- guestfs_php_003.phpt: rename to guestfs_070_optargs.phpt
- guestfs_php_bindtests.phpt: rename to guestfs_090_bindtests.phpt
- guestfs_090_version.phpt: new, checks taken from the former
  guestfs_php_002.phpt
- guestfs_100_launch.phpt: new, modelled after the equivalent in e.g.
  OCaml/Perl/Python
- guestfs_php_002.phpt: remove, as what it did is now covered by
  090_version and 100_launch
2016-02-12 15:10:07 +01:00

83 lines
1.4 KiB
PHP

--TEST--
Launch, create partitions and LVs and filesystems.
--FILE--
<?php
$g = guestfs_create ();
guestfs_add_drive_scratch ($g, 500 * 1024 * 1024);
guestfs_launch ($g);
guestfs_pvcreate ($g, "/dev/sda");
guestfs_vgcreate ($g, "VG", array ("/dev/sda"));
guestfs_lvcreate ($g, "LV1", "VG", 200);
guestfs_lvcreate ($g, "LV2", "VG", 200);
$lvs = guestfs_lvs ($g);
var_dump ($lvs);
guestfs_mkfs ($g, "ext2", "/dev/VG/LV1");
guestfs_mount ($g, "/dev/VG/LV1", "/");
guestfs_mkdir ($g, "/p");
guestfs_touch ($g, "/q");
function dir_cmp ($a, $b)
{
return strcmp ($a["name"], $b["name"]);
}
function dir_extract ($n)
{
return array ("name" => $n["name"], "ftyp" => $n["ftyp"]);
}
$dirs = guestfs_readdir ($g, "/");
usort ($dirs, "dir_cmp");
$dirs = array_map ("dir_extract", $dirs);
var_dump ($dirs);
guestfs_shutdown ($g);
echo ("OK\n");
?>
--EXPECT--
array(2) {
[0]=>
string(11) "/dev/VG/LV1"
[1]=>
string(11) "/dev/VG/LV2"
}
array(5) {
[0]=>
array(2) {
["name"]=>
string(1) "."
["ftyp"]=>
string(1) "d"
}
[1]=>
array(2) {
["name"]=>
string(2) ".."
["ftyp"]=>
string(1) "d"
}
[2]=>
array(2) {
["name"]=>
string(10) "lost+found"
["ftyp"]=>
string(1) "d"
}
[3]=>
array(2) {
["name"]=>
string(1) "p"
["ftyp"]=>
string(1) "d"
}
[4]=>
array(2) {
["name"]=>
string(1) "q"
["ftyp"]=>
string(1) "r"
}
}
OK