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_ll\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_upload\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_download\" has no tests\n");
106 static int test_blockdev_rereadpt_0 (void)
108 /* InitEmpty for blockdev_rereadpt (0) */
112 r = guestfs_umount_all (g);
119 r = guestfs_lvm_remove_all (g);
123 /* TestRun for blockdev_rereadpt (0) */
127 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
134 static int test_blockdev_flushbufs_0 (void)
136 /* InitEmpty for blockdev_flushbufs (0) */
140 r = guestfs_umount_all (g);
147 r = guestfs_lvm_remove_all (g);
151 /* TestRun for blockdev_flushbufs (0) */
155 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
162 static int test_blockdev_getsize64_0 (void)
164 /* InitEmpty for blockdev_getsize64 (0) */
168 r = guestfs_umount_all (g);
175 r = guestfs_lvm_remove_all (g);
179 /* TestOutputInt for blockdev_getsize64 (0) */
183 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
186 if (r != 524288000) {
187 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
194 static int test_blockdev_getsz_0 (void)
196 /* InitEmpty for blockdev_getsz (0) */
200 r = guestfs_umount_all (g);
207 r = guestfs_lvm_remove_all (g);
211 /* TestOutputInt for blockdev_getsz (0) */
215 r = guestfs_blockdev_getsz (g, "/dev/sda");
219 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
226 static int test_blockdev_getbsz_0 (void)
228 /* InitEmpty for blockdev_getbsz (0) */
232 r = guestfs_umount_all (g);
239 r = guestfs_lvm_remove_all (g);
243 /* TestOutputInt for blockdev_getbsz (0) */
247 r = guestfs_blockdev_getbsz (g, "/dev/sda");
251 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
258 static int test_blockdev_getss_0 (void)
260 /* InitEmpty for blockdev_getss (0) */
264 r = guestfs_umount_all (g);
271 r = guestfs_lvm_remove_all (g);
275 /* TestOutputInt for blockdev_getss (0) */
279 r = guestfs_blockdev_getss (g, "/dev/sda");
283 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
290 static int test_blockdev_getro_0 (void)
292 /* InitEmpty for blockdev_getro (0) */
296 r = guestfs_umount_all (g);
303 r = guestfs_lvm_remove_all (g);
307 /* TestOutputTrue for blockdev_getro (0) */
311 r = guestfs_blockdev_setro (g, "/dev/sda");
318 r = guestfs_blockdev_getro (g, "/dev/sda");
322 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
329 static int test_blockdev_setrw_0 (void)
331 /* InitEmpty for blockdev_setrw (0) */
335 r = guestfs_umount_all (g);
342 r = guestfs_lvm_remove_all (g);
346 /* TestOutputFalse for blockdev_setrw (0) */
350 r = guestfs_blockdev_setrw (g, "/dev/sda");
357 r = guestfs_blockdev_getro (g, "/dev/sda");
361 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
368 static int test_blockdev_setro_0 (void)
370 /* InitEmpty for blockdev_setro (0) */
374 r = guestfs_umount_all (g);
381 r = guestfs_lvm_remove_all (g);
385 /* TestOutputTrue for blockdev_setro (0) */
389 r = guestfs_blockdev_setro (g, "/dev/sda");
396 r = guestfs_blockdev_getro (g, "/dev/sda");
400 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
407 static int test_statvfs_0 (void)
409 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
413 r = guestfs_umount_all (g);
420 r = guestfs_lvm_remove_all (g);
431 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
438 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
445 r = guestfs_mount (g, "/dev/sda1", "/");
449 /* TestOutputStruct for statvfs (0) */
451 struct guestfs_statvfs *r;
453 r = guestfs_statvfs (g, "/");
456 if (r->bfree != 487702) {
457 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
461 if (r->blocks != 490020) {
462 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
466 if (r->bsize != 1024) {
467 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
476 static int test_lstat_0 (void)
478 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
482 r = guestfs_umount_all (g);
489 r = guestfs_lvm_remove_all (g);
500 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
507 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
514 r = guestfs_mount (g, "/dev/sda1", "/");
518 /* TestOutputStruct for lstat (0) */
522 r = guestfs_touch (g, "/new");
527 struct guestfs_stat *r;
529 r = guestfs_lstat (g, "/new");
533 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
542 static int test_stat_0 (void)
544 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
548 r = guestfs_umount_all (g);
555 r = guestfs_lvm_remove_all (g);
566 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
573 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
580 r = guestfs_mount (g, "/dev/sda1", "/");
584 /* TestOutputStruct for stat (0) */
588 r = guestfs_touch (g, "/new");
593 struct guestfs_stat *r;
595 r = guestfs_stat (g, "/new");
599 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
608 static int test_file_0 (void)
610 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
614 r = guestfs_umount_all (g);
621 r = guestfs_lvm_remove_all (g);
632 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
639 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
646 r = guestfs_mount (g, "/dev/sda1", "/");
650 /* TestOutput for file (0) */
654 r = guestfs_touch (g, "/new");
661 r = guestfs_file (g, "/new");
664 if (strcmp (r, "empty") != 0) {
665 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
673 static int test_file_1 (void)
675 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
679 r = guestfs_umount_all (g);
686 r = guestfs_lvm_remove_all (g);
697 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
704 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
711 r = guestfs_mount (g, "/dev/sda1", "/");
715 /* TestOutput for file (1) */
719 r = guestfs_write_file (g, "/new", "some content\n", 0);
726 r = guestfs_file (g, "/new");
729 if (strcmp (r, "ASCII text") != 0) {
730 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
738 static int test_file_2 (void)
740 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
744 r = guestfs_umount_all (g);
751 r = guestfs_lvm_remove_all (g);
762 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
769 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
776 r = guestfs_mount (g, "/dev/sda1", "/");
780 /* TestLastFail for file (2) */
784 r = guestfs_file (g, "/nofile");
792 static int test_umount_all_0 (void)
794 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
798 r = guestfs_umount_all (g);
805 r = guestfs_lvm_remove_all (g);
816 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
823 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
830 r = guestfs_mount (g, "/dev/sda1", "/");
834 /* TestOutputList for umount_all (0) */
838 r = guestfs_umount_all (g);
846 r = guestfs_mounts (g);
850 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
854 for (i = 0; r[i] != NULL; ++i)
861 static int test_mounts_0 (void)
863 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
867 r = guestfs_umount_all (g);
874 r = guestfs_lvm_remove_all (g);
885 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
892 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
899 r = guestfs_mount (g, "/dev/sda1", "/");
903 /* TestOutputList for mounts (0) */
908 r = guestfs_mounts (g);
912 fprintf (stderr, "test_mounts_0: short list returned from command\n");
916 if (strcmp (r[0], "/dev/sda1") != 0) {
917 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
921 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
925 for (i = 0; r[i] != NULL; ++i)
932 static int test_umount_0 (void)
934 /* InitEmpty for umount (0) */
938 r = guestfs_umount_all (g);
945 r = guestfs_lvm_remove_all (g);
949 /* TestOutputList for umount (0) */
957 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
964 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
971 r = guestfs_mount (g, "/dev/sda1", "/");
979 r = guestfs_mounts (g);
983 fprintf (stderr, "test_umount_0: short list returned from command\n");
987 if (strcmp (r[0], "/dev/sda1") != 0) {
988 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
992 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
996 for (i = 0; r[i] != NULL; ++i)
1003 static int test_umount_1 (void)
1005 /* InitEmpty for umount (1) */
1009 r = guestfs_umount_all (g);
1016 r = guestfs_lvm_remove_all (g);
1020 /* TestOutputList for umount (1) */
1028 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1035 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1042 r = guestfs_mount (g, "/dev/sda1", "/");
1049 r = guestfs_umount (g, "/");
1057 r = guestfs_mounts (g);
1061 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
1065 for (i = 0; r[i] != NULL; ++i)
1072 static int test_write_file_0 (void)
1074 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
1078 r = guestfs_umount_all (g);
1085 r = guestfs_lvm_remove_all (g);
1096 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1103 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1110 r = guestfs_mount (g, "/dev/sda1", "/");
1114 /* TestOutput for write_file (0) */
1118 r = guestfs_write_file (g, "/new", "new file contents", 0);
1125 r = guestfs_cat (g, "/new");
1128 if (strcmp (r, "new file contents") != 0) {
1129 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
1137 static int test_write_file_1 (void)
1139 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
1143 r = guestfs_umount_all (g);
1150 r = guestfs_lvm_remove_all (g);
1161 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1168 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1175 r = guestfs_mount (g, "/dev/sda1", "/");
1179 /* TestOutput for write_file (1) */
1183 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
1190 r = guestfs_cat (g, "/new");
1193 if (strcmp (r, "\nnew file contents\n") != 0) {
1194 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
1202 static int test_write_file_2 (void)
1204 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
1208 r = guestfs_umount_all (g);
1215 r = guestfs_lvm_remove_all (g);
1226 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1233 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1240 r = guestfs_mount (g, "/dev/sda1", "/");
1244 /* TestOutput for write_file (2) */
1248 r = guestfs_write_file (g, "/new", "\n\n", 0);
1255 r = guestfs_cat (g, "/new");
1258 if (strcmp (r, "\n\n") != 0) {
1259 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
1267 static int test_write_file_3 (void)
1269 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
1273 r = guestfs_umount_all (g);
1280 r = guestfs_lvm_remove_all (g);
1291 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1298 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1305 r = guestfs_mount (g, "/dev/sda1", "/");
1309 /* TestOutput for write_file (3) */
1313 r = guestfs_write_file (g, "/new", "", 0);
1320 r = guestfs_cat (g, "/new");
1323 if (strcmp (r, "") != 0) {
1324 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
1332 static int test_write_file_4 (void)
1334 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
1338 r = guestfs_umount_all (g);
1345 r = guestfs_lvm_remove_all (g);
1356 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1363 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1370 r = guestfs_mount (g, "/dev/sda1", "/");
1374 /* TestOutput for write_file (4) */
1378 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
1385 r = guestfs_cat (g, "/new");
1388 if (strcmp (r, "\n\n\n") != 0) {
1389 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
1397 static int test_write_file_5 (void)
1399 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
1403 r = guestfs_umount_all (g);
1410 r = guestfs_lvm_remove_all (g);
1421 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1428 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1435 r = guestfs_mount (g, "/dev/sda1", "/");
1439 /* TestOutput for write_file (5) */
1443 r = guestfs_write_file (g, "/new", "\n", 0);
1450 r = guestfs_cat (g, "/new");
1453 if (strcmp (r, "\n") != 0) {
1454 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
1462 static int test_mkfs_0 (void)
1464 /* InitEmpty for mkfs (0) */
1468 r = guestfs_umount_all (g);
1475 r = guestfs_lvm_remove_all (g);
1479 /* TestOutput for mkfs (0) */
1487 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1494 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1501 r = guestfs_mount (g, "/dev/sda1", "/");
1508 r = guestfs_write_file (g, "/new", "new file contents", 0);
1515 r = guestfs_cat (g, "/new");
1518 if (strcmp (r, "new file contents") != 0) {
1519 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
1527 static int test_lvcreate_0 (void)
1529 /* InitEmpty for lvcreate (0) */
1533 r = guestfs_umount_all (g);
1540 r = guestfs_lvm_remove_all (g);
1544 /* TestOutputList for lvcreate (0) */
1554 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1561 r = guestfs_pvcreate (g, "/dev/sda1");
1568 r = guestfs_pvcreate (g, "/dev/sda2");
1575 r = guestfs_pvcreate (g, "/dev/sda3");
1580 char *physvols[] = {
1587 r = guestfs_vgcreate (g, "VG1", physvols);
1592 char *physvols[] = {
1598 r = guestfs_vgcreate (g, "VG2", physvols);
1605 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
1612 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
1619 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
1626 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
1633 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
1641 r = guestfs_lvs (g);
1645 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1649 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
1650 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
1654 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1658 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
1659 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
1663 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1667 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
1668 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
1672 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1676 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
1677 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
1681 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
1685 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
1686 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
1690 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
1694 for (i = 0; r[i] != NULL; ++i)
1701 static int test_vgcreate_0 (void)
1703 /* InitEmpty for vgcreate (0) */
1707 r = guestfs_umount_all (g);
1714 r = guestfs_lvm_remove_all (g);
1718 /* TestOutputList for vgcreate (0) */
1728 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1735 r = guestfs_pvcreate (g, "/dev/sda1");
1742 r = guestfs_pvcreate (g, "/dev/sda2");
1749 r = guestfs_pvcreate (g, "/dev/sda3");
1754 char *physvols[] = {
1761 r = guestfs_vgcreate (g, "VG1", physvols);
1766 char *physvols[] = {
1772 r = guestfs_vgcreate (g, "VG2", physvols);
1780 r = guestfs_vgs (g);
1784 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
1788 if (strcmp (r[0], "VG1") != 0) {
1789 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
1793 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
1797 if (strcmp (r[1], "VG2") != 0) {
1798 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
1802 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
1806 for (i = 0; r[i] != NULL; ++i)
1813 static int test_pvcreate_0 (void)
1815 /* InitEmpty for pvcreate (0) */
1819 r = guestfs_umount_all (g);
1826 r = guestfs_lvm_remove_all (g);
1830 /* TestOutputList for pvcreate (0) */
1840 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1847 r = guestfs_pvcreate (g, "/dev/sda1");
1854 r = guestfs_pvcreate (g, "/dev/sda2");
1861 r = guestfs_pvcreate (g, "/dev/sda3");
1869 r = guestfs_pvs (g);
1873 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
1877 if (strcmp (r[0], "/dev/sda1") != 0) {
1878 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1882 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
1886 if (strcmp (r[1], "/dev/sda2") != 0) {
1887 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
1891 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
1895 if (strcmp (r[2], "/dev/sda3") != 0) {
1896 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
1900 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
1904 for (i = 0; r[i] != NULL; ++i)
1911 static int test_is_dir_0 (void)
1913 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
1917 r = guestfs_umount_all (g);
1924 r = guestfs_lvm_remove_all (g);
1935 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1942 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1949 r = guestfs_mount (g, "/dev/sda1", "/");
1953 /* TestOutputFalse for is_dir (0) */
1957 r = guestfs_touch (g, "/new");
1964 r = guestfs_is_dir (g, "/new");
1968 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
1975 static int test_is_dir_1 (void)
1977 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
1981 r = guestfs_umount_all (g);
1988 r = guestfs_lvm_remove_all (g);
1999 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2006 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2013 r = guestfs_mount (g, "/dev/sda1", "/");
2017 /* TestOutputTrue for is_dir (1) */
2021 r = guestfs_mkdir (g, "/new");
2028 r = guestfs_is_dir (g, "/new");
2032 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2039 static int test_is_file_0 (void)
2041 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2045 r = guestfs_umount_all (g);
2052 r = guestfs_lvm_remove_all (g);
2063 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2070 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2077 r = guestfs_mount (g, "/dev/sda1", "/");
2081 /* TestOutputTrue for is_file (0) */
2085 r = guestfs_touch (g, "/new");
2092 r = guestfs_is_file (g, "/new");
2096 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2103 static int test_is_file_1 (void)
2105 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2109 r = guestfs_umount_all (g);
2116 r = guestfs_lvm_remove_all (g);
2127 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2134 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2141 r = guestfs_mount (g, "/dev/sda1", "/");
2145 /* TestOutputFalse for is_file (1) */
2149 r = guestfs_mkdir (g, "/new");
2156 r = guestfs_is_file (g, "/new");
2160 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2167 static int test_exists_0 (void)
2169 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2173 r = guestfs_umount_all (g);
2180 r = guestfs_lvm_remove_all (g);
2191 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2198 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2205 r = guestfs_mount (g, "/dev/sda1", "/");
2209 /* TestOutputTrue for exists (0) */
2213 r = guestfs_touch (g, "/new");
2220 r = guestfs_exists (g, "/new");
2224 fprintf (stderr, "test_exists_0: expected true, got false\n");
2231 static int test_exists_1 (void)
2233 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
2237 r = guestfs_umount_all (g);
2244 r = guestfs_lvm_remove_all (g);
2255 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2262 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2269 r = guestfs_mount (g, "/dev/sda1", "/");
2273 /* TestOutputTrue for exists (1) */
2277 r = guestfs_mkdir (g, "/new");
2284 r = guestfs_exists (g, "/new");
2288 fprintf (stderr, "test_exists_1: expected true, got false\n");
2295 static int test_mkdir_p_0 (void)
2297 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
2301 r = guestfs_umount_all (g);
2308 r = guestfs_lvm_remove_all (g);
2319 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2326 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2333 r = guestfs_mount (g, "/dev/sda1", "/");
2337 /* TestOutputTrue for mkdir_p (0) */
2341 r = guestfs_mkdir_p (g, "/new/foo/bar");
2348 r = guestfs_is_dir (g, "/new/foo/bar");
2352 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
2359 static int test_mkdir_p_1 (void)
2361 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
2365 r = guestfs_umount_all (g);
2372 r = guestfs_lvm_remove_all (g);
2383 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2390 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2397 r = guestfs_mount (g, "/dev/sda1", "/");
2401 /* TestOutputTrue for mkdir_p (1) */
2405 r = guestfs_mkdir_p (g, "/new/foo/bar");
2412 r = guestfs_is_dir (g, "/new/foo");
2416 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
2423 static int test_mkdir_p_2 (void)
2425 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
2429 r = guestfs_umount_all (g);
2436 r = guestfs_lvm_remove_all (g);
2447 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2454 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2461 r = guestfs_mount (g, "/dev/sda1", "/");
2465 /* TestOutputTrue for mkdir_p (2) */
2469 r = guestfs_mkdir_p (g, "/new/foo/bar");
2476 r = guestfs_is_dir (g, "/new");
2480 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
2487 static int test_mkdir_0 (void)
2489 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
2493 r = guestfs_umount_all (g);
2500 r = guestfs_lvm_remove_all (g);
2511 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2518 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2525 r = guestfs_mount (g, "/dev/sda1", "/");
2529 /* TestOutputTrue for mkdir (0) */
2533 r = guestfs_mkdir (g, "/new");
2540 r = guestfs_is_dir (g, "/new");
2544 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
2551 static int test_mkdir_1 (void)
2553 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
2557 r = guestfs_umount_all (g);
2564 r = guestfs_lvm_remove_all (g);
2575 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2582 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2589 r = guestfs_mount (g, "/dev/sda1", "/");
2593 /* TestLastFail for mkdir (1) */
2597 r = guestfs_mkdir (g, "/new/foo/bar");
2604 static int test_rm_rf_0 (void)
2606 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
2610 r = guestfs_umount_all (g);
2617 r = guestfs_lvm_remove_all (g);
2628 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2635 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2642 r = guestfs_mount (g, "/dev/sda1", "/");
2646 /* TestOutputFalse for rm_rf (0) */
2650 r = guestfs_mkdir (g, "/new");
2657 r = guestfs_mkdir (g, "/new/foo");
2664 r = guestfs_touch (g, "/new/foo/bar");
2671 r = guestfs_rm_rf (g, "/new");
2678 r = guestfs_exists (g, "/new");
2682 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
2689 static int test_rmdir_0 (void)
2691 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
2695 r = guestfs_umount_all (g);
2702 r = guestfs_lvm_remove_all (g);
2713 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2720 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2727 r = guestfs_mount (g, "/dev/sda1", "/");
2731 /* TestRun for rmdir (0) */
2735 r = guestfs_mkdir (g, "/new");
2742 r = guestfs_rmdir (g, "/new");
2749 static int test_rmdir_1 (void)
2751 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
2755 r = guestfs_umount_all (g);
2762 r = guestfs_lvm_remove_all (g);
2773 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2780 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2787 r = guestfs_mount (g, "/dev/sda1", "/");
2791 /* TestLastFail for rmdir (1) */
2795 r = guestfs_rmdir (g, "/new");
2802 static int test_rmdir_2 (void)
2804 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
2808 r = guestfs_umount_all (g);
2815 r = guestfs_lvm_remove_all (g);
2826 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2833 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2840 r = guestfs_mount (g, "/dev/sda1", "/");
2844 /* TestLastFail for rmdir (2) */
2848 r = guestfs_touch (g, "/new");
2855 r = guestfs_rmdir (g, "/new");
2862 static int test_rm_0 (void)
2864 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
2868 r = guestfs_umount_all (g);
2875 r = guestfs_lvm_remove_all (g);
2886 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2893 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2900 r = guestfs_mount (g, "/dev/sda1", "/");
2904 /* TestRun for rm (0) */
2908 r = guestfs_touch (g, "/new");
2915 r = guestfs_rm (g, "/new");
2922 static int test_rm_1 (void)
2924 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
2928 r = guestfs_umount_all (g);
2935 r = guestfs_lvm_remove_all (g);
2946 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2953 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2960 r = guestfs_mount (g, "/dev/sda1", "/");
2964 /* TestLastFail for rm (1) */
2968 r = guestfs_rm (g, "/new");
2975 static int test_rm_2 (void)
2977 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
2981 r = guestfs_umount_all (g);
2988 r = guestfs_lvm_remove_all (g);
2999 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3006 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3013 r = guestfs_mount (g, "/dev/sda1", "/");
3017 /* TestLastFail for rm (2) */
3021 r = guestfs_mkdir (g, "/new");
3028 r = guestfs_rm (g, "/new");
3035 static int test_read_lines_0 (void)
3037 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3041 r = guestfs_umount_all (g);
3048 r = guestfs_lvm_remove_all (g);
3059 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3066 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3073 r = guestfs_mount (g, "/dev/sda1", "/");
3077 /* TestOutputList for read_lines (0) */
3081 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
3089 r = guestfs_read_lines (g, "/new");
3093 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3097 if (strcmp (r[0], "line1") != 0) {
3098 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
3102 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3106 if (strcmp (r[1], "line2") != 0) {
3107 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
3111 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3115 if (strcmp (r[2], "line3") != 0) {
3116 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
3120 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
3124 for (i = 0; r[i] != NULL; ++i)
3131 static int test_read_lines_1 (void)
3133 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
3137 r = guestfs_umount_all (g);
3144 r = guestfs_lvm_remove_all (g);
3155 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3162 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3169 r = guestfs_mount (g, "/dev/sda1", "/");
3173 /* TestOutputList for read_lines (1) */
3177 r = guestfs_write_file (g, "/new", "", 0);
3185 r = guestfs_read_lines (g, "/new");
3189 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
3193 for (i = 0; r[i] != NULL; ++i)
3200 static int test_lvs_0 (void)
3202 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
3206 r = guestfs_umount_all (g);
3213 r = guestfs_lvm_remove_all (g);
3224 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3231 r = guestfs_pvcreate (g, "/dev/sda1");
3236 char *physvols[] = {
3242 r = guestfs_vgcreate (g, "VG", physvols);
3249 r = guestfs_lvcreate (g, "LV", "VG", 8);
3256 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3263 r = guestfs_mount (g, "/dev/VG/LV", "/");
3267 /* TestOutputList for lvs (0) */
3272 r = guestfs_lvs (g);
3276 fprintf (stderr, "test_lvs_0: short list returned from command\n");
3280 if (strcmp (r[0], "/dev/VG/LV") != 0) {
3281 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
3285 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
3289 for (i = 0; r[i] != NULL; ++i)
3296 static int test_lvs_1 (void)
3298 /* InitEmpty for lvs (1) */
3302 r = guestfs_umount_all (g);
3309 r = guestfs_lvm_remove_all (g);
3313 /* TestOutputList for lvs (1) */
3323 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3330 r = guestfs_pvcreate (g, "/dev/sda1");
3337 r = guestfs_pvcreate (g, "/dev/sda2");
3344 r = guestfs_pvcreate (g, "/dev/sda3");
3349 char *physvols[] = {
3356 r = guestfs_vgcreate (g, "VG1", physvols);
3361 char *physvols[] = {
3367 r = guestfs_vgcreate (g, "VG2", physvols);
3374 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
3381 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
3388 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
3396 r = guestfs_lvs (g);
3400 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3404 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
3405 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
3409 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3413 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
3414 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
3418 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3422 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
3423 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
3427 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
3431 for (i = 0; r[i] != NULL; ++i)
3438 static int test_vgs_0 (void)
3440 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
3444 r = guestfs_umount_all (g);
3451 r = guestfs_lvm_remove_all (g);
3462 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3469 r = guestfs_pvcreate (g, "/dev/sda1");
3474 char *physvols[] = {
3480 r = guestfs_vgcreate (g, "VG", physvols);
3487 r = guestfs_lvcreate (g, "LV", "VG", 8);
3494 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3501 r = guestfs_mount (g, "/dev/VG/LV", "/");
3505 /* TestOutputList for vgs (0) */
3510 r = guestfs_vgs (g);
3514 fprintf (stderr, "test_vgs_0: short list returned from command\n");
3518 if (strcmp (r[0], "VG") != 0) {
3519 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
3523 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
3527 for (i = 0; r[i] != NULL; ++i)
3534 static int test_vgs_1 (void)
3536 /* InitEmpty for vgs (1) */
3540 r = guestfs_umount_all (g);
3547 r = guestfs_lvm_remove_all (g);
3551 /* TestOutputList for vgs (1) */
3561 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3568 r = guestfs_pvcreate (g, "/dev/sda1");
3575 r = guestfs_pvcreate (g, "/dev/sda2");
3582 r = guestfs_pvcreate (g, "/dev/sda3");
3587 char *physvols[] = {
3594 r = guestfs_vgcreate (g, "VG1", physvols);
3599 char *physvols[] = {
3605 r = guestfs_vgcreate (g, "VG2", physvols);
3613 r = guestfs_vgs (g);
3617 fprintf (stderr, "test_vgs_1: short list returned from command\n");
3621 if (strcmp (r[0], "VG1") != 0) {
3622 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
3626 fprintf (stderr, "test_vgs_1: short list returned from command\n");
3630 if (strcmp (r[1], "VG2") != 0) {
3631 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
3635 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
3639 for (i = 0; r[i] != NULL; ++i)
3646 static int test_pvs_0 (void)
3648 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
3652 r = guestfs_umount_all (g);
3659 r = guestfs_lvm_remove_all (g);
3670 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3677 r = guestfs_pvcreate (g, "/dev/sda1");
3682 char *physvols[] = {
3688 r = guestfs_vgcreate (g, "VG", physvols);
3695 r = guestfs_lvcreate (g, "LV", "VG", 8);
3702 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3709 r = guestfs_mount (g, "/dev/VG/LV", "/");
3713 /* TestOutputList for pvs (0) */
3718 r = guestfs_pvs (g);
3722 fprintf (stderr, "test_pvs_0: short list returned from command\n");
3726 if (strcmp (r[0], "/dev/sda1") != 0) {
3727 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3731 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
3735 for (i = 0; r[i] != NULL; ++i)
3742 static int test_pvs_1 (void)
3744 /* InitEmpty for pvs (1) */
3748 r = guestfs_umount_all (g);
3755 r = guestfs_lvm_remove_all (g);
3759 /* TestOutputList for pvs (1) */
3769 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3776 r = guestfs_pvcreate (g, "/dev/sda1");
3783 r = guestfs_pvcreate (g, "/dev/sda2");
3790 r = guestfs_pvcreate (g, "/dev/sda3");
3798 r = guestfs_pvs (g);
3802 fprintf (stderr, "test_pvs_1: short list returned from command\n");
3806 if (strcmp (r[0], "/dev/sda1") != 0) {
3807 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3811 fprintf (stderr, "test_pvs_1: short list returned from command\n");
3815 if (strcmp (r[1], "/dev/sda2") != 0) {
3816 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
3820 fprintf (stderr, "test_pvs_1: short list returned from command\n");
3824 if (strcmp (r[2], "/dev/sda3") != 0) {
3825 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
3829 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
3833 for (i = 0; r[i] != NULL; ++i)
3840 static int test_list_partitions_0 (void)
3842 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
3846 r = guestfs_umount_all (g);
3853 r = guestfs_lvm_remove_all (g);
3864 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3871 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3878 r = guestfs_mount (g, "/dev/sda1", "/");
3882 /* TestOutputList for list_partitions (0) */
3887 r = guestfs_list_partitions (g);
3891 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
3895 if (strcmp (r[0], "/dev/sda1") != 0) {
3896 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3900 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
3904 for (i = 0; r[i] != NULL; ++i)
3911 static int test_list_partitions_1 (void)
3913 /* InitEmpty for list_partitions (1) */
3917 r = guestfs_umount_all (g);
3924 r = guestfs_lvm_remove_all (g);
3928 /* TestOutputList for list_partitions (1) */
3938 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3946 r = guestfs_list_partitions (g);
3950 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
3954 if (strcmp (r[0], "/dev/sda1") != 0) {
3955 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3959 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
3963 if (strcmp (r[1], "/dev/sda2") != 0) {
3964 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
3968 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
3972 if (strcmp (r[2], "/dev/sda3") != 0) {
3973 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
3977 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
3981 for (i = 0; r[i] != NULL; ++i)
3988 static int test_list_devices_0 (void)
3990 /* InitEmpty for list_devices (0) */
3994 r = guestfs_umount_all (g);
4001 r = guestfs_lvm_remove_all (g);
4005 /* TestOutputList for list_devices (0) */
4010 r = guestfs_list_devices (g);
4014 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4018 if (strcmp (r[0], "/dev/sda") != 0) {
4019 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4023 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4027 if (strcmp (r[1], "/dev/sdb") != 0) {
4028 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4032 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4036 if (strcmp (r[2], "/dev/sdc") != 0) {
4037 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4041 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4045 for (i = 0; r[i] != NULL; ++i)
4052 static int test_ls_0 (void)
4054 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4058 r = guestfs_umount_all (g);
4065 r = guestfs_lvm_remove_all (g);
4076 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4083 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4090 r = guestfs_mount (g, "/dev/sda1", "/");
4094 /* TestOutputList for ls (0) */
4098 r = guestfs_touch (g, "/new");
4105 r = guestfs_touch (g, "/newer");
4112 r = guestfs_touch (g, "/newest");
4120 r = guestfs_ls (g, "/");
4124 fprintf (stderr, "test_ls_0: short list returned from command\n");
4128 if (strcmp (r[0], "lost+found") != 0) {
4129 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
4133 fprintf (stderr, "test_ls_0: short list returned from command\n");
4137 if (strcmp (r[1], "new") != 0) {
4138 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
4142 fprintf (stderr, "test_ls_0: short list returned from command\n");
4146 if (strcmp (r[2], "newer") != 0) {
4147 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
4151 fprintf (stderr, "test_ls_0: short list returned from command\n");
4155 if (strcmp (r[3], "newest") != 0) {
4156 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
4160 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
4164 for (i = 0; r[i] != NULL; ++i)
4171 static int test_cat_0 (void)
4173 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
4177 r = guestfs_umount_all (g);
4184 r = guestfs_lvm_remove_all (g);
4195 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4202 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4209 r = guestfs_mount (g, "/dev/sda1", "/");
4213 /* TestOutput for cat (0) */
4217 r = guestfs_write_file (g, "/new", "new file contents", 0);
4224 r = guestfs_cat (g, "/new");
4227 if (strcmp (r, "new file contents") != 0) {
4228 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
4236 static int test_touch_0 (void)
4238 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
4242 r = guestfs_umount_all (g);
4249 r = guestfs_lvm_remove_all (g);
4260 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4267 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4274 r = guestfs_mount (g, "/dev/sda1", "/");
4278 /* TestOutputTrue for touch (0) */
4282 r = guestfs_touch (g, "/new");
4289 r = guestfs_exists (g, "/new");
4293 fprintf (stderr, "test_touch_0: expected true, got false\n");
4300 static int test_sync_0 (void)
4302 /* InitEmpty for sync (0) */
4306 r = guestfs_umount_all (g);
4313 r = guestfs_lvm_remove_all (g);
4317 /* TestRun for sync (0) */
4321 r = guestfs_sync (g);
4328 static int test_mount_0 (void)
4330 /* InitEmpty for mount (0) */
4334 r = guestfs_umount_all (g);
4341 r = guestfs_lvm_remove_all (g);
4345 /* TestOutput for mount (0) */
4353 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4360 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4367 r = guestfs_mount (g, "/dev/sda1", "/");
4374 r = guestfs_write_file (g, "/new", "new file contents", 0);
4381 r = guestfs_cat (g, "/new");
4384 if (strcmp (r, "new file contents") != 0) {
4385 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
4393 int main (int argc, char *argv[])
4400 int nr_tests, test_num = 0;
4402 no_test_warnings ();
4404 g = guestfs_create ();
4406 printf ("guestfs_create FAILED\n");
4410 guestfs_set_error_handler (g, print_error, NULL);
4412 srcdir = getenv ("srcdir");
4413 if (!srcdir) srcdir = ".";
4414 guestfs_set_path (g, srcdir);
4416 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
4417 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4422 if (lseek (fd, 524288000, SEEK_SET) == -1) {
4428 if (write (fd, &c, 1) == -1) {
4434 if (close (fd) == -1) {
4439 if (guestfs_add_drive (g, buf) == -1) {
4440 printf ("guestfs_add_drive %s FAILED\n", buf);
4444 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
4445 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4450 if (lseek (fd, 52428800, SEEK_SET) == -1) {
4456 if (write (fd, &c, 1) == -1) {
4462 if (close (fd) == -1) {
4467 if (guestfs_add_drive (g, buf) == -1) {
4468 printf ("guestfs_add_drive %s FAILED\n", buf);
4472 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
4473 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4478 if (lseek (fd, 10485760, SEEK_SET) == -1) {
4484 if (write (fd, &c, 1) == -1) {
4490 if (close (fd) == -1) {
4495 if (guestfs_add_drive (g, buf) == -1) {
4496 printf ("guestfs_add_drive %s FAILED\n", buf);
4500 if (guestfs_launch (g) == -1) {
4501 printf ("guestfs_launch FAILED\n");
4504 if (guestfs_wait_ready (g) == -1) {
4505 printf ("guestfs_wait_ready FAILED\n");
4512 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
4513 if (test_blockdev_rereadpt_0 () == -1) {
4514 printf ("test_blockdev_rereadpt_0 FAILED\n");
4518 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
4519 if (test_blockdev_flushbufs_0 () == -1) {
4520 printf ("test_blockdev_flushbufs_0 FAILED\n");
4524 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
4525 if (test_blockdev_getsize64_0 () == -1) {
4526 printf ("test_blockdev_getsize64_0 FAILED\n");
4530 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
4531 if (test_blockdev_getsz_0 () == -1) {
4532 printf ("test_blockdev_getsz_0 FAILED\n");
4536 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
4537 if (test_blockdev_getbsz_0 () == -1) {
4538 printf ("test_blockdev_getbsz_0 FAILED\n");
4542 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
4543 if (test_blockdev_getss_0 () == -1) {
4544 printf ("test_blockdev_getss_0 FAILED\n");
4548 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
4549 if (test_blockdev_getro_0 () == -1) {
4550 printf ("test_blockdev_getro_0 FAILED\n");
4554 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
4555 if (test_blockdev_setrw_0 () == -1) {
4556 printf ("test_blockdev_setrw_0 FAILED\n");
4560 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
4561 if (test_blockdev_setro_0 () == -1) {
4562 printf ("test_blockdev_setro_0 FAILED\n");
4566 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
4567 if (test_statvfs_0 () == -1) {
4568 printf ("test_statvfs_0 FAILED\n");
4572 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
4573 if (test_lstat_0 () == -1) {
4574 printf ("test_lstat_0 FAILED\n");
4578 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
4579 if (test_stat_0 () == -1) {
4580 printf ("test_stat_0 FAILED\n");
4584 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
4585 if (test_file_0 () == -1) {
4586 printf ("test_file_0 FAILED\n");
4590 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
4591 if (test_file_1 () == -1) {
4592 printf ("test_file_1 FAILED\n");
4596 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
4597 if (test_file_2 () == -1) {
4598 printf ("test_file_2 FAILED\n");
4602 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
4603 if (test_umount_all_0 () == -1) {
4604 printf ("test_umount_all_0 FAILED\n");
4608 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
4609 if (test_mounts_0 () == -1) {
4610 printf ("test_mounts_0 FAILED\n");
4614 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
4615 if (test_umount_0 () == -1) {
4616 printf ("test_umount_0 FAILED\n");
4620 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
4621 if (test_umount_1 () == -1) {
4622 printf ("test_umount_1 FAILED\n");
4626 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
4627 if (test_write_file_0 () == -1) {
4628 printf ("test_write_file_0 FAILED\n");
4632 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
4633 if (test_write_file_1 () == -1) {
4634 printf ("test_write_file_1 FAILED\n");
4638 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
4639 if (test_write_file_2 () == -1) {
4640 printf ("test_write_file_2 FAILED\n");
4644 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
4645 if (test_write_file_3 () == -1) {
4646 printf ("test_write_file_3 FAILED\n");
4650 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
4651 if (test_write_file_4 () == -1) {
4652 printf ("test_write_file_4 FAILED\n");
4656 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
4657 if (test_write_file_5 () == -1) {
4658 printf ("test_write_file_5 FAILED\n");
4662 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
4663 if (test_mkfs_0 () == -1) {
4664 printf ("test_mkfs_0 FAILED\n");
4668 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
4669 if (test_lvcreate_0 () == -1) {
4670 printf ("test_lvcreate_0 FAILED\n");
4674 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
4675 if (test_vgcreate_0 () == -1) {
4676 printf ("test_vgcreate_0 FAILED\n");
4680 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
4681 if (test_pvcreate_0 () == -1) {
4682 printf ("test_pvcreate_0 FAILED\n");
4686 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
4687 if (test_is_dir_0 () == -1) {
4688 printf ("test_is_dir_0 FAILED\n");
4692 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
4693 if (test_is_dir_1 () == -1) {
4694 printf ("test_is_dir_1 FAILED\n");
4698 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
4699 if (test_is_file_0 () == -1) {
4700 printf ("test_is_file_0 FAILED\n");
4704 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
4705 if (test_is_file_1 () == -1) {
4706 printf ("test_is_file_1 FAILED\n");
4710 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
4711 if (test_exists_0 () == -1) {
4712 printf ("test_exists_0 FAILED\n");
4716 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
4717 if (test_exists_1 () == -1) {
4718 printf ("test_exists_1 FAILED\n");
4722 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
4723 if (test_mkdir_p_0 () == -1) {
4724 printf ("test_mkdir_p_0 FAILED\n");
4728 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
4729 if (test_mkdir_p_1 () == -1) {
4730 printf ("test_mkdir_p_1 FAILED\n");
4734 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
4735 if (test_mkdir_p_2 () == -1) {
4736 printf ("test_mkdir_p_2 FAILED\n");
4740 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
4741 if (test_mkdir_0 () == -1) {
4742 printf ("test_mkdir_0 FAILED\n");
4746 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
4747 if (test_mkdir_1 () == -1) {
4748 printf ("test_mkdir_1 FAILED\n");
4752 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
4753 if (test_rm_rf_0 () == -1) {
4754 printf ("test_rm_rf_0 FAILED\n");
4758 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
4759 if (test_rmdir_0 () == -1) {
4760 printf ("test_rmdir_0 FAILED\n");
4764 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
4765 if (test_rmdir_1 () == -1) {
4766 printf ("test_rmdir_1 FAILED\n");
4770 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
4771 if (test_rmdir_2 () == -1) {
4772 printf ("test_rmdir_2 FAILED\n");
4776 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
4777 if (test_rm_0 () == -1) {
4778 printf ("test_rm_0 FAILED\n");
4782 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
4783 if (test_rm_1 () == -1) {
4784 printf ("test_rm_1 FAILED\n");
4788 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
4789 if (test_rm_2 () == -1) {
4790 printf ("test_rm_2 FAILED\n");
4794 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
4795 if (test_read_lines_0 () == -1) {
4796 printf ("test_read_lines_0 FAILED\n");
4800 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
4801 if (test_read_lines_1 () == -1) {
4802 printf ("test_read_lines_1 FAILED\n");
4806 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
4807 if (test_lvs_0 () == -1) {
4808 printf ("test_lvs_0 FAILED\n");
4812 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
4813 if (test_lvs_1 () == -1) {
4814 printf ("test_lvs_1 FAILED\n");
4818 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
4819 if (test_vgs_0 () == -1) {
4820 printf ("test_vgs_0 FAILED\n");
4824 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
4825 if (test_vgs_1 () == -1) {
4826 printf ("test_vgs_1 FAILED\n");
4830 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
4831 if (test_pvs_0 () == -1) {
4832 printf ("test_pvs_0 FAILED\n");
4836 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
4837 if (test_pvs_1 () == -1) {
4838 printf ("test_pvs_1 FAILED\n");
4842 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
4843 if (test_list_partitions_0 () == -1) {
4844 printf ("test_list_partitions_0 FAILED\n");
4848 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
4849 if (test_list_partitions_1 () == -1) {
4850 printf ("test_list_partitions_1 FAILED\n");
4854 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
4855 if (test_list_devices_0 () == -1) {
4856 printf ("test_list_devices_0 FAILED\n");
4860 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
4861 if (test_ls_0 () == -1) {
4862 printf ("test_ls_0 FAILED\n");
4866 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
4867 if (test_cat_0 () == -1) {
4868 printf ("test_cat_0 FAILED\n");
4872 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
4873 if (test_touch_0 () == -1) {
4874 printf ("test_touch_0 FAILED\n");
4878 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
4879 if (test_sync_0 () == -1) {
4880 printf ("test_sync_0 FAILED\n");
4884 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
4885 if (test_mount_0 () == -1) {
4886 printf ("test_mount_0 FAILED\n");
4891 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
4893 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
4895 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
4899 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);