1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 static void print_error (guestfs_h *g, void *data, const char *msg)
37 fprintf (stderr, "%s\n", msg);
40 static void print_strings (char * const * const argv)
44 for (argc = 0; argv[argc] != NULL; ++argc)
45 printf ("\t%s\n", argv[argc]);
48 static void print_table (char * const * const argv)
52 for (i = 0; argv[i] != NULL; i += 2)
53 printf ("%s: %s\n", argv[i], argv[i+1]);
56 static void no_test_warnings (void)
58 fprintf (stderr, "warning: \"launch\" has no tests\n");
59 fprintf (stderr, "warning: \"wait_ready\" has no tests\n");
60 fprintf (stderr, "warning: \"kill_subprocess\" has no tests\n");
61 fprintf (stderr, "warning: \"add_drive\" has no tests\n");
62 fprintf (stderr, "warning: \"add_cdrom\" has no tests\n");
63 fprintf (stderr, "warning: \"config\" has no tests\n");
64 fprintf (stderr, "warning: \"set_path\" has no tests\n");
65 fprintf (stderr, "warning: \"get_path\" has no tests\n");
66 fprintf (stderr, "warning: \"set_autosync\" has no tests\n");
67 fprintf (stderr, "warning: \"get_autosync\" has no tests\n");
68 fprintf (stderr, "warning: \"set_verbose\" has no tests\n");
69 fprintf (stderr, "warning: \"get_verbose\" has no tests\n");
70 fprintf (stderr, "warning: \"ll\" has no tests\n");
71 fprintf (stderr, "warning: \"pvs_full\" has no tests\n");
72 fprintf (stderr, "warning: \"vgs_full\" has no tests\n");
73 fprintf (stderr, "warning: \"lvs_full\" has no tests\n");
74 fprintf (stderr, "warning: \"aug_init\" has no tests\n");
75 fprintf (stderr, "warning: \"aug_close\" has no tests\n");
76 fprintf (stderr, "warning: \"aug_defvar\" has no tests\n");
77 fprintf (stderr, "warning: \"aug_defnode\" has no tests\n");
78 fprintf (stderr, "warning: \"aug_get\" has no tests\n");
79 fprintf (stderr, "warning: \"aug_set\" has no tests\n");
80 fprintf (stderr, "warning: \"aug_insert\" has no tests\n");
81 fprintf (stderr, "warning: \"aug_rm\" has no tests\n");
82 fprintf (stderr, "warning: \"aug_mv\" has no tests\n");
83 fprintf (stderr, "warning: \"aug_match\" has no tests\n");
84 fprintf (stderr, "warning: \"aug_save\" has no tests\n");
85 fprintf (stderr, "warning: \"aug_load\" has no tests\n");
86 fprintf (stderr, "warning: \"aug_ls\" has no tests\n");
87 fprintf (stderr, "warning: \"chmod\" has no tests\n");
88 fprintf (stderr, "warning: \"chown\" has no tests\n");
89 fprintf (stderr, "warning: \"sfdisk\" has no tests\n");
90 fprintf (stderr, "warning: \"lvm_remove_all\" has no tests\n");
91 fprintf (stderr, "warning: \"command\" has no tests\n");
92 fprintf (stderr, "warning: \"command_lines\" has no tests\n");
93 fprintf (stderr, "warning: \"tune2fs_l\" has no tests\n");
96 static int test_mount_0 (void)
98 /* InitEmpty for mount (0) */
102 r = guestfs_umount_all (g);
109 r = guestfs_lvm_remove_all (g);
113 /* TestOutput for mount (0) */
121 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
128 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
135 r = guestfs_mount (g, "/dev/sda1", "/");
142 r = guestfs_write_file (g, "/new", "new file contents", 0);
149 r = guestfs_cat (g, "/new");
152 if (strcmp (r, "new file contents") != 0) {
153 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
161 static int test_sync_0 (void)
163 /* InitEmpty for sync (0) */
167 r = guestfs_umount_all (g);
174 r = guestfs_lvm_remove_all (g);
178 /* TestRun for sync (0) */
182 r = guestfs_sync (g);
189 static int test_touch_0 (void)
191 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
195 r = guestfs_umount_all (g);
202 r = guestfs_lvm_remove_all (g);
213 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
220 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
227 r = guestfs_mount (g, "/dev/sda1", "/");
231 /* TestOutputTrue for touch (0) */
235 r = guestfs_touch (g, "/new");
242 r = guestfs_exists (g, "/new");
246 fprintf (stderr, "test_touch_0: expected true, got false\n");
253 static int test_cat_0 (void)
255 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
259 r = guestfs_umount_all (g);
266 r = guestfs_lvm_remove_all (g);
277 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
284 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
291 r = guestfs_mount (g, "/dev/sda1", "/");
295 /* TestOutput for cat (0) */
299 r = guestfs_write_file (g, "/new", "new file contents", 0);
306 r = guestfs_cat (g, "/new");
309 if (strcmp (r, "new file contents") != 0) {
310 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
318 static int test_ls_0 (void)
320 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
324 r = guestfs_umount_all (g);
331 r = guestfs_lvm_remove_all (g);
342 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
349 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
356 r = guestfs_mount (g, "/dev/sda1", "/");
360 /* TestOutputList for ls (0) */
364 r = guestfs_touch (g, "/new");
371 r = guestfs_touch (g, "/newer");
378 r = guestfs_touch (g, "/newest");
386 r = guestfs_ls (g, "/");
390 fprintf (stderr, "test_ls_0: short list returned from command\n");
394 if (strcmp (r[0], "lost+found") != 0) {
395 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
399 fprintf (stderr, "test_ls_0: short list returned from command\n");
403 if (strcmp (r[1], "new") != 0) {
404 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
408 fprintf (stderr, "test_ls_0: short list returned from command\n");
412 if (strcmp (r[2], "newer") != 0) {
413 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
417 fprintf (stderr, "test_ls_0: short list returned from command\n");
421 if (strcmp (r[3], "newest") != 0) {
422 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
426 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
430 for (i = 0; r[i] != NULL; ++i)
437 static int test_list_devices_0 (void)
439 /* InitEmpty for list_devices (0) */
443 r = guestfs_umount_all (g);
450 r = guestfs_lvm_remove_all (g);
454 /* TestOutputList for list_devices (0) */
459 r = guestfs_list_devices (g);
463 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
467 if (strcmp (r[0], "/dev/sda") != 0) {
468 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
472 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
476 if (strcmp (r[1], "/dev/sdb") != 0) {
477 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
481 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
485 if (strcmp (r[2], "/dev/sdc") != 0) {
486 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
490 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
494 for (i = 0; r[i] != NULL; ++i)
501 static int test_list_partitions_0 (void)
503 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
507 r = guestfs_umount_all (g);
514 r = guestfs_lvm_remove_all (g);
525 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
532 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
539 r = guestfs_mount (g, "/dev/sda1", "/");
543 /* TestOutputList for list_partitions (0) */
548 r = guestfs_list_partitions (g);
552 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
556 if (strcmp (r[0], "/dev/sda1") != 0) {
557 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
561 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
565 for (i = 0; r[i] != NULL; ++i)
572 static int test_list_partitions_1 (void)
574 /* InitEmpty for list_partitions (1) */
578 r = guestfs_umount_all (g);
585 r = guestfs_lvm_remove_all (g);
589 /* TestOutputList for list_partitions (1) */
599 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
607 r = guestfs_list_partitions (g);
611 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
615 if (strcmp (r[0], "/dev/sda1") != 0) {
616 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
620 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
624 if (strcmp (r[1], "/dev/sda2") != 0) {
625 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
629 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
633 if (strcmp (r[2], "/dev/sda3") != 0) {
634 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
638 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
642 for (i = 0; r[i] != NULL; ++i)
649 static int test_pvs_0 (void)
651 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
655 r = guestfs_umount_all (g);
662 r = guestfs_lvm_remove_all (g);
673 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
680 r = guestfs_pvcreate (g, "/dev/sda1");
691 r = guestfs_vgcreate (g, "VG", physvols);
698 r = guestfs_lvcreate (g, "LV", "VG", 8);
705 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
712 r = guestfs_mount (g, "/dev/VG/LV", "/");
716 /* TestOutputList for pvs (0) */
725 fprintf (stderr, "test_pvs_0: short list returned from command\n");
729 if (strcmp (r[0], "/dev/sda1") != 0) {
730 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
734 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
738 for (i = 0; r[i] != NULL; ++i)
745 static int test_pvs_1 (void)
747 /* InitEmpty for pvs (1) */
751 r = guestfs_umount_all (g);
758 r = guestfs_lvm_remove_all (g);
762 /* TestOutputList for pvs (1) */
772 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
779 r = guestfs_pvcreate (g, "/dev/sda1");
786 r = guestfs_pvcreate (g, "/dev/sda2");
793 r = guestfs_pvcreate (g, "/dev/sda3");
805 fprintf (stderr, "test_pvs_1: short list returned from command\n");
809 if (strcmp (r[0], "/dev/sda1") != 0) {
810 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
814 fprintf (stderr, "test_pvs_1: short list returned from command\n");
818 if (strcmp (r[1], "/dev/sda2") != 0) {
819 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
823 fprintf (stderr, "test_pvs_1: short list returned from command\n");
827 if (strcmp (r[2], "/dev/sda3") != 0) {
828 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
832 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
836 for (i = 0; r[i] != NULL; ++i)
843 static int test_vgs_0 (void)
845 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
849 r = guestfs_umount_all (g);
856 r = guestfs_lvm_remove_all (g);
867 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
874 r = guestfs_pvcreate (g, "/dev/sda1");
885 r = guestfs_vgcreate (g, "VG", physvols);
892 r = guestfs_lvcreate (g, "LV", "VG", 8);
899 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
906 r = guestfs_mount (g, "/dev/VG/LV", "/");
910 /* TestOutputList for vgs (0) */
919 fprintf (stderr, "test_vgs_0: short list returned from command\n");
923 if (strcmp (r[0], "VG") != 0) {
924 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
928 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
932 for (i = 0; r[i] != NULL; ++i)
939 static int test_vgs_1 (void)
941 /* InitEmpty for vgs (1) */
945 r = guestfs_umount_all (g);
952 r = guestfs_lvm_remove_all (g);
956 /* TestOutputList for vgs (1) */
966 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
973 r = guestfs_pvcreate (g, "/dev/sda1");
980 r = guestfs_pvcreate (g, "/dev/sda2");
987 r = guestfs_pvcreate (g, "/dev/sda3");
999 r = guestfs_vgcreate (g, "VG1", physvols);
1004 char *physvols[] = {
1010 r = guestfs_vgcreate (g, "VG2", physvols);
1018 r = guestfs_vgs (g);
1022 fprintf (stderr, "test_vgs_1: short list returned from command\n");
1026 if (strcmp (r[0], "VG1") != 0) {
1027 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
1031 fprintf (stderr, "test_vgs_1: short list returned from command\n");
1035 if (strcmp (r[1], "VG2") != 0) {
1036 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
1040 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
1044 for (i = 0; r[i] != NULL; ++i)
1051 static int test_lvs_0 (void)
1053 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
1057 r = guestfs_umount_all (g);
1064 r = guestfs_lvm_remove_all (g);
1075 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1082 r = guestfs_pvcreate (g, "/dev/sda1");
1087 char *physvols[] = {
1093 r = guestfs_vgcreate (g, "VG", physvols);
1100 r = guestfs_lvcreate (g, "LV", "VG", 8);
1107 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
1114 r = guestfs_mount (g, "/dev/VG/LV", "/");
1118 /* TestOutputList for lvs (0) */
1123 r = guestfs_lvs (g);
1127 fprintf (stderr, "test_lvs_0: short list returned from command\n");
1131 if (strcmp (r[0], "/dev/VG/LV") != 0) {
1132 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
1136 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
1140 for (i = 0; r[i] != NULL; ++i)
1147 static int test_lvs_1 (void)
1149 /* InitEmpty for lvs (1) */
1153 r = guestfs_umount_all (g);
1160 r = guestfs_lvm_remove_all (g);
1164 /* TestOutputList for lvs (1) */
1174 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1181 r = guestfs_pvcreate (g, "/dev/sda1");
1188 r = guestfs_pvcreate (g, "/dev/sda2");
1195 r = guestfs_pvcreate (g, "/dev/sda3");
1200 char *physvols[] = {
1207 r = guestfs_vgcreate (g, "VG1", physvols);
1212 char *physvols[] = {
1218 r = guestfs_vgcreate (g, "VG2", physvols);
1225 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
1232 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
1239 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
1247 r = guestfs_lvs (g);
1251 fprintf (stderr, "test_lvs_1: short list returned from command\n");
1255 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
1256 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
1260 fprintf (stderr, "test_lvs_1: short list returned from command\n");
1264 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
1265 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
1269 fprintf (stderr, "test_lvs_1: short list returned from command\n");
1273 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
1274 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
1278 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
1282 for (i = 0; r[i] != NULL; ++i)
1289 static int test_read_lines_0 (void)
1291 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
1295 r = guestfs_umount_all (g);
1302 r = guestfs_lvm_remove_all (g);
1313 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1320 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1327 r = guestfs_mount (g, "/dev/sda1", "/");
1331 /* TestOutputList for read_lines (0) */
1335 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
1343 r = guestfs_read_lines (g, "/new");
1347 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
1351 if (strcmp (r[0], "line1") != 0) {
1352 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
1356 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
1360 if (strcmp (r[1], "line2") != 0) {
1361 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
1365 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
1369 if (strcmp (r[2], "line3") != 0) {
1370 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
1374 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
1378 for (i = 0; r[i] != NULL; ++i)
1385 static int test_read_lines_1 (void)
1387 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
1391 r = guestfs_umount_all (g);
1398 r = guestfs_lvm_remove_all (g);
1409 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1416 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1423 r = guestfs_mount (g, "/dev/sda1", "/");
1427 /* TestOutputList for read_lines (1) */
1431 r = guestfs_write_file (g, "/new", "", 0);
1439 r = guestfs_read_lines (g, "/new");
1443 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
1447 for (i = 0; r[i] != NULL; ++i)
1454 static int test_rm_0 (void)
1456 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
1460 r = guestfs_umount_all (g);
1467 r = guestfs_lvm_remove_all (g);
1478 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1485 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1492 r = guestfs_mount (g, "/dev/sda1", "/");
1496 /* TestRun for rm (0) */
1500 r = guestfs_touch (g, "/new");
1507 r = guestfs_rm (g, "/new");
1514 static int test_rm_1 (void)
1516 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
1520 r = guestfs_umount_all (g);
1527 r = guestfs_lvm_remove_all (g);
1538 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1545 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1552 r = guestfs_mount (g, "/dev/sda1", "/");
1556 /* TestLastFail for rm (1) */
1560 r = guestfs_rm (g, "/new");
1567 static int test_rm_2 (void)
1569 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
1573 r = guestfs_umount_all (g);
1580 r = guestfs_lvm_remove_all (g);
1591 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1598 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1605 r = guestfs_mount (g, "/dev/sda1", "/");
1609 /* TestLastFail for rm (2) */
1613 r = guestfs_mkdir (g, "/new");
1620 r = guestfs_rm (g, "/new");
1627 static int test_rmdir_0 (void)
1629 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
1633 r = guestfs_umount_all (g);
1640 r = guestfs_lvm_remove_all (g);
1651 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1658 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1665 r = guestfs_mount (g, "/dev/sda1", "/");
1669 /* TestRun for rmdir (0) */
1673 r = guestfs_mkdir (g, "/new");
1680 r = guestfs_rmdir (g, "/new");
1687 static int test_rmdir_1 (void)
1689 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
1693 r = guestfs_umount_all (g);
1700 r = guestfs_lvm_remove_all (g);
1711 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1718 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1725 r = guestfs_mount (g, "/dev/sda1", "/");
1729 /* TestLastFail for rmdir (1) */
1733 r = guestfs_rmdir (g, "/new");
1740 static int test_rmdir_2 (void)
1742 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
1746 r = guestfs_umount_all (g);
1753 r = guestfs_lvm_remove_all (g);
1764 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1771 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1778 r = guestfs_mount (g, "/dev/sda1", "/");
1782 /* TestLastFail for rmdir (2) */
1786 r = guestfs_touch (g, "/new");
1793 r = guestfs_rmdir (g, "/new");
1800 static int test_rm_rf_0 (void)
1802 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
1806 r = guestfs_umount_all (g);
1813 r = guestfs_lvm_remove_all (g);
1824 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1831 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1838 r = guestfs_mount (g, "/dev/sda1", "/");
1842 /* TestOutputFalse for rm_rf (0) */
1846 r = guestfs_mkdir (g, "/new");
1853 r = guestfs_mkdir (g, "/new/foo");
1860 r = guestfs_touch (g, "/new/foo/bar");
1867 r = guestfs_rm_rf (g, "/new");
1874 r = guestfs_exists (g, "/new");
1878 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
1885 static int test_mkdir_0 (void)
1887 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
1891 r = guestfs_umount_all (g);
1898 r = guestfs_lvm_remove_all (g);
1909 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1916 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1923 r = guestfs_mount (g, "/dev/sda1", "/");
1927 /* TestOutputTrue for mkdir (0) */
1931 r = guestfs_mkdir (g, "/new");
1938 r = guestfs_is_dir (g, "/new");
1942 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
1949 static int test_mkdir_1 (void)
1951 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
1955 r = guestfs_umount_all (g);
1962 r = guestfs_lvm_remove_all (g);
1973 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1980 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1987 r = guestfs_mount (g, "/dev/sda1", "/");
1991 /* TestLastFail for mkdir (1) */
1995 r = guestfs_mkdir (g, "/new/foo/bar");
2002 static int test_mkdir_p_0 (void)
2004 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
2008 r = guestfs_umount_all (g);
2015 r = guestfs_lvm_remove_all (g);
2026 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2033 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2040 r = guestfs_mount (g, "/dev/sda1", "/");
2044 /* TestOutputTrue for mkdir_p (0) */
2048 r = guestfs_mkdir_p (g, "/new/foo/bar");
2055 r = guestfs_is_dir (g, "/new/foo/bar");
2059 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
2066 static int test_mkdir_p_1 (void)
2068 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
2072 r = guestfs_umount_all (g);
2079 r = guestfs_lvm_remove_all (g);
2090 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2097 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2104 r = guestfs_mount (g, "/dev/sda1", "/");
2108 /* TestOutputTrue for mkdir_p (1) */
2112 r = guestfs_mkdir_p (g, "/new/foo/bar");
2119 r = guestfs_is_dir (g, "/new/foo");
2123 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
2130 static int test_mkdir_p_2 (void)
2132 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
2136 r = guestfs_umount_all (g);
2143 r = guestfs_lvm_remove_all (g);
2154 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2161 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2168 r = guestfs_mount (g, "/dev/sda1", "/");
2172 /* TestOutputTrue for mkdir_p (2) */
2176 r = guestfs_mkdir_p (g, "/new/foo/bar");
2183 r = guestfs_is_dir (g, "/new");
2187 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
2194 static int test_exists_0 (void)
2196 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2200 r = guestfs_umount_all (g);
2207 r = guestfs_lvm_remove_all (g);
2218 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2225 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2232 r = guestfs_mount (g, "/dev/sda1", "/");
2236 /* TestOutputTrue for exists (0) */
2240 r = guestfs_touch (g, "/new");
2247 r = guestfs_exists (g, "/new");
2251 fprintf (stderr, "test_exists_0: expected true, got false\n");
2258 static int test_exists_1 (void)
2260 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
2264 r = guestfs_umount_all (g);
2271 r = guestfs_lvm_remove_all (g);
2282 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2289 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2296 r = guestfs_mount (g, "/dev/sda1", "/");
2300 /* TestOutputTrue for exists (1) */
2304 r = guestfs_mkdir (g, "/new");
2311 r = guestfs_exists (g, "/new");
2315 fprintf (stderr, "test_exists_1: expected true, got false\n");
2322 static int test_is_file_0 (void)
2324 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2328 r = guestfs_umount_all (g);
2335 r = guestfs_lvm_remove_all (g);
2346 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2353 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2360 r = guestfs_mount (g, "/dev/sda1", "/");
2364 /* TestOutputTrue for is_file (0) */
2368 r = guestfs_touch (g, "/new");
2375 r = guestfs_is_file (g, "/new");
2379 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2386 static int test_is_file_1 (void)
2388 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2392 r = guestfs_umount_all (g);
2399 r = guestfs_lvm_remove_all (g);
2410 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2417 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2424 r = guestfs_mount (g, "/dev/sda1", "/");
2428 /* TestOutputFalse for is_file (1) */
2432 r = guestfs_mkdir (g, "/new");
2439 r = guestfs_is_file (g, "/new");
2443 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2450 static int test_is_dir_0 (void)
2452 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2456 r = guestfs_umount_all (g);
2463 r = guestfs_lvm_remove_all (g);
2474 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2481 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2488 r = guestfs_mount (g, "/dev/sda1", "/");
2492 /* TestOutputFalse for is_dir (0) */
2496 r = guestfs_touch (g, "/new");
2503 r = guestfs_is_dir (g, "/new");
2507 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2514 static int test_is_dir_1 (void)
2516 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2520 r = guestfs_umount_all (g);
2527 r = guestfs_lvm_remove_all (g);
2538 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2545 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2552 r = guestfs_mount (g, "/dev/sda1", "/");
2556 /* TestOutputTrue for is_dir (1) */
2560 r = guestfs_mkdir (g, "/new");
2567 r = guestfs_is_dir (g, "/new");
2571 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2578 static int test_pvcreate_0 (void)
2580 /* InitEmpty for pvcreate (0) */
2584 r = guestfs_umount_all (g);
2591 r = guestfs_lvm_remove_all (g);
2595 /* TestOutputList for pvcreate (0) */
2605 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2612 r = guestfs_pvcreate (g, "/dev/sda1");
2619 r = guestfs_pvcreate (g, "/dev/sda2");
2626 r = guestfs_pvcreate (g, "/dev/sda3");
2634 r = guestfs_pvs (g);
2638 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2642 if (strcmp (r[0], "/dev/sda1") != 0) {
2643 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2647 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2651 if (strcmp (r[1], "/dev/sda2") != 0) {
2652 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2656 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2660 if (strcmp (r[2], "/dev/sda3") != 0) {
2661 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2665 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2669 for (i = 0; r[i] != NULL; ++i)
2676 static int test_vgcreate_0 (void)
2678 /* InitEmpty for vgcreate (0) */
2682 r = guestfs_umount_all (g);
2689 r = guestfs_lvm_remove_all (g);
2693 /* TestOutputList for vgcreate (0) */
2703 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2710 r = guestfs_pvcreate (g, "/dev/sda1");
2717 r = guestfs_pvcreate (g, "/dev/sda2");
2724 r = guestfs_pvcreate (g, "/dev/sda3");
2729 char *physvols[] = {
2736 r = guestfs_vgcreate (g, "VG1", physvols);
2741 char *physvols[] = {
2747 r = guestfs_vgcreate (g, "VG2", physvols);
2755 r = guestfs_vgs (g);
2759 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2763 if (strcmp (r[0], "VG1") != 0) {
2764 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2768 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2772 if (strcmp (r[1], "VG2") != 0) {
2773 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2777 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2781 for (i = 0; r[i] != NULL; ++i)
2788 static int test_lvcreate_0 (void)
2790 /* InitEmpty for lvcreate (0) */
2794 r = guestfs_umount_all (g);
2801 r = guestfs_lvm_remove_all (g);
2805 /* TestOutputList for lvcreate (0) */
2815 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2822 r = guestfs_pvcreate (g, "/dev/sda1");
2829 r = guestfs_pvcreate (g, "/dev/sda2");
2836 r = guestfs_pvcreate (g, "/dev/sda3");
2841 char *physvols[] = {
2848 r = guestfs_vgcreate (g, "VG1", physvols);
2853 char *physvols[] = {
2859 r = guestfs_vgcreate (g, "VG2", physvols);
2866 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2873 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2880 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2887 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2894 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2902 r = guestfs_lvs (g);
2906 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2910 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2911 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2915 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2919 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2920 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2924 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2928 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2929 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2933 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2937 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2938 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2942 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2946 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2947 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2951 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2955 for (i = 0; r[i] != NULL; ++i)
2962 static int test_mkfs_0 (void)
2964 /* InitEmpty for mkfs (0) */
2968 r = guestfs_umount_all (g);
2975 r = guestfs_lvm_remove_all (g);
2979 /* TestOutput for mkfs (0) */
2987 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2994 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3001 r = guestfs_mount (g, "/dev/sda1", "/");
3008 r = guestfs_write_file (g, "/new", "new file contents", 0);
3015 r = guestfs_cat (g, "/new");
3018 if (strcmp (r, "new file contents") != 0) {
3019 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
3027 static int test_write_file_0 (void)
3029 /* InitEmpty for write_file (0) */
3033 r = guestfs_umount_all (g);
3040 r = guestfs_lvm_remove_all (g);
3044 /* TestOutput for write_file (0) */
3052 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3059 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3066 r = guestfs_mount (g, "/dev/sda1", "/");
3073 r = guestfs_write_file (g, "/new", "new file contents", 0);
3080 r = guestfs_cat (g, "/new");
3083 if (strcmp (r, "new file contents") != 0) {
3084 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
3092 static int test_umount_0 (void)
3094 /* InitEmpty for umount (0) */
3098 r = guestfs_umount_all (g);
3105 r = guestfs_lvm_remove_all (g);
3109 /* TestOutputList for umount (0) */
3117 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3124 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3131 r = guestfs_mount (g, "/dev/sda1", "/");
3139 r = guestfs_mounts (g);
3143 fprintf (stderr, "test_umount_0: short list returned from command\n");
3147 if (strcmp (r[0], "/dev/sda1") != 0) {
3148 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3152 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
3156 for (i = 0; r[i] != NULL; ++i)
3163 static int test_umount_1 (void)
3165 /* InitEmpty for umount (1) */
3169 r = guestfs_umount_all (g);
3176 r = guestfs_lvm_remove_all (g);
3180 /* TestOutputList for umount (1) */
3188 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3195 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3202 r = guestfs_mount (g, "/dev/sda1", "/");
3209 r = guestfs_umount (g, "/");
3217 r = guestfs_mounts (g);
3221 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
3225 for (i = 0; r[i] != NULL; ++i)
3232 static int test_mounts_0 (void)
3234 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
3238 r = guestfs_umount_all (g);
3245 r = guestfs_lvm_remove_all (g);
3256 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3263 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3270 r = guestfs_mount (g, "/dev/sda1", "/");
3274 /* TestOutputList for mounts (0) */
3279 r = guestfs_mounts (g);
3283 fprintf (stderr, "test_mounts_0: short list returned from command\n");
3287 if (strcmp (r[0], "/dev/sda1") != 0) {
3288 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3292 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
3296 for (i = 0; r[i] != NULL; ++i)
3303 static int test_umount_all_0 (void)
3305 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
3309 r = guestfs_umount_all (g);
3316 r = guestfs_lvm_remove_all (g);
3327 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3334 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3341 r = guestfs_mount (g, "/dev/sda1", "/");
3345 /* TestOutputList for umount_all (0) */
3349 r = guestfs_umount_all (g);
3357 r = guestfs_mounts (g);
3361 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
3365 for (i = 0; r[i] != NULL; ++i)
3372 static int test_file_0 (void)
3374 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
3378 r = guestfs_umount_all (g);
3385 r = guestfs_lvm_remove_all (g);
3396 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3403 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3410 r = guestfs_mount (g, "/dev/sda1", "/");
3414 /* TestOutput for file (0) */
3418 r = guestfs_touch (g, "/new");
3425 r = guestfs_file (g, "/new");
3428 if (strcmp (r, "empty") != 0) {
3429 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
3437 static int test_file_1 (void)
3439 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
3443 r = guestfs_umount_all (g);
3450 r = guestfs_lvm_remove_all (g);
3461 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3468 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3475 r = guestfs_mount (g, "/dev/sda1", "/");
3479 /* TestOutput for file (1) */
3483 r = guestfs_write_file (g, "/new", "some content\n", 0);
3490 r = guestfs_file (g, "/new");
3493 if (strcmp (r, "ASCII text") != 0) {
3494 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
3502 static int test_file_2 (void)
3504 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
3508 r = guestfs_umount_all (g);
3515 r = guestfs_lvm_remove_all (g);
3526 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3533 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3540 r = guestfs_mount (g, "/dev/sda1", "/");
3544 /* TestLastFail for file (2) */
3548 r = guestfs_file (g, "/nofile");
3556 static int test_stat_0 (void)
3558 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
3562 r = guestfs_umount_all (g);
3569 r = guestfs_lvm_remove_all (g);
3580 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3587 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3594 r = guestfs_mount (g, "/dev/sda1", "/");
3598 /* TestOutputStruct for stat (0) */
3602 r = guestfs_touch (g, "/new");
3607 struct guestfs_stat *r;
3609 r = guestfs_stat (g, "/new");
3613 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
3622 static int test_lstat_0 (void)
3624 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
3628 r = guestfs_umount_all (g);
3635 r = guestfs_lvm_remove_all (g);
3646 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3653 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3660 r = guestfs_mount (g, "/dev/sda1", "/");
3664 /* TestOutputStruct for lstat (0) */
3668 r = guestfs_touch (g, "/new");
3673 struct guestfs_stat *r;
3675 r = guestfs_lstat (g, "/new");
3679 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
3688 static int test_statvfs_0 (void)
3690 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
3694 r = guestfs_umount_all (g);
3701 r = guestfs_lvm_remove_all (g);
3712 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3719 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3726 r = guestfs_mount (g, "/dev/sda1", "/");
3730 /* TestOutputStruct for statvfs (0) */
3732 struct guestfs_statvfs *r;
3734 r = guestfs_statvfs (g, "/");
3737 if (r->bfree != 487702) {
3738 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
3742 if (r->blocks != 490020) {
3743 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
3747 if (r->bsize != 1024) {
3748 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
3757 int main (int argc, char *argv[])
3766 no_test_warnings ();
3768 g = guestfs_create ();
3770 printf ("guestfs_create FAILED\n");
3774 guestfs_set_error_handler (g, print_error, NULL);
3776 srcdir = getenv ("srcdir");
3777 if (!srcdir) srcdir = ".";
3778 guestfs_set_path (g, srcdir);
3780 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
3781 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
3786 if (lseek (fd, 524288000, SEEK_SET) == -1) {
3792 if (write (fd, &c, 1) == -1) {
3798 if (close (fd) == -1) {
3803 if (guestfs_add_drive (g, buf) == -1) {
3804 printf ("guestfs_add_drive %s FAILED\n", buf);
3808 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
3809 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
3814 if (lseek (fd, 52428800, SEEK_SET) == -1) {
3820 if (write (fd, &c, 1) == -1) {
3826 if (close (fd) == -1) {
3831 if (guestfs_add_drive (g, buf) == -1) {
3832 printf ("guestfs_add_drive %s FAILED\n", buf);
3836 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
3837 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
3842 if (lseek (fd, 10485760, SEEK_SET) == -1) {
3848 if (write (fd, &c, 1) == -1) {
3854 if (close (fd) == -1) {
3859 if (guestfs_add_drive (g, buf) == -1) {
3860 printf ("guestfs_add_drive %s FAILED\n", buf);
3864 if (guestfs_launch (g) == -1) {
3865 printf ("guestfs_launch FAILED\n");
3868 if (guestfs_wait_ready (g) == -1) {
3869 printf ("guestfs_wait_ready FAILED\n");
3874 printf (" 1/%3d test_mount_0\n", nr_tests);
3875 if (test_mount_0 () == -1) {
3876 printf ("test_mount_0 FAILED\n");
3879 printf (" 2/%3d test_sync_0\n", nr_tests);
3880 if (test_sync_0 () == -1) {
3881 printf ("test_sync_0 FAILED\n");
3884 printf (" 3/%3d test_touch_0\n", nr_tests);
3885 if (test_touch_0 () == -1) {
3886 printf ("test_touch_0 FAILED\n");
3889 printf (" 4/%3d test_cat_0\n", nr_tests);
3890 if (test_cat_0 () == -1) {
3891 printf ("test_cat_0 FAILED\n");
3894 printf (" 5/%3d test_ls_0\n", nr_tests);
3895 if (test_ls_0 () == -1) {
3896 printf ("test_ls_0 FAILED\n");
3899 printf (" 6/%3d test_list_devices_0\n", nr_tests);
3900 if (test_list_devices_0 () == -1) {
3901 printf ("test_list_devices_0 FAILED\n");
3904 printf (" 7/%3d test_list_partitions_0\n", nr_tests);
3905 if (test_list_partitions_0 () == -1) {
3906 printf ("test_list_partitions_0 FAILED\n");
3909 printf (" 8/%3d test_list_partitions_1\n", nr_tests);
3910 if (test_list_partitions_1 () == -1) {
3911 printf ("test_list_partitions_1 FAILED\n");
3914 printf (" 9/%3d test_pvs_0\n", nr_tests);
3915 if (test_pvs_0 () == -1) {
3916 printf ("test_pvs_0 FAILED\n");
3919 printf (" 10/%3d test_pvs_1\n", nr_tests);
3920 if (test_pvs_1 () == -1) {
3921 printf ("test_pvs_1 FAILED\n");
3924 printf (" 11/%3d test_vgs_0\n", nr_tests);
3925 if (test_vgs_0 () == -1) {
3926 printf ("test_vgs_0 FAILED\n");
3929 printf (" 12/%3d test_vgs_1\n", nr_tests);
3930 if (test_vgs_1 () == -1) {
3931 printf ("test_vgs_1 FAILED\n");
3934 printf (" 13/%3d test_lvs_0\n", nr_tests);
3935 if (test_lvs_0 () == -1) {
3936 printf ("test_lvs_0 FAILED\n");
3939 printf (" 14/%3d test_lvs_1\n", nr_tests);
3940 if (test_lvs_1 () == -1) {
3941 printf ("test_lvs_1 FAILED\n");
3944 printf (" 15/%3d test_read_lines_0\n", nr_tests);
3945 if (test_read_lines_0 () == -1) {
3946 printf ("test_read_lines_0 FAILED\n");
3949 printf (" 16/%3d test_read_lines_1\n", nr_tests);
3950 if (test_read_lines_1 () == -1) {
3951 printf ("test_read_lines_1 FAILED\n");
3954 printf (" 17/%3d test_rm_0\n", nr_tests);
3955 if (test_rm_0 () == -1) {
3956 printf ("test_rm_0 FAILED\n");
3959 printf (" 18/%3d test_rm_1\n", nr_tests);
3960 if (test_rm_1 () == -1) {
3961 printf ("test_rm_1 FAILED\n");
3964 printf (" 19/%3d test_rm_2\n", nr_tests);
3965 if (test_rm_2 () == -1) {
3966 printf ("test_rm_2 FAILED\n");
3969 printf (" 20/%3d test_rmdir_0\n", nr_tests);
3970 if (test_rmdir_0 () == -1) {
3971 printf ("test_rmdir_0 FAILED\n");
3974 printf (" 21/%3d test_rmdir_1\n", nr_tests);
3975 if (test_rmdir_1 () == -1) {
3976 printf ("test_rmdir_1 FAILED\n");
3979 printf (" 22/%3d test_rmdir_2\n", nr_tests);
3980 if (test_rmdir_2 () == -1) {
3981 printf ("test_rmdir_2 FAILED\n");
3984 printf (" 23/%3d test_rm_rf_0\n", nr_tests);
3985 if (test_rm_rf_0 () == -1) {
3986 printf ("test_rm_rf_0 FAILED\n");
3989 printf (" 24/%3d test_mkdir_0\n", nr_tests);
3990 if (test_mkdir_0 () == -1) {
3991 printf ("test_mkdir_0 FAILED\n");
3994 printf (" 25/%3d test_mkdir_1\n", nr_tests);
3995 if (test_mkdir_1 () == -1) {
3996 printf ("test_mkdir_1 FAILED\n");
3999 printf (" 26/%3d test_mkdir_p_0\n", nr_tests);
4000 if (test_mkdir_p_0 () == -1) {
4001 printf ("test_mkdir_p_0 FAILED\n");
4004 printf (" 27/%3d test_mkdir_p_1\n", nr_tests);
4005 if (test_mkdir_p_1 () == -1) {
4006 printf ("test_mkdir_p_1 FAILED\n");
4009 printf (" 28/%3d test_mkdir_p_2\n", nr_tests);
4010 if (test_mkdir_p_2 () == -1) {
4011 printf ("test_mkdir_p_2 FAILED\n");
4014 printf (" 29/%3d test_exists_0\n", nr_tests);
4015 if (test_exists_0 () == -1) {
4016 printf ("test_exists_0 FAILED\n");
4019 printf (" 30/%3d test_exists_1\n", nr_tests);
4020 if (test_exists_1 () == -1) {
4021 printf ("test_exists_1 FAILED\n");
4024 printf (" 31/%3d test_is_file_0\n", nr_tests);
4025 if (test_is_file_0 () == -1) {
4026 printf ("test_is_file_0 FAILED\n");
4029 printf (" 32/%3d test_is_file_1\n", nr_tests);
4030 if (test_is_file_1 () == -1) {
4031 printf ("test_is_file_1 FAILED\n");
4034 printf (" 33/%3d test_is_dir_0\n", nr_tests);
4035 if (test_is_dir_0 () == -1) {
4036 printf ("test_is_dir_0 FAILED\n");
4039 printf (" 34/%3d test_is_dir_1\n", nr_tests);
4040 if (test_is_dir_1 () == -1) {
4041 printf ("test_is_dir_1 FAILED\n");
4044 printf (" 35/%3d test_pvcreate_0\n", nr_tests);
4045 if (test_pvcreate_0 () == -1) {
4046 printf ("test_pvcreate_0 FAILED\n");
4049 printf (" 36/%3d test_vgcreate_0\n", nr_tests);
4050 if (test_vgcreate_0 () == -1) {
4051 printf ("test_vgcreate_0 FAILED\n");
4054 printf (" 37/%3d test_lvcreate_0\n", nr_tests);
4055 if (test_lvcreate_0 () == -1) {
4056 printf ("test_lvcreate_0 FAILED\n");
4059 printf (" 38/%3d test_mkfs_0\n", nr_tests);
4060 if (test_mkfs_0 () == -1) {
4061 printf ("test_mkfs_0 FAILED\n");
4064 printf (" 39/%3d test_write_file_0\n", nr_tests);
4065 if (test_write_file_0 () == -1) {
4066 printf ("test_write_file_0 FAILED\n");
4069 printf (" 40/%3d test_umount_0\n", nr_tests);
4070 if (test_umount_0 () == -1) {
4071 printf ("test_umount_0 FAILED\n");
4074 printf (" 41/%3d test_umount_1\n", nr_tests);
4075 if (test_umount_1 () == -1) {
4076 printf ("test_umount_1 FAILED\n");
4079 printf (" 42/%3d test_mounts_0\n", nr_tests);
4080 if (test_mounts_0 () == -1) {
4081 printf ("test_mounts_0 FAILED\n");
4084 printf (" 43/%3d test_umount_all_0\n", nr_tests);
4085 if (test_umount_all_0 () == -1) {
4086 printf ("test_umount_all_0 FAILED\n");
4089 printf (" 44/%3d test_file_0\n", nr_tests);
4090 if (test_file_0 () == -1) {
4091 printf ("test_file_0 FAILED\n");
4094 printf (" 45/%3d test_file_1\n", nr_tests);
4095 if (test_file_1 () == -1) {
4096 printf ("test_file_1 FAILED\n");
4099 printf (" 46/%3d test_file_2\n", nr_tests);
4100 if (test_file_2 () == -1) {
4101 printf ("test_file_2 FAILED\n");
4104 printf (" 47/%3d test_stat_0\n", nr_tests);
4105 if (test_stat_0 () == -1) {
4106 printf ("test_stat_0 FAILED\n");
4109 printf (" 48/%3d test_lstat_0\n", nr_tests);
4110 if (test_lstat_0 () == -1) {
4111 printf ("test_lstat_0 FAILED\n");
4114 printf (" 49/%3d test_statvfs_0\n", nr_tests);
4115 if (test_statvfs_0 () == -1) {
4116 printf ("test_statvfs_0 FAILED\n");
4121 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
4123 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
4125 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
4129 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);