1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 static void print_error (guestfs_h *g, void *data, const char *msg)
37 fprintf (stderr, "%s\n", msg);
40 static void print_strings (char * const * const argv)
44 for (argc = 0; argv[argc] != NULL; ++argc)
45 printf ("\t%s\n", argv[argc]);
49 static void print_table (char * const * const argv)
53 for (i = 0; argv[i] != NULL; i += 2)
54 printf ("%s: %s\n", argv[i], argv[i+1]);
58 static void no_test_warnings (void)
60 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
61 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
62 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
63 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
64 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
65 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_upload\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_download\" has no tests\n");
108 static int test_checksum_0 (void)
110 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
114 r = guestfs_umount_all (g);
121 r = guestfs_lvm_remove_all (g);
132 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
139 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
146 r = guestfs_mount (g, "/dev/sda1", "/");
150 /* TestOutput for checksum (0) */
154 r = guestfs_write_file (g, "/new", "test\n", 0);
161 r = guestfs_checksum (g, "crc", "/new");
164 if (strcmp (r, "935282863") != 0) {
165 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
173 static int test_checksum_1 (void)
175 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
179 r = guestfs_umount_all (g);
186 r = guestfs_lvm_remove_all (g);
197 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
204 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
211 r = guestfs_mount (g, "/dev/sda1", "/");
215 /* TestLastFail for checksum (1) */
219 r = guestfs_checksum (g, "crc", "/new");
227 static int test_checksum_2 (void)
229 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
233 r = guestfs_umount_all (g);
240 r = guestfs_lvm_remove_all (g);
251 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
258 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
265 r = guestfs_mount (g, "/dev/sda1", "/");
269 /* TestOutput for checksum (2) */
273 r = guestfs_write_file (g, "/new", "test\n", 0);
280 r = guestfs_checksum (g, "md5", "/new");
283 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
284 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
292 static int test_checksum_3 (void)
294 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
298 r = guestfs_umount_all (g);
305 r = guestfs_lvm_remove_all (g);
316 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
323 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
330 r = guestfs_mount (g, "/dev/sda1", "/");
334 /* TestOutput for checksum (3) */
338 r = guestfs_write_file (g, "/new", "test\n", 0);
345 r = guestfs_checksum (g, "sha1", "/new");
348 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
349 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
357 static int test_checksum_4 (void)
359 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
363 r = guestfs_umount_all (g);
370 r = guestfs_lvm_remove_all (g);
381 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
388 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
395 r = guestfs_mount (g, "/dev/sda1", "/");
399 /* TestOutput for checksum (4) */
403 r = guestfs_write_file (g, "/new", "test\n", 0);
410 r = guestfs_checksum (g, "sha224", "/new");
413 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
414 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
422 static int test_checksum_5 (void)
424 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
428 r = guestfs_umount_all (g);
435 r = guestfs_lvm_remove_all (g);
446 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
453 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
460 r = guestfs_mount (g, "/dev/sda1", "/");
464 /* TestOutput for checksum (5) */
468 r = guestfs_write_file (g, "/new", "test\n", 0);
475 r = guestfs_checksum (g, "sha256", "/new");
478 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
479 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
487 static int test_checksum_6 (void)
489 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
493 r = guestfs_umount_all (g);
500 r = guestfs_lvm_remove_all (g);
511 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
518 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
525 r = guestfs_mount (g, "/dev/sda1", "/");
529 /* TestOutput for checksum (6) */
533 r = guestfs_write_file (g, "/new", "test\n", 0);
540 r = guestfs_checksum (g, "sha384", "/new");
543 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
544 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
552 static int test_checksum_7 (void)
554 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
558 r = guestfs_umount_all (g);
565 r = guestfs_lvm_remove_all (g);
576 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
583 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
590 r = guestfs_mount (g, "/dev/sda1", "/");
594 /* TestOutput for checksum (7) */
598 r = guestfs_write_file (g, "/new", "test\n", 0);
605 r = guestfs_checksum (g, "sha512", "/new");
608 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
609 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
617 static int test_blockdev_rereadpt_0 (void)
619 /* InitEmpty for blockdev_rereadpt (0) */
623 r = guestfs_umount_all (g);
630 r = guestfs_lvm_remove_all (g);
634 /* TestRun for blockdev_rereadpt (0) */
638 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
645 static int test_blockdev_flushbufs_0 (void)
647 /* InitEmpty for blockdev_flushbufs (0) */
651 r = guestfs_umount_all (g);
658 r = guestfs_lvm_remove_all (g);
662 /* TestRun for blockdev_flushbufs (0) */
666 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
673 static int test_blockdev_getsize64_0 (void)
675 /* InitEmpty for blockdev_getsize64 (0) */
679 r = guestfs_umount_all (g);
686 r = guestfs_lvm_remove_all (g);
690 /* TestOutputInt for blockdev_getsize64 (0) */
694 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
697 if (r != 524288000) {
698 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
705 static int test_blockdev_getsz_0 (void)
707 /* InitEmpty for blockdev_getsz (0) */
711 r = guestfs_umount_all (g);
718 r = guestfs_lvm_remove_all (g);
722 /* TestOutputInt for blockdev_getsz (0) */
726 r = guestfs_blockdev_getsz (g, "/dev/sda");
730 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
737 static int test_blockdev_getbsz_0 (void)
739 /* InitEmpty for blockdev_getbsz (0) */
743 r = guestfs_umount_all (g);
750 r = guestfs_lvm_remove_all (g);
754 /* TestOutputInt for blockdev_getbsz (0) */
758 r = guestfs_blockdev_getbsz (g, "/dev/sda");
762 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
769 static int test_blockdev_getss_0 (void)
771 /* InitEmpty for blockdev_getss (0) */
775 r = guestfs_umount_all (g);
782 r = guestfs_lvm_remove_all (g);
786 /* TestOutputInt for blockdev_getss (0) */
790 r = guestfs_blockdev_getss (g, "/dev/sda");
794 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
801 static int test_blockdev_getro_0 (void)
803 /* InitEmpty for blockdev_getro (0) */
807 r = guestfs_umount_all (g);
814 r = guestfs_lvm_remove_all (g);
818 /* TestOutputTrue for blockdev_getro (0) */
822 r = guestfs_blockdev_setro (g, "/dev/sda");
829 r = guestfs_blockdev_getro (g, "/dev/sda");
833 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
840 static int test_blockdev_setrw_0 (void)
842 /* InitEmpty for blockdev_setrw (0) */
846 r = guestfs_umount_all (g);
853 r = guestfs_lvm_remove_all (g);
857 /* TestOutputFalse for blockdev_setrw (0) */
861 r = guestfs_blockdev_setrw (g, "/dev/sda");
868 r = guestfs_blockdev_getro (g, "/dev/sda");
872 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
879 static int test_blockdev_setro_0 (void)
881 /* InitEmpty for blockdev_setro (0) */
885 r = guestfs_umount_all (g);
892 r = guestfs_lvm_remove_all (g);
896 /* TestOutputTrue for blockdev_setro (0) */
900 r = guestfs_blockdev_setro (g, "/dev/sda");
907 r = guestfs_blockdev_getro (g, "/dev/sda");
911 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
918 static int test_statvfs_0 (void)
920 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
924 r = guestfs_umount_all (g);
931 r = guestfs_lvm_remove_all (g);
942 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
949 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
956 r = guestfs_mount (g, "/dev/sda1", "/");
960 /* TestOutputStruct for statvfs (0) */
962 struct guestfs_statvfs *r;
964 r = guestfs_statvfs (g, "/");
967 if (r->bfree != 487702) {
968 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
972 if (r->blocks != 490020) {
973 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
977 if (r->bsize != 1024) {
978 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
987 static int test_lstat_0 (void)
989 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
993 r = guestfs_umount_all (g);
1000 r = guestfs_lvm_remove_all (g);
1011 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1018 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1025 r = guestfs_mount (g, "/dev/sda1", "/");
1029 /* TestOutputStruct for lstat (0) */
1033 r = guestfs_touch (g, "/new");
1038 struct guestfs_stat *r;
1040 r = guestfs_lstat (g, "/new");
1044 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
1053 static int test_stat_0 (void)
1055 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
1059 r = guestfs_umount_all (g);
1066 r = guestfs_lvm_remove_all (g);
1077 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1084 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1091 r = guestfs_mount (g, "/dev/sda1", "/");
1095 /* TestOutputStruct for stat (0) */
1099 r = guestfs_touch (g, "/new");
1104 struct guestfs_stat *r;
1106 r = guestfs_stat (g, "/new");
1110 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
1119 static int test_file_0 (void)
1121 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
1125 r = guestfs_umount_all (g);
1132 r = guestfs_lvm_remove_all (g);
1143 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1150 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1157 r = guestfs_mount (g, "/dev/sda1", "/");
1161 /* TestOutput for file (0) */
1165 r = guestfs_touch (g, "/new");
1172 r = guestfs_file (g, "/new");
1175 if (strcmp (r, "empty") != 0) {
1176 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
1184 static int test_file_1 (void)
1186 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
1190 r = guestfs_umount_all (g);
1197 r = guestfs_lvm_remove_all (g);
1208 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1215 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1222 r = guestfs_mount (g, "/dev/sda1", "/");
1226 /* TestOutput for file (1) */
1230 r = guestfs_write_file (g, "/new", "some content\n", 0);
1237 r = guestfs_file (g, "/new");
1240 if (strcmp (r, "ASCII text") != 0) {
1241 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
1249 static int test_file_2 (void)
1251 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
1255 r = guestfs_umount_all (g);
1262 r = guestfs_lvm_remove_all (g);
1273 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1280 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1287 r = guestfs_mount (g, "/dev/sda1", "/");
1291 /* TestLastFail for file (2) */
1295 r = guestfs_file (g, "/nofile");
1303 static int test_umount_all_0 (void)
1305 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
1309 r = guestfs_umount_all (g);
1316 r = guestfs_lvm_remove_all (g);
1327 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1334 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1341 r = guestfs_mount (g, "/dev/sda1", "/");
1345 /* TestOutputList for umount_all (0) */
1349 r = guestfs_umount_all (g);
1357 r = guestfs_mounts (g);
1361 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
1365 for (i = 0; r[i] != NULL; ++i)
1372 static int test_mounts_0 (void)
1374 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
1378 r = guestfs_umount_all (g);
1385 r = guestfs_lvm_remove_all (g);
1396 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1403 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1410 r = guestfs_mount (g, "/dev/sda1", "/");
1414 /* TestOutputList for mounts (0) */
1419 r = guestfs_mounts (g);
1423 fprintf (stderr, "test_mounts_0: short list returned from command\n");
1427 if (strcmp (r[0], "/dev/sda1") != 0) {
1428 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1432 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
1436 for (i = 0; r[i] != NULL; ++i)
1443 static int test_umount_0 (void)
1445 /* InitEmpty for umount (0) */
1449 r = guestfs_umount_all (g);
1456 r = guestfs_lvm_remove_all (g);
1460 /* TestOutputList for umount (0) */
1468 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1475 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1482 r = guestfs_mount (g, "/dev/sda1", "/");
1490 r = guestfs_mounts (g);
1494 fprintf (stderr, "test_umount_0: short list returned from command\n");
1498 if (strcmp (r[0], "/dev/sda1") != 0) {
1499 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1503 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
1507 for (i = 0; r[i] != NULL; ++i)
1514 static int test_umount_1 (void)
1516 /* InitEmpty for umount (1) */
1520 r = guestfs_umount_all (g);
1527 r = guestfs_lvm_remove_all (g);
1531 /* TestOutputList for umount (1) */
1539 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1546 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1553 r = guestfs_mount (g, "/dev/sda1", "/");
1560 r = guestfs_umount (g, "/");
1568 r = guestfs_mounts (g);
1572 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
1576 for (i = 0; r[i] != NULL; ++i)
1583 static int test_write_file_0 (void)
1585 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
1589 r = guestfs_umount_all (g);
1596 r = guestfs_lvm_remove_all (g);
1607 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1614 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1621 r = guestfs_mount (g, "/dev/sda1", "/");
1625 /* TestOutput for write_file (0) */
1629 r = guestfs_write_file (g, "/new", "new file contents", 0);
1636 r = guestfs_cat (g, "/new");
1639 if (strcmp (r, "new file contents") != 0) {
1640 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
1648 static int test_write_file_1 (void)
1650 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
1654 r = guestfs_umount_all (g);
1661 r = guestfs_lvm_remove_all (g);
1672 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1679 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1686 r = guestfs_mount (g, "/dev/sda1", "/");
1690 /* TestOutput for write_file (1) */
1694 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
1701 r = guestfs_cat (g, "/new");
1704 if (strcmp (r, "\nnew file contents\n") != 0) {
1705 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
1713 static int test_write_file_2 (void)
1715 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
1719 r = guestfs_umount_all (g);
1726 r = guestfs_lvm_remove_all (g);
1737 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1744 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1751 r = guestfs_mount (g, "/dev/sda1", "/");
1755 /* TestOutput for write_file (2) */
1759 r = guestfs_write_file (g, "/new", "\n\n", 0);
1766 r = guestfs_cat (g, "/new");
1769 if (strcmp (r, "\n\n") != 0) {
1770 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
1778 static int test_write_file_3 (void)
1780 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
1784 r = guestfs_umount_all (g);
1791 r = guestfs_lvm_remove_all (g);
1802 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1809 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1816 r = guestfs_mount (g, "/dev/sda1", "/");
1820 /* TestOutput for write_file (3) */
1824 r = guestfs_write_file (g, "/new", "", 0);
1831 r = guestfs_cat (g, "/new");
1834 if (strcmp (r, "") != 0) {
1835 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
1843 static int test_write_file_4 (void)
1845 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
1849 r = guestfs_umount_all (g);
1856 r = guestfs_lvm_remove_all (g);
1867 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1874 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1881 r = guestfs_mount (g, "/dev/sda1", "/");
1885 /* TestOutput for write_file (4) */
1889 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
1896 r = guestfs_cat (g, "/new");
1899 if (strcmp (r, "\n\n\n") != 0) {
1900 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
1908 static int test_write_file_5 (void)
1910 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
1914 r = guestfs_umount_all (g);
1921 r = guestfs_lvm_remove_all (g);
1932 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1939 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1946 r = guestfs_mount (g, "/dev/sda1", "/");
1950 /* TestOutput for write_file (5) */
1954 r = guestfs_write_file (g, "/new", "\n", 0);
1961 r = guestfs_cat (g, "/new");
1964 if (strcmp (r, "\n") != 0) {
1965 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
1973 static int test_mkfs_0 (void)
1975 /* InitEmpty for mkfs (0) */
1979 r = guestfs_umount_all (g);
1986 r = guestfs_lvm_remove_all (g);
1990 /* TestOutput for mkfs (0) */
1998 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2005 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2012 r = guestfs_mount (g, "/dev/sda1", "/");
2019 r = guestfs_write_file (g, "/new", "new file contents", 0);
2026 r = guestfs_cat (g, "/new");
2029 if (strcmp (r, "new file contents") != 0) {
2030 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
2038 static int test_lvcreate_0 (void)
2040 /* InitEmpty for lvcreate (0) */
2044 r = guestfs_umount_all (g);
2051 r = guestfs_lvm_remove_all (g);
2055 /* TestOutputList for lvcreate (0) */
2065 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2072 r = guestfs_pvcreate (g, "/dev/sda1");
2079 r = guestfs_pvcreate (g, "/dev/sda2");
2086 r = guestfs_pvcreate (g, "/dev/sda3");
2091 char *physvols[] = {
2098 r = guestfs_vgcreate (g, "VG1", physvols);
2103 char *physvols[] = {
2109 r = guestfs_vgcreate (g, "VG2", physvols);
2116 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2123 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2130 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2137 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2144 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2152 r = guestfs_lvs (g);
2156 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2160 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2161 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2165 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2169 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2170 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2174 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2178 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2179 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2183 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2187 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2188 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2192 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2196 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2197 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2201 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2205 for (i = 0; r[i] != NULL; ++i)
2212 static int test_vgcreate_0 (void)
2214 /* InitEmpty for vgcreate (0) */
2218 r = guestfs_umount_all (g);
2225 r = guestfs_lvm_remove_all (g);
2229 /* TestOutputList for vgcreate (0) */
2239 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2246 r = guestfs_pvcreate (g, "/dev/sda1");
2253 r = guestfs_pvcreate (g, "/dev/sda2");
2260 r = guestfs_pvcreate (g, "/dev/sda3");
2265 char *physvols[] = {
2272 r = guestfs_vgcreate (g, "VG1", physvols);
2277 char *physvols[] = {
2283 r = guestfs_vgcreate (g, "VG2", physvols);
2291 r = guestfs_vgs (g);
2295 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2299 if (strcmp (r[0], "VG1") != 0) {
2300 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2304 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2308 if (strcmp (r[1], "VG2") != 0) {
2309 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2313 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2317 for (i = 0; r[i] != NULL; ++i)
2324 static int test_pvcreate_0 (void)
2326 /* InitEmpty for pvcreate (0) */
2330 r = guestfs_umount_all (g);
2337 r = guestfs_lvm_remove_all (g);
2341 /* TestOutputList for pvcreate (0) */
2351 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2358 r = guestfs_pvcreate (g, "/dev/sda1");
2365 r = guestfs_pvcreate (g, "/dev/sda2");
2372 r = guestfs_pvcreate (g, "/dev/sda3");
2380 r = guestfs_pvs (g);
2384 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2388 if (strcmp (r[0], "/dev/sda1") != 0) {
2389 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2393 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2397 if (strcmp (r[1], "/dev/sda2") != 0) {
2398 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2402 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2406 if (strcmp (r[2], "/dev/sda3") != 0) {
2407 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2411 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2415 for (i = 0; r[i] != NULL; ++i)
2422 static int test_is_dir_0 (void)
2424 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2428 r = guestfs_umount_all (g);
2435 r = guestfs_lvm_remove_all (g);
2446 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2453 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2460 r = guestfs_mount (g, "/dev/sda1", "/");
2464 /* TestOutputFalse for is_dir (0) */
2468 r = guestfs_touch (g, "/new");
2475 r = guestfs_is_dir (g, "/new");
2479 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2486 static int test_is_dir_1 (void)
2488 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2492 r = guestfs_umount_all (g);
2499 r = guestfs_lvm_remove_all (g);
2510 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2517 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2524 r = guestfs_mount (g, "/dev/sda1", "/");
2528 /* TestOutputTrue for is_dir (1) */
2532 r = guestfs_mkdir (g, "/new");
2539 r = guestfs_is_dir (g, "/new");
2543 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2550 static int test_is_file_0 (void)
2552 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2556 r = guestfs_umount_all (g);
2563 r = guestfs_lvm_remove_all (g);
2574 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2581 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2588 r = guestfs_mount (g, "/dev/sda1", "/");
2592 /* TestOutputTrue for is_file (0) */
2596 r = guestfs_touch (g, "/new");
2603 r = guestfs_is_file (g, "/new");
2607 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2614 static int test_is_file_1 (void)
2616 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2620 r = guestfs_umount_all (g);
2627 r = guestfs_lvm_remove_all (g);
2638 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2645 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2652 r = guestfs_mount (g, "/dev/sda1", "/");
2656 /* TestOutputFalse for is_file (1) */
2660 r = guestfs_mkdir (g, "/new");
2667 r = guestfs_is_file (g, "/new");
2671 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2678 static int test_exists_0 (void)
2680 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2684 r = guestfs_umount_all (g);
2691 r = guestfs_lvm_remove_all (g);
2702 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2709 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2716 r = guestfs_mount (g, "/dev/sda1", "/");
2720 /* TestOutputTrue for exists (0) */
2724 r = guestfs_touch (g, "/new");
2731 r = guestfs_exists (g, "/new");
2735 fprintf (stderr, "test_exists_0: expected true, got false\n");
2742 static int test_exists_1 (void)
2744 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
2748 r = guestfs_umount_all (g);
2755 r = guestfs_lvm_remove_all (g);
2766 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2773 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2780 r = guestfs_mount (g, "/dev/sda1", "/");
2784 /* TestOutputTrue for exists (1) */
2788 r = guestfs_mkdir (g, "/new");
2795 r = guestfs_exists (g, "/new");
2799 fprintf (stderr, "test_exists_1: expected true, got false\n");
2806 static int test_mkdir_p_0 (void)
2808 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
2812 r = guestfs_umount_all (g);
2819 r = guestfs_lvm_remove_all (g);
2830 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2837 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2844 r = guestfs_mount (g, "/dev/sda1", "/");
2848 /* TestOutputTrue for mkdir_p (0) */
2852 r = guestfs_mkdir_p (g, "/new/foo/bar");
2859 r = guestfs_is_dir (g, "/new/foo/bar");
2863 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
2870 static int test_mkdir_p_1 (void)
2872 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
2876 r = guestfs_umount_all (g);
2883 r = guestfs_lvm_remove_all (g);
2894 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2901 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2908 r = guestfs_mount (g, "/dev/sda1", "/");
2912 /* TestOutputTrue for mkdir_p (1) */
2916 r = guestfs_mkdir_p (g, "/new/foo/bar");
2923 r = guestfs_is_dir (g, "/new/foo");
2927 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
2934 static int test_mkdir_p_2 (void)
2936 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
2940 r = guestfs_umount_all (g);
2947 r = guestfs_lvm_remove_all (g);
2958 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2965 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2972 r = guestfs_mount (g, "/dev/sda1", "/");
2976 /* TestOutputTrue for mkdir_p (2) */
2980 r = guestfs_mkdir_p (g, "/new/foo/bar");
2987 r = guestfs_is_dir (g, "/new");
2991 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
2998 static int test_mkdir_0 (void)
3000 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
3004 r = guestfs_umount_all (g);
3011 r = guestfs_lvm_remove_all (g);
3022 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3029 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3036 r = guestfs_mount (g, "/dev/sda1", "/");
3040 /* TestOutputTrue for mkdir (0) */
3044 r = guestfs_mkdir (g, "/new");
3051 r = guestfs_is_dir (g, "/new");
3055 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
3062 static int test_mkdir_1 (void)
3064 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
3068 r = guestfs_umount_all (g);
3075 r = guestfs_lvm_remove_all (g);
3086 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3093 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3100 r = guestfs_mount (g, "/dev/sda1", "/");
3104 /* TestLastFail for mkdir (1) */
3108 r = guestfs_mkdir (g, "/new/foo/bar");
3115 static int test_rm_rf_0 (void)
3117 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
3121 r = guestfs_umount_all (g);
3128 r = guestfs_lvm_remove_all (g);
3139 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3146 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3153 r = guestfs_mount (g, "/dev/sda1", "/");
3157 /* TestOutputFalse for rm_rf (0) */
3161 r = guestfs_mkdir (g, "/new");
3168 r = guestfs_mkdir (g, "/new/foo");
3175 r = guestfs_touch (g, "/new/foo/bar");
3182 r = guestfs_rm_rf (g, "/new");
3189 r = guestfs_exists (g, "/new");
3193 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
3200 static int test_rmdir_0 (void)
3202 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
3206 r = guestfs_umount_all (g);
3213 r = guestfs_lvm_remove_all (g);
3224 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3231 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3238 r = guestfs_mount (g, "/dev/sda1", "/");
3242 /* TestRun for rmdir (0) */
3246 r = guestfs_mkdir (g, "/new");
3253 r = guestfs_rmdir (g, "/new");
3260 static int test_rmdir_1 (void)
3262 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
3266 r = guestfs_umount_all (g);
3273 r = guestfs_lvm_remove_all (g);
3284 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3291 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3298 r = guestfs_mount (g, "/dev/sda1", "/");
3302 /* TestLastFail for rmdir (1) */
3306 r = guestfs_rmdir (g, "/new");
3313 static int test_rmdir_2 (void)
3315 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
3319 r = guestfs_umount_all (g);
3326 r = guestfs_lvm_remove_all (g);
3337 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3344 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3351 r = guestfs_mount (g, "/dev/sda1", "/");
3355 /* TestLastFail for rmdir (2) */
3359 r = guestfs_touch (g, "/new");
3366 r = guestfs_rmdir (g, "/new");
3373 static int test_rm_0 (void)
3375 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
3379 r = guestfs_umount_all (g);
3386 r = guestfs_lvm_remove_all (g);
3397 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3404 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3411 r = guestfs_mount (g, "/dev/sda1", "/");
3415 /* TestRun for rm (0) */
3419 r = guestfs_touch (g, "/new");
3426 r = guestfs_rm (g, "/new");
3433 static int test_rm_1 (void)
3435 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
3439 r = guestfs_umount_all (g);
3446 r = guestfs_lvm_remove_all (g);
3457 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3464 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3471 r = guestfs_mount (g, "/dev/sda1", "/");
3475 /* TestLastFail for rm (1) */
3479 r = guestfs_rm (g, "/new");
3486 static int test_rm_2 (void)
3488 /* InitBasicFS for rm (2): 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 rm (2) */
3532 r = guestfs_mkdir (g, "/new");
3539 r = guestfs_rm (g, "/new");
3546 static int test_read_lines_0 (void)
3548 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3552 r = guestfs_umount_all (g);
3559 r = guestfs_lvm_remove_all (g);
3570 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3577 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3584 r = guestfs_mount (g, "/dev/sda1", "/");
3588 /* TestOutputList for read_lines (0) */
3592 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
3600 r = guestfs_read_lines (g, "/new");
3604 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3608 if (strcmp (r[0], "line1") != 0) {
3609 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
3613 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3617 if (strcmp (r[1], "line2") != 0) {
3618 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
3622 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3626 if (strcmp (r[2], "line3") != 0) {
3627 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
3631 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
3635 for (i = 0; r[i] != NULL; ++i)
3642 static int test_read_lines_1 (void)
3644 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
3648 r = guestfs_umount_all (g);
3655 r = guestfs_lvm_remove_all (g);
3666 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3673 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3680 r = guestfs_mount (g, "/dev/sda1", "/");
3684 /* TestOutputList for read_lines (1) */
3688 r = guestfs_write_file (g, "/new", "", 0);
3696 r = guestfs_read_lines (g, "/new");
3700 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
3704 for (i = 0; r[i] != NULL; ++i)
3711 static int test_lvs_0 (void)
3713 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
3717 r = guestfs_umount_all (g);
3724 r = guestfs_lvm_remove_all (g);
3735 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3742 r = guestfs_pvcreate (g, "/dev/sda1");
3747 char *physvols[] = {
3753 r = guestfs_vgcreate (g, "VG", physvols);
3760 r = guestfs_lvcreate (g, "LV", "VG", 8);
3767 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3774 r = guestfs_mount (g, "/dev/VG/LV", "/");
3778 /* TestOutputList for lvs (0) */
3783 r = guestfs_lvs (g);
3787 fprintf (stderr, "test_lvs_0: short list returned from command\n");
3791 if (strcmp (r[0], "/dev/VG/LV") != 0) {
3792 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
3796 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
3800 for (i = 0; r[i] != NULL; ++i)
3807 static int test_lvs_1 (void)
3809 /* InitEmpty for lvs (1) */
3813 r = guestfs_umount_all (g);
3820 r = guestfs_lvm_remove_all (g);
3824 /* TestOutputList for lvs (1) */
3834 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3841 r = guestfs_pvcreate (g, "/dev/sda1");
3848 r = guestfs_pvcreate (g, "/dev/sda2");
3855 r = guestfs_pvcreate (g, "/dev/sda3");
3860 char *physvols[] = {
3867 r = guestfs_vgcreate (g, "VG1", physvols);
3872 char *physvols[] = {
3878 r = guestfs_vgcreate (g, "VG2", physvols);
3885 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
3892 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
3899 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
3907 r = guestfs_lvs (g);
3911 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3915 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
3916 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
3920 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3924 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
3925 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
3929 fprintf (stderr, "test_lvs_1: short list returned from command\n");
3933 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
3934 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
3938 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
3942 for (i = 0; r[i] != NULL; ++i)
3949 static int test_vgs_0 (void)
3951 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
3955 r = guestfs_umount_all (g);
3962 r = guestfs_lvm_remove_all (g);
3973 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3980 r = guestfs_pvcreate (g, "/dev/sda1");
3985 char *physvols[] = {
3991 r = guestfs_vgcreate (g, "VG", physvols);
3998 r = guestfs_lvcreate (g, "LV", "VG", 8);
4005 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4012 r = guestfs_mount (g, "/dev/VG/LV", "/");
4016 /* TestOutputList for vgs (0) */
4021 r = guestfs_vgs (g);
4025 fprintf (stderr, "test_vgs_0: short list returned from command\n");
4029 if (strcmp (r[0], "VG") != 0) {
4030 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
4034 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
4038 for (i = 0; r[i] != NULL; ++i)
4045 static int test_vgs_1 (void)
4047 /* InitEmpty for vgs (1) */
4051 r = guestfs_umount_all (g);
4058 r = guestfs_lvm_remove_all (g);
4062 /* TestOutputList for vgs (1) */
4072 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4079 r = guestfs_pvcreate (g, "/dev/sda1");
4086 r = guestfs_pvcreate (g, "/dev/sda2");
4093 r = guestfs_pvcreate (g, "/dev/sda3");
4098 char *physvols[] = {
4105 r = guestfs_vgcreate (g, "VG1", physvols);
4110 char *physvols[] = {
4116 r = guestfs_vgcreate (g, "VG2", physvols);
4124 r = guestfs_vgs (g);
4128 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4132 if (strcmp (r[0], "VG1") != 0) {
4133 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
4137 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4141 if (strcmp (r[1], "VG2") != 0) {
4142 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
4146 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
4150 for (i = 0; r[i] != NULL; ++i)
4157 static int test_pvs_0 (void)
4159 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
4163 r = guestfs_umount_all (g);
4170 r = guestfs_lvm_remove_all (g);
4181 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4188 r = guestfs_pvcreate (g, "/dev/sda1");
4193 char *physvols[] = {
4199 r = guestfs_vgcreate (g, "VG", physvols);
4206 r = guestfs_lvcreate (g, "LV", "VG", 8);
4213 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4220 r = guestfs_mount (g, "/dev/VG/LV", "/");
4224 /* TestOutputList for pvs (0) */
4229 r = guestfs_pvs (g);
4233 fprintf (stderr, "test_pvs_0: short list returned from command\n");
4237 if (strcmp (r[0], "/dev/sda1") != 0) {
4238 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4242 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
4246 for (i = 0; r[i] != NULL; ++i)
4253 static int test_pvs_1 (void)
4255 /* InitEmpty for pvs (1) */
4259 r = guestfs_umount_all (g);
4266 r = guestfs_lvm_remove_all (g);
4270 /* TestOutputList for pvs (1) */
4280 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4287 r = guestfs_pvcreate (g, "/dev/sda1");
4294 r = guestfs_pvcreate (g, "/dev/sda2");
4301 r = guestfs_pvcreate (g, "/dev/sda3");
4309 r = guestfs_pvs (g);
4313 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4317 if (strcmp (r[0], "/dev/sda1") != 0) {
4318 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4322 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4326 if (strcmp (r[1], "/dev/sda2") != 0) {
4327 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4331 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4335 if (strcmp (r[2], "/dev/sda3") != 0) {
4336 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4340 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
4344 for (i = 0; r[i] != NULL; ++i)
4351 static int test_list_partitions_0 (void)
4353 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
4357 r = guestfs_umount_all (g);
4364 r = guestfs_lvm_remove_all (g);
4375 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4382 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4389 r = guestfs_mount (g, "/dev/sda1", "/");
4393 /* TestOutputList for list_partitions (0) */
4398 r = guestfs_list_partitions (g);
4402 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
4406 if (strcmp (r[0], "/dev/sda1") != 0) {
4407 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4411 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
4415 for (i = 0; r[i] != NULL; ++i)
4422 static int test_list_partitions_1 (void)
4424 /* InitEmpty for list_partitions (1) */
4428 r = guestfs_umount_all (g);
4435 r = guestfs_lvm_remove_all (g);
4439 /* TestOutputList for list_partitions (1) */
4449 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4457 r = guestfs_list_partitions (g);
4461 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4465 if (strcmp (r[0], "/dev/sda1") != 0) {
4466 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4470 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4474 if (strcmp (r[1], "/dev/sda2") != 0) {
4475 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4479 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4483 if (strcmp (r[2], "/dev/sda3") != 0) {
4484 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4488 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
4492 for (i = 0; r[i] != NULL; ++i)
4499 static int test_list_devices_0 (void)
4501 /* InitEmpty for list_devices (0) */
4505 r = guestfs_umount_all (g);
4512 r = guestfs_lvm_remove_all (g);
4516 /* TestOutputList for list_devices (0) */
4521 r = guestfs_list_devices (g);
4525 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4529 if (strcmp (r[0], "/dev/sda") != 0) {
4530 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4534 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4538 if (strcmp (r[1], "/dev/sdb") != 0) {
4539 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4543 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4547 if (strcmp (r[2], "/dev/sdc") != 0) {
4548 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4552 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4556 for (i = 0; r[i] != NULL; ++i)
4563 static int test_ls_0 (void)
4565 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4569 r = guestfs_umount_all (g);
4576 r = guestfs_lvm_remove_all (g);
4587 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4594 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4601 r = guestfs_mount (g, "/dev/sda1", "/");
4605 /* TestOutputList for ls (0) */
4609 r = guestfs_touch (g, "/new");
4616 r = guestfs_touch (g, "/newer");
4623 r = guestfs_touch (g, "/newest");
4631 r = guestfs_ls (g, "/");
4635 fprintf (stderr, "test_ls_0: short list returned from command\n");
4639 if (strcmp (r[0], "lost+found") != 0) {
4640 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
4644 fprintf (stderr, "test_ls_0: short list returned from command\n");
4648 if (strcmp (r[1], "new") != 0) {
4649 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
4653 fprintf (stderr, "test_ls_0: short list returned from command\n");
4657 if (strcmp (r[2], "newer") != 0) {
4658 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
4662 fprintf (stderr, "test_ls_0: short list returned from command\n");
4666 if (strcmp (r[3], "newest") != 0) {
4667 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
4671 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
4675 for (i = 0; r[i] != NULL; ++i)
4682 static int test_cat_0 (void)
4684 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
4688 r = guestfs_umount_all (g);
4695 r = guestfs_lvm_remove_all (g);
4706 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4713 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4720 r = guestfs_mount (g, "/dev/sda1", "/");
4724 /* TestOutput for cat (0) */
4728 r = guestfs_write_file (g, "/new", "new file contents", 0);
4735 r = guestfs_cat (g, "/new");
4738 if (strcmp (r, "new file contents") != 0) {
4739 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
4747 static int test_touch_0 (void)
4749 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
4753 r = guestfs_umount_all (g);
4760 r = guestfs_lvm_remove_all (g);
4771 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4778 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4785 r = guestfs_mount (g, "/dev/sda1", "/");
4789 /* TestOutputTrue for touch (0) */
4793 r = guestfs_touch (g, "/new");
4800 r = guestfs_exists (g, "/new");
4804 fprintf (stderr, "test_touch_0: expected true, got false\n");
4811 static int test_sync_0 (void)
4813 /* InitEmpty for sync (0) */
4817 r = guestfs_umount_all (g);
4824 r = guestfs_lvm_remove_all (g);
4828 /* TestRun for sync (0) */
4832 r = guestfs_sync (g);
4839 static int test_mount_0 (void)
4841 /* InitEmpty for mount (0) */
4845 r = guestfs_umount_all (g);
4852 r = guestfs_lvm_remove_all (g);
4856 /* TestOutput for mount (0) */
4864 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4871 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4878 r = guestfs_mount (g, "/dev/sda1", "/");
4885 r = guestfs_write_file (g, "/new", "new file contents", 0);
4892 r = guestfs_cat (g, "/new");
4895 if (strcmp (r, "new file contents") != 0) {
4896 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
4904 int main (int argc, char *argv[])
4911 int nr_tests, test_num = 0;
4913 no_test_warnings ();
4915 g = guestfs_create ();
4917 printf ("guestfs_create FAILED\n");
4921 guestfs_set_error_handler (g, print_error, NULL);
4923 srcdir = getenv ("srcdir");
4924 if (!srcdir) srcdir = ".";
4925 guestfs_set_path (g, srcdir);
4927 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
4928 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4933 if (lseek (fd, 524288000, SEEK_SET) == -1) {
4939 if (write (fd, &c, 1) == -1) {
4945 if (close (fd) == -1) {
4950 if (guestfs_add_drive (g, buf) == -1) {
4951 printf ("guestfs_add_drive %s FAILED\n", buf);
4955 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
4956 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4961 if (lseek (fd, 52428800, SEEK_SET) == -1) {
4967 if (write (fd, &c, 1) == -1) {
4973 if (close (fd) == -1) {
4978 if (guestfs_add_drive (g, buf) == -1) {
4979 printf ("guestfs_add_drive %s FAILED\n", buf);
4983 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
4984 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
4989 if (lseek (fd, 10485760, SEEK_SET) == -1) {
4995 if (write (fd, &c, 1) == -1) {
5001 if (close (fd) == -1) {
5006 if (guestfs_add_drive (g, buf) == -1) {
5007 printf ("guestfs_add_drive %s FAILED\n", buf);
5011 if (guestfs_launch (g) == -1) {
5012 printf ("guestfs_launch FAILED\n");
5015 if (guestfs_wait_ready (g) == -1) {
5016 printf ("guestfs_wait_ready FAILED\n");
5023 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
5024 if (test_checksum_0 () == -1) {
5025 printf ("test_checksum_0 FAILED\n");
5029 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
5030 if (test_checksum_1 () == -1) {
5031 printf ("test_checksum_1 FAILED\n");
5035 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
5036 if (test_checksum_2 () == -1) {
5037 printf ("test_checksum_2 FAILED\n");
5041 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
5042 if (test_checksum_3 () == -1) {
5043 printf ("test_checksum_3 FAILED\n");
5047 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
5048 if (test_checksum_4 () == -1) {
5049 printf ("test_checksum_4 FAILED\n");
5053 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
5054 if (test_checksum_5 () == -1) {
5055 printf ("test_checksum_5 FAILED\n");
5059 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
5060 if (test_checksum_6 () == -1) {
5061 printf ("test_checksum_6 FAILED\n");
5065 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
5066 if (test_checksum_7 () == -1) {
5067 printf ("test_checksum_7 FAILED\n");
5071 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
5072 if (test_blockdev_rereadpt_0 () == -1) {
5073 printf ("test_blockdev_rereadpt_0 FAILED\n");
5077 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
5078 if (test_blockdev_flushbufs_0 () == -1) {
5079 printf ("test_blockdev_flushbufs_0 FAILED\n");
5083 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
5084 if (test_blockdev_getsize64_0 () == -1) {
5085 printf ("test_blockdev_getsize64_0 FAILED\n");
5089 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
5090 if (test_blockdev_getsz_0 () == -1) {
5091 printf ("test_blockdev_getsz_0 FAILED\n");
5095 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
5096 if (test_blockdev_getbsz_0 () == -1) {
5097 printf ("test_blockdev_getbsz_0 FAILED\n");
5101 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
5102 if (test_blockdev_getss_0 () == -1) {
5103 printf ("test_blockdev_getss_0 FAILED\n");
5107 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
5108 if (test_blockdev_getro_0 () == -1) {
5109 printf ("test_blockdev_getro_0 FAILED\n");
5113 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
5114 if (test_blockdev_setrw_0 () == -1) {
5115 printf ("test_blockdev_setrw_0 FAILED\n");
5119 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
5120 if (test_blockdev_setro_0 () == -1) {
5121 printf ("test_blockdev_setro_0 FAILED\n");
5125 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
5126 if (test_statvfs_0 () == -1) {
5127 printf ("test_statvfs_0 FAILED\n");
5131 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
5132 if (test_lstat_0 () == -1) {
5133 printf ("test_lstat_0 FAILED\n");
5137 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
5138 if (test_stat_0 () == -1) {
5139 printf ("test_stat_0 FAILED\n");
5143 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
5144 if (test_file_0 () == -1) {
5145 printf ("test_file_0 FAILED\n");
5149 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
5150 if (test_file_1 () == -1) {
5151 printf ("test_file_1 FAILED\n");
5155 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
5156 if (test_file_2 () == -1) {
5157 printf ("test_file_2 FAILED\n");
5161 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
5162 if (test_umount_all_0 () == -1) {
5163 printf ("test_umount_all_0 FAILED\n");
5167 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
5168 if (test_mounts_0 () == -1) {
5169 printf ("test_mounts_0 FAILED\n");
5173 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
5174 if (test_umount_0 () == -1) {
5175 printf ("test_umount_0 FAILED\n");
5179 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
5180 if (test_umount_1 () == -1) {
5181 printf ("test_umount_1 FAILED\n");
5185 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
5186 if (test_write_file_0 () == -1) {
5187 printf ("test_write_file_0 FAILED\n");
5191 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
5192 if (test_write_file_1 () == -1) {
5193 printf ("test_write_file_1 FAILED\n");
5197 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
5198 if (test_write_file_2 () == -1) {
5199 printf ("test_write_file_2 FAILED\n");
5203 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
5204 if (test_write_file_3 () == -1) {
5205 printf ("test_write_file_3 FAILED\n");
5209 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
5210 if (test_write_file_4 () == -1) {
5211 printf ("test_write_file_4 FAILED\n");
5215 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
5216 if (test_write_file_5 () == -1) {
5217 printf ("test_write_file_5 FAILED\n");
5221 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
5222 if (test_mkfs_0 () == -1) {
5223 printf ("test_mkfs_0 FAILED\n");
5227 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
5228 if (test_lvcreate_0 () == -1) {
5229 printf ("test_lvcreate_0 FAILED\n");
5233 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
5234 if (test_vgcreate_0 () == -1) {
5235 printf ("test_vgcreate_0 FAILED\n");
5239 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
5240 if (test_pvcreate_0 () == -1) {
5241 printf ("test_pvcreate_0 FAILED\n");
5245 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
5246 if (test_is_dir_0 () == -1) {
5247 printf ("test_is_dir_0 FAILED\n");
5251 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
5252 if (test_is_dir_1 () == -1) {
5253 printf ("test_is_dir_1 FAILED\n");
5257 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
5258 if (test_is_file_0 () == -1) {
5259 printf ("test_is_file_0 FAILED\n");
5263 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
5264 if (test_is_file_1 () == -1) {
5265 printf ("test_is_file_1 FAILED\n");
5269 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
5270 if (test_exists_0 () == -1) {
5271 printf ("test_exists_0 FAILED\n");
5275 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
5276 if (test_exists_1 () == -1) {
5277 printf ("test_exists_1 FAILED\n");
5281 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
5282 if (test_mkdir_p_0 () == -1) {
5283 printf ("test_mkdir_p_0 FAILED\n");
5287 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
5288 if (test_mkdir_p_1 () == -1) {
5289 printf ("test_mkdir_p_1 FAILED\n");
5293 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
5294 if (test_mkdir_p_2 () == -1) {
5295 printf ("test_mkdir_p_2 FAILED\n");
5299 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
5300 if (test_mkdir_0 () == -1) {
5301 printf ("test_mkdir_0 FAILED\n");
5305 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
5306 if (test_mkdir_1 () == -1) {
5307 printf ("test_mkdir_1 FAILED\n");
5311 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
5312 if (test_rm_rf_0 () == -1) {
5313 printf ("test_rm_rf_0 FAILED\n");
5317 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
5318 if (test_rmdir_0 () == -1) {
5319 printf ("test_rmdir_0 FAILED\n");
5323 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
5324 if (test_rmdir_1 () == -1) {
5325 printf ("test_rmdir_1 FAILED\n");
5329 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
5330 if (test_rmdir_2 () == -1) {
5331 printf ("test_rmdir_2 FAILED\n");
5335 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
5336 if (test_rm_0 () == -1) {
5337 printf ("test_rm_0 FAILED\n");
5341 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
5342 if (test_rm_1 () == -1) {
5343 printf ("test_rm_1 FAILED\n");
5347 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
5348 if (test_rm_2 () == -1) {
5349 printf ("test_rm_2 FAILED\n");
5353 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
5354 if (test_read_lines_0 () == -1) {
5355 printf ("test_read_lines_0 FAILED\n");
5359 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
5360 if (test_read_lines_1 () == -1) {
5361 printf ("test_read_lines_1 FAILED\n");
5365 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
5366 if (test_lvs_0 () == -1) {
5367 printf ("test_lvs_0 FAILED\n");
5371 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
5372 if (test_lvs_1 () == -1) {
5373 printf ("test_lvs_1 FAILED\n");
5377 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
5378 if (test_vgs_0 () == -1) {
5379 printf ("test_vgs_0 FAILED\n");
5383 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
5384 if (test_vgs_1 () == -1) {
5385 printf ("test_vgs_1 FAILED\n");
5389 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
5390 if (test_pvs_0 () == -1) {
5391 printf ("test_pvs_0 FAILED\n");
5395 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
5396 if (test_pvs_1 () == -1) {
5397 printf ("test_pvs_1 FAILED\n");
5401 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
5402 if (test_list_partitions_0 () == -1) {
5403 printf ("test_list_partitions_0 FAILED\n");
5407 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
5408 if (test_list_partitions_1 () == -1) {
5409 printf ("test_list_partitions_1 FAILED\n");
5413 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
5414 if (test_list_devices_0 () == -1) {
5415 printf ("test_list_devices_0 FAILED\n");
5419 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
5420 if (test_ls_0 () == -1) {
5421 printf ("test_ls_0 FAILED\n");
5425 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
5426 if (test_cat_0 () == -1) {
5427 printf ("test_cat_0 FAILED\n");
5431 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
5432 if (test_touch_0 () == -1) {
5433 printf ("test_touch_0 FAILED\n");
5437 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
5438 if (test_sync_0 () == -1) {
5439 printf ("test_sync_0 FAILED\n");
5443 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
5444 if (test_mount_0 () == -1) {
5445 printf ("test_mount_0 FAILED\n");
5450 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
5452 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
5454 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
5458 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);