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_ping_daemon_0 (void)
117 /* InitEmpty for ping_daemon (0) */
121 r = guestfs_umount_all (g);
128 r = guestfs_lvm_remove_all (g);
132 /* TestRun for ping_daemon (0) */
136 r = guestfs_ping_daemon (g);
143 static int test_dmesg_0 (void)
145 /* InitEmpty for dmesg (0) */
149 r = guestfs_umount_all (g);
156 r = guestfs_lvm_remove_all (g);
160 /* TestRun for dmesg (0) */
164 r = guestfs_dmesg (g);
172 static int test_drop_caches_0 (void)
174 /* InitEmpty for drop_caches (0) */
178 r = guestfs_umount_all (g);
185 r = guestfs_lvm_remove_all (g);
189 /* TestRun for drop_caches (0) */
193 r = guestfs_drop_caches (g, 3);
200 static int test_mv_0 (void)
202 /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
206 r = guestfs_umount_all (g);
213 r = guestfs_lvm_remove_all (g);
224 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
231 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
238 r = guestfs_mount (g, "/dev/sda1", "/");
242 /* TestOutput for mv (0) */
246 r = guestfs_write_file (g, "/old", "file content", 0);
253 r = guestfs_mv (g, "/old", "/new");
260 r = guestfs_cat (g, "/new");
263 if (strcmp (r, "file content") != 0) {
264 fprintf (stderr, "test_mv_0: expected \"file content\" but got \"%s\"\n", r);
272 static int test_mv_1 (void)
274 /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
278 r = guestfs_umount_all (g);
285 r = guestfs_lvm_remove_all (g);
296 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
303 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
310 r = guestfs_mount (g, "/dev/sda1", "/");
314 /* TestOutputFalse for mv (1) */
318 r = guestfs_write_file (g, "/old", "file content", 0);
325 r = guestfs_mv (g, "/old", "/new");
332 r = guestfs_is_file (g, "/old");
336 fprintf (stderr, "test_mv_1: expected false, got true\n");
343 static int test_cp_a_0 (void)
345 /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
349 r = guestfs_umount_all (g);
356 r = guestfs_lvm_remove_all (g);
367 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
374 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
381 r = guestfs_mount (g, "/dev/sda1", "/");
385 /* TestOutput for cp_a (0) */
389 r = guestfs_mkdir (g, "/olddir");
396 r = guestfs_mkdir (g, "/newdir");
403 r = guestfs_write_file (g, "/olddir/file", "file content", 0);
410 r = guestfs_cp_a (g, "/olddir", "/newdir");
417 r = guestfs_cat (g, "/newdir/olddir/file");
420 if (strcmp (r, "file content") != 0) {
421 fprintf (stderr, "test_cp_a_0: expected \"file content\" but got \"%s\"\n", r);
429 static int test_cp_0 (void)
431 /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
435 r = guestfs_umount_all (g);
442 r = guestfs_lvm_remove_all (g);
453 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
460 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
467 r = guestfs_mount (g, "/dev/sda1", "/");
471 /* TestOutput for cp (0) */
475 r = guestfs_write_file (g, "/old", "file content", 0);
482 r = guestfs_cp (g, "/old", "/new");
489 r = guestfs_cat (g, "/new");
492 if (strcmp (r, "file content") != 0) {
493 fprintf (stderr, "test_cp_0: expected \"file content\" but got \"%s\"\n", r);
501 static int test_cp_1 (void)
503 /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
507 r = guestfs_umount_all (g);
514 r = guestfs_lvm_remove_all (g);
525 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
532 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
539 r = guestfs_mount (g, "/dev/sda1", "/");
543 /* TestOutputTrue for cp (1) */
547 r = guestfs_write_file (g, "/old", "file content", 0);
554 r = guestfs_cp (g, "/old", "/new");
561 r = guestfs_is_file (g, "/old");
565 fprintf (stderr, "test_cp_1: expected true, got false\n");
572 static int test_cp_2 (void)
574 /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
578 r = guestfs_umount_all (g);
585 r = guestfs_lvm_remove_all (g);
596 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
603 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
610 r = guestfs_mount (g, "/dev/sda1", "/");
614 /* TestOutput for cp (2) */
618 r = guestfs_write_file (g, "/old", "file content", 0);
625 r = guestfs_mkdir (g, "/dir");
632 r = guestfs_cp (g, "/old", "/dir/new");
639 r = guestfs_cat (g, "/dir/new");
642 if (strcmp (r, "file content") != 0) {
643 fprintf (stderr, "test_cp_2: expected \"file content\" but got \"%s\"\n", r);
651 static int test_grub_install_0 (void)
653 /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
657 r = guestfs_umount_all (g);
664 r = guestfs_lvm_remove_all (g);
675 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
682 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
689 r = guestfs_mount (g, "/dev/sda1", "/");
693 /* TestOutputTrue for grub_install (0) */
697 r = guestfs_grub_install (g, "/", "/dev/sda1");
704 r = guestfs_is_dir (g, "/boot");
708 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
715 static int test_zero_0 (void)
717 /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
721 r = guestfs_umount_all (g);
728 r = guestfs_lvm_remove_all (g);
739 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
746 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
753 r = guestfs_mount (g, "/dev/sda1", "/");
757 /* TestOutput for zero (0) */
761 r = guestfs_umount (g, "/dev/sda1");
768 r = guestfs_zero (g, "/dev/sda1");
775 r = guestfs_file (g, "/dev/sda1");
778 if (strcmp (r, "data") != 0) {
779 fprintf (stderr, "test_zero_0: expected \"data\" but got \"%s\"\n", r);
787 static int test_fsck_0 (void)
789 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
793 r = guestfs_umount_all (g);
800 r = guestfs_lvm_remove_all (g);
811 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
818 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
825 r = guestfs_mount (g, "/dev/sda1", "/");
829 /* TestOutputInt for fsck (0) */
833 r = guestfs_umount (g, "/dev/sda1");
840 r = guestfs_fsck (g, "ext2", "/dev/sda1");
844 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
851 static int test_fsck_1 (void)
853 /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
857 r = guestfs_umount_all (g);
864 r = guestfs_lvm_remove_all (g);
875 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
882 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
889 r = guestfs_mount (g, "/dev/sda1", "/");
893 /* TestOutputInt for fsck (1) */
897 r = guestfs_umount (g, "/dev/sda1");
904 r = guestfs_zero (g, "/dev/sda1");
911 r = guestfs_fsck (g, "ext2", "/dev/sda1");
915 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
922 static int test_set_e2uuid_0 (void)
924 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
928 r = guestfs_umount_all (g);
935 r = guestfs_lvm_remove_all (g);
946 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
953 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
960 r = guestfs_mount (g, "/dev/sda1", "/");
964 /* TestOutput for set_e2uuid (0) */
968 r = guestfs_set_e2uuid (g, "/dev/sda1", "a3a61220-882b-4f61-89f4-cf24dcc7297d");
975 r = guestfs_get_e2uuid (g, "/dev/sda1");
978 if (strcmp (r, "a3a61220-882b-4f61-89f4-cf24dcc7297d") != 0) {
979 fprintf (stderr, "test_set_e2uuid_0: expected \"a3a61220-882b-4f61-89f4-cf24dcc7297d\" but got \"%s\"\n", r);
987 static int test_set_e2uuid_1 (void)
989 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
993 r = guestfs_umount_all (g);
1000 r = guestfs_lvm_remove_all (g);
1011 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1018 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1025 r = guestfs_mount (g, "/dev/sda1", "/");
1029 /* TestOutput for set_e2uuid (1) */
1033 r = guestfs_set_e2uuid (g, "/dev/sda1", "clear");
1040 r = guestfs_get_e2uuid (g, "/dev/sda1");
1043 if (strcmp (r, "") != 0) {
1044 fprintf (stderr, "test_set_e2uuid_1: expected \"\" but got \"%s\"\n", r);
1052 static int test_set_e2uuid_2 (void)
1054 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1058 r = guestfs_umount_all (g);
1065 r = guestfs_lvm_remove_all (g);
1076 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1083 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1090 r = guestfs_mount (g, "/dev/sda1", "/");
1094 /* TestRun for set_e2uuid (2) */
1098 r = guestfs_set_e2uuid (g, "/dev/sda1", "random");
1105 static int test_set_e2uuid_3 (void)
1107 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
1111 r = guestfs_umount_all (g);
1118 r = guestfs_lvm_remove_all (g);
1129 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1136 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1143 r = guestfs_mount (g, "/dev/sda1", "/");
1147 /* TestRun for set_e2uuid (3) */
1151 r = guestfs_set_e2uuid (g, "/dev/sda1", "time");
1158 static int test_set_e2label_0 (void)
1160 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
1164 r = guestfs_umount_all (g);
1171 r = guestfs_lvm_remove_all (g);
1182 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1189 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1196 r = guestfs_mount (g, "/dev/sda1", "/");
1200 /* TestOutput for set_e2label (0) */
1204 r = guestfs_set_e2label (g, "/dev/sda1", "testlabel");
1211 r = guestfs_get_e2label (g, "/dev/sda1");
1214 if (strcmp (r, "testlabel") != 0) {
1215 fprintf (stderr, "test_set_e2label_0: expected \"testlabel\" but got \"%s\"\n", r);
1223 static int test_pvremove_0 (void)
1225 /* InitEmpty for pvremove (0) */
1229 r = guestfs_umount_all (g);
1236 r = guestfs_lvm_remove_all (g);
1240 /* TestOutputList for pvremove (0) */
1244 r = guestfs_pvcreate (g, "/dev/sda");
1249 char *physvols[] = {
1255 r = guestfs_vgcreate (g, "VG", physvols);
1262 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1269 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1276 r = guestfs_vgremove (g, "VG");
1283 r = guestfs_pvremove (g, "/dev/sda");
1291 r = guestfs_lvs (g);
1295 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
1299 for (i = 0; r[i] != NULL; ++i)
1306 static int test_pvremove_1 (void)
1308 /* InitEmpty for pvremove (1) */
1312 r = guestfs_umount_all (g);
1319 r = guestfs_lvm_remove_all (g);
1323 /* TestOutputList for pvremove (1) */
1327 r = guestfs_pvcreate (g, "/dev/sda");
1332 char *physvols[] = {
1338 r = guestfs_vgcreate (g, "VG", physvols);
1345 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1352 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1359 r = guestfs_vgremove (g, "VG");
1366 r = guestfs_pvremove (g, "/dev/sda");
1374 r = guestfs_vgs (g);
1378 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
1382 for (i = 0; r[i] != NULL; ++i)
1389 static int test_pvremove_2 (void)
1391 /* InitEmpty for pvremove (2) */
1395 r = guestfs_umount_all (g);
1402 r = guestfs_lvm_remove_all (g);
1406 /* TestOutputList for pvremove (2) */
1410 r = guestfs_pvcreate (g, "/dev/sda");
1415 char *physvols[] = {
1421 r = guestfs_vgcreate (g, "VG", physvols);
1428 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1435 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1442 r = guestfs_vgremove (g, "VG");
1449 r = guestfs_pvremove (g, "/dev/sda");
1457 r = guestfs_pvs (g);
1461 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
1465 for (i = 0; r[i] != NULL; ++i)
1472 static int test_vgremove_0 (void)
1474 /* InitEmpty for vgremove (0) */
1478 r = guestfs_umount_all (g);
1485 r = guestfs_lvm_remove_all (g);
1489 /* TestOutputList for vgremove (0) */
1493 r = guestfs_pvcreate (g, "/dev/sda");
1498 char *physvols[] = {
1504 r = guestfs_vgcreate (g, "VG", physvols);
1511 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1518 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1525 r = guestfs_vgremove (g, "VG");
1533 r = guestfs_lvs (g);
1537 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
1541 for (i = 0; r[i] != NULL; ++i)
1548 static int test_vgremove_1 (void)
1550 /* InitEmpty for vgremove (1) */
1554 r = guestfs_umount_all (g);
1561 r = guestfs_lvm_remove_all (g);
1565 /* TestOutputList for vgremove (1) */
1569 r = guestfs_pvcreate (g, "/dev/sda");
1574 char *physvols[] = {
1580 r = guestfs_vgcreate (g, "VG", physvols);
1587 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1594 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1601 r = guestfs_vgremove (g, "VG");
1609 r = guestfs_vgs (g);
1613 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
1617 for (i = 0; r[i] != NULL; ++i)
1624 static int test_lvremove_0 (void)
1626 /* InitEmpty for lvremove (0) */
1630 r = guestfs_umount_all (g);
1637 r = guestfs_lvm_remove_all (g);
1641 /* TestOutputList for lvremove (0) */
1645 r = guestfs_pvcreate (g, "/dev/sda");
1650 char *physvols[] = {
1656 r = guestfs_vgcreate (g, "VG", physvols);
1663 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1670 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1677 r = guestfs_lvremove (g, "/dev/VG/LV1");
1685 r = guestfs_lvs (g);
1689 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
1693 if (strcmp (r[0], "/dev/VG/LV2") != 0) {
1694 fprintf (stderr, "test_lvremove_0: expected \"/dev/VG/LV2\" but got \"%s\"\n", r[0]);
1698 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
1702 for (i = 0; r[i] != NULL; ++i)
1709 static int test_lvremove_1 (void)
1711 /* InitEmpty for lvremove (1) */
1715 r = guestfs_umount_all (g);
1722 r = guestfs_lvm_remove_all (g);
1726 /* TestOutputList for lvremove (1) */
1730 r = guestfs_pvcreate (g, "/dev/sda");
1735 char *physvols[] = {
1741 r = guestfs_vgcreate (g, "VG", physvols);
1748 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1755 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1762 r = guestfs_lvremove (g, "/dev/VG");
1770 r = guestfs_lvs (g);
1774 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
1778 for (i = 0; r[i] != NULL; ++i)
1785 static int test_lvremove_2 (void)
1787 /* InitEmpty for lvremove (2) */
1791 r = guestfs_umount_all (g);
1798 r = guestfs_lvm_remove_all (g);
1802 /* TestOutputList for lvremove (2) */
1806 r = guestfs_pvcreate (g, "/dev/sda");
1811 char *physvols[] = {
1817 r = guestfs_vgcreate (g, "VG", physvols);
1824 r = guestfs_lvcreate (g, "LV1", "VG", 50);
1831 r = guestfs_lvcreate (g, "LV2", "VG", 50);
1838 r = guestfs_lvremove (g, "/dev/VG");
1846 r = guestfs_vgs (g);
1850 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
1854 if (strcmp (r[0], "VG") != 0) {
1855 fprintf (stderr, "test_lvremove_2: expected \"VG\" but got \"%s\"\n", r[0]);
1859 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
1863 for (i = 0; r[i] != NULL; ++i)
1870 static int test_mount_ro_0 (void)
1872 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
1876 r = guestfs_umount_all (g);
1883 r = guestfs_lvm_remove_all (g);
1894 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1901 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1908 r = guestfs_mount (g, "/dev/sda1", "/");
1912 /* TestLastFail for mount_ro (0) */
1916 r = guestfs_umount (g, "/");
1923 r = guestfs_mount_ro (g, "/dev/sda1", "/");
1930 r = guestfs_touch (g, "/new");
1937 static int test_mount_ro_1 (void)
1939 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
1943 r = guestfs_umount_all (g);
1950 r = guestfs_lvm_remove_all (g);
1961 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1968 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1975 r = guestfs_mount (g, "/dev/sda1", "/");
1979 /* TestOutput for mount_ro (1) */
1983 r = guestfs_write_file (g, "/new", "data", 0);
1990 r = guestfs_umount (g, "/");
1997 r = guestfs_mount_ro (g, "/dev/sda1", "/");
2004 r = guestfs_cat (g, "/new");
2007 if (strcmp (r, "data") != 0) {
2008 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
2016 static int test_tgz_in_0 (void)
2018 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
2022 r = guestfs_umount_all (g);
2029 r = guestfs_lvm_remove_all (g);
2040 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2047 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2054 r = guestfs_mount (g, "/dev/sda1", "/");
2058 /* TestOutput for tgz_in (0) */
2062 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
2069 r = guestfs_cat (g, "/hello");
2072 if (strcmp (r, "hello\n") != 0) {
2073 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
2081 static int test_tar_in_0 (void)
2083 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
2087 r = guestfs_umount_all (g);
2094 r = guestfs_lvm_remove_all (g);
2105 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2112 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2119 r = guestfs_mount (g, "/dev/sda1", "/");
2123 /* TestOutput for tar_in (0) */
2127 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
2134 r = guestfs_cat (g, "/hello");
2137 if (strcmp (r, "hello\n") != 0) {
2138 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
2146 static int test_checksum_0 (void)
2148 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
2152 r = guestfs_umount_all (g);
2159 r = guestfs_lvm_remove_all (g);
2170 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2177 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2184 r = guestfs_mount (g, "/dev/sda1", "/");
2188 /* TestOutput for checksum (0) */
2192 r = guestfs_write_file (g, "/new", "test\n", 0);
2199 r = guestfs_checksum (g, "crc", "/new");
2202 if (strcmp (r, "935282863") != 0) {
2203 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
2211 static int test_checksum_1 (void)
2213 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
2217 r = guestfs_umount_all (g);
2224 r = guestfs_lvm_remove_all (g);
2235 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2242 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2249 r = guestfs_mount (g, "/dev/sda1", "/");
2253 /* TestLastFail for checksum (1) */
2257 r = guestfs_checksum (g, "crc", "/new");
2265 static int test_checksum_2 (void)
2267 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
2271 r = guestfs_umount_all (g);
2278 r = guestfs_lvm_remove_all (g);
2289 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2296 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2303 r = guestfs_mount (g, "/dev/sda1", "/");
2307 /* TestOutput for checksum (2) */
2311 r = guestfs_write_file (g, "/new", "test\n", 0);
2318 r = guestfs_checksum (g, "md5", "/new");
2321 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
2322 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
2330 static int test_checksum_3 (void)
2332 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
2336 r = guestfs_umount_all (g);
2343 r = guestfs_lvm_remove_all (g);
2354 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2361 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2368 r = guestfs_mount (g, "/dev/sda1", "/");
2372 /* TestOutput for checksum (3) */
2376 r = guestfs_write_file (g, "/new", "test\n", 0);
2383 r = guestfs_checksum (g, "sha1", "/new");
2386 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
2387 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
2395 static int test_checksum_4 (void)
2397 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
2401 r = guestfs_umount_all (g);
2408 r = guestfs_lvm_remove_all (g);
2419 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2426 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2433 r = guestfs_mount (g, "/dev/sda1", "/");
2437 /* TestOutput for checksum (4) */
2441 r = guestfs_write_file (g, "/new", "test\n", 0);
2448 r = guestfs_checksum (g, "sha224", "/new");
2451 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
2452 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
2460 static int test_checksum_5 (void)
2462 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
2466 r = guestfs_umount_all (g);
2473 r = guestfs_lvm_remove_all (g);
2484 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2491 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2498 r = guestfs_mount (g, "/dev/sda1", "/");
2502 /* TestOutput for checksum (5) */
2506 r = guestfs_write_file (g, "/new", "test\n", 0);
2513 r = guestfs_checksum (g, "sha256", "/new");
2516 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
2517 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
2525 static int test_checksum_6 (void)
2527 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
2531 r = guestfs_umount_all (g);
2538 r = guestfs_lvm_remove_all (g);
2549 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2556 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2563 r = guestfs_mount (g, "/dev/sda1", "/");
2567 /* TestOutput for checksum (6) */
2571 r = guestfs_write_file (g, "/new", "test\n", 0);
2578 r = guestfs_checksum (g, "sha384", "/new");
2581 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
2582 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
2590 static int test_checksum_7 (void)
2592 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
2596 r = guestfs_umount_all (g);
2603 r = guestfs_lvm_remove_all (g);
2614 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2621 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2628 r = guestfs_mount (g, "/dev/sda1", "/");
2632 /* TestOutput for checksum (7) */
2636 r = guestfs_write_file (g, "/new", "test\n", 0);
2643 r = guestfs_checksum (g, "sha512", "/new");
2646 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
2647 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
2655 static int test_download_0 (void)
2657 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
2661 r = guestfs_umount_all (g);
2668 r = guestfs_lvm_remove_all (g);
2679 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2686 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2693 r = guestfs_mount (g, "/dev/sda1", "/");
2697 /* TestOutput for download (0) */
2701 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2708 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
2715 r = guestfs_upload (g, "testdownload.tmp", "/upload");
2722 r = guestfs_checksum (g, "md5", "/upload");
2725 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2726 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2734 static int test_upload_0 (void)
2736 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
2740 r = guestfs_umount_all (g);
2747 r = guestfs_lvm_remove_all (g);
2758 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2765 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2772 r = guestfs_mount (g, "/dev/sda1", "/");
2776 /* TestOutput for upload (0) */
2780 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
2787 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
2790 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
2791 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
2799 static int test_blockdev_rereadpt_0 (void)
2801 /* InitEmpty for blockdev_rereadpt (0) */
2805 r = guestfs_umount_all (g);
2812 r = guestfs_lvm_remove_all (g);
2816 /* TestRun for blockdev_rereadpt (0) */
2820 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
2827 static int test_blockdev_flushbufs_0 (void)
2829 /* InitEmpty for blockdev_flushbufs (0) */
2833 r = guestfs_umount_all (g);
2840 r = guestfs_lvm_remove_all (g);
2844 /* TestRun for blockdev_flushbufs (0) */
2848 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
2855 static int test_blockdev_getsize64_0 (void)
2857 /* InitEmpty for blockdev_getsize64 (0) */
2861 r = guestfs_umount_all (g);
2868 r = guestfs_lvm_remove_all (g);
2872 /* TestOutputInt for blockdev_getsize64 (0) */
2876 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
2879 if (r != 524288000) {
2880 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
2887 static int test_blockdev_getsz_0 (void)
2889 /* InitEmpty for blockdev_getsz (0) */
2893 r = guestfs_umount_all (g);
2900 r = guestfs_lvm_remove_all (g);
2904 /* TestOutputInt for blockdev_getsz (0) */
2908 r = guestfs_blockdev_getsz (g, "/dev/sda");
2912 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
2919 static int test_blockdev_getbsz_0 (void)
2921 /* InitEmpty for blockdev_getbsz (0) */
2925 r = guestfs_umount_all (g);
2932 r = guestfs_lvm_remove_all (g);
2936 /* TestOutputInt for blockdev_getbsz (0) */
2940 r = guestfs_blockdev_getbsz (g, "/dev/sda");
2944 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
2951 static int test_blockdev_getss_0 (void)
2953 /* InitEmpty for blockdev_getss (0) */
2957 r = guestfs_umount_all (g);
2964 r = guestfs_lvm_remove_all (g);
2968 /* TestOutputInt for blockdev_getss (0) */
2972 r = guestfs_blockdev_getss (g, "/dev/sda");
2976 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
2983 static int test_blockdev_getro_0 (void)
2985 /* InitEmpty for blockdev_getro (0) */
2989 r = guestfs_umount_all (g);
2996 r = guestfs_lvm_remove_all (g);
3000 /* TestOutputTrue for blockdev_getro (0) */
3004 r = guestfs_blockdev_setro (g, "/dev/sda");
3011 r = guestfs_blockdev_getro (g, "/dev/sda");
3015 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
3022 static int test_blockdev_setrw_0 (void)
3024 /* InitEmpty for blockdev_setrw (0) */
3028 r = guestfs_umount_all (g);
3035 r = guestfs_lvm_remove_all (g);
3039 /* TestOutputFalse for blockdev_setrw (0) */
3043 r = guestfs_blockdev_setrw (g, "/dev/sda");
3050 r = guestfs_blockdev_getro (g, "/dev/sda");
3054 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
3061 static int test_blockdev_setro_0 (void)
3063 /* InitEmpty for blockdev_setro (0) */
3067 r = guestfs_umount_all (g);
3074 r = guestfs_lvm_remove_all (g);
3078 /* TestOutputTrue for blockdev_setro (0) */
3082 r = guestfs_blockdev_setro (g, "/dev/sda");
3089 r = guestfs_blockdev_getro (g, "/dev/sda");
3093 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
3100 static int test_statvfs_0 (void)
3102 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
3106 r = guestfs_umount_all (g);
3113 r = guestfs_lvm_remove_all (g);
3124 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3131 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3138 r = guestfs_mount (g, "/dev/sda1", "/");
3142 /* TestOutputStruct for statvfs (0) */
3144 struct guestfs_statvfs *r;
3146 r = guestfs_statvfs (g, "/");
3149 if (r->bfree != 487702) {
3150 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
3154 if (r->blocks != 490020) {
3155 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
3159 if (r->bsize != 1024) {
3160 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
3169 static int test_lstat_0 (void)
3171 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
3175 r = guestfs_umount_all (g);
3182 r = guestfs_lvm_remove_all (g);
3193 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3200 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3207 r = guestfs_mount (g, "/dev/sda1", "/");
3211 /* TestOutputStruct for lstat (0) */
3215 r = guestfs_touch (g, "/new");
3220 struct guestfs_stat *r;
3222 r = guestfs_lstat (g, "/new");
3226 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
3235 static int test_stat_0 (void)
3237 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
3241 r = guestfs_umount_all (g);
3248 r = guestfs_lvm_remove_all (g);
3259 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3266 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3273 r = guestfs_mount (g, "/dev/sda1", "/");
3277 /* TestOutputStruct for stat (0) */
3281 r = guestfs_touch (g, "/new");
3286 struct guestfs_stat *r;
3288 r = guestfs_stat (g, "/new");
3292 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
3301 static int test_file_0 (void)
3303 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
3307 r = guestfs_umount_all (g);
3314 r = guestfs_lvm_remove_all (g);
3325 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3332 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3339 r = guestfs_mount (g, "/dev/sda1", "/");
3343 /* TestOutput for file (0) */
3347 r = guestfs_touch (g, "/new");
3354 r = guestfs_file (g, "/new");
3357 if (strcmp (r, "empty") != 0) {
3358 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
3366 static int test_file_1 (void)
3368 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
3372 r = guestfs_umount_all (g);
3379 r = guestfs_lvm_remove_all (g);
3390 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3397 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3404 r = guestfs_mount (g, "/dev/sda1", "/");
3408 /* TestOutput for file (1) */
3412 r = guestfs_write_file (g, "/new", "some content\n", 0);
3419 r = guestfs_file (g, "/new");
3422 if (strcmp (r, "ASCII text") != 0) {
3423 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
3431 static int test_file_2 (void)
3433 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
3437 r = guestfs_umount_all (g);
3444 r = guestfs_lvm_remove_all (g);
3455 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3462 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3469 r = guestfs_mount (g, "/dev/sda1", "/");
3473 /* TestLastFail for file (2) */
3477 r = guestfs_file (g, "/nofile");
3485 static int test_umount_all_0 (void)
3487 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
3491 r = guestfs_umount_all (g);
3498 r = guestfs_lvm_remove_all (g);
3509 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3516 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3523 r = guestfs_mount (g, "/dev/sda1", "/");
3527 /* TestOutputList for umount_all (0) */
3531 r = guestfs_umount_all (g);
3539 r = guestfs_mounts (g);
3543 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
3547 for (i = 0; r[i] != NULL; ++i)
3554 static int test_umount_all_1 (void)
3556 /* InitEmpty for umount_all (1) */
3560 r = guestfs_umount_all (g);
3567 r = guestfs_lvm_remove_all (g);
3571 /* TestOutputList for umount_all (1) */
3581 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3588 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3595 r = guestfs_mkfs (g, "ext2", "/dev/sda2");
3602 r = guestfs_mkfs (g, "ext2", "/dev/sda3");
3609 r = guestfs_mount (g, "/dev/sda1", "/");
3616 r = guestfs_mkdir (g, "/mp1");
3623 r = guestfs_mount (g, "/dev/sda2", "/mp1");
3630 r = guestfs_mkdir (g, "/mp1/mp2");
3637 r = guestfs_mount (g, "/dev/sda3", "/mp1/mp2");
3644 r = guestfs_mkdir (g, "/mp1/mp2/mp3");
3651 r = guestfs_umount_all (g);
3659 r = guestfs_mounts (g);
3663 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
3667 for (i = 0; r[i] != NULL; ++i)
3674 static int test_mounts_0 (void)
3676 /* InitBasicFS for mounts (0): 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 /* TestOutputList for mounts (0) */
3721 r = guestfs_mounts (g);
3725 fprintf (stderr, "test_mounts_0: short list returned from command\n");
3729 if (strcmp (r[0], "/dev/sda1") != 0) {
3730 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3734 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
3738 for (i = 0; r[i] != NULL; ++i)
3745 static int test_umount_0 (void)
3747 /* InitEmpty for umount (0) */
3751 r = guestfs_umount_all (g);
3758 r = guestfs_lvm_remove_all (g);
3762 /* TestOutputList for umount (0) */
3770 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3777 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3784 r = guestfs_mount (g, "/dev/sda1", "/");
3792 r = guestfs_mounts (g);
3796 fprintf (stderr, "test_umount_0: short list returned from command\n");
3800 if (strcmp (r[0], "/dev/sda1") != 0) {
3801 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3805 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
3809 for (i = 0; r[i] != NULL; ++i)
3816 static int test_umount_1 (void)
3818 /* InitEmpty for umount (1) */
3822 r = guestfs_umount_all (g);
3829 r = guestfs_lvm_remove_all (g);
3833 /* TestOutputList for umount (1) */
3841 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3848 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3855 r = guestfs_mount (g, "/dev/sda1", "/");
3862 r = guestfs_umount (g, "/");
3870 r = guestfs_mounts (g);
3874 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
3878 for (i = 0; r[i] != NULL; ++i)
3885 static int test_write_file_0 (void)
3887 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
3891 r = guestfs_umount_all (g);
3898 r = guestfs_lvm_remove_all (g);
3909 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3916 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3923 r = guestfs_mount (g, "/dev/sda1", "/");
3927 /* TestOutput for write_file (0) */
3931 r = guestfs_write_file (g, "/new", "new file contents", 0);
3938 r = guestfs_cat (g, "/new");
3941 if (strcmp (r, "new file contents") != 0) {
3942 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
3950 static int test_write_file_1 (void)
3952 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
3956 r = guestfs_umount_all (g);
3963 r = guestfs_lvm_remove_all (g);
3974 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3981 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3988 r = guestfs_mount (g, "/dev/sda1", "/");
3992 /* TestOutput for write_file (1) */
3996 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
4003 r = guestfs_cat (g, "/new");
4006 if (strcmp (r, "\nnew file contents\n") != 0) {
4007 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
4015 static int test_write_file_2 (void)
4017 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
4021 r = guestfs_umount_all (g);
4028 r = guestfs_lvm_remove_all (g);
4039 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4046 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4053 r = guestfs_mount (g, "/dev/sda1", "/");
4057 /* TestOutput for write_file (2) */
4061 r = guestfs_write_file (g, "/new", "\n\n", 0);
4068 r = guestfs_cat (g, "/new");
4071 if (strcmp (r, "\n\n") != 0) {
4072 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
4080 static int test_write_file_3 (void)
4082 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
4086 r = guestfs_umount_all (g);
4093 r = guestfs_lvm_remove_all (g);
4104 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4111 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4118 r = guestfs_mount (g, "/dev/sda1", "/");
4122 /* TestOutput for write_file (3) */
4126 r = guestfs_write_file (g, "/new", "", 0);
4133 r = guestfs_cat (g, "/new");
4136 if (strcmp (r, "") != 0) {
4137 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
4145 static int test_write_file_4 (void)
4147 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
4151 r = guestfs_umount_all (g);
4158 r = guestfs_lvm_remove_all (g);
4169 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4176 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4183 r = guestfs_mount (g, "/dev/sda1", "/");
4187 /* TestOutput for write_file (4) */
4191 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
4198 r = guestfs_cat (g, "/new");
4201 if (strcmp (r, "\n\n\n") != 0) {
4202 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
4210 static int test_write_file_5 (void)
4212 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
4216 r = guestfs_umount_all (g);
4223 r = guestfs_lvm_remove_all (g);
4234 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4241 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4248 r = guestfs_mount (g, "/dev/sda1", "/");
4252 /* TestOutput for write_file (5) */
4256 r = guestfs_write_file (g, "/new", "\n", 0);
4263 r = guestfs_cat (g, "/new");
4266 if (strcmp (r, "\n") != 0) {
4267 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
4275 static int test_mkfs_0 (void)
4277 /* InitEmpty for mkfs (0) */
4281 r = guestfs_umount_all (g);
4288 r = guestfs_lvm_remove_all (g);
4292 /* TestOutput for mkfs (0) */
4300 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4307 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4314 r = guestfs_mount (g, "/dev/sda1", "/");
4321 r = guestfs_write_file (g, "/new", "new file contents", 0);
4328 r = guestfs_cat (g, "/new");
4331 if (strcmp (r, "new file contents") != 0) {
4332 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
4340 static int test_lvcreate_0 (void)
4342 /* InitEmpty for lvcreate (0) */
4346 r = guestfs_umount_all (g);
4353 r = guestfs_lvm_remove_all (g);
4357 /* TestOutputList for lvcreate (0) */
4367 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4374 r = guestfs_pvcreate (g, "/dev/sda1");
4381 r = guestfs_pvcreate (g, "/dev/sda2");
4388 r = guestfs_pvcreate (g, "/dev/sda3");
4393 char *physvols[] = {
4400 r = guestfs_vgcreate (g, "VG1", physvols);
4405 char *physvols[] = {
4411 r = guestfs_vgcreate (g, "VG2", physvols);
4418 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4425 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4432 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4439 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
4446 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
4454 r = guestfs_lvs (g);
4458 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4462 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4463 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4467 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4471 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4472 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4476 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4480 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4481 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4485 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4489 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
4490 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
4494 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
4498 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
4499 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
4503 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
4507 for (i = 0; r[i] != NULL; ++i)
4514 static int test_vgcreate_0 (void)
4516 /* InitEmpty for vgcreate (0) */
4520 r = guestfs_umount_all (g);
4527 r = guestfs_lvm_remove_all (g);
4531 /* TestOutputList for vgcreate (0) */
4541 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4548 r = guestfs_pvcreate (g, "/dev/sda1");
4555 r = guestfs_pvcreate (g, "/dev/sda2");
4562 r = guestfs_pvcreate (g, "/dev/sda3");
4567 char *physvols[] = {
4574 r = guestfs_vgcreate (g, "VG1", physvols);
4579 char *physvols[] = {
4585 r = guestfs_vgcreate (g, "VG2", physvols);
4593 r = guestfs_vgs (g);
4597 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4601 if (strcmp (r[0], "VG1") != 0) {
4602 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
4606 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
4610 if (strcmp (r[1], "VG2") != 0) {
4611 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
4615 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
4619 for (i = 0; r[i] != NULL; ++i)
4626 static int test_pvcreate_0 (void)
4628 /* InitEmpty for pvcreate (0) */
4632 r = guestfs_umount_all (g);
4639 r = guestfs_lvm_remove_all (g);
4643 /* TestOutputList for pvcreate (0) */
4653 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4660 r = guestfs_pvcreate (g, "/dev/sda1");
4667 r = guestfs_pvcreate (g, "/dev/sda2");
4674 r = guestfs_pvcreate (g, "/dev/sda3");
4682 r = guestfs_pvs (g);
4686 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4690 if (strcmp (r[0], "/dev/sda1") != 0) {
4691 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4695 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4699 if (strcmp (r[1], "/dev/sda2") != 0) {
4700 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4704 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
4708 if (strcmp (r[2], "/dev/sda3") != 0) {
4709 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4713 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
4717 for (i = 0; r[i] != NULL; ++i)
4724 static int test_is_dir_0 (void)
4726 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
4730 r = guestfs_umount_all (g);
4737 r = guestfs_lvm_remove_all (g);
4748 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4755 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4762 r = guestfs_mount (g, "/dev/sda1", "/");
4766 /* TestOutputFalse for is_dir (0) */
4770 r = guestfs_touch (g, "/new");
4777 r = guestfs_is_dir (g, "/new");
4781 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
4788 static int test_is_dir_1 (void)
4790 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
4794 r = guestfs_umount_all (g);
4801 r = guestfs_lvm_remove_all (g);
4812 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4819 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4826 r = guestfs_mount (g, "/dev/sda1", "/");
4830 /* TestOutputTrue for is_dir (1) */
4834 r = guestfs_mkdir (g, "/new");
4841 r = guestfs_is_dir (g, "/new");
4845 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
4852 static int test_is_file_0 (void)
4854 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
4858 r = guestfs_umount_all (g);
4865 r = guestfs_lvm_remove_all (g);
4876 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4883 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4890 r = guestfs_mount (g, "/dev/sda1", "/");
4894 /* TestOutputTrue for is_file (0) */
4898 r = guestfs_touch (g, "/new");
4905 r = guestfs_is_file (g, "/new");
4909 fprintf (stderr, "test_is_file_0: expected true, got false\n");
4916 static int test_is_file_1 (void)
4918 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
4922 r = guestfs_umount_all (g);
4929 r = guestfs_lvm_remove_all (g);
4940 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4947 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4954 r = guestfs_mount (g, "/dev/sda1", "/");
4958 /* TestOutputFalse for is_file (1) */
4962 r = guestfs_mkdir (g, "/new");
4969 r = guestfs_is_file (g, "/new");
4973 fprintf (stderr, "test_is_file_1: expected false, got true\n");
4980 static int test_exists_0 (void)
4982 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
4986 r = guestfs_umount_all (g);
4993 r = guestfs_lvm_remove_all (g);
5004 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5011 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5018 r = guestfs_mount (g, "/dev/sda1", "/");
5022 /* TestOutputTrue for exists (0) */
5026 r = guestfs_touch (g, "/new");
5033 r = guestfs_exists (g, "/new");
5037 fprintf (stderr, "test_exists_0: expected true, got false\n");
5044 static int test_exists_1 (void)
5046 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
5050 r = guestfs_umount_all (g);
5057 r = guestfs_lvm_remove_all (g);
5068 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5075 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5082 r = guestfs_mount (g, "/dev/sda1", "/");
5086 /* TestOutputTrue for exists (1) */
5090 r = guestfs_mkdir (g, "/new");
5097 r = guestfs_exists (g, "/new");
5101 fprintf (stderr, "test_exists_1: expected true, got false\n");
5108 static int test_mkdir_p_0 (void)
5110 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
5114 r = guestfs_umount_all (g);
5121 r = guestfs_lvm_remove_all (g);
5132 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5139 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5146 r = guestfs_mount (g, "/dev/sda1", "/");
5150 /* TestOutputTrue for mkdir_p (0) */
5154 r = guestfs_mkdir_p (g, "/new/foo/bar");
5161 r = guestfs_is_dir (g, "/new/foo/bar");
5165 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
5172 static int test_mkdir_p_1 (void)
5174 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
5178 r = guestfs_umount_all (g);
5185 r = guestfs_lvm_remove_all (g);
5196 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5203 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5210 r = guestfs_mount (g, "/dev/sda1", "/");
5214 /* TestOutputTrue for mkdir_p (1) */
5218 r = guestfs_mkdir_p (g, "/new/foo/bar");
5225 r = guestfs_is_dir (g, "/new/foo");
5229 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
5236 static int test_mkdir_p_2 (void)
5238 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
5242 r = guestfs_umount_all (g);
5249 r = guestfs_lvm_remove_all (g);
5260 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5267 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5274 r = guestfs_mount (g, "/dev/sda1", "/");
5278 /* TestOutputTrue for mkdir_p (2) */
5282 r = guestfs_mkdir_p (g, "/new/foo/bar");
5289 r = guestfs_is_dir (g, "/new");
5293 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
5300 static int test_mkdir_0 (void)
5302 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
5306 r = guestfs_umount_all (g);
5313 r = guestfs_lvm_remove_all (g);
5324 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5331 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5338 r = guestfs_mount (g, "/dev/sda1", "/");
5342 /* TestOutputTrue for mkdir (0) */
5346 r = guestfs_mkdir (g, "/new");
5353 r = guestfs_is_dir (g, "/new");
5357 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
5364 static int test_mkdir_1 (void)
5366 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
5370 r = guestfs_umount_all (g);
5377 r = guestfs_lvm_remove_all (g);
5388 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5395 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5402 r = guestfs_mount (g, "/dev/sda1", "/");
5406 /* TestLastFail for mkdir (1) */
5410 r = guestfs_mkdir (g, "/new/foo/bar");
5417 static int test_rm_rf_0 (void)
5419 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
5423 r = guestfs_umount_all (g);
5430 r = guestfs_lvm_remove_all (g);
5441 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5448 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5455 r = guestfs_mount (g, "/dev/sda1", "/");
5459 /* TestOutputFalse for rm_rf (0) */
5463 r = guestfs_mkdir (g, "/new");
5470 r = guestfs_mkdir (g, "/new/foo");
5477 r = guestfs_touch (g, "/new/foo/bar");
5484 r = guestfs_rm_rf (g, "/new");
5491 r = guestfs_exists (g, "/new");
5495 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
5502 static int test_rmdir_0 (void)
5504 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
5508 r = guestfs_umount_all (g);
5515 r = guestfs_lvm_remove_all (g);
5526 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5533 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5540 r = guestfs_mount (g, "/dev/sda1", "/");
5544 /* TestRun for rmdir (0) */
5548 r = guestfs_mkdir (g, "/new");
5555 r = guestfs_rmdir (g, "/new");
5562 static int test_rmdir_1 (void)
5564 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
5568 r = guestfs_umount_all (g);
5575 r = guestfs_lvm_remove_all (g);
5586 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5593 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5600 r = guestfs_mount (g, "/dev/sda1", "/");
5604 /* TestLastFail for rmdir (1) */
5608 r = guestfs_rmdir (g, "/new");
5615 static int test_rmdir_2 (void)
5617 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
5621 r = guestfs_umount_all (g);
5628 r = guestfs_lvm_remove_all (g);
5639 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5646 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5653 r = guestfs_mount (g, "/dev/sda1", "/");
5657 /* TestLastFail for rmdir (2) */
5661 r = guestfs_touch (g, "/new");
5668 r = guestfs_rmdir (g, "/new");
5675 static int test_rm_0 (void)
5677 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
5681 r = guestfs_umount_all (g);
5688 r = guestfs_lvm_remove_all (g);
5699 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5706 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5713 r = guestfs_mount (g, "/dev/sda1", "/");
5717 /* TestRun for rm (0) */
5721 r = guestfs_touch (g, "/new");
5728 r = guestfs_rm (g, "/new");
5735 static int test_rm_1 (void)
5737 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
5741 r = guestfs_umount_all (g);
5748 r = guestfs_lvm_remove_all (g);
5759 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5766 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5773 r = guestfs_mount (g, "/dev/sda1", "/");
5777 /* TestLastFail for rm (1) */
5781 r = guestfs_rm (g, "/new");
5788 static int test_rm_2 (void)
5790 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
5794 r = guestfs_umount_all (g);
5801 r = guestfs_lvm_remove_all (g);
5812 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5819 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5826 r = guestfs_mount (g, "/dev/sda1", "/");
5830 /* TestLastFail for rm (2) */
5834 r = guestfs_mkdir (g, "/new");
5841 r = guestfs_rm (g, "/new");
5848 static int test_read_lines_0 (void)
5850 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
5854 r = guestfs_umount_all (g);
5861 r = guestfs_lvm_remove_all (g);
5872 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5879 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5886 r = guestfs_mount (g, "/dev/sda1", "/");
5890 /* TestOutputList for read_lines (0) */
5894 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
5902 r = guestfs_read_lines (g, "/new");
5906 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5910 if (strcmp (r[0], "line1") != 0) {
5911 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
5915 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5919 if (strcmp (r[1], "line2") != 0) {
5920 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
5924 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
5928 if (strcmp (r[2], "line3") != 0) {
5929 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
5933 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
5937 for (i = 0; r[i] != NULL; ++i)
5944 static int test_read_lines_1 (void)
5946 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
5950 r = guestfs_umount_all (g);
5957 r = guestfs_lvm_remove_all (g);
5968 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5975 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5982 r = guestfs_mount (g, "/dev/sda1", "/");
5986 /* TestOutputList for read_lines (1) */
5990 r = guestfs_write_file (g, "/new", "", 0);
5998 r = guestfs_read_lines (g, "/new");
6002 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
6006 for (i = 0; r[i] != NULL; ++i)
6013 static int test_lvs_0 (void)
6015 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
6019 r = guestfs_umount_all (g);
6026 r = guestfs_lvm_remove_all (g);
6037 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6044 r = guestfs_pvcreate (g, "/dev/sda1");
6049 char *physvols[] = {
6055 r = guestfs_vgcreate (g, "VG", physvols);
6062 r = guestfs_lvcreate (g, "LV", "VG", 8);
6069 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6076 r = guestfs_mount (g, "/dev/VG/LV", "/");
6080 /* TestOutputList for lvs (0) */
6085 r = guestfs_lvs (g);
6089 fprintf (stderr, "test_lvs_0: short list returned from command\n");
6093 if (strcmp (r[0], "/dev/VG/LV") != 0) {
6094 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
6098 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
6102 for (i = 0; r[i] != NULL; ++i)
6109 static int test_lvs_1 (void)
6111 /* InitEmpty for lvs (1) */
6115 r = guestfs_umount_all (g);
6122 r = guestfs_lvm_remove_all (g);
6126 /* TestOutputList for lvs (1) */
6136 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6143 r = guestfs_pvcreate (g, "/dev/sda1");
6150 r = guestfs_pvcreate (g, "/dev/sda2");
6157 r = guestfs_pvcreate (g, "/dev/sda3");
6162 char *physvols[] = {
6169 r = guestfs_vgcreate (g, "VG1", physvols);
6174 char *physvols[] = {
6180 r = guestfs_vgcreate (g, "VG2", physvols);
6187 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
6194 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
6201 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
6209 r = guestfs_lvs (g);
6213 fprintf (stderr, "test_lvs_1: short list returned from command\n");
6217 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
6218 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
6222 fprintf (stderr, "test_lvs_1: short list returned from command\n");
6226 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
6227 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
6231 fprintf (stderr, "test_lvs_1: short list returned from command\n");
6235 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
6236 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
6240 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
6244 for (i = 0; r[i] != NULL; ++i)
6251 static int test_vgs_0 (void)
6253 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
6257 r = guestfs_umount_all (g);
6264 r = guestfs_lvm_remove_all (g);
6275 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6282 r = guestfs_pvcreate (g, "/dev/sda1");
6287 char *physvols[] = {
6293 r = guestfs_vgcreate (g, "VG", physvols);
6300 r = guestfs_lvcreate (g, "LV", "VG", 8);
6307 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6314 r = guestfs_mount (g, "/dev/VG/LV", "/");
6318 /* TestOutputList for vgs (0) */
6323 r = guestfs_vgs (g);
6327 fprintf (stderr, "test_vgs_0: short list returned from command\n");
6331 if (strcmp (r[0], "VG") != 0) {
6332 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
6336 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
6340 for (i = 0; r[i] != NULL; ++i)
6347 static int test_vgs_1 (void)
6349 /* InitEmpty for vgs (1) */
6353 r = guestfs_umount_all (g);
6360 r = guestfs_lvm_remove_all (g);
6364 /* TestOutputList for vgs (1) */
6374 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6381 r = guestfs_pvcreate (g, "/dev/sda1");
6388 r = guestfs_pvcreate (g, "/dev/sda2");
6395 r = guestfs_pvcreate (g, "/dev/sda3");
6400 char *physvols[] = {
6407 r = guestfs_vgcreate (g, "VG1", physvols);
6412 char *physvols[] = {
6418 r = guestfs_vgcreate (g, "VG2", physvols);
6426 r = guestfs_vgs (g);
6430 fprintf (stderr, "test_vgs_1: short list returned from command\n");
6434 if (strcmp (r[0], "VG1") != 0) {
6435 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
6439 fprintf (stderr, "test_vgs_1: short list returned from command\n");
6443 if (strcmp (r[1], "VG2") != 0) {
6444 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
6448 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
6452 for (i = 0; r[i] != NULL; ++i)
6459 static int test_pvs_0 (void)
6461 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
6465 r = guestfs_umount_all (g);
6472 r = guestfs_lvm_remove_all (g);
6483 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6490 r = guestfs_pvcreate (g, "/dev/sda1");
6495 char *physvols[] = {
6501 r = guestfs_vgcreate (g, "VG", physvols);
6508 r = guestfs_lvcreate (g, "LV", "VG", 8);
6515 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
6522 r = guestfs_mount (g, "/dev/VG/LV", "/");
6526 /* TestOutputList for pvs (0) */
6531 r = guestfs_pvs (g);
6535 fprintf (stderr, "test_pvs_0: short list returned from command\n");
6539 if (strcmp (r[0], "/dev/sda1") != 0) {
6540 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6544 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
6548 for (i = 0; r[i] != NULL; ++i)
6555 static int test_pvs_1 (void)
6557 /* InitEmpty for pvs (1) */
6561 r = guestfs_umount_all (g);
6568 r = guestfs_lvm_remove_all (g);
6572 /* TestOutputList for pvs (1) */
6582 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6589 r = guestfs_pvcreate (g, "/dev/sda1");
6596 r = guestfs_pvcreate (g, "/dev/sda2");
6603 r = guestfs_pvcreate (g, "/dev/sda3");
6611 r = guestfs_pvs (g);
6615 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6619 if (strcmp (r[0], "/dev/sda1") != 0) {
6620 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6624 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6628 if (strcmp (r[1], "/dev/sda2") != 0) {
6629 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6633 fprintf (stderr, "test_pvs_1: short list returned from command\n");
6637 if (strcmp (r[2], "/dev/sda3") != 0) {
6638 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6642 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
6646 for (i = 0; r[i] != NULL; ++i)
6653 static int test_list_partitions_0 (void)
6655 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
6659 r = guestfs_umount_all (g);
6666 r = guestfs_lvm_remove_all (g);
6677 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6684 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6691 r = guestfs_mount (g, "/dev/sda1", "/");
6695 /* TestOutputList for list_partitions (0) */
6700 r = guestfs_list_partitions (g);
6704 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
6708 if (strcmp (r[0], "/dev/sda1") != 0) {
6709 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6713 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
6717 for (i = 0; r[i] != NULL; ++i)
6724 static int test_list_partitions_1 (void)
6726 /* InitEmpty for list_partitions (1) */
6730 r = guestfs_umount_all (g);
6737 r = guestfs_lvm_remove_all (g);
6741 /* TestOutputList for list_partitions (1) */
6751 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6759 r = guestfs_list_partitions (g);
6763 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6767 if (strcmp (r[0], "/dev/sda1") != 0) {
6768 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
6772 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6776 if (strcmp (r[1], "/dev/sda2") != 0) {
6777 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
6781 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
6785 if (strcmp (r[2], "/dev/sda3") != 0) {
6786 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
6790 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
6794 for (i = 0; r[i] != NULL; ++i)
6801 static int test_list_devices_0 (void)
6803 /* InitEmpty for list_devices (0) */
6807 r = guestfs_umount_all (g);
6814 r = guestfs_lvm_remove_all (g);
6818 /* TestOutputList for list_devices (0) */
6823 r = guestfs_list_devices (g);
6827 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6831 if (strcmp (r[0], "/dev/sda") != 0) {
6832 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
6836 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6840 if (strcmp (r[1], "/dev/sdb") != 0) {
6841 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
6845 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
6849 if (strcmp (r[2], "/dev/sdc") != 0) {
6850 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
6854 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
6858 for (i = 0; r[i] != NULL; ++i)
6865 static int test_ls_0 (void)
6867 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
6871 r = guestfs_umount_all (g);
6878 r = guestfs_lvm_remove_all (g);
6889 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
6896 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
6903 r = guestfs_mount (g, "/dev/sda1", "/");
6907 /* TestOutputList for ls (0) */
6911 r = guestfs_touch (g, "/new");
6918 r = guestfs_touch (g, "/newer");
6925 r = guestfs_touch (g, "/newest");
6933 r = guestfs_ls (g, "/");
6937 fprintf (stderr, "test_ls_0: short list returned from command\n");
6941 if (strcmp (r[0], "lost+found") != 0) {
6942 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
6946 fprintf (stderr, "test_ls_0: short list returned from command\n");
6950 if (strcmp (r[1], "new") != 0) {
6951 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
6955 fprintf (stderr, "test_ls_0: short list returned from command\n");
6959 if (strcmp (r[2], "newer") != 0) {
6960 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
6964 fprintf (stderr, "test_ls_0: short list returned from command\n");
6968 if (strcmp (r[3], "newest") != 0) {
6969 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
6973 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
6977 for (i = 0; r[i] != NULL; ++i)
6984 static int test_cat_0 (void)
6986 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
6990 r = guestfs_umount_all (g);
6997 r = guestfs_lvm_remove_all (g);
7008 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7015 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7022 r = guestfs_mount (g, "/dev/sda1", "/");
7026 /* TestOutput for cat (0) */
7030 r = guestfs_write_file (g, "/new", "new file contents", 0);
7037 r = guestfs_cat (g, "/new");
7040 if (strcmp (r, "new file contents") != 0) {
7041 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
7049 static int test_touch_0 (void)
7051 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
7055 r = guestfs_umount_all (g);
7062 r = guestfs_lvm_remove_all (g);
7073 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7080 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7087 r = guestfs_mount (g, "/dev/sda1", "/");
7091 /* TestOutputTrue for touch (0) */
7095 r = guestfs_touch (g, "/new");
7102 r = guestfs_exists (g, "/new");
7106 fprintf (stderr, "test_touch_0: expected true, got false\n");
7113 static int test_sync_0 (void)
7115 /* InitEmpty for sync (0) */
7119 r = guestfs_umount_all (g);
7126 r = guestfs_lvm_remove_all (g);
7130 /* TestRun for sync (0) */
7134 r = guestfs_sync (g);
7141 static int test_mount_0 (void)
7143 /* InitEmpty for mount (0) */
7147 r = guestfs_umount_all (g);
7154 r = guestfs_lvm_remove_all (g);
7158 /* TestOutput for mount (0) */
7166 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
7173 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
7180 r = guestfs_mount (g, "/dev/sda1", "/");
7187 r = guestfs_write_file (g, "/new", "new file contents", 0);
7194 r = guestfs_cat (g, "/new");
7197 if (strcmp (r, "new file contents") != 0) {
7198 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
7206 int main (int argc, char *argv[])
7211 const char *filename;
7213 int nr_tests, test_num = 0;
7215 no_test_warnings ();
7217 g = guestfs_create ();
7219 printf ("guestfs_create FAILED\n");
7223 guestfs_set_error_handler (g, print_error, NULL);
7225 srcdir = getenv ("srcdir");
7226 if (!srcdir) srcdir = ".";
7228 guestfs_set_path (g, ".");
7230 filename = "test1.img";
7231 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7236 if (lseek (fd, 524288000, SEEK_SET) == -1) {
7242 if (write (fd, &c, 1) == -1) {
7248 if (close (fd) == -1) {
7253 if (guestfs_add_drive (g, filename) == -1) {
7254 printf ("guestfs_add_drive %s FAILED\n", filename);
7258 filename = "test2.img";
7259 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7264 if (lseek (fd, 52428800, SEEK_SET) == -1) {
7270 if (write (fd, &c, 1) == -1) {
7276 if (close (fd) == -1) {
7281 if (guestfs_add_drive (g, filename) == -1) {
7282 printf ("guestfs_add_drive %s FAILED\n", filename);
7286 filename = "test3.img";
7287 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
7292 if (lseek (fd, 10485760, SEEK_SET) == -1) {
7298 if (write (fd, &c, 1) == -1) {
7304 if (close (fd) == -1) {
7309 if (guestfs_add_drive (g, filename) == -1) {
7310 printf ("guestfs_add_drive %s FAILED\n", filename);
7314 if (guestfs_launch (g) == -1) {
7315 printf ("guestfs_launch FAILED\n");
7318 if (guestfs_wait_ready (g) == -1) {
7319 printf ("guestfs_wait_ready FAILED\n");
7326 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
7327 if (test_ping_daemon_0 () == -1) {
7328 printf ("test_ping_daemon_0 FAILED\n");
7332 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
7333 if (test_dmesg_0 () == -1) {
7334 printf ("test_dmesg_0 FAILED\n");
7338 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
7339 if (test_drop_caches_0 () == -1) {
7340 printf ("test_drop_caches_0 FAILED\n");
7344 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
7345 if (test_mv_0 () == -1) {
7346 printf ("test_mv_0 FAILED\n");
7350 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
7351 if (test_mv_1 () == -1) {
7352 printf ("test_mv_1 FAILED\n");
7356 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
7357 if (test_cp_a_0 () == -1) {
7358 printf ("test_cp_a_0 FAILED\n");
7362 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
7363 if (test_cp_0 () == -1) {
7364 printf ("test_cp_0 FAILED\n");
7368 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
7369 if (test_cp_1 () == -1) {
7370 printf ("test_cp_1 FAILED\n");
7374 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
7375 if (test_cp_2 () == -1) {
7376 printf ("test_cp_2 FAILED\n");
7380 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
7381 if (test_grub_install_0 () == -1) {
7382 printf ("test_grub_install_0 FAILED\n");
7386 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
7387 if (test_zero_0 () == -1) {
7388 printf ("test_zero_0 FAILED\n");
7392 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
7393 if (test_fsck_0 () == -1) {
7394 printf ("test_fsck_0 FAILED\n");
7398 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
7399 if (test_fsck_1 () == -1) {
7400 printf ("test_fsck_1 FAILED\n");
7404 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
7405 if (test_set_e2uuid_0 () == -1) {
7406 printf ("test_set_e2uuid_0 FAILED\n");
7410 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
7411 if (test_set_e2uuid_1 () == -1) {
7412 printf ("test_set_e2uuid_1 FAILED\n");
7416 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
7417 if (test_set_e2uuid_2 () == -1) {
7418 printf ("test_set_e2uuid_2 FAILED\n");
7422 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
7423 if (test_set_e2uuid_3 () == -1) {
7424 printf ("test_set_e2uuid_3 FAILED\n");
7428 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
7429 if (test_set_e2label_0 () == -1) {
7430 printf ("test_set_e2label_0 FAILED\n");
7434 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
7435 if (test_pvremove_0 () == -1) {
7436 printf ("test_pvremove_0 FAILED\n");
7440 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
7441 if (test_pvremove_1 () == -1) {
7442 printf ("test_pvremove_1 FAILED\n");
7446 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
7447 if (test_pvremove_2 () == -1) {
7448 printf ("test_pvremove_2 FAILED\n");
7452 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
7453 if (test_vgremove_0 () == -1) {
7454 printf ("test_vgremove_0 FAILED\n");
7458 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
7459 if (test_vgremove_1 () == -1) {
7460 printf ("test_vgremove_1 FAILED\n");
7464 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
7465 if (test_lvremove_0 () == -1) {
7466 printf ("test_lvremove_0 FAILED\n");
7470 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
7471 if (test_lvremove_1 () == -1) {
7472 printf ("test_lvremove_1 FAILED\n");
7476 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
7477 if (test_lvremove_2 () == -1) {
7478 printf ("test_lvremove_2 FAILED\n");
7482 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
7483 if (test_mount_ro_0 () == -1) {
7484 printf ("test_mount_ro_0 FAILED\n");
7488 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
7489 if (test_mount_ro_1 () == -1) {
7490 printf ("test_mount_ro_1 FAILED\n");
7494 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
7495 if (test_tgz_in_0 () == -1) {
7496 printf ("test_tgz_in_0 FAILED\n");
7500 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
7501 if (test_tar_in_0 () == -1) {
7502 printf ("test_tar_in_0 FAILED\n");
7506 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
7507 if (test_checksum_0 () == -1) {
7508 printf ("test_checksum_0 FAILED\n");
7512 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
7513 if (test_checksum_1 () == -1) {
7514 printf ("test_checksum_1 FAILED\n");
7518 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
7519 if (test_checksum_2 () == -1) {
7520 printf ("test_checksum_2 FAILED\n");
7524 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
7525 if (test_checksum_3 () == -1) {
7526 printf ("test_checksum_3 FAILED\n");
7530 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
7531 if (test_checksum_4 () == -1) {
7532 printf ("test_checksum_4 FAILED\n");
7536 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
7537 if (test_checksum_5 () == -1) {
7538 printf ("test_checksum_5 FAILED\n");
7542 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
7543 if (test_checksum_6 () == -1) {
7544 printf ("test_checksum_6 FAILED\n");
7548 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
7549 if (test_checksum_7 () == -1) {
7550 printf ("test_checksum_7 FAILED\n");
7554 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
7555 if (test_download_0 () == -1) {
7556 printf ("test_download_0 FAILED\n");
7560 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
7561 if (test_upload_0 () == -1) {
7562 printf ("test_upload_0 FAILED\n");
7566 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
7567 if (test_blockdev_rereadpt_0 () == -1) {
7568 printf ("test_blockdev_rereadpt_0 FAILED\n");
7572 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
7573 if (test_blockdev_flushbufs_0 () == -1) {
7574 printf ("test_blockdev_flushbufs_0 FAILED\n");
7578 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
7579 if (test_blockdev_getsize64_0 () == -1) {
7580 printf ("test_blockdev_getsize64_0 FAILED\n");
7584 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
7585 if (test_blockdev_getsz_0 () == -1) {
7586 printf ("test_blockdev_getsz_0 FAILED\n");
7590 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
7591 if (test_blockdev_getbsz_0 () == -1) {
7592 printf ("test_blockdev_getbsz_0 FAILED\n");
7596 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
7597 if (test_blockdev_getss_0 () == -1) {
7598 printf ("test_blockdev_getss_0 FAILED\n");
7602 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
7603 if (test_blockdev_getro_0 () == -1) {
7604 printf ("test_blockdev_getro_0 FAILED\n");
7608 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
7609 if (test_blockdev_setrw_0 () == -1) {
7610 printf ("test_blockdev_setrw_0 FAILED\n");
7614 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
7615 if (test_blockdev_setro_0 () == -1) {
7616 printf ("test_blockdev_setro_0 FAILED\n");
7620 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
7621 if (test_statvfs_0 () == -1) {
7622 printf ("test_statvfs_0 FAILED\n");
7626 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
7627 if (test_lstat_0 () == -1) {
7628 printf ("test_lstat_0 FAILED\n");
7632 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
7633 if (test_stat_0 () == -1) {
7634 printf ("test_stat_0 FAILED\n");
7638 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
7639 if (test_file_0 () == -1) {
7640 printf ("test_file_0 FAILED\n");
7644 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
7645 if (test_file_1 () == -1) {
7646 printf ("test_file_1 FAILED\n");
7650 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
7651 if (test_file_2 () == -1) {
7652 printf ("test_file_2 FAILED\n");
7656 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
7657 if (test_umount_all_0 () == -1) {
7658 printf ("test_umount_all_0 FAILED\n");
7662 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
7663 if (test_umount_all_1 () == -1) {
7664 printf ("test_umount_all_1 FAILED\n");
7668 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
7669 if (test_mounts_0 () == -1) {
7670 printf ("test_mounts_0 FAILED\n");
7674 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
7675 if (test_umount_0 () == -1) {
7676 printf ("test_umount_0 FAILED\n");
7680 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
7681 if (test_umount_1 () == -1) {
7682 printf ("test_umount_1 FAILED\n");
7686 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
7687 if (test_write_file_0 () == -1) {
7688 printf ("test_write_file_0 FAILED\n");
7692 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
7693 if (test_write_file_1 () == -1) {
7694 printf ("test_write_file_1 FAILED\n");
7698 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
7699 if (test_write_file_2 () == -1) {
7700 printf ("test_write_file_2 FAILED\n");
7704 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
7705 if (test_write_file_3 () == -1) {
7706 printf ("test_write_file_3 FAILED\n");
7710 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
7711 if (test_write_file_4 () == -1) {
7712 printf ("test_write_file_4 FAILED\n");
7716 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
7717 if (test_write_file_5 () == -1) {
7718 printf ("test_write_file_5 FAILED\n");
7722 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
7723 if (test_mkfs_0 () == -1) {
7724 printf ("test_mkfs_0 FAILED\n");
7728 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
7729 if (test_lvcreate_0 () == -1) {
7730 printf ("test_lvcreate_0 FAILED\n");
7734 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
7735 if (test_vgcreate_0 () == -1) {
7736 printf ("test_vgcreate_0 FAILED\n");
7740 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
7741 if (test_pvcreate_0 () == -1) {
7742 printf ("test_pvcreate_0 FAILED\n");
7746 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
7747 if (test_is_dir_0 () == -1) {
7748 printf ("test_is_dir_0 FAILED\n");
7752 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
7753 if (test_is_dir_1 () == -1) {
7754 printf ("test_is_dir_1 FAILED\n");
7758 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
7759 if (test_is_file_0 () == -1) {
7760 printf ("test_is_file_0 FAILED\n");
7764 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
7765 if (test_is_file_1 () == -1) {
7766 printf ("test_is_file_1 FAILED\n");
7770 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
7771 if (test_exists_0 () == -1) {
7772 printf ("test_exists_0 FAILED\n");
7776 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
7777 if (test_exists_1 () == -1) {
7778 printf ("test_exists_1 FAILED\n");
7782 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
7783 if (test_mkdir_p_0 () == -1) {
7784 printf ("test_mkdir_p_0 FAILED\n");
7788 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
7789 if (test_mkdir_p_1 () == -1) {
7790 printf ("test_mkdir_p_1 FAILED\n");
7794 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
7795 if (test_mkdir_p_2 () == -1) {
7796 printf ("test_mkdir_p_2 FAILED\n");
7800 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
7801 if (test_mkdir_0 () == -1) {
7802 printf ("test_mkdir_0 FAILED\n");
7806 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
7807 if (test_mkdir_1 () == -1) {
7808 printf ("test_mkdir_1 FAILED\n");
7812 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
7813 if (test_rm_rf_0 () == -1) {
7814 printf ("test_rm_rf_0 FAILED\n");
7818 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
7819 if (test_rmdir_0 () == -1) {
7820 printf ("test_rmdir_0 FAILED\n");
7824 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
7825 if (test_rmdir_1 () == -1) {
7826 printf ("test_rmdir_1 FAILED\n");
7830 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
7831 if (test_rmdir_2 () == -1) {
7832 printf ("test_rmdir_2 FAILED\n");
7836 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
7837 if (test_rm_0 () == -1) {
7838 printf ("test_rm_0 FAILED\n");
7842 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
7843 if (test_rm_1 () == -1) {
7844 printf ("test_rm_1 FAILED\n");
7848 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
7849 if (test_rm_2 () == -1) {
7850 printf ("test_rm_2 FAILED\n");
7854 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
7855 if (test_read_lines_0 () == -1) {
7856 printf ("test_read_lines_0 FAILED\n");
7860 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
7861 if (test_read_lines_1 () == -1) {
7862 printf ("test_read_lines_1 FAILED\n");
7866 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
7867 if (test_lvs_0 () == -1) {
7868 printf ("test_lvs_0 FAILED\n");
7872 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
7873 if (test_lvs_1 () == -1) {
7874 printf ("test_lvs_1 FAILED\n");
7878 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
7879 if (test_vgs_0 () == -1) {
7880 printf ("test_vgs_0 FAILED\n");
7884 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
7885 if (test_vgs_1 () == -1) {
7886 printf ("test_vgs_1 FAILED\n");
7890 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
7891 if (test_pvs_0 () == -1) {
7892 printf ("test_pvs_0 FAILED\n");
7896 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
7897 if (test_pvs_1 () == -1) {
7898 printf ("test_pvs_1 FAILED\n");
7902 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
7903 if (test_list_partitions_0 () == -1) {
7904 printf ("test_list_partitions_0 FAILED\n");
7908 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
7909 if (test_list_partitions_1 () == -1) {
7910 printf ("test_list_partitions_1 FAILED\n");
7914 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
7915 if (test_list_devices_0 () == -1) {
7916 printf ("test_list_devices_0 FAILED\n");
7920 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
7921 if (test_ls_0 () == -1) {
7922 printf ("test_ls_0 FAILED\n");
7926 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
7927 if (test_cat_0 () == -1) {
7928 printf ("test_cat_0 FAILED\n");
7932 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
7933 if (test_touch_0 () == -1) {
7934 printf ("test_touch_0 FAILED\n");
7938 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
7939 if (test_sync_0 () == -1) {
7940 printf ("test_sync_0 FAILED\n");
7944 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
7945 if (test_mount_0 () == -1) {
7946 printf ("test_mount_0 FAILED\n");
7951 unlink ("test1.img");
7952 unlink ("test2.img");
7953 unlink ("test3.img");
7956 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);