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");
106 static int test_checksum_0 (void)
108 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
112 r = guestfs_umount_all (g);
119 r = guestfs_lvm_remove_all (g);
130 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
137 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
144 r = guestfs_mount (g, "/dev/sda1", "/");
148 /* TestOutput for checksum (0) */
152 r = guestfs_write_file (g, "/new", "test\n", 0);
159 r = guestfs_checksum (g, "crc", "/new");
162 if (strcmp (r, "935282863") != 0) {
163 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
171 static int test_checksum_1 (void)
173 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
177 r = guestfs_umount_all (g);
184 r = guestfs_lvm_remove_all (g);
195 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
202 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
209 r = guestfs_mount (g, "/dev/sda1", "/");
213 /* TestLastFail for checksum (1) */
217 r = guestfs_checksum (g, "crc", "/new");
225 static int test_checksum_2 (void)
227 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
231 r = guestfs_umount_all (g);
238 r = guestfs_lvm_remove_all (g);
249 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
256 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
263 r = guestfs_mount (g, "/dev/sda1", "/");
267 /* TestOutput for checksum (2) */
271 r = guestfs_write_file (g, "/new", "test\n", 0);
278 r = guestfs_checksum (g, "md5", "/new");
281 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
282 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
290 static int test_checksum_3 (void)
292 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
296 r = guestfs_umount_all (g);
303 r = guestfs_lvm_remove_all (g);
314 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
321 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
328 r = guestfs_mount (g, "/dev/sda1", "/");
332 /* TestOutput for checksum (3) */
336 r = guestfs_write_file (g, "/new", "test\n", 0);
343 r = guestfs_checksum (g, "sha1", "/new");
346 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
347 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
355 static int test_checksum_4 (void)
357 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
361 r = guestfs_umount_all (g);
368 r = guestfs_lvm_remove_all (g);
379 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
386 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
393 r = guestfs_mount (g, "/dev/sda1", "/");
397 /* TestOutput for checksum (4) */
401 r = guestfs_write_file (g, "/new", "test\n", 0);
408 r = guestfs_checksum (g, "sha224", "/new");
411 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
412 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
420 static int test_checksum_5 (void)
422 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
426 r = guestfs_umount_all (g);
433 r = guestfs_lvm_remove_all (g);
444 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
451 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
458 r = guestfs_mount (g, "/dev/sda1", "/");
462 /* TestOutput for checksum (5) */
466 r = guestfs_write_file (g, "/new", "test\n", 0);
473 r = guestfs_checksum (g, "sha256", "/new");
476 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
477 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
485 static int test_checksum_6 (void)
487 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
491 r = guestfs_umount_all (g);
498 r = guestfs_lvm_remove_all (g);
509 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
516 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
523 r = guestfs_mount (g, "/dev/sda1", "/");
527 /* TestOutput for checksum (6) */
531 r = guestfs_write_file (g, "/new", "test\n", 0);
538 r = guestfs_checksum (g, "sha384", "/new");
541 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
542 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
550 static int test_checksum_7 (void)
552 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
556 r = guestfs_umount_all (g);
563 r = guestfs_lvm_remove_all (g);
574 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
581 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
588 r = guestfs_mount (g, "/dev/sda1", "/");
592 /* TestOutput for checksum (7) */
596 r = guestfs_write_file (g, "/new", "test\n", 0);
603 r = guestfs_checksum (g, "sha512", "/new");
606 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
607 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
615 static int test_download_0 (void)
617 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
621 r = guestfs_umount_all (g);
628 r = guestfs_lvm_remove_all (g);
639 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
646 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
653 r = guestfs_mount (g, "/dev/sda1", "/");
657 /* TestOutput for download (0) */
661 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
668 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
675 r = guestfs_upload (g, "testdownload.tmp", "/upload");
682 r = guestfs_checksum (g, "md5", "/upload");
685 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
686 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
694 static int test_upload_0 (void)
696 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
700 r = guestfs_umount_all (g);
707 r = guestfs_lvm_remove_all (g);
718 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
725 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
732 r = guestfs_mount (g, "/dev/sda1", "/");
736 /* TestOutput for upload (0) */
740 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
747 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
750 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
751 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
759 static int test_blockdev_rereadpt_0 (void)
761 /* InitEmpty for blockdev_rereadpt (0) */
765 r = guestfs_umount_all (g);
772 r = guestfs_lvm_remove_all (g);
776 /* TestRun for blockdev_rereadpt (0) */
780 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
787 static int test_blockdev_flushbufs_0 (void)
789 /* InitEmpty for blockdev_flushbufs (0) */
793 r = guestfs_umount_all (g);
800 r = guestfs_lvm_remove_all (g);
804 /* TestRun for blockdev_flushbufs (0) */
808 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
815 static int test_blockdev_getsize64_0 (void)
817 /* InitEmpty for blockdev_getsize64 (0) */
821 r = guestfs_umount_all (g);
828 r = guestfs_lvm_remove_all (g);
832 /* TestOutputInt for blockdev_getsize64 (0) */
836 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
839 if (r != 524288000) {
840 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
847 static int test_blockdev_getsz_0 (void)
849 /* InitEmpty for blockdev_getsz (0) */
853 r = guestfs_umount_all (g);
860 r = guestfs_lvm_remove_all (g);
864 /* TestOutputInt for blockdev_getsz (0) */
868 r = guestfs_blockdev_getsz (g, "/dev/sda");
872 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
879 static int test_blockdev_getbsz_0 (void)
881 /* InitEmpty for blockdev_getbsz (0) */
885 r = guestfs_umount_all (g);
892 r = guestfs_lvm_remove_all (g);
896 /* TestOutputInt for blockdev_getbsz (0) */
900 r = guestfs_blockdev_getbsz (g, "/dev/sda");
904 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
911 static int test_blockdev_getss_0 (void)
913 /* InitEmpty for blockdev_getss (0) */
917 r = guestfs_umount_all (g);
924 r = guestfs_lvm_remove_all (g);
928 /* TestOutputInt for blockdev_getss (0) */
932 r = guestfs_blockdev_getss (g, "/dev/sda");
936 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
943 static int test_blockdev_getro_0 (void)
945 /* InitEmpty for blockdev_getro (0) */
949 r = guestfs_umount_all (g);
956 r = guestfs_lvm_remove_all (g);
960 /* TestOutputTrue for blockdev_getro (0) */
964 r = guestfs_blockdev_setro (g, "/dev/sda");
971 r = guestfs_blockdev_getro (g, "/dev/sda");
975 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
982 static int test_blockdev_setrw_0 (void)
984 /* InitEmpty for blockdev_setrw (0) */
988 r = guestfs_umount_all (g);
995 r = guestfs_lvm_remove_all (g);
999 /* TestOutputFalse for blockdev_setrw (0) */
1003 r = guestfs_blockdev_setrw (g, "/dev/sda");
1010 r = guestfs_blockdev_getro (g, "/dev/sda");
1014 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
1021 static int test_blockdev_setro_0 (void)
1023 /* InitEmpty for blockdev_setro (0) */
1027 r = guestfs_umount_all (g);
1034 r = guestfs_lvm_remove_all (g);
1038 /* TestOutputTrue for blockdev_setro (0) */
1042 r = guestfs_blockdev_setro (g, "/dev/sda");
1049 r = guestfs_blockdev_getro (g, "/dev/sda");
1053 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
1060 static int test_statvfs_0 (void)
1062 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
1066 r = guestfs_umount_all (g);
1073 r = guestfs_lvm_remove_all (g);
1084 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1091 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1098 r = guestfs_mount (g, "/dev/sda1", "/");
1102 /* TestOutputStruct for statvfs (0) */
1104 struct guestfs_statvfs *r;
1106 r = guestfs_statvfs (g, "/");
1109 if (r->bfree != 487702) {
1110 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
1114 if (r->blocks != 490020) {
1115 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
1119 if (r->bsize != 1024) {
1120 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
1129 static int test_lstat_0 (void)
1131 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
1135 r = guestfs_umount_all (g);
1142 r = guestfs_lvm_remove_all (g);
1153 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1160 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1167 r = guestfs_mount (g, "/dev/sda1", "/");
1171 /* TestOutputStruct for lstat (0) */
1175 r = guestfs_touch (g, "/new");
1180 struct guestfs_stat *r;
1182 r = guestfs_lstat (g, "/new");
1186 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
1195 static int test_stat_0 (void)
1197 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
1201 r = guestfs_umount_all (g);
1208 r = guestfs_lvm_remove_all (g);
1219 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1226 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1233 r = guestfs_mount (g, "/dev/sda1", "/");
1237 /* TestOutputStruct for stat (0) */
1241 r = guestfs_touch (g, "/new");
1246 struct guestfs_stat *r;
1248 r = guestfs_stat (g, "/new");
1252 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
1261 static int test_file_0 (void)
1263 /* InitBasicFS for file (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 /* TestOutput for file (0) */
1307 r = guestfs_touch (g, "/new");
1314 r = guestfs_file (g, "/new");
1317 if (strcmp (r, "empty") != 0) {
1318 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
1326 static int test_file_1 (void)
1328 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
1332 r = guestfs_umount_all (g);
1339 r = guestfs_lvm_remove_all (g);
1350 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1357 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1364 r = guestfs_mount (g, "/dev/sda1", "/");
1368 /* TestOutput for file (1) */
1372 r = guestfs_write_file (g, "/new", "some content\n", 0);
1379 r = guestfs_file (g, "/new");
1382 if (strcmp (r, "ASCII text") != 0) {
1383 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
1391 static int test_file_2 (void)
1393 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
1397 r = guestfs_umount_all (g);
1404 r = guestfs_lvm_remove_all (g);
1415 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1422 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1429 r = guestfs_mount (g, "/dev/sda1", "/");
1433 /* TestLastFail for file (2) */
1437 r = guestfs_file (g, "/nofile");
1445 static int test_umount_all_0 (void)
1447 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
1451 r = guestfs_umount_all (g);
1458 r = guestfs_lvm_remove_all (g);
1469 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1476 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1483 r = guestfs_mount (g, "/dev/sda1", "/");
1487 /* TestOutputList for umount_all (0) */
1491 r = guestfs_umount_all (g);
1499 r = guestfs_mounts (g);
1503 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
1507 for (i = 0; r[i] != NULL; ++i)
1514 static int test_mounts_0 (void)
1516 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
1520 r = guestfs_umount_all (g);
1527 r = guestfs_lvm_remove_all (g);
1538 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1545 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1552 r = guestfs_mount (g, "/dev/sda1", "/");
1556 /* TestOutputList for mounts (0) */
1561 r = guestfs_mounts (g);
1565 fprintf (stderr, "test_mounts_0: short list returned from command\n");
1569 if (strcmp (r[0], "/dev/sda1") != 0) {
1570 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1574 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
1578 for (i = 0; r[i] != NULL; ++i)
1585 static int test_umount_0 (void)
1587 /* InitEmpty for umount (0) */
1591 r = guestfs_umount_all (g);
1598 r = guestfs_lvm_remove_all (g);
1602 /* TestOutputList for umount (0) */
1610 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1617 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1624 r = guestfs_mount (g, "/dev/sda1", "/");
1632 r = guestfs_mounts (g);
1636 fprintf (stderr, "test_umount_0: short list returned from command\n");
1640 if (strcmp (r[0], "/dev/sda1") != 0) {
1641 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
1645 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
1649 for (i = 0; r[i] != NULL; ++i)
1656 static int test_umount_1 (void)
1658 /* InitEmpty for umount (1) */
1662 r = guestfs_umount_all (g);
1669 r = guestfs_lvm_remove_all (g);
1673 /* TestOutputList for umount (1) */
1681 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1688 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1695 r = guestfs_mount (g, "/dev/sda1", "/");
1702 r = guestfs_umount (g, "/");
1710 r = guestfs_mounts (g);
1714 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
1718 for (i = 0; r[i] != NULL; ++i)
1725 static int test_write_file_0 (void)
1727 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
1731 r = guestfs_umount_all (g);
1738 r = guestfs_lvm_remove_all (g);
1749 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1756 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1763 r = guestfs_mount (g, "/dev/sda1", "/");
1767 /* TestOutput for write_file (0) */
1771 r = guestfs_write_file (g, "/new", "new file contents", 0);
1778 r = guestfs_cat (g, "/new");
1781 if (strcmp (r, "new file contents") != 0) {
1782 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
1790 static int test_write_file_1 (void)
1792 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
1796 r = guestfs_umount_all (g);
1803 r = guestfs_lvm_remove_all (g);
1814 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1821 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1828 r = guestfs_mount (g, "/dev/sda1", "/");
1832 /* TestOutput for write_file (1) */
1836 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
1843 r = guestfs_cat (g, "/new");
1846 if (strcmp (r, "\nnew file contents\n") != 0) {
1847 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
1855 static int test_write_file_2 (void)
1857 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
1861 r = guestfs_umount_all (g);
1868 r = guestfs_lvm_remove_all (g);
1879 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1886 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1893 r = guestfs_mount (g, "/dev/sda1", "/");
1897 /* TestOutput for write_file (2) */
1901 r = guestfs_write_file (g, "/new", "\n\n", 0);
1908 r = guestfs_cat (g, "/new");
1911 if (strcmp (r, "\n\n") != 0) {
1912 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
1920 static int test_write_file_3 (void)
1922 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
1926 r = guestfs_umount_all (g);
1933 r = guestfs_lvm_remove_all (g);
1944 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1951 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1958 r = guestfs_mount (g, "/dev/sda1", "/");
1962 /* TestOutput for write_file (3) */
1966 r = guestfs_write_file (g, "/new", "", 0);
1973 r = guestfs_cat (g, "/new");
1976 if (strcmp (r, "") != 0) {
1977 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
1985 static int test_write_file_4 (void)
1987 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
1991 r = guestfs_umount_all (g);
1998 r = guestfs_lvm_remove_all (g);
2009 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2016 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2023 r = guestfs_mount (g, "/dev/sda1", "/");
2027 /* TestOutput for write_file (4) */
2031 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
2038 r = guestfs_cat (g, "/new");
2041 if (strcmp (r, "\n\n\n") != 0) {
2042 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
2050 static int test_write_file_5 (void)
2052 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
2056 r = guestfs_umount_all (g);
2063 r = guestfs_lvm_remove_all (g);
2074 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2081 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2088 r = guestfs_mount (g, "/dev/sda1", "/");
2092 /* TestOutput for write_file (5) */
2096 r = guestfs_write_file (g, "/new", "\n", 0);
2103 r = guestfs_cat (g, "/new");
2106 if (strcmp (r, "\n") != 0) {
2107 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
2115 static int test_mkfs_0 (void)
2117 /* InitEmpty for mkfs (0) */
2121 r = guestfs_umount_all (g);
2128 r = guestfs_lvm_remove_all (g);
2132 /* TestOutput for mkfs (0) */
2140 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2147 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2154 r = guestfs_mount (g, "/dev/sda1", "/");
2161 r = guestfs_write_file (g, "/new", "new file contents", 0);
2168 r = guestfs_cat (g, "/new");
2171 if (strcmp (r, "new file contents") != 0) {
2172 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
2180 static int test_lvcreate_0 (void)
2182 /* InitEmpty for lvcreate (0) */
2186 r = guestfs_umount_all (g);
2193 r = guestfs_lvm_remove_all (g);
2197 /* TestOutputList for lvcreate (0) */
2207 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2214 r = guestfs_pvcreate (g, "/dev/sda1");
2221 r = guestfs_pvcreate (g, "/dev/sda2");
2228 r = guestfs_pvcreate (g, "/dev/sda3");
2233 char *physvols[] = {
2240 r = guestfs_vgcreate (g, "VG1", physvols);
2245 char *physvols[] = {
2251 r = guestfs_vgcreate (g, "VG2", physvols);
2258 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
2265 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
2272 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
2279 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
2286 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
2294 r = guestfs_lvs (g);
2298 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2302 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
2303 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
2307 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2311 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
2312 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
2316 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2320 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
2321 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
2325 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2329 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
2330 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
2334 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
2338 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
2339 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
2343 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
2347 for (i = 0; r[i] != NULL; ++i)
2354 static int test_vgcreate_0 (void)
2356 /* InitEmpty for vgcreate (0) */
2360 r = guestfs_umount_all (g);
2367 r = guestfs_lvm_remove_all (g);
2371 /* TestOutputList for vgcreate (0) */
2381 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2388 r = guestfs_pvcreate (g, "/dev/sda1");
2395 r = guestfs_pvcreate (g, "/dev/sda2");
2402 r = guestfs_pvcreate (g, "/dev/sda3");
2407 char *physvols[] = {
2414 r = guestfs_vgcreate (g, "VG1", physvols);
2419 char *physvols[] = {
2425 r = guestfs_vgcreate (g, "VG2", physvols);
2433 r = guestfs_vgs (g);
2437 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2441 if (strcmp (r[0], "VG1") != 0) {
2442 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
2446 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
2450 if (strcmp (r[1], "VG2") != 0) {
2451 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
2455 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
2459 for (i = 0; r[i] != NULL; ++i)
2466 static int test_pvcreate_0 (void)
2468 /* InitEmpty for pvcreate (0) */
2472 r = guestfs_umount_all (g);
2479 r = guestfs_lvm_remove_all (g);
2483 /* TestOutputList for pvcreate (0) */
2493 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2500 r = guestfs_pvcreate (g, "/dev/sda1");
2507 r = guestfs_pvcreate (g, "/dev/sda2");
2514 r = guestfs_pvcreate (g, "/dev/sda3");
2522 r = guestfs_pvs (g);
2526 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2530 if (strcmp (r[0], "/dev/sda1") != 0) {
2531 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2535 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2539 if (strcmp (r[1], "/dev/sda2") != 0) {
2540 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
2544 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
2548 if (strcmp (r[2], "/dev/sda3") != 0) {
2549 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
2553 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
2557 for (i = 0; r[i] != NULL; ++i)
2564 static int test_is_dir_0 (void)
2566 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
2570 r = guestfs_umount_all (g);
2577 r = guestfs_lvm_remove_all (g);
2588 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2595 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2602 r = guestfs_mount (g, "/dev/sda1", "/");
2606 /* TestOutputFalse for is_dir (0) */
2610 r = guestfs_touch (g, "/new");
2617 r = guestfs_is_dir (g, "/new");
2621 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
2628 static int test_is_dir_1 (void)
2630 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
2634 r = guestfs_umount_all (g);
2641 r = guestfs_lvm_remove_all (g);
2652 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2659 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2666 r = guestfs_mount (g, "/dev/sda1", "/");
2670 /* TestOutputTrue for is_dir (1) */
2674 r = guestfs_mkdir (g, "/new");
2681 r = guestfs_is_dir (g, "/new");
2685 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
2692 static int test_is_file_0 (void)
2694 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
2698 r = guestfs_umount_all (g);
2705 r = guestfs_lvm_remove_all (g);
2716 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2723 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2730 r = guestfs_mount (g, "/dev/sda1", "/");
2734 /* TestOutputTrue for is_file (0) */
2738 r = guestfs_touch (g, "/new");
2745 r = guestfs_is_file (g, "/new");
2749 fprintf (stderr, "test_is_file_0: expected true, got false\n");
2756 static int test_is_file_1 (void)
2758 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
2762 r = guestfs_umount_all (g);
2769 r = guestfs_lvm_remove_all (g);
2780 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2787 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2794 r = guestfs_mount (g, "/dev/sda1", "/");
2798 /* TestOutputFalse for is_file (1) */
2802 r = guestfs_mkdir (g, "/new");
2809 r = guestfs_is_file (g, "/new");
2813 fprintf (stderr, "test_is_file_1: expected false, got true\n");
2820 static int test_exists_0 (void)
2822 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
2826 r = guestfs_umount_all (g);
2833 r = guestfs_lvm_remove_all (g);
2844 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2851 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2858 r = guestfs_mount (g, "/dev/sda1", "/");
2862 /* TestOutputTrue for exists (0) */
2866 r = guestfs_touch (g, "/new");
2873 r = guestfs_exists (g, "/new");
2877 fprintf (stderr, "test_exists_0: expected true, got false\n");
2884 static int test_exists_1 (void)
2886 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
2890 r = guestfs_umount_all (g);
2897 r = guestfs_lvm_remove_all (g);
2908 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2915 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2922 r = guestfs_mount (g, "/dev/sda1", "/");
2926 /* TestOutputTrue for exists (1) */
2930 r = guestfs_mkdir (g, "/new");
2937 r = guestfs_exists (g, "/new");
2941 fprintf (stderr, "test_exists_1: expected true, got false\n");
2948 static int test_mkdir_p_0 (void)
2950 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
2954 r = guestfs_umount_all (g);
2961 r = guestfs_lvm_remove_all (g);
2972 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2979 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2986 r = guestfs_mount (g, "/dev/sda1", "/");
2990 /* TestOutputTrue for mkdir_p (0) */
2994 r = guestfs_mkdir_p (g, "/new/foo/bar");
3001 r = guestfs_is_dir (g, "/new/foo/bar");
3005 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
3012 static int test_mkdir_p_1 (void)
3014 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
3018 r = guestfs_umount_all (g);
3025 r = guestfs_lvm_remove_all (g);
3036 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3043 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3050 r = guestfs_mount (g, "/dev/sda1", "/");
3054 /* TestOutputTrue for mkdir_p (1) */
3058 r = guestfs_mkdir_p (g, "/new/foo/bar");
3065 r = guestfs_is_dir (g, "/new/foo");
3069 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
3076 static int test_mkdir_p_2 (void)
3078 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
3082 r = guestfs_umount_all (g);
3089 r = guestfs_lvm_remove_all (g);
3100 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3107 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3114 r = guestfs_mount (g, "/dev/sda1", "/");
3118 /* TestOutputTrue for mkdir_p (2) */
3122 r = guestfs_mkdir_p (g, "/new/foo/bar");
3129 r = guestfs_is_dir (g, "/new");
3133 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
3140 static int test_mkdir_0 (void)
3142 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
3146 r = guestfs_umount_all (g);
3153 r = guestfs_lvm_remove_all (g);
3164 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3171 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3178 r = guestfs_mount (g, "/dev/sda1", "/");
3182 /* TestOutputTrue for mkdir (0) */
3186 r = guestfs_mkdir (g, "/new");
3193 r = guestfs_is_dir (g, "/new");
3197 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
3204 static int test_mkdir_1 (void)
3206 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
3210 r = guestfs_umount_all (g);
3217 r = guestfs_lvm_remove_all (g);
3228 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3235 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3242 r = guestfs_mount (g, "/dev/sda1", "/");
3246 /* TestLastFail for mkdir (1) */
3250 r = guestfs_mkdir (g, "/new/foo/bar");
3257 static int test_rm_rf_0 (void)
3259 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
3263 r = guestfs_umount_all (g);
3270 r = guestfs_lvm_remove_all (g);
3281 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3288 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3295 r = guestfs_mount (g, "/dev/sda1", "/");
3299 /* TestOutputFalse for rm_rf (0) */
3303 r = guestfs_mkdir (g, "/new");
3310 r = guestfs_mkdir (g, "/new/foo");
3317 r = guestfs_touch (g, "/new/foo/bar");
3324 r = guestfs_rm_rf (g, "/new");
3331 r = guestfs_exists (g, "/new");
3335 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
3342 static int test_rmdir_0 (void)
3344 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
3348 r = guestfs_umount_all (g);
3355 r = guestfs_lvm_remove_all (g);
3366 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3373 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3380 r = guestfs_mount (g, "/dev/sda1", "/");
3384 /* TestRun for rmdir (0) */
3388 r = guestfs_mkdir (g, "/new");
3395 r = guestfs_rmdir (g, "/new");
3402 static int test_rmdir_1 (void)
3404 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
3408 r = guestfs_umount_all (g);
3415 r = guestfs_lvm_remove_all (g);
3426 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3433 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3440 r = guestfs_mount (g, "/dev/sda1", "/");
3444 /* TestLastFail for rmdir (1) */
3448 r = guestfs_rmdir (g, "/new");
3455 static int test_rmdir_2 (void)
3457 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
3461 r = guestfs_umount_all (g);
3468 r = guestfs_lvm_remove_all (g);
3479 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3486 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3493 r = guestfs_mount (g, "/dev/sda1", "/");
3497 /* TestLastFail for rmdir (2) */
3501 r = guestfs_touch (g, "/new");
3508 r = guestfs_rmdir (g, "/new");
3515 static int test_rm_0 (void)
3517 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
3521 r = guestfs_umount_all (g);
3528 r = guestfs_lvm_remove_all (g);
3539 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3546 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3553 r = guestfs_mount (g, "/dev/sda1", "/");
3557 /* TestRun for rm (0) */
3561 r = guestfs_touch (g, "/new");
3568 r = guestfs_rm (g, "/new");
3575 static int test_rm_1 (void)
3577 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
3581 r = guestfs_umount_all (g);
3588 r = guestfs_lvm_remove_all (g);
3599 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3606 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3613 r = guestfs_mount (g, "/dev/sda1", "/");
3617 /* TestLastFail for rm (1) */
3621 r = guestfs_rm (g, "/new");
3628 static int test_rm_2 (void)
3630 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
3634 r = guestfs_umount_all (g);
3641 r = guestfs_lvm_remove_all (g);
3652 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3659 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3666 r = guestfs_mount (g, "/dev/sda1", "/");
3670 /* TestLastFail for rm (2) */
3674 r = guestfs_mkdir (g, "/new");
3681 r = guestfs_rm (g, "/new");
3688 static int test_read_lines_0 (void)
3690 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
3694 r = guestfs_umount_all (g);
3701 r = guestfs_lvm_remove_all (g);
3712 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3719 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3726 r = guestfs_mount (g, "/dev/sda1", "/");
3730 /* TestOutputList for read_lines (0) */
3734 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
3742 r = guestfs_read_lines (g, "/new");
3746 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3750 if (strcmp (r[0], "line1") != 0) {
3751 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
3755 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3759 if (strcmp (r[1], "line2") != 0) {
3760 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
3764 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
3768 if (strcmp (r[2], "line3") != 0) {
3769 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
3773 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
3777 for (i = 0; r[i] != NULL; ++i)
3784 static int test_read_lines_1 (void)
3786 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
3790 r = guestfs_umount_all (g);
3797 r = guestfs_lvm_remove_all (g);
3808 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3815 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3822 r = guestfs_mount (g, "/dev/sda1", "/");
3826 /* TestOutputList for read_lines (1) */
3830 r = guestfs_write_file (g, "/new", "", 0);
3838 r = guestfs_read_lines (g, "/new");
3842 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
3846 for (i = 0; r[i] != NULL; ++i)
3853 static int test_lvs_0 (void)
3855 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
3859 r = guestfs_umount_all (g);
3866 r = guestfs_lvm_remove_all (g);
3877 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3884 r = guestfs_pvcreate (g, "/dev/sda1");
3889 char *physvols[] = {
3895 r = guestfs_vgcreate (g, "VG", physvols);
3902 r = guestfs_lvcreate (g, "LV", "VG", 8);
3909 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
3916 r = guestfs_mount (g, "/dev/VG/LV", "/");
3920 /* TestOutputList for lvs (0) */
3925 r = guestfs_lvs (g);
3929 fprintf (stderr, "test_lvs_0: short list returned from command\n");
3933 if (strcmp (r[0], "/dev/VG/LV") != 0) {
3934 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
3938 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
3942 for (i = 0; r[i] != NULL; ++i)
3949 static int test_lvs_1 (void)
3951 /* InitEmpty for lvs (1) */
3955 r = guestfs_umount_all (g);
3962 r = guestfs_lvm_remove_all (g);
3966 /* TestOutputList for lvs (1) */
3976 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3983 r = guestfs_pvcreate (g, "/dev/sda1");
3990 r = guestfs_pvcreate (g, "/dev/sda2");
3997 r = guestfs_pvcreate (g, "/dev/sda3");
4002 char *physvols[] = {
4009 r = guestfs_vgcreate (g, "VG1", physvols);
4014 char *physvols[] = {
4020 r = guestfs_vgcreate (g, "VG2", physvols);
4027 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4034 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4041 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4049 r = guestfs_lvs (g);
4053 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4057 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4058 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4062 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4066 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4067 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
4071 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4075 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
4076 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
4080 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
4084 for (i = 0; r[i] != NULL; ++i)
4091 static int test_vgs_0 (void)
4093 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
4097 r = guestfs_umount_all (g);
4104 r = guestfs_lvm_remove_all (g);
4115 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4122 r = guestfs_pvcreate (g, "/dev/sda1");
4127 char *physvols[] = {
4133 r = guestfs_vgcreate (g, "VG", physvols);
4140 r = guestfs_lvcreate (g, "LV", "VG", 8);
4147 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4154 r = guestfs_mount (g, "/dev/VG/LV", "/");
4158 /* TestOutputList for vgs (0) */
4163 r = guestfs_vgs (g);
4167 fprintf (stderr, "test_vgs_0: short list returned from command\n");
4171 if (strcmp (r[0], "VG") != 0) {
4172 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
4176 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
4180 for (i = 0; r[i] != NULL; ++i)
4187 static int test_vgs_1 (void)
4189 /* InitEmpty for vgs (1) */
4193 r = guestfs_umount_all (g);
4200 r = guestfs_lvm_remove_all (g);
4204 /* TestOutputList for vgs (1) */
4214 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4221 r = guestfs_pvcreate (g, "/dev/sda1");
4228 r = guestfs_pvcreate (g, "/dev/sda2");
4235 r = guestfs_pvcreate (g, "/dev/sda3");
4240 char *physvols[] = {
4247 r = guestfs_vgcreate (g, "VG1", physvols);
4252 char *physvols[] = {
4258 r = guestfs_vgcreate (g, "VG2", physvols);
4266 r = guestfs_vgs (g);
4270 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4274 if (strcmp (r[0], "VG1") != 0) {
4275 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
4279 fprintf (stderr, "test_vgs_1: short list returned from command\n");
4283 if (strcmp (r[1], "VG2") != 0) {
4284 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
4288 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
4292 for (i = 0; r[i] != NULL; ++i)
4299 static int test_pvs_0 (void)
4301 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
4305 r = guestfs_umount_all (g);
4312 r = guestfs_lvm_remove_all (g);
4323 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4330 r = guestfs_pvcreate (g, "/dev/sda1");
4335 char *physvols[] = {
4341 r = guestfs_vgcreate (g, "VG", physvols);
4348 r = guestfs_lvcreate (g, "LV", "VG", 8);
4355 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4362 r = guestfs_mount (g, "/dev/VG/LV", "/");
4366 /* TestOutputList for pvs (0) */
4371 r = guestfs_pvs (g);
4375 fprintf (stderr, "test_pvs_0: short list returned from command\n");
4379 if (strcmp (r[0], "/dev/sda1") != 0) {
4380 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4384 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
4388 for (i = 0; r[i] != NULL; ++i)
4395 static int test_pvs_1 (void)
4397 /* InitEmpty for pvs (1) */
4401 r = guestfs_umount_all (g);
4408 r = guestfs_lvm_remove_all (g);
4412 /* TestOutputList for pvs (1) */
4422 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4429 r = guestfs_pvcreate (g, "/dev/sda1");
4436 r = guestfs_pvcreate (g, "/dev/sda2");
4443 r = guestfs_pvcreate (g, "/dev/sda3");
4451 r = guestfs_pvs (g);
4455 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4459 if (strcmp (r[0], "/dev/sda1") != 0) {
4460 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4464 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4468 if (strcmp (r[1], "/dev/sda2") != 0) {
4469 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4473 fprintf (stderr, "test_pvs_1: short list returned from command\n");
4477 if (strcmp (r[2], "/dev/sda3") != 0) {
4478 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4482 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
4486 for (i = 0; r[i] != NULL; ++i)
4493 static int test_list_partitions_0 (void)
4495 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
4499 r = guestfs_umount_all (g);
4506 r = guestfs_lvm_remove_all (g);
4517 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4524 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4531 r = guestfs_mount (g, "/dev/sda1", "/");
4535 /* TestOutputList for list_partitions (0) */
4540 r = guestfs_list_partitions (g);
4544 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
4548 if (strcmp (r[0], "/dev/sda1") != 0) {
4549 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4553 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
4557 for (i = 0; r[i] != NULL; ++i)
4564 static int test_list_partitions_1 (void)
4566 /* InitEmpty for list_partitions (1) */
4570 r = guestfs_umount_all (g);
4577 r = guestfs_lvm_remove_all (g);
4581 /* TestOutputList for list_partitions (1) */
4591 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4599 r = guestfs_list_partitions (g);
4603 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4607 if (strcmp (r[0], "/dev/sda1") != 0) {
4608 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
4612 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4616 if (strcmp (r[1], "/dev/sda2") != 0) {
4617 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
4621 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
4625 if (strcmp (r[2], "/dev/sda3") != 0) {
4626 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
4630 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
4634 for (i = 0; r[i] != NULL; ++i)
4641 static int test_list_devices_0 (void)
4643 /* InitEmpty for list_devices (0) */
4647 r = guestfs_umount_all (g);
4654 r = guestfs_lvm_remove_all (g);
4658 /* TestOutputList for list_devices (0) */
4663 r = guestfs_list_devices (g);
4667 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4671 if (strcmp (r[0], "/dev/sda") != 0) {
4672 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
4676 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4680 if (strcmp (r[1], "/dev/sdb") != 0) {
4681 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
4685 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
4689 if (strcmp (r[2], "/dev/sdc") != 0) {
4690 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
4694 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
4698 for (i = 0; r[i] != NULL; ++i)
4705 static int test_ls_0 (void)
4707 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
4711 r = guestfs_umount_all (g);
4718 r = guestfs_lvm_remove_all (g);
4729 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4736 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4743 r = guestfs_mount (g, "/dev/sda1", "/");
4747 /* TestOutputList for ls (0) */
4751 r = guestfs_touch (g, "/new");
4758 r = guestfs_touch (g, "/newer");
4765 r = guestfs_touch (g, "/newest");
4773 r = guestfs_ls (g, "/");
4777 fprintf (stderr, "test_ls_0: short list returned from command\n");
4781 if (strcmp (r[0], "lost+found") != 0) {
4782 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
4786 fprintf (stderr, "test_ls_0: short list returned from command\n");
4790 if (strcmp (r[1], "new") != 0) {
4791 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
4795 fprintf (stderr, "test_ls_0: short list returned from command\n");
4799 if (strcmp (r[2], "newer") != 0) {
4800 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
4804 fprintf (stderr, "test_ls_0: short list returned from command\n");
4808 if (strcmp (r[3], "newest") != 0) {
4809 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
4813 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
4817 for (i = 0; r[i] != NULL; ++i)
4824 static int test_cat_0 (void)
4826 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
4830 r = guestfs_umount_all (g);
4837 r = guestfs_lvm_remove_all (g);
4848 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4855 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4862 r = guestfs_mount (g, "/dev/sda1", "/");
4866 /* TestOutput for cat (0) */
4870 r = guestfs_write_file (g, "/new", "new file contents", 0);
4877 r = guestfs_cat (g, "/new");
4880 if (strcmp (r, "new file contents") != 0) {
4881 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
4889 static int test_touch_0 (void)
4891 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
4895 r = guestfs_umount_all (g);
4902 r = guestfs_lvm_remove_all (g);
4913 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4920 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4927 r = guestfs_mount (g, "/dev/sda1", "/");
4931 /* TestOutputTrue for touch (0) */
4935 r = guestfs_touch (g, "/new");
4942 r = guestfs_exists (g, "/new");
4946 fprintf (stderr, "test_touch_0: expected true, got false\n");
4953 static int test_sync_0 (void)
4955 /* InitEmpty for sync (0) */
4959 r = guestfs_umount_all (g);
4966 r = guestfs_lvm_remove_all (g);
4970 /* TestRun for sync (0) */
4974 r = guestfs_sync (g);
4981 static int test_mount_0 (void)
4983 /* InitEmpty for mount (0) */
4987 r = guestfs_umount_all (g);
4994 r = guestfs_lvm_remove_all (g);
4998 /* TestOutput for mount (0) */
5006 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5013 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5020 r = guestfs_mount (g, "/dev/sda1", "/");
5027 r = guestfs_write_file (g, "/new", "new file contents", 0);
5034 r = guestfs_cat (g, "/new");
5037 if (strcmp (r, "new file contents") != 0) {
5038 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
5046 int main (int argc, char *argv[])
5053 int nr_tests, test_num = 0;
5055 no_test_warnings ();
5057 g = guestfs_create ();
5059 printf ("guestfs_create FAILED\n");
5063 guestfs_set_error_handler (g, print_error, NULL);
5065 srcdir = getenv ("srcdir");
5066 if (!srcdir) srcdir = ".";
5067 guestfs_set_path (g, srcdir);
5069 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
5070 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5075 if (lseek (fd, 524288000, SEEK_SET) == -1) {
5081 if (write (fd, &c, 1) == -1) {
5087 if (close (fd) == -1) {
5092 if (guestfs_add_drive (g, buf) == -1) {
5093 printf ("guestfs_add_drive %s FAILED\n", buf);
5097 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
5098 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5103 if (lseek (fd, 52428800, SEEK_SET) == -1) {
5109 if (write (fd, &c, 1) == -1) {
5115 if (close (fd) == -1) {
5120 if (guestfs_add_drive (g, buf) == -1) {
5121 printf ("guestfs_add_drive %s FAILED\n", buf);
5125 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
5126 fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
5131 if (lseek (fd, 10485760, SEEK_SET) == -1) {
5137 if (write (fd, &c, 1) == -1) {
5143 if (close (fd) == -1) {
5148 if (guestfs_add_drive (g, buf) == -1) {
5149 printf ("guestfs_add_drive %s FAILED\n", buf);
5153 if (guestfs_launch (g) == -1) {
5154 printf ("guestfs_launch FAILED\n");
5157 if (guestfs_wait_ready (g) == -1) {
5158 printf ("guestfs_wait_ready FAILED\n");
5165 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
5166 if (test_checksum_0 () == -1) {
5167 printf ("test_checksum_0 FAILED\n");
5171 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
5172 if (test_checksum_1 () == -1) {
5173 printf ("test_checksum_1 FAILED\n");
5177 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
5178 if (test_checksum_2 () == -1) {
5179 printf ("test_checksum_2 FAILED\n");
5183 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
5184 if (test_checksum_3 () == -1) {
5185 printf ("test_checksum_3 FAILED\n");
5189 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
5190 if (test_checksum_4 () == -1) {
5191 printf ("test_checksum_4 FAILED\n");
5195 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
5196 if (test_checksum_5 () == -1) {
5197 printf ("test_checksum_5 FAILED\n");
5201 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
5202 if (test_checksum_6 () == -1) {
5203 printf ("test_checksum_6 FAILED\n");
5207 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
5208 if (test_checksum_7 () == -1) {
5209 printf ("test_checksum_7 FAILED\n");
5213 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
5214 if (test_download_0 () == -1) {
5215 printf ("test_download_0 FAILED\n");
5219 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
5220 if (test_upload_0 () == -1) {
5221 printf ("test_upload_0 FAILED\n");
5225 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
5226 if (test_blockdev_rereadpt_0 () == -1) {
5227 printf ("test_blockdev_rereadpt_0 FAILED\n");
5231 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
5232 if (test_blockdev_flushbufs_0 () == -1) {
5233 printf ("test_blockdev_flushbufs_0 FAILED\n");
5237 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
5238 if (test_blockdev_getsize64_0 () == -1) {
5239 printf ("test_blockdev_getsize64_0 FAILED\n");
5243 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
5244 if (test_blockdev_getsz_0 () == -1) {
5245 printf ("test_blockdev_getsz_0 FAILED\n");
5249 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
5250 if (test_blockdev_getbsz_0 () == -1) {
5251 printf ("test_blockdev_getbsz_0 FAILED\n");
5255 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
5256 if (test_blockdev_getss_0 () == -1) {
5257 printf ("test_blockdev_getss_0 FAILED\n");
5261 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
5262 if (test_blockdev_getro_0 () == -1) {
5263 printf ("test_blockdev_getro_0 FAILED\n");
5267 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
5268 if (test_blockdev_setrw_0 () == -1) {
5269 printf ("test_blockdev_setrw_0 FAILED\n");
5273 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
5274 if (test_blockdev_setro_0 () == -1) {
5275 printf ("test_blockdev_setro_0 FAILED\n");
5279 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
5280 if (test_statvfs_0 () == -1) {
5281 printf ("test_statvfs_0 FAILED\n");
5285 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
5286 if (test_lstat_0 () == -1) {
5287 printf ("test_lstat_0 FAILED\n");
5291 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
5292 if (test_stat_0 () == -1) {
5293 printf ("test_stat_0 FAILED\n");
5297 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
5298 if (test_file_0 () == -1) {
5299 printf ("test_file_0 FAILED\n");
5303 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
5304 if (test_file_1 () == -1) {
5305 printf ("test_file_1 FAILED\n");
5309 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
5310 if (test_file_2 () == -1) {
5311 printf ("test_file_2 FAILED\n");
5315 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
5316 if (test_umount_all_0 () == -1) {
5317 printf ("test_umount_all_0 FAILED\n");
5321 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
5322 if (test_mounts_0 () == -1) {
5323 printf ("test_mounts_0 FAILED\n");
5327 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
5328 if (test_umount_0 () == -1) {
5329 printf ("test_umount_0 FAILED\n");
5333 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
5334 if (test_umount_1 () == -1) {
5335 printf ("test_umount_1 FAILED\n");
5339 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
5340 if (test_write_file_0 () == -1) {
5341 printf ("test_write_file_0 FAILED\n");
5345 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
5346 if (test_write_file_1 () == -1) {
5347 printf ("test_write_file_1 FAILED\n");
5351 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
5352 if (test_write_file_2 () == -1) {
5353 printf ("test_write_file_2 FAILED\n");
5357 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
5358 if (test_write_file_3 () == -1) {
5359 printf ("test_write_file_3 FAILED\n");
5363 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
5364 if (test_write_file_4 () == -1) {
5365 printf ("test_write_file_4 FAILED\n");
5369 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
5370 if (test_write_file_5 () == -1) {
5371 printf ("test_write_file_5 FAILED\n");
5375 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
5376 if (test_mkfs_0 () == -1) {
5377 printf ("test_mkfs_0 FAILED\n");
5381 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
5382 if (test_lvcreate_0 () == -1) {
5383 printf ("test_lvcreate_0 FAILED\n");
5387 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
5388 if (test_vgcreate_0 () == -1) {
5389 printf ("test_vgcreate_0 FAILED\n");
5393 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
5394 if (test_pvcreate_0 () == -1) {
5395 printf ("test_pvcreate_0 FAILED\n");
5399 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
5400 if (test_is_dir_0 () == -1) {
5401 printf ("test_is_dir_0 FAILED\n");
5405 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
5406 if (test_is_dir_1 () == -1) {
5407 printf ("test_is_dir_1 FAILED\n");
5411 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
5412 if (test_is_file_0 () == -1) {
5413 printf ("test_is_file_0 FAILED\n");
5417 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
5418 if (test_is_file_1 () == -1) {
5419 printf ("test_is_file_1 FAILED\n");
5423 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
5424 if (test_exists_0 () == -1) {
5425 printf ("test_exists_0 FAILED\n");
5429 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
5430 if (test_exists_1 () == -1) {
5431 printf ("test_exists_1 FAILED\n");
5435 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
5436 if (test_mkdir_p_0 () == -1) {
5437 printf ("test_mkdir_p_0 FAILED\n");
5441 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
5442 if (test_mkdir_p_1 () == -1) {
5443 printf ("test_mkdir_p_1 FAILED\n");
5447 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
5448 if (test_mkdir_p_2 () == -1) {
5449 printf ("test_mkdir_p_2 FAILED\n");
5453 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
5454 if (test_mkdir_0 () == -1) {
5455 printf ("test_mkdir_0 FAILED\n");
5459 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
5460 if (test_mkdir_1 () == -1) {
5461 printf ("test_mkdir_1 FAILED\n");
5465 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
5466 if (test_rm_rf_0 () == -1) {
5467 printf ("test_rm_rf_0 FAILED\n");
5471 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
5472 if (test_rmdir_0 () == -1) {
5473 printf ("test_rmdir_0 FAILED\n");
5477 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
5478 if (test_rmdir_1 () == -1) {
5479 printf ("test_rmdir_1 FAILED\n");
5483 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
5484 if (test_rmdir_2 () == -1) {
5485 printf ("test_rmdir_2 FAILED\n");
5489 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
5490 if (test_rm_0 () == -1) {
5491 printf ("test_rm_0 FAILED\n");
5495 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
5496 if (test_rm_1 () == -1) {
5497 printf ("test_rm_1 FAILED\n");
5501 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
5502 if (test_rm_2 () == -1) {
5503 printf ("test_rm_2 FAILED\n");
5507 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
5508 if (test_read_lines_0 () == -1) {
5509 printf ("test_read_lines_0 FAILED\n");
5513 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
5514 if (test_read_lines_1 () == -1) {
5515 printf ("test_read_lines_1 FAILED\n");
5519 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
5520 if (test_lvs_0 () == -1) {
5521 printf ("test_lvs_0 FAILED\n");
5525 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
5526 if (test_lvs_1 () == -1) {
5527 printf ("test_lvs_1 FAILED\n");
5531 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
5532 if (test_vgs_0 () == -1) {
5533 printf ("test_vgs_0 FAILED\n");
5537 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
5538 if (test_vgs_1 () == -1) {
5539 printf ("test_vgs_1 FAILED\n");
5543 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
5544 if (test_pvs_0 () == -1) {
5545 printf ("test_pvs_0 FAILED\n");
5549 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
5550 if (test_pvs_1 () == -1) {
5551 printf ("test_pvs_1 FAILED\n");
5555 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
5556 if (test_list_partitions_0 () == -1) {
5557 printf ("test_list_partitions_0 FAILED\n");
5561 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
5562 if (test_list_partitions_1 () == -1) {
5563 printf ("test_list_partitions_1 FAILED\n");
5567 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
5568 if (test_list_devices_0 () == -1) {
5569 printf ("test_list_devices_0 FAILED\n");
5573 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
5574 if (test_ls_0 () == -1) {
5575 printf ("test_ls_0 FAILED\n");
5579 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
5580 if (test_cat_0 () == -1) {
5581 printf ("test_cat_0 FAILED\n");
5585 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
5586 if (test_touch_0 () == -1) {
5587 printf ("test_touch_0 FAILED\n");
5591 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
5592 if (test_sync_0 () == -1) {
5593 printf ("test_sync_0 FAILED\n");
5597 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
5598 if (test_mount_0 () == -1) {
5599 printf ("test_mount_0 FAILED\n");
5604 snprintf (buf, sizeof buf, "%s/test1.img", srcdir);
5606 snprintf (buf, sizeof buf, "%s/test2.img", srcdir);
5608 snprintf (buf, sizeof buf, "%s/test3.img", srcdir);
5612 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);