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_grub_install_0 (void)
117 /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
121 r = guestfs_umount_all (g);
128 r = guestfs_lvm_remove_all (g);
139 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
146 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
153 r = guestfs_mount (g, "/dev/sda1", "/");
157 /* TestOutputTrue for grub_install (0) */
161 r = guestfs_grub_install (g, "/", "/dev/sda1");
168 r = guestfs_is_dir (g, "/boot");
172 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
179 static int test_zero_0 (void)
181 /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
185 r = guestfs_umount_all (g);
192 r = guestfs_lvm_remove_all (g);
203 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
210 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
217 r = guestfs_mount (g, "/dev/sda1", "/");
221 /* TestOutput for zero (0) */
225 r = guestfs_umount (g, "/dev/sda1");
232 r = guestfs_zero (g, "/dev/sda1");
239 r = guestfs_file (g, "/dev/sda1");
242 if (strcmp (r, "data") != 0) {
243 fprintf (stderr, "test_zero_0: expected \"data\" but got \"%s\"\n", r);
251 static int test_fsck_0 (void)
253 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
257 r = guestfs_umount_all (g);
264 r = guestfs_lvm_remove_all (g);
275 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
282 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
289 r = guestfs_mount (g, "/dev/sda1", "/");
293 /* TestOutputInt for fsck (0) */
297 r = guestfs_umount (g, "/dev/sda1");
304 r = guestfs_fsck (g, "ext2", "/dev/sda1");
308 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
315 static int test_fsck_1 (void)
317 /* InitBasicFS for fsck (1): 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 /* TestOutputInt for fsck (1) */
361 r = guestfs_umount (g, "/dev/sda1");
368 r = guestfs_zero (g, "/dev/sda1");
375 r = guestfs_fsck (g, "ext2", "/dev/sda1");
379 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
386 static int test_set_e2uuid_0 (void)
388 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
392 r = guestfs_umount_all (g);
399 r = guestfs_lvm_remove_all (g);
410 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
417 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
424 r = guestfs_mount (g, "/dev/sda1", "/");
428 /* TestOutput for set_e2uuid (0) */
432 r = guestfs_set_e2uuid (g, "/dev/sda1", "a3a61220-882b-4f61-89f4-cf24dcc7297d");
439 r = guestfs_get_e2uuid (g, "/dev/sda1");
442 if (strcmp (r, "a3a61220-882b-4f61-89f4-cf24dcc7297d") != 0) {
443 fprintf (stderr, "test_set_e2uuid_0: expected \"a3a61220-882b-4f61-89f4-cf24dcc7297d\" but got \"%s\"\n", r);
451 static int test_set_e2uuid_1 (void)
453 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
457 r = guestfs_umount_all (g);
464 r = guestfs_lvm_remove_all (g);
475 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
482 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
489 r = guestfs_mount (g, "/dev/sda1", "/");
493 /* TestOutput for set_e2uuid (1) */
497 r = guestfs_set_e2uuid (g, "/dev/sda1", "clear");
504 r = guestfs_get_e2uuid (g, "/dev/sda1");
507 if (strcmp (r, "") != 0) {
508 fprintf (stderr, "test_set_e2uuid_1: expected \"\" but got \"%s\"\n", r);
516 static int test_set_e2uuid_2 (void)
518 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
522 r = guestfs_umount_all (g);
529 r = guestfs_lvm_remove_all (g);
540 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
547 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
554 r = guestfs_mount (g, "/dev/sda1", "/");
558 /* TestRun for set_e2uuid (2) */
562 r = guestfs_set_e2uuid (g, "/dev/sda1", "random");
569 static int test_set_e2uuid_3 (void)
571 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
575 r = guestfs_umount_all (g);
582 r = guestfs_lvm_remove_all (g);
593 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
600 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
607 r = guestfs_mount (g, "/dev/sda1", "/");
611 /* TestRun for set_e2uuid (3) */
615 r = guestfs_set_e2uuid (g, "/dev/sda1", "time");
622 static int test_set_e2label_0 (void)
624 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
628 r = guestfs_umount_all (g);
635 r = guestfs_lvm_remove_all (g);
646 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
653 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
660 r = guestfs_mount (g, "/dev/sda1", "/");
664 /* TestOutput for set_e2label (0) */
668 r = guestfs_set_e2label (g, "/dev/sda1", "testlabel");
675 r = guestfs_get_e2label (g, "/dev/sda1");
678 if (strcmp (r, "testlabel") != 0) {
679 fprintf (stderr, "test_set_e2label_0: expected \"testlabel\" but got \"%s\"\n", r);
687 static int test_pvremove_0 (void)
689 /* InitEmpty for pvremove (0) */
693 r = guestfs_umount_all (g);
700 r = guestfs_lvm_remove_all (g);
704 /* TestOutputList for pvremove (0) */
708 r = guestfs_pvcreate (g, "/dev/sda");
719 r = guestfs_vgcreate (g, "VG", physvols);
726 r = guestfs_lvcreate (g, "LV1", "VG", 50);
733 r = guestfs_lvcreate (g, "LV2", "VG", 50);
740 r = guestfs_vgremove (g, "VG");
747 r = guestfs_pvremove (g, "/dev/sda");
759 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
763 for (i = 0; r[i] != NULL; ++i)
770 static int test_pvremove_1 (void)
772 /* InitEmpty for pvremove (1) */
776 r = guestfs_umount_all (g);
783 r = guestfs_lvm_remove_all (g);
787 /* TestOutputList for pvremove (1) */
791 r = guestfs_pvcreate (g, "/dev/sda");
802 r = guestfs_vgcreate (g, "VG", physvols);
809 r = guestfs_lvcreate (g, "LV1", "VG", 50);
816 r = guestfs_lvcreate (g, "LV2", "VG", 50);
823 r = guestfs_vgremove (g, "VG");
830 r = guestfs_pvremove (g, "/dev/sda");
842 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
846 for (i = 0; r[i] != NULL; ++i)
853 static int test_pvremove_2 (void)
855 /* InitEmpty for pvremove (2) */
859 r = guestfs_umount_all (g);
866 r = guestfs_lvm_remove_all (g);
870 /* TestOutputList for pvremove (2) */
874 r = guestfs_pvcreate (g, "/dev/sda");
885 r = guestfs_vgcreate (g, "VG", physvols);
892 r = guestfs_lvcreate (g, "LV1", "VG", 50);
899 r = guestfs_lvcreate (g, "LV2", "VG", 50);
906 r = guestfs_vgremove (g, "VG");
913 r = guestfs_pvremove (g, "/dev/sda");
925 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
929 for (i = 0; r[i] != NULL; ++i)
936 static int test_vgremove_0 (void)
938 /* InitEmpty for vgremove (0) */
942 r = guestfs_umount_all (g);
949 r = guestfs_lvm_remove_all (g);
953 /* TestOutputList for vgremove (0) */
957 r = guestfs_pvcreate (g, "/dev/sda");
968 r = guestfs_vgcreate (g, "VG", physvols);
975 r = guestfs_lvcreate (g, "LV1", "VG", 50);
982 r = guestfs_lvcreate (g, "LV2", "VG", 50);
989 r = guestfs_vgremove (g, "VG");
1001 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
1005 for (i = 0; r[i] != NULL; ++i)
1012 static int test_vgremove_1 (void)
1014 /* InitEmpty for vgremove (1) */
1018 r = guestfs_umount_all (g);
1025 r = guestfs_lvm_remove_all (g);
1029 /* TestOutputList for vgremove (1) */
1033 r = guestfs_pvcreate (g, "/dev/sda");
1038 char *physvols[] = {
1044 r = guestfs_vgcreate (g, "VG", physvols);
1051 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1058 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1065 r = guestfs_vgremove (g, "VG");
1073 r = guestfs_vgs (g);
1077 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
1081 for (i = 0; r[i] != NULL; ++i)
1088 static int test_lvremove_0 (void)
1090 /* InitEmpty for lvremove (0) */
1094 r = guestfs_umount_all (g);
1101 r = guestfs_lvm_remove_all (g);
1105 /* TestOutputList for lvremove (0) */
1109 r = guestfs_pvcreate (g, "/dev/sda");
1114 char *physvols[] = {
1120 r = guestfs_vgcreate (g, "VG", physvols);
1127 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1134 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1141 r = guestfs_lvremove (g, "/dev/VG/LV1");
1149 r = guestfs_lvs (g);
1153 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
1157 if (strcmp (r[0], "/dev/VG/LV2") != 0) {
1158 fprintf (stderr, "test_lvremove_0: expected \"/dev/VG/LV2\" but got \"%s\"\n", r[0]);
1162 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
1166 for (i = 0; r[i] != NULL; ++i)
1173 static int test_lvremove_1 (void)
1175 /* InitEmpty for lvremove (1) */
1179 r = guestfs_umount_all (g);
1186 r = guestfs_lvm_remove_all (g);
1190 /* TestOutputList for lvremove (1) */
1194 r = guestfs_pvcreate (g, "/dev/sda");
1199 char *physvols[] = {
1205 r = guestfs_vgcreate (g, "VG", physvols);
1212 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1219 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1226 r = guestfs_lvremove (g, "/dev/VG");
1234 r = guestfs_lvs (g);
1238 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
1242 for (i = 0; r[i] != NULL; ++i)
1249 static int test_lvremove_2 (void)
1251 /* InitEmpty for lvremove (2) */
1255 r = guestfs_umount_all (g);
1262 r = guestfs_lvm_remove_all (g);
1266 /* TestOutputList for lvremove (2) */
1270 r = guestfs_pvcreate (g, "/dev/sda");
1275 char *physvols[] = {
1281 r = guestfs_vgcreate (g, "VG", physvols);
1288 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1295 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1302 r = guestfs_lvremove (g, "/dev/VG");
1310 r = guestfs_vgs (g);
1314 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
1318 if (strcmp (r[0], "VG") != 0) {
1319 fprintf (stderr, "test_lvremove_2: expected \"VG\" but got \"%s\"\n", r[0]);
1323 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
1327 for (i = 0; r[i] != NULL; ++i)
1334 static int test_mount_ro_0 (void)
1336 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
1340 r = guestfs_umount_all (g);
1347 r = guestfs_lvm_remove_all (g);
1358 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1365 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1372 r = guestfs_mount (g, "/dev/sda1", "/");
1376 /* TestLastFail for mount_ro (0) */
1380 r = guestfs_umount (g, "/");
1387 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1394 r = guestfs_touch (g, "/new");
1401 static int test_mount_ro_1 (void)
1403 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
1407 r = guestfs_umount_all (g);
1414 r = guestfs_lvm_remove_all (g);
1425 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1432 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1439 r = guestfs_mount (g, "/dev/sda1", "/");
1443 /* TestOutput for mount_ro (1) */
1447 r = guestfs_write_file (g, "/new", "data", 0);
1454 r = guestfs_umount (g, "/");
1461 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1468 r = guestfs_cat (g, "/new");
1471 if (strcmp (r, "data") != 0) {
1472 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
1480 static int test_tgz_in_0 (void)
1482 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
1486 r = guestfs_umount_all (g);
1493 r = guestfs_lvm_remove_all (g);
1504 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1511 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1518 r = guestfs_mount (g, "/dev/sda1", "/");
1522 /* TestOutput for tgz_in (0) */
1526 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
1533 r = guestfs_cat (g, "/hello");
1536 if (strcmp (r, "hello\n") != 0) {
1537 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
1545 static int test_tar_in_0 (void)
1547 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
1551 r = guestfs_umount_all (g);
1558 r = guestfs_lvm_remove_all (g);
1569 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1576 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1583 r = guestfs_mount (g, "/dev/sda1", "/");
1587 /* TestOutput for tar_in (0) */
1591 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
1598 r = guestfs_cat (g, "/hello");
1601 if (strcmp (r, "hello\n") != 0) {
1602 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
1610 static int test_checksum_0 (void)
1612 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
1616 r = guestfs_umount_all (g);
1623 r = guestfs_lvm_remove_all (g);
1634 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1641 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1648 r = guestfs_mount (g, "/dev/sda1", "/");
1652 /* TestOutput for checksum (0) */
1656 r = guestfs_write_file (g, "/new", "test\n", 0);
1663 r = guestfs_checksum (g, "crc", "/new");
1666 if (strcmp (r, "935282863") != 0) {
1667 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
1675 static int test_checksum_1 (void)
1677 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
1681 r = guestfs_umount_all (g);
1688 r = guestfs_lvm_remove_all (g);
1699 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1706 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1713 r = guestfs_mount (g, "/dev/sda1", "/");
1717 /* TestLastFail for checksum (1) */
1721 r = guestfs_checksum (g, "crc", "/new");
1729 static int test_checksum_2 (void)
1731 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
1735 r = guestfs_umount_all (g);
1742 r = guestfs_lvm_remove_all (g);
1753 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1760 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1767 r = guestfs_mount (g, "/dev/sda1", "/");
1771 /* TestOutput for checksum (2) */
1775 r = guestfs_write_file (g, "/new", "test\n", 0);
1782 r = guestfs_checksum (g, "md5", "/new");
1785 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
1786 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
1794 static int test_checksum_3 (void)
1796 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
1800 r = guestfs_umount_all (g);
1807 r = guestfs_lvm_remove_all (g);
1818 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1825 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1832 r = guestfs_mount (g, "/dev/sda1", "/");
1836 /* TestOutput for checksum (3) */
1840 r = guestfs_write_file (g, "/new", "test\n", 0);
1847 r = guestfs_checksum (g, "sha1", "/new");
1850 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
1851 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
1859 static int test_checksum_4 (void)
1861 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
1865 r = guestfs_umount_all (g);
1872 r = guestfs_lvm_remove_all (g);
1883 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1890 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1897 r = guestfs_mount (g, "/dev/sda1", "/");
1901 /* TestOutput for checksum (4) */
1905 r = guestfs_write_file (g, "/new", "test\n", 0);
1912 r = guestfs_checksum (g, "sha224", "/new");
1915 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
1916 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
1924 static int test_checksum_5 (void)
1926 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
1930 r = guestfs_umount_all (g);
1937 r = guestfs_lvm_remove_all (g);
1948 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1955 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1962 r = guestfs_mount (g, "/dev/sda1", "/");
1966 /* TestOutput for checksum (5) */
1970 r = guestfs_write_file (g, "/new", "test\n", 0);
1977 r = guestfs_checksum (g, "sha256", "/new");
1980 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
1981 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
1989 static int test_checksum_6 (void)
1991 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
1995 r = guestfs_umount_all (g);
2002 r = guestfs_lvm_remove_all (g);
2013 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2020 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2027 r = guestfs_mount (g, "/dev/sda1", "/");
2031 /* TestOutput for checksum (6) */
2035 r = guestfs_write_file (g, "/new", "test\n", 0);
2042 r = guestfs_checksum (g, "sha384", "/new");
2045 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
2046 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
2054 static int test_checksum_7 (void)
2056 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
2060 r = guestfs_umount_all (g);
2067 r = guestfs_lvm_remove_all (g);
2078 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2085 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2092 r = guestfs_mount (g, "/dev/sda1", "/");
2096 /* TestOutput for checksum (7) */
2100 r = guestfs_write_file (g, "/new", "test\n", 0);
2107 r = guestfs_checksum (g, "sha512", "/new");
2110 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
2111 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
2119 static int test_download_0 (void)
2121 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
2125 r = guestfs_umount_all (g);
2132 r = guestfs_lvm_remove_all (g);
2143 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2150 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2157 r = guestfs_mount (g, "/dev/sda1", "/");
2161 /* TestOutput for download (0) */
2165 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2172 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
2179 r = guestfs_upload (g, "testdownload.tmp", "/upload");
2186 r = guestfs_checksum (g, "md5", "/upload");
2189 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2190 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2198 static int test_upload_0 (void)
2200 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
2204 r = guestfs_umount_all (g);
2211 r = guestfs_lvm_remove_all (g);
2222 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2229 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2236 r = guestfs_mount (g, "/dev/sda1", "/");
2240 /* TestOutput for upload (0) */
2244 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2251 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
2254 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2255 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2263 static int test_blockdev_rereadpt_0 (void)
2265 /* InitEmpty for blockdev_rereadpt (0) */
2269 r = guestfs_umount_all (g);
2276 r = guestfs_lvm_remove_all (g);
2280 /* TestRun for blockdev_rereadpt (0) */
2284 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
2291 static int test_blockdev_flushbufs_0 (void)
2293 /* InitEmpty for blockdev_flushbufs (0) */
2297 r = guestfs_umount_all (g);
2304 r = guestfs_lvm_remove_all (g);
2308 /* TestRun for blockdev_flushbufs (0) */
2312 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
2319 static int test_blockdev_getsize64_0 (void)
2321 /* InitEmpty for blockdev_getsize64 (0) */
2325 r = guestfs_umount_all (g);
2332 r = guestfs_lvm_remove_all (g);
2336 /* TestOutputInt for blockdev_getsize64 (0) */
2340 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
2343 if (r != 524288000) {
2344 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
2351 static int test_blockdev_getsz_0 (void)
2353 /* InitEmpty for blockdev_getsz (0) */
2357 r = guestfs_umount_all (g);
2364 r = guestfs_lvm_remove_all (g);
2368 /* TestOutputInt for blockdev_getsz (0) */
2372 r = guestfs_blockdev_getsz (g, "/dev/sda");
2376 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
2383 static int test_blockdev_getbsz_0 (void)
2385 /* InitEmpty for blockdev_getbsz (0) */
2389 r = guestfs_umount_all (g);
2396 r = guestfs_lvm_remove_all (g);
2400 /* TestOutputInt for blockdev_getbsz (0) */
2404 r = guestfs_blockdev_getbsz (g, "/dev/sda");
2408 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
2415 static int test_blockdev_getss_0 (void)
2417 /* InitEmpty for blockdev_getss (0) */
2421 r = guestfs_umount_all (g);
2428 r = guestfs_lvm_remove_all (g);
2432 /* TestOutputInt for blockdev_getss (0) */
2436 r = guestfs_blockdev_getss (g, "/dev/sda");
2440 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
2447 static int test_blockdev_getro_0 (void)
2449 /* InitEmpty for blockdev_getro (0) */
2453 r = guestfs_umount_all (g);
2460 r = guestfs_lvm_remove_all (g);
2464 /* TestOutputTrue for blockdev_getro (0) */
2468 r = guestfs_blockdev_setro (g, "/dev/sda");
2475 r = guestfs_blockdev_getro (g, "/dev/sda");
2479 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
2486 static int test_blockdev_setrw_0 (void)
2488 /* InitEmpty for blockdev_setrw (0) */
2492 r = guestfs_umount_all (g);
2499 r = guestfs_lvm_remove_all (g);
2503 /* TestOutputFalse for blockdev_setrw (0) */
2507 r = guestfs_blockdev_setrw (g, "/dev/sda");
2514 r = guestfs_blockdev_getro (g, "/dev/sda");
2518 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
2525 static int test_blockdev_setro_0 (void)
2527 /* InitEmpty for blockdev_setro (0) */
2531 r = guestfs_umount_all (g);
2538 r = guestfs_lvm_remove_all (g);
2542 /* TestOutputTrue for blockdev_setro (0) */
2546 r = guestfs_blockdev_setro (g, "/dev/sda");
2553 r = guestfs_blockdev_getro (g, "/dev/sda");
2557 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
2564 static int test_statvfs_0 (void)
2566 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
2570 r = guestfs_umount_all (g);
2577 r = guestfs_lvm_remove_all (g);
2588 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2595 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2602 r = guestfs_mount (g, "/dev/sda1", "/");
2606 /* TestOutputStruct for statvfs (0) */
2608 struct guestfs_statvfs *r;
2610 r = guestfs_statvfs (g, "/");
2613 if (r->bfree != 487702) {
2614 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
2618 if (r->blocks != 490020) {
2619 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
2623 if (r->bsize != 1024) {
2624 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
2633 static int test_lstat_0 (void)
2635 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
2639 r = guestfs_umount_all (g);
2646 r = guestfs_lvm_remove_all (g);
2657 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2664 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2671 r = guestfs_mount (g, "/dev/sda1", "/");
2675 /* TestOutputStruct for lstat (0) */
2679 r = guestfs_touch (g, "/new");
2684 struct guestfs_stat *r;
2686 r = guestfs_lstat (g, "/new");
2690 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
2699 static int test_stat_0 (void)
2701 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
2705 r = guestfs_umount_all (g);
2712 r = guestfs_lvm_remove_all (g);
2723 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2730 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2737 r = guestfs_mount (g, "/dev/sda1", "/");
2741 /* TestOutputStruct for stat (0) */
2745 r = guestfs_touch (g, "/new");
2750 struct guestfs_stat *r;
2752 r = guestfs_stat (g, "/new");
2756 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
2765 static int test_file_0 (void)
2767 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
2771 r = guestfs_umount_all (g);
2778 r = guestfs_lvm_remove_all (g);
2789 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2796 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2803 r = guestfs_mount (g, "/dev/sda1", "/");
2807 /* TestOutput for file (0) */
2811 r = guestfs_touch (g, "/new");
2818 r = guestfs_file (g, "/new");
2821 if (strcmp (r, "empty") != 0) {
2822 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
2830 static int test_file_1 (void)
2832 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
2836 r = guestfs_umount_all (g);
2843 r = guestfs_lvm_remove_all (g);
2854 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2861 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2868 r = guestfs_mount (g, "/dev/sda1", "/");
2872 /* TestOutput for file (1) */
2876 r = guestfs_write_file (g, "/new", "some content\n", 0);
2883 r = guestfs_file (g, "/new");
2886 if (strcmp (r, "ASCII text") != 0) {
2887 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
2895 static int test_file_2 (void)
2897 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
2901 r = guestfs_umount_all (g);
2908 r = guestfs_lvm_remove_all (g);
2919 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2926 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2933 r = guestfs_mount (g, "/dev/sda1", "/");
2937 /* TestLastFail for file (2) */
2941 r = guestfs_file (g, "/nofile");
2949 static int test_umount_all_0 (void)
2951 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
2955 r = guestfs_umount_all (g);
2962 r = guestfs_lvm_remove_all (g);
2973 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2980 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2987 r = guestfs_mount (g, "/dev/sda1", "/");
2991 /* TestOutputList for umount_all (0) */
2995 r = guestfs_umount_all (g);
3003 r = guestfs_mounts (g);
3007 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
3011 for (i = 0; r[i] != NULL; ++i)
3018 static int test_umount_all_1 (void)
3020 /* InitEmpty for umount_all (1) */
3024 r = guestfs_umount_all (g);
3031 r = guestfs_lvm_remove_all (g);
3035 /* TestOutputList for umount_all (1) */
3045 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3052 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3059 r = guestfs_mkfs (g, "ext2", "/dev/sda2");
3066 r = guestfs_mkfs (g, "ext2", "/dev/sda3");
3073 r = guestfs_mount (g, "/dev/sda1", "/");
3080 r = guestfs_mkdir (g, "/mp1");
3087 r = guestfs_mount (g, "/dev/sda2", "/mp1");
3094 r = guestfs_mkdir (g, "/mp1/mp2");
3101 r = guestfs_mount (g, "/dev/sda3", "/mp1/mp2");
3108 r = guestfs_mkdir (g, "/mp1/mp2/mp3");
3115 r = guestfs_umount_all (g);
3123 r = guestfs_mounts (g);
3127 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
3131 for (i = 0; r[i] != NULL; ++i)
3138 static int test_mounts_0 (void)
3140 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
3144 r = guestfs_umount_all (g);
3151 r = guestfs_lvm_remove_all (g);
3162 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3169 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3176 r = guestfs_mount (g, "/dev/sda1", "/");
3180 /* TestOutputList for mounts (0) */
3185 r = guestfs_mounts (g);
3189 fprintf (stderr, "test_mounts_0: short list returned from command\n");
3193 if (strcmp (r[0], "/dev/sda1") != 0) {
3194 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3198 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
3202 for (i = 0; r[i] != NULL; ++i)
3209 static int test_umount_0 (void)
3211 /* InitEmpty for umount (0) */
3215 r = guestfs_umount_all (g);
3222 r = guestfs_lvm_remove_all (g);
3226 /* TestOutputList for umount (0) */
3234 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3241 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3248 r = guestfs_mount (g, "/dev/sda1", "/");
3256 r = guestfs_mounts (g);
3260 fprintf (stderr, "test_umount_0: short list returned from command\n");
3264 if (strcmp (r[0], "/dev/sda1") != 0) {
3265 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3269 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
3273 for (i = 0; r[i] != NULL; ++i)
3280 static int test_umount_1 (void)
3282 /* InitEmpty for umount (1) */
3286 r = guestfs_umount_all (g);
3293 r = guestfs_lvm_remove_all (g);
3297 /* TestOutputList for umount (1) */
3305 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3312 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3319 r = guestfs_mount (g, "/dev/sda1", "/");
3326 r = guestfs_umount (g, "/");
3334 r = guestfs_mounts (g);
3338 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
3342 for (i = 0; r[i] != NULL; ++i)
3349 static int test_write_file_0 (void)
3351 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
3355 r = guestfs_umount_all (g);
3362 r = guestfs_lvm_remove_all (g);
3373 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3380 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3387 r = guestfs_mount (g, "/dev/sda1", "/");
3391 /* TestOutput for write_file (0) */
3395 r = guestfs_write_file (g, "/new", "new file contents", 0);
3402 r = guestfs_cat (g, "/new");
3405 if (strcmp (r, "new file contents") != 0) {
3406 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
3414 static int test_write_file_1 (void)
3416 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
3420 r = guestfs_umount_all (g);
3427 r = guestfs_lvm_remove_all (g);
3438 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3445 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3452 r = guestfs_mount (g, "/dev/sda1", "/");
3456 /* TestOutput for write_file (1) */
3460 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
3467 r = guestfs_cat (g, "/new");
3470 if (strcmp (r, "\nnew file contents\n") != 0) {
3471 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
3479 static int test_write_file_2 (void)
3481 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
3485 r = guestfs_umount_all (g);
3492 r = guestfs_lvm_remove_all (g);
3503 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3510 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3517 r = guestfs_mount (g, "/dev/sda1", "/");
3521 /* TestOutput for write_file (2) */
3525 r = guestfs_write_file (g, "/new", "\n\n", 0);
3532 r = guestfs_cat (g, "/new");
3535 if (strcmp (r, "\n\n") != 0) {
3536 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
3544 static int test_write_file_3 (void)
3546 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
3550 r = guestfs_umount_all (g);
3557 r = guestfs_lvm_remove_all (g);
3568 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3575 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3582 r = guestfs_mount (g, "/dev/sda1", "/");
3586 /* TestOutput for write_file (3) */
3590 r = guestfs_write_file (g, "/new", "", 0);
3597 r = guestfs_cat (g, "/new");
3600 if (strcmp (r, "") != 0) {
3601 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
3609 static int test_write_file_4 (void)
3611 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
3615 r = guestfs_umount_all (g);
3622 r = guestfs_lvm_remove_all (g);
3633 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3640 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3647 r = guestfs_mount (g, "/dev/sda1", "/");
3651 /* TestOutput for write_file (4) */
3655 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
3662 r = guestfs_cat (g, "/new");
3665 if (strcmp (r, "\n\n\n") != 0) {
3666 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
3674 static int test_write_file_5 (void)
3676 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
3680 r = guestfs_umount_all (g);
3687 r = guestfs_lvm_remove_all (g);
3698 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3705 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3712 r = guestfs_mount (g, "/dev/sda1", "/");
3716 /* TestOutput for write_file (5) */
3720 r = guestfs_write_file (g, "/new", "\n", 0);
3727 r = guestfs_cat (g, "/new");
3730 if (strcmp (r, "\n") != 0) {
3731 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
3739 static int test_mkfs_0 (void)
3741 /* InitEmpty for mkfs (0) */
3745 r = guestfs_umount_all (g);
3752 r = guestfs_lvm_remove_all (g);
3756 /* TestOutput for mkfs (0) */
3764 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3771 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3778 r = guestfs_mount (g, "/dev/sda1", "/");
3785 r = guestfs_write_file (g, "/new", "new file contents", 0);
3792 r = guestfs_cat (g, "/new");
3795 if (strcmp (r, "new file contents") != 0) {
3796 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
3804 static int test_lvcreate_0 (void)
3806 /* InitEmpty for lvcreate (0) */
3810 r = guestfs_umount_all (g);
3817 r = guestfs_lvm_remove_all (g);
3821 /* TestOutputList for lvcreate (0) */
3831 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3838 r = guestfs_pvcreate (g, "/dev/sda1");
3845 r = guestfs_pvcreate (g, "/dev/sda2");
3852 r = guestfs_pvcreate (g, "/dev/sda3");
3857 char *physvols[] = {
3864 r = guestfs_vgcreate (g, "VG1", physvols);
3869 char *physvols[] = {
3875 r = guestfs_vgcreate (g, "VG2", physvols);
3882 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
3889 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
3896 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
3903 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
3910 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
3918 r = guestfs_lvs (g);
3922 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3926 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
3927 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
3931 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3935 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
3936 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
3940 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3944 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
3945 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
3949 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3953 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
3954 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
3958 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3962 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
3963 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
3967 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
3971 for (i = 0; r[i] != NULL; ++i)
3978 static int test_vgcreate_0 (void)
3980 /* InitEmpty for vgcreate (0) */
3984 r = guestfs_umount_all (g);
3991 r = guestfs_lvm_remove_all (g);
3995 /* TestOutputList for vgcreate (0) */
4005 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4012 r = guestfs_pvcreate (g, "/dev/sda1");
4019 r = guestfs_pvcreate (g, "/dev/sda2");
4026 r = guestfs_pvcreate (g, "/dev/sda3");
4031 char *physvols[] = {
4038 r = guestfs_vgcreate (g, "VG1", physvols);
4043 char *physvols[] = {
4049 r = guestfs_vgcreate (g, "VG2", physvols);
4057 r = guestfs_vgs (g);
4061 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4065 if (strcmp (r[0], "VG1") != 0) {
4066 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
4070 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4074 if (strcmp (r[1], "VG2") != 0) {
4075 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
4079 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
4083 for (i = 0; r[i] != NULL; ++i)
4090 static int test_pvcreate_0 (void)
4092 /* InitEmpty for pvcreate (0) */
4096 r = guestfs_umount_all (g);
4103 r = guestfs_lvm_remove_all (g);
4107 /* TestOutputList for pvcreate (0) */
4117 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4124 r = guestfs_pvcreate (g, "/dev/sda1");
4131 r = guestfs_pvcreate (g, "/dev/sda2");
4138 r = guestfs_pvcreate (g, "/dev/sda3");
4146 r = guestfs_pvs (g);
4150 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4154 if (strcmp (r[0], "/dev/sda1") != 0) {
4155 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4159 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4163 if (strcmp (r[1], "/dev/sda2") != 0) {
4164 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4168 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4172 if (strcmp (r[2], "/dev/sda3") != 0) {
4173 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4177 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
4181 for (i = 0; r[i] != NULL; ++i)
4188 static int test_is_dir_0 (void)
4190 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
4194 r = guestfs_umount_all (g);
4201 r = guestfs_lvm_remove_all (g);
4212 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4219 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4226 r = guestfs_mount (g, "/dev/sda1", "/");
4230 /* TestOutputFalse for is_dir (0) */
4234 r = guestfs_touch (g, "/new");
4241 r = guestfs_is_dir (g, "/new");
4245 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
4252 static int test_is_dir_1 (void)
4254 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
4258 r = guestfs_umount_all (g);
4265 r = guestfs_lvm_remove_all (g);
4276 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4283 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4290 r = guestfs_mount (g, "/dev/sda1", "/");
4294 /* TestOutputTrue for is_dir (1) */
4298 r = guestfs_mkdir (g, "/new");
4305 r = guestfs_is_dir (g, "/new");
4309 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
4316 static int test_is_file_0 (void)
4318 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
4322 r = guestfs_umount_all (g);
4329 r = guestfs_lvm_remove_all (g);
4340 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4347 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4354 r = guestfs_mount (g, "/dev/sda1", "/");
4358 /* TestOutputTrue for is_file (0) */
4362 r = guestfs_touch (g, "/new");
4369 r = guestfs_is_file (g, "/new");
4373 fprintf (stderr, "test_is_file_0: expected true, got false\n");
4380 static int test_is_file_1 (void)
4382 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
4386 r = guestfs_umount_all (g);
4393 r = guestfs_lvm_remove_all (g);
4404 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4411 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4418 r = guestfs_mount (g, "/dev/sda1", "/");
4422 /* TestOutputFalse for is_file (1) */
4426 r = guestfs_mkdir (g, "/new");
4433 r = guestfs_is_file (g, "/new");
4437 fprintf (stderr, "test_is_file_1: expected false, got true\n");
4444 static int test_exists_0 (void)
4446 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
4450 r = guestfs_umount_all (g);
4457 r = guestfs_lvm_remove_all (g);
4468 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4475 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4482 r = guestfs_mount (g, "/dev/sda1", "/");
4486 /* TestOutputTrue for exists (0) */
4490 r = guestfs_touch (g, "/new");
4497 r = guestfs_exists (g, "/new");
4501 fprintf (stderr, "test_exists_0: expected true, got false\n");
4508 static int test_exists_1 (void)
4510 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
4514 r = guestfs_umount_all (g);
4521 r = guestfs_lvm_remove_all (g);
4532 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4539 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4546 r = guestfs_mount (g, "/dev/sda1", "/");
4550 /* TestOutputTrue for exists (1) */
4554 r = guestfs_mkdir (g, "/new");
4561 r = guestfs_exists (g, "/new");
4565 fprintf (stderr, "test_exists_1: expected true, got false\n");
4572 static int test_mkdir_p_0 (void)
4574 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
4578 r = guestfs_umount_all (g);
4585 r = guestfs_lvm_remove_all (g);
4596 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4603 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4610 r = guestfs_mount (g, "/dev/sda1", "/");
4614 /* TestOutputTrue for mkdir_p (0) */
4618 r = guestfs_mkdir_p (g, "/new/foo/bar");
4625 r = guestfs_is_dir (g, "/new/foo/bar");
4629 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
4636 static int test_mkdir_p_1 (void)
4638 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
4642 r = guestfs_umount_all (g);
4649 r = guestfs_lvm_remove_all (g);
4660 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4667 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4674 r = guestfs_mount (g, "/dev/sda1", "/");
4678 /* TestOutputTrue for mkdir_p (1) */
4682 r = guestfs_mkdir_p (g, "/new/foo/bar");
4689 r = guestfs_is_dir (g, "/new/foo");
4693 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
4700 static int test_mkdir_p_2 (void)
4702 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
4706 r = guestfs_umount_all (g);
4713 r = guestfs_lvm_remove_all (g);
4724 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4731 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4738 r = guestfs_mount (g, "/dev/sda1", "/");
4742 /* TestOutputTrue for mkdir_p (2) */
4746 r = guestfs_mkdir_p (g, "/new/foo/bar");
4753 r = guestfs_is_dir (g, "/new");
4757 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
4764 static int test_mkdir_0 (void)
4766 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
4770 r = guestfs_umount_all (g);
4777 r = guestfs_lvm_remove_all (g);
4788 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4795 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4802 r = guestfs_mount (g, "/dev/sda1", "/");
4806 /* TestOutputTrue for mkdir (0) */
4810 r = guestfs_mkdir (g, "/new");
4817 r = guestfs_is_dir (g, "/new");
4821 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
4828 static int test_mkdir_1 (void)
4830 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
4834 r = guestfs_umount_all (g);
4841 r = guestfs_lvm_remove_all (g);
4852 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4859 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4866 r = guestfs_mount (g, "/dev/sda1", "/");
4870 /* TestLastFail for mkdir (1) */
4874 r = guestfs_mkdir (g, "/new/foo/bar");
4881 static int test_rm_rf_0 (void)
4883 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
4887 r = guestfs_umount_all (g);
4894 r = guestfs_lvm_remove_all (g);
4905 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4912 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4919 r = guestfs_mount (g, "/dev/sda1", "/");
4923 /* TestOutputFalse for rm_rf (0) */
4927 r = guestfs_mkdir (g, "/new");
4934 r = guestfs_mkdir (g, "/new/foo");
4941 r = guestfs_touch (g, "/new/foo/bar");
4948 r = guestfs_rm_rf (g, "/new");
4955 r = guestfs_exists (g, "/new");
4959 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
4966 static int test_rmdir_0 (void)
4968 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
4972 r = guestfs_umount_all (g);
4979 r = guestfs_lvm_remove_all (g);
4990 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4997 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5004 r = guestfs_mount (g, "/dev/sda1", "/");
5008 /* TestRun for rmdir (0) */
5012 r = guestfs_mkdir (g, "/new");
5019 r = guestfs_rmdir (g, "/new");
5026 static int test_rmdir_1 (void)
5028 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
5032 r = guestfs_umount_all (g);
5039 r = guestfs_lvm_remove_all (g);
5050 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5057 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5064 r = guestfs_mount (g, "/dev/sda1", "/");
5068 /* TestLastFail for rmdir (1) */
5072 r = guestfs_rmdir (g, "/new");
5079 static int test_rmdir_2 (void)
5081 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
5085 r = guestfs_umount_all (g);
5092 r = guestfs_lvm_remove_all (g);
5103 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5110 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5117 r = guestfs_mount (g, "/dev/sda1", "/");
5121 /* TestLastFail for rmdir (2) */
5125 r = guestfs_touch (g, "/new");
5132 r = guestfs_rmdir (g, "/new");
5139 static int test_rm_0 (void)
5141 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
5145 r = guestfs_umount_all (g);
5152 r = guestfs_lvm_remove_all (g);
5163 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5170 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5177 r = guestfs_mount (g, "/dev/sda1", "/");
5181 /* TestRun for rm (0) */
5185 r = guestfs_touch (g, "/new");
5192 r = guestfs_rm (g, "/new");
5199 static int test_rm_1 (void)
5201 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
5205 r = guestfs_umount_all (g);
5212 r = guestfs_lvm_remove_all (g);
5223 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5230 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5237 r = guestfs_mount (g, "/dev/sda1", "/");
5241 /* TestLastFail for rm (1) */
5245 r = guestfs_rm (g, "/new");
5252 static int test_rm_2 (void)
5254 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
5258 r = guestfs_umount_all (g);
5265 r = guestfs_lvm_remove_all (g);
5276 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5283 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5290 r = guestfs_mount (g, "/dev/sda1", "/");
5294 /* TestLastFail for rm (2) */
5298 r = guestfs_mkdir (g, "/new");
5305 r = guestfs_rm (g, "/new");
5312 static int test_read_lines_0 (void)
5314 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
5318 r = guestfs_umount_all (g);
5325 r = guestfs_lvm_remove_all (g);
5336 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5343 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5350 r = guestfs_mount (g, "/dev/sda1", "/");
5354 /* TestOutputList for read_lines (0) */
5358 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
5366 r = guestfs_read_lines (g, "/new");
5370 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5374 if (strcmp (r[0], "line1") != 0) {
5375 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
5379 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5383 if (strcmp (r[1], "line2") != 0) {
5384 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
5388 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5392 if (strcmp (r[2], "line3") != 0) {
5393 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
5397 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
5401 for (i = 0; r[i] != NULL; ++i)
5408 static int test_read_lines_1 (void)
5410 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
5414 r = guestfs_umount_all (g);
5421 r = guestfs_lvm_remove_all (g);
5432 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5439 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5446 r = guestfs_mount (g, "/dev/sda1", "/");
5450 /* TestOutputList for read_lines (1) */
5454 r = guestfs_write_file (g, "/new", "", 0);
5462 r = guestfs_read_lines (g, "/new");
5466 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
5470 for (i = 0; r[i] != NULL; ++i)
5477 static int test_lvs_0 (void)
5479 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
5483 r = guestfs_umount_all (g);
5490 r = guestfs_lvm_remove_all (g);
5501 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5508 r = guestfs_pvcreate (g, "/dev/sda1");
5513 char *physvols[] = {
5519 r = guestfs_vgcreate (g, "VG", physvols);
5526 r = guestfs_lvcreate (g, "LV", "VG", 8);
5533 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5540 r = guestfs_mount (g, "/dev/VG/LV", "/");
5544 /* TestOutputList for lvs (0) */
5549 r = guestfs_lvs (g);
5553 fprintf (stderr, "test_lvs_0: short list returned from command\n");
5557 if (strcmp (r[0], "/dev/VG/LV") != 0) {
5558 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
5562 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
5566 for (i = 0; r[i] != NULL; ++i)
5573 static int test_lvs_1 (void)
5575 /* InitEmpty for lvs (1) */
5579 r = guestfs_umount_all (g);
5586 r = guestfs_lvm_remove_all (g);
5590 /* TestOutputList for lvs (1) */
5600 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5607 r = guestfs_pvcreate (g, "/dev/sda1");
5614 r = guestfs_pvcreate (g, "/dev/sda2");
5621 r = guestfs_pvcreate (g, "/dev/sda3");
5626 char *physvols[] = {
5633 r = guestfs_vgcreate (g, "VG1", physvols);
5638 char *physvols[] = {
5644 r = guestfs_vgcreate (g, "VG2", physvols);
5651 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
5658 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
5665 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
5673 r = guestfs_lvs (g);
5677 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5681 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
5682 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
5686 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5690 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
5691 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
5695 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5699 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
5700 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
5704 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
5708 for (i = 0; r[i] != NULL; ++i)
5715 static int test_vgs_0 (void)
5717 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
5721 r = guestfs_umount_all (g);
5728 r = guestfs_lvm_remove_all (g);
5739 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5746 r = guestfs_pvcreate (g, "/dev/sda1");
5751 char *physvols[] = {
5757 r = guestfs_vgcreate (g, "VG", physvols);
5764 r = guestfs_lvcreate (g, "LV", "VG", 8);
5771 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5778 r = guestfs_mount (g, "/dev/VG/LV", "/");
5782 /* TestOutputList for vgs (0) */
5787 r = guestfs_vgs (g);
5791 fprintf (stderr, "test_vgs_0: short list returned from command\n");
5795 if (strcmp (r[0], "VG") != 0) {
5796 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
5800 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
5804 for (i = 0; r[i] != NULL; ++i)
5811 static int test_vgs_1 (void)
5813 /* InitEmpty for vgs (1) */
5817 r = guestfs_umount_all (g);
5824 r = guestfs_lvm_remove_all (g);
5828 /* TestOutputList for vgs (1) */
5838 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5845 r = guestfs_pvcreate (g, "/dev/sda1");
5852 r = guestfs_pvcreate (g, "/dev/sda2");
5859 r = guestfs_pvcreate (g, "/dev/sda3");
5864 char *physvols[] = {
5871 r = guestfs_vgcreate (g, "VG1", physvols);
5876 char *physvols[] = {
5882 r = guestfs_vgcreate (g, "VG2", physvols);
5890 r = guestfs_vgs (g);
5894 fprintf (stderr, "test_vgs_1: short list returned from command\n");
5898 if (strcmp (r[0], "VG1") != 0) {
5899 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
5903 fprintf (stderr, "test_vgs_1: short list returned from command\n");
5907 if (strcmp (r[1], "VG2") != 0) {
5908 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
5912 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
5916 for (i = 0; r[i] != NULL; ++i)
5923 static int test_pvs_0 (void)
5925 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
5929 r = guestfs_umount_all (g);
5936 r = guestfs_lvm_remove_all (g);
5947 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5954 r = guestfs_pvcreate (g, "/dev/sda1");
5959 char *physvols[] = {
5965 r = guestfs_vgcreate (g, "VG", physvols);
5972 r = guestfs_lvcreate (g, "LV", "VG", 8);
5979 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5986 r = guestfs_mount (g, "/dev/VG/LV", "/");
5990 /* TestOutputList for pvs (0) */
5995 r = guestfs_pvs (g);
5999 fprintf (stderr, "test_pvs_0: short list returned from command\n");
6003 if (strcmp (r[0], "/dev/sda1") != 0) {
6004 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6008 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
6012 for (i = 0; r[i] != NULL; ++i)
6019 static int test_pvs_1 (void)
6021 /* InitEmpty for pvs (1) */
6025 r = guestfs_umount_all (g);
6032 r = guestfs_lvm_remove_all (g);
6036 /* TestOutputList for pvs (1) */
6046 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6053 r = guestfs_pvcreate (g, "/dev/sda1");
6060 r = guestfs_pvcreate (g, "/dev/sda2");
6067 r = guestfs_pvcreate (g, "/dev/sda3");
6075 r = guestfs_pvs (g);
6079 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6083 if (strcmp (r[0], "/dev/sda1") != 0) {
6084 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6088 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6092 if (strcmp (r[1], "/dev/sda2") != 0) {
6093 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6097 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6101 if (strcmp (r[2], "/dev/sda3") != 0) {
6102 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6106 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
6110 for (i = 0; r[i] != NULL; ++i)
6117 static int test_list_partitions_0 (void)
6119 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
6123 r = guestfs_umount_all (g);
6130 r = guestfs_lvm_remove_all (g);
6141 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6148 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6155 r = guestfs_mount (g, "/dev/sda1", "/");
6159 /* TestOutputList for list_partitions (0) */
6164 r = guestfs_list_partitions (g);
6168 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
6172 if (strcmp (r[0], "/dev/sda1") != 0) {
6173 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6177 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
6181 for (i = 0; r[i] != NULL; ++i)
6188 static int test_list_partitions_1 (void)
6190 /* InitEmpty for list_partitions (1) */
6194 r = guestfs_umount_all (g);
6201 r = guestfs_lvm_remove_all (g);
6205 /* TestOutputList for list_partitions (1) */
6215 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6223 r = guestfs_list_partitions (g);
6227 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6231 if (strcmp (r[0], "/dev/sda1") != 0) {
6232 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6236 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6240 if (strcmp (r[1], "/dev/sda2") != 0) {
6241 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6245 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6249 if (strcmp (r[2], "/dev/sda3") != 0) {
6250 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6254 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
6258 for (i = 0; r[i] != NULL; ++i)
6265 static int test_list_devices_0 (void)
6267 /* InitEmpty for list_devices (0) */
6271 r = guestfs_umount_all (g);
6278 r = guestfs_lvm_remove_all (g);
6282 /* TestOutputList for list_devices (0) */
6287 r = guestfs_list_devices (g);
6291 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6295 if (strcmp (r[0], "/dev/sda") != 0) {
6296 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
6300 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6304 if (strcmp (r[1], "/dev/sdb") != 0) {
6305 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
6309 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6313 if (strcmp (r[2], "/dev/sdc") != 0) {
6314 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
6318 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
6322 for (i = 0; r[i] != NULL; ++i)
6329 static int test_ls_0 (void)
6331 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
6335 r = guestfs_umount_all (g);
6342 r = guestfs_lvm_remove_all (g);
6353 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6360 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6367 r = guestfs_mount (g, "/dev/sda1", "/");
6371 /* TestOutputList for ls (0) */
6375 r = guestfs_touch (g, "/new");
6382 r = guestfs_touch (g, "/newer");
6389 r = guestfs_touch (g, "/newest");
6397 r = guestfs_ls (g, "/");
6401 fprintf (stderr, "test_ls_0: short list returned from command\n");
6405 if (strcmp (r[0], "lost+found") != 0) {
6406 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
6410 fprintf (stderr, "test_ls_0: short list returned from command\n");
6414 if (strcmp (r[1], "new") != 0) {
6415 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
6419 fprintf (stderr, "test_ls_0: short list returned from command\n");
6423 if (strcmp (r[2], "newer") != 0) {
6424 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
6428 fprintf (stderr, "test_ls_0: short list returned from command\n");
6432 if (strcmp (r[3], "newest") != 0) {
6433 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
6437 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
6441 for (i = 0; r[i] != NULL; ++i)
6448 static int test_cat_0 (void)
6450 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
6454 r = guestfs_umount_all (g);
6461 r = guestfs_lvm_remove_all (g);
6472 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6479 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6486 r = guestfs_mount (g, "/dev/sda1", "/");
6490 /* TestOutput for cat (0) */
6494 r = guestfs_write_file (g, "/new", "new file contents", 0);
6501 r = guestfs_cat (g, "/new");
6504 if (strcmp (r, "new file contents") != 0) {
6505 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
6513 static int test_touch_0 (void)
6515 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
6519 r = guestfs_umount_all (g);
6526 r = guestfs_lvm_remove_all (g);
6537 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6544 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6551 r = guestfs_mount (g, "/dev/sda1", "/");
6555 /* TestOutputTrue for touch (0) */
6559 r = guestfs_touch (g, "/new");
6566 r = guestfs_exists (g, "/new");
6570 fprintf (stderr, "test_touch_0: expected true, got false\n");
6577 static int test_sync_0 (void)
6579 /* InitEmpty for sync (0) */
6583 r = guestfs_umount_all (g);
6590 r = guestfs_lvm_remove_all (g);
6594 /* TestRun for sync (0) */
6598 r = guestfs_sync (g);
6605 static int test_mount_0 (void)
6607 /* InitEmpty for mount (0) */
6611 r = guestfs_umount_all (g);
6618 r = guestfs_lvm_remove_all (g);
6622 /* TestOutput for mount (0) */
6630 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6637 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6644 r = guestfs_mount (g, "/dev/sda1", "/");
6651 r = guestfs_write_file (g, "/new", "new file contents", 0);
6658 r = guestfs_cat (g, "/new");
6661 if (strcmp (r, "new file contents") != 0) {
6662 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
6670 int main (int argc, char *argv[])
6675 const char *filename;
6677 int nr_tests, test_num = 0;
6679 no_test_warnings ();
6681 g = guestfs_create ();
6683 printf ("guestfs_create FAILED\n");
6687 guestfs_set_error_handler (g, print_error, NULL);
6689 srcdir = getenv ("srcdir");
6690 if (!srcdir) srcdir = ".";
6692 guestfs_set_path (g, ".");
6694 filename = "test1.img";
6695 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6700 if (lseek (fd, 524288000, SEEK_SET) == -1) {
6706 if (write (fd, &c, 1) == -1) {
6712 if (close (fd) == -1) {
6717 if (guestfs_add_drive (g, filename) == -1) {
6718 printf ("guestfs_add_drive %s FAILED\n", filename);
6722 filename = "test2.img";
6723 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6728 if (lseek (fd, 52428800, SEEK_SET) == -1) {
6734 if (write (fd, &c, 1) == -1) {
6740 if (close (fd) == -1) {
6745 if (guestfs_add_drive (g, filename) == -1) {
6746 printf ("guestfs_add_drive %s FAILED\n", filename);
6750 filename = "test3.img";
6751 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6756 if (lseek (fd, 10485760, SEEK_SET) == -1) {
6762 if (write (fd, &c, 1) == -1) {
6768 if (close (fd) == -1) {
6773 if (guestfs_add_drive (g, filename) == -1) {
6774 printf ("guestfs_add_drive %s FAILED\n", filename);
6778 if (guestfs_launch (g) == -1) {
6779 printf ("guestfs_launch FAILED\n");
6782 if (guestfs_wait_ready (g) == -1) {
6783 printf ("guestfs_wait_ready FAILED\n");
6790 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
6791 if (test_grub_install_0 () == -1) {
6792 printf ("test_grub_install_0 FAILED\n");
6796 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
6797 if (test_zero_0 () == -1) {
6798 printf ("test_zero_0 FAILED\n");
6802 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
6803 if (test_fsck_0 () == -1) {
6804 printf ("test_fsck_0 FAILED\n");
6808 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
6809 if (test_fsck_1 () == -1) {
6810 printf ("test_fsck_1 FAILED\n");
6814 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
6815 if (test_set_e2uuid_0 () == -1) {
6816 printf ("test_set_e2uuid_0 FAILED\n");
6820 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
6821 if (test_set_e2uuid_1 () == -1) {
6822 printf ("test_set_e2uuid_1 FAILED\n");
6826 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
6827 if (test_set_e2uuid_2 () == -1) {
6828 printf ("test_set_e2uuid_2 FAILED\n");
6832 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
6833 if (test_set_e2uuid_3 () == -1) {
6834 printf ("test_set_e2uuid_3 FAILED\n");
6838 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
6839 if (test_set_e2label_0 () == -1) {
6840 printf ("test_set_e2label_0 FAILED\n");
6844 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
6845 if (test_pvremove_0 () == -1) {
6846 printf ("test_pvremove_0 FAILED\n");
6850 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
6851 if (test_pvremove_1 () == -1) {
6852 printf ("test_pvremove_1 FAILED\n");
6856 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
6857 if (test_pvremove_2 () == -1) {
6858 printf ("test_pvremove_2 FAILED\n");
6862 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
6863 if (test_vgremove_0 () == -1) {
6864 printf ("test_vgremove_0 FAILED\n");
6868 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
6869 if (test_vgremove_1 () == -1) {
6870 printf ("test_vgremove_1 FAILED\n");
6874 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
6875 if (test_lvremove_0 () == -1) {
6876 printf ("test_lvremove_0 FAILED\n");
6880 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
6881 if (test_lvremove_1 () == -1) {
6882 printf ("test_lvremove_1 FAILED\n");
6886 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
6887 if (test_lvremove_2 () == -1) {
6888 printf ("test_lvremove_2 FAILED\n");
6892 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
6893 if (test_mount_ro_0 () == -1) {
6894 printf ("test_mount_ro_0 FAILED\n");
6898 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
6899 if (test_mount_ro_1 () == -1) {
6900 printf ("test_mount_ro_1 FAILED\n");
6904 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
6905 if (test_tgz_in_0 () == -1) {
6906 printf ("test_tgz_in_0 FAILED\n");
6910 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
6911 if (test_tar_in_0 () == -1) {
6912 printf ("test_tar_in_0 FAILED\n");
6916 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
6917 if (test_checksum_0 () == -1) {
6918 printf ("test_checksum_0 FAILED\n");
6922 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
6923 if (test_checksum_1 () == -1) {
6924 printf ("test_checksum_1 FAILED\n");
6928 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
6929 if (test_checksum_2 () == -1) {
6930 printf ("test_checksum_2 FAILED\n");
6934 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
6935 if (test_checksum_3 () == -1) {
6936 printf ("test_checksum_3 FAILED\n");
6940 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
6941 if (test_checksum_4 () == -1) {
6942 printf ("test_checksum_4 FAILED\n");
6946 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
6947 if (test_checksum_5 () == -1) {
6948 printf ("test_checksum_5 FAILED\n");
6952 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
6953 if (test_checksum_6 () == -1) {
6954 printf ("test_checksum_6 FAILED\n");
6958 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
6959 if (test_checksum_7 () == -1) {
6960 printf ("test_checksum_7 FAILED\n");
6964 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
6965 if (test_download_0 () == -1) {
6966 printf ("test_download_0 FAILED\n");
6970 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
6971 if (test_upload_0 () == -1) {
6972 printf ("test_upload_0 FAILED\n");
6976 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
6977 if (test_blockdev_rereadpt_0 () == -1) {
6978 printf ("test_blockdev_rereadpt_0 FAILED\n");
6982 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
6983 if (test_blockdev_flushbufs_0 () == -1) {
6984 printf ("test_blockdev_flushbufs_0 FAILED\n");
6988 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
6989 if (test_blockdev_getsize64_0 () == -1) {
6990 printf ("test_blockdev_getsize64_0 FAILED\n");
6994 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
6995 if (test_blockdev_getsz_0 () == -1) {
6996 printf ("test_blockdev_getsz_0 FAILED\n");
7000 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
7001 if (test_blockdev_getbsz_0 () == -1) {
7002 printf ("test_blockdev_getbsz_0 FAILED\n");
7006 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
7007 if (test_blockdev_getss_0 () == -1) {
7008 printf ("test_blockdev_getss_0 FAILED\n");
7012 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
7013 if (test_blockdev_getro_0 () == -1) {
7014 printf ("test_blockdev_getro_0 FAILED\n");
7018 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
7019 if (test_blockdev_setrw_0 () == -1) {
7020 printf ("test_blockdev_setrw_0 FAILED\n");
7024 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
7025 if (test_blockdev_setro_0 () == -1) {
7026 printf ("test_blockdev_setro_0 FAILED\n");
7030 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
7031 if (test_statvfs_0 () == -1) {
7032 printf ("test_statvfs_0 FAILED\n");
7036 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
7037 if (test_lstat_0 () == -1) {
7038 printf ("test_lstat_0 FAILED\n");
7042 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
7043 if (test_stat_0 () == -1) {
7044 printf ("test_stat_0 FAILED\n");
7048 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
7049 if (test_file_0 () == -1) {
7050 printf ("test_file_0 FAILED\n");
7054 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
7055 if (test_file_1 () == -1) {
7056 printf ("test_file_1 FAILED\n");
7060 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
7061 if (test_file_2 () == -1) {
7062 printf ("test_file_2 FAILED\n");
7066 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
7067 if (test_umount_all_0 () == -1) {
7068 printf ("test_umount_all_0 FAILED\n");
7072 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
7073 if (test_umount_all_1 () == -1) {
7074 printf ("test_umount_all_1 FAILED\n");
7078 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
7079 if (test_mounts_0 () == -1) {
7080 printf ("test_mounts_0 FAILED\n");
7084 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
7085 if (test_umount_0 () == -1) {
7086 printf ("test_umount_0 FAILED\n");
7090 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
7091 if (test_umount_1 () == -1) {
7092 printf ("test_umount_1 FAILED\n");
7096 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
7097 if (test_write_file_0 () == -1) {
7098 printf ("test_write_file_0 FAILED\n");
7102 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
7103 if (test_write_file_1 () == -1) {
7104 printf ("test_write_file_1 FAILED\n");
7108 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
7109 if (test_write_file_2 () == -1) {
7110 printf ("test_write_file_2 FAILED\n");
7114 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
7115 if (test_write_file_3 () == -1) {
7116 printf ("test_write_file_3 FAILED\n");
7120 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
7121 if (test_write_file_4 () == -1) {
7122 printf ("test_write_file_4 FAILED\n");
7126 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
7127 if (test_write_file_5 () == -1) {
7128 printf ("test_write_file_5 FAILED\n");
7132 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
7133 if (test_mkfs_0 () == -1) {
7134 printf ("test_mkfs_0 FAILED\n");
7138 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
7139 if (test_lvcreate_0 () == -1) {
7140 printf ("test_lvcreate_0 FAILED\n");
7144 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
7145 if (test_vgcreate_0 () == -1) {
7146 printf ("test_vgcreate_0 FAILED\n");
7150 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
7151 if (test_pvcreate_0 () == -1) {
7152 printf ("test_pvcreate_0 FAILED\n");
7156 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
7157 if (test_is_dir_0 () == -1) {
7158 printf ("test_is_dir_0 FAILED\n");
7162 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
7163 if (test_is_dir_1 () == -1) {
7164 printf ("test_is_dir_1 FAILED\n");
7168 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
7169 if (test_is_file_0 () == -1) {
7170 printf ("test_is_file_0 FAILED\n");
7174 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
7175 if (test_is_file_1 () == -1) {
7176 printf ("test_is_file_1 FAILED\n");
7180 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
7181 if (test_exists_0 () == -1) {
7182 printf ("test_exists_0 FAILED\n");
7186 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
7187 if (test_exists_1 () == -1) {
7188 printf ("test_exists_1 FAILED\n");
7192 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
7193 if (test_mkdir_p_0 () == -1) {
7194 printf ("test_mkdir_p_0 FAILED\n");
7198 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
7199 if (test_mkdir_p_1 () == -1) {
7200 printf ("test_mkdir_p_1 FAILED\n");
7204 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
7205 if (test_mkdir_p_2 () == -1) {
7206 printf ("test_mkdir_p_2 FAILED\n");
7210 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
7211 if (test_mkdir_0 () == -1) {
7212 printf ("test_mkdir_0 FAILED\n");
7216 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
7217 if (test_mkdir_1 () == -1) {
7218 printf ("test_mkdir_1 FAILED\n");
7222 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
7223 if (test_rm_rf_0 () == -1) {
7224 printf ("test_rm_rf_0 FAILED\n");
7228 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
7229 if (test_rmdir_0 () == -1) {
7230 printf ("test_rmdir_0 FAILED\n");
7234 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
7235 if (test_rmdir_1 () == -1) {
7236 printf ("test_rmdir_1 FAILED\n");
7240 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
7241 if (test_rmdir_2 () == -1) {
7242 printf ("test_rmdir_2 FAILED\n");
7246 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
7247 if (test_rm_0 () == -1) {
7248 printf ("test_rm_0 FAILED\n");
7252 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
7253 if (test_rm_1 () == -1) {
7254 printf ("test_rm_1 FAILED\n");
7258 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
7259 if (test_rm_2 () == -1) {
7260 printf ("test_rm_2 FAILED\n");
7264 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
7265 if (test_read_lines_0 () == -1) {
7266 printf ("test_read_lines_0 FAILED\n");
7270 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
7271 if (test_read_lines_1 () == -1) {
7272 printf ("test_read_lines_1 FAILED\n");
7276 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
7277 if (test_lvs_0 () == -1) {
7278 printf ("test_lvs_0 FAILED\n");
7282 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
7283 if (test_lvs_1 () == -1) {
7284 printf ("test_lvs_1 FAILED\n");
7288 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
7289 if (test_vgs_0 () == -1) {
7290 printf ("test_vgs_0 FAILED\n");
7294 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
7295 if (test_vgs_1 () == -1) {
7296 printf ("test_vgs_1 FAILED\n");
7300 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
7301 if (test_pvs_0 () == -1) {
7302 printf ("test_pvs_0 FAILED\n");
7306 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
7307 if (test_pvs_1 () == -1) {
7308 printf ("test_pvs_1 FAILED\n");
7312 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
7313 if (test_list_partitions_0 () == -1) {
7314 printf ("test_list_partitions_0 FAILED\n");
7318 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
7319 if (test_list_partitions_1 () == -1) {
7320 printf ("test_list_partitions_1 FAILED\n");
7324 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
7325 if (test_list_devices_0 () == -1) {
7326 printf ("test_list_devices_0 FAILED\n");
7330 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
7331 if (test_ls_0 () == -1) {
7332 printf ("test_ls_0 FAILED\n");
7336 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
7337 if (test_cat_0 () == -1) {
7338 printf ("test_cat_0 FAILED\n");
7342 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
7343 if (test_touch_0 () == -1) {
7344 printf ("test_touch_0 FAILED\n");
7348 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
7349 if (test_sync_0 () == -1) {
7350 printf ("test_sync_0 FAILED\n");
7354 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
7355 if (test_mount_0 () == -1) {
7356 printf ("test_mount_0 FAILED\n");
7361 unlink ("test1.img");
7362 unlink ("test2.img");
7363 unlink ("test3.img");
7366 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);