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_path\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_upload\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_download\" has no tests\n");
108 static int test_blockdev_rereadpt_0 (void)
110 /* InitEmpty for blockdev_rereadpt (0) */
114 r = guestfs_umount_all (g);
121 r = guestfs_lvm_remove_all (g);
125 /* TestRun for blockdev_rereadpt (0) */
129 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
136 static int test_blockdev_flushbufs_0 (void)
138 /* InitEmpty for blockdev_flushbufs (0) */
142 r = guestfs_umount_all (g);
149 r = guestfs_lvm_remove_all (g);
153 /* TestRun for blockdev_flushbufs (0) */
157 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
164 static int test_blockdev_getsize64_0 (void)
166 /* InitEmpty for blockdev_getsize64 (0) */
170 r = guestfs_umount_all (g);
177 r = guestfs_lvm_remove_all (g);
181 /* TestOutputInt for blockdev_getsize64 (0) */
185 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
188 if (r != 524288000) {
189 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
196 static int test_blockdev_getsz_0 (void)
198 /* InitEmpty for blockdev_getsz (0) */
202 r = guestfs_umount_all (g);
209 r = guestfs_lvm_remove_all (g);
213 /* TestOutputInt for blockdev_getsz (0) */
217 r = guestfs_blockdev_getsz (g, "/dev/sda");
221 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
228 static int test_blockdev_getbsz_0 (void)
230 /* InitEmpty for blockdev_getbsz (0) */
234 r = guestfs_umount_all (g);
241 r = guestfs_lvm_remove_all (g);
245 /* TestOutputInt for blockdev_getbsz (0) */
249 r = guestfs_blockdev_getbsz (g, "/dev/sda");
253 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
260 static int test_blockdev_getss_0 (void)
262 /* InitEmpty for blockdev_getss (0) */
266 r = guestfs_umount_all (g);
273 r = guestfs_lvm_remove_all (g);
277 /* TestOutputInt for blockdev_getss (0) */
281 r = guestfs_blockdev_getss (g, "/dev/sda");
285 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
292 static int test_blockdev_getro_0 (void)
294 /* InitEmpty for blockdev_getro (0) */
298 r = guestfs_umount_all (g);
305 r = guestfs_lvm_remove_all (g);
309 /* TestOutputTrue for blockdev_getro (0) */
313 r = guestfs_blockdev_setro (g, "/dev/sda");
320 r = guestfs_blockdev_getro (g, "/dev/sda");
324 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
331 static int test_blockdev_setrw_0 (void)
333 /* InitEmpty for blockdev_setrw (0) */
337 r = guestfs_umount_all (g);
344 r = guestfs_lvm_remove_all (g);
348 /* TestOutputFalse for blockdev_setrw (0) */
352 r = guestfs_blockdev_setrw (g, "/dev/sda");
359 r = guestfs_blockdev_getro (g, "/dev/sda");
363 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
370 static int test_blockdev_setro_0 (void)
372 /* InitEmpty for blockdev_setro (0) */
376 r = guestfs_umount_all (g);
383 r = guestfs_lvm_remove_all (g);
387 /* TestOutputTrue for blockdev_setro (0) */
391 r = guestfs_blockdev_setro (g, "/dev/sda");
398 r = guestfs_blockdev_getro (g, "/dev/sda");
402 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
409 static int test_statvfs_0 (void)
411 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
415 r = guestfs_umount_all (g);
422 r = guestfs_lvm_remove_all (g);
433 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
440 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
447 r = guestfs_mount (g, "/dev/sda1", "/");
451 /* TestOutputStruct for statvfs (0) */
453 struct guestfs_statvfs *r;
455 r = guestfs_statvfs (g, "/");
458 if (r->bfree != 487702) {
459 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
463 if (r->blocks != 490020) {
464 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
468 if (r->bsize != 1024) {
469 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
478 static int test_lstat_0 (void)
480 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
484 r = guestfs_umount_all (g);
491 r = guestfs_lvm_remove_all (g);
502 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
509 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
516 r = guestfs_mount (g, "/dev/sda1", "/");
520 /* TestOutputStruct for lstat (0) */
524 r = guestfs_touch (g, "/new");
529 struct guestfs_stat *r;
531 r = guestfs_lstat (g, "/new");
535 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
544 static int test_stat_0 (void)
546 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
550 r = guestfs_umount_all (g);
557 r = guestfs_lvm_remove_all (g);
568 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
575 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
582 r = guestfs_mount (g, "/dev/sda1", "/");
586 /* TestOutputStruct for stat (0) */
590 r = guestfs_touch (g, "/new");
595 struct guestfs_stat *r;
597 r = guestfs_stat (g, "/new");
601 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
610 static int test_file_0 (void)
612 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
616 r = guestfs_umount_all (g);
623 r = guestfs_lvm_remove_all (g);
634 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
641 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
648 r = guestfs_mount (g, "/dev/sda1", "/");
652 /* TestOutput for file (0) */
656 r = guestfs_touch (g, "/new");
663 r = guestfs_file (g, "/new");
666 if (strcmp (r, "empty") != 0) {
667 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
675 static int test_file_1 (void)
677 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
681 r = guestfs_umount_all (g);
688 r = guestfs_lvm_remove_all (g);
699 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
706 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
713 r = guestfs_mount (g, "/dev/sda1", "/");
717 /* TestOutput for file (1) */
721 r = guestfs_write_file (g, "/new", "some content\n", 0);
728 r = guestfs_file (g, "/new");
731 if (strcmp (r, "ASCII text") != 0) {
732 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
740 static int test_file_2 (void)
742 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
746 r = guestfs_umount_all (g);
753 r = guestfs_lvm_remove_all (g);
764 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
771 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
778 r = guestfs_mount (g, "/dev/sda1", "/");
782 /* TestLastFail for file (2) */
786 r = guestfs_file (g, "/nofile");
794 static int test_umount_all_0 (void)
796 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
800 r = guestfs_umount_all (g);
807 r = guestfs_lvm_remove_all (g);
818 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
825 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
832 r = guestfs_mount (g, "/dev/sda1", "/");
836 /* TestOutputList for umount_all (0) */
840 r = guestfs_umount_all (g);
848 r = guestfs_mounts (g);
852 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
856 for (i = 0; r[i] != NULL; ++i)
863 static int test_mounts_0 (void)
865 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
869 r = guestfs_umount_all (g);
876 r = guestfs_lvm_remove_all (g);
887 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
894 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
901 r = guestfs_mount (g, "/dev/sda1", "/");
905 /* TestOutputList for mounts (0) */
910 r = guestfs_mounts (g);
914 fprintf (stderr, "test_mounts_0: short list returned from command\n");
918 if (strcmp (r[0], "/dev/sda1") != 0) {
919 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
923 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
927 for (i = 0; r[i] != NULL; ++i)
934 static int test_umount_0 (void)
936 /* InitEmpty for umount (0) */
940 r = guestfs_umount_all (g);
947 r = guestfs_lvm_remove_all (g);
951 /* TestOutputList for umount (0) */
959 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
966 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
973 r = guestfs_mount (g, "/dev/sda1", "/");
981 r = guestfs_mounts (g);
985 fprintf (stderr, "test_umount_0: short list returned from command\n");
989 if (strcmp (r[0], "/dev/sda1") != 0) {
990 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
994 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
998 for (i = 0; r[i] != NULL; ++i)
1005 static int test_umount_1 (void)
1007 /* InitEmpty for umount (1) */
1011 r = guestfs_umount_all (g);
1018 r = guestfs_lvm_remove_all (g);
1022 /* TestOutputList for umount (1) */
1030 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1037 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1044 r = guestfs_mount (g, "/dev/sda1", "/");
1051 r = guestfs_umount (g, "/");
1059 r = guestfs_mounts (g);
1063 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
1067 for (i = 0; r[i] != NULL; ++i)
1074 static int test_write_file_0 (void)
1076 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
1080 r = guestfs_umount_all (g);
1087 r = guestfs_lvm_remove_all (g);
1098 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1105 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1112 r = guestfs_mount (g, "/dev/sda1", "/");
1116 /* TestOutput for write_file (0) */
1120 r = guestfs_write_file (g, "/new", "new file contents", 0);
1127 r = guestfs_cat (g, "/new");
1130 if (strcmp (r, "new file contents") != 0) {
1131 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
1139 static int test_write_file_1 (void)
1141 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
1145 r = guestfs_umount_all (g);
1152 r = guestfs_lvm_remove_all (g);
1163 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1170 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1177 r = guestfs_mount (g, "/dev/sda1", "/");
1181 /* TestOutput for write_file (1) */
1185 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
1192 r = guestfs_cat (g, "/new");
1195 if (strcmp (r, "\nnew file contents\n") != 0) {
1196 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
1204 static int test_write_file_2 (void)
1206 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
1210 r = guestfs_umount_all (g);
1217 r = guestfs_lvm_remove_all (g);
1228 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1235 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1242 r = guestfs_mount (g, "/dev/sda1", "/");
1246 /* TestOutput for write_file (2) */
1250 r = guestfs_write_file (g, "/new", "\n\n", 0);
1257 r = guestfs_cat (g, "/new");
1260 if (strcmp (r, "\n\n") != 0) {
1261 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
1269 static int test_write_file_3 (void)
1271 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
1275 r = guestfs_umount_all (g);
1282 r = guestfs_lvm_remove_all (g);
1293 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1300 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1307 r = guestfs_mount (g, "/dev/sda1", "/");
1311 /* TestOutput for write_file (3) */
1315 r = guestfs_write_file (g, "/new", "", 0);
1322 r = guestfs_cat (g, "/new");
1325 if (strcmp (r, "") != 0) {
1326 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
1334 static int test_write_file_4 (void)
1336 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
1340 r = guestfs_umount_all (g);
1347 r = guestfs_lvm_remove_all (g);
1358 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1365 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1372 r = guestfs_mount (g, "/dev/sda1", "/");
1376 /* TestOutput for write_file (4) */
1380 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
1387 r = guestfs_cat (g, "/new");
1390 if (strcmp (r, "\n\n\n") != 0) {
1391 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
1399 static int test_write_file_5 (void)
1401 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
1405 r = guestfs_umount_all (g);
1412 r = guestfs_lvm_remove_all (g);
1423 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1430 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1437 r = guestfs_mount (g, "/dev/sda1", "/");
1441 /* TestOutput for write_file (5) */
1445 r = guestfs_write_file (g, "/new", "\n", 0);
1452 r = guestfs_cat (g, "/new");
1455 if (strcmp (r, "\n") != 0) {
1456 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
1464 static int test_mkfs_0 (void)
1466 /* InitEmpty for mkfs (0) */
1470 r = guestfs_umount_all (g);
1477 r = guestfs_lvm_remove_all (g);
1481 /* TestOutput for mkfs (0) */
1489 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1496 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1503 r = guestfs_mount (g, "/dev/sda1", "/");
1510 r = guestfs_write_file (g, "/new", "new file contents", 0);
1517 r = guestfs_cat (g, "/new");
1520 if (strcmp (r, "new file contents") != 0) {
1521 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
1529 static int test_lvcreate_0 (void)
1531 /* InitEmpty for lvcreate (0) */
1535 r = guestfs_umount_all (g);
1542 r = guestfs_lvm_remove_all (g);
1546 /* TestOutputList for lvcreate (0) */
1556 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1563 r = guestfs_pvcreate (g, "/dev/sda1");
1570 r = guestfs_pvcreate (g, "/dev/sda2");
1577 r = guestfs_pvcreate (g, "/dev/sda3");
1582 char *physvols[] = {
1589 r = guestfs_vgcreate (g, "VG1", physvols);
1594 char *physvols[] = {
1600 r = guestfs_vgcreate (g, "VG2", physvols);
1607 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
1614 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
1621 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
1628 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
1635 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
1643 r = guestfs_lvs (g);
1647 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1651 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
1652 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
1656 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1660 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
1661 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
1665 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1669 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
1670 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
1674 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1678 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
1679 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
1683 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1687 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
1688 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
1692 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
1696 for (i = 0; r[i] != NULL; ++i)
1703 static int test_vgcreate_0 (void)
1705 /* InitEmpty for vgcreate (0) */
1709 r = guestfs_umount_all (g);
1716 r = guestfs_lvm_remove_all (g);
1720 /* TestOutputList for vgcreate (0) */
1730 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1737 r = guestfs_pvcreate (g, "/dev/sda1");
1744 r = guestfs_pvcreate (g, "/dev/sda2");
1751 r = guestfs_pvcreate (g, "/dev/sda3");
1756 char *physvols[] = {
1763 r = guestfs_vgcreate (g, "VG1", physvols);
1768 char *physvols[] = {
1774 r = guestfs_vgcreate (g, "VG2", physvols);
1782 r = guestfs_vgs (g);
1786 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
1790 if (strcmp (r[0], "VG1") != 0) {
1791 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
1795 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
1799 if (strcmp (r[1], "VG2") != 0) {
1800 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
1804 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
1808 for (i = 0; r[i] != NULL; ++i)
1815 static int test_pvcreate_0 (void)
1817 /* InitEmpty for pvcreate (0) */
1821 r = guestfs_umount_all (g);
1828 r = guestfs_lvm_remove_all (g);
1832 /* TestOutputList for pvcreate (0) */
1842 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1849 r = guestfs_pvcreate (g, "/dev/sda1");
1856 r = guestfs_pvcreate (g, "/dev/sda2");
1863 r = guestfs_pvcreate (g, "/dev/sda3");
1871 r = guestfs_pvs (g);
1875 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
1879 if (strcmp (r[0], "/dev/sda1") != 0) {
1880 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1884 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
1888 if (strcmp (r[1], "/dev/sda2") != 0) {
1889 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
1893 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
1897 if (strcmp (r[2], "/dev/sda3") != 0) {
1898 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
1902 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
1906 for (i = 0; r[i] != NULL; ++i)
1913 static int test_is_dir_0 (void)
1915 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
1919 r = guestfs_umount_all (g);
1926 r = guestfs_lvm_remove_all (g);
1937 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1944 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1951 r = guestfs_mount (g, "/dev/sda1", "/");
1955 /* TestOutputFalse for is_dir (0) */
1959 r = guestfs_touch (g, "/new");
1966 r = guestfs_is_dir (g, "/new");
1970 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
1977 static int test_is_dir_1 (void)
1979 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
1983 r = guestfs_umount_all (g);
1990 r = guestfs_lvm_remove_all (g);
2001 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2008 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2015 r = guestfs_mount (g, "/dev/sda1", "/");
2019 /* TestOutputTrue for is_dir (1) */
2023 r = guestfs_mkdir (g, "/new");
2030 r = guestfs_is_dir (g, "/new");
2034 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2041 static int test_is_file_0 (void)
2043 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2047 r = guestfs_umount_all (g);
2054 r = guestfs_lvm_remove_all (g);
2065 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2072 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2079 r = guestfs_mount (g, "/dev/sda1", "/");
2083 /* TestOutputTrue for is_file (0) */
2087 r = guestfs_touch (g, "/new");
2094 r = guestfs_is_file (g, "/new");
2098 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2105 static int test_is_file_1 (void)
2107 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2111 r = guestfs_umount_all (g);
2118 r = guestfs_lvm_remove_all (g);
2129 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2136 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2143 r = guestfs_mount (g, "/dev/sda1", "/");
2147 /* TestOutputFalse for is_file (1) */
2151 r = guestfs_mkdir (g, "/new");
2158 r = guestfs_is_file (g, "/new");
2162 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2169 static int test_exists_0 (void)
2171 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2175 r = guestfs_umount_all (g);
2182 r = guestfs_lvm_remove_all (g);
2193 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2200 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2207 r = guestfs_mount (g, "/dev/sda1", "/");
2211 /* TestOutputTrue for exists (0) */
2215 r = guestfs_touch (g, "/new");
2222 r = guestfs_exists (g, "/new");
2226 fprintf (stderr, "test_exists_0: expected true, got false\n");
2233 static int test_exists_1 (void)
2235 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
2239 r = guestfs_umount_all (g);
2246 r = guestfs_lvm_remove_all (g);
2257 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2264 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2271 r = guestfs_mount (g, "/dev/sda1", "/");
2275 /* TestOutputTrue for exists (1) */
2279 r = guestfs_mkdir (g, "/new");
2286 r = guestfs_exists (g, "/new");
2290 fprintf (stderr, "test_exists_1: expected true, got false\n");
2297 static int test_mkdir_p_0 (void)
2299 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
2303 r = guestfs_umount_all (g);
2310 r = guestfs_lvm_remove_all (g);
2321 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2328 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2335 r = guestfs_mount (g, "/dev/sda1", "/");
2339 /* TestOutputTrue for mkdir_p (0) */
2343 r = guestfs_mkdir_p (g, "/new/foo/bar");
2350 r = guestfs_is_dir (g, "/new/foo/bar");
2354 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
2361 static int test_mkdir_p_1 (void)
2363 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
2367 r = guestfs_umount_all (g);
2374 r = guestfs_lvm_remove_all (g);
2385 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2392 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2399 r = guestfs_mount (g, "/dev/sda1", "/");
2403 /* TestOutputTrue for mkdir_p (1) */
2407 r = guestfs_mkdir_p (g, "/new/foo/bar");
2414 r = guestfs_is_dir (g, "/new/foo");
2418 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
2425 static int test_mkdir_p_2 (void)
2427 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
2431 r = guestfs_umount_all (g);
2438 r = guestfs_lvm_remove_all (g);
2449 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2456 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2463 r = guestfs_mount (g, "/dev/sda1", "/");
2467 /* TestOutputTrue for mkdir_p (2) */
2471 r = guestfs_mkdir_p (g, "/new/foo/bar");
2478 r = guestfs_is_dir (g, "/new");
2482 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
2489 static int test_mkdir_0 (void)
2491 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
2495 r = guestfs_umount_all (g);
2502 r = guestfs_lvm_remove_all (g);
2513 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2520 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2527 r = guestfs_mount (g, "/dev/sda1", "/");
2531 /* TestOutputTrue for mkdir (0) */
2535 r = guestfs_mkdir (g, "/new");
2542 r = guestfs_is_dir (g, "/new");
2546 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
2553 static int test_mkdir_1 (void)
2555 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
2559 r = guestfs_umount_all (g);
2566 r = guestfs_lvm_remove_all (g);
2577 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2584 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2591 r = guestfs_mount (g, "/dev/sda1", "/");
2595 /* TestLastFail for mkdir (1) */
2599 r = guestfs_mkdir (g, "/new/foo/bar");
2606 static int test_rm_rf_0 (void)
2608 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
2612 r = guestfs_umount_all (g);
2619 r = guestfs_lvm_remove_all (g);
2630 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2637 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2644 r = guestfs_mount (g, "/dev/sda1", "/");
2648 /* TestOutputFalse for rm_rf (0) */
2652 r = guestfs_mkdir (g, "/new");
2659 r = guestfs_mkdir (g, "/new/foo");
2666 r = guestfs_touch (g, "/new/foo/bar");
2673 r = guestfs_rm_rf (g, "/new");
2680 r = guestfs_exists (g, "/new");
2684 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
2691 static int test_rmdir_0 (void)
2693 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
2697 r = guestfs_umount_all (g);
2704 r = guestfs_lvm_remove_all (g);
2715 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2722 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2729 r = guestfs_mount (g, "/dev/sda1", "/");
2733 /* TestRun for rmdir (0) */
2737 r = guestfs_mkdir (g, "/new");
2744 r = guestfs_rmdir (g, "/new");
2751 static int test_rmdir_1 (void)
2753 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
2757 r = guestfs_umount_all (g);
2764 r = guestfs_lvm_remove_all (g);
2775 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2782 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2789 r = guestfs_mount (g, "/dev/sda1", "/");
2793 /* TestLastFail for rmdir (1) */
2797 r = guestfs_rmdir (g, "/new");
2804 static int test_rmdir_2 (void)
2806 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
2810 r = guestfs_umount_all (g);
2817 r = guestfs_lvm_remove_all (g);
2828 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2835 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2842 r = guestfs_mount (g, "/dev/sda1", "/");
2846 /* TestLastFail for rmdir (2) */
2850 r = guestfs_touch (g, "/new");
2857 r = guestfs_rmdir (g, "/new");
2864 static int test_rm_0 (void)
2866 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
2870 r = guestfs_umount_all (g);
2877 r = guestfs_lvm_remove_all (g);
2888 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2895 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2902 r = guestfs_mount (g, "/dev/sda1", "/");
2906 /* TestRun for rm (0) */
2910 r = guestfs_touch (g, "/new");
2917 r = guestfs_rm (g, "/new");
2924 static int test_rm_1 (void)
2926 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
2930 r = guestfs_umount_all (g);
2937 r = guestfs_lvm_remove_all (g);
2948 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2955 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2962 r = guestfs_mount (g, "/dev/sda1", "/");
2966 /* TestLastFail for rm (1) */
2970 r = guestfs_rm (g, "/new");
2977 static int test_rm_2 (void)
2979 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
2983 r = guestfs_umount_all (g);
2990 r = guestfs_lvm_remove_all (g);
3001 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3008 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3015 r = guestfs_mount (g, "/dev/sda1", "/");
3019 /* TestLastFail for rm (2) */
3023 r = guestfs_mkdir (g, "/new");
3030 r = guestfs_rm (g, "/new");
3037 static int test_read_lines_0 (void)
3039 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3043 r = guestfs_umount_all (g);
3050 r = guestfs_lvm_remove_all (g);
3061 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3068 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3075 r = guestfs_mount (g, "/dev/sda1", "/");
3079 /* TestOutputList for read_lines (0) */
3083 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
3091 r = guestfs_read_lines (g, "/new");
3095 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3099 if (strcmp (r[0], "line1") != 0) {
3100 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
3104 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3108 if (strcmp (r[1], "line2") != 0) {
3109 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
3113 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3117 if (strcmp (r[2], "line3") != 0) {
3118 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
3122 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
3126 for (i = 0; r[i] != NULL; ++i)
3133 static int test_read_lines_1 (void)
3135 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
3139 r = guestfs_umount_all (g);
3146 r = guestfs_lvm_remove_all (g);
3157 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3164 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3171 r = guestfs_mount (g, "/dev/sda1", "/");
3175 /* TestOutputList for read_lines (1) */
3179 r = guestfs_write_file (g, "/new", "", 0);
3187 r = guestfs_read_lines (g, "/new");
3191 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
3195 for (i = 0; r[i] != NULL; ++i)
3202 static int test_lvs_0 (void)
3204 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
3208 r = guestfs_umount_all (g);
3215 r = guestfs_lvm_remove_all (g);
3226 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3233 r = guestfs_pvcreate (g, "/dev/sda1");
3238 char *physvols[] = {
3244 r = guestfs_vgcreate (g, "VG", physvols);
3251 r = guestfs_lvcreate (g, "LV", "VG", 8);
3258 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3265 r = guestfs_mount (g, "/dev/VG/LV", "/");
3269 /* TestOutputList for lvs (0) */
3274 r = guestfs_lvs (g);
3278 fprintf (stderr, "test_lvs_0: short list returned from command\n");
3282 if (strcmp (r[0], "/dev/VG/LV") != 0) {
3283 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
3287 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
3291 for (i = 0; r[i] != NULL; ++i)
3298 static int test_lvs_1 (void)
3300 /* InitEmpty for lvs (1) */
3304 r = guestfs_umount_all (g);
3311 r = guestfs_lvm_remove_all (g);
3315 /* TestOutputList for lvs (1) */
3325 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3332 r = guestfs_pvcreate (g, "/dev/sda1");
3339 r = guestfs_pvcreate (g, "/dev/sda2");
3346 r = guestfs_pvcreate (g, "/dev/sda3");
3351 char *physvols[] = {
3358 r = guestfs_vgcreate (g, "VG1", physvols);
3363 char *physvols[] = {
3369 r = guestfs_vgcreate (g, "VG2", physvols);
3376 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
3383 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
3390 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
3398 r = guestfs_lvs (g);
3402 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3406 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
3407 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
3411 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3415 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
3416 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
3420 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3424 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
3425 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
3429 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
3433 for (i = 0; r[i] != NULL; ++i)
3440 static int test_vgs_0 (void)
3442 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
3446 r = guestfs_umount_all (g);
3453 r = guestfs_lvm_remove_all (g);
3464 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3471 r = guestfs_pvcreate (g, "/dev/sda1");
3476 char *physvols[] = {
3482 r = guestfs_vgcreate (g, "VG", physvols);
3489 r = guestfs_lvcreate (g, "LV", "VG", 8);
3496 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3503 r = guestfs_mount (g, "/dev/VG/LV", "/");
3507 /* TestOutputList for vgs (0) */
3512 r = guestfs_vgs (g);
3516 fprintf (stderr, "test_vgs_0: short list returned from command\n");
3520 if (strcmp (r[0], "VG") != 0) {
3521 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
3525 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
3529 for (i = 0; r[i] != NULL; ++i)
3536 static int test_vgs_1 (void)
3538 /* InitEmpty for vgs (1) */
3542 r = guestfs_umount_all (g);
3549 r = guestfs_lvm_remove_all (g);
3553 /* TestOutputList for vgs (1) */
3563 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3570 r = guestfs_pvcreate (g, "/dev/sda1");
3577 r = guestfs_pvcreate (g, "/dev/sda2");
3584 r = guestfs_pvcreate (g, "/dev/sda3");
3589 char *physvols[] = {
3596 r = guestfs_vgcreate (g, "VG1", physvols);
3601 char *physvols[] = {
3607 r = guestfs_vgcreate (g, "VG2", physvols);
3615 r = guestfs_vgs (g);
3619 fprintf (stderr, "test_vgs_1: short list returned from command\n");
3623 if (strcmp (r[0], "VG1") != 0) {
3624 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
3628 fprintf (stderr, "test_vgs_1: short list returned from command\n");
3632 if (strcmp (r[1], "VG2") != 0) {
3633 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
3637 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
3641 for (i = 0; r[i] != NULL; ++i)
3648 static int test_pvs_0 (void)
3650 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
3654 r = guestfs_umount_all (g);
3661 r = guestfs_lvm_remove_all (g);
3672 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3679 r = guestfs_pvcreate (g, "/dev/sda1");
3684 char *physvols[] = {
3690 r = guestfs_vgcreate (g, "VG", physvols);
3697 r = guestfs_lvcreate (g, "LV", "VG", 8);
3704 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3711 r = guestfs_mount (g, "/dev/VG/LV", "/");
3715 /* TestOutputList for pvs (0) */
3720 r = guestfs_pvs (g);
3724 fprintf (stderr, "test_pvs_0: short list returned from command\n");
3728 if (strcmp (r[0], "/dev/sda1") != 0) {
3729 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3733 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
3737 for (i = 0; r[i] != NULL; ++i)
3744 static int test_pvs_1 (void)
3746 /* InitEmpty for pvs (1) */
3750 r = guestfs_umount_all (g);
3757 r = guestfs_lvm_remove_all (g);
3761 /* TestOutputList for pvs (1) */
3771 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3778 r = guestfs_pvcreate (g, "/dev/sda1");
3785 r = guestfs_pvcreate (g, "/dev/sda2");
3792 r = guestfs_pvcreate (g, "/dev/sda3");
3800 r = guestfs_pvs (g);
3804 fprintf (stderr, "test_pvs_1: short list returned from command\n");
3808 if (strcmp (r[0], "/dev/sda1") != 0) {
3809 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3813 fprintf (stderr, "test_pvs_1: short list returned from command\n");
3817 if (strcmp (r[1], "/dev/sda2") != 0) {
3818 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
3822 fprintf (stderr, "test_pvs_1: short list returned from command\n");
3826 if (strcmp (r[2], "/dev/sda3") != 0) {
3827 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
3831 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
3835 for (i = 0; r[i] != NULL; ++i)
3842 static int test_list_partitions_0 (void)
3844 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
3848 r = guestfs_umount_all (g);
3855 r = guestfs_lvm_remove_all (g);
3866 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3873 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3880 r = guestfs_mount (g, "/dev/sda1", "/");
3884 /* TestOutputList for list_partitions (0) */
3889 r = guestfs_list_partitions (g);
3893 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
3897 if (strcmp (r[0], "/dev/sda1") != 0) {
3898 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3902 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
3906 for (i = 0; r[i] != NULL; ++i)
3913 static int test_list_partitions_1 (void)
3915 /* InitEmpty for list_partitions (1) */
3919 r = guestfs_umount_all (g);
3926 r = guestfs_lvm_remove_all (g);
3930 /* TestOutputList for list_partitions (1) */
3940 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3948 r = guestfs_list_partitions (g);
3952 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
3956 if (strcmp (r[0], "/dev/sda1") != 0) {
3957 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3961 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
3965 if (strcmp (r[1], "/dev/sda2") != 0) {
3966 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
3970 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
3974 if (strcmp (r[2], "/dev/sda3") != 0) {
3975 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
3979 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
3983 for (i = 0; r[i] != NULL; ++i)
3990 static int test_list_devices_0 (void)
3992 /* InitEmpty for list_devices (0) */
3996 r = guestfs_umount_all (g);
4003 r = guestfs_lvm_remove_all (g);
4007 /* TestOutputList for list_devices (0) */
4012 r = guestfs_list_devices (g);
4016 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4020 if (strcmp (r[0], "/dev/sda") != 0) {
4021 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4025 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4029 if (strcmp (r[1], "/dev/sdb") != 0) {
4030 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4034 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4038 if (strcmp (r[2], "/dev/sdc") != 0) {
4039 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4043 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4047 for (i = 0; r[i] != NULL; ++i)
4054 static int test_ls_0 (void)
4056 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4060 r = guestfs_umount_all (g);
4067 r = guestfs_lvm_remove_all (g);
4078 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4085 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4092 r = guestfs_mount (g, "/dev/sda1", "/");
4096 /* TestOutputList for ls (0) */
4100 r = guestfs_touch (g, "/new");
4107 r = guestfs_touch (g, "/newer");
4114 r = guestfs_touch (g, "/newest");
4122 r = guestfs_ls (g, "/");
4126 fprintf (stderr, "test_ls_0: short list returned from command\n");
4130 if (strcmp (r[0], "lost+found") != 0) {
4131 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
4135 fprintf (stderr, "test_ls_0: short list returned from command\n");
4139 if (strcmp (r[1], "new") != 0) {
4140 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
4144 fprintf (stderr, "test_ls_0: short list returned from command\n");
4148 if (strcmp (r[2], "newer") != 0) {
4149 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
4153 fprintf (stderr, "test_ls_0: short list returned from command\n");
4157 if (strcmp (r[3], "newest") != 0) {
4158 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
4162 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
4166 for (i = 0; r[i] != NULL; ++i)
4173 static int test_cat_0 (void)
4175 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
4179 r = guestfs_umount_all (g);
4186 r = guestfs_lvm_remove_all (g);
4197 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4204 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4211 r = guestfs_mount (g, "/dev/sda1", "/");
4215 /* TestOutput for cat (0) */
4219 r = guestfs_write_file (g, "/new", "new file contents", 0);
4226 r = guestfs_cat (g, "/new");
4229 if (strcmp (r, "new file contents") != 0) {
4230 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
4238 static int test_touch_0 (void)
4240 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
4244 r = guestfs_umount_all (g);
4251 r = guestfs_lvm_remove_all (g);
4262 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4269 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4276 r = guestfs_mount (g, "/dev/sda1", "/");
4280 /* TestOutputTrue for touch (0) */
4284 r = guestfs_touch (g, "/new");
4291 r = guestfs_exists (g, "/new");
4295 fprintf (stderr, "test_touch_0: expected true, got false\n");
4302 static int test_sync_0 (void)
4304 /* InitEmpty for sync (0) */
4308 r = guestfs_umount_all (g);
4315 r = guestfs_lvm_remove_all (g);
4319 /* TestRun for sync (0) */
4323 r = guestfs_sync (g);
4330 static int test_mount_0 (void)
4332 /* InitEmpty for mount (0) */
4336 r = guestfs_umount_all (g);
4343 r = guestfs_lvm_remove_all (g);
4347 /* TestOutput for mount (0) */
4355 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4362 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4369 r = guestfs_mount (g, "/dev/sda1", "/");
4376 r = guestfs_write_file (g, "/new", "new file contents", 0);
4383 r = guestfs_cat (g, "/new");
4386 if (strcmp (r, "new file contents") != 0) {
4387 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
4395 int main (int argc, char *argv[])
4402 int nr_tests, test_num = 0;
4404 no_test_warnings ();
4406 g = guestfs_create ();
4408 printf ("guestfs_create FAILED\n");
4412 guestfs_set_error_handler (g, print_error, NULL);
4414 srcdir = getenv ("srcdir");
4415 if (!srcdir) srcdir = ".";
4416 guestfs_set_path (g, srcdir);
4418 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
4419 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4424 if (lseek (fd, 524288000, SEEK_SET) == -1) {
4430 if (write (fd, &c, 1) == -1) {
4436 if (close (fd) == -1) {
4441 if (guestfs_add_drive (g, buf) == -1) {
4442 printf ("guestfs_add_drive %s FAILED\n", buf);
4446 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
4447 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4452 if (lseek (fd, 52428800, SEEK_SET) == -1) {
4458 if (write (fd, &c, 1) == -1) {
4464 if (close (fd) == -1) {
4469 if (guestfs_add_drive (g, buf) == -1) {
4470 printf ("guestfs_add_drive %s FAILED\n", buf);
4474 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
4475 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4480 if (lseek (fd, 10485760, SEEK_SET) == -1) {
4486 if (write (fd, &c, 1) == -1) {
4492 if (close (fd) == -1) {
4497 if (guestfs_add_drive (g, buf) == -1) {
4498 printf ("guestfs_add_drive %s FAILED\n", buf);
4502 if (guestfs_launch (g) == -1) {
4503 printf ("guestfs_launch FAILED\n");
4506 if (guestfs_wait_ready (g) == -1) {
4507 printf ("guestfs_wait_ready FAILED\n");
4514 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
4515 if (test_blockdev_rereadpt_0 () == -1) {
4516 printf ("test_blockdev_rereadpt_0 FAILED\n");
4520 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
4521 if (test_blockdev_flushbufs_0 () == -1) {
4522 printf ("test_blockdev_flushbufs_0 FAILED\n");
4526 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
4527 if (test_blockdev_getsize64_0 () == -1) {
4528 printf ("test_blockdev_getsize64_0 FAILED\n");
4532 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
4533 if (test_blockdev_getsz_0 () == -1) {
4534 printf ("test_blockdev_getsz_0 FAILED\n");
4538 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
4539 if (test_blockdev_getbsz_0 () == -1) {
4540 printf ("test_blockdev_getbsz_0 FAILED\n");
4544 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
4545 if (test_blockdev_getss_0 () == -1) {
4546 printf ("test_blockdev_getss_0 FAILED\n");
4550 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
4551 if (test_blockdev_getro_0 () == -1) {
4552 printf ("test_blockdev_getro_0 FAILED\n");
4556 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
4557 if (test_blockdev_setrw_0 () == -1) {
4558 printf ("test_blockdev_setrw_0 FAILED\n");
4562 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
4563 if (test_blockdev_setro_0 () == -1) {
4564 printf ("test_blockdev_setro_0 FAILED\n");
4568 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
4569 if (test_statvfs_0 () == -1) {
4570 printf ("test_statvfs_0 FAILED\n");
4574 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
4575 if (test_lstat_0 () == -1) {
4576 printf ("test_lstat_0 FAILED\n");
4580 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
4581 if (test_stat_0 () == -1) {
4582 printf ("test_stat_0 FAILED\n");
4586 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
4587 if (test_file_0 () == -1) {
4588 printf ("test_file_0 FAILED\n");
4592 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
4593 if (test_file_1 () == -1) {
4594 printf ("test_file_1 FAILED\n");
4598 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
4599 if (test_file_2 () == -1) {
4600 printf ("test_file_2 FAILED\n");
4604 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
4605 if (test_umount_all_0 () == -1) {
4606 printf ("test_umount_all_0 FAILED\n");
4610 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
4611 if (test_mounts_0 () == -1) {
4612 printf ("test_mounts_0 FAILED\n");
4616 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
4617 if (test_umount_0 () == -1) {
4618 printf ("test_umount_0 FAILED\n");
4622 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
4623 if (test_umount_1 () == -1) {
4624 printf ("test_umount_1 FAILED\n");
4628 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
4629 if (test_write_file_0 () == -1) {
4630 printf ("test_write_file_0 FAILED\n");
4634 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
4635 if (test_write_file_1 () == -1) {
4636 printf ("test_write_file_1 FAILED\n");
4640 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
4641 if (test_write_file_2 () == -1) {
4642 printf ("test_write_file_2 FAILED\n");
4646 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
4647 if (test_write_file_3 () == -1) {
4648 printf ("test_write_file_3 FAILED\n");
4652 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
4653 if (test_write_file_4 () == -1) {
4654 printf ("test_write_file_4 FAILED\n");
4658 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
4659 if (test_write_file_5 () == -1) {
4660 printf ("test_write_file_5 FAILED\n");
4664 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
4665 if (test_mkfs_0 () == -1) {
4666 printf ("test_mkfs_0 FAILED\n");
4670 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
4671 if (test_lvcreate_0 () == -1) {
4672 printf ("test_lvcreate_0 FAILED\n");
4676 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
4677 if (test_vgcreate_0 () == -1) {
4678 printf ("test_vgcreate_0 FAILED\n");
4682 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
4683 if (test_pvcreate_0 () == -1) {
4684 printf ("test_pvcreate_0 FAILED\n");
4688 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
4689 if (test_is_dir_0 () == -1) {
4690 printf ("test_is_dir_0 FAILED\n");
4694 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
4695 if (test_is_dir_1 () == -1) {
4696 printf ("test_is_dir_1 FAILED\n");
4700 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
4701 if (test_is_file_0 () == -1) {
4702 printf ("test_is_file_0 FAILED\n");
4706 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
4707 if (test_is_file_1 () == -1) {
4708 printf ("test_is_file_1 FAILED\n");
4712 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
4713 if (test_exists_0 () == -1) {
4714 printf ("test_exists_0 FAILED\n");
4718 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
4719 if (test_exists_1 () == -1) {
4720 printf ("test_exists_1 FAILED\n");
4724 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
4725 if (test_mkdir_p_0 () == -1) {
4726 printf ("test_mkdir_p_0 FAILED\n");
4730 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
4731 if (test_mkdir_p_1 () == -1) {
4732 printf ("test_mkdir_p_1 FAILED\n");
4736 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
4737 if (test_mkdir_p_2 () == -1) {
4738 printf ("test_mkdir_p_2 FAILED\n");
4742 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
4743 if (test_mkdir_0 () == -1) {
4744 printf ("test_mkdir_0 FAILED\n");
4748 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
4749 if (test_mkdir_1 () == -1) {
4750 printf ("test_mkdir_1 FAILED\n");
4754 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
4755 if (test_rm_rf_0 () == -1) {
4756 printf ("test_rm_rf_0 FAILED\n");
4760 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
4761 if (test_rmdir_0 () == -1) {
4762 printf ("test_rmdir_0 FAILED\n");
4766 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
4767 if (test_rmdir_1 () == -1) {
4768 printf ("test_rmdir_1 FAILED\n");
4772 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
4773 if (test_rmdir_2 () == -1) {
4774 printf ("test_rmdir_2 FAILED\n");
4778 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
4779 if (test_rm_0 () == -1) {
4780 printf ("test_rm_0 FAILED\n");
4784 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
4785 if (test_rm_1 () == -1) {
4786 printf ("test_rm_1 FAILED\n");
4790 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
4791 if (test_rm_2 () == -1) {
4792 printf ("test_rm_2 FAILED\n");
4796 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
4797 if (test_read_lines_0 () == -1) {
4798 printf ("test_read_lines_0 FAILED\n");
4802 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
4803 if (test_read_lines_1 () == -1) {
4804 printf ("test_read_lines_1 FAILED\n");
4808 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
4809 if (test_lvs_0 () == -1) {
4810 printf ("test_lvs_0 FAILED\n");
4814 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
4815 if (test_lvs_1 () == -1) {
4816 printf ("test_lvs_1 FAILED\n");
4820 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
4821 if (test_vgs_0 () == -1) {
4822 printf ("test_vgs_0 FAILED\n");
4826 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
4827 if (test_vgs_1 () == -1) {
4828 printf ("test_vgs_1 FAILED\n");
4832 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
4833 if (test_pvs_0 () == -1) {
4834 printf ("test_pvs_0 FAILED\n");
4838 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
4839 if (test_pvs_1 () == -1) {
4840 printf ("test_pvs_1 FAILED\n");
4844 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
4845 if (test_list_partitions_0 () == -1) {
4846 printf ("test_list_partitions_0 FAILED\n");
4850 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
4851 if (test_list_partitions_1 () == -1) {
4852 printf ("test_list_partitions_1 FAILED\n");
4856 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
4857 if (test_list_devices_0 () == -1) {
4858 printf ("test_list_devices_0 FAILED\n");
4862 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
4863 if (test_ls_0 () == -1) {
4864 printf ("test_ls_0 FAILED\n");
4868 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
4869 if (test_cat_0 () == -1) {
4870 printf ("test_cat_0 FAILED\n");
4874 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
4875 if (test_touch_0 () == -1) {
4876 printf ("test_touch_0 FAILED\n");
4880 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
4881 if (test_sync_0 () == -1) {
4882 printf ("test_sync_0 FAILED\n");
4886 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
4887 if (test_mount_0 () == -1) {
4888 printf ("test_mount_0 FAILED\n");
4893 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
4895 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
4897 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
4901 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);