1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 static void print_error (guestfs_h *g, void *data, const char *msg)
37 fprintf (stderr, "%s\n", msg);
40 static void print_strings (char * const * const argv)
44 for (argc = 0; argv[argc] != NULL; ++argc)
45 printf ("\t%s\n", argv[argc]);
49 static void print_table (char * const * const argv)
53 for (i = 0; argv[i] != NULL; i += 2)
54 printf ("%s: %s\n", argv[i], argv[i+1]);
58 static void no_test_warnings (void)
60 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
61 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
62 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
63 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
64 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
65 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
113 static int test_mount_ro_0 (void)
115 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
119 r = guestfs_umount_all (g);
126 r = guestfs_lvm_remove_all (g);
137 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
144 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
151 r = guestfs_mount (g, "/dev/sda1", "/");
155 /* TestLastFail for mount_ro (0) */
159 r = guestfs_umount (g, "/");
166 r = guestfs_mount_ro (g, "/dev/sda1", "/");
173 r = guestfs_touch (g, "/new");
180 static int test_mount_ro_1 (void)
182 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
186 r = guestfs_umount_all (g);
193 r = guestfs_lvm_remove_all (g);
204 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
211 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
218 r = guestfs_mount (g, "/dev/sda1", "/");
222 /* TestOutput for mount_ro (1) */
226 r = guestfs_write_file (g, "/new", "data", 0);
233 r = guestfs_umount (g, "/");
240 r = guestfs_mount_ro (g, "/dev/sda1", "/");
247 r = guestfs_cat (g, "/new");
250 if (strcmp (r, "data") != 0) {
251 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
259 static int test_tgz_in_0 (void)
261 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
265 r = guestfs_umount_all (g);
272 r = guestfs_lvm_remove_all (g);
283 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
290 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
297 r = guestfs_mount (g, "/dev/sda1", "/");
301 /* TestOutput for tgz_in (0) */
305 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
312 r = guestfs_cat (g, "/hello");
315 if (strcmp (r, "hello\n") != 0) {
316 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
324 static int test_tar_in_0 (void)
326 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
330 r = guestfs_umount_all (g);
337 r = guestfs_lvm_remove_all (g);
348 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
355 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
362 r = guestfs_mount (g, "/dev/sda1", "/");
366 /* TestOutput for tar_in (0) */
370 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
377 r = guestfs_cat (g, "/hello");
380 if (strcmp (r, "hello\n") != 0) {
381 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
389 static int test_checksum_0 (void)
391 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
395 r = guestfs_umount_all (g);
402 r = guestfs_lvm_remove_all (g);
413 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
420 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
427 r = guestfs_mount (g, "/dev/sda1", "/");
431 /* TestOutput for checksum (0) */
435 r = guestfs_write_file (g, "/new", "test\n", 0);
442 r = guestfs_checksum (g, "crc", "/new");
445 if (strcmp (r, "935282863") != 0) {
446 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
454 static int test_checksum_1 (void)
456 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
460 r = guestfs_umount_all (g);
467 r = guestfs_lvm_remove_all (g);
478 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
485 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
492 r = guestfs_mount (g, "/dev/sda1", "/");
496 /* TestLastFail for checksum (1) */
500 r = guestfs_checksum (g, "crc", "/new");
508 static int test_checksum_2 (void)
510 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
514 r = guestfs_umount_all (g);
521 r = guestfs_lvm_remove_all (g);
532 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
539 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
546 r = guestfs_mount (g, "/dev/sda1", "/");
550 /* TestOutput for checksum (2) */
554 r = guestfs_write_file (g, "/new", "test\n", 0);
561 r = guestfs_checksum (g, "md5", "/new");
564 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
565 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
573 static int test_checksum_3 (void)
575 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
579 r = guestfs_umount_all (g);
586 r = guestfs_lvm_remove_all (g);
597 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
604 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
611 r = guestfs_mount (g, "/dev/sda1", "/");
615 /* TestOutput for checksum (3) */
619 r = guestfs_write_file (g, "/new", "test\n", 0);
626 r = guestfs_checksum (g, "sha1", "/new");
629 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
630 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
638 static int test_checksum_4 (void)
640 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
644 r = guestfs_umount_all (g);
651 r = guestfs_lvm_remove_all (g);
662 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
669 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
676 r = guestfs_mount (g, "/dev/sda1", "/");
680 /* TestOutput for checksum (4) */
684 r = guestfs_write_file (g, "/new", "test\n", 0);
691 r = guestfs_checksum (g, "sha224", "/new");
694 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
695 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
703 static int test_checksum_5 (void)
705 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
709 r = guestfs_umount_all (g);
716 r = guestfs_lvm_remove_all (g);
727 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
734 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
741 r = guestfs_mount (g, "/dev/sda1", "/");
745 /* TestOutput for checksum (5) */
749 r = guestfs_write_file (g, "/new", "test\n", 0);
756 r = guestfs_checksum (g, "sha256", "/new");
759 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
760 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
768 static int test_checksum_6 (void)
770 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
774 r = guestfs_umount_all (g);
781 r = guestfs_lvm_remove_all (g);
792 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
799 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
806 r = guestfs_mount (g, "/dev/sda1", "/");
810 /* TestOutput for checksum (6) */
814 r = guestfs_write_file (g, "/new", "test\n", 0);
821 r = guestfs_checksum (g, "sha384", "/new");
824 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
825 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
833 static int test_checksum_7 (void)
835 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
839 r = guestfs_umount_all (g);
846 r = guestfs_lvm_remove_all (g);
857 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
864 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
871 r = guestfs_mount (g, "/dev/sda1", "/");
875 /* TestOutput for checksum (7) */
879 r = guestfs_write_file (g, "/new", "test\n", 0);
886 r = guestfs_checksum (g, "sha512", "/new");
889 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
890 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
898 static int test_download_0 (void)
900 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
904 r = guestfs_umount_all (g);
911 r = guestfs_lvm_remove_all (g);
922 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
929 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
936 r = guestfs_mount (g, "/dev/sda1", "/");
940 /* TestOutput for download (0) */
944 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
951 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
958 r = guestfs_upload (g, "testdownload.tmp", "/upload");
965 r = guestfs_checksum (g, "md5", "/upload");
968 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
969 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
977 static int test_upload_0 (void)
979 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
983 r = guestfs_umount_all (g);
990 r = guestfs_lvm_remove_all (g);
1001 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1008 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1015 r = guestfs_mount (g, "/dev/sda1", "/");
1019 /* TestOutput for upload (0) */
1023 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
1030 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
1033 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
1034 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
1042 static int test_blockdev_rereadpt_0 (void)
1044 /* InitEmpty for blockdev_rereadpt (0) */
1048 r = guestfs_umount_all (g);
1055 r = guestfs_lvm_remove_all (g);
1059 /* TestRun for blockdev_rereadpt (0) */
1063 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
1070 static int test_blockdev_flushbufs_0 (void)
1072 /* InitEmpty for blockdev_flushbufs (0) */
1076 r = guestfs_umount_all (g);
1083 r = guestfs_lvm_remove_all (g);
1087 /* TestRun for blockdev_flushbufs (0) */
1091 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
1098 static int test_blockdev_getsize64_0 (void)
1100 /* InitEmpty for blockdev_getsize64 (0) */
1104 r = guestfs_umount_all (g);
1111 r = guestfs_lvm_remove_all (g);
1115 /* TestOutputInt for blockdev_getsize64 (0) */
1119 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
1122 if (r != 524288000) {
1123 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
1130 static int test_blockdev_getsz_0 (void)
1132 /* InitEmpty for blockdev_getsz (0) */
1136 r = guestfs_umount_all (g);
1143 r = guestfs_lvm_remove_all (g);
1147 /* TestOutputInt for blockdev_getsz (0) */
1151 r = guestfs_blockdev_getsz (g, "/dev/sda");
1155 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
1162 static int test_blockdev_getbsz_0 (void)
1164 /* InitEmpty for blockdev_getbsz (0) */
1168 r = guestfs_umount_all (g);
1175 r = guestfs_lvm_remove_all (g);
1179 /* TestOutputInt for blockdev_getbsz (0) */
1183 r = guestfs_blockdev_getbsz (g, "/dev/sda");
1187 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
1194 static int test_blockdev_getss_0 (void)
1196 /* InitEmpty for blockdev_getss (0) */
1200 r = guestfs_umount_all (g);
1207 r = guestfs_lvm_remove_all (g);
1211 /* TestOutputInt for blockdev_getss (0) */
1215 r = guestfs_blockdev_getss (g, "/dev/sda");
1219 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
1226 static int test_blockdev_getro_0 (void)
1228 /* InitEmpty for blockdev_getro (0) */
1232 r = guestfs_umount_all (g);
1239 r = guestfs_lvm_remove_all (g);
1243 /* TestOutputTrue for blockdev_getro (0) */
1247 r = guestfs_blockdev_setro (g, "/dev/sda");
1254 r = guestfs_blockdev_getro (g, "/dev/sda");
1258 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
1265 static int test_blockdev_setrw_0 (void)
1267 /* InitEmpty for blockdev_setrw (0) */
1271 r = guestfs_umount_all (g);
1278 r = guestfs_lvm_remove_all (g);
1282 /* TestOutputFalse for blockdev_setrw (0) */
1286 r = guestfs_blockdev_setrw (g, "/dev/sda");
1293 r = guestfs_blockdev_getro (g, "/dev/sda");
1297 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
1304 static int test_blockdev_setro_0 (void)
1306 /* InitEmpty for blockdev_setro (0) */
1310 r = guestfs_umount_all (g);
1317 r = guestfs_lvm_remove_all (g);
1321 /* TestOutputTrue for blockdev_setro (0) */
1325 r = guestfs_blockdev_setro (g, "/dev/sda");
1332 r = guestfs_blockdev_getro (g, "/dev/sda");
1336 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
1343 static int test_statvfs_0 (void)
1345 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
1349 r = guestfs_umount_all (g);
1356 r = guestfs_lvm_remove_all (g);
1367 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1374 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1381 r = guestfs_mount (g, "/dev/sda1", "/");
1385 /* TestOutputStruct for statvfs (0) */
1387 struct guestfs_statvfs *r;
1389 r = guestfs_statvfs (g, "/");
1392 if (r->bfree != 487702) {
1393 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
1397 if (r->blocks != 490020) {
1398 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
1402 if (r->bsize != 1024) {
1403 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
1412 static int test_lstat_0 (void)
1414 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
1418 r = guestfs_umount_all (g);
1425 r = guestfs_lvm_remove_all (g);
1436 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1443 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1450 r = guestfs_mount (g, "/dev/sda1", "/");
1454 /* TestOutputStruct for lstat (0) */
1458 r = guestfs_touch (g, "/new");
1463 struct guestfs_stat *r;
1465 r = guestfs_lstat (g, "/new");
1469 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
1478 static int test_stat_0 (void)
1480 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
1484 r = guestfs_umount_all (g);
1491 r = guestfs_lvm_remove_all (g);
1502 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1509 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1516 r = guestfs_mount (g, "/dev/sda1", "/");
1520 /* TestOutputStruct for stat (0) */
1524 r = guestfs_touch (g, "/new");
1529 struct guestfs_stat *r;
1531 r = guestfs_stat (g, "/new");
1535 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
1544 static int test_file_0 (void)
1546 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
1550 r = guestfs_umount_all (g);
1557 r = guestfs_lvm_remove_all (g);
1568 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1575 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1582 r = guestfs_mount (g, "/dev/sda1", "/");
1586 /* TestOutput for file (0) */
1590 r = guestfs_touch (g, "/new");
1597 r = guestfs_file (g, "/new");
1600 if (strcmp (r, "empty") != 0) {
1601 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
1609 static int test_file_1 (void)
1611 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
1615 r = guestfs_umount_all (g);
1622 r = guestfs_lvm_remove_all (g);
1633 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1640 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1647 r = guestfs_mount (g, "/dev/sda1", "/");
1651 /* TestOutput for file (1) */
1655 r = guestfs_write_file (g, "/new", "some content\n", 0);
1662 r = guestfs_file (g, "/new");
1665 if (strcmp (r, "ASCII text") != 0) {
1666 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
1674 static int test_file_2 (void)
1676 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
1680 r = guestfs_umount_all (g);
1687 r = guestfs_lvm_remove_all (g);
1698 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1705 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1712 r = guestfs_mount (g, "/dev/sda1", "/");
1716 /* TestLastFail for file (2) */
1720 r = guestfs_file (g, "/nofile");
1728 static int test_umount_all_0 (void)
1730 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
1734 r = guestfs_umount_all (g);
1741 r = guestfs_lvm_remove_all (g);
1752 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1759 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1766 r = guestfs_mount (g, "/dev/sda1", "/");
1770 /* TestOutputList for umount_all (0) */
1774 r = guestfs_umount_all (g);
1782 r = guestfs_mounts (g);
1786 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
1790 for (i = 0; r[i] != NULL; ++i)
1797 static int test_mounts_0 (void)
1799 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
1803 r = guestfs_umount_all (g);
1810 r = guestfs_lvm_remove_all (g);
1821 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1828 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1835 r = guestfs_mount (g, "/dev/sda1", "/");
1839 /* TestOutputList for mounts (0) */
1844 r = guestfs_mounts (g);
1848 fprintf (stderr, "test_mounts_0: short list returned from command\n");
1852 if (strcmp (r[0], "/dev/sda1") != 0) {
1853 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1857 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
1861 for (i = 0; r[i] != NULL; ++i)
1868 static int test_umount_0 (void)
1870 /* InitEmpty for umount (0) */
1874 r = guestfs_umount_all (g);
1881 r = guestfs_lvm_remove_all (g);
1885 /* TestOutputList for umount (0) */
1893 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1900 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1907 r = guestfs_mount (g, "/dev/sda1", "/");
1915 r = guestfs_mounts (g);
1919 fprintf (stderr, "test_umount_0: short list returned from command\n");
1923 if (strcmp (r[0], "/dev/sda1") != 0) {
1924 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1928 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
1932 for (i = 0; r[i] != NULL; ++i)
1939 static int test_umount_1 (void)
1941 /* InitEmpty for umount (1) */
1945 r = guestfs_umount_all (g);
1952 r = guestfs_lvm_remove_all (g);
1956 /* TestOutputList for umount (1) */
1964 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1971 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1978 r = guestfs_mount (g, "/dev/sda1", "/");
1985 r = guestfs_umount (g, "/");
1993 r = guestfs_mounts (g);
1997 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
2001 for (i = 0; r[i] != NULL; ++i)
2008 static int test_write_file_0 (void)
2010 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
2014 r = guestfs_umount_all (g);
2021 r = guestfs_lvm_remove_all (g);
2032 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2039 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2046 r = guestfs_mount (g, "/dev/sda1", "/");
2050 /* TestOutput for write_file (0) */
2054 r = guestfs_write_file (g, "/new", "new file contents", 0);
2061 r = guestfs_cat (g, "/new");
2064 if (strcmp (r, "new file contents") != 0) {
2065 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
2073 static int test_write_file_1 (void)
2075 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
2079 r = guestfs_umount_all (g);
2086 r = guestfs_lvm_remove_all (g);
2097 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2104 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2111 r = guestfs_mount (g, "/dev/sda1", "/");
2115 /* TestOutput for write_file (1) */
2119 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
2126 r = guestfs_cat (g, "/new");
2129 if (strcmp (r, "\nnew file contents\n") != 0) {
2130 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
2138 static int test_write_file_2 (void)
2140 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
2144 r = guestfs_umount_all (g);
2151 r = guestfs_lvm_remove_all (g);
2162 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2169 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2176 r = guestfs_mount (g, "/dev/sda1", "/");
2180 /* TestOutput for write_file (2) */
2184 r = guestfs_write_file (g, "/new", "\n\n", 0);
2191 r = guestfs_cat (g, "/new");
2194 if (strcmp (r, "\n\n") != 0) {
2195 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
2203 static int test_write_file_3 (void)
2205 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
2209 r = guestfs_umount_all (g);
2216 r = guestfs_lvm_remove_all (g);
2227 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2234 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2241 r = guestfs_mount (g, "/dev/sda1", "/");
2245 /* TestOutput for write_file (3) */
2249 r = guestfs_write_file (g, "/new", "", 0);
2256 r = guestfs_cat (g, "/new");
2259 if (strcmp (r, "") != 0) {
2260 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
2268 static int test_write_file_4 (void)
2270 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
2274 r = guestfs_umount_all (g);
2281 r = guestfs_lvm_remove_all (g);
2292 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2299 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2306 r = guestfs_mount (g, "/dev/sda1", "/");
2310 /* TestOutput for write_file (4) */
2314 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
2321 r = guestfs_cat (g, "/new");
2324 if (strcmp (r, "\n\n\n") != 0) {
2325 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
2333 static int test_write_file_5 (void)
2335 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
2339 r = guestfs_umount_all (g);
2346 r = guestfs_lvm_remove_all (g);
2357 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2364 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2371 r = guestfs_mount (g, "/dev/sda1", "/");
2375 /* TestOutput for write_file (5) */
2379 r = guestfs_write_file (g, "/new", "\n", 0);
2386 r = guestfs_cat (g, "/new");
2389 if (strcmp (r, "\n") != 0) {
2390 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
2398 static int test_mkfs_0 (void)
2400 /* InitEmpty for mkfs (0) */
2404 r = guestfs_umount_all (g);
2411 r = guestfs_lvm_remove_all (g);
2415 /* TestOutput for mkfs (0) */
2423 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2430 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2437 r = guestfs_mount (g, "/dev/sda1", "/");
2444 r = guestfs_write_file (g, "/new", "new file contents", 0);
2451 r = guestfs_cat (g, "/new");
2454 if (strcmp (r, "new file contents") != 0) {
2455 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
2463 static int test_lvcreate_0 (void)
2465 /* InitEmpty for lvcreate (0) */
2469 r = guestfs_umount_all (g);
2476 r = guestfs_lvm_remove_all (g);
2480 /* TestOutputList for lvcreate (0) */
2490 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2497 r = guestfs_pvcreate (g, "/dev/sda1");
2504 r = guestfs_pvcreate (g, "/dev/sda2");
2511 r = guestfs_pvcreate (g, "/dev/sda3");
2516 char *physvols[] = {
2523 r = guestfs_vgcreate (g, "VG1", physvols);
2528 char *physvols[] = {
2534 r = guestfs_vgcreate (g, "VG2", physvols);
2541 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2548 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2555 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2562 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2569 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2577 r = guestfs_lvs (g);
2581 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2585 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2586 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2590 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2594 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2595 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2599 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2603 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2604 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2608 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2612 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2613 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2617 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2621 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2622 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2626 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2630 for (i = 0; r[i] != NULL; ++i)
2637 static int test_vgcreate_0 (void)
2639 /* InitEmpty for vgcreate (0) */
2643 r = guestfs_umount_all (g);
2650 r = guestfs_lvm_remove_all (g);
2654 /* TestOutputList for vgcreate (0) */
2664 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2671 r = guestfs_pvcreate (g, "/dev/sda1");
2678 r = guestfs_pvcreate (g, "/dev/sda2");
2685 r = guestfs_pvcreate (g, "/dev/sda3");
2690 char *physvols[] = {
2697 r = guestfs_vgcreate (g, "VG1", physvols);
2702 char *physvols[] = {
2708 r = guestfs_vgcreate (g, "VG2", physvols);
2716 r = guestfs_vgs (g);
2720 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2724 if (strcmp (r[0], "VG1") != 0) {
2725 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2729 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2733 if (strcmp (r[1], "VG2") != 0) {
2734 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2738 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2742 for (i = 0; r[i] != NULL; ++i)
2749 static int test_pvcreate_0 (void)
2751 /* InitEmpty for pvcreate (0) */
2755 r = guestfs_umount_all (g);
2762 r = guestfs_lvm_remove_all (g);
2766 /* TestOutputList for pvcreate (0) */
2776 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2783 r = guestfs_pvcreate (g, "/dev/sda1");
2790 r = guestfs_pvcreate (g, "/dev/sda2");
2797 r = guestfs_pvcreate (g, "/dev/sda3");
2805 r = guestfs_pvs (g);
2809 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2813 if (strcmp (r[0], "/dev/sda1") != 0) {
2814 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2818 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2822 if (strcmp (r[1], "/dev/sda2") != 0) {
2823 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2827 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2831 if (strcmp (r[2], "/dev/sda3") != 0) {
2832 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2836 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2840 for (i = 0; r[i] != NULL; ++i)
2847 static int test_is_dir_0 (void)
2849 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2853 r = guestfs_umount_all (g);
2860 r = guestfs_lvm_remove_all (g);
2871 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2878 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2885 r = guestfs_mount (g, "/dev/sda1", "/");
2889 /* TestOutputFalse for is_dir (0) */
2893 r = guestfs_touch (g, "/new");
2900 r = guestfs_is_dir (g, "/new");
2904 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2911 static int test_is_dir_1 (void)
2913 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2917 r = guestfs_umount_all (g);
2924 r = guestfs_lvm_remove_all (g);
2935 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2942 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2949 r = guestfs_mount (g, "/dev/sda1", "/");
2953 /* TestOutputTrue for is_dir (1) */
2957 r = guestfs_mkdir (g, "/new");
2964 r = guestfs_is_dir (g, "/new");
2968 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2975 static int test_is_file_0 (void)
2977 /* InitBasicFS for is_file (0): 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 /* TestOutputTrue for is_file (0) */
3021 r = guestfs_touch (g, "/new");
3028 r = guestfs_is_file (g, "/new");
3032 fprintf (stderr, "test_is_file_0: expected true, got false\n");
3039 static int test_is_file_1 (void)
3041 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
3045 r = guestfs_umount_all (g);
3052 r = guestfs_lvm_remove_all (g);
3063 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3070 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3077 r = guestfs_mount (g, "/dev/sda1", "/");
3081 /* TestOutputFalse for is_file (1) */
3085 r = guestfs_mkdir (g, "/new");
3092 r = guestfs_is_file (g, "/new");
3096 fprintf (stderr, "test_is_file_1: expected false, got true\n");
3103 static int test_exists_0 (void)
3105 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
3109 r = guestfs_umount_all (g);
3116 r = guestfs_lvm_remove_all (g);
3127 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3134 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3141 r = guestfs_mount (g, "/dev/sda1", "/");
3145 /* TestOutputTrue for exists (0) */
3149 r = guestfs_touch (g, "/new");
3156 r = guestfs_exists (g, "/new");
3160 fprintf (stderr, "test_exists_0: expected true, got false\n");
3167 static int test_exists_1 (void)
3169 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
3173 r = guestfs_umount_all (g);
3180 r = guestfs_lvm_remove_all (g);
3191 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3198 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3205 r = guestfs_mount (g, "/dev/sda1", "/");
3209 /* TestOutputTrue for exists (1) */
3213 r = guestfs_mkdir (g, "/new");
3220 r = guestfs_exists (g, "/new");
3224 fprintf (stderr, "test_exists_1: expected true, got false\n");
3231 static int test_mkdir_p_0 (void)
3233 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
3237 r = guestfs_umount_all (g);
3244 r = guestfs_lvm_remove_all (g);
3255 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3262 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3269 r = guestfs_mount (g, "/dev/sda1", "/");
3273 /* TestOutputTrue for mkdir_p (0) */
3277 r = guestfs_mkdir_p (g, "/new/foo/bar");
3284 r = guestfs_is_dir (g, "/new/foo/bar");
3288 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
3295 static int test_mkdir_p_1 (void)
3297 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
3301 r = guestfs_umount_all (g);
3308 r = guestfs_lvm_remove_all (g);
3319 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3326 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3333 r = guestfs_mount (g, "/dev/sda1", "/");
3337 /* TestOutputTrue for mkdir_p (1) */
3341 r = guestfs_mkdir_p (g, "/new/foo/bar");
3348 r = guestfs_is_dir (g, "/new/foo");
3352 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
3359 static int test_mkdir_p_2 (void)
3361 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
3365 r = guestfs_umount_all (g);
3372 r = guestfs_lvm_remove_all (g);
3383 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3390 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3397 r = guestfs_mount (g, "/dev/sda1", "/");
3401 /* TestOutputTrue for mkdir_p (2) */
3405 r = guestfs_mkdir_p (g, "/new/foo/bar");
3412 r = guestfs_is_dir (g, "/new");
3416 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
3423 static int test_mkdir_0 (void)
3425 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
3429 r = guestfs_umount_all (g);
3436 r = guestfs_lvm_remove_all (g);
3447 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3454 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3461 r = guestfs_mount (g, "/dev/sda1", "/");
3465 /* TestOutputTrue for mkdir (0) */
3469 r = guestfs_mkdir (g, "/new");
3476 r = guestfs_is_dir (g, "/new");
3480 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
3487 static int test_mkdir_1 (void)
3489 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
3493 r = guestfs_umount_all (g);
3500 r = guestfs_lvm_remove_all (g);
3511 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3518 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3525 r = guestfs_mount (g, "/dev/sda1", "/");
3529 /* TestLastFail for mkdir (1) */
3533 r = guestfs_mkdir (g, "/new/foo/bar");
3540 static int test_rm_rf_0 (void)
3542 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
3546 r = guestfs_umount_all (g);
3553 r = guestfs_lvm_remove_all (g);
3564 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3571 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3578 r = guestfs_mount (g, "/dev/sda1", "/");
3582 /* TestOutputFalse for rm_rf (0) */
3586 r = guestfs_mkdir (g, "/new");
3593 r = guestfs_mkdir (g, "/new/foo");
3600 r = guestfs_touch (g, "/new/foo/bar");
3607 r = guestfs_rm_rf (g, "/new");
3614 r = guestfs_exists (g, "/new");
3618 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
3625 static int test_rmdir_0 (void)
3627 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
3631 r = guestfs_umount_all (g);
3638 r = guestfs_lvm_remove_all (g);
3649 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3656 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3663 r = guestfs_mount (g, "/dev/sda1", "/");
3667 /* TestRun for rmdir (0) */
3671 r = guestfs_mkdir (g, "/new");
3678 r = guestfs_rmdir (g, "/new");
3685 static int test_rmdir_1 (void)
3687 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
3691 r = guestfs_umount_all (g);
3698 r = guestfs_lvm_remove_all (g);
3709 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3716 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3723 r = guestfs_mount (g, "/dev/sda1", "/");
3727 /* TestLastFail for rmdir (1) */
3731 r = guestfs_rmdir (g, "/new");
3738 static int test_rmdir_2 (void)
3740 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
3744 r = guestfs_umount_all (g);
3751 r = guestfs_lvm_remove_all (g);
3762 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3769 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3776 r = guestfs_mount (g, "/dev/sda1", "/");
3780 /* TestLastFail for rmdir (2) */
3784 r = guestfs_touch (g, "/new");
3791 r = guestfs_rmdir (g, "/new");
3798 static int test_rm_0 (void)
3800 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
3804 r = guestfs_umount_all (g);
3811 r = guestfs_lvm_remove_all (g);
3822 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3829 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3836 r = guestfs_mount (g, "/dev/sda1", "/");
3840 /* TestRun for rm (0) */
3844 r = guestfs_touch (g, "/new");
3851 r = guestfs_rm (g, "/new");
3858 static int test_rm_1 (void)
3860 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
3864 r = guestfs_umount_all (g);
3871 r = guestfs_lvm_remove_all (g);
3882 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3889 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3896 r = guestfs_mount (g, "/dev/sda1", "/");
3900 /* TestLastFail for rm (1) */
3904 r = guestfs_rm (g, "/new");
3911 static int test_rm_2 (void)
3913 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
3917 r = guestfs_umount_all (g);
3924 r = guestfs_lvm_remove_all (g);
3935 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3942 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3949 r = guestfs_mount (g, "/dev/sda1", "/");
3953 /* TestLastFail for rm (2) */
3957 r = guestfs_mkdir (g, "/new");
3964 r = guestfs_rm (g, "/new");
3971 static int test_read_lines_0 (void)
3973 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3977 r = guestfs_umount_all (g);
3984 r = guestfs_lvm_remove_all (g);
3995 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4002 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4009 r = guestfs_mount (g, "/dev/sda1", "/");
4013 /* TestOutputList for read_lines (0) */
4017 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
4025 r = guestfs_read_lines (g, "/new");
4029 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4033 if (strcmp (r[0], "line1") != 0) {
4034 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
4038 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4042 if (strcmp (r[1], "line2") != 0) {
4043 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
4047 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4051 if (strcmp (r[2], "line3") != 0) {
4052 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
4056 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
4060 for (i = 0; r[i] != NULL; ++i)
4067 static int test_read_lines_1 (void)
4069 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
4073 r = guestfs_umount_all (g);
4080 r = guestfs_lvm_remove_all (g);
4091 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4098 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4105 r = guestfs_mount (g, "/dev/sda1", "/");
4109 /* TestOutputList for read_lines (1) */
4113 r = guestfs_write_file (g, "/new", "", 0);
4121 r = guestfs_read_lines (g, "/new");
4125 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
4129 for (i = 0; r[i] != NULL; ++i)
4136 static int test_lvs_0 (void)
4138 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
4142 r = guestfs_umount_all (g);
4149 r = guestfs_lvm_remove_all (g);
4160 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4167 r = guestfs_pvcreate (g, "/dev/sda1");
4172 char *physvols[] = {
4178 r = guestfs_vgcreate (g, "VG", physvols);
4185 r = guestfs_lvcreate (g, "LV", "VG", 8);
4192 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4199 r = guestfs_mount (g, "/dev/VG/LV", "/");
4203 /* TestOutputList for lvs (0) */
4208 r = guestfs_lvs (g);
4212 fprintf (stderr, "test_lvs_0: short list returned from command\n");
4216 if (strcmp (r[0], "/dev/VG/LV") != 0) {
4217 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
4221 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
4225 for (i = 0; r[i] != NULL; ++i)
4232 static int test_lvs_1 (void)
4234 /* InitEmpty for lvs (1) */
4238 r = guestfs_umount_all (g);
4245 r = guestfs_lvm_remove_all (g);
4249 /* TestOutputList for lvs (1) */
4259 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4266 r = guestfs_pvcreate (g, "/dev/sda1");
4273 r = guestfs_pvcreate (g, "/dev/sda2");
4280 r = guestfs_pvcreate (g, "/dev/sda3");
4285 char *physvols[] = {
4292 r = guestfs_vgcreate (g, "VG1", physvols);
4297 char *physvols[] = {
4303 r = guestfs_vgcreate (g, "VG2", physvols);
4310 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4317 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4324 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4332 r = guestfs_lvs (g);
4336 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4340 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4341 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4345 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4349 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4350 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4354 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4358 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4359 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4363 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
4367 for (i = 0; r[i] != NULL; ++i)
4374 static int test_vgs_0 (void)
4376 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
4380 r = guestfs_umount_all (g);
4387 r = guestfs_lvm_remove_all (g);
4398 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4405 r = guestfs_pvcreate (g, "/dev/sda1");
4410 char *physvols[] = {
4416 r = guestfs_vgcreate (g, "VG", physvols);
4423 r = guestfs_lvcreate (g, "LV", "VG", 8);
4430 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4437 r = guestfs_mount (g, "/dev/VG/LV", "/");
4441 /* TestOutputList for vgs (0) */
4446 r = guestfs_vgs (g);
4450 fprintf (stderr, "test_vgs_0: short list returned from command\n");
4454 if (strcmp (r[0], "VG") != 0) {
4455 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
4459 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
4463 for (i = 0; r[i] != NULL; ++i)
4470 static int test_vgs_1 (void)
4472 /* InitEmpty for vgs (1) */
4476 r = guestfs_umount_all (g);
4483 r = guestfs_lvm_remove_all (g);
4487 /* TestOutputList for vgs (1) */
4497 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4504 r = guestfs_pvcreate (g, "/dev/sda1");
4511 r = guestfs_pvcreate (g, "/dev/sda2");
4518 r = guestfs_pvcreate (g, "/dev/sda3");
4523 char *physvols[] = {
4530 r = guestfs_vgcreate (g, "VG1", physvols);
4535 char *physvols[] = {
4541 r = guestfs_vgcreate (g, "VG2", physvols);
4549 r = guestfs_vgs (g);
4553 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4557 if (strcmp (r[0], "VG1") != 0) {
4558 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
4562 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4566 if (strcmp (r[1], "VG2") != 0) {
4567 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
4571 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
4575 for (i = 0; r[i] != NULL; ++i)
4582 static int test_pvs_0 (void)
4584 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
4588 r = guestfs_umount_all (g);
4595 r = guestfs_lvm_remove_all (g);
4606 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4613 r = guestfs_pvcreate (g, "/dev/sda1");
4618 char *physvols[] = {
4624 r = guestfs_vgcreate (g, "VG", physvols);
4631 r = guestfs_lvcreate (g, "LV", "VG", 8);
4638 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4645 r = guestfs_mount (g, "/dev/VG/LV", "/");
4649 /* TestOutputList for pvs (0) */
4654 r = guestfs_pvs (g);
4658 fprintf (stderr, "test_pvs_0: short list returned from command\n");
4662 if (strcmp (r[0], "/dev/sda1") != 0) {
4663 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4667 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
4671 for (i = 0; r[i] != NULL; ++i)
4678 static int test_pvs_1 (void)
4680 /* InitEmpty for pvs (1) */
4684 r = guestfs_umount_all (g);
4691 r = guestfs_lvm_remove_all (g);
4695 /* TestOutputList for pvs (1) */
4705 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4712 r = guestfs_pvcreate (g, "/dev/sda1");
4719 r = guestfs_pvcreate (g, "/dev/sda2");
4726 r = guestfs_pvcreate (g, "/dev/sda3");
4734 r = guestfs_pvs (g);
4738 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4742 if (strcmp (r[0], "/dev/sda1") != 0) {
4743 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4747 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4751 if (strcmp (r[1], "/dev/sda2") != 0) {
4752 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4756 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4760 if (strcmp (r[2], "/dev/sda3") != 0) {
4761 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4765 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
4769 for (i = 0; r[i] != NULL; ++i)
4776 static int test_list_partitions_0 (void)
4778 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
4782 r = guestfs_umount_all (g);
4789 r = guestfs_lvm_remove_all (g);
4800 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4807 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4814 r = guestfs_mount (g, "/dev/sda1", "/");
4818 /* TestOutputList for list_partitions (0) */
4823 r = guestfs_list_partitions (g);
4827 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
4831 if (strcmp (r[0], "/dev/sda1") != 0) {
4832 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4836 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
4840 for (i = 0; r[i] != NULL; ++i)
4847 static int test_list_partitions_1 (void)
4849 /* InitEmpty for list_partitions (1) */
4853 r = guestfs_umount_all (g);
4860 r = guestfs_lvm_remove_all (g);
4864 /* TestOutputList for list_partitions (1) */
4874 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4882 r = guestfs_list_partitions (g);
4886 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4890 if (strcmp (r[0], "/dev/sda1") != 0) {
4891 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4895 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4899 if (strcmp (r[1], "/dev/sda2") != 0) {
4900 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4904 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4908 if (strcmp (r[2], "/dev/sda3") != 0) {
4909 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4913 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
4917 for (i = 0; r[i] != NULL; ++i)
4924 static int test_list_devices_0 (void)
4926 /* InitEmpty for list_devices (0) */
4930 r = guestfs_umount_all (g);
4937 r = guestfs_lvm_remove_all (g);
4941 /* TestOutputList for list_devices (0) */
4946 r = guestfs_list_devices (g);
4950 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4954 if (strcmp (r[0], "/dev/sda") != 0) {
4955 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4959 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4963 if (strcmp (r[1], "/dev/sdb") != 0) {
4964 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4968 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4972 if (strcmp (r[2], "/dev/sdc") != 0) {
4973 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4977 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4981 for (i = 0; r[i] != NULL; ++i)
4988 static int test_ls_0 (void)
4990 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4994 r = guestfs_umount_all (g);
5001 r = guestfs_lvm_remove_all (g);
5012 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5019 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5026 r = guestfs_mount (g, "/dev/sda1", "/");
5030 /* TestOutputList for ls (0) */
5034 r = guestfs_touch (g, "/new");
5041 r = guestfs_touch (g, "/newer");
5048 r = guestfs_touch (g, "/newest");
5056 r = guestfs_ls (g, "/");
5060 fprintf (stderr, "test_ls_0: short list returned from command\n");
5064 if (strcmp (r[0], "lost+found") != 0) {
5065 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
5069 fprintf (stderr, "test_ls_0: short list returned from command\n");
5073 if (strcmp (r[1], "new") != 0) {
5074 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
5078 fprintf (stderr, "test_ls_0: short list returned from command\n");
5082 if (strcmp (r[2], "newer") != 0) {
5083 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
5087 fprintf (stderr, "test_ls_0: short list returned from command\n");
5091 if (strcmp (r[3], "newest") != 0) {
5092 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
5096 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
5100 for (i = 0; r[i] != NULL; ++i)
5107 static int test_cat_0 (void)
5109 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
5113 r = guestfs_umount_all (g);
5120 r = guestfs_lvm_remove_all (g);
5131 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5138 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5145 r = guestfs_mount (g, "/dev/sda1", "/");
5149 /* TestOutput for cat (0) */
5153 r = guestfs_write_file (g, "/new", "new file contents", 0);
5160 r = guestfs_cat (g, "/new");
5163 if (strcmp (r, "new file contents") != 0) {
5164 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
5172 static int test_touch_0 (void)
5174 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
5178 r = guestfs_umount_all (g);
5185 r = guestfs_lvm_remove_all (g);
5196 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5203 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5210 r = guestfs_mount (g, "/dev/sda1", "/");
5214 /* TestOutputTrue for touch (0) */
5218 r = guestfs_touch (g, "/new");
5225 r = guestfs_exists (g, "/new");
5229 fprintf (stderr, "test_touch_0: expected true, got false\n");
5236 static int test_sync_0 (void)
5238 /* InitEmpty for sync (0) */
5242 r = guestfs_umount_all (g);
5249 r = guestfs_lvm_remove_all (g);
5253 /* TestRun for sync (0) */
5257 r = guestfs_sync (g);
5264 static int test_mount_0 (void)
5266 /* InitEmpty for mount (0) */
5270 r = guestfs_umount_all (g);
5277 r = guestfs_lvm_remove_all (g);
5281 /* TestOutput for mount (0) */
5289 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5296 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5303 r = guestfs_mount (g, "/dev/sda1", "/");
5310 r = guestfs_write_file (g, "/new", "new file contents", 0);
5317 r = guestfs_cat (g, "/new");
5320 if (strcmp (r, "new file contents") != 0) {
5321 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
5329 int main (int argc, char *argv[])
5334 const char *filename;
5336 int nr_tests, test_num = 0;
5338 no_test_warnings ();
5340 g = guestfs_create ();
5342 printf ("guestfs_create FAILED\n");
5346 guestfs_set_error_handler (g, print_error, NULL);
5348 srcdir = getenv ("srcdir");
5349 if (!srcdir) srcdir = ".";
5351 guestfs_set_path (g, ".");
5353 filename = "test1.img";
5354 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5359 if (lseek (fd, 524288000, SEEK_SET) == -1) {
5365 if (write (fd, &c, 1) == -1) {
5371 if (close (fd) == -1) {
5376 if (guestfs_add_drive (g, filename) == -1) {
5377 printf ("guestfs_add_drive %s FAILED\n", filename);
5381 filename = "test2.img";
5382 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5387 if (lseek (fd, 52428800, SEEK_SET) == -1) {
5393 if (write (fd, &c, 1) == -1) {
5399 if (close (fd) == -1) {
5404 if (guestfs_add_drive (g, filename) == -1) {
5405 printf ("guestfs_add_drive %s FAILED\n", filename);
5409 filename = "test3.img";
5410 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5415 if (lseek (fd, 10485760, SEEK_SET) == -1) {
5421 if (write (fd, &c, 1) == -1) {
5427 if (close (fd) == -1) {
5432 if (guestfs_add_drive (g, filename) == -1) {
5433 printf ("guestfs_add_drive %s FAILED\n", filename);
5437 if (guestfs_launch (g) == -1) {
5438 printf ("guestfs_launch FAILED\n");
5441 if (guestfs_wait_ready (g) == -1) {
5442 printf ("guestfs_wait_ready FAILED\n");
5449 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
5450 if (test_mount_ro_0 () == -1) {
5451 printf ("test_mount_ro_0 FAILED\n");
5455 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
5456 if (test_mount_ro_1 () == -1) {
5457 printf ("test_mount_ro_1 FAILED\n");
5461 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
5462 if (test_tgz_in_0 () == -1) {
5463 printf ("test_tgz_in_0 FAILED\n");
5467 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
5468 if (test_tar_in_0 () == -1) {
5469 printf ("test_tar_in_0 FAILED\n");
5473 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
5474 if (test_checksum_0 () == -1) {
5475 printf ("test_checksum_0 FAILED\n");
5479 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
5480 if (test_checksum_1 () == -1) {
5481 printf ("test_checksum_1 FAILED\n");
5485 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
5486 if (test_checksum_2 () == -1) {
5487 printf ("test_checksum_2 FAILED\n");
5491 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
5492 if (test_checksum_3 () == -1) {
5493 printf ("test_checksum_3 FAILED\n");
5497 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
5498 if (test_checksum_4 () == -1) {
5499 printf ("test_checksum_4 FAILED\n");
5503 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
5504 if (test_checksum_5 () == -1) {
5505 printf ("test_checksum_5 FAILED\n");
5509 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
5510 if (test_checksum_6 () == -1) {
5511 printf ("test_checksum_6 FAILED\n");
5515 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
5516 if (test_checksum_7 () == -1) {
5517 printf ("test_checksum_7 FAILED\n");
5521 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
5522 if (test_download_0 () == -1) {
5523 printf ("test_download_0 FAILED\n");
5527 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
5528 if (test_upload_0 () == -1) {
5529 printf ("test_upload_0 FAILED\n");
5533 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
5534 if (test_blockdev_rereadpt_0 () == -1) {
5535 printf ("test_blockdev_rereadpt_0 FAILED\n");
5539 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
5540 if (test_blockdev_flushbufs_0 () == -1) {
5541 printf ("test_blockdev_flushbufs_0 FAILED\n");
5545 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
5546 if (test_blockdev_getsize64_0 () == -1) {
5547 printf ("test_blockdev_getsize64_0 FAILED\n");
5551 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
5552 if (test_blockdev_getsz_0 () == -1) {
5553 printf ("test_blockdev_getsz_0 FAILED\n");
5557 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
5558 if (test_blockdev_getbsz_0 () == -1) {
5559 printf ("test_blockdev_getbsz_0 FAILED\n");
5563 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
5564 if (test_blockdev_getss_0 () == -1) {
5565 printf ("test_blockdev_getss_0 FAILED\n");
5569 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
5570 if (test_blockdev_getro_0 () == -1) {
5571 printf ("test_blockdev_getro_0 FAILED\n");
5575 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
5576 if (test_blockdev_setrw_0 () == -1) {
5577 printf ("test_blockdev_setrw_0 FAILED\n");
5581 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
5582 if (test_blockdev_setro_0 () == -1) {
5583 printf ("test_blockdev_setro_0 FAILED\n");
5587 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
5588 if (test_statvfs_0 () == -1) {
5589 printf ("test_statvfs_0 FAILED\n");
5593 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
5594 if (test_lstat_0 () == -1) {
5595 printf ("test_lstat_0 FAILED\n");
5599 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
5600 if (test_stat_0 () == -1) {
5601 printf ("test_stat_0 FAILED\n");
5605 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
5606 if (test_file_0 () == -1) {
5607 printf ("test_file_0 FAILED\n");
5611 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
5612 if (test_file_1 () == -1) {
5613 printf ("test_file_1 FAILED\n");
5617 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
5618 if (test_file_2 () == -1) {
5619 printf ("test_file_2 FAILED\n");
5623 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
5624 if (test_umount_all_0 () == -1) {
5625 printf ("test_umount_all_0 FAILED\n");
5629 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
5630 if (test_mounts_0 () == -1) {
5631 printf ("test_mounts_0 FAILED\n");
5635 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
5636 if (test_umount_0 () == -1) {
5637 printf ("test_umount_0 FAILED\n");
5641 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
5642 if (test_umount_1 () == -1) {
5643 printf ("test_umount_1 FAILED\n");
5647 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
5648 if (test_write_file_0 () == -1) {
5649 printf ("test_write_file_0 FAILED\n");
5653 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
5654 if (test_write_file_1 () == -1) {
5655 printf ("test_write_file_1 FAILED\n");
5659 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
5660 if (test_write_file_2 () == -1) {
5661 printf ("test_write_file_2 FAILED\n");
5665 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
5666 if (test_write_file_3 () == -1) {
5667 printf ("test_write_file_3 FAILED\n");
5671 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
5672 if (test_write_file_4 () == -1) {
5673 printf ("test_write_file_4 FAILED\n");
5677 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
5678 if (test_write_file_5 () == -1) {
5679 printf ("test_write_file_5 FAILED\n");
5683 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
5684 if (test_mkfs_0 () == -1) {
5685 printf ("test_mkfs_0 FAILED\n");
5689 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
5690 if (test_lvcreate_0 () == -1) {
5691 printf ("test_lvcreate_0 FAILED\n");
5695 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
5696 if (test_vgcreate_0 () == -1) {
5697 printf ("test_vgcreate_0 FAILED\n");
5701 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
5702 if (test_pvcreate_0 () == -1) {
5703 printf ("test_pvcreate_0 FAILED\n");
5707 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
5708 if (test_is_dir_0 () == -1) {
5709 printf ("test_is_dir_0 FAILED\n");
5713 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
5714 if (test_is_dir_1 () == -1) {
5715 printf ("test_is_dir_1 FAILED\n");
5719 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
5720 if (test_is_file_0 () == -1) {
5721 printf ("test_is_file_0 FAILED\n");
5725 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
5726 if (test_is_file_1 () == -1) {
5727 printf ("test_is_file_1 FAILED\n");
5731 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
5732 if (test_exists_0 () == -1) {
5733 printf ("test_exists_0 FAILED\n");
5737 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
5738 if (test_exists_1 () == -1) {
5739 printf ("test_exists_1 FAILED\n");
5743 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
5744 if (test_mkdir_p_0 () == -1) {
5745 printf ("test_mkdir_p_0 FAILED\n");
5749 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
5750 if (test_mkdir_p_1 () == -1) {
5751 printf ("test_mkdir_p_1 FAILED\n");
5755 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
5756 if (test_mkdir_p_2 () == -1) {
5757 printf ("test_mkdir_p_2 FAILED\n");
5761 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
5762 if (test_mkdir_0 () == -1) {
5763 printf ("test_mkdir_0 FAILED\n");
5767 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
5768 if (test_mkdir_1 () == -1) {
5769 printf ("test_mkdir_1 FAILED\n");
5773 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
5774 if (test_rm_rf_0 () == -1) {
5775 printf ("test_rm_rf_0 FAILED\n");
5779 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
5780 if (test_rmdir_0 () == -1) {
5781 printf ("test_rmdir_0 FAILED\n");
5785 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
5786 if (test_rmdir_1 () == -1) {
5787 printf ("test_rmdir_1 FAILED\n");
5791 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
5792 if (test_rmdir_2 () == -1) {
5793 printf ("test_rmdir_2 FAILED\n");
5797 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
5798 if (test_rm_0 () == -1) {
5799 printf ("test_rm_0 FAILED\n");
5803 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
5804 if (test_rm_1 () == -1) {
5805 printf ("test_rm_1 FAILED\n");
5809 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
5810 if (test_rm_2 () == -1) {
5811 printf ("test_rm_2 FAILED\n");
5815 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
5816 if (test_read_lines_0 () == -1) {
5817 printf ("test_read_lines_0 FAILED\n");
5821 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
5822 if (test_read_lines_1 () == -1) {
5823 printf ("test_read_lines_1 FAILED\n");
5827 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
5828 if (test_lvs_0 () == -1) {
5829 printf ("test_lvs_0 FAILED\n");
5833 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
5834 if (test_lvs_1 () == -1) {
5835 printf ("test_lvs_1 FAILED\n");
5839 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
5840 if (test_vgs_0 () == -1) {
5841 printf ("test_vgs_0 FAILED\n");
5845 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
5846 if (test_vgs_1 () == -1) {
5847 printf ("test_vgs_1 FAILED\n");
5851 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
5852 if (test_pvs_0 () == -1) {
5853 printf ("test_pvs_0 FAILED\n");
5857 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
5858 if (test_pvs_1 () == -1) {
5859 printf ("test_pvs_1 FAILED\n");
5863 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
5864 if (test_list_partitions_0 () == -1) {
5865 printf ("test_list_partitions_0 FAILED\n");
5869 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
5870 if (test_list_partitions_1 () == -1) {
5871 printf ("test_list_partitions_1 FAILED\n");
5875 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
5876 if (test_list_devices_0 () == -1) {
5877 printf ("test_list_devices_0 FAILED\n");
5881 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
5882 if (test_ls_0 () == -1) {
5883 printf ("test_ls_0 FAILED\n");
5887 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
5888 if (test_cat_0 () == -1) {
5889 printf ("test_cat_0 FAILED\n");
5893 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
5894 if (test_touch_0 () == -1) {
5895 printf ("test_touch_0 FAILED\n");
5899 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
5900 if (test_sync_0 () == -1) {
5901 printf ("test_sync_0 FAILED\n");
5905 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
5906 if (test_mount_0 () == -1) {
5907 printf ("test_mount_0 FAILED\n");
5912 unlink ("test1.img");
5913 unlink ("test2.img");
5914 unlink ("test3.img");
5917 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);