1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 static void print_error (guestfs_h *g, void *data, const char *msg)
37 fprintf (stderr, "%s\n", msg);
40 static void print_strings (char * const * const argv)
44 for (argc = 0; argv[argc] != NULL; ++argc)
45 printf ("\t%s\n", argv[argc]);
49 static void print_table (char * const * const argv)
53 for (i = 0; argv[i] != NULL; i += 2)
54 printf ("%s: %s\n", argv[i], argv[i+1]);
58 static void no_test_warnings (void)
60 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
61 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
62 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
63 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
64 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
65 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
112 static int test_mount_ro_0 (void)
114 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
118 r = guestfs_umount_all (g);
125 r = guestfs_lvm_remove_all (g);
136 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
143 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
150 r = guestfs_mount (g, "/dev/sda1", "/");
154 /* TestLastFail for mount_ro (0) */
158 r = guestfs_umount (g, "/");
165 r = guestfs_mount_ro (g, "/dev/sda1", "/");
172 r = guestfs_touch (g, "/new");
179 static int test_mount_ro_1 (void)
181 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
185 r = guestfs_umount_all (g);
192 r = guestfs_lvm_remove_all (g);
203 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
210 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
217 r = guestfs_mount (g, "/dev/sda1", "/");
221 /* TestOutput for mount_ro (1) */
225 r = guestfs_write_file (g, "/new", "data", 0);
232 r = guestfs_umount (g, "/");
239 r = guestfs_mount_ro (g, "/dev/sda1", "/");
246 r = guestfs_cat (g, "/new");
249 if (strcmp (r, "data") != 0) {
250 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
258 static int test_tgz_in_0 (void)
260 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
264 r = guestfs_umount_all (g);
271 r = guestfs_lvm_remove_all (g);
282 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
289 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
296 r = guestfs_mount (g, "/dev/sda1", "/");
300 /* TestOutput for tgz_in (0) */
304 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
311 r = guestfs_cat (g, "/hello");
314 if (strcmp (r, "hello\n") != 0) {
315 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
323 static int test_tar_in_0 (void)
325 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
329 r = guestfs_umount_all (g);
336 r = guestfs_lvm_remove_all (g);
347 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
354 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
361 r = guestfs_mount (g, "/dev/sda1", "/");
365 /* TestOutput for tar_in (0) */
369 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
376 r = guestfs_cat (g, "/hello");
379 if (strcmp (r, "hello\n") != 0) {
380 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
388 static int test_checksum_0 (void)
390 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
394 r = guestfs_umount_all (g);
401 r = guestfs_lvm_remove_all (g);
412 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
419 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
426 r = guestfs_mount (g, "/dev/sda1", "/");
430 /* TestOutput for checksum (0) */
434 r = guestfs_write_file (g, "/new", "test\n", 0);
441 r = guestfs_checksum (g, "crc", "/new");
444 if (strcmp (r, "935282863") != 0) {
445 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
453 static int test_checksum_1 (void)
455 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
459 r = guestfs_umount_all (g);
466 r = guestfs_lvm_remove_all (g);
477 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
484 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
491 r = guestfs_mount (g, "/dev/sda1", "/");
495 /* TestLastFail for checksum (1) */
499 r = guestfs_checksum (g, "crc", "/new");
507 static int test_checksum_2 (void)
509 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
513 r = guestfs_umount_all (g);
520 r = guestfs_lvm_remove_all (g);
531 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
538 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
545 r = guestfs_mount (g, "/dev/sda1", "/");
549 /* TestOutput for checksum (2) */
553 r = guestfs_write_file (g, "/new", "test\n", 0);
560 r = guestfs_checksum (g, "md5", "/new");
563 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
564 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
572 static int test_checksum_3 (void)
574 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
578 r = guestfs_umount_all (g);
585 r = guestfs_lvm_remove_all (g);
596 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
603 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
610 r = guestfs_mount (g, "/dev/sda1", "/");
614 /* TestOutput for checksum (3) */
618 r = guestfs_write_file (g, "/new", "test\n", 0);
625 r = guestfs_checksum (g, "sha1", "/new");
628 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
629 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
637 static int test_checksum_4 (void)
639 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
643 r = guestfs_umount_all (g);
650 r = guestfs_lvm_remove_all (g);
661 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
668 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
675 r = guestfs_mount (g, "/dev/sda1", "/");
679 /* TestOutput for checksum (4) */
683 r = guestfs_write_file (g, "/new", "test\n", 0);
690 r = guestfs_checksum (g, "sha224", "/new");
693 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
694 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
702 static int test_checksum_5 (void)
704 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
708 r = guestfs_umount_all (g);
715 r = guestfs_lvm_remove_all (g);
726 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
733 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
740 r = guestfs_mount (g, "/dev/sda1", "/");
744 /* TestOutput for checksum (5) */
748 r = guestfs_write_file (g, "/new", "test\n", 0);
755 r = guestfs_checksum (g, "sha256", "/new");
758 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
759 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
767 static int test_checksum_6 (void)
769 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
773 r = guestfs_umount_all (g);
780 r = guestfs_lvm_remove_all (g);
791 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
798 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
805 r = guestfs_mount (g, "/dev/sda1", "/");
809 /* TestOutput for checksum (6) */
813 r = guestfs_write_file (g, "/new", "test\n", 0);
820 r = guestfs_checksum (g, "sha384", "/new");
823 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
824 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
832 static int test_checksum_7 (void)
834 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
838 r = guestfs_umount_all (g);
845 r = guestfs_lvm_remove_all (g);
856 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
863 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
870 r = guestfs_mount (g, "/dev/sda1", "/");
874 /* TestOutput for checksum (7) */
878 r = guestfs_write_file (g, "/new", "test\n", 0);
885 r = guestfs_checksum (g, "sha512", "/new");
888 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
889 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
897 static int test_download_0 (void)
899 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
903 r = guestfs_umount_all (g);
910 r = guestfs_lvm_remove_all (g);
921 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
928 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
935 r = guestfs_mount (g, "/dev/sda1", "/");
939 /* TestOutput for download (0) */
943 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
950 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
957 r = guestfs_upload (g, "testdownload.tmp", "/upload");
964 r = guestfs_checksum (g, "md5", "/upload");
967 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
968 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
976 static int test_upload_0 (void)
978 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
982 r = guestfs_umount_all (g);
989 r = guestfs_lvm_remove_all (g);
1000 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1007 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1014 r = guestfs_mount (g, "/dev/sda1", "/");
1018 /* TestOutput for upload (0) */
1022 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
1029 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
1032 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
1033 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
1041 static int test_blockdev_rereadpt_0 (void)
1043 /* InitEmpty for blockdev_rereadpt (0) */
1047 r = guestfs_umount_all (g);
1054 r = guestfs_lvm_remove_all (g);
1058 /* TestRun for blockdev_rereadpt (0) */
1062 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
1069 static int test_blockdev_flushbufs_0 (void)
1071 /* InitEmpty for blockdev_flushbufs (0) */
1075 r = guestfs_umount_all (g);
1082 r = guestfs_lvm_remove_all (g);
1086 /* TestRun for blockdev_flushbufs (0) */
1090 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
1097 static int test_blockdev_getsize64_0 (void)
1099 /* InitEmpty for blockdev_getsize64 (0) */
1103 r = guestfs_umount_all (g);
1110 r = guestfs_lvm_remove_all (g);
1114 /* TestOutputInt for blockdev_getsize64 (0) */
1118 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
1121 if (r != 524288000) {
1122 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
1129 static int test_blockdev_getsz_0 (void)
1131 /* InitEmpty for blockdev_getsz (0) */
1135 r = guestfs_umount_all (g);
1142 r = guestfs_lvm_remove_all (g);
1146 /* TestOutputInt for blockdev_getsz (0) */
1150 r = guestfs_blockdev_getsz (g, "/dev/sda");
1154 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
1161 static int test_blockdev_getbsz_0 (void)
1163 /* InitEmpty for blockdev_getbsz (0) */
1167 r = guestfs_umount_all (g);
1174 r = guestfs_lvm_remove_all (g);
1178 /* TestOutputInt for blockdev_getbsz (0) */
1182 r = guestfs_blockdev_getbsz (g, "/dev/sda");
1186 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
1193 static int test_blockdev_getss_0 (void)
1195 /* InitEmpty for blockdev_getss (0) */
1199 r = guestfs_umount_all (g);
1206 r = guestfs_lvm_remove_all (g);
1210 /* TestOutputInt for blockdev_getss (0) */
1214 r = guestfs_blockdev_getss (g, "/dev/sda");
1218 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
1225 static int test_blockdev_getro_0 (void)
1227 /* InitEmpty for blockdev_getro (0) */
1231 r = guestfs_umount_all (g);
1238 r = guestfs_lvm_remove_all (g);
1242 /* TestOutputTrue for blockdev_getro (0) */
1246 r = guestfs_blockdev_setro (g, "/dev/sda");
1253 r = guestfs_blockdev_getro (g, "/dev/sda");
1257 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
1264 static int test_blockdev_setrw_0 (void)
1266 /* InitEmpty for blockdev_setrw (0) */
1270 r = guestfs_umount_all (g);
1277 r = guestfs_lvm_remove_all (g);
1281 /* TestOutputFalse for blockdev_setrw (0) */
1285 r = guestfs_blockdev_setrw (g, "/dev/sda");
1292 r = guestfs_blockdev_getro (g, "/dev/sda");
1296 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
1303 static int test_blockdev_setro_0 (void)
1305 /* InitEmpty for blockdev_setro (0) */
1309 r = guestfs_umount_all (g);
1316 r = guestfs_lvm_remove_all (g);
1320 /* TestOutputTrue for blockdev_setro (0) */
1324 r = guestfs_blockdev_setro (g, "/dev/sda");
1331 r = guestfs_blockdev_getro (g, "/dev/sda");
1335 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
1342 static int test_statvfs_0 (void)
1344 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
1348 r = guestfs_umount_all (g);
1355 r = guestfs_lvm_remove_all (g);
1366 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1373 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1380 r = guestfs_mount (g, "/dev/sda1", "/");
1384 /* TestOutputStruct for statvfs (0) */
1386 struct guestfs_statvfs *r;
1388 r = guestfs_statvfs (g, "/");
1391 if (r->bfree != 487702) {
1392 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
1396 if (r->blocks != 490020) {
1397 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
1401 if (r->bsize != 1024) {
1402 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
1411 static int test_lstat_0 (void)
1413 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
1417 r = guestfs_umount_all (g);
1424 r = guestfs_lvm_remove_all (g);
1435 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1442 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1449 r = guestfs_mount (g, "/dev/sda1", "/");
1453 /* TestOutputStruct for lstat (0) */
1457 r = guestfs_touch (g, "/new");
1462 struct guestfs_stat *r;
1464 r = guestfs_lstat (g, "/new");
1468 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
1477 static int test_stat_0 (void)
1479 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
1483 r = guestfs_umount_all (g);
1490 r = guestfs_lvm_remove_all (g);
1501 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1508 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1515 r = guestfs_mount (g, "/dev/sda1", "/");
1519 /* TestOutputStruct for stat (0) */
1523 r = guestfs_touch (g, "/new");
1528 struct guestfs_stat *r;
1530 r = guestfs_stat (g, "/new");
1534 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
1543 static int test_file_0 (void)
1545 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
1549 r = guestfs_umount_all (g);
1556 r = guestfs_lvm_remove_all (g);
1567 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1574 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1581 r = guestfs_mount (g, "/dev/sda1", "/");
1585 /* TestOutput for file (0) */
1589 r = guestfs_touch (g, "/new");
1596 r = guestfs_file (g, "/new");
1599 if (strcmp (r, "empty") != 0) {
1600 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
1608 static int test_file_1 (void)
1610 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
1614 r = guestfs_umount_all (g);
1621 r = guestfs_lvm_remove_all (g);
1632 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1639 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1646 r = guestfs_mount (g, "/dev/sda1", "/");
1650 /* TestOutput for file (1) */
1654 r = guestfs_write_file (g, "/new", "some content\n", 0);
1661 r = guestfs_file (g, "/new");
1664 if (strcmp (r, "ASCII text") != 0) {
1665 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
1673 static int test_file_2 (void)
1675 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
1679 r = guestfs_umount_all (g);
1686 r = guestfs_lvm_remove_all (g);
1697 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1704 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1711 r = guestfs_mount (g, "/dev/sda1", "/");
1715 /* TestLastFail for file (2) */
1719 r = guestfs_file (g, "/nofile");
1727 static int test_umount_all_0 (void)
1729 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
1733 r = guestfs_umount_all (g);
1740 r = guestfs_lvm_remove_all (g);
1751 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1758 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1765 r = guestfs_mount (g, "/dev/sda1", "/");
1769 /* TestOutputList for umount_all (0) */
1773 r = guestfs_umount_all (g);
1781 r = guestfs_mounts (g);
1785 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
1789 for (i = 0; r[i] != NULL; ++i)
1796 static int test_mounts_0 (void)
1798 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
1802 r = guestfs_umount_all (g);
1809 r = guestfs_lvm_remove_all (g);
1820 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1827 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1834 r = guestfs_mount (g, "/dev/sda1", "/");
1838 /* TestOutputList for mounts (0) */
1843 r = guestfs_mounts (g);
1847 fprintf (stderr, "test_mounts_0: short list returned from command\n");
1851 if (strcmp (r[0], "/dev/sda1") != 0) {
1852 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1856 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
1860 for (i = 0; r[i] != NULL; ++i)
1867 static int test_umount_0 (void)
1869 /* InitEmpty for umount (0) */
1873 r = guestfs_umount_all (g);
1880 r = guestfs_lvm_remove_all (g);
1884 /* TestOutputList for umount (0) */
1892 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1899 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1906 r = guestfs_mount (g, "/dev/sda1", "/");
1914 r = guestfs_mounts (g);
1918 fprintf (stderr, "test_umount_0: short list returned from command\n");
1922 if (strcmp (r[0], "/dev/sda1") != 0) {
1923 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1927 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
1931 for (i = 0; r[i] != NULL; ++i)
1938 static int test_umount_1 (void)
1940 /* InitEmpty for umount (1) */
1944 r = guestfs_umount_all (g);
1951 r = guestfs_lvm_remove_all (g);
1955 /* TestOutputList for umount (1) */
1963 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1970 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1977 r = guestfs_mount (g, "/dev/sda1", "/");
1984 r = guestfs_umount (g, "/");
1992 r = guestfs_mounts (g);
1996 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
2000 for (i = 0; r[i] != NULL; ++i)
2007 static int test_write_file_0 (void)
2009 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
2013 r = guestfs_umount_all (g);
2020 r = guestfs_lvm_remove_all (g);
2031 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2038 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2045 r = guestfs_mount (g, "/dev/sda1", "/");
2049 /* TestOutput for write_file (0) */
2053 r = guestfs_write_file (g, "/new", "new file contents", 0);
2060 r = guestfs_cat (g, "/new");
2063 if (strcmp (r, "new file contents") != 0) {
2064 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
2072 static int test_write_file_1 (void)
2074 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
2078 r = guestfs_umount_all (g);
2085 r = guestfs_lvm_remove_all (g);
2096 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2103 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2110 r = guestfs_mount (g, "/dev/sda1", "/");
2114 /* TestOutput for write_file (1) */
2118 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
2125 r = guestfs_cat (g, "/new");
2128 if (strcmp (r, "\nnew file contents\n") != 0) {
2129 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
2137 static int test_write_file_2 (void)
2139 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
2143 r = guestfs_umount_all (g);
2150 r = guestfs_lvm_remove_all (g);
2161 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2168 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2175 r = guestfs_mount (g, "/dev/sda1", "/");
2179 /* TestOutput for write_file (2) */
2183 r = guestfs_write_file (g, "/new", "\n\n", 0);
2190 r = guestfs_cat (g, "/new");
2193 if (strcmp (r, "\n\n") != 0) {
2194 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
2202 static int test_write_file_3 (void)
2204 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
2208 r = guestfs_umount_all (g);
2215 r = guestfs_lvm_remove_all (g);
2226 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2233 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2240 r = guestfs_mount (g, "/dev/sda1", "/");
2244 /* TestOutput for write_file (3) */
2248 r = guestfs_write_file (g, "/new", "", 0);
2255 r = guestfs_cat (g, "/new");
2258 if (strcmp (r, "") != 0) {
2259 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
2267 static int test_write_file_4 (void)
2269 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
2273 r = guestfs_umount_all (g);
2280 r = guestfs_lvm_remove_all (g);
2291 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2298 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2305 r = guestfs_mount (g, "/dev/sda1", "/");
2309 /* TestOutput for write_file (4) */
2313 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
2320 r = guestfs_cat (g, "/new");
2323 if (strcmp (r, "\n\n\n") != 0) {
2324 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
2332 static int test_write_file_5 (void)
2334 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
2338 r = guestfs_umount_all (g);
2345 r = guestfs_lvm_remove_all (g);
2356 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2363 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2370 r = guestfs_mount (g, "/dev/sda1", "/");
2374 /* TestOutput for write_file (5) */
2378 r = guestfs_write_file (g, "/new", "\n", 0);
2385 r = guestfs_cat (g, "/new");
2388 if (strcmp (r, "\n") != 0) {
2389 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
2397 static int test_mkfs_0 (void)
2399 /* InitEmpty for mkfs (0) */
2403 r = guestfs_umount_all (g);
2410 r = guestfs_lvm_remove_all (g);
2414 /* TestOutput for mkfs (0) */
2422 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2429 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2436 r = guestfs_mount (g, "/dev/sda1", "/");
2443 r = guestfs_write_file (g, "/new", "new file contents", 0);
2450 r = guestfs_cat (g, "/new");
2453 if (strcmp (r, "new file contents") != 0) {
2454 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
2462 static int test_lvcreate_0 (void)
2464 /* InitEmpty for lvcreate (0) */
2468 r = guestfs_umount_all (g);
2475 r = guestfs_lvm_remove_all (g);
2479 /* TestOutputList for lvcreate (0) */
2489 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2496 r = guestfs_pvcreate (g, "/dev/sda1");
2503 r = guestfs_pvcreate (g, "/dev/sda2");
2510 r = guestfs_pvcreate (g, "/dev/sda3");
2515 char *physvols[] = {
2522 r = guestfs_vgcreate (g, "VG1", physvols);
2527 char *physvols[] = {
2533 r = guestfs_vgcreate (g, "VG2", physvols);
2540 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2547 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2554 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2561 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2568 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2576 r = guestfs_lvs (g);
2580 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2584 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2585 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2589 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2593 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2594 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2598 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2602 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2603 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2607 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2611 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2612 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2616 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2620 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2621 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2625 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2629 for (i = 0; r[i] != NULL; ++i)
2636 static int test_vgcreate_0 (void)
2638 /* InitEmpty for vgcreate (0) */
2642 r = guestfs_umount_all (g);
2649 r = guestfs_lvm_remove_all (g);
2653 /* TestOutputList for vgcreate (0) */
2663 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2670 r = guestfs_pvcreate (g, "/dev/sda1");
2677 r = guestfs_pvcreate (g, "/dev/sda2");
2684 r = guestfs_pvcreate (g, "/dev/sda3");
2689 char *physvols[] = {
2696 r = guestfs_vgcreate (g, "VG1", physvols);
2701 char *physvols[] = {
2707 r = guestfs_vgcreate (g, "VG2", physvols);
2715 r = guestfs_vgs (g);
2719 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2723 if (strcmp (r[0], "VG1") != 0) {
2724 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2728 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2732 if (strcmp (r[1], "VG2") != 0) {
2733 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2737 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2741 for (i = 0; r[i] != NULL; ++i)
2748 static int test_pvcreate_0 (void)
2750 /* InitEmpty for pvcreate (0) */
2754 r = guestfs_umount_all (g);
2761 r = guestfs_lvm_remove_all (g);
2765 /* TestOutputList for pvcreate (0) */
2775 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2782 r = guestfs_pvcreate (g, "/dev/sda1");
2789 r = guestfs_pvcreate (g, "/dev/sda2");
2796 r = guestfs_pvcreate (g, "/dev/sda3");
2804 r = guestfs_pvs (g);
2808 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2812 if (strcmp (r[0], "/dev/sda1") != 0) {
2813 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2817 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2821 if (strcmp (r[1], "/dev/sda2") != 0) {
2822 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2826 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2830 if (strcmp (r[2], "/dev/sda3") != 0) {
2831 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2835 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2839 for (i = 0; r[i] != NULL; ++i)
2846 static int test_is_dir_0 (void)
2848 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2852 r = guestfs_umount_all (g);
2859 r = guestfs_lvm_remove_all (g);
2870 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2877 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2884 r = guestfs_mount (g, "/dev/sda1", "/");
2888 /* TestOutputFalse for is_dir (0) */
2892 r = guestfs_touch (g, "/new");
2899 r = guestfs_is_dir (g, "/new");
2903 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2910 static int test_is_dir_1 (void)
2912 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2916 r = guestfs_umount_all (g);
2923 r = guestfs_lvm_remove_all (g);
2934 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2941 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2948 r = guestfs_mount (g, "/dev/sda1", "/");
2952 /* TestOutputTrue for is_dir (1) */
2956 r = guestfs_mkdir (g, "/new");
2963 r = guestfs_is_dir (g, "/new");
2967 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2974 static int test_is_file_0 (void)
2976 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2980 r = guestfs_umount_all (g);
2987 r = guestfs_lvm_remove_all (g);
2998 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3005 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3012 r = guestfs_mount (g, "/dev/sda1", "/");
3016 /* TestOutputTrue for is_file (0) */
3020 r = guestfs_touch (g, "/new");
3027 r = guestfs_is_file (g, "/new");
3031 fprintf (stderr, "test_is_file_0: expected true, got false\n");
3038 static int test_is_file_1 (void)
3040 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
3044 r = guestfs_umount_all (g);
3051 r = guestfs_lvm_remove_all (g);
3062 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3069 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3076 r = guestfs_mount (g, "/dev/sda1", "/");
3080 /* TestOutputFalse for is_file (1) */
3084 r = guestfs_mkdir (g, "/new");
3091 r = guestfs_is_file (g, "/new");
3095 fprintf (stderr, "test_is_file_1: expected false, got true\n");
3102 static int test_exists_0 (void)
3104 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
3108 r = guestfs_umount_all (g);
3115 r = guestfs_lvm_remove_all (g);
3126 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3133 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3140 r = guestfs_mount (g, "/dev/sda1", "/");
3144 /* TestOutputTrue for exists (0) */
3148 r = guestfs_touch (g, "/new");
3155 r = guestfs_exists (g, "/new");
3159 fprintf (stderr, "test_exists_0: expected true, got false\n");
3166 static int test_exists_1 (void)
3168 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
3172 r = guestfs_umount_all (g);
3179 r = guestfs_lvm_remove_all (g);
3190 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3197 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3204 r = guestfs_mount (g, "/dev/sda1", "/");
3208 /* TestOutputTrue for exists (1) */
3212 r = guestfs_mkdir (g, "/new");
3219 r = guestfs_exists (g, "/new");
3223 fprintf (stderr, "test_exists_1: expected true, got false\n");
3230 static int test_mkdir_p_0 (void)
3232 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
3236 r = guestfs_umount_all (g);
3243 r = guestfs_lvm_remove_all (g);
3254 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3261 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3268 r = guestfs_mount (g, "/dev/sda1", "/");
3272 /* TestOutputTrue for mkdir_p (0) */
3276 r = guestfs_mkdir_p (g, "/new/foo/bar");
3283 r = guestfs_is_dir (g, "/new/foo/bar");
3287 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
3294 static int test_mkdir_p_1 (void)
3296 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
3300 r = guestfs_umount_all (g);
3307 r = guestfs_lvm_remove_all (g);
3318 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3325 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3332 r = guestfs_mount (g, "/dev/sda1", "/");
3336 /* TestOutputTrue for mkdir_p (1) */
3340 r = guestfs_mkdir_p (g, "/new/foo/bar");
3347 r = guestfs_is_dir (g, "/new/foo");
3351 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
3358 static int test_mkdir_p_2 (void)
3360 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
3364 r = guestfs_umount_all (g);
3371 r = guestfs_lvm_remove_all (g);
3382 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3389 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3396 r = guestfs_mount (g, "/dev/sda1", "/");
3400 /* TestOutputTrue for mkdir_p (2) */
3404 r = guestfs_mkdir_p (g, "/new/foo/bar");
3411 r = guestfs_is_dir (g, "/new");
3415 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
3422 static int test_mkdir_0 (void)
3424 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
3428 r = guestfs_umount_all (g);
3435 r = guestfs_lvm_remove_all (g);
3446 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3453 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3460 r = guestfs_mount (g, "/dev/sda1", "/");
3464 /* TestOutputTrue for mkdir (0) */
3468 r = guestfs_mkdir (g, "/new");
3475 r = guestfs_is_dir (g, "/new");
3479 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
3486 static int test_mkdir_1 (void)
3488 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
3492 r = guestfs_umount_all (g);
3499 r = guestfs_lvm_remove_all (g);
3510 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3517 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3524 r = guestfs_mount (g, "/dev/sda1", "/");
3528 /* TestLastFail for mkdir (1) */
3532 r = guestfs_mkdir (g, "/new/foo/bar");
3539 static int test_rm_rf_0 (void)
3541 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
3545 r = guestfs_umount_all (g);
3552 r = guestfs_lvm_remove_all (g);
3563 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3570 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3577 r = guestfs_mount (g, "/dev/sda1", "/");
3581 /* TestOutputFalse for rm_rf (0) */
3585 r = guestfs_mkdir (g, "/new");
3592 r = guestfs_mkdir (g, "/new/foo");
3599 r = guestfs_touch (g, "/new/foo/bar");
3606 r = guestfs_rm_rf (g, "/new");
3613 r = guestfs_exists (g, "/new");
3617 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
3624 static int test_rmdir_0 (void)
3626 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
3630 r = guestfs_umount_all (g);
3637 r = guestfs_lvm_remove_all (g);
3648 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3655 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3662 r = guestfs_mount (g, "/dev/sda1", "/");
3666 /* TestRun for rmdir (0) */
3670 r = guestfs_mkdir (g, "/new");
3677 r = guestfs_rmdir (g, "/new");
3684 static int test_rmdir_1 (void)
3686 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
3690 r = guestfs_umount_all (g);
3697 r = guestfs_lvm_remove_all (g);
3708 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3715 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3722 r = guestfs_mount (g, "/dev/sda1", "/");
3726 /* TestLastFail for rmdir (1) */
3730 r = guestfs_rmdir (g, "/new");
3737 static int test_rmdir_2 (void)
3739 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
3743 r = guestfs_umount_all (g);
3750 r = guestfs_lvm_remove_all (g);
3761 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3768 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3775 r = guestfs_mount (g, "/dev/sda1", "/");
3779 /* TestLastFail for rmdir (2) */
3783 r = guestfs_touch (g, "/new");
3790 r = guestfs_rmdir (g, "/new");
3797 static int test_rm_0 (void)
3799 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
3803 r = guestfs_umount_all (g);
3810 r = guestfs_lvm_remove_all (g);
3821 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3828 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3835 r = guestfs_mount (g, "/dev/sda1", "/");
3839 /* TestRun for rm (0) */
3843 r = guestfs_touch (g, "/new");
3850 r = guestfs_rm (g, "/new");
3857 static int test_rm_1 (void)
3859 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
3863 r = guestfs_umount_all (g);
3870 r = guestfs_lvm_remove_all (g);
3881 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3888 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3895 r = guestfs_mount (g, "/dev/sda1", "/");
3899 /* TestLastFail for rm (1) */
3903 r = guestfs_rm (g, "/new");
3910 static int test_rm_2 (void)
3912 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
3916 r = guestfs_umount_all (g);
3923 r = guestfs_lvm_remove_all (g);
3934 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3941 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3948 r = guestfs_mount (g, "/dev/sda1", "/");
3952 /* TestLastFail for rm (2) */
3956 r = guestfs_mkdir (g, "/new");
3963 r = guestfs_rm (g, "/new");
3970 static int test_read_lines_0 (void)
3972 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3976 r = guestfs_umount_all (g);
3983 r = guestfs_lvm_remove_all (g);
3994 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4001 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4008 r = guestfs_mount (g, "/dev/sda1", "/");
4012 /* TestOutputList for read_lines (0) */
4016 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
4024 r = guestfs_read_lines (g, "/new");
4028 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4032 if (strcmp (r[0], "line1") != 0) {
4033 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
4037 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4041 if (strcmp (r[1], "line2") != 0) {
4042 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
4046 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4050 if (strcmp (r[2], "line3") != 0) {
4051 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
4055 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
4059 for (i = 0; r[i] != NULL; ++i)
4066 static int test_read_lines_1 (void)
4068 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
4072 r = guestfs_umount_all (g);
4079 r = guestfs_lvm_remove_all (g);
4090 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4097 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4104 r = guestfs_mount (g, "/dev/sda1", "/");
4108 /* TestOutputList for read_lines (1) */
4112 r = guestfs_write_file (g, "/new", "", 0);
4120 r = guestfs_read_lines (g, "/new");
4124 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
4128 for (i = 0; r[i] != NULL; ++i)
4135 static int test_lvs_0 (void)
4137 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
4141 r = guestfs_umount_all (g);
4148 r = guestfs_lvm_remove_all (g);
4159 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4166 r = guestfs_pvcreate (g, "/dev/sda1");
4171 char *physvols[] = {
4177 r = guestfs_vgcreate (g, "VG", physvols);
4184 r = guestfs_lvcreate (g, "LV", "VG", 8);
4191 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4198 r = guestfs_mount (g, "/dev/VG/LV", "/");
4202 /* TestOutputList for lvs (0) */
4207 r = guestfs_lvs (g);
4211 fprintf (stderr, "test_lvs_0: short list returned from command\n");
4215 if (strcmp (r[0], "/dev/VG/LV") != 0) {
4216 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
4220 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
4224 for (i = 0; r[i] != NULL; ++i)
4231 static int test_lvs_1 (void)
4233 /* InitEmpty for lvs (1) */
4237 r = guestfs_umount_all (g);
4244 r = guestfs_lvm_remove_all (g);
4248 /* TestOutputList for lvs (1) */
4258 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4265 r = guestfs_pvcreate (g, "/dev/sda1");
4272 r = guestfs_pvcreate (g, "/dev/sda2");
4279 r = guestfs_pvcreate (g, "/dev/sda3");
4284 char *physvols[] = {
4291 r = guestfs_vgcreate (g, "VG1", physvols);
4296 char *physvols[] = {
4302 r = guestfs_vgcreate (g, "VG2", physvols);
4309 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4316 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4323 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4331 r = guestfs_lvs (g);
4335 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4339 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4340 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4344 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4348 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4349 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4353 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4357 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4358 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4362 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
4366 for (i = 0; r[i] != NULL; ++i)
4373 static int test_vgs_0 (void)
4375 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
4379 r = guestfs_umount_all (g);
4386 r = guestfs_lvm_remove_all (g);
4397 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4404 r = guestfs_pvcreate (g, "/dev/sda1");
4409 char *physvols[] = {
4415 r = guestfs_vgcreate (g, "VG", physvols);
4422 r = guestfs_lvcreate (g, "LV", "VG", 8);
4429 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4436 r = guestfs_mount (g, "/dev/VG/LV", "/");
4440 /* TestOutputList for vgs (0) */
4445 r = guestfs_vgs (g);
4449 fprintf (stderr, "test_vgs_0: short list returned from command\n");
4453 if (strcmp (r[0], "VG") != 0) {
4454 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
4458 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
4462 for (i = 0; r[i] != NULL; ++i)
4469 static int test_vgs_1 (void)
4471 /* InitEmpty for vgs (1) */
4475 r = guestfs_umount_all (g);
4482 r = guestfs_lvm_remove_all (g);
4486 /* TestOutputList for vgs (1) */
4496 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4503 r = guestfs_pvcreate (g, "/dev/sda1");
4510 r = guestfs_pvcreate (g, "/dev/sda2");
4517 r = guestfs_pvcreate (g, "/dev/sda3");
4522 char *physvols[] = {
4529 r = guestfs_vgcreate (g, "VG1", physvols);
4534 char *physvols[] = {
4540 r = guestfs_vgcreate (g, "VG2", physvols);
4548 r = guestfs_vgs (g);
4552 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4556 if (strcmp (r[0], "VG1") != 0) {
4557 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
4561 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4565 if (strcmp (r[1], "VG2") != 0) {
4566 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
4570 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
4574 for (i = 0; r[i] != NULL; ++i)
4581 static int test_pvs_0 (void)
4583 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
4587 r = guestfs_umount_all (g);
4594 r = guestfs_lvm_remove_all (g);
4605 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4612 r = guestfs_pvcreate (g, "/dev/sda1");
4617 char *physvols[] = {
4623 r = guestfs_vgcreate (g, "VG", physvols);
4630 r = guestfs_lvcreate (g, "LV", "VG", 8);
4637 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4644 r = guestfs_mount (g, "/dev/VG/LV", "/");
4648 /* TestOutputList for pvs (0) */
4653 r = guestfs_pvs (g);
4657 fprintf (stderr, "test_pvs_0: short list returned from command\n");
4661 if (strcmp (r[0], "/dev/sda1") != 0) {
4662 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4666 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
4670 for (i = 0; r[i] != NULL; ++i)
4677 static int test_pvs_1 (void)
4679 /* InitEmpty for pvs (1) */
4683 r = guestfs_umount_all (g);
4690 r = guestfs_lvm_remove_all (g);
4694 /* TestOutputList for pvs (1) */
4704 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4711 r = guestfs_pvcreate (g, "/dev/sda1");
4718 r = guestfs_pvcreate (g, "/dev/sda2");
4725 r = guestfs_pvcreate (g, "/dev/sda3");
4733 r = guestfs_pvs (g);
4737 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4741 if (strcmp (r[0], "/dev/sda1") != 0) {
4742 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4746 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4750 if (strcmp (r[1], "/dev/sda2") != 0) {
4751 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4755 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4759 if (strcmp (r[2], "/dev/sda3") != 0) {
4760 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4764 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
4768 for (i = 0; r[i] != NULL; ++i)
4775 static int test_list_partitions_0 (void)
4777 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
4781 r = guestfs_umount_all (g);
4788 r = guestfs_lvm_remove_all (g);
4799 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4806 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4813 r = guestfs_mount (g, "/dev/sda1", "/");
4817 /* TestOutputList for list_partitions (0) */
4822 r = guestfs_list_partitions (g);
4826 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
4830 if (strcmp (r[0], "/dev/sda1") != 0) {
4831 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4835 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
4839 for (i = 0; r[i] != NULL; ++i)
4846 static int test_list_partitions_1 (void)
4848 /* InitEmpty for list_partitions (1) */
4852 r = guestfs_umount_all (g);
4859 r = guestfs_lvm_remove_all (g);
4863 /* TestOutputList for list_partitions (1) */
4873 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4881 r = guestfs_list_partitions (g);
4885 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4889 if (strcmp (r[0], "/dev/sda1") != 0) {
4890 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4894 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4898 if (strcmp (r[1], "/dev/sda2") != 0) {
4899 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4903 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4907 if (strcmp (r[2], "/dev/sda3") != 0) {
4908 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4912 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
4916 for (i = 0; r[i] != NULL; ++i)
4923 static int test_list_devices_0 (void)
4925 /* InitEmpty for list_devices (0) */
4929 r = guestfs_umount_all (g);
4936 r = guestfs_lvm_remove_all (g);
4940 /* TestOutputList for list_devices (0) */
4945 r = guestfs_list_devices (g);
4949 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4953 if (strcmp (r[0], "/dev/sda") != 0) {
4954 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4958 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4962 if (strcmp (r[1], "/dev/sdb") != 0) {
4963 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4967 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4971 if (strcmp (r[2], "/dev/sdc") != 0) {
4972 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4976 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4980 for (i = 0; r[i] != NULL; ++i)
4987 static int test_ls_0 (void)
4989 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4993 r = guestfs_umount_all (g);
5000 r = guestfs_lvm_remove_all (g);
5011 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5018 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5025 r = guestfs_mount (g, "/dev/sda1", "/");
5029 /* TestOutputList for ls (0) */
5033 r = guestfs_touch (g, "/new");
5040 r = guestfs_touch (g, "/newer");
5047 r = guestfs_touch (g, "/newest");
5055 r = guestfs_ls (g, "/");
5059 fprintf (stderr, "test_ls_0: short list returned from command\n");
5063 if (strcmp (r[0], "lost+found") != 0) {
5064 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
5068 fprintf (stderr, "test_ls_0: short list returned from command\n");
5072 if (strcmp (r[1], "new") != 0) {
5073 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
5077 fprintf (stderr, "test_ls_0: short list returned from command\n");
5081 if (strcmp (r[2], "newer") != 0) {
5082 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
5086 fprintf (stderr, "test_ls_0: short list returned from command\n");
5090 if (strcmp (r[3], "newest") != 0) {
5091 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
5095 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
5099 for (i = 0; r[i] != NULL; ++i)
5106 static int test_cat_0 (void)
5108 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
5112 r = guestfs_umount_all (g);
5119 r = guestfs_lvm_remove_all (g);
5130 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5137 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5144 r = guestfs_mount (g, "/dev/sda1", "/");
5148 /* TestOutput for cat (0) */
5152 r = guestfs_write_file (g, "/new", "new file contents", 0);
5159 r = guestfs_cat (g, "/new");
5162 if (strcmp (r, "new file contents") != 0) {
5163 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
5171 static int test_touch_0 (void)
5173 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
5177 r = guestfs_umount_all (g);
5184 r = guestfs_lvm_remove_all (g);
5195 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5202 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5209 r = guestfs_mount (g, "/dev/sda1", "/");
5213 /* TestOutputTrue for touch (0) */
5217 r = guestfs_touch (g, "/new");
5224 r = guestfs_exists (g, "/new");
5228 fprintf (stderr, "test_touch_0: expected true, got false\n");
5235 static int test_sync_0 (void)
5237 /* InitEmpty for sync (0) */
5241 r = guestfs_umount_all (g);
5248 r = guestfs_lvm_remove_all (g);
5252 /* TestRun for sync (0) */
5256 r = guestfs_sync (g);
5263 static int test_mount_0 (void)
5265 /* InitEmpty for mount (0) */
5269 r = guestfs_umount_all (g);
5276 r = guestfs_lvm_remove_all (g);
5280 /* TestOutput for mount (0) */
5288 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5295 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5302 r = guestfs_mount (g, "/dev/sda1", "/");
5309 r = guestfs_write_file (g, "/new", "new file contents", 0);
5316 r = guestfs_cat (g, "/new");
5319 if (strcmp (r, "new file contents") != 0) {
5320 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
5328 int main (int argc, char *argv[])
5333 const char *filename;
5335 int nr_tests, test_num = 0;
5337 no_test_warnings ();
5339 g = guestfs_create ();
5341 printf ("guestfs_create FAILED\n");
5345 guestfs_set_error_handler (g, print_error, NULL);
5347 srcdir = getenv ("srcdir");
5348 if (!srcdir) srcdir = ".";
5350 guestfs_set_path (g, ".");
5352 filename = "test1.img";
5353 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5358 if (lseek (fd, 524288000, SEEK_SET) == -1) {
5364 if (write (fd, &c, 1) == -1) {
5370 if (close (fd) == -1) {
5375 if (guestfs_add_drive (g, filename) == -1) {
5376 printf ("guestfs_add_drive %s FAILED\n", filename);
5380 filename = "test2.img";
5381 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5386 if (lseek (fd, 52428800, SEEK_SET) == -1) {
5392 if (write (fd, &c, 1) == -1) {
5398 if (close (fd) == -1) {
5403 if (guestfs_add_drive (g, filename) == -1) {
5404 printf ("guestfs_add_drive %s FAILED\n", filename);
5408 filename = "test3.img";
5409 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5414 if (lseek (fd, 10485760, SEEK_SET) == -1) {
5420 if (write (fd, &c, 1) == -1) {
5426 if (close (fd) == -1) {
5431 if (guestfs_add_drive (g, filename) == -1) {
5432 printf ("guestfs_add_drive %s FAILED\n", filename);
5436 if (guestfs_launch (g) == -1) {
5437 printf ("guestfs_launch FAILED\n");
5440 if (guestfs_wait_ready (g) == -1) {
5441 printf ("guestfs_wait_ready FAILED\n");
5448 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
5449 if (test_mount_ro_0 () == -1) {
5450 printf ("test_mount_ro_0 FAILED\n");
5454 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
5455 if (test_mount_ro_1 () == -1) {
5456 printf ("test_mount_ro_1 FAILED\n");
5460 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
5461 if (test_tgz_in_0 () == -1) {
5462 printf ("test_tgz_in_0 FAILED\n");
5466 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
5467 if (test_tar_in_0 () == -1) {
5468 printf ("test_tar_in_0 FAILED\n");
5472 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
5473 if (test_checksum_0 () == -1) {
5474 printf ("test_checksum_0 FAILED\n");
5478 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
5479 if (test_checksum_1 () == -1) {
5480 printf ("test_checksum_1 FAILED\n");
5484 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
5485 if (test_checksum_2 () == -1) {
5486 printf ("test_checksum_2 FAILED\n");
5490 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
5491 if (test_checksum_3 () == -1) {
5492 printf ("test_checksum_3 FAILED\n");
5496 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
5497 if (test_checksum_4 () == -1) {
5498 printf ("test_checksum_4 FAILED\n");
5502 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
5503 if (test_checksum_5 () == -1) {
5504 printf ("test_checksum_5 FAILED\n");
5508 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
5509 if (test_checksum_6 () == -1) {
5510 printf ("test_checksum_6 FAILED\n");
5514 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
5515 if (test_checksum_7 () == -1) {
5516 printf ("test_checksum_7 FAILED\n");
5520 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
5521 if (test_download_0 () == -1) {
5522 printf ("test_download_0 FAILED\n");
5526 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
5527 if (test_upload_0 () == -1) {
5528 printf ("test_upload_0 FAILED\n");
5532 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
5533 if (test_blockdev_rereadpt_0 () == -1) {
5534 printf ("test_blockdev_rereadpt_0 FAILED\n");
5538 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
5539 if (test_blockdev_flushbufs_0 () == -1) {
5540 printf ("test_blockdev_flushbufs_0 FAILED\n");
5544 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
5545 if (test_blockdev_getsize64_0 () == -1) {
5546 printf ("test_blockdev_getsize64_0 FAILED\n");
5550 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
5551 if (test_blockdev_getsz_0 () == -1) {
5552 printf ("test_blockdev_getsz_0 FAILED\n");
5556 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
5557 if (test_blockdev_getbsz_0 () == -1) {
5558 printf ("test_blockdev_getbsz_0 FAILED\n");
5562 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
5563 if (test_blockdev_getss_0 () == -1) {
5564 printf ("test_blockdev_getss_0 FAILED\n");
5568 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
5569 if (test_blockdev_getro_0 () == -1) {
5570 printf ("test_blockdev_getro_0 FAILED\n");
5574 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
5575 if (test_blockdev_setrw_0 () == -1) {
5576 printf ("test_blockdev_setrw_0 FAILED\n");
5580 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
5581 if (test_blockdev_setro_0 () == -1) {
5582 printf ("test_blockdev_setro_0 FAILED\n");
5586 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
5587 if (test_statvfs_0 () == -1) {
5588 printf ("test_statvfs_0 FAILED\n");
5592 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
5593 if (test_lstat_0 () == -1) {
5594 printf ("test_lstat_0 FAILED\n");
5598 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
5599 if (test_stat_0 () == -1) {
5600 printf ("test_stat_0 FAILED\n");
5604 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
5605 if (test_file_0 () == -1) {
5606 printf ("test_file_0 FAILED\n");
5610 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
5611 if (test_file_1 () == -1) {
5612 printf ("test_file_1 FAILED\n");
5616 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
5617 if (test_file_2 () == -1) {
5618 printf ("test_file_2 FAILED\n");
5622 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
5623 if (test_umount_all_0 () == -1) {
5624 printf ("test_umount_all_0 FAILED\n");
5628 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
5629 if (test_mounts_0 () == -1) {
5630 printf ("test_mounts_0 FAILED\n");
5634 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
5635 if (test_umount_0 () == -1) {
5636 printf ("test_umount_0 FAILED\n");
5640 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
5641 if (test_umount_1 () == -1) {
5642 printf ("test_umount_1 FAILED\n");
5646 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
5647 if (test_write_file_0 () == -1) {
5648 printf ("test_write_file_0 FAILED\n");
5652 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
5653 if (test_write_file_1 () == -1) {
5654 printf ("test_write_file_1 FAILED\n");
5658 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
5659 if (test_write_file_2 () == -1) {
5660 printf ("test_write_file_2 FAILED\n");
5664 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
5665 if (test_write_file_3 () == -1) {
5666 printf ("test_write_file_3 FAILED\n");
5670 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
5671 if (test_write_file_4 () == -1) {
5672 printf ("test_write_file_4 FAILED\n");
5676 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
5677 if (test_write_file_5 () == -1) {
5678 printf ("test_write_file_5 FAILED\n");
5682 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
5683 if (test_mkfs_0 () == -1) {
5684 printf ("test_mkfs_0 FAILED\n");
5688 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
5689 if (test_lvcreate_0 () == -1) {
5690 printf ("test_lvcreate_0 FAILED\n");
5694 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
5695 if (test_vgcreate_0 () == -1) {
5696 printf ("test_vgcreate_0 FAILED\n");
5700 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
5701 if (test_pvcreate_0 () == -1) {
5702 printf ("test_pvcreate_0 FAILED\n");
5706 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
5707 if (test_is_dir_0 () == -1) {
5708 printf ("test_is_dir_0 FAILED\n");
5712 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
5713 if (test_is_dir_1 () == -1) {
5714 printf ("test_is_dir_1 FAILED\n");
5718 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
5719 if (test_is_file_0 () == -1) {
5720 printf ("test_is_file_0 FAILED\n");
5724 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
5725 if (test_is_file_1 () == -1) {
5726 printf ("test_is_file_1 FAILED\n");
5730 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
5731 if (test_exists_0 () == -1) {
5732 printf ("test_exists_0 FAILED\n");
5736 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
5737 if (test_exists_1 () == -1) {
5738 printf ("test_exists_1 FAILED\n");
5742 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
5743 if (test_mkdir_p_0 () == -1) {
5744 printf ("test_mkdir_p_0 FAILED\n");
5748 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
5749 if (test_mkdir_p_1 () == -1) {
5750 printf ("test_mkdir_p_1 FAILED\n");
5754 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
5755 if (test_mkdir_p_2 () == -1) {
5756 printf ("test_mkdir_p_2 FAILED\n");
5760 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
5761 if (test_mkdir_0 () == -1) {
5762 printf ("test_mkdir_0 FAILED\n");
5766 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
5767 if (test_mkdir_1 () == -1) {
5768 printf ("test_mkdir_1 FAILED\n");
5772 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
5773 if (test_rm_rf_0 () == -1) {
5774 printf ("test_rm_rf_0 FAILED\n");
5778 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
5779 if (test_rmdir_0 () == -1) {
5780 printf ("test_rmdir_0 FAILED\n");
5784 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
5785 if (test_rmdir_1 () == -1) {
5786 printf ("test_rmdir_1 FAILED\n");
5790 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
5791 if (test_rmdir_2 () == -1) {
5792 printf ("test_rmdir_2 FAILED\n");
5796 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
5797 if (test_rm_0 () == -1) {
5798 printf ("test_rm_0 FAILED\n");
5802 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
5803 if (test_rm_1 () == -1) {
5804 printf ("test_rm_1 FAILED\n");
5808 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
5809 if (test_rm_2 () == -1) {
5810 printf ("test_rm_2 FAILED\n");
5814 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
5815 if (test_read_lines_0 () == -1) {
5816 printf ("test_read_lines_0 FAILED\n");
5820 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
5821 if (test_read_lines_1 () == -1) {
5822 printf ("test_read_lines_1 FAILED\n");
5826 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
5827 if (test_lvs_0 () == -1) {
5828 printf ("test_lvs_0 FAILED\n");
5832 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
5833 if (test_lvs_1 () == -1) {
5834 printf ("test_lvs_1 FAILED\n");
5838 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
5839 if (test_vgs_0 () == -1) {
5840 printf ("test_vgs_0 FAILED\n");
5844 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
5845 if (test_vgs_1 () == -1) {
5846 printf ("test_vgs_1 FAILED\n");
5850 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
5851 if (test_pvs_0 () == -1) {
5852 printf ("test_pvs_0 FAILED\n");
5856 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
5857 if (test_pvs_1 () == -1) {
5858 printf ("test_pvs_1 FAILED\n");
5862 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
5863 if (test_list_partitions_0 () == -1) {
5864 printf ("test_list_partitions_0 FAILED\n");
5868 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
5869 if (test_list_partitions_1 () == -1) {
5870 printf ("test_list_partitions_1 FAILED\n");
5874 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
5875 if (test_list_devices_0 () == -1) {
5876 printf ("test_list_devices_0 FAILED\n");
5880 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
5881 if (test_ls_0 () == -1) {
5882 printf ("test_ls_0 FAILED\n");
5886 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
5887 if (test_cat_0 () == -1) {
5888 printf ("test_cat_0 FAILED\n");
5892 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
5893 if (test_touch_0 () == -1) {
5894 printf ("test_touch_0 FAILED\n");
5898 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
5899 if (test_sync_0 () == -1) {
5900 printf ("test_sync_0 FAILED\n");
5904 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
5905 if (test_mount_0 () == -1) {
5906 printf ("test_mount_0 FAILED\n");
5911 unlink ("test1.img");
5912 unlink ("test2.img");
5913 unlink ("test3.img");
5916 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);