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");
110 static int test_tgz_in_0 (void)
112 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
116 r = guestfs_umount_all (g);
123 r = guestfs_lvm_remove_all (g);
134 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
141 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
148 r = guestfs_mount (g, "/dev/sda1", "/");
152 /* TestOutput for tgz_in (0) */
156 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
163 r = guestfs_cat (g, "/hello");
166 if (strcmp (r, "hello\n") != 0) {
167 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
175 static int test_tar_in_0 (void)
177 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
181 r = guestfs_umount_all (g);
188 r = guestfs_lvm_remove_all (g);
199 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
206 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
213 r = guestfs_mount (g, "/dev/sda1", "/");
217 /* TestOutput for tar_in (0) */
221 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
228 r = guestfs_cat (g, "/hello");
231 if (strcmp (r, "hello\n") != 0) {
232 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
240 static int test_checksum_0 (void)
242 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
246 r = guestfs_umount_all (g);
253 r = guestfs_lvm_remove_all (g);
264 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
271 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
278 r = guestfs_mount (g, "/dev/sda1", "/");
282 /* TestOutput for checksum (0) */
286 r = guestfs_write_file (g, "/new", "test\n", 0);
293 r = guestfs_checksum (g, "crc", "/new");
296 if (strcmp (r, "935282863") != 0) {
297 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
305 static int test_checksum_1 (void)
307 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
311 r = guestfs_umount_all (g);
318 r = guestfs_lvm_remove_all (g);
329 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
336 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
343 r = guestfs_mount (g, "/dev/sda1", "/");
347 /* TestLastFail for checksum (1) */
351 r = guestfs_checksum (g, "crc", "/new");
359 static int test_checksum_2 (void)
361 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
365 r = guestfs_umount_all (g);
372 r = guestfs_lvm_remove_all (g);
383 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
390 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
397 r = guestfs_mount (g, "/dev/sda1", "/");
401 /* TestOutput for checksum (2) */
405 r = guestfs_write_file (g, "/new", "test\n", 0);
412 r = guestfs_checksum (g, "md5", "/new");
415 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
416 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
424 static int test_checksum_3 (void)
426 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
430 r = guestfs_umount_all (g);
437 r = guestfs_lvm_remove_all (g);
448 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
455 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
462 r = guestfs_mount (g, "/dev/sda1", "/");
466 /* TestOutput for checksum (3) */
470 r = guestfs_write_file (g, "/new", "test\n", 0);
477 r = guestfs_checksum (g, "sha1", "/new");
480 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
481 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
489 static int test_checksum_4 (void)
491 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
495 r = guestfs_umount_all (g);
502 r = guestfs_lvm_remove_all (g);
513 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
520 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
527 r = guestfs_mount (g, "/dev/sda1", "/");
531 /* TestOutput for checksum (4) */
535 r = guestfs_write_file (g, "/new", "test\n", 0);
542 r = guestfs_checksum (g, "sha224", "/new");
545 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
546 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
554 static int test_checksum_5 (void)
556 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
560 r = guestfs_umount_all (g);
567 r = guestfs_lvm_remove_all (g);
578 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
585 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
592 r = guestfs_mount (g, "/dev/sda1", "/");
596 /* TestOutput for checksum (5) */
600 r = guestfs_write_file (g, "/new", "test\n", 0);
607 r = guestfs_checksum (g, "sha256", "/new");
610 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
611 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
619 static int test_checksum_6 (void)
621 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
625 r = guestfs_umount_all (g);
632 r = guestfs_lvm_remove_all (g);
643 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
650 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
657 r = guestfs_mount (g, "/dev/sda1", "/");
661 /* TestOutput for checksum (6) */
665 r = guestfs_write_file (g, "/new", "test\n", 0);
672 r = guestfs_checksum (g, "sha384", "/new");
675 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
676 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
684 static int test_checksum_7 (void)
686 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
690 r = guestfs_umount_all (g);
697 r = guestfs_lvm_remove_all (g);
708 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
715 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
722 r = guestfs_mount (g, "/dev/sda1", "/");
726 /* TestOutput for checksum (7) */
730 r = guestfs_write_file (g, "/new", "test\n", 0);
737 r = guestfs_checksum (g, "sha512", "/new");
740 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
741 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
749 static int test_download_0 (void)
751 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
755 r = guestfs_umount_all (g);
762 r = guestfs_lvm_remove_all (g);
773 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
780 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
787 r = guestfs_mount (g, "/dev/sda1", "/");
791 /* TestOutput for download (0) */
795 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
802 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
809 r = guestfs_upload (g, "testdownload.tmp", "/upload");
816 r = guestfs_checksum (g, "md5", "/upload");
819 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
820 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
828 static int test_upload_0 (void)
830 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
834 r = guestfs_umount_all (g);
841 r = guestfs_lvm_remove_all (g);
852 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
859 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
866 r = guestfs_mount (g, "/dev/sda1", "/");
870 /* TestOutput for upload (0) */
874 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
881 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
884 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
885 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
893 static int test_blockdev_rereadpt_0 (void)
895 /* InitEmpty for blockdev_rereadpt (0) */
899 r = guestfs_umount_all (g);
906 r = guestfs_lvm_remove_all (g);
910 /* TestRun for blockdev_rereadpt (0) */
914 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
921 static int test_blockdev_flushbufs_0 (void)
923 /* InitEmpty for blockdev_flushbufs (0) */
927 r = guestfs_umount_all (g);
934 r = guestfs_lvm_remove_all (g);
938 /* TestRun for blockdev_flushbufs (0) */
942 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
949 static int test_blockdev_getsize64_0 (void)
951 /* InitEmpty for blockdev_getsize64 (0) */
955 r = guestfs_umount_all (g);
962 r = guestfs_lvm_remove_all (g);
966 /* TestOutputInt for blockdev_getsize64 (0) */
970 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
973 if (r != 524288000) {
974 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
981 static int test_blockdev_getsz_0 (void)
983 /* InitEmpty for blockdev_getsz (0) */
987 r = guestfs_umount_all (g);
994 r = guestfs_lvm_remove_all (g);
998 /* TestOutputInt for blockdev_getsz (0) */
1002 r = guestfs_blockdev_getsz (g, "/dev/sda");
1006 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
1013 static int test_blockdev_getbsz_0 (void)
1015 /* InitEmpty for blockdev_getbsz (0) */
1019 r = guestfs_umount_all (g);
1026 r = guestfs_lvm_remove_all (g);
1030 /* TestOutputInt for blockdev_getbsz (0) */
1034 r = guestfs_blockdev_getbsz (g, "/dev/sda");
1038 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
1045 static int test_blockdev_getss_0 (void)
1047 /* InitEmpty for blockdev_getss (0) */
1051 r = guestfs_umount_all (g);
1058 r = guestfs_lvm_remove_all (g);
1062 /* TestOutputInt for blockdev_getss (0) */
1066 r = guestfs_blockdev_getss (g, "/dev/sda");
1070 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
1077 static int test_blockdev_getro_0 (void)
1079 /* InitEmpty for blockdev_getro (0) */
1083 r = guestfs_umount_all (g);
1090 r = guestfs_lvm_remove_all (g);
1094 /* TestOutputTrue for blockdev_getro (0) */
1098 r = guestfs_blockdev_setro (g, "/dev/sda");
1105 r = guestfs_blockdev_getro (g, "/dev/sda");
1109 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
1116 static int test_blockdev_setrw_0 (void)
1118 /* InitEmpty for blockdev_setrw (0) */
1122 r = guestfs_umount_all (g);
1129 r = guestfs_lvm_remove_all (g);
1133 /* TestOutputFalse for blockdev_setrw (0) */
1137 r = guestfs_blockdev_setrw (g, "/dev/sda");
1144 r = guestfs_blockdev_getro (g, "/dev/sda");
1148 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
1155 static int test_blockdev_setro_0 (void)
1157 /* InitEmpty for blockdev_setro (0) */
1161 r = guestfs_umount_all (g);
1168 r = guestfs_lvm_remove_all (g);
1172 /* TestOutputTrue for blockdev_setro (0) */
1176 r = guestfs_blockdev_setro (g, "/dev/sda");
1183 r = guestfs_blockdev_getro (g, "/dev/sda");
1187 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
1194 static int test_statvfs_0 (void)
1196 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
1200 r = guestfs_umount_all (g);
1207 r = guestfs_lvm_remove_all (g);
1218 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1225 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1232 r = guestfs_mount (g, "/dev/sda1", "/");
1236 /* TestOutputStruct for statvfs (0) */
1238 struct guestfs_statvfs *r;
1240 r = guestfs_statvfs (g, "/");
1243 if (r->bfree != 487702) {
1244 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
1248 if (r->blocks != 490020) {
1249 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
1253 if (r->bsize != 1024) {
1254 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
1263 static int test_lstat_0 (void)
1265 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
1269 r = guestfs_umount_all (g);
1276 r = guestfs_lvm_remove_all (g);
1287 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1294 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1301 r = guestfs_mount (g, "/dev/sda1", "/");
1305 /* TestOutputStruct for lstat (0) */
1309 r = guestfs_touch (g, "/new");
1314 struct guestfs_stat *r;
1316 r = guestfs_lstat (g, "/new");
1320 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
1329 static int test_stat_0 (void)
1331 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
1335 r = guestfs_umount_all (g);
1342 r = guestfs_lvm_remove_all (g);
1353 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1360 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1367 r = guestfs_mount (g, "/dev/sda1", "/");
1371 /* TestOutputStruct for stat (0) */
1375 r = guestfs_touch (g, "/new");
1380 struct guestfs_stat *r;
1382 r = guestfs_stat (g, "/new");
1386 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
1395 static int test_file_0 (void)
1397 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
1401 r = guestfs_umount_all (g);
1408 r = guestfs_lvm_remove_all (g);
1419 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1426 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1433 r = guestfs_mount (g, "/dev/sda1", "/");
1437 /* TestOutput for file (0) */
1441 r = guestfs_touch (g, "/new");
1448 r = guestfs_file (g, "/new");
1451 if (strcmp (r, "empty") != 0) {
1452 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
1460 static int test_file_1 (void)
1462 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
1466 r = guestfs_umount_all (g);
1473 r = guestfs_lvm_remove_all (g);
1484 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1491 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1498 r = guestfs_mount (g, "/dev/sda1", "/");
1502 /* TestOutput for file (1) */
1506 r = guestfs_write_file (g, "/new", "some content\n", 0);
1513 r = guestfs_file (g, "/new");
1516 if (strcmp (r, "ASCII text") != 0) {
1517 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
1525 static int test_file_2 (void)
1527 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
1531 r = guestfs_umount_all (g);
1538 r = guestfs_lvm_remove_all (g);
1549 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1556 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1563 r = guestfs_mount (g, "/dev/sda1", "/");
1567 /* TestLastFail for file (2) */
1571 r = guestfs_file (g, "/nofile");
1579 static int test_umount_all_0 (void)
1581 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
1585 r = guestfs_umount_all (g);
1592 r = guestfs_lvm_remove_all (g);
1603 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1610 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1617 r = guestfs_mount (g, "/dev/sda1", "/");
1621 /* TestOutputList for umount_all (0) */
1625 r = guestfs_umount_all (g);
1633 r = guestfs_mounts (g);
1637 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
1641 for (i = 0; r[i] != NULL; ++i)
1648 static int test_mounts_0 (void)
1650 /* InitBasicFS for mounts (0): 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 /* TestOutputList for mounts (0) */
1695 r = guestfs_mounts (g);
1699 fprintf (stderr, "test_mounts_0: short list returned from command\n");
1703 if (strcmp (r[0], "/dev/sda1") != 0) {
1704 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1708 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
1712 for (i = 0; r[i] != NULL; ++i)
1719 static int test_umount_0 (void)
1721 /* InitEmpty for umount (0) */
1725 r = guestfs_umount_all (g);
1732 r = guestfs_lvm_remove_all (g);
1736 /* TestOutputList for umount (0) */
1744 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1751 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1758 r = guestfs_mount (g, "/dev/sda1", "/");
1766 r = guestfs_mounts (g);
1770 fprintf (stderr, "test_umount_0: short list returned from command\n");
1774 if (strcmp (r[0], "/dev/sda1") != 0) {
1775 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1779 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
1783 for (i = 0; r[i] != NULL; ++i)
1790 static int test_umount_1 (void)
1792 /* InitEmpty for umount (1) */
1796 r = guestfs_umount_all (g);
1803 r = guestfs_lvm_remove_all (g);
1807 /* TestOutputList for umount (1) */
1815 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1822 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1829 r = guestfs_mount (g, "/dev/sda1", "/");
1836 r = guestfs_umount (g, "/");
1844 r = guestfs_mounts (g);
1848 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
1852 for (i = 0; r[i] != NULL; ++i)
1859 static int test_write_file_0 (void)
1861 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
1865 r = guestfs_umount_all (g);
1872 r = guestfs_lvm_remove_all (g);
1883 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1890 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1897 r = guestfs_mount (g, "/dev/sda1", "/");
1901 /* TestOutput for write_file (0) */
1905 r = guestfs_write_file (g, "/new", "new file contents", 0);
1912 r = guestfs_cat (g, "/new");
1915 if (strcmp (r, "new file contents") != 0) {
1916 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
1924 static int test_write_file_1 (void)
1926 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
1930 r = guestfs_umount_all (g);
1937 r = guestfs_lvm_remove_all (g);
1948 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1955 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1962 r = guestfs_mount (g, "/dev/sda1", "/");
1966 /* TestOutput for write_file (1) */
1970 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
1977 r = guestfs_cat (g, "/new");
1980 if (strcmp (r, "\nnew file contents\n") != 0) {
1981 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
1989 static int test_write_file_2 (void)
1991 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
1995 r = guestfs_umount_all (g);
2002 r = guestfs_lvm_remove_all (g);
2013 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2020 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2027 r = guestfs_mount (g, "/dev/sda1", "/");
2031 /* TestOutput for write_file (2) */
2035 r = guestfs_write_file (g, "/new", "\n\n", 0);
2042 r = guestfs_cat (g, "/new");
2045 if (strcmp (r, "\n\n") != 0) {
2046 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
2054 static int test_write_file_3 (void)
2056 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
2060 r = guestfs_umount_all (g);
2067 r = guestfs_lvm_remove_all (g);
2078 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2085 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2092 r = guestfs_mount (g, "/dev/sda1", "/");
2096 /* TestOutput for write_file (3) */
2100 r = guestfs_write_file (g, "/new", "", 0);
2107 r = guestfs_cat (g, "/new");
2110 if (strcmp (r, "") != 0) {
2111 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
2119 static int test_write_file_4 (void)
2121 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
2125 r = guestfs_umount_all (g);
2132 r = guestfs_lvm_remove_all (g);
2143 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2150 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2157 r = guestfs_mount (g, "/dev/sda1", "/");
2161 /* TestOutput for write_file (4) */
2165 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
2172 r = guestfs_cat (g, "/new");
2175 if (strcmp (r, "\n\n\n") != 0) {
2176 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
2184 static int test_write_file_5 (void)
2186 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
2190 r = guestfs_umount_all (g);
2197 r = guestfs_lvm_remove_all (g);
2208 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2215 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2222 r = guestfs_mount (g, "/dev/sda1", "/");
2226 /* TestOutput for write_file (5) */
2230 r = guestfs_write_file (g, "/new", "\n", 0);
2237 r = guestfs_cat (g, "/new");
2240 if (strcmp (r, "\n") != 0) {
2241 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
2249 static int test_mkfs_0 (void)
2251 /* InitEmpty for mkfs (0) */
2255 r = guestfs_umount_all (g);
2262 r = guestfs_lvm_remove_all (g);
2266 /* TestOutput for mkfs (0) */
2274 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2281 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2288 r = guestfs_mount (g, "/dev/sda1", "/");
2295 r = guestfs_write_file (g, "/new", "new file contents", 0);
2302 r = guestfs_cat (g, "/new");
2305 if (strcmp (r, "new file contents") != 0) {
2306 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
2314 static int test_lvcreate_0 (void)
2316 /* InitEmpty for lvcreate (0) */
2320 r = guestfs_umount_all (g);
2327 r = guestfs_lvm_remove_all (g);
2331 /* TestOutputList for lvcreate (0) */
2341 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2348 r = guestfs_pvcreate (g, "/dev/sda1");
2355 r = guestfs_pvcreate (g, "/dev/sda2");
2362 r = guestfs_pvcreate (g, "/dev/sda3");
2367 char *physvols[] = {
2374 r = guestfs_vgcreate (g, "VG1", physvols);
2379 char *physvols[] = {
2385 r = guestfs_vgcreate (g, "VG2", physvols);
2392 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2399 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2406 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2413 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2420 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2428 r = guestfs_lvs (g);
2432 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2436 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2437 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2441 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2445 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2446 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2450 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2454 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2455 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2459 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2463 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2464 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2468 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2472 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2473 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2477 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2481 for (i = 0; r[i] != NULL; ++i)
2488 static int test_vgcreate_0 (void)
2490 /* InitEmpty for vgcreate (0) */
2494 r = guestfs_umount_all (g);
2501 r = guestfs_lvm_remove_all (g);
2505 /* TestOutputList for vgcreate (0) */
2515 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2522 r = guestfs_pvcreate (g, "/dev/sda1");
2529 r = guestfs_pvcreate (g, "/dev/sda2");
2536 r = guestfs_pvcreate (g, "/dev/sda3");
2541 char *physvols[] = {
2548 r = guestfs_vgcreate (g, "VG1", physvols);
2553 char *physvols[] = {
2559 r = guestfs_vgcreate (g, "VG2", physvols);
2567 r = guestfs_vgs (g);
2571 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2575 if (strcmp (r[0], "VG1") != 0) {
2576 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2580 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2584 if (strcmp (r[1], "VG2") != 0) {
2585 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2589 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2593 for (i = 0; r[i] != NULL; ++i)
2600 static int test_pvcreate_0 (void)
2602 /* InitEmpty for pvcreate (0) */
2606 r = guestfs_umount_all (g);
2613 r = guestfs_lvm_remove_all (g);
2617 /* TestOutputList for pvcreate (0) */
2627 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2634 r = guestfs_pvcreate (g, "/dev/sda1");
2641 r = guestfs_pvcreate (g, "/dev/sda2");
2648 r = guestfs_pvcreate (g, "/dev/sda3");
2656 r = guestfs_pvs (g);
2660 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2664 if (strcmp (r[0], "/dev/sda1") != 0) {
2665 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2669 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2673 if (strcmp (r[1], "/dev/sda2") != 0) {
2674 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2678 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2682 if (strcmp (r[2], "/dev/sda3") != 0) {
2683 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2687 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2691 for (i = 0; r[i] != NULL; ++i)
2698 static int test_is_dir_0 (void)
2700 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2704 r = guestfs_umount_all (g);
2711 r = guestfs_lvm_remove_all (g);
2722 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2729 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2736 r = guestfs_mount (g, "/dev/sda1", "/");
2740 /* TestOutputFalse for is_dir (0) */
2744 r = guestfs_touch (g, "/new");
2751 r = guestfs_is_dir (g, "/new");
2755 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2762 static int test_is_dir_1 (void)
2764 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2768 r = guestfs_umount_all (g);
2775 r = guestfs_lvm_remove_all (g);
2786 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2793 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2800 r = guestfs_mount (g, "/dev/sda1", "/");
2804 /* TestOutputTrue for is_dir (1) */
2808 r = guestfs_mkdir (g, "/new");
2815 r = guestfs_is_dir (g, "/new");
2819 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2826 static int test_is_file_0 (void)
2828 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2832 r = guestfs_umount_all (g);
2839 r = guestfs_lvm_remove_all (g);
2850 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2857 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2864 r = guestfs_mount (g, "/dev/sda1", "/");
2868 /* TestOutputTrue for is_file (0) */
2872 r = guestfs_touch (g, "/new");
2879 r = guestfs_is_file (g, "/new");
2883 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2890 static int test_is_file_1 (void)
2892 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2896 r = guestfs_umount_all (g);
2903 r = guestfs_lvm_remove_all (g);
2914 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2921 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2928 r = guestfs_mount (g, "/dev/sda1", "/");
2932 /* TestOutputFalse for is_file (1) */
2936 r = guestfs_mkdir (g, "/new");
2943 r = guestfs_is_file (g, "/new");
2947 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2954 static int test_exists_0 (void)
2956 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2960 r = guestfs_umount_all (g);
2967 r = guestfs_lvm_remove_all (g);
2978 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2985 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2992 r = guestfs_mount (g, "/dev/sda1", "/");
2996 /* TestOutputTrue for exists (0) */
3000 r = guestfs_touch (g, "/new");
3007 r = guestfs_exists (g, "/new");
3011 fprintf (stderr, "test_exists_0: expected true, got false\n");
3018 static int test_exists_1 (void)
3020 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
3024 r = guestfs_umount_all (g);
3031 r = guestfs_lvm_remove_all (g);
3042 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3049 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3056 r = guestfs_mount (g, "/dev/sda1", "/");
3060 /* TestOutputTrue for exists (1) */
3064 r = guestfs_mkdir (g, "/new");
3071 r = guestfs_exists (g, "/new");
3075 fprintf (stderr, "test_exists_1: expected true, got false\n");
3082 static int test_mkdir_p_0 (void)
3084 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
3088 r = guestfs_umount_all (g);
3095 r = guestfs_lvm_remove_all (g);
3106 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3113 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3120 r = guestfs_mount (g, "/dev/sda1", "/");
3124 /* TestOutputTrue for mkdir_p (0) */
3128 r = guestfs_mkdir_p (g, "/new/foo/bar");
3135 r = guestfs_is_dir (g, "/new/foo/bar");
3139 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
3146 static int test_mkdir_p_1 (void)
3148 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
3152 r = guestfs_umount_all (g);
3159 r = guestfs_lvm_remove_all (g);
3170 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3177 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3184 r = guestfs_mount (g, "/dev/sda1", "/");
3188 /* TestOutputTrue for mkdir_p (1) */
3192 r = guestfs_mkdir_p (g, "/new/foo/bar");
3199 r = guestfs_is_dir (g, "/new/foo");
3203 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
3210 static int test_mkdir_p_2 (void)
3212 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
3216 r = guestfs_umount_all (g);
3223 r = guestfs_lvm_remove_all (g);
3234 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3241 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3248 r = guestfs_mount (g, "/dev/sda1", "/");
3252 /* TestOutputTrue for mkdir_p (2) */
3256 r = guestfs_mkdir_p (g, "/new/foo/bar");
3263 r = guestfs_is_dir (g, "/new");
3267 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
3274 static int test_mkdir_0 (void)
3276 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
3280 r = guestfs_umount_all (g);
3287 r = guestfs_lvm_remove_all (g);
3298 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3305 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3312 r = guestfs_mount (g, "/dev/sda1", "/");
3316 /* TestOutputTrue for mkdir (0) */
3320 r = guestfs_mkdir (g, "/new");
3327 r = guestfs_is_dir (g, "/new");
3331 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
3338 static int test_mkdir_1 (void)
3340 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
3344 r = guestfs_umount_all (g);
3351 r = guestfs_lvm_remove_all (g);
3362 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3369 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3376 r = guestfs_mount (g, "/dev/sda1", "/");
3380 /* TestLastFail for mkdir (1) */
3384 r = guestfs_mkdir (g, "/new/foo/bar");
3391 static int test_rm_rf_0 (void)
3393 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
3397 r = guestfs_umount_all (g);
3404 r = guestfs_lvm_remove_all (g);
3415 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3422 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3429 r = guestfs_mount (g, "/dev/sda1", "/");
3433 /* TestOutputFalse for rm_rf (0) */
3437 r = guestfs_mkdir (g, "/new");
3444 r = guestfs_mkdir (g, "/new/foo");
3451 r = guestfs_touch (g, "/new/foo/bar");
3458 r = guestfs_rm_rf (g, "/new");
3465 r = guestfs_exists (g, "/new");
3469 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
3476 static int test_rmdir_0 (void)
3478 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
3482 r = guestfs_umount_all (g);
3489 r = guestfs_lvm_remove_all (g);
3500 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3507 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3514 r = guestfs_mount (g, "/dev/sda1", "/");
3518 /* TestRun for rmdir (0) */
3522 r = guestfs_mkdir (g, "/new");
3529 r = guestfs_rmdir (g, "/new");
3536 static int test_rmdir_1 (void)
3538 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
3542 r = guestfs_umount_all (g);
3549 r = guestfs_lvm_remove_all (g);
3560 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3567 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3574 r = guestfs_mount (g, "/dev/sda1", "/");
3578 /* TestLastFail for rmdir (1) */
3582 r = guestfs_rmdir (g, "/new");
3589 static int test_rmdir_2 (void)
3591 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
3595 r = guestfs_umount_all (g);
3602 r = guestfs_lvm_remove_all (g);
3613 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3620 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3627 r = guestfs_mount (g, "/dev/sda1", "/");
3631 /* TestLastFail for rmdir (2) */
3635 r = guestfs_touch (g, "/new");
3642 r = guestfs_rmdir (g, "/new");
3649 static int test_rm_0 (void)
3651 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
3655 r = guestfs_umount_all (g);
3662 r = guestfs_lvm_remove_all (g);
3673 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3680 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3687 r = guestfs_mount (g, "/dev/sda1", "/");
3691 /* TestRun for rm (0) */
3695 r = guestfs_touch (g, "/new");
3702 r = guestfs_rm (g, "/new");
3709 static int test_rm_1 (void)
3711 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
3715 r = guestfs_umount_all (g);
3722 r = guestfs_lvm_remove_all (g);
3733 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3740 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3747 r = guestfs_mount (g, "/dev/sda1", "/");
3751 /* TestLastFail for rm (1) */
3755 r = guestfs_rm (g, "/new");
3762 static int test_rm_2 (void)
3764 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
3768 r = guestfs_umount_all (g);
3775 r = guestfs_lvm_remove_all (g);
3786 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3793 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3800 r = guestfs_mount (g, "/dev/sda1", "/");
3804 /* TestLastFail for rm (2) */
3808 r = guestfs_mkdir (g, "/new");
3815 r = guestfs_rm (g, "/new");
3822 static int test_read_lines_0 (void)
3824 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3828 r = guestfs_umount_all (g);
3835 r = guestfs_lvm_remove_all (g);
3846 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3853 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3860 r = guestfs_mount (g, "/dev/sda1", "/");
3864 /* TestOutputList for read_lines (0) */
3868 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
3876 r = guestfs_read_lines (g, "/new");
3880 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3884 if (strcmp (r[0], "line1") != 0) {
3885 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
3889 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3893 if (strcmp (r[1], "line2") != 0) {
3894 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
3898 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3902 if (strcmp (r[2], "line3") != 0) {
3903 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
3907 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
3911 for (i = 0; r[i] != NULL; ++i)
3918 static int test_read_lines_1 (void)
3920 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
3924 r = guestfs_umount_all (g);
3931 r = guestfs_lvm_remove_all (g);
3942 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3949 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3956 r = guestfs_mount (g, "/dev/sda1", "/");
3960 /* TestOutputList for read_lines (1) */
3964 r = guestfs_write_file (g, "/new", "", 0);
3972 r = guestfs_read_lines (g, "/new");
3976 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
3980 for (i = 0; r[i] != NULL; ++i)
3987 static int test_lvs_0 (void)
3989 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
3993 r = guestfs_umount_all (g);
4000 r = guestfs_lvm_remove_all (g);
4011 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4018 r = guestfs_pvcreate (g, "/dev/sda1");
4023 char *physvols[] = {
4029 r = guestfs_vgcreate (g, "VG", physvols);
4036 r = guestfs_lvcreate (g, "LV", "VG", 8);
4043 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4050 r = guestfs_mount (g, "/dev/VG/LV", "/");
4054 /* TestOutputList for lvs (0) */
4059 r = guestfs_lvs (g);
4063 fprintf (stderr, "test_lvs_0: short list returned from command\n");
4067 if (strcmp (r[0], "/dev/VG/LV") != 0) {
4068 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
4072 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
4076 for (i = 0; r[i] != NULL; ++i)
4083 static int test_lvs_1 (void)
4085 /* InitEmpty for lvs (1) */
4089 r = guestfs_umount_all (g);
4096 r = guestfs_lvm_remove_all (g);
4100 /* TestOutputList for lvs (1) */
4110 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4117 r = guestfs_pvcreate (g, "/dev/sda1");
4124 r = guestfs_pvcreate (g, "/dev/sda2");
4131 r = guestfs_pvcreate (g, "/dev/sda3");
4136 char *physvols[] = {
4143 r = guestfs_vgcreate (g, "VG1", physvols);
4148 char *physvols[] = {
4154 r = guestfs_vgcreate (g, "VG2", physvols);
4161 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4168 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4175 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4183 r = guestfs_lvs (g);
4187 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4191 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4192 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4196 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4200 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4201 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4205 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4209 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4210 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4214 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
4218 for (i = 0; r[i] != NULL; ++i)
4225 static int test_vgs_0 (void)
4227 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
4231 r = guestfs_umount_all (g);
4238 r = guestfs_lvm_remove_all (g);
4249 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4256 r = guestfs_pvcreate (g, "/dev/sda1");
4261 char *physvols[] = {
4267 r = guestfs_vgcreate (g, "VG", physvols);
4274 r = guestfs_lvcreate (g, "LV", "VG", 8);
4281 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4288 r = guestfs_mount (g, "/dev/VG/LV", "/");
4292 /* TestOutputList for vgs (0) */
4297 r = guestfs_vgs (g);
4301 fprintf (stderr, "test_vgs_0: short list returned from command\n");
4305 if (strcmp (r[0], "VG") != 0) {
4306 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
4310 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
4314 for (i = 0; r[i] != NULL; ++i)
4321 static int test_vgs_1 (void)
4323 /* InitEmpty for vgs (1) */
4327 r = guestfs_umount_all (g);
4334 r = guestfs_lvm_remove_all (g);
4338 /* TestOutputList for vgs (1) */
4348 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4355 r = guestfs_pvcreate (g, "/dev/sda1");
4362 r = guestfs_pvcreate (g, "/dev/sda2");
4369 r = guestfs_pvcreate (g, "/dev/sda3");
4374 char *physvols[] = {
4381 r = guestfs_vgcreate (g, "VG1", physvols);
4386 char *physvols[] = {
4392 r = guestfs_vgcreate (g, "VG2", physvols);
4400 r = guestfs_vgs (g);
4404 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4408 if (strcmp (r[0], "VG1") != 0) {
4409 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
4413 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4417 if (strcmp (r[1], "VG2") != 0) {
4418 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
4422 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
4426 for (i = 0; r[i] != NULL; ++i)
4433 static int test_pvs_0 (void)
4435 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
4439 r = guestfs_umount_all (g);
4446 r = guestfs_lvm_remove_all (g);
4457 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4464 r = guestfs_pvcreate (g, "/dev/sda1");
4469 char *physvols[] = {
4475 r = guestfs_vgcreate (g, "VG", physvols);
4482 r = guestfs_lvcreate (g, "LV", "VG", 8);
4489 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4496 r = guestfs_mount (g, "/dev/VG/LV", "/");
4500 /* TestOutputList for pvs (0) */
4505 r = guestfs_pvs (g);
4509 fprintf (stderr, "test_pvs_0: short list returned from command\n");
4513 if (strcmp (r[0], "/dev/sda1") != 0) {
4514 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4518 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
4522 for (i = 0; r[i] != NULL; ++i)
4529 static int test_pvs_1 (void)
4531 /* InitEmpty for pvs (1) */
4535 r = guestfs_umount_all (g);
4542 r = guestfs_lvm_remove_all (g);
4546 /* TestOutputList for pvs (1) */
4556 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4563 r = guestfs_pvcreate (g, "/dev/sda1");
4570 r = guestfs_pvcreate (g, "/dev/sda2");
4577 r = guestfs_pvcreate (g, "/dev/sda3");
4585 r = guestfs_pvs (g);
4589 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4593 if (strcmp (r[0], "/dev/sda1") != 0) {
4594 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4598 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4602 if (strcmp (r[1], "/dev/sda2") != 0) {
4603 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4607 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4611 if (strcmp (r[2], "/dev/sda3") != 0) {
4612 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4616 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
4620 for (i = 0; r[i] != NULL; ++i)
4627 static int test_list_partitions_0 (void)
4629 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
4633 r = guestfs_umount_all (g);
4640 r = guestfs_lvm_remove_all (g);
4651 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4658 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4665 r = guestfs_mount (g, "/dev/sda1", "/");
4669 /* TestOutputList for list_partitions (0) */
4674 r = guestfs_list_partitions (g);
4678 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
4682 if (strcmp (r[0], "/dev/sda1") != 0) {
4683 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4687 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
4691 for (i = 0; r[i] != NULL; ++i)
4698 static int test_list_partitions_1 (void)
4700 /* InitEmpty for list_partitions (1) */
4704 r = guestfs_umount_all (g);
4711 r = guestfs_lvm_remove_all (g);
4715 /* TestOutputList for list_partitions (1) */
4725 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4733 r = guestfs_list_partitions (g);
4737 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4741 if (strcmp (r[0], "/dev/sda1") != 0) {
4742 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4746 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4750 if (strcmp (r[1], "/dev/sda2") != 0) {
4751 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4755 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4759 if (strcmp (r[2], "/dev/sda3") != 0) {
4760 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4764 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
4768 for (i = 0; r[i] != NULL; ++i)
4775 static int test_list_devices_0 (void)
4777 /* InitEmpty for list_devices (0) */
4781 r = guestfs_umount_all (g);
4788 r = guestfs_lvm_remove_all (g);
4792 /* TestOutputList for list_devices (0) */
4797 r = guestfs_list_devices (g);
4801 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4805 if (strcmp (r[0], "/dev/sda") != 0) {
4806 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4810 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4814 if (strcmp (r[1], "/dev/sdb") != 0) {
4815 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4819 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4823 if (strcmp (r[2], "/dev/sdc") != 0) {
4824 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4828 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4832 for (i = 0; r[i] != NULL; ++i)
4839 static int test_ls_0 (void)
4841 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4845 r = guestfs_umount_all (g);
4852 r = guestfs_lvm_remove_all (g);
4863 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4870 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4877 r = guestfs_mount (g, "/dev/sda1", "/");
4881 /* TestOutputList for ls (0) */
4885 r = guestfs_touch (g, "/new");
4892 r = guestfs_touch (g, "/newer");
4899 r = guestfs_touch (g, "/newest");
4907 r = guestfs_ls (g, "/");
4911 fprintf (stderr, "test_ls_0: short list returned from command\n");
4915 if (strcmp (r[0], "lost+found") != 0) {
4916 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
4920 fprintf (stderr, "test_ls_0: short list returned from command\n");
4924 if (strcmp (r[1], "new") != 0) {
4925 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
4929 fprintf (stderr, "test_ls_0: short list returned from command\n");
4933 if (strcmp (r[2], "newer") != 0) {
4934 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
4938 fprintf (stderr, "test_ls_0: short list returned from command\n");
4942 if (strcmp (r[3], "newest") != 0) {
4943 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
4947 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
4951 for (i = 0; r[i] != NULL; ++i)
4958 static int test_cat_0 (void)
4960 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
4964 r = guestfs_umount_all (g);
4971 r = guestfs_lvm_remove_all (g);
4982 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4989 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4996 r = guestfs_mount (g, "/dev/sda1", "/");
5000 /* TestOutput for cat (0) */
5004 r = guestfs_write_file (g, "/new", "new file contents", 0);
5011 r = guestfs_cat (g, "/new");
5014 if (strcmp (r, "new file contents") != 0) {
5015 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
5023 static int test_touch_0 (void)
5025 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
5029 r = guestfs_umount_all (g);
5036 r = guestfs_lvm_remove_all (g);
5047 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5054 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5061 r = guestfs_mount (g, "/dev/sda1", "/");
5065 /* TestOutputTrue for touch (0) */
5069 r = guestfs_touch (g, "/new");
5076 r = guestfs_exists (g, "/new");
5080 fprintf (stderr, "test_touch_0: expected true, got false\n");
5087 static int test_sync_0 (void)
5089 /* InitEmpty for sync (0) */
5093 r = guestfs_umount_all (g);
5100 r = guestfs_lvm_remove_all (g);
5104 /* TestRun for sync (0) */
5108 r = guestfs_sync (g);
5115 static int test_mount_0 (void)
5117 /* InitEmpty for mount (0) */
5121 r = guestfs_umount_all (g);
5128 r = guestfs_lvm_remove_all (g);
5132 /* TestOutput for mount (0) */
5140 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5147 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5154 r = guestfs_mount (g, "/dev/sda1", "/");
5161 r = guestfs_write_file (g, "/new", "new file contents", 0);
5168 r = guestfs_cat (g, "/new");
5171 if (strcmp (r, "new file contents") != 0) {
5172 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
5180 int main (int argc, char *argv[])
5185 const char *filename;
5187 int nr_tests, test_num = 0;
5189 no_test_warnings ();
5191 g = guestfs_create ();
5193 printf ("guestfs_create FAILED\n");
5197 guestfs_set_error_handler (g, print_error, NULL);
5199 srcdir = getenv ("srcdir");
5200 if (!srcdir) srcdir = ".";
5202 guestfs_set_path (g, ".");
5204 filename = "test1.img";
5205 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5210 if (lseek (fd, 524288000, SEEK_SET) == -1) {
5216 if (write (fd, &c, 1) == -1) {
5222 if (close (fd) == -1) {
5227 if (guestfs_add_drive (g, filename) == -1) {
5228 printf ("guestfs_add_drive %s FAILED\n", filename);
5232 filename = "test2.img";
5233 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5238 if (lseek (fd, 52428800, SEEK_SET) == -1) {
5244 if (write (fd, &c, 1) == -1) {
5250 if (close (fd) == -1) {
5255 if (guestfs_add_drive (g, filename) == -1) {
5256 printf ("guestfs_add_drive %s FAILED\n", filename);
5260 filename = "test3.img";
5261 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5266 if (lseek (fd, 10485760, SEEK_SET) == -1) {
5272 if (write (fd, &c, 1) == -1) {
5278 if (close (fd) == -1) {
5283 if (guestfs_add_drive (g, filename) == -1) {
5284 printf ("guestfs_add_drive %s FAILED\n", filename);
5288 if (guestfs_launch (g) == -1) {
5289 printf ("guestfs_launch FAILED\n");
5292 if (guestfs_wait_ready (g) == -1) {
5293 printf ("guestfs_wait_ready FAILED\n");
5300 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
5301 if (test_tgz_in_0 () == -1) {
5302 printf ("test_tgz_in_0 FAILED\n");
5306 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
5307 if (test_tar_in_0 () == -1) {
5308 printf ("test_tar_in_0 FAILED\n");
5312 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
5313 if (test_checksum_0 () == -1) {
5314 printf ("test_checksum_0 FAILED\n");
5318 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
5319 if (test_checksum_1 () == -1) {
5320 printf ("test_checksum_1 FAILED\n");
5324 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
5325 if (test_checksum_2 () == -1) {
5326 printf ("test_checksum_2 FAILED\n");
5330 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
5331 if (test_checksum_3 () == -1) {
5332 printf ("test_checksum_3 FAILED\n");
5336 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
5337 if (test_checksum_4 () == -1) {
5338 printf ("test_checksum_4 FAILED\n");
5342 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
5343 if (test_checksum_5 () == -1) {
5344 printf ("test_checksum_5 FAILED\n");
5348 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
5349 if (test_checksum_6 () == -1) {
5350 printf ("test_checksum_6 FAILED\n");
5354 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
5355 if (test_checksum_7 () == -1) {
5356 printf ("test_checksum_7 FAILED\n");
5360 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
5361 if (test_download_0 () == -1) {
5362 printf ("test_download_0 FAILED\n");
5366 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
5367 if (test_upload_0 () == -1) {
5368 printf ("test_upload_0 FAILED\n");
5372 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
5373 if (test_blockdev_rereadpt_0 () == -1) {
5374 printf ("test_blockdev_rereadpt_0 FAILED\n");
5378 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
5379 if (test_blockdev_flushbufs_0 () == -1) {
5380 printf ("test_blockdev_flushbufs_0 FAILED\n");
5384 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
5385 if (test_blockdev_getsize64_0 () == -1) {
5386 printf ("test_blockdev_getsize64_0 FAILED\n");
5390 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
5391 if (test_blockdev_getsz_0 () == -1) {
5392 printf ("test_blockdev_getsz_0 FAILED\n");
5396 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
5397 if (test_blockdev_getbsz_0 () == -1) {
5398 printf ("test_blockdev_getbsz_0 FAILED\n");
5402 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
5403 if (test_blockdev_getss_0 () == -1) {
5404 printf ("test_blockdev_getss_0 FAILED\n");
5408 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
5409 if (test_blockdev_getro_0 () == -1) {
5410 printf ("test_blockdev_getro_0 FAILED\n");
5414 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
5415 if (test_blockdev_setrw_0 () == -1) {
5416 printf ("test_blockdev_setrw_0 FAILED\n");
5420 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
5421 if (test_blockdev_setro_0 () == -1) {
5422 printf ("test_blockdev_setro_0 FAILED\n");
5426 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
5427 if (test_statvfs_0 () == -1) {
5428 printf ("test_statvfs_0 FAILED\n");
5432 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
5433 if (test_lstat_0 () == -1) {
5434 printf ("test_lstat_0 FAILED\n");
5438 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
5439 if (test_stat_0 () == -1) {
5440 printf ("test_stat_0 FAILED\n");
5444 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
5445 if (test_file_0 () == -1) {
5446 printf ("test_file_0 FAILED\n");
5450 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
5451 if (test_file_1 () == -1) {
5452 printf ("test_file_1 FAILED\n");
5456 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
5457 if (test_file_2 () == -1) {
5458 printf ("test_file_2 FAILED\n");
5462 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
5463 if (test_umount_all_0 () == -1) {
5464 printf ("test_umount_all_0 FAILED\n");
5468 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
5469 if (test_mounts_0 () == -1) {
5470 printf ("test_mounts_0 FAILED\n");
5474 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
5475 if (test_umount_0 () == -1) {
5476 printf ("test_umount_0 FAILED\n");
5480 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
5481 if (test_umount_1 () == -1) {
5482 printf ("test_umount_1 FAILED\n");
5486 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
5487 if (test_write_file_0 () == -1) {
5488 printf ("test_write_file_0 FAILED\n");
5492 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
5493 if (test_write_file_1 () == -1) {
5494 printf ("test_write_file_1 FAILED\n");
5498 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
5499 if (test_write_file_2 () == -1) {
5500 printf ("test_write_file_2 FAILED\n");
5504 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
5505 if (test_write_file_3 () == -1) {
5506 printf ("test_write_file_3 FAILED\n");
5510 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
5511 if (test_write_file_4 () == -1) {
5512 printf ("test_write_file_4 FAILED\n");
5516 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
5517 if (test_write_file_5 () == -1) {
5518 printf ("test_write_file_5 FAILED\n");
5522 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
5523 if (test_mkfs_0 () == -1) {
5524 printf ("test_mkfs_0 FAILED\n");
5528 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
5529 if (test_lvcreate_0 () == -1) {
5530 printf ("test_lvcreate_0 FAILED\n");
5534 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
5535 if (test_vgcreate_0 () == -1) {
5536 printf ("test_vgcreate_0 FAILED\n");
5540 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
5541 if (test_pvcreate_0 () == -1) {
5542 printf ("test_pvcreate_0 FAILED\n");
5546 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
5547 if (test_is_dir_0 () == -1) {
5548 printf ("test_is_dir_0 FAILED\n");
5552 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
5553 if (test_is_dir_1 () == -1) {
5554 printf ("test_is_dir_1 FAILED\n");
5558 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
5559 if (test_is_file_0 () == -1) {
5560 printf ("test_is_file_0 FAILED\n");
5564 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
5565 if (test_is_file_1 () == -1) {
5566 printf ("test_is_file_1 FAILED\n");
5570 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
5571 if (test_exists_0 () == -1) {
5572 printf ("test_exists_0 FAILED\n");
5576 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
5577 if (test_exists_1 () == -1) {
5578 printf ("test_exists_1 FAILED\n");
5582 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
5583 if (test_mkdir_p_0 () == -1) {
5584 printf ("test_mkdir_p_0 FAILED\n");
5588 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
5589 if (test_mkdir_p_1 () == -1) {
5590 printf ("test_mkdir_p_1 FAILED\n");
5594 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
5595 if (test_mkdir_p_2 () == -1) {
5596 printf ("test_mkdir_p_2 FAILED\n");
5600 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
5601 if (test_mkdir_0 () == -1) {
5602 printf ("test_mkdir_0 FAILED\n");
5606 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
5607 if (test_mkdir_1 () == -1) {
5608 printf ("test_mkdir_1 FAILED\n");
5612 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
5613 if (test_rm_rf_0 () == -1) {
5614 printf ("test_rm_rf_0 FAILED\n");
5618 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
5619 if (test_rmdir_0 () == -1) {
5620 printf ("test_rmdir_0 FAILED\n");
5624 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
5625 if (test_rmdir_1 () == -1) {
5626 printf ("test_rmdir_1 FAILED\n");
5630 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
5631 if (test_rmdir_2 () == -1) {
5632 printf ("test_rmdir_2 FAILED\n");
5636 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
5637 if (test_rm_0 () == -1) {
5638 printf ("test_rm_0 FAILED\n");
5642 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
5643 if (test_rm_1 () == -1) {
5644 printf ("test_rm_1 FAILED\n");
5648 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
5649 if (test_rm_2 () == -1) {
5650 printf ("test_rm_2 FAILED\n");
5654 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
5655 if (test_read_lines_0 () == -1) {
5656 printf ("test_read_lines_0 FAILED\n");
5660 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
5661 if (test_read_lines_1 () == -1) {
5662 printf ("test_read_lines_1 FAILED\n");
5666 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
5667 if (test_lvs_0 () == -1) {
5668 printf ("test_lvs_0 FAILED\n");
5672 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
5673 if (test_lvs_1 () == -1) {
5674 printf ("test_lvs_1 FAILED\n");
5678 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
5679 if (test_vgs_0 () == -1) {
5680 printf ("test_vgs_0 FAILED\n");
5684 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
5685 if (test_vgs_1 () == -1) {
5686 printf ("test_vgs_1 FAILED\n");
5690 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
5691 if (test_pvs_0 () == -1) {
5692 printf ("test_pvs_0 FAILED\n");
5696 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
5697 if (test_pvs_1 () == -1) {
5698 printf ("test_pvs_1 FAILED\n");
5702 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
5703 if (test_list_partitions_0 () == -1) {
5704 printf ("test_list_partitions_0 FAILED\n");
5708 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
5709 if (test_list_partitions_1 () == -1) {
5710 printf ("test_list_partitions_1 FAILED\n");
5714 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
5715 if (test_list_devices_0 () == -1) {
5716 printf ("test_list_devices_0 FAILED\n");
5720 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
5721 if (test_ls_0 () == -1) {
5722 printf ("test_ls_0 FAILED\n");
5726 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
5727 if (test_cat_0 () == -1) {
5728 printf ("test_cat_0 FAILED\n");
5732 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
5733 if (test_touch_0 () == -1) {
5734 printf ("test_touch_0 FAILED\n");
5738 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
5739 if (test_sync_0 () == -1) {
5740 printf ("test_sync_0 FAILED\n");
5744 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
5745 if (test_mount_0 () == -1) {
5746 printf ("test_mount_0 FAILED\n");
5751 unlink ("test1.img");
5752 unlink ("test2.img");
5753 unlink ("test3.img");
5756 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);