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_zero_0 (void)
117 /* InitBasicFS for zero (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 /* TestOutput for zero (0) */
161 r = guestfs_umount (g, "/dev/sda1");
168 r = guestfs_zero (g, "/dev/sda1");
175 r = guestfs_file (g, "/dev/sda1");
178 if (strcmp (r, "data") != 0) {
179 fprintf (stderr, "test_zero_0: expected \"data\" but got \"%s\"\n", r);
187 static int test_fsck_0 (void)
189 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
193 r = guestfs_umount_all (g);
200 r = guestfs_lvm_remove_all (g);
211 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
218 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
225 r = guestfs_mount (g, "/dev/sda1", "/");
229 /* TestOutputInt for fsck (0) */
233 r = guestfs_umount (g, "/dev/sda1");
240 r = guestfs_fsck (g, "ext2", "/dev/sda1");
244 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
251 static int test_fsck_1 (void)
253 /* InitBasicFS for fsck (1): 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 (1) */
297 r = guestfs_umount (g, "/dev/sda1");
304 r = guestfs_zero (g, "/dev/sda1");
311 r = guestfs_fsck (g, "ext2", "/dev/sda1");
315 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
322 static int test_set_e2uuid_0 (void)
324 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
328 r = guestfs_umount_all (g);
335 r = guestfs_lvm_remove_all (g);
346 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
353 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
360 r = guestfs_mount (g, "/dev/sda1", "/");
364 /* TestOutput for set_e2uuid (0) */
368 r = guestfs_set_e2uuid (g, "/dev/sda1", "a3a61220-882b-4f61-89f4-cf24dcc7297d");
375 r = guestfs_get_e2uuid (g, "/dev/sda1");
378 if (strcmp (r, "a3a61220-882b-4f61-89f4-cf24dcc7297d") != 0) {
379 fprintf (stderr, "test_set_e2uuid_0: expected \"a3a61220-882b-4f61-89f4-cf24dcc7297d\" but got \"%s\"\n", r);
387 static int test_set_e2uuid_1 (void)
389 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
393 r = guestfs_umount_all (g);
400 r = guestfs_lvm_remove_all (g);
411 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
418 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
425 r = guestfs_mount (g, "/dev/sda1", "/");
429 /* TestOutput for set_e2uuid (1) */
433 r = guestfs_set_e2uuid (g, "/dev/sda1", "clear");
440 r = guestfs_get_e2uuid (g, "/dev/sda1");
443 if (strcmp (r, "") != 0) {
444 fprintf (stderr, "test_set_e2uuid_1: expected \"\" but got \"%s\"\n", r);
452 static int test_set_e2uuid_2 (void)
454 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
458 r = guestfs_umount_all (g);
465 r = guestfs_lvm_remove_all (g);
476 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
483 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
490 r = guestfs_mount (g, "/dev/sda1", "/");
494 /* TestRun for set_e2uuid (2) */
498 r = guestfs_set_e2uuid (g, "/dev/sda1", "random");
505 static int test_set_e2uuid_3 (void)
507 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
511 r = guestfs_umount_all (g);
518 r = guestfs_lvm_remove_all (g);
529 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
536 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
543 r = guestfs_mount (g, "/dev/sda1", "/");
547 /* TestRun for set_e2uuid (3) */
551 r = guestfs_set_e2uuid (g, "/dev/sda1", "time");
558 static int test_set_e2label_0 (void)
560 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
564 r = guestfs_umount_all (g);
571 r = guestfs_lvm_remove_all (g);
582 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
589 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
596 r = guestfs_mount (g, "/dev/sda1", "/");
600 /* TestOutput for set_e2label (0) */
604 r = guestfs_set_e2label (g, "/dev/sda1", "testlabel");
611 r = guestfs_get_e2label (g, "/dev/sda1");
614 if (strcmp (r, "testlabel") != 0) {
615 fprintf (stderr, "test_set_e2label_0: expected \"testlabel\" but got \"%s\"\n", r);
623 static int test_pvremove_0 (void)
625 /* InitEmpty for pvremove (0) */
629 r = guestfs_umount_all (g);
636 r = guestfs_lvm_remove_all (g);
640 /* TestOutputList for pvremove (0) */
644 r = guestfs_pvcreate (g, "/dev/sda");
655 r = guestfs_vgcreate (g, "VG", physvols);
662 r = guestfs_lvcreate (g, "LV1", "VG", 50);
669 r = guestfs_lvcreate (g, "LV2", "VG", 50);
676 r = guestfs_vgremove (g, "VG");
683 r = guestfs_pvremove (g, "/dev/sda");
695 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
699 for (i = 0; r[i] != NULL; ++i)
706 static int test_pvremove_1 (void)
708 /* InitEmpty for pvremove (1) */
712 r = guestfs_umount_all (g);
719 r = guestfs_lvm_remove_all (g);
723 /* TestOutputList for pvremove (1) */
727 r = guestfs_pvcreate (g, "/dev/sda");
738 r = guestfs_vgcreate (g, "VG", physvols);
745 r = guestfs_lvcreate (g, "LV1", "VG", 50);
752 r = guestfs_lvcreate (g, "LV2", "VG", 50);
759 r = guestfs_vgremove (g, "VG");
766 r = guestfs_pvremove (g, "/dev/sda");
778 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
782 for (i = 0; r[i] != NULL; ++i)
789 static int test_pvremove_2 (void)
791 /* InitEmpty for pvremove (2) */
795 r = guestfs_umount_all (g);
802 r = guestfs_lvm_remove_all (g);
806 /* TestOutputList for pvremove (2) */
810 r = guestfs_pvcreate (g, "/dev/sda");
821 r = guestfs_vgcreate (g, "VG", physvols);
828 r = guestfs_lvcreate (g, "LV1", "VG", 50);
835 r = guestfs_lvcreate (g, "LV2", "VG", 50);
842 r = guestfs_vgremove (g, "VG");
849 r = guestfs_pvremove (g, "/dev/sda");
861 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
865 for (i = 0; r[i] != NULL; ++i)
872 static int test_vgremove_0 (void)
874 /* InitEmpty for vgremove (0) */
878 r = guestfs_umount_all (g);
885 r = guestfs_lvm_remove_all (g);
889 /* TestOutputList for vgremove (0) */
893 r = guestfs_pvcreate (g, "/dev/sda");
904 r = guestfs_vgcreate (g, "VG", physvols);
911 r = guestfs_lvcreate (g, "LV1", "VG", 50);
918 r = guestfs_lvcreate (g, "LV2", "VG", 50);
925 r = guestfs_vgremove (g, "VG");
937 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
941 for (i = 0; r[i] != NULL; ++i)
948 static int test_vgremove_1 (void)
950 /* InitEmpty for vgremove (1) */
954 r = guestfs_umount_all (g);
961 r = guestfs_lvm_remove_all (g);
965 /* TestOutputList for vgremove (1) */
969 r = guestfs_pvcreate (g, "/dev/sda");
980 r = guestfs_vgcreate (g, "VG", physvols);
987 r = guestfs_lvcreate (g, "LV1", "VG", 50);
994 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1001 r = guestfs_vgremove (g, "VG");
1009 r = guestfs_vgs (g);
1013 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
1017 for (i = 0; r[i] != NULL; ++i)
1024 static int test_lvremove_0 (void)
1026 /* InitEmpty for lvremove (0) */
1030 r = guestfs_umount_all (g);
1037 r = guestfs_lvm_remove_all (g);
1041 /* TestOutputList for lvremove (0) */
1045 r = guestfs_pvcreate (g, "/dev/sda");
1050 char *physvols[] = {
1056 r = guestfs_vgcreate (g, "VG", physvols);
1063 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1070 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1077 r = guestfs_lvremove (g, "/dev/VG/LV1");
1085 r = guestfs_lvs (g);
1089 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
1093 if (strcmp (r[0], "/dev/VG/LV2") != 0) {
1094 fprintf (stderr, "test_lvremove_0: expected \"/dev/VG/LV2\" but got \"%s\"\n", r[0]);
1098 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
1102 for (i = 0; r[i] != NULL; ++i)
1109 static int test_lvremove_1 (void)
1111 /* InitEmpty for lvremove (1) */
1115 r = guestfs_umount_all (g);
1122 r = guestfs_lvm_remove_all (g);
1126 /* TestOutputList for lvremove (1) */
1130 r = guestfs_pvcreate (g, "/dev/sda");
1135 char *physvols[] = {
1141 r = guestfs_vgcreate (g, "VG", physvols);
1148 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1155 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1162 r = guestfs_lvremove (g, "/dev/VG");
1170 r = guestfs_lvs (g);
1174 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
1178 for (i = 0; r[i] != NULL; ++i)
1185 static int test_lvremove_2 (void)
1187 /* InitEmpty for lvremove (2) */
1191 r = guestfs_umount_all (g);
1198 r = guestfs_lvm_remove_all (g);
1202 /* TestOutputList for lvremove (2) */
1206 r = guestfs_pvcreate (g, "/dev/sda");
1211 char *physvols[] = {
1217 r = guestfs_vgcreate (g, "VG", physvols);
1224 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1231 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1238 r = guestfs_lvremove (g, "/dev/VG");
1246 r = guestfs_vgs (g);
1250 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
1254 if (strcmp (r[0], "VG") != 0) {
1255 fprintf (stderr, "test_lvremove_2: expected \"VG\" but got \"%s\"\n", r[0]);
1259 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
1263 for (i = 0; r[i] != NULL; ++i)
1270 static int test_mount_ro_0 (void)
1272 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
1276 r = guestfs_umount_all (g);
1283 r = guestfs_lvm_remove_all (g);
1294 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1301 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1308 r = guestfs_mount (g, "/dev/sda1", "/");
1312 /* TestLastFail for mount_ro (0) */
1316 r = guestfs_umount (g, "/");
1323 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1330 r = guestfs_touch (g, "/new");
1337 static int test_mount_ro_1 (void)
1339 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
1343 r = guestfs_umount_all (g);
1350 r = guestfs_lvm_remove_all (g);
1361 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1368 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1375 r = guestfs_mount (g, "/dev/sda1", "/");
1379 /* TestOutput for mount_ro (1) */
1383 r = guestfs_write_file (g, "/new", "data", 0);
1390 r = guestfs_umount (g, "/");
1397 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1404 r = guestfs_cat (g, "/new");
1407 if (strcmp (r, "data") != 0) {
1408 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
1416 static int test_tgz_in_0 (void)
1418 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
1422 r = guestfs_umount_all (g);
1429 r = guestfs_lvm_remove_all (g);
1440 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1447 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1454 r = guestfs_mount (g, "/dev/sda1", "/");
1458 /* TestOutput for tgz_in (0) */
1462 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
1469 r = guestfs_cat (g, "/hello");
1472 if (strcmp (r, "hello\n") != 0) {
1473 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
1481 static int test_tar_in_0 (void)
1483 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
1487 r = guestfs_umount_all (g);
1494 r = guestfs_lvm_remove_all (g);
1505 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1512 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1519 r = guestfs_mount (g, "/dev/sda1", "/");
1523 /* TestOutput for tar_in (0) */
1527 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
1534 r = guestfs_cat (g, "/hello");
1537 if (strcmp (r, "hello\n") != 0) {
1538 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
1546 static int test_checksum_0 (void)
1548 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
1552 r = guestfs_umount_all (g);
1559 r = guestfs_lvm_remove_all (g);
1570 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1577 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1584 r = guestfs_mount (g, "/dev/sda1", "/");
1588 /* TestOutput for checksum (0) */
1592 r = guestfs_write_file (g, "/new", "test\n", 0);
1599 r = guestfs_checksum (g, "crc", "/new");
1602 if (strcmp (r, "935282863") != 0) {
1603 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
1611 static int test_checksum_1 (void)
1613 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
1617 r = guestfs_umount_all (g);
1624 r = guestfs_lvm_remove_all (g);
1635 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1642 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1649 r = guestfs_mount (g, "/dev/sda1", "/");
1653 /* TestLastFail for checksum (1) */
1657 r = guestfs_checksum (g, "crc", "/new");
1665 static int test_checksum_2 (void)
1667 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
1671 r = guestfs_umount_all (g);
1678 r = guestfs_lvm_remove_all (g);
1689 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1696 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1703 r = guestfs_mount (g, "/dev/sda1", "/");
1707 /* TestOutput for checksum (2) */
1711 r = guestfs_write_file (g, "/new", "test\n", 0);
1718 r = guestfs_checksum (g, "md5", "/new");
1721 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
1722 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
1730 static int test_checksum_3 (void)
1732 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
1736 r = guestfs_umount_all (g);
1743 r = guestfs_lvm_remove_all (g);
1754 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1761 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1768 r = guestfs_mount (g, "/dev/sda1", "/");
1772 /* TestOutput for checksum (3) */
1776 r = guestfs_write_file (g, "/new", "test\n", 0);
1783 r = guestfs_checksum (g, "sha1", "/new");
1786 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
1787 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
1795 static int test_checksum_4 (void)
1797 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
1801 r = guestfs_umount_all (g);
1808 r = guestfs_lvm_remove_all (g);
1819 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1826 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1833 r = guestfs_mount (g, "/dev/sda1", "/");
1837 /* TestOutput for checksum (4) */
1841 r = guestfs_write_file (g, "/new", "test\n", 0);
1848 r = guestfs_checksum (g, "sha224", "/new");
1851 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
1852 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
1860 static int test_checksum_5 (void)
1862 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
1866 r = guestfs_umount_all (g);
1873 r = guestfs_lvm_remove_all (g);
1884 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1891 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1898 r = guestfs_mount (g, "/dev/sda1", "/");
1902 /* TestOutput for checksum (5) */
1906 r = guestfs_write_file (g, "/new", "test\n", 0);
1913 r = guestfs_checksum (g, "sha256", "/new");
1916 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
1917 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
1925 static int test_checksum_6 (void)
1927 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
1931 r = guestfs_umount_all (g);
1938 r = guestfs_lvm_remove_all (g);
1949 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1956 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1963 r = guestfs_mount (g, "/dev/sda1", "/");
1967 /* TestOutput for checksum (6) */
1971 r = guestfs_write_file (g, "/new", "test\n", 0);
1978 r = guestfs_checksum (g, "sha384", "/new");
1981 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
1982 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
1990 static int test_checksum_7 (void)
1992 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
1996 r = guestfs_umount_all (g);
2003 r = guestfs_lvm_remove_all (g);
2014 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2021 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2028 r = guestfs_mount (g, "/dev/sda1", "/");
2032 /* TestOutput for checksum (7) */
2036 r = guestfs_write_file (g, "/new", "test\n", 0);
2043 r = guestfs_checksum (g, "sha512", "/new");
2046 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
2047 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
2055 static int test_download_0 (void)
2057 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
2061 r = guestfs_umount_all (g);
2068 r = guestfs_lvm_remove_all (g);
2079 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2086 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2093 r = guestfs_mount (g, "/dev/sda1", "/");
2097 /* TestOutput for download (0) */
2101 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2108 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
2115 r = guestfs_upload (g, "testdownload.tmp", "/upload");
2122 r = guestfs_checksum (g, "md5", "/upload");
2125 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2126 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2134 static int test_upload_0 (void)
2136 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
2140 r = guestfs_umount_all (g);
2147 r = guestfs_lvm_remove_all (g);
2158 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2165 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2172 r = guestfs_mount (g, "/dev/sda1", "/");
2176 /* TestOutput for upload (0) */
2180 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2187 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
2190 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2191 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2199 static int test_blockdev_rereadpt_0 (void)
2201 /* InitEmpty for blockdev_rereadpt (0) */
2205 r = guestfs_umount_all (g);
2212 r = guestfs_lvm_remove_all (g);
2216 /* TestRun for blockdev_rereadpt (0) */
2220 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
2227 static int test_blockdev_flushbufs_0 (void)
2229 /* InitEmpty for blockdev_flushbufs (0) */
2233 r = guestfs_umount_all (g);
2240 r = guestfs_lvm_remove_all (g);
2244 /* TestRun for blockdev_flushbufs (0) */
2248 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
2255 static int test_blockdev_getsize64_0 (void)
2257 /* InitEmpty for blockdev_getsize64 (0) */
2261 r = guestfs_umount_all (g);
2268 r = guestfs_lvm_remove_all (g);
2272 /* TestOutputInt for blockdev_getsize64 (0) */
2276 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
2279 if (r != 524288000) {
2280 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
2287 static int test_blockdev_getsz_0 (void)
2289 /* InitEmpty for blockdev_getsz (0) */
2293 r = guestfs_umount_all (g);
2300 r = guestfs_lvm_remove_all (g);
2304 /* TestOutputInt for blockdev_getsz (0) */
2308 r = guestfs_blockdev_getsz (g, "/dev/sda");
2312 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
2319 static int test_blockdev_getbsz_0 (void)
2321 /* InitEmpty for blockdev_getbsz (0) */
2325 r = guestfs_umount_all (g);
2332 r = guestfs_lvm_remove_all (g);
2336 /* TestOutputInt for blockdev_getbsz (0) */
2340 r = guestfs_blockdev_getbsz (g, "/dev/sda");
2344 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
2351 static int test_blockdev_getss_0 (void)
2353 /* InitEmpty for blockdev_getss (0) */
2357 r = guestfs_umount_all (g);
2364 r = guestfs_lvm_remove_all (g);
2368 /* TestOutputInt for blockdev_getss (0) */
2372 r = guestfs_blockdev_getss (g, "/dev/sda");
2376 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
2383 static int test_blockdev_getro_0 (void)
2385 /* InitEmpty for blockdev_getro (0) */
2389 r = guestfs_umount_all (g);
2396 r = guestfs_lvm_remove_all (g);
2400 /* TestOutputTrue for blockdev_getro (0) */
2404 r = guestfs_blockdev_setro (g, "/dev/sda");
2411 r = guestfs_blockdev_getro (g, "/dev/sda");
2415 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
2422 static int test_blockdev_setrw_0 (void)
2424 /* InitEmpty for blockdev_setrw (0) */
2428 r = guestfs_umount_all (g);
2435 r = guestfs_lvm_remove_all (g);
2439 /* TestOutputFalse for blockdev_setrw (0) */
2443 r = guestfs_blockdev_setrw (g, "/dev/sda");
2450 r = guestfs_blockdev_getro (g, "/dev/sda");
2454 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
2461 static int test_blockdev_setro_0 (void)
2463 /* InitEmpty for blockdev_setro (0) */
2467 r = guestfs_umount_all (g);
2474 r = guestfs_lvm_remove_all (g);
2478 /* TestOutputTrue for blockdev_setro (0) */
2482 r = guestfs_blockdev_setro (g, "/dev/sda");
2489 r = guestfs_blockdev_getro (g, "/dev/sda");
2493 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
2500 static int test_statvfs_0 (void)
2502 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
2506 r = guestfs_umount_all (g);
2513 r = guestfs_lvm_remove_all (g);
2524 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2531 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2538 r = guestfs_mount (g, "/dev/sda1", "/");
2542 /* TestOutputStruct for statvfs (0) */
2544 struct guestfs_statvfs *r;
2546 r = guestfs_statvfs (g, "/");
2549 if (r->bfree != 487702) {
2550 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
2554 if (r->blocks != 490020) {
2555 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
2559 if (r->bsize != 1024) {
2560 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
2569 static int test_lstat_0 (void)
2571 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
2575 r = guestfs_umount_all (g);
2582 r = guestfs_lvm_remove_all (g);
2593 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2600 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2607 r = guestfs_mount (g, "/dev/sda1", "/");
2611 /* TestOutputStruct for lstat (0) */
2615 r = guestfs_touch (g, "/new");
2620 struct guestfs_stat *r;
2622 r = guestfs_lstat (g, "/new");
2626 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
2635 static int test_stat_0 (void)
2637 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
2641 r = guestfs_umount_all (g);
2648 r = guestfs_lvm_remove_all (g);
2659 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2666 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2673 r = guestfs_mount (g, "/dev/sda1", "/");
2677 /* TestOutputStruct for stat (0) */
2681 r = guestfs_touch (g, "/new");
2686 struct guestfs_stat *r;
2688 r = guestfs_stat (g, "/new");
2692 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
2701 static int test_file_0 (void)
2703 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
2707 r = guestfs_umount_all (g);
2714 r = guestfs_lvm_remove_all (g);
2725 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2732 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2739 r = guestfs_mount (g, "/dev/sda1", "/");
2743 /* TestOutput for file (0) */
2747 r = guestfs_touch (g, "/new");
2754 r = guestfs_file (g, "/new");
2757 if (strcmp (r, "empty") != 0) {
2758 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
2766 static int test_file_1 (void)
2768 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
2772 r = guestfs_umount_all (g);
2779 r = guestfs_lvm_remove_all (g);
2790 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2797 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2804 r = guestfs_mount (g, "/dev/sda1", "/");
2808 /* TestOutput for file (1) */
2812 r = guestfs_write_file (g, "/new", "some content\n", 0);
2819 r = guestfs_file (g, "/new");
2822 if (strcmp (r, "ASCII text") != 0) {
2823 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
2831 static int test_file_2 (void)
2833 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
2837 r = guestfs_umount_all (g);
2844 r = guestfs_lvm_remove_all (g);
2855 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2862 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2869 r = guestfs_mount (g, "/dev/sda1", "/");
2873 /* TestLastFail for file (2) */
2877 r = guestfs_file (g, "/nofile");
2885 static int test_umount_all_0 (void)
2887 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
2891 r = guestfs_umount_all (g);
2898 r = guestfs_lvm_remove_all (g);
2909 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2916 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2923 r = guestfs_mount (g, "/dev/sda1", "/");
2927 /* TestOutputList for umount_all (0) */
2931 r = guestfs_umount_all (g);
2939 r = guestfs_mounts (g);
2943 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
2947 for (i = 0; r[i] != NULL; ++i)
2954 static int test_umount_all_1 (void)
2956 /* InitEmpty for umount_all (1) */
2960 r = guestfs_umount_all (g);
2967 r = guestfs_lvm_remove_all (g);
2971 /* TestOutputList for umount_all (1) */
2981 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2988 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2995 r = guestfs_mkfs (g, "ext2", "/dev/sda2");
3002 r = guestfs_mkfs (g, "ext2", "/dev/sda3");
3009 r = guestfs_mount (g, "/dev/sda1", "/");
3016 r = guestfs_mkdir (g, "/mp1");
3023 r = guestfs_mount (g, "/dev/sda2", "/mp1");
3030 r = guestfs_mkdir (g, "/mp1/mp2");
3037 r = guestfs_mount (g, "/dev/sda3", "/mp1/mp2");
3044 r = guestfs_mkdir (g, "/mp1/mp2/mp3");
3051 r = guestfs_umount_all (g);
3059 r = guestfs_mounts (g);
3063 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
3067 for (i = 0; r[i] != NULL; ++i)
3074 static int test_mounts_0 (void)
3076 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
3080 r = guestfs_umount_all (g);
3087 r = guestfs_lvm_remove_all (g);
3098 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3105 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3112 r = guestfs_mount (g, "/dev/sda1", "/");
3116 /* TestOutputList for mounts (0) */
3121 r = guestfs_mounts (g);
3125 fprintf (stderr, "test_mounts_0: short list returned from command\n");
3129 if (strcmp (r[0], "/dev/sda1") != 0) {
3130 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3134 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
3138 for (i = 0; r[i] != NULL; ++i)
3145 static int test_umount_0 (void)
3147 /* InitEmpty for umount (0) */
3151 r = guestfs_umount_all (g);
3158 r = guestfs_lvm_remove_all (g);
3162 /* TestOutputList for umount (0) */
3170 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3177 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3184 r = guestfs_mount (g, "/dev/sda1", "/");
3192 r = guestfs_mounts (g);
3196 fprintf (stderr, "test_umount_0: short list returned from command\n");
3200 if (strcmp (r[0], "/dev/sda1") != 0) {
3201 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3205 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
3209 for (i = 0; r[i] != NULL; ++i)
3216 static int test_umount_1 (void)
3218 /* InitEmpty for umount (1) */
3222 r = guestfs_umount_all (g);
3229 r = guestfs_lvm_remove_all (g);
3233 /* TestOutputList for umount (1) */
3241 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3248 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3255 r = guestfs_mount (g, "/dev/sda1", "/");
3262 r = guestfs_umount (g, "/");
3270 r = guestfs_mounts (g);
3274 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
3278 for (i = 0; r[i] != NULL; ++i)
3285 static int test_write_file_0 (void)
3287 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
3291 r = guestfs_umount_all (g);
3298 r = guestfs_lvm_remove_all (g);
3309 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3316 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3323 r = guestfs_mount (g, "/dev/sda1", "/");
3327 /* TestOutput for write_file (0) */
3331 r = guestfs_write_file (g, "/new", "new file contents", 0);
3338 r = guestfs_cat (g, "/new");
3341 if (strcmp (r, "new file contents") != 0) {
3342 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
3350 static int test_write_file_1 (void)
3352 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
3356 r = guestfs_umount_all (g);
3363 r = guestfs_lvm_remove_all (g);
3374 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3381 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3388 r = guestfs_mount (g, "/dev/sda1", "/");
3392 /* TestOutput for write_file (1) */
3396 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
3403 r = guestfs_cat (g, "/new");
3406 if (strcmp (r, "\nnew file contents\n") != 0) {
3407 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
3415 static int test_write_file_2 (void)
3417 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
3421 r = guestfs_umount_all (g);
3428 r = guestfs_lvm_remove_all (g);
3439 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3446 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3453 r = guestfs_mount (g, "/dev/sda1", "/");
3457 /* TestOutput for write_file (2) */
3461 r = guestfs_write_file (g, "/new", "\n\n", 0);
3468 r = guestfs_cat (g, "/new");
3471 if (strcmp (r, "\n\n") != 0) {
3472 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
3480 static int test_write_file_3 (void)
3482 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
3486 r = guestfs_umount_all (g);
3493 r = guestfs_lvm_remove_all (g);
3504 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3511 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3518 r = guestfs_mount (g, "/dev/sda1", "/");
3522 /* TestOutput for write_file (3) */
3526 r = guestfs_write_file (g, "/new", "", 0);
3533 r = guestfs_cat (g, "/new");
3536 if (strcmp (r, "") != 0) {
3537 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
3545 static int test_write_file_4 (void)
3547 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
3551 r = guestfs_umount_all (g);
3558 r = guestfs_lvm_remove_all (g);
3569 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3576 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3583 r = guestfs_mount (g, "/dev/sda1", "/");
3587 /* TestOutput for write_file (4) */
3591 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
3598 r = guestfs_cat (g, "/new");
3601 if (strcmp (r, "\n\n\n") != 0) {
3602 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
3610 static int test_write_file_5 (void)
3612 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
3616 r = guestfs_umount_all (g);
3623 r = guestfs_lvm_remove_all (g);
3634 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3641 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3648 r = guestfs_mount (g, "/dev/sda1", "/");
3652 /* TestOutput for write_file (5) */
3656 r = guestfs_write_file (g, "/new", "\n", 0);
3663 r = guestfs_cat (g, "/new");
3666 if (strcmp (r, "\n") != 0) {
3667 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
3675 static int test_mkfs_0 (void)
3677 /* InitEmpty for mkfs (0) */
3681 r = guestfs_umount_all (g);
3688 r = guestfs_lvm_remove_all (g);
3692 /* TestOutput for mkfs (0) */
3700 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3707 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3714 r = guestfs_mount (g, "/dev/sda1", "/");
3721 r = guestfs_write_file (g, "/new", "new file contents", 0);
3728 r = guestfs_cat (g, "/new");
3731 if (strcmp (r, "new file contents") != 0) {
3732 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
3740 static int test_lvcreate_0 (void)
3742 /* InitEmpty for lvcreate (0) */
3746 r = guestfs_umount_all (g);
3753 r = guestfs_lvm_remove_all (g);
3757 /* TestOutputList for lvcreate (0) */
3767 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3774 r = guestfs_pvcreate (g, "/dev/sda1");
3781 r = guestfs_pvcreate (g, "/dev/sda2");
3788 r = guestfs_pvcreate (g, "/dev/sda3");
3793 char *physvols[] = {
3800 r = guestfs_vgcreate (g, "VG1", physvols);
3805 char *physvols[] = {
3811 r = guestfs_vgcreate (g, "VG2", physvols);
3818 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
3825 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
3832 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
3839 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
3846 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
3854 r = guestfs_lvs (g);
3858 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3862 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
3863 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
3867 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3871 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
3872 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
3876 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3880 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
3881 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
3885 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3889 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
3890 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
3894 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3898 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
3899 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
3903 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
3907 for (i = 0; r[i] != NULL; ++i)
3914 static int test_vgcreate_0 (void)
3916 /* InitEmpty for vgcreate (0) */
3920 r = guestfs_umount_all (g);
3927 r = guestfs_lvm_remove_all (g);
3931 /* TestOutputList for vgcreate (0) */
3941 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3948 r = guestfs_pvcreate (g, "/dev/sda1");
3955 r = guestfs_pvcreate (g, "/dev/sda2");
3962 r = guestfs_pvcreate (g, "/dev/sda3");
3967 char *physvols[] = {
3974 r = guestfs_vgcreate (g, "VG1", physvols);
3979 char *physvols[] = {
3985 r = guestfs_vgcreate (g, "VG2", physvols);
3993 r = guestfs_vgs (g);
3997 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4001 if (strcmp (r[0], "VG1") != 0) {
4002 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
4006 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4010 if (strcmp (r[1], "VG2") != 0) {
4011 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
4015 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
4019 for (i = 0; r[i] != NULL; ++i)
4026 static int test_pvcreate_0 (void)
4028 /* InitEmpty for pvcreate (0) */
4032 r = guestfs_umount_all (g);
4039 r = guestfs_lvm_remove_all (g);
4043 /* TestOutputList for pvcreate (0) */
4053 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4060 r = guestfs_pvcreate (g, "/dev/sda1");
4067 r = guestfs_pvcreate (g, "/dev/sda2");
4074 r = guestfs_pvcreate (g, "/dev/sda3");
4082 r = guestfs_pvs (g);
4086 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4090 if (strcmp (r[0], "/dev/sda1") != 0) {
4091 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4095 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4099 if (strcmp (r[1], "/dev/sda2") != 0) {
4100 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4104 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4108 if (strcmp (r[2], "/dev/sda3") != 0) {
4109 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4113 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
4117 for (i = 0; r[i] != NULL; ++i)
4124 static int test_is_dir_0 (void)
4126 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
4130 r = guestfs_umount_all (g);
4137 r = guestfs_lvm_remove_all (g);
4148 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4155 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4162 r = guestfs_mount (g, "/dev/sda1", "/");
4166 /* TestOutputFalse for is_dir (0) */
4170 r = guestfs_touch (g, "/new");
4177 r = guestfs_is_dir (g, "/new");
4181 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
4188 static int test_is_dir_1 (void)
4190 /* InitBasicFS for is_dir (1): 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 /* TestOutputTrue for is_dir (1) */
4234 r = guestfs_mkdir (g, "/new");
4241 r = guestfs_is_dir (g, "/new");
4245 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
4252 static int test_is_file_0 (void)
4254 /* InitBasicFS for is_file (0): 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_file (0) */
4298 r = guestfs_touch (g, "/new");
4305 r = guestfs_is_file (g, "/new");
4309 fprintf (stderr, "test_is_file_0: expected true, got false\n");
4316 static int test_is_file_1 (void)
4318 /* InitBasicFS for is_file (1): 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 /* TestOutputFalse for is_file (1) */
4362 r = guestfs_mkdir (g, "/new");
4369 r = guestfs_is_file (g, "/new");
4373 fprintf (stderr, "test_is_file_1: expected false, got true\n");
4380 static int test_exists_0 (void)
4382 /* InitBasicFS for exists (0): 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 /* TestOutputTrue for exists (0) */
4426 r = guestfs_touch (g, "/new");
4433 r = guestfs_exists (g, "/new");
4437 fprintf (stderr, "test_exists_0: expected true, got false\n");
4444 static int test_exists_1 (void)
4446 /* InitBasicFS for exists (1): 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 (1) */
4490 r = guestfs_mkdir (g, "/new");
4497 r = guestfs_exists (g, "/new");
4501 fprintf (stderr, "test_exists_1: expected true, got false\n");
4508 static int test_mkdir_p_0 (void)
4510 /* InitBasicFS for mkdir_p (0): 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 mkdir_p (0) */
4554 r = guestfs_mkdir_p (g, "/new/foo/bar");
4561 r = guestfs_is_dir (g, "/new/foo/bar");
4565 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
4572 static int test_mkdir_p_1 (void)
4574 /* InitBasicFS for mkdir_p (1): 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 (1) */
4618 r = guestfs_mkdir_p (g, "/new/foo/bar");
4625 r = guestfs_is_dir (g, "/new/foo");
4629 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
4636 static int test_mkdir_p_2 (void)
4638 /* InitBasicFS for mkdir_p (2): 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 (2) */
4682 r = guestfs_mkdir_p (g, "/new/foo/bar");
4689 r = guestfs_is_dir (g, "/new");
4693 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
4700 static int test_mkdir_0 (void)
4702 /* InitBasicFS for mkdir (0): 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 (0) */
4746 r = guestfs_mkdir (g, "/new");
4753 r = guestfs_is_dir (g, "/new");
4757 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
4764 static int test_mkdir_1 (void)
4766 /* InitBasicFS for mkdir (1): 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 /* TestLastFail for mkdir (1) */
4810 r = guestfs_mkdir (g, "/new/foo/bar");
4817 static int test_rm_rf_0 (void)
4819 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
4823 r = guestfs_umount_all (g);
4830 r = guestfs_lvm_remove_all (g);
4841 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4848 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4855 r = guestfs_mount (g, "/dev/sda1", "/");
4859 /* TestOutputFalse for rm_rf (0) */
4863 r = guestfs_mkdir (g, "/new");
4870 r = guestfs_mkdir (g, "/new/foo");
4877 r = guestfs_touch (g, "/new/foo/bar");
4884 r = guestfs_rm_rf (g, "/new");
4891 r = guestfs_exists (g, "/new");
4895 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
4902 static int test_rmdir_0 (void)
4904 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
4908 r = guestfs_umount_all (g);
4915 r = guestfs_lvm_remove_all (g);
4926 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4933 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4940 r = guestfs_mount (g, "/dev/sda1", "/");
4944 /* TestRun for rmdir (0) */
4948 r = guestfs_mkdir (g, "/new");
4955 r = guestfs_rmdir (g, "/new");
4962 static int test_rmdir_1 (void)
4964 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
4968 r = guestfs_umount_all (g);
4975 r = guestfs_lvm_remove_all (g);
4986 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4993 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5000 r = guestfs_mount (g, "/dev/sda1", "/");
5004 /* TestLastFail for rmdir (1) */
5008 r = guestfs_rmdir (g, "/new");
5015 static int test_rmdir_2 (void)
5017 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
5021 r = guestfs_umount_all (g);
5028 r = guestfs_lvm_remove_all (g);
5039 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5046 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5053 r = guestfs_mount (g, "/dev/sda1", "/");
5057 /* TestLastFail for rmdir (2) */
5061 r = guestfs_touch (g, "/new");
5068 r = guestfs_rmdir (g, "/new");
5075 static int test_rm_0 (void)
5077 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
5081 r = guestfs_umount_all (g);
5088 r = guestfs_lvm_remove_all (g);
5099 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5106 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5113 r = guestfs_mount (g, "/dev/sda1", "/");
5117 /* TestRun for rm (0) */
5121 r = guestfs_touch (g, "/new");
5128 r = guestfs_rm (g, "/new");
5135 static int test_rm_1 (void)
5137 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
5141 r = guestfs_umount_all (g);
5148 r = guestfs_lvm_remove_all (g);
5159 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5166 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5173 r = guestfs_mount (g, "/dev/sda1", "/");
5177 /* TestLastFail for rm (1) */
5181 r = guestfs_rm (g, "/new");
5188 static int test_rm_2 (void)
5190 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
5194 r = guestfs_umount_all (g);
5201 r = guestfs_lvm_remove_all (g);
5212 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5219 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5226 r = guestfs_mount (g, "/dev/sda1", "/");
5230 /* TestLastFail for rm (2) */
5234 r = guestfs_mkdir (g, "/new");
5241 r = guestfs_rm (g, "/new");
5248 static int test_read_lines_0 (void)
5250 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
5254 r = guestfs_umount_all (g);
5261 r = guestfs_lvm_remove_all (g);
5272 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5279 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5286 r = guestfs_mount (g, "/dev/sda1", "/");
5290 /* TestOutputList for read_lines (0) */
5294 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
5302 r = guestfs_read_lines (g, "/new");
5306 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5310 if (strcmp (r[0], "line1") != 0) {
5311 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
5315 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5319 if (strcmp (r[1], "line2") != 0) {
5320 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
5324 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5328 if (strcmp (r[2], "line3") != 0) {
5329 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
5333 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
5337 for (i = 0; r[i] != NULL; ++i)
5344 static int test_read_lines_1 (void)
5346 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
5350 r = guestfs_umount_all (g);
5357 r = guestfs_lvm_remove_all (g);
5368 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5375 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5382 r = guestfs_mount (g, "/dev/sda1", "/");
5386 /* TestOutputList for read_lines (1) */
5390 r = guestfs_write_file (g, "/new", "", 0);
5398 r = guestfs_read_lines (g, "/new");
5402 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
5406 for (i = 0; r[i] != NULL; ++i)
5413 static int test_lvs_0 (void)
5415 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
5419 r = guestfs_umount_all (g);
5426 r = guestfs_lvm_remove_all (g);
5437 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5444 r = guestfs_pvcreate (g, "/dev/sda1");
5449 char *physvols[] = {
5455 r = guestfs_vgcreate (g, "VG", physvols);
5462 r = guestfs_lvcreate (g, "LV", "VG", 8);
5469 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5476 r = guestfs_mount (g, "/dev/VG/LV", "/");
5480 /* TestOutputList for lvs (0) */
5485 r = guestfs_lvs (g);
5489 fprintf (stderr, "test_lvs_0: short list returned from command\n");
5493 if (strcmp (r[0], "/dev/VG/LV") != 0) {
5494 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
5498 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
5502 for (i = 0; r[i] != NULL; ++i)
5509 static int test_lvs_1 (void)
5511 /* InitEmpty for lvs (1) */
5515 r = guestfs_umount_all (g);
5522 r = guestfs_lvm_remove_all (g);
5526 /* TestOutputList for lvs (1) */
5536 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5543 r = guestfs_pvcreate (g, "/dev/sda1");
5550 r = guestfs_pvcreate (g, "/dev/sda2");
5557 r = guestfs_pvcreate (g, "/dev/sda3");
5562 char *physvols[] = {
5569 r = guestfs_vgcreate (g, "VG1", physvols);
5574 char *physvols[] = {
5580 r = guestfs_vgcreate (g, "VG2", physvols);
5587 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
5594 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
5601 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
5609 r = guestfs_lvs (g);
5613 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5617 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
5618 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
5622 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5626 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
5627 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
5631 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5635 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
5636 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
5640 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
5644 for (i = 0; r[i] != NULL; ++i)
5651 static int test_vgs_0 (void)
5653 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
5657 r = guestfs_umount_all (g);
5664 r = guestfs_lvm_remove_all (g);
5675 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5682 r = guestfs_pvcreate (g, "/dev/sda1");
5687 char *physvols[] = {
5693 r = guestfs_vgcreate (g, "VG", physvols);
5700 r = guestfs_lvcreate (g, "LV", "VG", 8);
5707 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5714 r = guestfs_mount (g, "/dev/VG/LV", "/");
5718 /* TestOutputList for vgs (0) */
5723 r = guestfs_vgs (g);
5727 fprintf (stderr, "test_vgs_0: short list returned from command\n");
5731 if (strcmp (r[0], "VG") != 0) {
5732 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
5736 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
5740 for (i = 0; r[i] != NULL; ++i)
5747 static int test_vgs_1 (void)
5749 /* InitEmpty for vgs (1) */
5753 r = guestfs_umount_all (g);
5760 r = guestfs_lvm_remove_all (g);
5764 /* TestOutputList for vgs (1) */
5774 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5781 r = guestfs_pvcreate (g, "/dev/sda1");
5788 r = guestfs_pvcreate (g, "/dev/sda2");
5795 r = guestfs_pvcreate (g, "/dev/sda3");
5800 char *physvols[] = {
5807 r = guestfs_vgcreate (g, "VG1", physvols);
5812 char *physvols[] = {
5818 r = guestfs_vgcreate (g, "VG2", physvols);
5826 r = guestfs_vgs (g);
5830 fprintf (stderr, "test_vgs_1: short list returned from command\n");
5834 if (strcmp (r[0], "VG1") != 0) {
5835 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
5839 fprintf (stderr, "test_vgs_1: short list returned from command\n");
5843 if (strcmp (r[1], "VG2") != 0) {
5844 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
5848 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
5852 for (i = 0; r[i] != NULL; ++i)
5859 static int test_pvs_0 (void)
5861 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
5865 r = guestfs_umount_all (g);
5872 r = guestfs_lvm_remove_all (g);
5883 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5890 r = guestfs_pvcreate (g, "/dev/sda1");
5895 char *physvols[] = {
5901 r = guestfs_vgcreate (g, "VG", physvols);
5908 r = guestfs_lvcreate (g, "LV", "VG", 8);
5915 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5922 r = guestfs_mount (g, "/dev/VG/LV", "/");
5926 /* TestOutputList for pvs (0) */
5931 r = guestfs_pvs (g);
5935 fprintf (stderr, "test_pvs_0: short list returned from command\n");
5939 if (strcmp (r[0], "/dev/sda1") != 0) {
5940 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
5944 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
5948 for (i = 0; r[i] != NULL; ++i)
5955 static int test_pvs_1 (void)
5957 /* InitEmpty for pvs (1) */
5961 r = guestfs_umount_all (g);
5968 r = guestfs_lvm_remove_all (g);
5972 /* TestOutputList for pvs (1) */
5982 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5989 r = guestfs_pvcreate (g, "/dev/sda1");
5996 r = guestfs_pvcreate (g, "/dev/sda2");
6003 r = guestfs_pvcreate (g, "/dev/sda3");
6011 r = guestfs_pvs (g);
6015 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6019 if (strcmp (r[0], "/dev/sda1") != 0) {
6020 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6024 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6028 if (strcmp (r[1], "/dev/sda2") != 0) {
6029 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6033 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6037 if (strcmp (r[2], "/dev/sda3") != 0) {
6038 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6042 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
6046 for (i = 0; r[i] != NULL; ++i)
6053 static int test_list_partitions_0 (void)
6055 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
6059 r = guestfs_umount_all (g);
6066 r = guestfs_lvm_remove_all (g);
6077 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6084 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6091 r = guestfs_mount (g, "/dev/sda1", "/");
6095 /* TestOutputList for list_partitions (0) */
6100 r = guestfs_list_partitions (g);
6104 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
6108 if (strcmp (r[0], "/dev/sda1") != 0) {
6109 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6113 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
6117 for (i = 0; r[i] != NULL; ++i)
6124 static int test_list_partitions_1 (void)
6126 /* InitEmpty for list_partitions (1) */
6130 r = guestfs_umount_all (g);
6137 r = guestfs_lvm_remove_all (g);
6141 /* TestOutputList for list_partitions (1) */
6151 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6159 r = guestfs_list_partitions (g);
6163 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6167 if (strcmp (r[0], "/dev/sda1") != 0) {
6168 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6172 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6176 if (strcmp (r[1], "/dev/sda2") != 0) {
6177 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6181 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6185 if (strcmp (r[2], "/dev/sda3") != 0) {
6186 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6190 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
6194 for (i = 0; r[i] != NULL; ++i)
6201 static int test_list_devices_0 (void)
6203 /* InitEmpty for list_devices (0) */
6207 r = guestfs_umount_all (g);
6214 r = guestfs_lvm_remove_all (g);
6218 /* TestOutputList for list_devices (0) */
6223 r = guestfs_list_devices (g);
6227 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6231 if (strcmp (r[0], "/dev/sda") != 0) {
6232 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
6236 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6240 if (strcmp (r[1], "/dev/sdb") != 0) {
6241 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
6245 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6249 if (strcmp (r[2], "/dev/sdc") != 0) {
6250 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
6254 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
6258 for (i = 0; r[i] != NULL; ++i)
6265 static int test_ls_0 (void)
6267 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
6271 r = guestfs_umount_all (g);
6278 r = guestfs_lvm_remove_all (g);
6289 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6296 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6303 r = guestfs_mount (g, "/dev/sda1", "/");
6307 /* TestOutputList for ls (0) */
6311 r = guestfs_touch (g, "/new");
6318 r = guestfs_touch (g, "/newer");
6325 r = guestfs_touch (g, "/newest");
6333 r = guestfs_ls (g, "/");
6337 fprintf (stderr, "test_ls_0: short list returned from command\n");
6341 if (strcmp (r[0], "lost+found") != 0) {
6342 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
6346 fprintf (stderr, "test_ls_0: short list returned from command\n");
6350 if (strcmp (r[1], "new") != 0) {
6351 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
6355 fprintf (stderr, "test_ls_0: short list returned from command\n");
6359 if (strcmp (r[2], "newer") != 0) {
6360 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
6364 fprintf (stderr, "test_ls_0: short list returned from command\n");
6368 if (strcmp (r[3], "newest") != 0) {
6369 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
6373 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
6377 for (i = 0; r[i] != NULL; ++i)
6384 static int test_cat_0 (void)
6386 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
6390 r = guestfs_umount_all (g);
6397 r = guestfs_lvm_remove_all (g);
6408 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6415 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6422 r = guestfs_mount (g, "/dev/sda1", "/");
6426 /* TestOutput for cat (0) */
6430 r = guestfs_write_file (g, "/new", "new file contents", 0);
6437 r = guestfs_cat (g, "/new");
6440 if (strcmp (r, "new file contents") != 0) {
6441 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
6449 static int test_touch_0 (void)
6451 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
6455 r = guestfs_umount_all (g);
6462 r = guestfs_lvm_remove_all (g);
6473 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6480 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6487 r = guestfs_mount (g, "/dev/sda1", "/");
6491 /* TestOutputTrue for touch (0) */
6495 r = guestfs_touch (g, "/new");
6502 r = guestfs_exists (g, "/new");
6506 fprintf (stderr, "test_touch_0: expected true, got false\n");
6513 static int test_sync_0 (void)
6515 /* InitEmpty for sync (0) */
6519 r = guestfs_umount_all (g);
6526 r = guestfs_lvm_remove_all (g);
6530 /* TestRun for sync (0) */
6534 r = guestfs_sync (g);
6541 static int test_mount_0 (void)
6543 /* InitEmpty for mount (0) */
6547 r = guestfs_umount_all (g);
6554 r = guestfs_lvm_remove_all (g);
6558 /* TestOutput for mount (0) */
6566 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6573 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6580 r = guestfs_mount (g, "/dev/sda1", "/");
6587 r = guestfs_write_file (g, "/new", "new file contents", 0);
6594 r = guestfs_cat (g, "/new");
6597 if (strcmp (r, "new file contents") != 0) {
6598 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
6606 int main (int argc, char *argv[])
6611 const char *filename;
6613 int nr_tests, test_num = 0;
6615 no_test_warnings ();
6617 g = guestfs_create ();
6619 printf ("guestfs_create FAILED\n");
6623 guestfs_set_error_handler (g, print_error, NULL);
6625 srcdir = getenv ("srcdir");
6626 if (!srcdir) srcdir = ".";
6628 guestfs_set_path (g, ".");
6630 filename = "test1.img";
6631 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6636 if (lseek (fd, 524288000, SEEK_SET) == -1) {
6642 if (write (fd, &c, 1) == -1) {
6648 if (close (fd) == -1) {
6653 if (guestfs_add_drive (g, filename) == -1) {
6654 printf ("guestfs_add_drive %s FAILED\n", filename);
6658 filename = "test2.img";
6659 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6664 if (lseek (fd, 52428800, SEEK_SET) == -1) {
6670 if (write (fd, &c, 1) == -1) {
6676 if (close (fd) == -1) {
6681 if (guestfs_add_drive (g, filename) == -1) {
6682 printf ("guestfs_add_drive %s FAILED\n", filename);
6686 filename = "test3.img";
6687 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6692 if (lseek (fd, 10485760, SEEK_SET) == -1) {
6698 if (write (fd, &c, 1) == -1) {
6704 if (close (fd) == -1) {
6709 if (guestfs_add_drive (g, filename) == -1) {
6710 printf ("guestfs_add_drive %s FAILED\n", filename);
6714 if (guestfs_launch (g) == -1) {
6715 printf ("guestfs_launch FAILED\n");
6718 if (guestfs_wait_ready (g) == -1) {
6719 printf ("guestfs_wait_ready FAILED\n");
6726 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
6727 if (test_zero_0 () == -1) {
6728 printf ("test_zero_0 FAILED\n");
6732 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
6733 if (test_fsck_0 () == -1) {
6734 printf ("test_fsck_0 FAILED\n");
6738 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
6739 if (test_fsck_1 () == -1) {
6740 printf ("test_fsck_1 FAILED\n");
6744 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
6745 if (test_set_e2uuid_0 () == -1) {
6746 printf ("test_set_e2uuid_0 FAILED\n");
6750 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
6751 if (test_set_e2uuid_1 () == -1) {
6752 printf ("test_set_e2uuid_1 FAILED\n");
6756 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
6757 if (test_set_e2uuid_2 () == -1) {
6758 printf ("test_set_e2uuid_2 FAILED\n");
6762 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
6763 if (test_set_e2uuid_3 () == -1) {
6764 printf ("test_set_e2uuid_3 FAILED\n");
6768 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
6769 if (test_set_e2label_0 () == -1) {
6770 printf ("test_set_e2label_0 FAILED\n");
6774 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
6775 if (test_pvremove_0 () == -1) {
6776 printf ("test_pvremove_0 FAILED\n");
6780 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
6781 if (test_pvremove_1 () == -1) {
6782 printf ("test_pvremove_1 FAILED\n");
6786 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
6787 if (test_pvremove_2 () == -1) {
6788 printf ("test_pvremove_2 FAILED\n");
6792 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
6793 if (test_vgremove_0 () == -1) {
6794 printf ("test_vgremove_0 FAILED\n");
6798 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
6799 if (test_vgremove_1 () == -1) {
6800 printf ("test_vgremove_1 FAILED\n");
6804 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
6805 if (test_lvremove_0 () == -1) {
6806 printf ("test_lvremove_0 FAILED\n");
6810 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
6811 if (test_lvremove_1 () == -1) {
6812 printf ("test_lvremove_1 FAILED\n");
6816 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
6817 if (test_lvremove_2 () == -1) {
6818 printf ("test_lvremove_2 FAILED\n");
6822 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
6823 if (test_mount_ro_0 () == -1) {
6824 printf ("test_mount_ro_0 FAILED\n");
6828 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
6829 if (test_mount_ro_1 () == -1) {
6830 printf ("test_mount_ro_1 FAILED\n");
6834 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
6835 if (test_tgz_in_0 () == -1) {
6836 printf ("test_tgz_in_0 FAILED\n");
6840 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
6841 if (test_tar_in_0 () == -1) {
6842 printf ("test_tar_in_0 FAILED\n");
6846 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
6847 if (test_checksum_0 () == -1) {
6848 printf ("test_checksum_0 FAILED\n");
6852 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
6853 if (test_checksum_1 () == -1) {
6854 printf ("test_checksum_1 FAILED\n");
6858 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
6859 if (test_checksum_2 () == -1) {
6860 printf ("test_checksum_2 FAILED\n");
6864 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
6865 if (test_checksum_3 () == -1) {
6866 printf ("test_checksum_3 FAILED\n");
6870 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
6871 if (test_checksum_4 () == -1) {
6872 printf ("test_checksum_4 FAILED\n");
6876 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
6877 if (test_checksum_5 () == -1) {
6878 printf ("test_checksum_5 FAILED\n");
6882 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
6883 if (test_checksum_6 () == -1) {
6884 printf ("test_checksum_6 FAILED\n");
6888 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
6889 if (test_checksum_7 () == -1) {
6890 printf ("test_checksum_7 FAILED\n");
6894 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
6895 if (test_download_0 () == -1) {
6896 printf ("test_download_0 FAILED\n");
6900 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
6901 if (test_upload_0 () == -1) {
6902 printf ("test_upload_0 FAILED\n");
6906 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
6907 if (test_blockdev_rereadpt_0 () == -1) {
6908 printf ("test_blockdev_rereadpt_0 FAILED\n");
6912 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
6913 if (test_blockdev_flushbufs_0 () == -1) {
6914 printf ("test_blockdev_flushbufs_0 FAILED\n");
6918 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
6919 if (test_blockdev_getsize64_0 () == -1) {
6920 printf ("test_blockdev_getsize64_0 FAILED\n");
6924 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
6925 if (test_blockdev_getsz_0 () == -1) {
6926 printf ("test_blockdev_getsz_0 FAILED\n");
6930 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
6931 if (test_blockdev_getbsz_0 () == -1) {
6932 printf ("test_blockdev_getbsz_0 FAILED\n");
6936 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
6937 if (test_blockdev_getss_0 () == -1) {
6938 printf ("test_blockdev_getss_0 FAILED\n");
6942 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
6943 if (test_blockdev_getro_0 () == -1) {
6944 printf ("test_blockdev_getro_0 FAILED\n");
6948 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
6949 if (test_blockdev_setrw_0 () == -1) {
6950 printf ("test_blockdev_setrw_0 FAILED\n");
6954 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
6955 if (test_blockdev_setro_0 () == -1) {
6956 printf ("test_blockdev_setro_0 FAILED\n");
6960 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
6961 if (test_statvfs_0 () == -1) {
6962 printf ("test_statvfs_0 FAILED\n");
6966 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
6967 if (test_lstat_0 () == -1) {
6968 printf ("test_lstat_0 FAILED\n");
6972 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
6973 if (test_stat_0 () == -1) {
6974 printf ("test_stat_0 FAILED\n");
6978 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
6979 if (test_file_0 () == -1) {
6980 printf ("test_file_0 FAILED\n");
6984 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
6985 if (test_file_1 () == -1) {
6986 printf ("test_file_1 FAILED\n");
6990 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
6991 if (test_file_2 () == -1) {
6992 printf ("test_file_2 FAILED\n");
6996 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
6997 if (test_umount_all_0 () == -1) {
6998 printf ("test_umount_all_0 FAILED\n");
7002 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
7003 if (test_umount_all_1 () == -1) {
7004 printf ("test_umount_all_1 FAILED\n");
7008 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
7009 if (test_mounts_0 () == -1) {
7010 printf ("test_mounts_0 FAILED\n");
7014 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
7015 if (test_umount_0 () == -1) {
7016 printf ("test_umount_0 FAILED\n");
7020 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
7021 if (test_umount_1 () == -1) {
7022 printf ("test_umount_1 FAILED\n");
7026 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
7027 if (test_write_file_0 () == -1) {
7028 printf ("test_write_file_0 FAILED\n");
7032 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
7033 if (test_write_file_1 () == -1) {
7034 printf ("test_write_file_1 FAILED\n");
7038 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
7039 if (test_write_file_2 () == -1) {
7040 printf ("test_write_file_2 FAILED\n");
7044 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
7045 if (test_write_file_3 () == -1) {
7046 printf ("test_write_file_3 FAILED\n");
7050 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
7051 if (test_write_file_4 () == -1) {
7052 printf ("test_write_file_4 FAILED\n");
7056 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
7057 if (test_write_file_5 () == -1) {
7058 printf ("test_write_file_5 FAILED\n");
7062 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
7063 if (test_mkfs_0 () == -1) {
7064 printf ("test_mkfs_0 FAILED\n");
7068 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
7069 if (test_lvcreate_0 () == -1) {
7070 printf ("test_lvcreate_0 FAILED\n");
7074 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
7075 if (test_vgcreate_0 () == -1) {
7076 printf ("test_vgcreate_0 FAILED\n");
7080 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
7081 if (test_pvcreate_0 () == -1) {
7082 printf ("test_pvcreate_0 FAILED\n");
7086 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
7087 if (test_is_dir_0 () == -1) {
7088 printf ("test_is_dir_0 FAILED\n");
7092 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
7093 if (test_is_dir_1 () == -1) {
7094 printf ("test_is_dir_1 FAILED\n");
7098 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
7099 if (test_is_file_0 () == -1) {
7100 printf ("test_is_file_0 FAILED\n");
7104 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
7105 if (test_is_file_1 () == -1) {
7106 printf ("test_is_file_1 FAILED\n");
7110 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
7111 if (test_exists_0 () == -1) {
7112 printf ("test_exists_0 FAILED\n");
7116 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
7117 if (test_exists_1 () == -1) {
7118 printf ("test_exists_1 FAILED\n");
7122 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
7123 if (test_mkdir_p_0 () == -1) {
7124 printf ("test_mkdir_p_0 FAILED\n");
7128 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
7129 if (test_mkdir_p_1 () == -1) {
7130 printf ("test_mkdir_p_1 FAILED\n");
7134 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
7135 if (test_mkdir_p_2 () == -1) {
7136 printf ("test_mkdir_p_2 FAILED\n");
7140 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
7141 if (test_mkdir_0 () == -1) {
7142 printf ("test_mkdir_0 FAILED\n");
7146 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
7147 if (test_mkdir_1 () == -1) {
7148 printf ("test_mkdir_1 FAILED\n");
7152 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
7153 if (test_rm_rf_0 () == -1) {
7154 printf ("test_rm_rf_0 FAILED\n");
7158 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
7159 if (test_rmdir_0 () == -1) {
7160 printf ("test_rmdir_0 FAILED\n");
7164 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
7165 if (test_rmdir_1 () == -1) {
7166 printf ("test_rmdir_1 FAILED\n");
7170 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
7171 if (test_rmdir_2 () == -1) {
7172 printf ("test_rmdir_2 FAILED\n");
7176 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
7177 if (test_rm_0 () == -1) {
7178 printf ("test_rm_0 FAILED\n");
7182 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
7183 if (test_rm_1 () == -1) {
7184 printf ("test_rm_1 FAILED\n");
7188 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
7189 if (test_rm_2 () == -1) {
7190 printf ("test_rm_2 FAILED\n");
7194 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
7195 if (test_read_lines_0 () == -1) {
7196 printf ("test_read_lines_0 FAILED\n");
7200 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
7201 if (test_read_lines_1 () == -1) {
7202 printf ("test_read_lines_1 FAILED\n");
7206 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
7207 if (test_lvs_0 () == -1) {
7208 printf ("test_lvs_0 FAILED\n");
7212 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
7213 if (test_lvs_1 () == -1) {
7214 printf ("test_lvs_1 FAILED\n");
7218 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
7219 if (test_vgs_0 () == -1) {
7220 printf ("test_vgs_0 FAILED\n");
7224 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
7225 if (test_vgs_1 () == -1) {
7226 printf ("test_vgs_1 FAILED\n");
7230 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
7231 if (test_pvs_0 () == -1) {
7232 printf ("test_pvs_0 FAILED\n");
7236 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
7237 if (test_pvs_1 () == -1) {
7238 printf ("test_pvs_1 FAILED\n");
7242 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
7243 if (test_list_partitions_0 () == -1) {
7244 printf ("test_list_partitions_0 FAILED\n");
7248 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
7249 if (test_list_partitions_1 () == -1) {
7250 printf ("test_list_partitions_1 FAILED\n");
7254 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
7255 if (test_list_devices_0 () == -1) {
7256 printf ("test_list_devices_0 FAILED\n");
7260 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
7261 if (test_ls_0 () == -1) {
7262 printf ("test_ls_0 FAILED\n");
7266 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
7267 if (test_cat_0 () == -1) {
7268 printf ("test_cat_0 FAILED\n");
7272 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
7273 if (test_touch_0 () == -1) {
7274 printf ("test_touch_0 FAILED\n");
7278 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
7279 if (test_sync_0 () == -1) {
7280 printf ("test_sync_0 FAILED\n");
7284 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
7285 if (test_mount_0 () == -1) {
7286 printf ("test_mount_0 FAILED\n");
7291 unlink ("test1.img");
7292 unlink ("test2.img");
7293 unlink ("test3.img");
7296 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);