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_tar_out\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
108 static int test_tgz_in_0 (void)
110 /* InitBasicFS for tgz_in (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 tgz_in (0) */
154 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
161 r = guestfs_cat (g, "/hello");
164 if (strcmp (r, "hello\n") != 0) {
165 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
173 static int test_tar_in_0 (void)
175 /* InitBasicFS for tar_in (0): 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 /* TestOutput for tar_in (0) */
219 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
226 r = guestfs_cat (g, "/hello");
229 if (strcmp (r, "hello\n") != 0) {
230 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
238 static int test_checksum_0 (void)
240 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
244 r = guestfs_umount_all (g);
251 r = guestfs_lvm_remove_all (g);
262 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
269 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
276 r = guestfs_mount (g, "/dev/sda1", "/");
280 /* TestOutput for checksum (0) */
284 r = guestfs_write_file (g, "/new", "test\n", 0);
291 r = guestfs_checksum (g, "crc", "/new");
294 if (strcmp (r, "935282863") != 0) {
295 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
303 static int test_checksum_1 (void)
305 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
309 r = guestfs_umount_all (g);
316 r = guestfs_lvm_remove_all (g);
327 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
334 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
341 r = guestfs_mount (g, "/dev/sda1", "/");
345 /* TestLastFail for checksum (1) */
349 r = guestfs_checksum (g, "crc", "/new");
357 static int test_checksum_2 (void)
359 /* InitBasicFS for checksum (2): 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 (2) */
403 r = guestfs_write_file (g, "/new", "test\n", 0);
410 r = guestfs_checksum (g, "md5", "/new");
413 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
414 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
422 static int test_checksum_3 (void)
424 /* InitBasicFS for checksum (3): 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 (3) */
468 r = guestfs_write_file (g, "/new", "test\n", 0);
475 r = guestfs_checksum (g, "sha1", "/new");
478 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
479 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
487 static int test_checksum_4 (void)
489 /* InitBasicFS for checksum (4): 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 (4) */
533 r = guestfs_write_file (g, "/new", "test\n", 0);
540 r = guestfs_checksum (g, "sha224", "/new");
543 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
544 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
552 static int test_checksum_5 (void)
554 /* InitBasicFS for checksum (5): 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 (5) */
598 r = guestfs_write_file (g, "/new", "test\n", 0);
605 r = guestfs_checksum (g, "sha256", "/new");
608 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
609 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
617 static int test_checksum_6 (void)
619 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
623 r = guestfs_umount_all (g);
630 r = guestfs_lvm_remove_all (g);
641 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
648 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
655 r = guestfs_mount (g, "/dev/sda1", "/");
659 /* TestOutput for checksum (6) */
663 r = guestfs_write_file (g, "/new", "test\n", 0);
670 r = guestfs_checksum (g, "sha384", "/new");
673 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
674 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
682 static int test_checksum_7 (void)
684 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
688 r = guestfs_umount_all (g);
695 r = guestfs_lvm_remove_all (g);
706 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
713 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
720 r = guestfs_mount (g, "/dev/sda1", "/");
724 /* TestOutput for checksum (7) */
728 r = guestfs_write_file (g, "/new", "test\n", 0);
735 r = guestfs_checksum (g, "sha512", "/new");
738 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
739 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
747 static int test_download_0 (void)
749 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
753 r = guestfs_umount_all (g);
760 r = guestfs_lvm_remove_all (g);
771 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
778 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
785 r = guestfs_mount (g, "/dev/sda1", "/");
789 /* TestOutput for download (0) */
793 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
800 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
807 r = guestfs_upload (g, "testdownload.tmp", "/upload");
814 r = guestfs_checksum (g, "md5", "/upload");
817 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
818 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
826 static int test_upload_0 (void)
828 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
832 r = guestfs_umount_all (g);
839 r = guestfs_lvm_remove_all (g);
850 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
857 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
864 r = guestfs_mount (g, "/dev/sda1", "/");
868 /* TestOutput for upload (0) */
872 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
879 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
882 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
883 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
891 static int test_blockdev_rereadpt_0 (void)
893 /* InitEmpty for blockdev_rereadpt (0) */
897 r = guestfs_umount_all (g);
904 r = guestfs_lvm_remove_all (g);
908 /* TestRun for blockdev_rereadpt (0) */
912 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
919 static int test_blockdev_flushbufs_0 (void)
921 /* InitEmpty for blockdev_flushbufs (0) */
925 r = guestfs_umount_all (g);
932 r = guestfs_lvm_remove_all (g);
936 /* TestRun for blockdev_flushbufs (0) */
940 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
947 static int test_blockdev_getsize64_0 (void)
949 /* InitEmpty for blockdev_getsize64 (0) */
953 r = guestfs_umount_all (g);
960 r = guestfs_lvm_remove_all (g);
964 /* TestOutputInt for blockdev_getsize64 (0) */
968 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
971 if (r != 524288000) {
972 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
979 static int test_blockdev_getsz_0 (void)
981 /* InitEmpty for blockdev_getsz (0) */
985 r = guestfs_umount_all (g);
992 r = guestfs_lvm_remove_all (g);
996 /* TestOutputInt for blockdev_getsz (0) */
1000 r = guestfs_blockdev_getsz (g, "/dev/sda");
1004 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
1011 static int test_blockdev_getbsz_0 (void)
1013 /* InitEmpty for blockdev_getbsz (0) */
1017 r = guestfs_umount_all (g);
1024 r = guestfs_lvm_remove_all (g);
1028 /* TestOutputInt for blockdev_getbsz (0) */
1032 r = guestfs_blockdev_getbsz (g, "/dev/sda");
1036 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
1043 static int test_blockdev_getss_0 (void)
1045 /* InitEmpty for blockdev_getss (0) */
1049 r = guestfs_umount_all (g);
1056 r = guestfs_lvm_remove_all (g);
1060 /* TestOutputInt for blockdev_getss (0) */
1064 r = guestfs_blockdev_getss (g, "/dev/sda");
1068 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
1075 static int test_blockdev_getro_0 (void)
1077 /* InitEmpty for blockdev_getro (0) */
1081 r = guestfs_umount_all (g);
1088 r = guestfs_lvm_remove_all (g);
1092 /* TestOutputTrue for blockdev_getro (0) */
1096 r = guestfs_blockdev_setro (g, "/dev/sda");
1103 r = guestfs_blockdev_getro (g, "/dev/sda");
1107 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
1114 static int test_blockdev_setrw_0 (void)
1116 /* InitEmpty for blockdev_setrw (0) */
1120 r = guestfs_umount_all (g);
1127 r = guestfs_lvm_remove_all (g);
1131 /* TestOutputFalse for blockdev_setrw (0) */
1135 r = guestfs_blockdev_setrw (g, "/dev/sda");
1142 r = guestfs_blockdev_getro (g, "/dev/sda");
1146 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
1153 static int test_blockdev_setro_0 (void)
1155 /* InitEmpty for blockdev_setro (0) */
1159 r = guestfs_umount_all (g);
1166 r = guestfs_lvm_remove_all (g);
1170 /* TestOutputTrue for blockdev_setro (0) */
1174 r = guestfs_blockdev_setro (g, "/dev/sda");
1181 r = guestfs_blockdev_getro (g, "/dev/sda");
1185 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
1192 static int test_statvfs_0 (void)
1194 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
1198 r = guestfs_umount_all (g);
1205 r = guestfs_lvm_remove_all (g);
1216 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1223 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1230 r = guestfs_mount (g, "/dev/sda1", "/");
1234 /* TestOutputStruct for statvfs (0) */
1236 struct guestfs_statvfs *r;
1238 r = guestfs_statvfs (g, "/");
1241 if (r->bfree != 487702) {
1242 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
1246 if (r->blocks != 490020) {
1247 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
1251 if (r->bsize != 1024) {
1252 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
1261 static int test_lstat_0 (void)
1263 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
1267 r = guestfs_umount_all (g);
1274 r = guestfs_lvm_remove_all (g);
1285 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1292 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1299 r = guestfs_mount (g, "/dev/sda1", "/");
1303 /* TestOutputStruct for lstat (0) */
1307 r = guestfs_touch (g, "/new");
1312 struct guestfs_stat *r;
1314 r = guestfs_lstat (g, "/new");
1318 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
1327 static int test_stat_0 (void)
1329 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
1333 r = guestfs_umount_all (g);
1340 r = guestfs_lvm_remove_all (g);
1351 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1358 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1365 r = guestfs_mount (g, "/dev/sda1", "/");
1369 /* TestOutputStruct for stat (0) */
1373 r = guestfs_touch (g, "/new");
1378 struct guestfs_stat *r;
1380 r = guestfs_stat (g, "/new");
1384 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
1393 static int test_file_0 (void)
1395 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
1399 r = guestfs_umount_all (g);
1406 r = guestfs_lvm_remove_all (g);
1417 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1424 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1431 r = guestfs_mount (g, "/dev/sda1", "/");
1435 /* TestOutput for file (0) */
1439 r = guestfs_touch (g, "/new");
1446 r = guestfs_file (g, "/new");
1449 if (strcmp (r, "empty") != 0) {
1450 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
1458 static int test_file_1 (void)
1460 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
1464 r = guestfs_umount_all (g);
1471 r = guestfs_lvm_remove_all (g);
1482 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1489 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1496 r = guestfs_mount (g, "/dev/sda1", "/");
1500 /* TestOutput for file (1) */
1504 r = guestfs_write_file (g, "/new", "some content\n", 0);
1511 r = guestfs_file (g, "/new");
1514 if (strcmp (r, "ASCII text") != 0) {
1515 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
1523 static int test_file_2 (void)
1525 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
1529 r = guestfs_umount_all (g);
1536 r = guestfs_lvm_remove_all (g);
1547 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1554 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1561 r = guestfs_mount (g, "/dev/sda1", "/");
1565 /* TestLastFail for file (2) */
1569 r = guestfs_file (g, "/nofile");
1577 static int test_umount_all_0 (void)
1579 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
1583 r = guestfs_umount_all (g);
1590 r = guestfs_lvm_remove_all (g);
1601 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1608 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1615 r = guestfs_mount (g, "/dev/sda1", "/");
1619 /* TestOutputList for umount_all (0) */
1623 r = guestfs_umount_all (g);
1631 r = guestfs_mounts (g);
1635 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
1639 for (i = 0; r[i] != NULL; ++i)
1646 static int test_mounts_0 (void)
1648 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
1652 r = guestfs_umount_all (g);
1659 r = guestfs_lvm_remove_all (g);
1670 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1677 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1684 r = guestfs_mount (g, "/dev/sda1", "/");
1688 /* TestOutputList for mounts (0) */
1693 r = guestfs_mounts (g);
1697 fprintf (stderr, "test_mounts_0: short list returned from command\n");
1701 if (strcmp (r[0], "/dev/sda1") != 0) {
1702 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1706 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
1710 for (i = 0; r[i] != NULL; ++i)
1717 static int test_umount_0 (void)
1719 /* InitEmpty for umount (0) */
1723 r = guestfs_umount_all (g);
1730 r = guestfs_lvm_remove_all (g);
1734 /* TestOutputList for umount (0) */
1742 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1749 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1756 r = guestfs_mount (g, "/dev/sda1", "/");
1764 r = guestfs_mounts (g);
1768 fprintf (stderr, "test_umount_0: short list returned from command\n");
1772 if (strcmp (r[0], "/dev/sda1") != 0) {
1773 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1777 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
1781 for (i = 0; r[i] != NULL; ++i)
1788 static int test_umount_1 (void)
1790 /* InitEmpty for umount (1) */
1794 r = guestfs_umount_all (g);
1801 r = guestfs_lvm_remove_all (g);
1805 /* TestOutputList for umount (1) */
1813 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1820 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1827 r = guestfs_mount (g, "/dev/sda1", "/");
1834 r = guestfs_umount (g, "/");
1842 r = guestfs_mounts (g);
1846 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
1850 for (i = 0; r[i] != NULL; ++i)
1857 static int test_write_file_0 (void)
1859 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
1863 r = guestfs_umount_all (g);
1870 r = guestfs_lvm_remove_all (g);
1881 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1888 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1895 r = guestfs_mount (g, "/dev/sda1", "/");
1899 /* TestOutput for write_file (0) */
1903 r = guestfs_write_file (g, "/new", "new file contents", 0);
1910 r = guestfs_cat (g, "/new");
1913 if (strcmp (r, "new file contents") != 0) {
1914 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
1922 static int test_write_file_1 (void)
1924 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
1928 r = guestfs_umount_all (g);
1935 r = guestfs_lvm_remove_all (g);
1946 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1953 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1960 r = guestfs_mount (g, "/dev/sda1", "/");
1964 /* TestOutput for write_file (1) */
1968 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
1975 r = guestfs_cat (g, "/new");
1978 if (strcmp (r, "\nnew file contents\n") != 0) {
1979 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
1987 static int test_write_file_2 (void)
1989 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
1993 r = guestfs_umount_all (g);
2000 r = guestfs_lvm_remove_all (g);
2011 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2018 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2025 r = guestfs_mount (g, "/dev/sda1", "/");
2029 /* TestOutput for write_file (2) */
2033 r = guestfs_write_file (g, "/new", "\n\n", 0);
2040 r = guestfs_cat (g, "/new");
2043 if (strcmp (r, "\n\n") != 0) {
2044 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
2052 static int test_write_file_3 (void)
2054 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
2058 r = guestfs_umount_all (g);
2065 r = guestfs_lvm_remove_all (g);
2076 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2083 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2090 r = guestfs_mount (g, "/dev/sda1", "/");
2094 /* TestOutput for write_file (3) */
2098 r = guestfs_write_file (g, "/new", "", 0);
2105 r = guestfs_cat (g, "/new");
2108 if (strcmp (r, "") != 0) {
2109 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
2117 static int test_write_file_4 (void)
2119 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
2123 r = guestfs_umount_all (g);
2130 r = guestfs_lvm_remove_all (g);
2141 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2148 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2155 r = guestfs_mount (g, "/dev/sda1", "/");
2159 /* TestOutput for write_file (4) */
2163 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
2170 r = guestfs_cat (g, "/new");
2173 if (strcmp (r, "\n\n\n") != 0) {
2174 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
2182 static int test_write_file_5 (void)
2184 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
2188 r = guestfs_umount_all (g);
2195 r = guestfs_lvm_remove_all (g);
2206 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2213 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2220 r = guestfs_mount (g, "/dev/sda1", "/");
2224 /* TestOutput for write_file (5) */
2228 r = guestfs_write_file (g, "/new", "\n", 0);
2235 r = guestfs_cat (g, "/new");
2238 if (strcmp (r, "\n") != 0) {
2239 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
2247 static int test_mkfs_0 (void)
2249 /* InitEmpty for mkfs (0) */
2253 r = guestfs_umount_all (g);
2260 r = guestfs_lvm_remove_all (g);
2264 /* TestOutput for mkfs (0) */
2272 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2279 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2286 r = guestfs_mount (g, "/dev/sda1", "/");
2293 r = guestfs_write_file (g, "/new", "new file contents", 0);
2300 r = guestfs_cat (g, "/new");
2303 if (strcmp (r, "new file contents") != 0) {
2304 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
2312 static int test_lvcreate_0 (void)
2314 /* InitEmpty for lvcreate (0) */
2318 r = guestfs_umount_all (g);
2325 r = guestfs_lvm_remove_all (g);
2329 /* TestOutputList for lvcreate (0) */
2339 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2346 r = guestfs_pvcreate (g, "/dev/sda1");
2353 r = guestfs_pvcreate (g, "/dev/sda2");
2360 r = guestfs_pvcreate (g, "/dev/sda3");
2365 char *physvols[] = {
2372 r = guestfs_vgcreate (g, "VG1", physvols);
2377 char *physvols[] = {
2383 r = guestfs_vgcreate (g, "VG2", physvols);
2390 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2397 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2404 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2411 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2418 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2426 r = guestfs_lvs (g);
2430 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2434 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2435 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2439 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2443 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2444 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2448 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2452 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2453 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2457 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2461 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2462 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2466 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2470 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2471 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2475 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2479 for (i = 0; r[i] != NULL; ++i)
2486 static int test_vgcreate_0 (void)
2488 /* InitEmpty for vgcreate (0) */
2492 r = guestfs_umount_all (g);
2499 r = guestfs_lvm_remove_all (g);
2503 /* TestOutputList for vgcreate (0) */
2513 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2520 r = guestfs_pvcreate (g, "/dev/sda1");
2527 r = guestfs_pvcreate (g, "/dev/sda2");
2534 r = guestfs_pvcreate (g, "/dev/sda3");
2539 char *physvols[] = {
2546 r = guestfs_vgcreate (g, "VG1", physvols);
2551 char *physvols[] = {
2557 r = guestfs_vgcreate (g, "VG2", physvols);
2565 r = guestfs_vgs (g);
2569 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2573 if (strcmp (r[0], "VG1") != 0) {
2574 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2578 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2582 if (strcmp (r[1], "VG2") != 0) {
2583 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2587 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2591 for (i = 0; r[i] != NULL; ++i)
2598 static int test_pvcreate_0 (void)
2600 /* InitEmpty for pvcreate (0) */
2604 r = guestfs_umount_all (g);
2611 r = guestfs_lvm_remove_all (g);
2615 /* TestOutputList for pvcreate (0) */
2625 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2632 r = guestfs_pvcreate (g, "/dev/sda1");
2639 r = guestfs_pvcreate (g, "/dev/sda2");
2646 r = guestfs_pvcreate (g, "/dev/sda3");
2654 r = guestfs_pvs (g);
2658 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2662 if (strcmp (r[0], "/dev/sda1") != 0) {
2663 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2667 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2671 if (strcmp (r[1], "/dev/sda2") != 0) {
2672 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2676 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2680 if (strcmp (r[2], "/dev/sda3") != 0) {
2681 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2685 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2689 for (i = 0; r[i] != NULL; ++i)
2696 static int test_is_dir_0 (void)
2698 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2702 r = guestfs_umount_all (g);
2709 r = guestfs_lvm_remove_all (g);
2720 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2727 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2734 r = guestfs_mount (g, "/dev/sda1", "/");
2738 /* TestOutputFalse for is_dir (0) */
2742 r = guestfs_touch (g, "/new");
2749 r = guestfs_is_dir (g, "/new");
2753 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2760 static int test_is_dir_1 (void)
2762 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2766 r = guestfs_umount_all (g);
2773 r = guestfs_lvm_remove_all (g);
2784 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2791 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2798 r = guestfs_mount (g, "/dev/sda1", "/");
2802 /* TestOutputTrue for is_dir (1) */
2806 r = guestfs_mkdir (g, "/new");
2813 r = guestfs_is_dir (g, "/new");
2817 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2824 static int test_is_file_0 (void)
2826 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2830 r = guestfs_umount_all (g);
2837 r = guestfs_lvm_remove_all (g);
2848 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2855 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2862 r = guestfs_mount (g, "/dev/sda1", "/");
2866 /* TestOutputTrue for is_file (0) */
2870 r = guestfs_touch (g, "/new");
2877 r = guestfs_is_file (g, "/new");
2881 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2888 static int test_is_file_1 (void)
2890 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2894 r = guestfs_umount_all (g);
2901 r = guestfs_lvm_remove_all (g);
2912 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2919 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2926 r = guestfs_mount (g, "/dev/sda1", "/");
2930 /* TestOutputFalse for is_file (1) */
2934 r = guestfs_mkdir (g, "/new");
2941 r = guestfs_is_file (g, "/new");
2945 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2952 static int test_exists_0 (void)
2954 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2958 r = guestfs_umount_all (g);
2965 r = guestfs_lvm_remove_all (g);
2976 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2983 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2990 r = guestfs_mount (g, "/dev/sda1", "/");
2994 /* TestOutputTrue for exists (0) */
2998 r = guestfs_touch (g, "/new");
3005 r = guestfs_exists (g, "/new");
3009 fprintf (stderr, "test_exists_0: expected true, got false\n");
3016 static int test_exists_1 (void)
3018 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
3022 r = guestfs_umount_all (g);
3029 r = guestfs_lvm_remove_all (g);
3040 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3047 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3054 r = guestfs_mount (g, "/dev/sda1", "/");
3058 /* TestOutputTrue for exists (1) */
3062 r = guestfs_mkdir (g, "/new");
3069 r = guestfs_exists (g, "/new");
3073 fprintf (stderr, "test_exists_1: expected true, got false\n");
3080 static int test_mkdir_p_0 (void)
3082 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
3086 r = guestfs_umount_all (g);
3093 r = guestfs_lvm_remove_all (g);
3104 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3111 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3118 r = guestfs_mount (g, "/dev/sda1", "/");
3122 /* TestOutputTrue for mkdir_p (0) */
3126 r = guestfs_mkdir_p (g, "/new/foo/bar");
3133 r = guestfs_is_dir (g, "/new/foo/bar");
3137 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
3144 static int test_mkdir_p_1 (void)
3146 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
3150 r = guestfs_umount_all (g);
3157 r = guestfs_lvm_remove_all (g);
3168 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3175 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3182 r = guestfs_mount (g, "/dev/sda1", "/");
3186 /* TestOutputTrue for mkdir_p (1) */
3190 r = guestfs_mkdir_p (g, "/new/foo/bar");
3197 r = guestfs_is_dir (g, "/new/foo");
3201 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
3208 static int test_mkdir_p_2 (void)
3210 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
3214 r = guestfs_umount_all (g);
3221 r = guestfs_lvm_remove_all (g);
3232 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3239 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3246 r = guestfs_mount (g, "/dev/sda1", "/");
3250 /* TestOutputTrue for mkdir_p (2) */
3254 r = guestfs_mkdir_p (g, "/new/foo/bar");
3261 r = guestfs_is_dir (g, "/new");
3265 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
3272 static int test_mkdir_0 (void)
3274 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
3278 r = guestfs_umount_all (g);
3285 r = guestfs_lvm_remove_all (g);
3296 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3303 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3310 r = guestfs_mount (g, "/dev/sda1", "/");
3314 /* TestOutputTrue for mkdir (0) */
3318 r = guestfs_mkdir (g, "/new");
3325 r = guestfs_is_dir (g, "/new");
3329 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
3336 static int test_mkdir_1 (void)
3338 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
3342 r = guestfs_umount_all (g);
3349 r = guestfs_lvm_remove_all (g);
3360 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3367 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3374 r = guestfs_mount (g, "/dev/sda1", "/");
3378 /* TestLastFail for mkdir (1) */
3382 r = guestfs_mkdir (g, "/new/foo/bar");
3389 static int test_rm_rf_0 (void)
3391 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
3395 r = guestfs_umount_all (g);
3402 r = guestfs_lvm_remove_all (g);
3413 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3420 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3427 r = guestfs_mount (g, "/dev/sda1", "/");
3431 /* TestOutputFalse for rm_rf (0) */
3435 r = guestfs_mkdir (g, "/new");
3442 r = guestfs_mkdir (g, "/new/foo");
3449 r = guestfs_touch (g, "/new/foo/bar");
3456 r = guestfs_rm_rf (g, "/new");
3463 r = guestfs_exists (g, "/new");
3467 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
3474 static int test_rmdir_0 (void)
3476 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
3480 r = guestfs_umount_all (g);
3487 r = guestfs_lvm_remove_all (g);
3498 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3505 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3512 r = guestfs_mount (g, "/dev/sda1", "/");
3516 /* TestRun for rmdir (0) */
3520 r = guestfs_mkdir (g, "/new");
3527 r = guestfs_rmdir (g, "/new");
3534 static int test_rmdir_1 (void)
3536 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
3540 r = guestfs_umount_all (g);
3547 r = guestfs_lvm_remove_all (g);
3558 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3565 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3572 r = guestfs_mount (g, "/dev/sda1", "/");
3576 /* TestLastFail for rmdir (1) */
3580 r = guestfs_rmdir (g, "/new");
3587 static int test_rmdir_2 (void)
3589 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
3593 r = guestfs_umount_all (g);
3600 r = guestfs_lvm_remove_all (g);
3611 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3618 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3625 r = guestfs_mount (g, "/dev/sda1", "/");
3629 /* TestLastFail for rmdir (2) */
3633 r = guestfs_touch (g, "/new");
3640 r = guestfs_rmdir (g, "/new");
3647 static int test_rm_0 (void)
3649 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
3653 r = guestfs_umount_all (g);
3660 r = guestfs_lvm_remove_all (g);
3671 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3678 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3685 r = guestfs_mount (g, "/dev/sda1", "/");
3689 /* TestRun for rm (0) */
3693 r = guestfs_touch (g, "/new");
3700 r = guestfs_rm (g, "/new");
3707 static int test_rm_1 (void)
3709 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
3713 r = guestfs_umount_all (g);
3720 r = guestfs_lvm_remove_all (g);
3731 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3738 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3745 r = guestfs_mount (g, "/dev/sda1", "/");
3749 /* TestLastFail for rm (1) */
3753 r = guestfs_rm (g, "/new");
3760 static int test_rm_2 (void)
3762 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
3766 r = guestfs_umount_all (g);
3773 r = guestfs_lvm_remove_all (g);
3784 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3791 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3798 r = guestfs_mount (g, "/dev/sda1", "/");
3802 /* TestLastFail for rm (2) */
3806 r = guestfs_mkdir (g, "/new");
3813 r = guestfs_rm (g, "/new");
3820 static int test_read_lines_0 (void)
3822 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3826 r = guestfs_umount_all (g);
3833 r = guestfs_lvm_remove_all (g);
3844 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3851 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3858 r = guestfs_mount (g, "/dev/sda1", "/");
3862 /* TestOutputList for read_lines (0) */
3866 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
3874 r = guestfs_read_lines (g, "/new");
3878 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3882 if (strcmp (r[0], "line1") != 0) {
3883 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
3887 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3891 if (strcmp (r[1], "line2") != 0) {
3892 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
3896 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3900 if (strcmp (r[2], "line3") != 0) {
3901 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
3905 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
3909 for (i = 0; r[i] != NULL; ++i)
3916 static int test_read_lines_1 (void)
3918 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
3922 r = guestfs_umount_all (g);
3929 r = guestfs_lvm_remove_all (g);
3940 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3947 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3954 r = guestfs_mount (g, "/dev/sda1", "/");
3958 /* TestOutputList for read_lines (1) */
3962 r = guestfs_write_file (g, "/new", "", 0);
3970 r = guestfs_read_lines (g, "/new");
3974 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
3978 for (i = 0; r[i] != NULL; ++i)
3985 static int test_lvs_0 (void)
3987 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
3991 r = guestfs_umount_all (g);
3998 r = guestfs_lvm_remove_all (g);
4009 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4016 r = guestfs_pvcreate (g, "/dev/sda1");
4021 char *physvols[] = {
4027 r = guestfs_vgcreate (g, "VG", physvols);
4034 r = guestfs_lvcreate (g, "LV", "VG", 8);
4041 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4048 r = guestfs_mount (g, "/dev/VG/LV", "/");
4052 /* TestOutputList for lvs (0) */
4057 r = guestfs_lvs (g);
4061 fprintf (stderr, "test_lvs_0: short list returned from command\n");
4065 if (strcmp (r[0], "/dev/VG/LV") != 0) {
4066 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
4070 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
4074 for (i = 0; r[i] != NULL; ++i)
4081 static int test_lvs_1 (void)
4083 /* InitEmpty for lvs (1) */
4087 r = guestfs_umount_all (g);
4094 r = guestfs_lvm_remove_all (g);
4098 /* TestOutputList for lvs (1) */
4108 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4115 r = guestfs_pvcreate (g, "/dev/sda1");
4122 r = guestfs_pvcreate (g, "/dev/sda2");
4129 r = guestfs_pvcreate (g, "/dev/sda3");
4134 char *physvols[] = {
4141 r = guestfs_vgcreate (g, "VG1", physvols);
4146 char *physvols[] = {
4152 r = guestfs_vgcreate (g, "VG2", physvols);
4159 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4166 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4173 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4181 r = guestfs_lvs (g);
4185 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4189 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4190 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4194 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4198 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4199 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4203 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4207 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4208 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4212 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
4216 for (i = 0; r[i] != NULL; ++i)
4223 static int test_vgs_0 (void)
4225 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
4229 r = guestfs_umount_all (g);
4236 r = guestfs_lvm_remove_all (g);
4247 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4254 r = guestfs_pvcreate (g, "/dev/sda1");
4259 char *physvols[] = {
4265 r = guestfs_vgcreate (g, "VG", physvols);
4272 r = guestfs_lvcreate (g, "LV", "VG", 8);
4279 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4286 r = guestfs_mount (g, "/dev/VG/LV", "/");
4290 /* TestOutputList for vgs (0) */
4295 r = guestfs_vgs (g);
4299 fprintf (stderr, "test_vgs_0: short list returned from command\n");
4303 if (strcmp (r[0], "VG") != 0) {
4304 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
4308 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
4312 for (i = 0; r[i] != NULL; ++i)
4319 static int test_vgs_1 (void)
4321 /* InitEmpty for vgs (1) */
4325 r = guestfs_umount_all (g);
4332 r = guestfs_lvm_remove_all (g);
4336 /* TestOutputList for vgs (1) */
4346 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4353 r = guestfs_pvcreate (g, "/dev/sda1");
4360 r = guestfs_pvcreate (g, "/dev/sda2");
4367 r = guestfs_pvcreate (g, "/dev/sda3");
4372 char *physvols[] = {
4379 r = guestfs_vgcreate (g, "VG1", physvols);
4384 char *physvols[] = {
4390 r = guestfs_vgcreate (g, "VG2", physvols);
4398 r = guestfs_vgs (g);
4402 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4406 if (strcmp (r[0], "VG1") != 0) {
4407 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
4411 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4415 if (strcmp (r[1], "VG2") != 0) {
4416 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
4420 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
4424 for (i = 0; r[i] != NULL; ++i)
4431 static int test_pvs_0 (void)
4433 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
4437 r = guestfs_umount_all (g);
4444 r = guestfs_lvm_remove_all (g);
4455 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4462 r = guestfs_pvcreate (g, "/dev/sda1");
4467 char *physvols[] = {
4473 r = guestfs_vgcreate (g, "VG", physvols);
4480 r = guestfs_lvcreate (g, "LV", "VG", 8);
4487 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4494 r = guestfs_mount (g, "/dev/VG/LV", "/");
4498 /* TestOutputList for pvs (0) */
4503 r = guestfs_pvs (g);
4507 fprintf (stderr, "test_pvs_0: short list returned from command\n");
4511 if (strcmp (r[0], "/dev/sda1") != 0) {
4512 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4516 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
4520 for (i = 0; r[i] != NULL; ++i)
4527 static int test_pvs_1 (void)
4529 /* InitEmpty for pvs (1) */
4533 r = guestfs_umount_all (g);
4540 r = guestfs_lvm_remove_all (g);
4544 /* TestOutputList for pvs (1) */
4554 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4561 r = guestfs_pvcreate (g, "/dev/sda1");
4568 r = guestfs_pvcreate (g, "/dev/sda2");
4575 r = guestfs_pvcreate (g, "/dev/sda3");
4583 r = guestfs_pvs (g);
4587 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4591 if (strcmp (r[0], "/dev/sda1") != 0) {
4592 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4596 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4600 if (strcmp (r[1], "/dev/sda2") != 0) {
4601 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4605 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4609 if (strcmp (r[2], "/dev/sda3") != 0) {
4610 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4614 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
4618 for (i = 0; r[i] != NULL; ++i)
4625 static int test_list_partitions_0 (void)
4627 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
4631 r = guestfs_umount_all (g);
4638 r = guestfs_lvm_remove_all (g);
4649 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4656 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4663 r = guestfs_mount (g, "/dev/sda1", "/");
4667 /* TestOutputList for list_partitions (0) */
4672 r = guestfs_list_partitions (g);
4676 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
4680 if (strcmp (r[0], "/dev/sda1") != 0) {
4681 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4685 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
4689 for (i = 0; r[i] != NULL; ++i)
4696 static int test_list_partitions_1 (void)
4698 /* InitEmpty for list_partitions (1) */
4702 r = guestfs_umount_all (g);
4709 r = guestfs_lvm_remove_all (g);
4713 /* TestOutputList for list_partitions (1) */
4723 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4731 r = guestfs_list_partitions (g);
4735 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4739 if (strcmp (r[0], "/dev/sda1") != 0) {
4740 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4744 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4748 if (strcmp (r[1], "/dev/sda2") != 0) {
4749 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4753 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4757 if (strcmp (r[2], "/dev/sda3") != 0) {
4758 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4762 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
4766 for (i = 0; r[i] != NULL; ++i)
4773 static int test_list_devices_0 (void)
4775 /* InitEmpty for list_devices (0) */
4779 r = guestfs_umount_all (g);
4786 r = guestfs_lvm_remove_all (g);
4790 /* TestOutputList for list_devices (0) */
4795 r = guestfs_list_devices (g);
4799 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4803 if (strcmp (r[0], "/dev/sda") != 0) {
4804 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4808 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4812 if (strcmp (r[1], "/dev/sdb") != 0) {
4813 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4817 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4821 if (strcmp (r[2], "/dev/sdc") != 0) {
4822 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4826 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4830 for (i = 0; r[i] != NULL; ++i)
4837 static int test_ls_0 (void)
4839 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4843 r = guestfs_umount_all (g);
4850 r = guestfs_lvm_remove_all (g);
4861 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4868 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4875 r = guestfs_mount (g, "/dev/sda1", "/");
4879 /* TestOutputList for ls (0) */
4883 r = guestfs_touch (g, "/new");
4890 r = guestfs_touch (g, "/newer");
4897 r = guestfs_touch (g, "/newest");
4905 r = guestfs_ls (g, "/");
4909 fprintf (stderr, "test_ls_0: short list returned from command\n");
4913 if (strcmp (r[0], "lost+found") != 0) {
4914 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
4918 fprintf (stderr, "test_ls_0: short list returned from command\n");
4922 if (strcmp (r[1], "new") != 0) {
4923 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
4927 fprintf (stderr, "test_ls_0: short list returned from command\n");
4931 if (strcmp (r[2], "newer") != 0) {
4932 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
4936 fprintf (stderr, "test_ls_0: short list returned from command\n");
4940 if (strcmp (r[3], "newest") != 0) {
4941 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
4945 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
4949 for (i = 0; r[i] != NULL; ++i)
4956 static int test_cat_0 (void)
4958 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
4962 r = guestfs_umount_all (g);
4969 r = guestfs_lvm_remove_all (g);
4980 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4987 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4994 r = guestfs_mount (g, "/dev/sda1", "/");
4998 /* TestOutput for cat (0) */
5002 r = guestfs_write_file (g, "/new", "new file contents", 0);
5009 r = guestfs_cat (g, "/new");
5012 if (strcmp (r, "new file contents") != 0) {
5013 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
5021 static int test_touch_0 (void)
5023 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
5027 r = guestfs_umount_all (g);
5034 r = guestfs_lvm_remove_all (g);
5045 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5052 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5059 r = guestfs_mount (g, "/dev/sda1", "/");
5063 /* TestOutputTrue for touch (0) */
5067 r = guestfs_touch (g, "/new");
5074 r = guestfs_exists (g, "/new");
5078 fprintf (stderr, "test_touch_0: expected true, got false\n");
5085 static int test_sync_0 (void)
5087 /* InitEmpty for sync (0) */
5091 r = guestfs_umount_all (g);
5098 r = guestfs_lvm_remove_all (g);
5102 /* TestRun for sync (0) */
5106 r = guestfs_sync (g);
5113 static int test_mount_0 (void)
5115 /* InitEmpty for mount (0) */
5119 r = guestfs_umount_all (g);
5126 r = guestfs_lvm_remove_all (g);
5130 /* TestOutput for mount (0) */
5138 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5145 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5152 r = guestfs_mount (g, "/dev/sda1", "/");
5159 r = guestfs_write_file (g, "/new", "new file contents", 0);
5166 r = guestfs_cat (g, "/new");
5169 if (strcmp (r, "new file contents") != 0) {
5170 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
5178 int main (int argc, char *argv[])
5183 const char *filename;
5185 int nr_tests, test_num = 0;
5187 no_test_warnings ();
5189 g = guestfs_create ();
5191 printf ("guestfs_create FAILED\n");
5195 guestfs_set_error_handler (g, print_error, NULL);
5197 srcdir = getenv ("srcdir");
5198 if (!srcdir) srcdir = ".";
5200 guestfs_set_path (g, ".");
5202 filename = "test1.img";
5203 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5208 if (lseek (fd, 524288000, SEEK_SET) == -1) {
5214 if (write (fd, &c, 1) == -1) {
5220 if (close (fd) == -1) {
5225 if (guestfs_add_drive (g, filename) == -1) {
5226 printf ("guestfs_add_drive %s FAILED\n", filename);
5230 filename = "test2.img";
5231 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5236 if (lseek (fd, 52428800, SEEK_SET) == -1) {
5242 if (write (fd, &c, 1) == -1) {
5248 if (close (fd) == -1) {
5253 if (guestfs_add_drive (g, filename) == -1) {
5254 printf ("guestfs_add_drive %s FAILED\n", filename);
5258 filename = "test3.img";
5259 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5264 if (lseek (fd, 10485760, SEEK_SET) == -1) {
5270 if (write (fd, &c, 1) == -1) {
5276 if (close (fd) == -1) {
5281 if (guestfs_add_drive (g, filename) == -1) {
5282 printf ("guestfs_add_drive %s FAILED\n", filename);
5286 if (guestfs_launch (g) == -1) {
5287 printf ("guestfs_launch FAILED\n");
5290 if (guestfs_wait_ready (g) == -1) {
5291 printf ("guestfs_wait_ready FAILED\n");
5298 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
5299 if (test_tgz_in_0 () == -1) {
5300 printf ("test_tgz_in_0 FAILED\n");
5304 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
5305 if (test_tar_in_0 () == -1) {
5306 printf ("test_tar_in_0 FAILED\n");
5310 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
5311 if (test_checksum_0 () == -1) {
5312 printf ("test_checksum_0 FAILED\n");
5316 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
5317 if (test_checksum_1 () == -1) {
5318 printf ("test_checksum_1 FAILED\n");
5322 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
5323 if (test_checksum_2 () == -1) {
5324 printf ("test_checksum_2 FAILED\n");
5328 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
5329 if (test_checksum_3 () == -1) {
5330 printf ("test_checksum_3 FAILED\n");
5334 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
5335 if (test_checksum_4 () == -1) {
5336 printf ("test_checksum_4 FAILED\n");
5340 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
5341 if (test_checksum_5 () == -1) {
5342 printf ("test_checksum_5 FAILED\n");
5346 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
5347 if (test_checksum_6 () == -1) {
5348 printf ("test_checksum_6 FAILED\n");
5352 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
5353 if (test_checksum_7 () == -1) {
5354 printf ("test_checksum_7 FAILED\n");
5358 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
5359 if (test_download_0 () == -1) {
5360 printf ("test_download_0 FAILED\n");
5364 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
5365 if (test_upload_0 () == -1) {
5366 printf ("test_upload_0 FAILED\n");
5370 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
5371 if (test_blockdev_rereadpt_0 () == -1) {
5372 printf ("test_blockdev_rereadpt_0 FAILED\n");
5376 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
5377 if (test_blockdev_flushbufs_0 () == -1) {
5378 printf ("test_blockdev_flushbufs_0 FAILED\n");
5382 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
5383 if (test_blockdev_getsize64_0 () == -1) {
5384 printf ("test_blockdev_getsize64_0 FAILED\n");
5388 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
5389 if (test_blockdev_getsz_0 () == -1) {
5390 printf ("test_blockdev_getsz_0 FAILED\n");
5394 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
5395 if (test_blockdev_getbsz_0 () == -1) {
5396 printf ("test_blockdev_getbsz_0 FAILED\n");
5400 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
5401 if (test_blockdev_getss_0 () == -1) {
5402 printf ("test_blockdev_getss_0 FAILED\n");
5406 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
5407 if (test_blockdev_getro_0 () == -1) {
5408 printf ("test_blockdev_getro_0 FAILED\n");
5412 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
5413 if (test_blockdev_setrw_0 () == -1) {
5414 printf ("test_blockdev_setrw_0 FAILED\n");
5418 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
5419 if (test_blockdev_setro_0 () == -1) {
5420 printf ("test_blockdev_setro_0 FAILED\n");
5424 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
5425 if (test_statvfs_0 () == -1) {
5426 printf ("test_statvfs_0 FAILED\n");
5430 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
5431 if (test_lstat_0 () == -1) {
5432 printf ("test_lstat_0 FAILED\n");
5436 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
5437 if (test_stat_0 () == -1) {
5438 printf ("test_stat_0 FAILED\n");
5442 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
5443 if (test_file_0 () == -1) {
5444 printf ("test_file_0 FAILED\n");
5448 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
5449 if (test_file_1 () == -1) {
5450 printf ("test_file_1 FAILED\n");
5454 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
5455 if (test_file_2 () == -1) {
5456 printf ("test_file_2 FAILED\n");
5460 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
5461 if (test_umount_all_0 () == -1) {
5462 printf ("test_umount_all_0 FAILED\n");
5466 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
5467 if (test_mounts_0 () == -1) {
5468 printf ("test_mounts_0 FAILED\n");
5472 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
5473 if (test_umount_0 () == -1) {
5474 printf ("test_umount_0 FAILED\n");
5478 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
5479 if (test_umount_1 () == -1) {
5480 printf ("test_umount_1 FAILED\n");
5484 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
5485 if (test_write_file_0 () == -1) {
5486 printf ("test_write_file_0 FAILED\n");
5490 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
5491 if (test_write_file_1 () == -1) {
5492 printf ("test_write_file_1 FAILED\n");
5496 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
5497 if (test_write_file_2 () == -1) {
5498 printf ("test_write_file_2 FAILED\n");
5502 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
5503 if (test_write_file_3 () == -1) {
5504 printf ("test_write_file_3 FAILED\n");
5508 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
5509 if (test_write_file_4 () == -1) {
5510 printf ("test_write_file_4 FAILED\n");
5514 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
5515 if (test_write_file_5 () == -1) {
5516 printf ("test_write_file_5 FAILED\n");
5520 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
5521 if (test_mkfs_0 () == -1) {
5522 printf ("test_mkfs_0 FAILED\n");
5526 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
5527 if (test_lvcreate_0 () == -1) {
5528 printf ("test_lvcreate_0 FAILED\n");
5532 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
5533 if (test_vgcreate_0 () == -1) {
5534 printf ("test_vgcreate_0 FAILED\n");
5538 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
5539 if (test_pvcreate_0 () == -1) {
5540 printf ("test_pvcreate_0 FAILED\n");
5544 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
5545 if (test_is_dir_0 () == -1) {
5546 printf ("test_is_dir_0 FAILED\n");
5550 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
5551 if (test_is_dir_1 () == -1) {
5552 printf ("test_is_dir_1 FAILED\n");
5556 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
5557 if (test_is_file_0 () == -1) {
5558 printf ("test_is_file_0 FAILED\n");
5562 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
5563 if (test_is_file_1 () == -1) {
5564 printf ("test_is_file_1 FAILED\n");
5568 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
5569 if (test_exists_0 () == -1) {
5570 printf ("test_exists_0 FAILED\n");
5574 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
5575 if (test_exists_1 () == -1) {
5576 printf ("test_exists_1 FAILED\n");
5580 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
5581 if (test_mkdir_p_0 () == -1) {
5582 printf ("test_mkdir_p_0 FAILED\n");
5586 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
5587 if (test_mkdir_p_1 () == -1) {
5588 printf ("test_mkdir_p_1 FAILED\n");
5592 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
5593 if (test_mkdir_p_2 () == -1) {
5594 printf ("test_mkdir_p_2 FAILED\n");
5598 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
5599 if (test_mkdir_0 () == -1) {
5600 printf ("test_mkdir_0 FAILED\n");
5604 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
5605 if (test_mkdir_1 () == -1) {
5606 printf ("test_mkdir_1 FAILED\n");
5610 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
5611 if (test_rm_rf_0 () == -1) {
5612 printf ("test_rm_rf_0 FAILED\n");
5616 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
5617 if (test_rmdir_0 () == -1) {
5618 printf ("test_rmdir_0 FAILED\n");
5622 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
5623 if (test_rmdir_1 () == -1) {
5624 printf ("test_rmdir_1 FAILED\n");
5628 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
5629 if (test_rmdir_2 () == -1) {
5630 printf ("test_rmdir_2 FAILED\n");
5634 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
5635 if (test_rm_0 () == -1) {
5636 printf ("test_rm_0 FAILED\n");
5640 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
5641 if (test_rm_1 () == -1) {
5642 printf ("test_rm_1 FAILED\n");
5646 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
5647 if (test_rm_2 () == -1) {
5648 printf ("test_rm_2 FAILED\n");
5652 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
5653 if (test_read_lines_0 () == -1) {
5654 printf ("test_read_lines_0 FAILED\n");
5658 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
5659 if (test_read_lines_1 () == -1) {
5660 printf ("test_read_lines_1 FAILED\n");
5664 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
5665 if (test_lvs_0 () == -1) {
5666 printf ("test_lvs_0 FAILED\n");
5670 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
5671 if (test_lvs_1 () == -1) {
5672 printf ("test_lvs_1 FAILED\n");
5676 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
5677 if (test_vgs_0 () == -1) {
5678 printf ("test_vgs_0 FAILED\n");
5682 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
5683 if (test_vgs_1 () == -1) {
5684 printf ("test_vgs_1 FAILED\n");
5688 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
5689 if (test_pvs_0 () == -1) {
5690 printf ("test_pvs_0 FAILED\n");
5694 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
5695 if (test_pvs_1 () == -1) {
5696 printf ("test_pvs_1 FAILED\n");
5700 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
5701 if (test_list_partitions_0 () == -1) {
5702 printf ("test_list_partitions_0 FAILED\n");
5706 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
5707 if (test_list_partitions_1 () == -1) {
5708 printf ("test_list_partitions_1 FAILED\n");
5712 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
5713 if (test_list_devices_0 () == -1) {
5714 printf ("test_list_devices_0 FAILED\n");
5718 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
5719 if (test_ls_0 () == -1) {
5720 printf ("test_ls_0 FAILED\n");
5724 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
5725 if (test_cat_0 () == -1) {
5726 printf ("test_cat_0 FAILED\n");
5730 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
5731 if (test_touch_0 () == -1) {
5732 printf ("test_touch_0 FAILED\n");
5736 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
5737 if (test_sync_0 () == -1) {
5738 printf ("test_sync_0 FAILED\n");
5742 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
5743 if (test_mount_0 () == -1) {
5744 printf ("test_mount_0 FAILED\n");
5749 unlink ("test1.img");
5750 unlink ("test2.img");
5751 unlink ("test3.img");
5754 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);