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]);
49 static void print_table (char * const * const argv)
53 for (i = 0; argv[i] != NULL; i += 2)
54 printf ("%s: %s\n", argv[i], argv[i+1]);
58 static void no_test_warnings (void)
60 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
61 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
62 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
63 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
64 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
65 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
115 static int test_dmesg_0 (void)
117 /* InitEmpty for dmesg (0) */
121 r = guestfs_umount_all (g);
128 r = guestfs_lvm_remove_all (g);
132 /* TestRun for dmesg (0) */
136 r = guestfs_dmesg (g);
144 static int test_drop_caches_0 (void)
146 /* InitEmpty for drop_caches (0) */
150 r = guestfs_umount_all (g);
157 r = guestfs_lvm_remove_all (g);
161 /* TestRun for drop_caches (0) */
165 r = guestfs_drop_caches (g, 3);
172 static int test_mv_0 (void)
174 /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
178 r = guestfs_umount_all (g);
185 r = guestfs_lvm_remove_all (g);
196 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
203 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
210 r = guestfs_mount (g, "/dev/sda1", "/");
214 /* TestOutput for mv (0) */
218 r = guestfs_write_file (g, "/old", "file content", 0);
225 r = guestfs_mv (g, "/old", "/new");
232 r = guestfs_cat (g, "/new");
235 if (strcmp (r, "file content") != 0) {
236 fprintf (stderr, "test_mv_0: expected \"file content\" but got \"%s\"\n", r);
244 static int test_mv_1 (void)
246 /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
250 r = guestfs_umount_all (g);
257 r = guestfs_lvm_remove_all (g);
268 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
275 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
282 r = guestfs_mount (g, "/dev/sda1", "/");
286 /* TestOutputFalse for mv (1) */
290 r = guestfs_write_file (g, "/old", "file content", 0);
297 r = guestfs_mv (g, "/old", "/new");
304 r = guestfs_is_file (g, "/old");
308 fprintf (stderr, "test_mv_1: expected false, got true\n");
315 static int test_cp_a_0 (void)
317 /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
321 r = guestfs_umount_all (g);
328 r = guestfs_lvm_remove_all (g);
339 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
346 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
353 r = guestfs_mount (g, "/dev/sda1", "/");
357 /* TestOutput for cp_a (0) */
361 r = guestfs_mkdir (g, "/olddir");
368 r = guestfs_mkdir (g, "/newdir");
375 r = guestfs_write_file (g, "/olddir/file", "file content", 0);
382 r = guestfs_cp_a (g, "/olddir", "/newdir");
389 r = guestfs_cat (g, "/newdir/olddir/file");
392 if (strcmp (r, "file content") != 0) {
393 fprintf (stderr, "test_cp_a_0: expected \"file content\" but got \"%s\"\n", r);
401 static int test_cp_0 (void)
403 /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
407 r = guestfs_umount_all (g);
414 r = guestfs_lvm_remove_all (g);
425 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
432 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
439 r = guestfs_mount (g, "/dev/sda1", "/");
443 /* TestOutput for cp (0) */
447 r = guestfs_write_file (g, "/old", "file content", 0);
454 r = guestfs_cp (g, "/old", "/new");
461 r = guestfs_cat (g, "/new");
464 if (strcmp (r, "file content") != 0) {
465 fprintf (stderr, "test_cp_0: expected \"file content\" but got \"%s\"\n", r);
473 static int test_cp_1 (void)
475 /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
479 r = guestfs_umount_all (g);
486 r = guestfs_lvm_remove_all (g);
497 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
504 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
511 r = guestfs_mount (g, "/dev/sda1", "/");
515 /* TestOutputTrue for cp (1) */
519 r = guestfs_write_file (g, "/old", "file content", 0);
526 r = guestfs_cp (g, "/old", "/new");
533 r = guestfs_is_file (g, "/old");
537 fprintf (stderr, "test_cp_1: expected true, got false\n");
544 static int test_cp_2 (void)
546 /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
550 r = guestfs_umount_all (g);
557 r = guestfs_lvm_remove_all (g);
568 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
575 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
582 r = guestfs_mount (g, "/dev/sda1", "/");
586 /* TestOutput for cp (2) */
590 r = guestfs_write_file (g, "/old", "file content", 0);
597 r = guestfs_mkdir (g, "/dir");
604 r = guestfs_cp (g, "/old", "/dir/new");
611 r = guestfs_cat (g, "/dir/new");
614 if (strcmp (r, "file content") != 0) {
615 fprintf (stderr, "test_cp_2: expected \"file content\" but got \"%s\"\n", r);
623 static int test_grub_install_0 (void)
625 /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
629 r = guestfs_umount_all (g);
636 r = guestfs_lvm_remove_all (g);
647 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
654 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
661 r = guestfs_mount (g, "/dev/sda1", "/");
665 /* TestOutputTrue for grub_install (0) */
669 r = guestfs_grub_install (g, "/", "/dev/sda1");
676 r = guestfs_is_dir (g, "/boot");
680 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
687 static int test_zero_0 (void)
689 /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
693 r = guestfs_umount_all (g);
700 r = guestfs_lvm_remove_all (g);
711 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
718 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
725 r = guestfs_mount (g, "/dev/sda1", "/");
729 /* TestOutput for zero (0) */
733 r = guestfs_umount (g, "/dev/sda1");
740 r = guestfs_zero (g, "/dev/sda1");
747 r = guestfs_file (g, "/dev/sda1");
750 if (strcmp (r, "data") != 0) {
751 fprintf (stderr, "test_zero_0: expected \"data\" but got \"%s\"\n", r);
759 static int test_fsck_0 (void)
761 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
765 r = guestfs_umount_all (g);
772 r = guestfs_lvm_remove_all (g);
783 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
790 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
797 r = guestfs_mount (g, "/dev/sda1", "/");
801 /* TestOutputInt for fsck (0) */
805 r = guestfs_umount (g, "/dev/sda1");
812 r = guestfs_fsck (g, "ext2", "/dev/sda1");
816 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
823 static int test_fsck_1 (void)
825 /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
829 r = guestfs_umount_all (g);
836 r = guestfs_lvm_remove_all (g);
847 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
854 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
861 r = guestfs_mount (g, "/dev/sda1", "/");
865 /* TestOutputInt for fsck (1) */
869 r = guestfs_umount (g, "/dev/sda1");
876 r = guestfs_zero (g, "/dev/sda1");
883 r = guestfs_fsck (g, "ext2", "/dev/sda1");
887 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
894 static int test_set_e2uuid_0 (void)
896 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
900 r = guestfs_umount_all (g);
907 r = guestfs_lvm_remove_all (g);
918 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
925 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
932 r = guestfs_mount (g, "/dev/sda1", "/");
936 /* TestOutput for set_e2uuid (0) */
940 r = guestfs_set_e2uuid (g, "/dev/sda1", "a3a61220-882b-4f61-89f4-cf24dcc7297d");
947 r = guestfs_get_e2uuid (g, "/dev/sda1");
950 if (strcmp (r, "a3a61220-882b-4f61-89f4-cf24dcc7297d") != 0) {
951 fprintf (stderr, "test_set_e2uuid_0: expected \"a3a61220-882b-4f61-89f4-cf24dcc7297d\" but got \"%s\"\n", r);
959 static int test_set_e2uuid_1 (void)
961 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
965 r = guestfs_umount_all (g);
972 r = guestfs_lvm_remove_all (g);
983 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
990 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
997 r = guestfs_mount (g, "/dev/sda1", "/");
1001 /* TestOutput for set_e2uuid (1) */
1005 r = guestfs_set_e2uuid (g, "/dev/sda1", "clear");
1012 r = guestfs_get_e2uuid (g, "/dev/sda1");
1015 if (strcmp (r, "") != 0) {
1016 fprintf (stderr, "test_set_e2uuid_1: expected \"\" but got \"%s\"\n", r);
1024 static int test_set_e2uuid_2 (void)
1026 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1030 r = guestfs_umount_all (g);
1037 r = guestfs_lvm_remove_all (g);
1048 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1055 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1062 r = guestfs_mount (g, "/dev/sda1", "/");
1066 /* TestRun for set_e2uuid (2) */
1070 r = guestfs_set_e2uuid (g, "/dev/sda1", "random");
1077 static int test_set_e2uuid_3 (void)
1079 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
1083 r = guestfs_umount_all (g);
1090 r = guestfs_lvm_remove_all (g);
1101 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1108 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1115 r = guestfs_mount (g, "/dev/sda1", "/");
1119 /* TestRun for set_e2uuid (3) */
1123 r = guestfs_set_e2uuid (g, "/dev/sda1", "time");
1130 static int test_set_e2label_0 (void)
1132 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
1136 r = guestfs_umount_all (g);
1143 r = guestfs_lvm_remove_all (g);
1154 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1161 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1168 r = guestfs_mount (g, "/dev/sda1", "/");
1172 /* TestOutput for set_e2label (0) */
1176 r = guestfs_set_e2label (g, "/dev/sda1", "testlabel");
1183 r = guestfs_get_e2label (g, "/dev/sda1");
1186 if (strcmp (r, "testlabel") != 0) {
1187 fprintf (stderr, "test_set_e2label_0: expected \"testlabel\" but got \"%s\"\n", r);
1195 static int test_pvremove_0 (void)
1197 /* InitEmpty for pvremove (0) */
1201 r = guestfs_umount_all (g);
1208 r = guestfs_lvm_remove_all (g);
1212 /* TestOutputList for pvremove (0) */
1216 r = guestfs_pvcreate (g, "/dev/sda");
1221 char *physvols[] = {
1227 r = guestfs_vgcreate (g, "VG", physvols);
1234 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1241 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1248 r = guestfs_vgremove (g, "VG");
1255 r = guestfs_pvremove (g, "/dev/sda");
1263 r = guestfs_lvs (g);
1267 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
1271 for (i = 0; r[i] != NULL; ++i)
1278 static int test_pvremove_1 (void)
1280 /* InitEmpty for pvremove (1) */
1284 r = guestfs_umount_all (g);
1291 r = guestfs_lvm_remove_all (g);
1295 /* TestOutputList for pvremove (1) */
1299 r = guestfs_pvcreate (g, "/dev/sda");
1304 char *physvols[] = {
1310 r = guestfs_vgcreate (g, "VG", physvols);
1317 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1324 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1331 r = guestfs_vgremove (g, "VG");
1338 r = guestfs_pvremove (g, "/dev/sda");
1346 r = guestfs_vgs (g);
1350 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
1354 for (i = 0; r[i] != NULL; ++i)
1361 static int test_pvremove_2 (void)
1363 /* InitEmpty for pvremove (2) */
1367 r = guestfs_umount_all (g);
1374 r = guestfs_lvm_remove_all (g);
1378 /* TestOutputList for pvremove (2) */
1382 r = guestfs_pvcreate (g, "/dev/sda");
1387 char *physvols[] = {
1393 r = guestfs_vgcreate (g, "VG", physvols);
1400 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1407 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1414 r = guestfs_vgremove (g, "VG");
1421 r = guestfs_pvremove (g, "/dev/sda");
1429 r = guestfs_pvs (g);
1433 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
1437 for (i = 0; r[i] != NULL; ++i)
1444 static int test_vgremove_0 (void)
1446 /* InitEmpty for vgremove (0) */
1450 r = guestfs_umount_all (g);
1457 r = guestfs_lvm_remove_all (g);
1461 /* TestOutputList for vgremove (0) */
1465 r = guestfs_pvcreate (g, "/dev/sda");
1470 char *physvols[] = {
1476 r = guestfs_vgcreate (g, "VG", physvols);
1483 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1490 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1497 r = guestfs_vgremove (g, "VG");
1505 r = guestfs_lvs (g);
1509 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
1513 for (i = 0; r[i] != NULL; ++i)
1520 static int test_vgremove_1 (void)
1522 /* InitEmpty for vgremove (1) */
1526 r = guestfs_umount_all (g);
1533 r = guestfs_lvm_remove_all (g);
1537 /* TestOutputList for vgremove (1) */
1541 r = guestfs_pvcreate (g, "/dev/sda");
1546 char *physvols[] = {
1552 r = guestfs_vgcreate (g, "VG", physvols);
1559 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1566 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1573 r = guestfs_vgremove (g, "VG");
1581 r = guestfs_vgs (g);
1585 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
1589 for (i = 0; r[i] != NULL; ++i)
1596 static int test_lvremove_0 (void)
1598 /* InitEmpty for lvremove (0) */
1602 r = guestfs_umount_all (g);
1609 r = guestfs_lvm_remove_all (g);
1613 /* TestOutputList for lvremove (0) */
1617 r = guestfs_pvcreate (g, "/dev/sda");
1622 char *physvols[] = {
1628 r = guestfs_vgcreate (g, "VG", physvols);
1635 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1642 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1649 r = guestfs_lvremove (g, "/dev/VG/LV1");
1657 r = guestfs_lvs (g);
1661 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
1665 if (strcmp (r[0], "/dev/VG/LV2") != 0) {
1666 fprintf (stderr, "test_lvremove_0: expected \"/dev/VG/LV2\" but got \"%s\"\n", r[0]);
1670 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
1674 for (i = 0; r[i] != NULL; ++i)
1681 static int test_lvremove_1 (void)
1683 /* InitEmpty for lvremove (1) */
1687 r = guestfs_umount_all (g);
1694 r = guestfs_lvm_remove_all (g);
1698 /* TestOutputList for lvremove (1) */
1702 r = guestfs_pvcreate (g, "/dev/sda");
1707 char *physvols[] = {
1713 r = guestfs_vgcreate (g, "VG", physvols);
1720 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1727 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1734 r = guestfs_lvremove (g, "/dev/VG");
1742 r = guestfs_lvs (g);
1746 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
1750 for (i = 0; r[i] != NULL; ++i)
1757 static int test_lvremove_2 (void)
1759 /* InitEmpty for lvremove (2) */
1763 r = guestfs_umount_all (g);
1770 r = guestfs_lvm_remove_all (g);
1774 /* TestOutputList for lvremove (2) */
1778 r = guestfs_pvcreate (g, "/dev/sda");
1783 char *physvols[] = {
1789 r = guestfs_vgcreate (g, "VG", physvols);
1796 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1803 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1810 r = guestfs_lvremove (g, "/dev/VG");
1818 r = guestfs_vgs (g);
1822 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
1826 if (strcmp (r[0], "VG") != 0) {
1827 fprintf (stderr, "test_lvremove_2: expected \"VG\" but got \"%s\"\n", r[0]);
1831 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
1835 for (i = 0; r[i] != NULL; ++i)
1842 static int test_mount_ro_0 (void)
1844 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
1848 r = guestfs_umount_all (g);
1855 r = guestfs_lvm_remove_all (g);
1866 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1873 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1880 r = guestfs_mount (g, "/dev/sda1", "/");
1884 /* TestLastFail for mount_ro (0) */
1888 r = guestfs_umount (g, "/");
1895 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1902 r = guestfs_touch (g, "/new");
1909 static int test_mount_ro_1 (void)
1911 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
1915 r = guestfs_umount_all (g);
1922 r = guestfs_lvm_remove_all (g);
1933 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1940 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1947 r = guestfs_mount (g, "/dev/sda1", "/");
1951 /* TestOutput for mount_ro (1) */
1955 r = guestfs_write_file (g, "/new", "data", 0);
1962 r = guestfs_umount (g, "/");
1969 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1976 r = guestfs_cat (g, "/new");
1979 if (strcmp (r, "data") != 0) {
1980 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
1988 static int test_tgz_in_0 (void)
1990 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
1994 r = guestfs_umount_all (g);
2001 r = guestfs_lvm_remove_all (g);
2012 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2019 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2026 r = guestfs_mount (g, "/dev/sda1", "/");
2030 /* TestOutput for tgz_in (0) */
2034 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
2041 r = guestfs_cat (g, "/hello");
2044 if (strcmp (r, "hello\n") != 0) {
2045 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
2053 static int test_tar_in_0 (void)
2055 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
2059 r = guestfs_umount_all (g);
2066 r = guestfs_lvm_remove_all (g);
2077 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2084 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2091 r = guestfs_mount (g, "/dev/sda1", "/");
2095 /* TestOutput for tar_in (0) */
2099 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
2106 r = guestfs_cat (g, "/hello");
2109 if (strcmp (r, "hello\n") != 0) {
2110 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
2118 static int test_checksum_0 (void)
2120 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
2124 r = guestfs_umount_all (g);
2131 r = guestfs_lvm_remove_all (g);
2142 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2149 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2156 r = guestfs_mount (g, "/dev/sda1", "/");
2160 /* TestOutput for checksum (0) */
2164 r = guestfs_write_file (g, "/new", "test\n", 0);
2171 r = guestfs_checksum (g, "crc", "/new");
2174 if (strcmp (r, "935282863") != 0) {
2175 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
2183 static int test_checksum_1 (void)
2185 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
2189 r = guestfs_umount_all (g);
2196 r = guestfs_lvm_remove_all (g);
2207 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2214 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2221 r = guestfs_mount (g, "/dev/sda1", "/");
2225 /* TestLastFail for checksum (1) */
2229 r = guestfs_checksum (g, "crc", "/new");
2237 static int test_checksum_2 (void)
2239 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
2243 r = guestfs_umount_all (g);
2250 r = guestfs_lvm_remove_all (g);
2261 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2268 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2275 r = guestfs_mount (g, "/dev/sda1", "/");
2279 /* TestOutput for checksum (2) */
2283 r = guestfs_write_file (g, "/new", "test\n", 0);
2290 r = guestfs_checksum (g, "md5", "/new");
2293 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
2294 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
2302 static int test_checksum_3 (void)
2304 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
2308 r = guestfs_umount_all (g);
2315 r = guestfs_lvm_remove_all (g);
2326 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2333 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2340 r = guestfs_mount (g, "/dev/sda1", "/");
2344 /* TestOutput for checksum (3) */
2348 r = guestfs_write_file (g, "/new", "test\n", 0);
2355 r = guestfs_checksum (g, "sha1", "/new");
2358 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
2359 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
2367 static int test_checksum_4 (void)
2369 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
2373 r = guestfs_umount_all (g);
2380 r = guestfs_lvm_remove_all (g);
2391 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2398 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2405 r = guestfs_mount (g, "/dev/sda1", "/");
2409 /* TestOutput for checksum (4) */
2413 r = guestfs_write_file (g, "/new", "test\n", 0);
2420 r = guestfs_checksum (g, "sha224", "/new");
2423 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
2424 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
2432 static int test_checksum_5 (void)
2434 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
2438 r = guestfs_umount_all (g);
2445 r = guestfs_lvm_remove_all (g);
2456 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2463 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2470 r = guestfs_mount (g, "/dev/sda1", "/");
2474 /* TestOutput for checksum (5) */
2478 r = guestfs_write_file (g, "/new", "test\n", 0);
2485 r = guestfs_checksum (g, "sha256", "/new");
2488 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
2489 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
2497 static int test_checksum_6 (void)
2499 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
2503 r = guestfs_umount_all (g);
2510 r = guestfs_lvm_remove_all (g);
2521 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2528 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2535 r = guestfs_mount (g, "/dev/sda1", "/");
2539 /* TestOutput for checksum (6) */
2543 r = guestfs_write_file (g, "/new", "test\n", 0);
2550 r = guestfs_checksum (g, "sha384", "/new");
2553 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
2554 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
2562 static int test_checksum_7 (void)
2564 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
2568 r = guestfs_umount_all (g);
2575 r = guestfs_lvm_remove_all (g);
2586 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2593 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2600 r = guestfs_mount (g, "/dev/sda1", "/");
2604 /* TestOutput for checksum (7) */
2608 r = guestfs_write_file (g, "/new", "test\n", 0);
2615 r = guestfs_checksum (g, "sha512", "/new");
2618 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
2619 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
2627 static int test_download_0 (void)
2629 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
2633 r = guestfs_umount_all (g);
2640 r = guestfs_lvm_remove_all (g);
2651 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2658 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2665 r = guestfs_mount (g, "/dev/sda1", "/");
2669 /* TestOutput for download (0) */
2673 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2680 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
2687 r = guestfs_upload (g, "testdownload.tmp", "/upload");
2694 r = guestfs_checksum (g, "md5", "/upload");
2697 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2698 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2706 static int test_upload_0 (void)
2708 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
2712 r = guestfs_umount_all (g);
2719 r = guestfs_lvm_remove_all (g);
2730 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2737 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2744 r = guestfs_mount (g, "/dev/sda1", "/");
2748 /* TestOutput for upload (0) */
2752 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2759 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
2762 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2763 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2771 static int test_blockdev_rereadpt_0 (void)
2773 /* InitEmpty for blockdev_rereadpt (0) */
2777 r = guestfs_umount_all (g);
2784 r = guestfs_lvm_remove_all (g);
2788 /* TestRun for blockdev_rereadpt (0) */
2792 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
2799 static int test_blockdev_flushbufs_0 (void)
2801 /* InitEmpty for blockdev_flushbufs (0) */
2805 r = guestfs_umount_all (g);
2812 r = guestfs_lvm_remove_all (g);
2816 /* TestRun for blockdev_flushbufs (0) */
2820 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
2827 static int test_blockdev_getsize64_0 (void)
2829 /* InitEmpty for blockdev_getsize64 (0) */
2833 r = guestfs_umount_all (g);
2840 r = guestfs_lvm_remove_all (g);
2844 /* TestOutputInt for blockdev_getsize64 (0) */
2848 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
2851 if (r != 524288000) {
2852 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
2859 static int test_blockdev_getsz_0 (void)
2861 /* InitEmpty for blockdev_getsz (0) */
2865 r = guestfs_umount_all (g);
2872 r = guestfs_lvm_remove_all (g);
2876 /* TestOutputInt for blockdev_getsz (0) */
2880 r = guestfs_blockdev_getsz (g, "/dev/sda");
2884 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
2891 static int test_blockdev_getbsz_0 (void)
2893 /* InitEmpty for blockdev_getbsz (0) */
2897 r = guestfs_umount_all (g);
2904 r = guestfs_lvm_remove_all (g);
2908 /* TestOutputInt for blockdev_getbsz (0) */
2912 r = guestfs_blockdev_getbsz (g, "/dev/sda");
2916 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
2923 static int test_blockdev_getss_0 (void)
2925 /* InitEmpty for blockdev_getss (0) */
2929 r = guestfs_umount_all (g);
2936 r = guestfs_lvm_remove_all (g);
2940 /* TestOutputInt for blockdev_getss (0) */
2944 r = guestfs_blockdev_getss (g, "/dev/sda");
2948 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
2955 static int test_blockdev_getro_0 (void)
2957 /* InitEmpty for blockdev_getro (0) */
2961 r = guestfs_umount_all (g);
2968 r = guestfs_lvm_remove_all (g);
2972 /* TestOutputTrue for blockdev_getro (0) */
2976 r = guestfs_blockdev_setro (g, "/dev/sda");
2983 r = guestfs_blockdev_getro (g, "/dev/sda");
2987 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
2994 static int test_blockdev_setrw_0 (void)
2996 /* InitEmpty for blockdev_setrw (0) */
3000 r = guestfs_umount_all (g);
3007 r = guestfs_lvm_remove_all (g);
3011 /* TestOutputFalse for blockdev_setrw (0) */
3015 r = guestfs_blockdev_setrw (g, "/dev/sda");
3022 r = guestfs_blockdev_getro (g, "/dev/sda");
3026 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
3033 static int test_blockdev_setro_0 (void)
3035 /* InitEmpty for blockdev_setro (0) */
3039 r = guestfs_umount_all (g);
3046 r = guestfs_lvm_remove_all (g);
3050 /* TestOutputTrue for blockdev_setro (0) */
3054 r = guestfs_blockdev_setro (g, "/dev/sda");
3061 r = guestfs_blockdev_getro (g, "/dev/sda");
3065 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
3072 static int test_statvfs_0 (void)
3074 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
3078 r = guestfs_umount_all (g);
3085 r = guestfs_lvm_remove_all (g);
3096 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3103 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3110 r = guestfs_mount (g, "/dev/sda1", "/");
3114 /* TestOutputStruct for statvfs (0) */
3116 struct guestfs_statvfs *r;
3118 r = guestfs_statvfs (g, "/");
3121 if (r->bfree != 487702) {
3122 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
3126 if (r->blocks != 490020) {
3127 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
3131 if (r->bsize != 1024) {
3132 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
3141 static int test_lstat_0 (void)
3143 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
3147 r = guestfs_umount_all (g);
3154 r = guestfs_lvm_remove_all (g);
3165 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3172 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3179 r = guestfs_mount (g, "/dev/sda1", "/");
3183 /* TestOutputStruct for lstat (0) */
3187 r = guestfs_touch (g, "/new");
3192 struct guestfs_stat *r;
3194 r = guestfs_lstat (g, "/new");
3198 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
3207 static int test_stat_0 (void)
3209 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
3213 r = guestfs_umount_all (g);
3220 r = guestfs_lvm_remove_all (g);
3231 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3238 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3245 r = guestfs_mount (g, "/dev/sda1", "/");
3249 /* TestOutputStruct for stat (0) */
3253 r = guestfs_touch (g, "/new");
3258 struct guestfs_stat *r;
3260 r = guestfs_stat (g, "/new");
3264 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
3273 static int test_file_0 (void)
3275 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
3279 r = guestfs_umount_all (g);
3286 r = guestfs_lvm_remove_all (g);
3297 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3304 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3311 r = guestfs_mount (g, "/dev/sda1", "/");
3315 /* TestOutput for file (0) */
3319 r = guestfs_touch (g, "/new");
3326 r = guestfs_file (g, "/new");
3329 if (strcmp (r, "empty") != 0) {
3330 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
3338 static int test_file_1 (void)
3340 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
3344 r = guestfs_umount_all (g);
3351 r = guestfs_lvm_remove_all (g);
3362 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3369 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3376 r = guestfs_mount (g, "/dev/sda1", "/");
3380 /* TestOutput for file (1) */
3384 r = guestfs_write_file (g, "/new", "some content\n", 0);
3391 r = guestfs_file (g, "/new");
3394 if (strcmp (r, "ASCII text") != 0) {
3395 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
3403 static int test_file_2 (void)
3405 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
3409 r = guestfs_umount_all (g);
3416 r = guestfs_lvm_remove_all (g);
3427 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3434 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3441 r = guestfs_mount (g, "/dev/sda1", "/");
3445 /* TestLastFail for file (2) */
3449 r = guestfs_file (g, "/nofile");
3457 static int test_umount_all_0 (void)
3459 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
3463 r = guestfs_umount_all (g);
3470 r = guestfs_lvm_remove_all (g);
3481 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3488 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3495 r = guestfs_mount (g, "/dev/sda1", "/");
3499 /* TestOutputList for umount_all (0) */
3503 r = guestfs_umount_all (g);
3511 r = guestfs_mounts (g);
3515 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
3519 for (i = 0; r[i] != NULL; ++i)
3526 static int test_umount_all_1 (void)
3528 /* InitEmpty for umount_all (1) */
3532 r = guestfs_umount_all (g);
3539 r = guestfs_lvm_remove_all (g);
3543 /* TestOutputList for umount_all (1) */
3553 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3560 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3567 r = guestfs_mkfs (g, "ext2", "/dev/sda2");
3574 r = guestfs_mkfs (g, "ext2", "/dev/sda3");
3581 r = guestfs_mount (g, "/dev/sda1", "/");
3588 r = guestfs_mkdir (g, "/mp1");
3595 r = guestfs_mount (g, "/dev/sda2", "/mp1");
3602 r = guestfs_mkdir (g, "/mp1/mp2");
3609 r = guestfs_mount (g, "/dev/sda3", "/mp1/mp2");
3616 r = guestfs_mkdir (g, "/mp1/mp2/mp3");
3623 r = guestfs_umount_all (g);
3631 r = guestfs_mounts (g);
3635 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
3639 for (i = 0; r[i] != NULL; ++i)
3646 static int test_mounts_0 (void)
3648 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
3652 r = guestfs_umount_all (g);
3659 r = guestfs_lvm_remove_all (g);
3670 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3677 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3684 r = guestfs_mount (g, "/dev/sda1", "/");
3688 /* TestOutputList for mounts (0) */
3693 r = guestfs_mounts (g);
3697 fprintf (stderr, "test_mounts_0: short list returned from command\n");
3701 if (strcmp (r[0], "/dev/sda1") != 0) {
3702 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3706 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
3710 for (i = 0; r[i] != NULL; ++i)
3717 static int test_umount_0 (void)
3719 /* InitEmpty for umount (0) */
3723 r = guestfs_umount_all (g);
3730 r = guestfs_lvm_remove_all (g);
3734 /* TestOutputList for umount (0) */
3742 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3749 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3756 r = guestfs_mount (g, "/dev/sda1", "/");
3764 r = guestfs_mounts (g);
3768 fprintf (stderr, "test_umount_0: short list returned from command\n");
3772 if (strcmp (r[0], "/dev/sda1") != 0) {
3773 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3777 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
3781 for (i = 0; r[i] != NULL; ++i)
3788 static int test_umount_1 (void)
3790 /* InitEmpty for umount (1) */
3794 r = guestfs_umount_all (g);
3801 r = guestfs_lvm_remove_all (g);
3805 /* TestOutputList for umount (1) */
3813 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3820 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3827 r = guestfs_mount (g, "/dev/sda1", "/");
3834 r = guestfs_umount (g, "/");
3842 r = guestfs_mounts (g);
3846 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
3850 for (i = 0; r[i] != NULL; ++i)
3857 static int test_write_file_0 (void)
3859 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
3863 r = guestfs_umount_all (g);
3870 r = guestfs_lvm_remove_all (g);
3881 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3888 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3895 r = guestfs_mount (g, "/dev/sda1", "/");
3899 /* TestOutput for write_file (0) */
3903 r = guestfs_write_file (g, "/new", "new file contents", 0);
3910 r = guestfs_cat (g, "/new");
3913 if (strcmp (r, "new file contents") != 0) {
3914 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
3922 static int test_write_file_1 (void)
3924 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
3928 r = guestfs_umount_all (g);
3935 r = guestfs_lvm_remove_all (g);
3946 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3953 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3960 r = guestfs_mount (g, "/dev/sda1", "/");
3964 /* TestOutput for write_file (1) */
3968 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
3975 r = guestfs_cat (g, "/new");
3978 if (strcmp (r, "\nnew file contents\n") != 0) {
3979 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
3987 static int test_write_file_2 (void)
3989 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
3993 r = guestfs_umount_all (g);
4000 r = guestfs_lvm_remove_all (g);
4011 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4018 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4025 r = guestfs_mount (g, "/dev/sda1", "/");
4029 /* TestOutput for write_file (2) */
4033 r = guestfs_write_file (g, "/new", "\n\n", 0);
4040 r = guestfs_cat (g, "/new");
4043 if (strcmp (r, "\n\n") != 0) {
4044 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
4052 static int test_write_file_3 (void)
4054 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
4058 r = guestfs_umount_all (g);
4065 r = guestfs_lvm_remove_all (g);
4076 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4083 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4090 r = guestfs_mount (g, "/dev/sda1", "/");
4094 /* TestOutput for write_file (3) */
4098 r = guestfs_write_file (g, "/new", "", 0);
4105 r = guestfs_cat (g, "/new");
4108 if (strcmp (r, "") != 0) {
4109 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
4117 static int test_write_file_4 (void)
4119 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
4123 r = guestfs_umount_all (g);
4130 r = guestfs_lvm_remove_all (g);
4141 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4148 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4155 r = guestfs_mount (g, "/dev/sda1", "/");
4159 /* TestOutput for write_file (4) */
4163 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
4170 r = guestfs_cat (g, "/new");
4173 if (strcmp (r, "\n\n\n") != 0) {
4174 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
4182 static int test_write_file_5 (void)
4184 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
4188 r = guestfs_umount_all (g);
4195 r = guestfs_lvm_remove_all (g);
4206 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4213 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4220 r = guestfs_mount (g, "/dev/sda1", "/");
4224 /* TestOutput for write_file (5) */
4228 r = guestfs_write_file (g, "/new", "\n", 0);
4235 r = guestfs_cat (g, "/new");
4238 if (strcmp (r, "\n") != 0) {
4239 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
4247 static int test_mkfs_0 (void)
4249 /* InitEmpty for mkfs (0) */
4253 r = guestfs_umount_all (g);
4260 r = guestfs_lvm_remove_all (g);
4264 /* TestOutput for mkfs (0) */
4272 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4279 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4286 r = guestfs_mount (g, "/dev/sda1", "/");
4293 r = guestfs_write_file (g, "/new", "new file contents", 0);
4300 r = guestfs_cat (g, "/new");
4303 if (strcmp (r, "new file contents") != 0) {
4304 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
4312 static int test_lvcreate_0 (void)
4314 /* InitEmpty for lvcreate (0) */
4318 r = guestfs_umount_all (g);
4325 r = guestfs_lvm_remove_all (g);
4329 /* TestOutputList for lvcreate (0) */
4339 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4346 r = guestfs_pvcreate (g, "/dev/sda1");
4353 r = guestfs_pvcreate (g, "/dev/sda2");
4360 r = guestfs_pvcreate (g, "/dev/sda3");
4365 char *physvols[] = {
4372 r = guestfs_vgcreate (g, "VG1", physvols);
4377 char *physvols[] = {
4383 r = guestfs_vgcreate (g, "VG2", physvols);
4390 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4397 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4404 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4411 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
4418 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
4426 r = guestfs_lvs (g);
4430 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4434 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4435 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4439 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4443 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4444 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4448 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4452 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4453 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4457 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4461 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
4462 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
4466 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4470 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
4471 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
4475 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
4479 for (i = 0; r[i] != NULL; ++i)
4486 static int test_vgcreate_0 (void)
4488 /* InitEmpty for vgcreate (0) */
4492 r = guestfs_umount_all (g);
4499 r = guestfs_lvm_remove_all (g);
4503 /* TestOutputList for vgcreate (0) */
4513 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4520 r = guestfs_pvcreate (g, "/dev/sda1");
4527 r = guestfs_pvcreate (g, "/dev/sda2");
4534 r = guestfs_pvcreate (g, "/dev/sda3");
4539 char *physvols[] = {
4546 r = guestfs_vgcreate (g, "VG1", physvols);
4551 char *physvols[] = {
4557 r = guestfs_vgcreate (g, "VG2", physvols);
4565 r = guestfs_vgs (g);
4569 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4573 if (strcmp (r[0], "VG1") != 0) {
4574 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
4578 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4582 if (strcmp (r[1], "VG2") != 0) {
4583 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
4587 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
4591 for (i = 0; r[i] != NULL; ++i)
4598 static int test_pvcreate_0 (void)
4600 /* InitEmpty for pvcreate (0) */
4604 r = guestfs_umount_all (g);
4611 r = guestfs_lvm_remove_all (g);
4615 /* TestOutputList for pvcreate (0) */
4625 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4632 r = guestfs_pvcreate (g, "/dev/sda1");
4639 r = guestfs_pvcreate (g, "/dev/sda2");
4646 r = guestfs_pvcreate (g, "/dev/sda3");
4654 r = guestfs_pvs (g);
4658 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4662 if (strcmp (r[0], "/dev/sda1") != 0) {
4663 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4667 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4671 if (strcmp (r[1], "/dev/sda2") != 0) {
4672 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4676 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4680 if (strcmp (r[2], "/dev/sda3") != 0) {
4681 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4685 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
4689 for (i = 0; r[i] != NULL; ++i)
4696 static int test_is_dir_0 (void)
4698 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
4702 r = guestfs_umount_all (g);
4709 r = guestfs_lvm_remove_all (g);
4720 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4727 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4734 r = guestfs_mount (g, "/dev/sda1", "/");
4738 /* TestOutputFalse for is_dir (0) */
4742 r = guestfs_touch (g, "/new");
4749 r = guestfs_is_dir (g, "/new");
4753 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
4760 static int test_is_dir_1 (void)
4762 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
4766 r = guestfs_umount_all (g);
4773 r = guestfs_lvm_remove_all (g);
4784 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4791 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4798 r = guestfs_mount (g, "/dev/sda1", "/");
4802 /* TestOutputTrue for is_dir (1) */
4806 r = guestfs_mkdir (g, "/new");
4813 r = guestfs_is_dir (g, "/new");
4817 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
4824 static int test_is_file_0 (void)
4826 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
4830 r = guestfs_umount_all (g);
4837 r = guestfs_lvm_remove_all (g);
4848 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4855 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4862 r = guestfs_mount (g, "/dev/sda1", "/");
4866 /* TestOutputTrue for is_file (0) */
4870 r = guestfs_touch (g, "/new");
4877 r = guestfs_is_file (g, "/new");
4881 fprintf (stderr, "test_is_file_0: expected true, got false\n");
4888 static int test_is_file_1 (void)
4890 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
4894 r = guestfs_umount_all (g);
4901 r = guestfs_lvm_remove_all (g);
4912 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4919 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4926 r = guestfs_mount (g, "/dev/sda1", "/");
4930 /* TestOutputFalse for is_file (1) */
4934 r = guestfs_mkdir (g, "/new");
4941 r = guestfs_is_file (g, "/new");
4945 fprintf (stderr, "test_is_file_1: expected false, got true\n");
4952 static int test_exists_0 (void)
4954 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
4958 r = guestfs_umount_all (g);
4965 r = guestfs_lvm_remove_all (g);
4976 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4983 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4990 r = guestfs_mount (g, "/dev/sda1", "/");
4994 /* TestOutputTrue for exists (0) */
4998 r = guestfs_touch (g, "/new");
5005 r = guestfs_exists (g, "/new");
5009 fprintf (stderr, "test_exists_0: expected true, got false\n");
5016 static int test_exists_1 (void)
5018 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
5022 r = guestfs_umount_all (g);
5029 r = guestfs_lvm_remove_all (g);
5040 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5047 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5054 r = guestfs_mount (g, "/dev/sda1", "/");
5058 /* TestOutputTrue for exists (1) */
5062 r = guestfs_mkdir (g, "/new");
5069 r = guestfs_exists (g, "/new");
5073 fprintf (stderr, "test_exists_1: expected true, got false\n");
5080 static int test_mkdir_p_0 (void)
5082 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
5086 r = guestfs_umount_all (g);
5093 r = guestfs_lvm_remove_all (g);
5104 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5111 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5118 r = guestfs_mount (g, "/dev/sda1", "/");
5122 /* TestOutputTrue for mkdir_p (0) */
5126 r = guestfs_mkdir_p (g, "/new/foo/bar");
5133 r = guestfs_is_dir (g, "/new/foo/bar");
5137 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
5144 static int test_mkdir_p_1 (void)
5146 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
5150 r = guestfs_umount_all (g);
5157 r = guestfs_lvm_remove_all (g);
5168 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5175 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5182 r = guestfs_mount (g, "/dev/sda1", "/");
5186 /* TestOutputTrue for mkdir_p (1) */
5190 r = guestfs_mkdir_p (g, "/new/foo/bar");
5197 r = guestfs_is_dir (g, "/new/foo");
5201 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
5208 static int test_mkdir_p_2 (void)
5210 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
5214 r = guestfs_umount_all (g);
5221 r = guestfs_lvm_remove_all (g);
5232 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5239 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5246 r = guestfs_mount (g, "/dev/sda1", "/");
5250 /* TestOutputTrue for mkdir_p (2) */
5254 r = guestfs_mkdir_p (g, "/new/foo/bar");
5261 r = guestfs_is_dir (g, "/new");
5265 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
5272 static int test_mkdir_0 (void)
5274 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
5278 r = guestfs_umount_all (g);
5285 r = guestfs_lvm_remove_all (g);
5296 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5303 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5310 r = guestfs_mount (g, "/dev/sda1", "/");
5314 /* TestOutputTrue for mkdir (0) */
5318 r = guestfs_mkdir (g, "/new");
5325 r = guestfs_is_dir (g, "/new");
5329 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
5336 static int test_mkdir_1 (void)
5338 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
5342 r = guestfs_umount_all (g);
5349 r = guestfs_lvm_remove_all (g);
5360 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5367 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5374 r = guestfs_mount (g, "/dev/sda1", "/");
5378 /* TestLastFail for mkdir (1) */
5382 r = guestfs_mkdir (g, "/new/foo/bar");
5389 static int test_rm_rf_0 (void)
5391 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
5395 r = guestfs_umount_all (g);
5402 r = guestfs_lvm_remove_all (g);
5413 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5420 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5427 r = guestfs_mount (g, "/dev/sda1", "/");
5431 /* TestOutputFalse for rm_rf (0) */
5435 r = guestfs_mkdir (g, "/new");
5442 r = guestfs_mkdir (g, "/new/foo");
5449 r = guestfs_touch (g, "/new/foo/bar");
5456 r = guestfs_rm_rf (g, "/new");
5463 r = guestfs_exists (g, "/new");
5467 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
5474 static int test_rmdir_0 (void)
5476 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
5480 r = guestfs_umount_all (g);
5487 r = guestfs_lvm_remove_all (g);
5498 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5505 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5512 r = guestfs_mount (g, "/dev/sda1", "/");
5516 /* TestRun for rmdir (0) */
5520 r = guestfs_mkdir (g, "/new");
5527 r = guestfs_rmdir (g, "/new");
5534 static int test_rmdir_1 (void)
5536 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
5540 r = guestfs_umount_all (g);
5547 r = guestfs_lvm_remove_all (g);
5558 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5565 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5572 r = guestfs_mount (g, "/dev/sda1", "/");
5576 /* TestLastFail for rmdir (1) */
5580 r = guestfs_rmdir (g, "/new");
5587 static int test_rmdir_2 (void)
5589 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
5593 r = guestfs_umount_all (g);
5600 r = guestfs_lvm_remove_all (g);
5611 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5618 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5625 r = guestfs_mount (g, "/dev/sda1", "/");
5629 /* TestLastFail for rmdir (2) */
5633 r = guestfs_touch (g, "/new");
5640 r = guestfs_rmdir (g, "/new");
5647 static int test_rm_0 (void)
5649 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
5653 r = guestfs_umount_all (g);
5660 r = guestfs_lvm_remove_all (g);
5671 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5678 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5685 r = guestfs_mount (g, "/dev/sda1", "/");
5689 /* TestRun for rm (0) */
5693 r = guestfs_touch (g, "/new");
5700 r = guestfs_rm (g, "/new");
5707 static int test_rm_1 (void)
5709 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
5713 r = guestfs_umount_all (g);
5720 r = guestfs_lvm_remove_all (g);
5731 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5738 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5745 r = guestfs_mount (g, "/dev/sda1", "/");
5749 /* TestLastFail for rm (1) */
5753 r = guestfs_rm (g, "/new");
5760 static int test_rm_2 (void)
5762 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
5766 r = guestfs_umount_all (g);
5773 r = guestfs_lvm_remove_all (g);
5784 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5791 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5798 r = guestfs_mount (g, "/dev/sda1", "/");
5802 /* TestLastFail for rm (2) */
5806 r = guestfs_mkdir (g, "/new");
5813 r = guestfs_rm (g, "/new");
5820 static int test_read_lines_0 (void)
5822 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
5826 r = guestfs_umount_all (g);
5833 r = guestfs_lvm_remove_all (g);
5844 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5851 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5858 r = guestfs_mount (g, "/dev/sda1", "/");
5862 /* TestOutputList for read_lines (0) */
5866 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
5874 r = guestfs_read_lines (g, "/new");
5878 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5882 if (strcmp (r[0], "line1") != 0) {
5883 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
5887 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5891 if (strcmp (r[1], "line2") != 0) {
5892 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
5896 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5900 if (strcmp (r[2], "line3") != 0) {
5901 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
5905 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
5909 for (i = 0; r[i] != NULL; ++i)
5916 static int test_read_lines_1 (void)
5918 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
5922 r = guestfs_umount_all (g);
5929 r = guestfs_lvm_remove_all (g);
5940 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5947 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5954 r = guestfs_mount (g, "/dev/sda1", "/");
5958 /* TestOutputList for read_lines (1) */
5962 r = guestfs_write_file (g, "/new", "", 0);
5970 r = guestfs_read_lines (g, "/new");
5974 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
5978 for (i = 0; r[i] != NULL; ++i)
5985 static int test_lvs_0 (void)
5987 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
5991 r = guestfs_umount_all (g);
5998 r = guestfs_lvm_remove_all (g);
6009 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6016 r = guestfs_pvcreate (g, "/dev/sda1");
6021 char *physvols[] = {
6027 r = guestfs_vgcreate (g, "VG", physvols);
6034 r = guestfs_lvcreate (g, "LV", "VG", 8);
6041 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6048 r = guestfs_mount (g, "/dev/VG/LV", "/");
6052 /* TestOutputList for lvs (0) */
6057 r = guestfs_lvs (g);
6061 fprintf (stderr, "test_lvs_0: short list returned from command\n");
6065 if (strcmp (r[0], "/dev/VG/LV") != 0) {
6066 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
6070 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
6074 for (i = 0; r[i] != NULL; ++i)
6081 static int test_lvs_1 (void)
6083 /* InitEmpty for lvs (1) */
6087 r = guestfs_umount_all (g);
6094 r = guestfs_lvm_remove_all (g);
6098 /* TestOutputList for lvs (1) */
6108 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6115 r = guestfs_pvcreate (g, "/dev/sda1");
6122 r = guestfs_pvcreate (g, "/dev/sda2");
6129 r = guestfs_pvcreate (g, "/dev/sda3");
6134 char *physvols[] = {
6141 r = guestfs_vgcreate (g, "VG1", physvols);
6146 char *physvols[] = {
6152 r = guestfs_vgcreate (g, "VG2", physvols);
6159 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
6166 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
6173 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
6181 r = guestfs_lvs (g);
6185 fprintf (stderr, "test_lvs_1: short list returned from command\n");
6189 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
6190 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
6194 fprintf (stderr, "test_lvs_1: short list returned from command\n");
6198 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
6199 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
6203 fprintf (stderr, "test_lvs_1: short list returned from command\n");
6207 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
6208 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
6212 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
6216 for (i = 0; r[i] != NULL; ++i)
6223 static int test_vgs_0 (void)
6225 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
6229 r = guestfs_umount_all (g);
6236 r = guestfs_lvm_remove_all (g);
6247 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6254 r = guestfs_pvcreate (g, "/dev/sda1");
6259 char *physvols[] = {
6265 r = guestfs_vgcreate (g, "VG", physvols);
6272 r = guestfs_lvcreate (g, "LV", "VG", 8);
6279 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6286 r = guestfs_mount (g, "/dev/VG/LV", "/");
6290 /* TestOutputList for vgs (0) */
6295 r = guestfs_vgs (g);
6299 fprintf (stderr, "test_vgs_0: short list returned from command\n");
6303 if (strcmp (r[0], "VG") != 0) {
6304 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
6308 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
6312 for (i = 0; r[i] != NULL; ++i)
6319 static int test_vgs_1 (void)
6321 /* InitEmpty for vgs (1) */
6325 r = guestfs_umount_all (g);
6332 r = guestfs_lvm_remove_all (g);
6336 /* TestOutputList for vgs (1) */
6346 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6353 r = guestfs_pvcreate (g, "/dev/sda1");
6360 r = guestfs_pvcreate (g, "/dev/sda2");
6367 r = guestfs_pvcreate (g, "/dev/sda3");
6372 char *physvols[] = {
6379 r = guestfs_vgcreate (g, "VG1", physvols);
6384 char *physvols[] = {
6390 r = guestfs_vgcreate (g, "VG2", physvols);
6398 r = guestfs_vgs (g);
6402 fprintf (stderr, "test_vgs_1: short list returned from command\n");
6406 if (strcmp (r[0], "VG1") != 0) {
6407 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
6411 fprintf (stderr, "test_vgs_1: short list returned from command\n");
6415 if (strcmp (r[1], "VG2") != 0) {
6416 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
6420 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
6424 for (i = 0; r[i] != NULL; ++i)
6431 static int test_pvs_0 (void)
6433 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
6437 r = guestfs_umount_all (g);
6444 r = guestfs_lvm_remove_all (g);
6455 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6462 r = guestfs_pvcreate (g, "/dev/sda1");
6467 char *physvols[] = {
6473 r = guestfs_vgcreate (g, "VG", physvols);
6480 r = guestfs_lvcreate (g, "LV", "VG", 8);
6487 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6494 r = guestfs_mount (g, "/dev/VG/LV", "/");
6498 /* TestOutputList for pvs (0) */
6503 r = guestfs_pvs (g);
6507 fprintf (stderr, "test_pvs_0: short list returned from command\n");
6511 if (strcmp (r[0], "/dev/sda1") != 0) {
6512 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6516 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
6520 for (i = 0; r[i] != NULL; ++i)
6527 static int test_pvs_1 (void)
6529 /* InitEmpty for pvs (1) */
6533 r = guestfs_umount_all (g);
6540 r = guestfs_lvm_remove_all (g);
6544 /* TestOutputList for pvs (1) */
6554 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6561 r = guestfs_pvcreate (g, "/dev/sda1");
6568 r = guestfs_pvcreate (g, "/dev/sda2");
6575 r = guestfs_pvcreate (g, "/dev/sda3");
6583 r = guestfs_pvs (g);
6587 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6591 if (strcmp (r[0], "/dev/sda1") != 0) {
6592 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6596 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6600 if (strcmp (r[1], "/dev/sda2") != 0) {
6601 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6605 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6609 if (strcmp (r[2], "/dev/sda3") != 0) {
6610 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6614 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
6618 for (i = 0; r[i] != NULL; ++i)
6625 static int test_list_partitions_0 (void)
6627 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
6631 r = guestfs_umount_all (g);
6638 r = guestfs_lvm_remove_all (g);
6649 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6656 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6663 r = guestfs_mount (g, "/dev/sda1", "/");
6667 /* TestOutputList for list_partitions (0) */
6672 r = guestfs_list_partitions (g);
6676 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
6680 if (strcmp (r[0], "/dev/sda1") != 0) {
6681 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6685 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
6689 for (i = 0; r[i] != NULL; ++i)
6696 static int test_list_partitions_1 (void)
6698 /* InitEmpty for list_partitions (1) */
6702 r = guestfs_umount_all (g);
6709 r = guestfs_lvm_remove_all (g);
6713 /* TestOutputList for list_partitions (1) */
6723 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6731 r = guestfs_list_partitions (g);
6735 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6739 if (strcmp (r[0], "/dev/sda1") != 0) {
6740 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6744 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6748 if (strcmp (r[1], "/dev/sda2") != 0) {
6749 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6753 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6757 if (strcmp (r[2], "/dev/sda3") != 0) {
6758 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6762 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
6766 for (i = 0; r[i] != NULL; ++i)
6773 static int test_list_devices_0 (void)
6775 /* InitEmpty for list_devices (0) */
6779 r = guestfs_umount_all (g);
6786 r = guestfs_lvm_remove_all (g);
6790 /* TestOutputList for list_devices (0) */
6795 r = guestfs_list_devices (g);
6799 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6803 if (strcmp (r[0], "/dev/sda") != 0) {
6804 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
6808 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6812 if (strcmp (r[1], "/dev/sdb") != 0) {
6813 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
6817 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6821 if (strcmp (r[2], "/dev/sdc") != 0) {
6822 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
6826 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
6830 for (i = 0; r[i] != NULL; ++i)
6837 static int test_ls_0 (void)
6839 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
6843 r = guestfs_umount_all (g);
6850 r = guestfs_lvm_remove_all (g);
6861 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6868 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6875 r = guestfs_mount (g, "/dev/sda1", "/");
6879 /* TestOutputList for ls (0) */
6883 r = guestfs_touch (g, "/new");
6890 r = guestfs_touch (g, "/newer");
6897 r = guestfs_touch (g, "/newest");
6905 r = guestfs_ls (g, "/");
6909 fprintf (stderr, "test_ls_0: short list returned from command\n");
6913 if (strcmp (r[0], "lost+found") != 0) {
6914 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
6918 fprintf (stderr, "test_ls_0: short list returned from command\n");
6922 if (strcmp (r[1], "new") != 0) {
6923 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
6927 fprintf (stderr, "test_ls_0: short list returned from command\n");
6931 if (strcmp (r[2], "newer") != 0) {
6932 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
6936 fprintf (stderr, "test_ls_0: short list returned from command\n");
6940 if (strcmp (r[3], "newest") != 0) {
6941 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
6945 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
6949 for (i = 0; r[i] != NULL; ++i)
6956 static int test_cat_0 (void)
6958 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
6962 r = guestfs_umount_all (g);
6969 r = guestfs_lvm_remove_all (g);
6980 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6987 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6994 r = guestfs_mount (g, "/dev/sda1", "/");
6998 /* TestOutput for cat (0) */
7002 r = guestfs_write_file (g, "/new", "new file contents", 0);
7009 r = guestfs_cat (g, "/new");
7012 if (strcmp (r, "new file contents") != 0) {
7013 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
7021 static int test_touch_0 (void)
7023 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
7027 r = guestfs_umount_all (g);
7034 r = guestfs_lvm_remove_all (g);
7045 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7052 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7059 r = guestfs_mount (g, "/dev/sda1", "/");
7063 /* TestOutputTrue for touch (0) */
7067 r = guestfs_touch (g, "/new");
7074 r = guestfs_exists (g, "/new");
7078 fprintf (stderr, "test_touch_0: expected true, got false\n");
7085 static int test_sync_0 (void)
7087 /* InitEmpty for sync (0) */
7091 r = guestfs_umount_all (g);
7098 r = guestfs_lvm_remove_all (g);
7102 /* TestRun for sync (0) */
7106 r = guestfs_sync (g);
7113 static int test_mount_0 (void)
7115 /* InitEmpty for mount (0) */
7119 r = guestfs_umount_all (g);
7126 r = guestfs_lvm_remove_all (g);
7130 /* TestOutput for mount (0) */
7138 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7145 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7152 r = guestfs_mount (g, "/dev/sda1", "/");
7159 r = guestfs_write_file (g, "/new", "new file contents", 0);
7166 r = guestfs_cat (g, "/new");
7169 if (strcmp (r, "new file contents") != 0) {
7170 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
7178 int main (int argc, char *argv[])
7183 const char *filename;
7185 int nr_tests, test_num = 0;
7187 no_test_warnings ();
7189 g = guestfs_create ();
7191 printf ("guestfs_create FAILED\n");
7195 guestfs_set_error_handler (g, print_error, NULL);
7197 srcdir = getenv ("srcdir");
7198 if (!srcdir) srcdir = ".";
7200 guestfs_set_path (g, ".");
7202 filename = "test1.img";
7203 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7208 if (lseek (fd, 524288000, SEEK_SET) == -1) {
7214 if (write (fd, &c, 1) == -1) {
7220 if (close (fd) == -1) {
7225 if (guestfs_add_drive (g, filename) == -1) {
7226 printf ("guestfs_add_drive %s FAILED\n", filename);
7230 filename = "test2.img";
7231 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7236 if (lseek (fd, 52428800, SEEK_SET) == -1) {
7242 if (write (fd, &c, 1) == -1) {
7248 if (close (fd) == -1) {
7253 if (guestfs_add_drive (g, filename) == -1) {
7254 printf ("guestfs_add_drive %s FAILED\n", filename);
7258 filename = "test3.img";
7259 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7264 if (lseek (fd, 10485760, SEEK_SET) == -1) {
7270 if (write (fd, &c, 1) == -1) {
7276 if (close (fd) == -1) {
7281 if (guestfs_add_drive (g, filename) == -1) {
7282 printf ("guestfs_add_drive %s FAILED\n", filename);
7286 if (guestfs_launch (g) == -1) {
7287 printf ("guestfs_launch FAILED\n");
7290 if (guestfs_wait_ready (g) == -1) {
7291 printf ("guestfs_wait_ready FAILED\n");
7298 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
7299 if (test_dmesg_0 () == -1) {
7300 printf ("test_dmesg_0 FAILED\n");
7304 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
7305 if (test_drop_caches_0 () == -1) {
7306 printf ("test_drop_caches_0 FAILED\n");
7310 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
7311 if (test_mv_0 () == -1) {
7312 printf ("test_mv_0 FAILED\n");
7316 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
7317 if (test_mv_1 () == -1) {
7318 printf ("test_mv_1 FAILED\n");
7322 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
7323 if (test_cp_a_0 () == -1) {
7324 printf ("test_cp_a_0 FAILED\n");
7328 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
7329 if (test_cp_0 () == -1) {
7330 printf ("test_cp_0 FAILED\n");
7334 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
7335 if (test_cp_1 () == -1) {
7336 printf ("test_cp_1 FAILED\n");
7340 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
7341 if (test_cp_2 () == -1) {
7342 printf ("test_cp_2 FAILED\n");
7346 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
7347 if (test_grub_install_0 () == -1) {
7348 printf ("test_grub_install_0 FAILED\n");
7352 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
7353 if (test_zero_0 () == -1) {
7354 printf ("test_zero_0 FAILED\n");
7358 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
7359 if (test_fsck_0 () == -1) {
7360 printf ("test_fsck_0 FAILED\n");
7364 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
7365 if (test_fsck_1 () == -1) {
7366 printf ("test_fsck_1 FAILED\n");
7370 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
7371 if (test_set_e2uuid_0 () == -1) {
7372 printf ("test_set_e2uuid_0 FAILED\n");
7376 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
7377 if (test_set_e2uuid_1 () == -1) {
7378 printf ("test_set_e2uuid_1 FAILED\n");
7382 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
7383 if (test_set_e2uuid_2 () == -1) {
7384 printf ("test_set_e2uuid_2 FAILED\n");
7388 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
7389 if (test_set_e2uuid_3 () == -1) {
7390 printf ("test_set_e2uuid_3 FAILED\n");
7394 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
7395 if (test_set_e2label_0 () == -1) {
7396 printf ("test_set_e2label_0 FAILED\n");
7400 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
7401 if (test_pvremove_0 () == -1) {
7402 printf ("test_pvremove_0 FAILED\n");
7406 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
7407 if (test_pvremove_1 () == -1) {
7408 printf ("test_pvremove_1 FAILED\n");
7412 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
7413 if (test_pvremove_2 () == -1) {
7414 printf ("test_pvremove_2 FAILED\n");
7418 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
7419 if (test_vgremove_0 () == -1) {
7420 printf ("test_vgremove_0 FAILED\n");
7424 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
7425 if (test_vgremove_1 () == -1) {
7426 printf ("test_vgremove_1 FAILED\n");
7430 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
7431 if (test_lvremove_0 () == -1) {
7432 printf ("test_lvremove_0 FAILED\n");
7436 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
7437 if (test_lvremove_1 () == -1) {
7438 printf ("test_lvremove_1 FAILED\n");
7442 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
7443 if (test_lvremove_2 () == -1) {
7444 printf ("test_lvremove_2 FAILED\n");
7448 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
7449 if (test_mount_ro_0 () == -1) {
7450 printf ("test_mount_ro_0 FAILED\n");
7454 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
7455 if (test_mount_ro_1 () == -1) {
7456 printf ("test_mount_ro_1 FAILED\n");
7460 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
7461 if (test_tgz_in_0 () == -1) {
7462 printf ("test_tgz_in_0 FAILED\n");
7466 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
7467 if (test_tar_in_0 () == -1) {
7468 printf ("test_tar_in_0 FAILED\n");
7472 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
7473 if (test_checksum_0 () == -1) {
7474 printf ("test_checksum_0 FAILED\n");
7478 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
7479 if (test_checksum_1 () == -1) {
7480 printf ("test_checksum_1 FAILED\n");
7484 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
7485 if (test_checksum_2 () == -1) {
7486 printf ("test_checksum_2 FAILED\n");
7490 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
7491 if (test_checksum_3 () == -1) {
7492 printf ("test_checksum_3 FAILED\n");
7496 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
7497 if (test_checksum_4 () == -1) {
7498 printf ("test_checksum_4 FAILED\n");
7502 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
7503 if (test_checksum_5 () == -1) {
7504 printf ("test_checksum_5 FAILED\n");
7508 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
7509 if (test_checksum_6 () == -1) {
7510 printf ("test_checksum_6 FAILED\n");
7514 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
7515 if (test_checksum_7 () == -1) {
7516 printf ("test_checksum_7 FAILED\n");
7520 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
7521 if (test_download_0 () == -1) {
7522 printf ("test_download_0 FAILED\n");
7526 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
7527 if (test_upload_0 () == -1) {
7528 printf ("test_upload_0 FAILED\n");
7532 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
7533 if (test_blockdev_rereadpt_0 () == -1) {
7534 printf ("test_blockdev_rereadpt_0 FAILED\n");
7538 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
7539 if (test_blockdev_flushbufs_0 () == -1) {
7540 printf ("test_blockdev_flushbufs_0 FAILED\n");
7544 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
7545 if (test_blockdev_getsize64_0 () == -1) {
7546 printf ("test_blockdev_getsize64_0 FAILED\n");
7550 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
7551 if (test_blockdev_getsz_0 () == -1) {
7552 printf ("test_blockdev_getsz_0 FAILED\n");
7556 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
7557 if (test_blockdev_getbsz_0 () == -1) {
7558 printf ("test_blockdev_getbsz_0 FAILED\n");
7562 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
7563 if (test_blockdev_getss_0 () == -1) {
7564 printf ("test_blockdev_getss_0 FAILED\n");
7568 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
7569 if (test_blockdev_getro_0 () == -1) {
7570 printf ("test_blockdev_getro_0 FAILED\n");
7574 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
7575 if (test_blockdev_setrw_0 () == -1) {
7576 printf ("test_blockdev_setrw_0 FAILED\n");
7580 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
7581 if (test_blockdev_setro_0 () == -1) {
7582 printf ("test_blockdev_setro_0 FAILED\n");
7586 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
7587 if (test_statvfs_0 () == -1) {
7588 printf ("test_statvfs_0 FAILED\n");
7592 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
7593 if (test_lstat_0 () == -1) {
7594 printf ("test_lstat_0 FAILED\n");
7598 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
7599 if (test_stat_0 () == -1) {
7600 printf ("test_stat_0 FAILED\n");
7604 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
7605 if (test_file_0 () == -1) {
7606 printf ("test_file_0 FAILED\n");
7610 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
7611 if (test_file_1 () == -1) {
7612 printf ("test_file_1 FAILED\n");
7616 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
7617 if (test_file_2 () == -1) {
7618 printf ("test_file_2 FAILED\n");
7622 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
7623 if (test_umount_all_0 () == -1) {
7624 printf ("test_umount_all_0 FAILED\n");
7628 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
7629 if (test_umount_all_1 () == -1) {
7630 printf ("test_umount_all_1 FAILED\n");
7634 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
7635 if (test_mounts_0 () == -1) {
7636 printf ("test_mounts_0 FAILED\n");
7640 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
7641 if (test_umount_0 () == -1) {
7642 printf ("test_umount_0 FAILED\n");
7646 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
7647 if (test_umount_1 () == -1) {
7648 printf ("test_umount_1 FAILED\n");
7652 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
7653 if (test_write_file_0 () == -1) {
7654 printf ("test_write_file_0 FAILED\n");
7658 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
7659 if (test_write_file_1 () == -1) {
7660 printf ("test_write_file_1 FAILED\n");
7664 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
7665 if (test_write_file_2 () == -1) {
7666 printf ("test_write_file_2 FAILED\n");
7670 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
7671 if (test_write_file_3 () == -1) {
7672 printf ("test_write_file_3 FAILED\n");
7676 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
7677 if (test_write_file_4 () == -1) {
7678 printf ("test_write_file_4 FAILED\n");
7682 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
7683 if (test_write_file_5 () == -1) {
7684 printf ("test_write_file_5 FAILED\n");
7688 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
7689 if (test_mkfs_0 () == -1) {
7690 printf ("test_mkfs_0 FAILED\n");
7694 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
7695 if (test_lvcreate_0 () == -1) {
7696 printf ("test_lvcreate_0 FAILED\n");
7700 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
7701 if (test_vgcreate_0 () == -1) {
7702 printf ("test_vgcreate_0 FAILED\n");
7706 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
7707 if (test_pvcreate_0 () == -1) {
7708 printf ("test_pvcreate_0 FAILED\n");
7712 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
7713 if (test_is_dir_0 () == -1) {
7714 printf ("test_is_dir_0 FAILED\n");
7718 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
7719 if (test_is_dir_1 () == -1) {
7720 printf ("test_is_dir_1 FAILED\n");
7724 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
7725 if (test_is_file_0 () == -1) {
7726 printf ("test_is_file_0 FAILED\n");
7730 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
7731 if (test_is_file_1 () == -1) {
7732 printf ("test_is_file_1 FAILED\n");
7736 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
7737 if (test_exists_0 () == -1) {
7738 printf ("test_exists_0 FAILED\n");
7742 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
7743 if (test_exists_1 () == -1) {
7744 printf ("test_exists_1 FAILED\n");
7748 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
7749 if (test_mkdir_p_0 () == -1) {
7750 printf ("test_mkdir_p_0 FAILED\n");
7754 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
7755 if (test_mkdir_p_1 () == -1) {
7756 printf ("test_mkdir_p_1 FAILED\n");
7760 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
7761 if (test_mkdir_p_2 () == -1) {
7762 printf ("test_mkdir_p_2 FAILED\n");
7766 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
7767 if (test_mkdir_0 () == -1) {
7768 printf ("test_mkdir_0 FAILED\n");
7772 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
7773 if (test_mkdir_1 () == -1) {
7774 printf ("test_mkdir_1 FAILED\n");
7778 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
7779 if (test_rm_rf_0 () == -1) {
7780 printf ("test_rm_rf_0 FAILED\n");
7784 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
7785 if (test_rmdir_0 () == -1) {
7786 printf ("test_rmdir_0 FAILED\n");
7790 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
7791 if (test_rmdir_1 () == -1) {
7792 printf ("test_rmdir_1 FAILED\n");
7796 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
7797 if (test_rmdir_2 () == -1) {
7798 printf ("test_rmdir_2 FAILED\n");
7802 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
7803 if (test_rm_0 () == -1) {
7804 printf ("test_rm_0 FAILED\n");
7808 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
7809 if (test_rm_1 () == -1) {
7810 printf ("test_rm_1 FAILED\n");
7814 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
7815 if (test_rm_2 () == -1) {
7816 printf ("test_rm_2 FAILED\n");
7820 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
7821 if (test_read_lines_0 () == -1) {
7822 printf ("test_read_lines_0 FAILED\n");
7826 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
7827 if (test_read_lines_1 () == -1) {
7828 printf ("test_read_lines_1 FAILED\n");
7832 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
7833 if (test_lvs_0 () == -1) {
7834 printf ("test_lvs_0 FAILED\n");
7838 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
7839 if (test_lvs_1 () == -1) {
7840 printf ("test_lvs_1 FAILED\n");
7844 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
7845 if (test_vgs_0 () == -1) {
7846 printf ("test_vgs_0 FAILED\n");
7850 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
7851 if (test_vgs_1 () == -1) {
7852 printf ("test_vgs_1 FAILED\n");
7856 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
7857 if (test_pvs_0 () == -1) {
7858 printf ("test_pvs_0 FAILED\n");
7862 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
7863 if (test_pvs_1 () == -1) {
7864 printf ("test_pvs_1 FAILED\n");
7868 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
7869 if (test_list_partitions_0 () == -1) {
7870 printf ("test_list_partitions_0 FAILED\n");
7874 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
7875 if (test_list_partitions_1 () == -1) {
7876 printf ("test_list_partitions_1 FAILED\n");
7880 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
7881 if (test_list_devices_0 () == -1) {
7882 printf ("test_list_devices_0 FAILED\n");
7886 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
7887 if (test_ls_0 () == -1) {
7888 printf ("test_ls_0 FAILED\n");
7892 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
7893 if (test_cat_0 () == -1) {
7894 printf ("test_cat_0 FAILED\n");
7898 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
7899 if (test_touch_0 () == -1) {
7900 printf ("test_touch_0 FAILED\n");
7904 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
7905 if (test_sync_0 () == -1) {
7906 printf ("test_sync_0 FAILED\n");
7910 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
7911 if (test_mount_0 () == -1) {
7912 printf ("test_mount_0 FAILED\n");
7917 unlink ("test1.img");
7918 unlink ("test2.img");
7919 unlink ("test3.img");
7922 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);