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 /* This will be 's' or 'h' depending on whether the guest kernel
35 * names IDE devices /dev/sd* or /dev/hd*.
37 static char devchar = 's';
39 static void print_error (guestfs_h *g, void *data, const char *msg)
42 fprintf (stderr, "%s\n", msg);
45 static void print_strings (char * const * const argv)
49 for (argc = 0; argv[argc] != NULL; ++argc)
50 printf ("\t%s\n", argv[argc]);
54 static void print_table (char * const * const argv)
58 for (i = 0; argv[i] != NULL; i += 2)
59 printf ("%s: %s\n", argv[i], argv[i+1]);
63 static void no_test_warnings (void)
65 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
113 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
114 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
115 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
116 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
117 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
118 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
121 static int test_hexdump_0 (void)
123 /* InitBasicFS for hexdump (0): create ext2 on /dev/sda1 */
125 char device[] = "/dev/sda";
129 r = guestfs_blockdev_setrw (g, device);
136 r = guestfs_umount_all (g);
143 r = guestfs_lvm_remove_all (g);
148 char device[] = "/dev/sda";
150 char lines_0[] = ",";
157 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
162 char fstype[] = "ext2";
163 char device[] = "/dev/sda1";
167 r = guestfs_mkfs (g, fstype, device);
172 char device[] = "/dev/sda1";
174 char mountpoint[] = "/";
177 r = guestfs_mount (g, device, mountpoint);
181 /* TestOutput for hexdump (0) */
182 char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
184 char path[] = "/new";
185 char content[] = "hello\nworld\n";
188 r = guestfs_write_file (g, path, content, 12);
193 char path[] = "/new";
196 r = guestfs_hexdump (g, path);
199 if (strcmp (r, expected) != 0) {
200 fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
208 static int test_strings_e_0 (void)
210 /* InitBasicFS for strings_e (0): create ext2 on /dev/sda1 */
212 char device[] = "/dev/sda";
216 r = guestfs_blockdev_setrw (g, device);
223 r = guestfs_umount_all (g);
230 r = guestfs_lvm_remove_all (g);
235 char device[] = "/dev/sda";
237 char lines_0[] = ",";
244 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
249 char fstype[] = "ext2";
250 char device[] = "/dev/sda1";
254 r = guestfs_mkfs (g, fstype, device);
259 char device[] = "/dev/sda1";
261 char mountpoint[] = "/";
264 r = guestfs_mount (g, device, mountpoint);
268 /* TestOutputList for strings_e (0) */
270 char path[] = "/new";
271 char content[] = "hello\nworld\n";
274 r = guestfs_write_file (g, path, content, 0);
279 char encoding[] = "b";
280 char path[] = "/new";
284 r = guestfs_strings_e (g, encoding, path);
288 fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
292 for (i = 0; r[i] != NULL; ++i)
299 static int test_strings_0 (void)
301 /* InitBasicFS for strings (0): create ext2 on /dev/sda1 */
303 char device[] = "/dev/sda";
307 r = guestfs_blockdev_setrw (g, device);
314 r = guestfs_umount_all (g);
321 r = guestfs_lvm_remove_all (g);
326 char device[] = "/dev/sda";
328 char lines_0[] = ",";
335 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
340 char fstype[] = "ext2";
341 char device[] = "/dev/sda1";
345 r = guestfs_mkfs (g, fstype, device);
350 char device[] = "/dev/sda1";
352 char mountpoint[] = "/";
355 r = guestfs_mount (g, device, mountpoint);
359 /* TestOutputList for strings (0) */
361 char path[] = "/new";
362 char content[] = "hello\nworld\n";
365 r = guestfs_write_file (g, path, content, 0);
370 char path[] = "/new";
374 r = guestfs_strings (g, path);
378 fprintf (stderr, "test_strings_0: short list returned from command\n");
383 char expected[] = "hello";
384 if (strcmp (r[0], expected) != 0) {
385 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
390 fprintf (stderr, "test_strings_0: short list returned from command\n");
395 char expected[] = "world";
396 if (strcmp (r[1], expected) != 0) {
397 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
402 fprintf (stderr, "test_strings_0: extra elements returned from command\n");
406 for (i = 0; r[i] != NULL; ++i)
413 static int test_equal_0 (void)
415 /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */
417 char device[] = "/dev/sda";
421 r = guestfs_blockdev_setrw (g, device);
428 r = guestfs_umount_all (g);
435 r = guestfs_lvm_remove_all (g);
440 char device[] = "/dev/sda";
442 char lines_0[] = ",";
449 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
454 char fstype[] = "ext2";
455 char device[] = "/dev/sda1";
459 r = guestfs_mkfs (g, fstype, device);
464 char device[] = "/dev/sda1";
466 char mountpoint[] = "/";
469 r = guestfs_mount (g, device, mountpoint);
473 /* TestOutputTrue for equal (0) */
475 char path[] = "/file1";
476 char content[] = "contents of a file";
479 r = guestfs_write_file (g, path, content, 0);
484 char src[] = "/file1";
485 char dest[] = "/file2";
488 r = guestfs_cp (g, src, dest);
493 char file1[] = "/file1";
494 char file2[] = "/file2";
497 r = guestfs_equal (g, file1, file2);
501 fprintf (stderr, "test_equal_0: expected true, got false\n");
508 static int test_equal_1 (void)
510 /* InitBasicFS for equal (1): create ext2 on /dev/sda1 */
512 char device[] = "/dev/sda";
516 r = guestfs_blockdev_setrw (g, device);
523 r = guestfs_umount_all (g);
530 r = guestfs_lvm_remove_all (g);
535 char device[] = "/dev/sda";
537 char lines_0[] = ",";
544 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
549 char fstype[] = "ext2";
550 char device[] = "/dev/sda1";
554 r = guestfs_mkfs (g, fstype, device);
559 char device[] = "/dev/sda1";
561 char mountpoint[] = "/";
564 r = guestfs_mount (g, device, mountpoint);
568 /* TestOutputFalse for equal (1) */
570 char path[] = "/file1";
571 char content[] = "contents of a file";
574 r = guestfs_write_file (g, path, content, 0);
579 char path[] = "/file2";
580 char content[] = "contents of another file";
583 r = guestfs_write_file (g, path, content, 0);
588 char file1[] = "/file1";
589 char file2[] = "/file2";
592 r = guestfs_equal (g, file1, file2);
596 fprintf (stderr, "test_equal_1: expected false, got true\n");
603 static int test_equal_2 (void)
605 /* InitBasicFS for equal (2): create ext2 on /dev/sda1 */
607 char device[] = "/dev/sda";
611 r = guestfs_blockdev_setrw (g, device);
618 r = guestfs_umount_all (g);
625 r = guestfs_lvm_remove_all (g);
630 char device[] = "/dev/sda";
632 char lines_0[] = ",";
639 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
644 char fstype[] = "ext2";
645 char device[] = "/dev/sda1";
649 r = guestfs_mkfs (g, fstype, device);
654 char device[] = "/dev/sda1";
656 char mountpoint[] = "/";
659 r = guestfs_mount (g, device, mountpoint);
663 /* TestLastFail for equal (2) */
665 char file1[] = "/file1";
666 char file2[] = "/file2";
669 r = guestfs_equal (g, file1, file2);
676 static int test_ping_daemon_0 (void)
678 /* InitEmpty for ping_daemon (0) */
680 char device[] = "/dev/sda";
684 r = guestfs_blockdev_setrw (g, device);
691 r = guestfs_umount_all (g);
698 r = guestfs_lvm_remove_all (g);
702 /* TestRun for ping_daemon (0) */
706 r = guestfs_ping_daemon (g);
713 static int test_dmesg_0 (void)
715 /* InitEmpty for dmesg (0) */
717 char device[] = "/dev/sda";
721 r = guestfs_blockdev_setrw (g, device);
728 r = guestfs_umount_all (g);
735 r = guestfs_lvm_remove_all (g);
739 /* TestRun for dmesg (0) */
743 r = guestfs_dmesg (g);
751 static int test_drop_caches_0 (void)
753 /* InitEmpty for drop_caches (0) */
755 char device[] = "/dev/sda";
759 r = guestfs_blockdev_setrw (g, device);
766 r = guestfs_umount_all (g);
773 r = guestfs_lvm_remove_all (g);
777 /* TestRun for drop_caches (0) */
781 r = guestfs_drop_caches (g, 3);
788 static int test_mv_0 (void)
790 /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
792 char device[] = "/dev/sda";
796 r = guestfs_blockdev_setrw (g, device);
803 r = guestfs_umount_all (g);
810 r = guestfs_lvm_remove_all (g);
815 char device[] = "/dev/sda";
817 char lines_0[] = ",";
824 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
829 char fstype[] = "ext2";
830 char device[] = "/dev/sda1";
834 r = guestfs_mkfs (g, fstype, device);
839 char device[] = "/dev/sda1";
841 char mountpoint[] = "/";
844 r = guestfs_mount (g, device, mountpoint);
848 /* TestOutput for mv (0) */
849 char expected[] = "file content";
851 char path[] = "/old";
852 char content[] = "file content";
855 r = guestfs_write_file (g, path, content, 0);
861 char dest[] = "/new";
864 r = guestfs_mv (g, src, dest);
869 char path[] = "/new";
872 r = guestfs_cat (g, path);
875 if (strcmp (r, expected) != 0) {
876 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
884 static int test_mv_1 (void)
886 /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
888 char device[] = "/dev/sda";
892 r = guestfs_blockdev_setrw (g, device);
899 r = guestfs_umount_all (g);
906 r = guestfs_lvm_remove_all (g);
911 char device[] = "/dev/sda";
913 char lines_0[] = ",";
920 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
925 char fstype[] = "ext2";
926 char device[] = "/dev/sda1";
930 r = guestfs_mkfs (g, fstype, device);
935 char device[] = "/dev/sda1";
937 char mountpoint[] = "/";
940 r = guestfs_mount (g, device, mountpoint);
944 /* TestOutputFalse for mv (1) */
946 char path[] = "/old";
947 char content[] = "file content";
950 r = guestfs_write_file (g, path, content, 0);
956 char dest[] = "/new";
959 r = guestfs_mv (g, src, dest);
964 char path[] = "/old";
967 r = guestfs_is_file (g, path);
971 fprintf (stderr, "test_mv_1: expected false, got true\n");
978 static int test_cp_a_0 (void)
980 /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
982 char device[] = "/dev/sda";
986 r = guestfs_blockdev_setrw (g, device);
993 r = guestfs_umount_all (g);
1000 r = guestfs_lvm_remove_all (g);
1005 char device[] = "/dev/sda";
1006 device[5] = devchar;
1007 char lines_0[] = ",";
1014 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1019 char fstype[] = "ext2";
1020 char device[] = "/dev/sda1";
1021 device[5] = devchar;
1024 r = guestfs_mkfs (g, fstype, device);
1029 char device[] = "/dev/sda1";
1030 device[5] = devchar;
1031 char mountpoint[] = "/";
1034 r = guestfs_mount (g, device, mountpoint);
1038 /* TestOutput for cp_a (0) */
1039 char expected[] = "file content";
1041 char path[] = "/olddir";
1044 r = guestfs_mkdir (g, path);
1049 char path[] = "/newdir";
1052 r = guestfs_mkdir (g, path);
1057 char path[] = "/olddir/file";
1058 char content[] = "file content";
1061 r = guestfs_write_file (g, path, content, 0);
1066 char src[] = "/olddir";
1067 char dest[] = "/newdir";
1070 r = guestfs_cp_a (g, src, dest);
1075 char path[] = "/newdir/olddir/file";
1078 r = guestfs_cat (g, path);
1081 if (strcmp (r, expected) != 0) {
1082 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
1090 static int test_cp_0 (void)
1092 /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
1094 char device[] = "/dev/sda";
1095 device[5] = devchar;
1098 r = guestfs_blockdev_setrw (g, device);
1105 r = guestfs_umount_all (g);
1112 r = guestfs_lvm_remove_all (g);
1117 char device[] = "/dev/sda";
1118 device[5] = devchar;
1119 char lines_0[] = ",";
1126 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1131 char fstype[] = "ext2";
1132 char device[] = "/dev/sda1";
1133 device[5] = devchar;
1136 r = guestfs_mkfs (g, fstype, device);
1141 char device[] = "/dev/sda1";
1142 device[5] = devchar;
1143 char mountpoint[] = "/";
1146 r = guestfs_mount (g, device, mountpoint);
1150 /* TestOutput for cp (0) */
1151 char expected[] = "file content";
1153 char path[] = "/old";
1154 char content[] = "file content";
1157 r = guestfs_write_file (g, path, content, 0);
1162 char src[] = "/old";
1163 char dest[] = "/new";
1166 r = guestfs_cp (g, src, dest);
1171 char path[] = "/new";
1174 r = guestfs_cat (g, path);
1177 if (strcmp (r, expected) != 0) {
1178 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
1186 static int test_cp_1 (void)
1188 /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
1190 char device[] = "/dev/sda";
1191 device[5] = devchar;
1194 r = guestfs_blockdev_setrw (g, device);
1201 r = guestfs_umount_all (g);
1208 r = guestfs_lvm_remove_all (g);
1213 char device[] = "/dev/sda";
1214 device[5] = devchar;
1215 char lines_0[] = ",";
1222 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1227 char fstype[] = "ext2";
1228 char device[] = "/dev/sda1";
1229 device[5] = devchar;
1232 r = guestfs_mkfs (g, fstype, device);
1237 char device[] = "/dev/sda1";
1238 device[5] = devchar;
1239 char mountpoint[] = "/";
1242 r = guestfs_mount (g, device, mountpoint);
1246 /* TestOutputTrue for cp (1) */
1248 char path[] = "/old";
1249 char content[] = "file content";
1252 r = guestfs_write_file (g, path, content, 0);
1257 char src[] = "/old";
1258 char dest[] = "/new";
1261 r = guestfs_cp (g, src, dest);
1266 char path[] = "/old";
1269 r = guestfs_is_file (g, path);
1273 fprintf (stderr, "test_cp_1: expected true, got false\n");
1280 static int test_cp_2 (void)
1282 /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
1284 char device[] = "/dev/sda";
1285 device[5] = devchar;
1288 r = guestfs_blockdev_setrw (g, device);
1295 r = guestfs_umount_all (g);
1302 r = guestfs_lvm_remove_all (g);
1307 char device[] = "/dev/sda";
1308 device[5] = devchar;
1309 char lines_0[] = ",";
1316 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1321 char fstype[] = "ext2";
1322 char device[] = "/dev/sda1";
1323 device[5] = devchar;
1326 r = guestfs_mkfs (g, fstype, device);
1331 char device[] = "/dev/sda1";
1332 device[5] = devchar;
1333 char mountpoint[] = "/";
1336 r = guestfs_mount (g, device, mountpoint);
1340 /* TestOutput for cp (2) */
1341 char expected[] = "file content";
1343 char path[] = "/old";
1344 char content[] = "file content";
1347 r = guestfs_write_file (g, path, content, 0);
1352 char path[] = "/dir";
1355 r = guestfs_mkdir (g, path);
1360 char src[] = "/old";
1361 char dest[] = "/dir/new";
1364 r = guestfs_cp (g, src, dest);
1369 char path[] = "/dir/new";
1372 r = guestfs_cat (g, path);
1375 if (strcmp (r, expected) != 0) {
1376 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
1384 static int test_grub_install_0 (void)
1386 /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
1388 char device[] = "/dev/sda";
1389 device[5] = devchar;
1392 r = guestfs_blockdev_setrw (g, device);
1399 r = guestfs_umount_all (g);
1406 r = guestfs_lvm_remove_all (g);
1411 char device[] = "/dev/sda";
1412 device[5] = devchar;
1413 char lines_0[] = ",";
1420 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1425 char fstype[] = "ext2";
1426 char device[] = "/dev/sda1";
1427 device[5] = devchar;
1430 r = guestfs_mkfs (g, fstype, device);
1435 char device[] = "/dev/sda1";
1436 device[5] = devchar;
1437 char mountpoint[] = "/";
1440 r = guestfs_mount (g, device, mountpoint);
1444 /* TestOutputTrue for grub_install (0) */
1447 char device[] = "/dev/sda1";
1448 device[5] = devchar;
1451 r = guestfs_grub_install (g, root, device);
1456 char path[] = "/boot";
1459 r = guestfs_is_dir (g, path);
1463 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
1470 static int test_zero_0 (void)
1472 /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
1474 char device[] = "/dev/sda";
1475 device[5] = devchar;
1478 r = guestfs_blockdev_setrw (g, device);
1485 r = guestfs_umount_all (g);
1492 r = guestfs_lvm_remove_all (g);
1497 char device[] = "/dev/sda";
1498 device[5] = devchar;
1499 char lines_0[] = ",";
1506 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1511 char fstype[] = "ext2";
1512 char device[] = "/dev/sda1";
1513 device[5] = devchar;
1516 r = guestfs_mkfs (g, fstype, device);
1521 char device[] = "/dev/sda1";
1522 device[5] = devchar;
1523 char mountpoint[] = "/";
1526 r = guestfs_mount (g, device, mountpoint);
1530 /* TestOutput for zero (0) */
1531 char expected[] = "data";
1533 char pathordevice[] = "/dev/sda1";
1534 pathordevice[5] = devchar;
1537 r = guestfs_umount (g, pathordevice);
1542 char device[] = "/dev/sda1";
1543 device[5] = devchar;
1546 r = guestfs_zero (g, device);
1551 char path[] = "/dev/sda1";
1555 r = guestfs_file (g, path);
1558 if (strcmp (r, expected) != 0) {
1559 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
1567 static int test_fsck_0 (void)
1569 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
1571 char device[] = "/dev/sda";
1572 device[5] = devchar;
1575 r = guestfs_blockdev_setrw (g, device);
1582 r = guestfs_umount_all (g);
1589 r = guestfs_lvm_remove_all (g);
1594 char device[] = "/dev/sda";
1595 device[5] = devchar;
1596 char lines_0[] = ",";
1603 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1608 char fstype[] = "ext2";
1609 char device[] = "/dev/sda1";
1610 device[5] = devchar;
1613 r = guestfs_mkfs (g, fstype, device);
1618 char device[] = "/dev/sda1";
1619 device[5] = devchar;
1620 char mountpoint[] = "/";
1623 r = guestfs_mount (g, device, mountpoint);
1627 /* TestOutputInt for fsck (0) */
1629 char pathordevice[] = "/dev/sda1";
1630 pathordevice[5] = devchar;
1633 r = guestfs_umount (g, pathordevice);
1638 char fstype[] = "ext2";
1639 char device[] = "/dev/sda1";
1640 device[5] = devchar;
1643 r = guestfs_fsck (g, fstype, device);
1647 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
1654 static int test_fsck_1 (void)
1656 /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
1658 char device[] = "/dev/sda";
1659 device[5] = devchar;
1662 r = guestfs_blockdev_setrw (g, device);
1669 r = guestfs_umount_all (g);
1676 r = guestfs_lvm_remove_all (g);
1681 char device[] = "/dev/sda";
1682 device[5] = devchar;
1683 char lines_0[] = ",";
1690 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1695 char fstype[] = "ext2";
1696 char device[] = "/dev/sda1";
1697 device[5] = devchar;
1700 r = guestfs_mkfs (g, fstype, device);
1705 char device[] = "/dev/sda1";
1706 device[5] = devchar;
1707 char mountpoint[] = "/";
1710 r = guestfs_mount (g, device, mountpoint);
1714 /* TestOutputInt for fsck (1) */
1716 char pathordevice[] = "/dev/sda1";
1717 pathordevice[5] = devchar;
1720 r = guestfs_umount (g, pathordevice);
1725 char device[] = "/dev/sda1";
1726 device[5] = devchar;
1729 r = guestfs_zero (g, device);
1734 char fstype[] = "ext2";
1735 char device[] = "/dev/sda1";
1736 device[5] = devchar;
1739 r = guestfs_fsck (g, fstype, device);
1743 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
1750 static int test_set_e2uuid_0 (void)
1752 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
1754 char device[] = "/dev/sda";
1755 device[5] = devchar;
1758 r = guestfs_blockdev_setrw (g, device);
1765 r = guestfs_umount_all (g);
1772 r = guestfs_lvm_remove_all (g);
1777 char device[] = "/dev/sda";
1778 device[5] = devchar;
1779 char lines_0[] = ",";
1786 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1791 char fstype[] = "ext2";
1792 char device[] = "/dev/sda1";
1793 device[5] = devchar;
1796 r = guestfs_mkfs (g, fstype, device);
1801 char device[] = "/dev/sda1";
1802 device[5] = devchar;
1803 char mountpoint[] = "/";
1806 r = guestfs_mount (g, device, mountpoint);
1810 /* TestOutput for set_e2uuid (0) */
1811 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1813 char device[] = "/dev/sda1";
1814 device[5] = devchar;
1815 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1818 r = guestfs_set_e2uuid (g, device, uuid);
1823 char device[] = "/dev/sda1";
1824 device[5] = devchar;
1827 r = guestfs_get_e2uuid (g, device);
1830 if (strcmp (r, expected) != 0) {
1831 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
1839 static int test_set_e2uuid_1 (void)
1841 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
1843 char device[] = "/dev/sda";
1844 device[5] = devchar;
1847 r = guestfs_blockdev_setrw (g, device);
1854 r = guestfs_umount_all (g);
1861 r = guestfs_lvm_remove_all (g);
1866 char device[] = "/dev/sda";
1867 device[5] = devchar;
1868 char lines_0[] = ",";
1875 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1880 char fstype[] = "ext2";
1881 char device[] = "/dev/sda1";
1882 device[5] = devchar;
1885 r = guestfs_mkfs (g, fstype, device);
1890 char device[] = "/dev/sda1";
1891 device[5] = devchar;
1892 char mountpoint[] = "/";
1895 r = guestfs_mount (g, device, mountpoint);
1899 /* TestOutput for set_e2uuid (1) */
1900 char expected[] = "";
1902 char device[] = "/dev/sda1";
1903 device[5] = devchar;
1904 char uuid[] = "clear";
1907 r = guestfs_set_e2uuid (g, device, uuid);
1912 char device[] = "/dev/sda1";
1913 device[5] = devchar;
1916 r = guestfs_get_e2uuid (g, device);
1919 if (strcmp (r, expected) != 0) {
1920 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
1928 static int test_set_e2uuid_2 (void)
1930 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1932 char device[] = "/dev/sda";
1933 device[5] = devchar;
1936 r = guestfs_blockdev_setrw (g, device);
1943 r = guestfs_umount_all (g);
1950 r = guestfs_lvm_remove_all (g);
1955 char device[] = "/dev/sda";
1956 device[5] = devchar;
1957 char lines_0[] = ",";
1964 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1969 char fstype[] = "ext2";
1970 char device[] = "/dev/sda1";
1971 device[5] = devchar;
1974 r = guestfs_mkfs (g, fstype, device);
1979 char device[] = "/dev/sda1";
1980 device[5] = devchar;
1981 char mountpoint[] = "/";
1984 r = guestfs_mount (g, device, mountpoint);
1988 /* TestRun for set_e2uuid (2) */
1990 char device[] = "/dev/sda1";
1991 device[5] = devchar;
1992 char uuid[] = "random";
1995 r = guestfs_set_e2uuid (g, device, uuid);
2002 static int test_set_e2uuid_3 (void)
2004 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
2006 char device[] = "/dev/sda";
2007 device[5] = devchar;
2010 r = guestfs_blockdev_setrw (g, device);
2017 r = guestfs_umount_all (g);
2024 r = guestfs_lvm_remove_all (g);
2029 char device[] = "/dev/sda";
2030 device[5] = devchar;
2031 char lines_0[] = ",";
2038 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2043 char fstype[] = "ext2";
2044 char device[] = "/dev/sda1";
2045 device[5] = devchar;
2048 r = guestfs_mkfs (g, fstype, device);
2053 char device[] = "/dev/sda1";
2054 device[5] = devchar;
2055 char mountpoint[] = "/";
2058 r = guestfs_mount (g, device, mountpoint);
2062 /* TestRun for set_e2uuid (3) */
2064 char device[] = "/dev/sda1";
2065 device[5] = devchar;
2066 char uuid[] = "time";
2069 r = guestfs_set_e2uuid (g, device, uuid);
2076 static int test_set_e2label_0 (void)
2078 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
2080 char device[] = "/dev/sda";
2081 device[5] = devchar;
2084 r = guestfs_blockdev_setrw (g, device);
2091 r = guestfs_umount_all (g);
2098 r = guestfs_lvm_remove_all (g);
2103 char device[] = "/dev/sda";
2104 device[5] = devchar;
2105 char lines_0[] = ",";
2112 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2117 char fstype[] = "ext2";
2118 char device[] = "/dev/sda1";
2119 device[5] = devchar;
2122 r = guestfs_mkfs (g, fstype, device);
2127 char device[] = "/dev/sda1";
2128 device[5] = devchar;
2129 char mountpoint[] = "/";
2132 r = guestfs_mount (g, device, mountpoint);
2136 /* TestOutput for set_e2label (0) */
2137 char expected[] = "testlabel";
2139 char device[] = "/dev/sda1";
2140 device[5] = devchar;
2141 char label[] = "testlabel";
2144 r = guestfs_set_e2label (g, device, label);
2149 char device[] = "/dev/sda1";
2150 device[5] = devchar;
2153 r = guestfs_get_e2label (g, device);
2156 if (strcmp (r, expected) != 0) {
2157 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
2165 static int test_pvremove_0 (void)
2167 /* InitEmpty for pvremove (0) */
2169 char device[] = "/dev/sda";
2170 device[5] = devchar;
2173 r = guestfs_blockdev_setrw (g, device);
2180 r = guestfs_umount_all (g);
2187 r = guestfs_lvm_remove_all (g);
2191 /* TestOutputList for pvremove (0) */
2193 char device[] = "/dev/sda";
2194 device[5] = devchar;
2197 r = guestfs_pvcreate (g, device);
2202 char volgroup[] = "VG";
2203 char physvols_0[] = "/dev/sda";
2204 physvols_0[5] = devchar;
2205 char *physvols[] = {
2211 r = guestfs_vgcreate (g, volgroup, physvols);
2216 char logvol[] = "LV1";
2217 char volgroup[] = "VG";
2220 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2225 char logvol[] = "LV2";
2226 char volgroup[] = "VG";
2229 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2234 char vgname[] = "VG";
2237 r = guestfs_vgremove (g, vgname);
2242 char device[] = "/dev/sda";
2243 device[5] = devchar;
2246 r = guestfs_pvremove (g, device);
2254 r = guestfs_lvs (g);
2258 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
2262 for (i = 0; r[i] != NULL; ++i)
2269 static int test_pvremove_1 (void)
2271 /* InitEmpty for pvremove (1) */
2273 char device[] = "/dev/sda";
2274 device[5] = devchar;
2277 r = guestfs_blockdev_setrw (g, device);
2284 r = guestfs_umount_all (g);
2291 r = guestfs_lvm_remove_all (g);
2295 /* TestOutputList for pvremove (1) */
2297 char device[] = "/dev/sda";
2298 device[5] = devchar;
2301 r = guestfs_pvcreate (g, device);
2306 char volgroup[] = "VG";
2307 char physvols_0[] = "/dev/sda";
2308 physvols_0[5] = devchar;
2309 char *physvols[] = {
2315 r = guestfs_vgcreate (g, volgroup, physvols);
2320 char logvol[] = "LV1";
2321 char volgroup[] = "VG";
2324 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2329 char logvol[] = "LV2";
2330 char volgroup[] = "VG";
2333 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2338 char vgname[] = "VG";
2341 r = guestfs_vgremove (g, vgname);
2346 char device[] = "/dev/sda";
2347 device[5] = devchar;
2350 r = guestfs_pvremove (g, device);
2358 r = guestfs_vgs (g);
2362 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
2366 for (i = 0; r[i] != NULL; ++i)
2373 static int test_pvremove_2 (void)
2375 /* InitEmpty for pvremove (2) */
2377 char device[] = "/dev/sda";
2378 device[5] = devchar;
2381 r = guestfs_blockdev_setrw (g, device);
2388 r = guestfs_umount_all (g);
2395 r = guestfs_lvm_remove_all (g);
2399 /* TestOutputList for pvremove (2) */
2401 char device[] = "/dev/sda";
2402 device[5] = devchar;
2405 r = guestfs_pvcreate (g, device);
2410 char volgroup[] = "VG";
2411 char physvols_0[] = "/dev/sda";
2412 physvols_0[5] = devchar;
2413 char *physvols[] = {
2419 r = guestfs_vgcreate (g, volgroup, physvols);
2424 char logvol[] = "LV1";
2425 char volgroup[] = "VG";
2428 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2433 char logvol[] = "LV2";
2434 char volgroup[] = "VG";
2437 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2442 char vgname[] = "VG";
2445 r = guestfs_vgremove (g, vgname);
2450 char device[] = "/dev/sda";
2451 device[5] = devchar;
2454 r = guestfs_pvremove (g, device);
2462 r = guestfs_pvs (g);
2466 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
2470 for (i = 0; r[i] != NULL; ++i)
2477 static int test_vgremove_0 (void)
2479 /* InitEmpty for vgremove (0) */
2481 char device[] = "/dev/sda";
2482 device[5] = devchar;
2485 r = guestfs_blockdev_setrw (g, device);
2492 r = guestfs_umount_all (g);
2499 r = guestfs_lvm_remove_all (g);
2503 /* TestOutputList for vgremove (0) */
2505 char device[] = "/dev/sda";
2506 device[5] = devchar;
2509 r = guestfs_pvcreate (g, device);
2514 char volgroup[] = "VG";
2515 char physvols_0[] = "/dev/sda";
2516 physvols_0[5] = devchar;
2517 char *physvols[] = {
2523 r = guestfs_vgcreate (g, volgroup, physvols);
2528 char logvol[] = "LV1";
2529 char volgroup[] = "VG";
2532 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2537 char logvol[] = "LV2";
2538 char volgroup[] = "VG";
2541 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2546 char vgname[] = "VG";
2549 r = guestfs_vgremove (g, vgname);
2557 r = guestfs_lvs (g);
2561 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
2565 for (i = 0; r[i] != NULL; ++i)
2572 static int test_vgremove_1 (void)
2574 /* InitEmpty for vgremove (1) */
2576 char device[] = "/dev/sda";
2577 device[5] = devchar;
2580 r = guestfs_blockdev_setrw (g, device);
2587 r = guestfs_umount_all (g);
2594 r = guestfs_lvm_remove_all (g);
2598 /* TestOutputList for vgremove (1) */
2600 char device[] = "/dev/sda";
2601 device[5] = devchar;
2604 r = guestfs_pvcreate (g, device);
2609 char volgroup[] = "VG";
2610 char physvols_0[] = "/dev/sda";
2611 physvols_0[5] = devchar;
2612 char *physvols[] = {
2618 r = guestfs_vgcreate (g, volgroup, physvols);
2623 char logvol[] = "LV1";
2624 char volgroup[] = "VG";
2627 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2632 char logvol[] = "LV2";
2633 char volgroup[] = "VG";
2636 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2641 char vgname[] = "VG";
2644 r = guestfs_vgremove (g, vgname);
2652 r = guestfs_vgs (g);
2656 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
2660 for (i = 0; r[i] != NULL; ++i)
2667 static int test_lvremove_0 (void)
2669 /* InitEmpty for lvremove (0) */
2671 char device[] = "/dev/sda";
2672 device[5] = devchar;
2675 r = guestfs_blockdev_setrw (g, device);
2682 r = guestfs_umount_all (g);
2689 r = guestfs_lvm_remove_all (g);
2693 /* TestOutputList for lvremove (0) */
2695 char device[] = "/dev/sda";
2696 device[5] = devchar;
2699 r = guestfs_pvcreate (g, device);
2704 char volgroup[] = "VG";
2705 char physvols_0[] = "/dev/sda";
2706 physvols_0[5] = devchar;
2707 char *physvols[] = {
2713 r = guestfs_vgcreate (g, volgroup, physvols);
2718 char logvol[] = "LV1";
2719 char volgroup[] = "VG";
2722 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2727 char logvol[] = "LV2";
2728 char volgroup[] = "VG";
2731 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2736 char device[] = "/dev/VG/LV1";
2739 r = guestfs_lvremove (g, device);
2747 r = guestfs_lvs (g);
2751 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
2756 char expected[] = "/dev/VG/LV2";
2757 if (strcmp (r[0], expected) != 0) {
2758 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2763 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
2767 for (i = 0; r[i] != NULL; ++i)
2774 static int test_lvremove_1 (void)
2776 /* InitEmpty for lvremove (1) */
2778 char device[] = "/dev/sda";
2779 device[5] = devchar;
2782 r = guestfs_blockdev_setrw (g, device);
2789 r = guestfs_umount_all (g);
2796 r = guestfs_lvm_remove_all (g);
2800 /* TestOutputList for lvremove (1) */
2802 char device[] = "/dev/sda";
2803 device[5] = devchar;
2806 r = guestfs_pvcreate (g, device);
2811 char volgroup[] = "VG";
2812 char physvols_0[] = "/dev/sda";
2813 physvols_0[5] = devchar;
2814 char *physvols[] = {
2820 r = guestfs_vgcreate (g, volgroup, physvols);
2825 char logvol[] = "LV1";
2826 char volgroup[] = "VG";
2829 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2834 char logvol[] = "LV2";
2835 char volgroup[] = "VG";
2838 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2843 char device[] = "/dev/VG";
2846 r = guestfs_lvremove (g, device);
2854 r = guestfs_lvs (g);
2858 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
2862 for (i = 0; r[i] != NULL; ++i)
2869 static int test_lvremove_2 (void)
2871 /* InitEmpty for lvremove (2) */
2873 char device[] = "/dev/sda";
2874 device[5] = devchar;
2877 r = guestfs_blockdev_setrw (g, device);
2884 r = guestfs_umount_all (g);
2891 r = guestfs_lvm_remove_all (g);
2895 /* TestOutputList for lvremove (2) */
2897 char device[] = "/dev/sda";
2898 device[5] = devchar;
2901 r = guestfs_pvcreate (g, device);
2906 char volgroup[] = "VG";
2907 char physvols_0[] = "/dev/sda";
2908 physvols_0[5] = devchar;
2909 char *physvols[] = {
2915 r = guestfs_vgcreate (g, volgroup, physvols);
2920 char logvol[] = "LV1";
2921 char volgroup[] = "VG";
2924 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2929 char logvol[] = "LV2";
2930 char volgroup[] = "VG";
2933 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2938 char device[] = "/dev/VG";
2941 r = guestfs_lvremove (g, device);
2949 r = guestfs_vgs (g);
2953 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
2958 char expected[] = "VG";
2959 if (strcmp (r[0], expected) != 0) {
2960 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2965 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
2969 for (i = 0; r[i] != NULL; ++i)
2976 static int test_mount_ro_0 (void)
2978 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
2980 char device[] = "/dev/sda";
2981 device[5] = devchar;
2984 r = guestfs_blockdev_setrw (g, device);
2991 r = guestfs_umount_all (g);
2998 r = guestfs_lvm_remove_all (g);
3003 char device[] = "/dev/sda";
3004 device[5] = devchar;
3005 char lines_0[] = ",";
3012 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3017 char fstype[] = "ext2";
3018 char device[] = "/dev/sda1";
3019 device[5] = devchar;
3022 r = guestfs_mkfs (g, fstype, device);
3027 char device[] = "/dev/sda1";
3028 device[5] = devchar;
3029 char mountpoint[] = "/";
3032 r = guestfs_mount (g, device, mountpoint);
3036 /* TestLastFail for mount_ro (0) */
3038 char pathordevice[] = "/";
3041 r = guestfs_umount (g, pathordevice);
3046 char device[] = "/dev/sda1";
3047 device[5] = devchar;
3048 char mountpoint[] = "/";
3051 r = guestfs_mount_ro (g, device, mountpoint);
3056 char path[] = "/new";
3059 r = guestfs_touch (g, path);
3066 static int test_mount_ro_1 (void)
3068 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
3070 char device[] = "/dev/sda";
3071 device[5] = devchar;
3074 r = guestfs_blockdev_setrw (g, device);
3081 r = guestfs_umount_all (g);
3088 r = guestfs_lvm_remove_all (g);
3093 char device[] = "/dev/sda";
3094 device[5] = devchar;
3095 char lines_0[] = ",";
3102 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3107 char fstype[] = "ext2";
3108 char device[] = "/dev/sda1";
3109 device[5] = devchar;
3112 r = guestfs_mkfs (g, fstype, device);
3117 char device[] = "/dev/sda1";
3118 device[5] = devchar;
3119 char mountpoint[] = "/";
3122 r = guestfs_mount (g, device, mountpoint);
3126 /* TestOutput for mount_ro (1) */
3127 char expected[] = "data";
3129 char path[] = "/new";
3130 char content[] = "data";
3133 r = guestfs_write_file (g, path, content, 0);
3138 char pathordevice[] = "/";
3141 r = guestfs_umount (g, pathordevice);
3146 char device[] = "/dev/sda1";
3147 device[5] = devchar;
3148 char mountpoint[] = "/";
3151 r = guestfs_mount_ro (g, device, mountpoint);
3156 char path[] = "/new";
3159 r = guestfs_cat (g, path);
3162 if (strcmp (r, expected) != 0) {
3163 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
3171 static int test_tgz_in_0 (void)
3173 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
3175 char device[] = "/dev/sda";
3176 device[5] = devchar;
3179 r = guestfs_blockdev_setrw (g, device);
3186 r = guestfs_umount_all (g);
3193 r = guestfs_lvm_remove_all (g);
3198 char device[] = "/dev/sda";
3199 device[5] = devchar;
3200 char lines_0[] = ",";
3207 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3212 char fstype[] = "ext2";
3213 char device[] = "/dev/sda1";
3214 device[5] = devchar;
3217 r = guestfs_mkfs (g, fstype, device);
3222 char device[] = "/dev/sda1";
3223 device[5] = devchar;
3224 char mountpoint[] = "/";
3227 r = guestfs_mount (g, device, mountpoint);
3231 /* TestOutput for tgz_in (0) */
3232 char expected[] = "hello\n";
3234 char directory[] = "/";
3237 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory);
3242 char path[] = "/hello";
3245 r = guestfs_cat (g, path);
3248 if (strcmp (r, expected) != 0) {
3249 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3257 static int test_tar_in_0 (void)
3259 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
3261 char device[] = "/dev/sda";
3262 device[5] = devchar;
3265 r = guestfs_blockdev_setrw (g, device);
3272 r = guestfs_umount_all (g);
3279 r = guestfs_lvm_remove_all (g);
3284 char device[] = "/dev/sda";
3285 device[5] = devchar;
3286 char lines_0[] = ",";
3293 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3298 char fstype[] = "ext2";
3299 char device[] = "/dev/sda1";
3300 device[5] = devchar;
3303 r = guestfs_mkfs (g, fstype, device);
3308 char device[] = "/dev/sda1";
3309 device[5] = devchar;
3310 char mountpoint[] = "/";
3313 r = guestfs_mount (g, device, mountpoint);
3317 /* TestOutput for tar_in (0) */
3318 char expected[] = "hello\n";
3320 char directory[] = "/";
3323 r = guestfs_tar_in (g, "images/helloworld.tar", directory);
3328 char path[] = "/hello";
3331 r = guestfs_cat (g, path);
3334 if (strcmp (r, expected) != 0) {
3335 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3343 static int test_checksum_0 (void)
3345 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
3347 char device[] = "/dev/sda";
3348 device[5] = devchar;
3351 r = guestfs_blockdev_setrw (g, device);
3358 r = guestfs_umount_all (g);
3365 r = guestfs_lvm_remove_all (g);
3370 char device[] = "/dev/sda";
3371 device[5] = devchar;
3372 char lines_0[] = ",";
3379 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3384 char fstype[] = "ext2";
3385 char device[] = "/dev/sda1";
3386 device[5] = devchar;
3389 r = guestfs_mkfs (g, fstype, device);
3394 char device[] = "/dev/sda1";
3395 device[5] = devchar;
3396 char mountpoint[] = "/";
3399 r = guestfs_mount (g, device, mountpoint);
3403 /* TestOutput for checksum (0) */
3404 char expected[] = "935282863";
3406 char path[] = "/new";
3407 char content[] = "test\n";
3410 r = guestfs_write_file (g, path, content, 0);
3415 char csumtype[] = "crc";
3416 char path[] = "/new";
3419 r = guestfs_checksum (g, csumtype, path);
3422 if (strcmp (r, expected) != 0) {
3423 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
3431 static int test_checksum_1 (void)
3433 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
3435 char device[] = "/dev/sda";
3436 device[5] = devchar;
3439 r = guestfs_blockdev_setrw (g, device);
3446 r = guestfs_umount_all (g);
3453 r = guestfs_lvm_remove_all (g);
3458 char device[] = "/dev/sda";
3459 device[5] = devchar;
3460 char lines_0[] = ",";
3467 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3472 char fstype[] = "ext2";
3473 char device[] = "/dev/sda1";
3474 device[5] = devchar;
3477 r = guestfs_mkfs (g, fstype, device);
3482 char device[] = "/dev/sda1";
3483 device[5] = devchar;
3484 char mountpoint[] = "/";
3487 r = guestfs_mount (g, device, mountpoint);
3491 /* TestLastFail for checksum (1) */
3493 char csumtype[] = "crc";
3494 char path[] = "/new";
3497 r = guestfs_checksum (g, csumtype, path);
3505 static int test_checksum_2 (void)
3507 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
3509 char device[] = "/dev/sda";
3510 device[5] = devchar;
3513 r = guestfs_blockdev_setrw (g, device);
3520 r = guestfs_umount_all (g);
3527 r = guestfs_lvm_remove_all (g);
3532 char device[] = "/dev/sda";
3533 device[5] = devchar;
3534 char lines_0[] = ",";
3541 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3546 char fstype[] = "ext2";
3547 char device[] = "/dev/sda1";
3548 device[5] = devchar;
3551 r = guestfs_mkfs (g, fstype, device);
3556 char device[] = "/dev/sda1";
3557 device[5] = devchar;
3558 char mountpoint[] = "/";
3561 r = guestfs_mount (g, device, mountpoint);
3565 /* TestOutput for checksum (2) */
3566 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
3568 char path[] = "/new";
3569 char content[] = "test\n";
3572 r = guestfs_write_file (g, path, content, 0);
3577 char csumtype[] = "md5";
3578 char path[] = "/new";
3581 r = guestfs_checksum (g, csumtype, path);
3584 if (strcmp (r, expected) != 0) {
3585 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
3593 static int test_checksum_3 (void)
3595 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
3597 char device[] = "/dev/sda";
3598 device[5] = devchar;
3601 r = guestfs_blockdev_setrw (g, device);
3608 r = guestfs_umount_all (g);
3615 r = guestfs_lvm_remove_all (g);
3620 char device[] = "/dev/sda";
3621 device[5] = devchar;
3622 char lines_0[] = ",";
3629 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3634 char fstype[] = "ext2";
3635 char device[] = "/dev/sda1";
3636 device[5] = devchar;
3639 r = guestfs_mkfs (g, fstype, device);
3644 char device[] = "/dev/sda1";
3645 device[5] = devchar;
3646 char mountpoint[] = "/";
3649 r = guestfs_mount (g, device, mountpoint);
3653 /* TestOutput for checksum (3) */
3654 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
3656 char path[] = "/new";
3657 char content[] = "test\n";
3660 r = guestfs_write_file (g, path, content, 0);
3665 char csumtype[] = "sha1";
3666 char path[] = "/new";
3669 r = guestfs_checksum (g, csumtype, path);
3672 if (strcmp (r, expected) != 0) {
3673 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
3681 static int test_checksum_4 (void)
3683 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
3685 char device[] = "/dev/sda";
3686 device[5] = devchar;
3689 r = guestfs_blockdev_setrw (g, device);
3696 r = guestfs_umount_all (g);
3703 r = guestfs_lvm_remove_all (g);
3708 char device[] = "/dev/sda";
3709 device[5] = devchar;
3710 char lines_0[] = ",";
3717 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3722 char fstype[] = "ext2";
3723 char device[] = "/dev/sda1";
3724 device[5] = devchar;
3727 r = guestfs_mkfs (g, fstype, device);
3732 char device[] = "/dev/sda1";
3733 device[5] = devchar;
3734 char mountpoint[] = "/";
3737 r = guestfs_mount (g, device, mountpoint);
3741 /* TestOutput for checksum (4) */
3742 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
3744 char path[] = "/new";
3745 char content[] = "test\n";
3748 r = guestfs_write_file (g, path, content, 0);
3753 char csumtype[] = "sha224";
3754 char path[] = "/new";
3757 r = guestfs_checksum (g, csumtype, path);
3760 if (strcmp (r, expected) != 0) {
3761 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
3769 static int test_checksum_5 (void)
3771 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
3773 char device[] = "/dev/sda";
3774 device[5] = devchar;
3777 r = guestfs_blockdev_setrw (g, device);
3784 r = guestfs_umount_all (g);
3791 r = guestfs_lvm_remove_all (g);
3796 char device[] = "/dev/sda";
3797 device[5] = devchar;
3798 char lines_0[] = ",";
3805 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3810 char fstype[] = "ext2";
3811 char device[] = "/dev/sda1";
3812 device[5] = devchar;
3815 r = guestfs_mkfs (g, fstype, device);
3820 char device[] = "/dev/sda1";
3821 device[5] = devchar;
3822 char mountpoint[] = "/";
3825 r = guestfs_mount (g, device, mountpoint);
3829 /* TestOutput for checksum (5) */
3830 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
3832 char path[] = "/new";
3833 char content[] = "test\n";
3836 r = guestfs_write_file (g, path, content, 0);
3841 char csumtype[] = "sha256";
3842 char path[] = "/new";
3845 r = guestfs_checksum (g, csumtype, path);
3848 if (strcmp (r, expected) != 0) {
3849 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
3857 static int test_checksum_6 (void)
3859 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
3861 char device[] = "/dev/sda";
3862 device[5] = devchar;
3865 r = guestfs_blockdev_setrw (g, device);
3872 r = guestfs_umount_all (g);
3879 r = guestfs_lvm_remove_all (g);
3884 char device[] = "/dev/sda";
3885 device[5] = devchar;
3886 char lines_0[] = ",";
3893 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3898 char fstype[] = "ext2";
3899 char device[] = "/dev/sda1";
3900 device[5] = devchar;
3903 r = guestfs_mkfs (g, fstype, device);
3908 char device[] = "/dev/sda1";
3909 device[5] = devchar;
3910 char mountpoint[] = "/";
3913 r = guestfs_mount (g, device, mountpoint);
3917 /* TestOutput for checksum (6) */
3918 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
3920 char path[] = "/new";
3921 char content[] = "test\n";
3924 r = guestfs_write_file (g, path, content, 0);
3929 char csumtype[] = "sha384";
3930 char path[] = "/new";
3933 r = guestfs_checksum (g, csumtype, path);
3936 if (strcmp (r, expected) != 0) {
3937 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
3945 static int test_checksum_7 (void)
3947 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
3949 char device[] = "/dev/sda";
3950 device[5] = devchar;
3953 r = guestfs_blockdev_setrw (g, device);
3960 r = guestfs_umount_all (g);
3967 r = guestfs_lvm_remove_all (g);
3972 char device[] = "/dev/sda";
3973 device[5] = devchar;
3974 char lines_0[] = ",";
3981 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3986 char fstype[] = "ext2";
3987 char device[] = "/dev/sda1";
3988 device[5] = devchar;
3991 r = guestfs_mkfs (g, fstype, device);
3996 char device[] = "/dev/sda1";
3997 device[5] = devchar;
3998 char mountpoint[] = "/";
4001 r = guestfs_mount (g, device, mountpoint);
4005 /* TestOutput for checksum (7) */
4006 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
4008 char path[] = "/new";
4009 char content[] = "test\n";
4012 r = guestfs_write_file (g, path, content, 0);
4017 char csumtype[] = "sha512";
4018 char path[] = "/new";
4021 r = guestfs_checksum (g, csumtype, path);
4024 if (strcmp (r, expected) != 0) {
4025 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
4033 static int test_download_0 (void)
4035 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
4037 char device[] = "/dev/sda";
4038 device[5] = devchar;
4041 r = guestfs_blockdev_setrw (g, device);
4048 r = guestfs_umount_all (g);
4055 r = guestfs_lvm_remove_all (g);
4060 char device[] = "/dev/sda";
4061 device[5] = devchar;
4062 char lines_0[] = ",";
4069 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4074 char fstype[] = "ext2";
4075 char device[] = "/dev/sda1";
4076 device[5] = devchar;
4079 r = guestfs_mkfs (g, fstype, device);
4084 char device[] = "/dev/sda1";
4085 device[5] = devchar;
4086 char mountpoint[] = "/";
4089 r = guestfs_mount (g, device, mountpoint);
4093 /* TestOutput for download (0) */
4094 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4096 char remotefilename[] = "/COPYING.LIB";
4099 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4104 char remotefilename[] = "/COPYING.LIB";
4107 r = guestfs_download (g, remotefilename, "testdownload.tmp");
4112 char remotefilename[] = "/upload";
4115 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
4120 char csumtype[] = "md5";
4121 char path[] = "/upload";
4124 r = guestfs_checksum (g, csumtype, path);
4127 if (strcmp (r, expected) != 0) {
4128 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
4136 static int test_upload_0 (void)
4138 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
4140 char device[] = "/dev/sda";
4141 device[5] = devchar;
4144 r = guestfs_blockdev_setrw (g, device);
4151 r = guestfs_umount_all (g);
4158 r = guestfs_lvm_remove_all (g);
4163 char device[] = "/dev/sda";
4164 device[5] = devchar;
4165 char lines_0[] = ",";
4172 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4177 char fstype[] = "ext2";
4178 char device[] = "/dev/sda1";
4179 device[5] = devchar;
4182 r = guestfs_mkfs (g, fstype, device);
4187 char device[] = "/dev/sda1";
4188 device[5] = devchar;
4189 char mountpoint[] = "/";
4192 r = guestfs_mount (g, device, mountpoint);
4196 /* TestOutput for upload (0) */
4197 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4199 char remotefilename[] = "/COPYING.LIB";
4202 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4207 char csumtype[] = "md5";
4208 char path[] = "/COPYING.LIB";
4211 r = guestfs_checksum (g, csumtype, path);
4214 if (strcmp (r, expected) != 0) {
4215 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
4223 static int test_blockdev_rereadpt_0 (void)
4225 /* InitEmpty for blockdev_rereadpt (0) */
4227 char device[] = "/dev/sda";
4228 device[5] = devchar;
4231 r = guestfs_blockdev_setrw (g, device);
4238 r = guestfs_umount_all (g);
4245 r = guestfs_lvm_remove_all (g);
4249 /* TestRun for blockdev_rereadpt (0) */
4251 char device[] = "/dev/sda";
4252 device[5] = devchar;
4255 r = guestfs_blockdev_rereadpt (g, device);
4262 static int test_blockdev_flushbufs_0 (void)
4264 /* InitEmpty for blockdev_flushbufs (0) */
4266 char device[] = "/dev/sda";
4267 device[5] = devchar;
4270 r = guestfs_blockdev_setrw (g, device);
4277 r = guestfs_umount_all (g);
4284 r = guestfs_lvm_remove_all (g);
4288 /* TestRun for blockdev_flushbufs (0) */
4290 char device[] = "/dev/sda";
4291 device[5] = devchar;
4294 r = guestfs_blockdev_flushbufs (g, device);
4301 static int test_blockdev_getsize64_0 (void)
4303 /* InitEmpty for blockdev_getsize64 (0) */
4305 char device[] = "/dev/sda";
4306 device[5] = devchar;
4309 r = guestfs_blockdev_setrw (g, device);
4316 r = guestfs_umount_all (g);
4323 r = guestfs_lvm_remove_all (g);
4327 /* TestOutputInt for blockdev_getsize64 (0) */
4329 char device[] = "/dev/sda";
4330 device[5] = devchar;
4333 r = guestfs_blockdev_getsize64 (g, device);
4336 if (r != 524288000) {
4337 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
4344 static int test_blockdev_getsz_0 (void)
4346 /* InitEmpty for blockdev_getsz (0) */
4348 char device[] = "/dev/sda";
4349 device[5] = devchar;
4352 r = guestfs_blockdev_setrw (g, device);
4359 r = guestfs_umount_all (g);
4366 r = guestfs_lvm_remove_all (g);
4370 /* TestOutputInt for blockdev_getsz (0) */
4372 char device[] = "/dev/sda";
4373 device[5] = devchar;
4376 r = guestfs_blockdev_getsz (g, device);
4380 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
4387 static int test_blockdev_getbsz_0 (void)
4389 /* InitEmpty for blockdev_getbsz (0) */
4391 char device[] = "/dev/sda";
4392 device[5] = devchar;
4395 r = guestfs_blockdev_setrw (g, device);
4402 r = guestfs_umount_all (g);
4409 r = guestfs_lvm_remove_all (g);
4413 /* TestOutputInt for blockdev_getbsz (0) */
4415 char device[] = "/dev/sda";
4416 device[5] = devchar;
4419 r = guestfs_blockdev_getbsz (g, device);
4423 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
4430 static int test_blockdev_getss_0 (void)
4432 /* InitEmpty for blockdev_getss (0) */
4434 char device[] = "/dev/sda";
4435 device[5] = devchar;
4438 r = guestfs_blockdev_setrw (g, device);
4445 r = guestfs_umount_all (g);
4452 r = guestfs_lvm_remove_all (g);
4456 /* TestOutputInt for blockdev_getss (0) */
4458 char device[] = "/dev/sda";
4459 device[5] = devchar;
4462 r = guestfs_blockdev_getss (g, device);
4466 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
4473 static int test_blockdev_getro_0 (void)
4475 /* InitEmpty for blockdev_getro (0) */
4477 char device[] = "/dev/sda";
4478 device[5] = devchar;
4481 r = guestfs_blockdev_setrw (g, device);
4488 r = guestfs_umount_all (g);
4495 r = guestfs_lvm_remove_all (g);
4499 /* TestOutputTrue for blockdev_getro (0) */
4501 char device[] = "/dev/sda";
4502 device[5] = devchar;
4505 r = guestfs_blockdev_setro (g, device);
4510 char device[] = "/dev/sda";
4511 device[5] = devchar;
4514 r = guestfs_blockdev_getro (g, device);
4518 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
4525 static int test_blockdev_setrw_0 (void)
4527 /* InitEmpty for blockdev_setrw (0) */
4529 char device[] = "/dev/sda";
4530 device[5] = devchar;
4533 r = guestfs_blockdev_setrw (g, device);
4540 r = guestfs_umount_all (g);
4547 r = guestfs_lvm_remove_all (g);
4551 /* TestOutputFalse for blockdev_setrw (0) */
4553 char device[] = "/dev/sda";
4554 device[5] = devchar;
4557 r = guestfs_blockdev_setrw (g, device);
4562 char device[] = "/dev/sda";
4563 device[5] = devchar;
4566 r = guestfs_blockdev_getro (g, device);
4570 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
4577 static int test_blockdev_setro_0 (void)
4579 /* InitEmpty for blockdev_setro (0) */
4581 char device[] = "/dev/sda";
4582 device[5] = devchar;
4585 r = guestfs_blockdev_setrw (g, device);
4592 r = guestfs_umount_all (g);
4599 r = guestfs_lvm_remove_all (g);
4603 /* TestOutputTrue for blockdev_setro (0) */
4605 char device[] = "/dev/sda";
4606 device[5] = devchar;
4609 r = guestfs_blockdev_setro (g, device);
4614 char device[] = "/dev/sda";
4615 device[5] = devchar;
4618 r = guestfs_blockdev_getro (g, device);
4622 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
4629 static int test_statvfs_0 (void)
4631 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
4633 char device[] = "/dev/sda";
4634 device[5] = devchar;
4637 r = guestfs_blockdev_setrw (g, device);
4644 r = guestfs_umount_all (g);
4651 r = guestfs_lvm_remove_all (g);
4656 char device[] = "/dev/sda";
4657 device[5] = devchar;
4658 char lines_0[] = ",";
4665 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4670 char fstype[] = "ext2";
4671 char device[] = "/dev/sda1";
4672 device[5] = devchar;
4675 r = guestfs_mkfs (g, fstype, device);
4680 char device[] = "/dev/sda1";
4681 device[5] = devchar;
4682 char mountpoint[] = "/";
4685 r = guestfs_mount (g, device, mountpoint);
4689 /* TestOutputStruct for statvfs (0) */
4692 struct guestfs_statvfs *r;
4694 r = guestfs_statvfs (g, path);
4697 if (r->bfree != 487702) {
4698 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
4702 if (r->blocks != 490020) {
4703 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
4707 if (r->bsize != 1024) {
4708 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
4717 static int test_lstat_0 (void)
4719 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
4721 char device[] = "/dev/sda";
4722 device[5] = devchar;
4725 r = guestfs_blockdev_setrw (g, device);
4732 r = guestfs_umount_all (g);
4739 r = guestfs_lvm_remove_all (g);
4744 char device[] = "/dev/sda";
4745 device[5] = devchar;
4746 char lines_0[] = ",";
4753 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4758 char fstype[] = "ext2";
4759 char device[] = "/dev/sda1";
4760 device[5] = devchar;
4763 r = guestfs_mkfs (g, fstype, device);
4768 char device[] = "/dev/sda1";
4769 device[5] = devchar;
4770 char mountpoint[] = "/";
4773 r = guestfs_mount (g, device, mountpoint);
4777 /* TestOutputStruct for lstat (0) */
4779 char path[] = "/new";
4782 r = guestfs_touch (g, path);
4787 char path[] = "/new";
4788 struct guestfs_stat *r;
4790 r = guestfs_lstat (g, path);
4794 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
4803 static int test_stat_0 (void)
4805 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
4807 char device[] = "/dev/sda";
4808 device[5] = devchar;
4811 r = guestfs_blockdev_setrw (g, device);
4818 r = guestfs_umount_all (g);
4825 r = guestfs_lvm_remove_all (g);
4830 char device[] = "/dev/sda";
4831 device[5] = devchar;
4832 char lines_0[] = ",";
4839 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4844 char fstype[] = "ext2";
4845 char device[] = "/dev/sda1";
4846 device[5] = devchar;
4849 r = guestfs_mkfs (g, fstype, device);
4854 char device[] = "/dev/sda1";
4855 device[5] = devchar;
4856 char mountpoint[] = "/";
4859 r = guestfs_mount (g, device, mountpoint);
4863 /* TestOutputStruct for stat (0) */
4865 char path[] = "/new";
4868 r = guestfs_touch (g, path);
4873 char path[] = "/new";
4874 struct guestfs_stat *r;
4876 r = guestfs_stat (g, path);
4880 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
4889 static int test_file_0 (void)
4891 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
4893 char device[] = "/dev/sda";
4894 device[5] = devchar;
4897 r = guestfs_blockdev_setrw (g, device);
4904 r = guestfs_umount_all (g);
4911 r = guestfs_lvm_remove_all (g);
4916 char device[] = "/dev/sda";
4917 device[5] = devchar;
4918 char lines_0[] = ",";
4925 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4930 char fstype[] = "ext2";
4931 char device[] = "/dev/sda1";
4932 device[5] = devchar;
4935 r = guestfs_mkfs (g, fstype, device);
4940 char device[] = "/dev/sda1";
4941 device[5] = devchar;
4942 char mountpoint[] = "/";
4945 r = guestfs_mount (g, device, mountpoint);
4949 /* TestOutput for file (0) */
4950 char expected[] = "empty";
4952 char path[] = "/new";
4955 r = guestfs_touch (g, path);
4960 char path[] = "/new";
4963 r = guestfs_file (g, path);
4966 if (strcmp (r, expected) != 0) {
4967 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
4975 static int test_file_1 (void)
4977 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
4979 char device[] = "/dev/sda";
4980 device[5] = devchar;
4983 r = guestfs_blockdev_setrw (g, device);
4990 r = guestfs_umount_all (g);
4997 r = guestfs_lvm_remove_all (g);
5002 char device[] = "/dev/sda";
5003 device[5] = devchar;
5004 char lines_0[] = ",";
5011 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5016 char fstype[] = "ext2";
5017 char device[] = "/dev/sda1";
5018 device[5] = devchar;
5021 r = guestfs_mkfs (g, fstype, device);
5026 char device[] = "/dev/sda1";
5027 device[5] = devchar;
5028 char mountpoint[] = "/";
5031 r = guestfs_mount (g, device, mountpoint);
5035 /* TestOutput for file (1) */
5036 char expected[] = "ASCII text";
5038 char path[] = "/new";
5039 char content[] = "some content\n";
5042 r = guestfs_write_file (g, path, content, 0);
5047 char path[] = "/new";
5050 r = guestfs_file (g, path);
5053 if (strcmp (r, expected) != 0) {
5054 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5062 static int test_file_2 (void)
5064 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
5066 char device[] = "/dev/sda";
5067 device[5] = devchar;
5070 r = guestfs_blockdev_setrw (g, device);
5077 r = guestfs_umount_all (g);
5084 r = guestfs_lvm_remove_all (g);
5089 char device[] = "/dev/sda";
5090 device[5] = devchar;
5091 char lines_0[] = ",";
5098 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5103 char fstype[] = "ext2";
5104 char device[] = "/dev/sda1";
5105 device[5] = devchar;
5108 r = guestfs_mkfs (g, fstype, device);
5113 char device[] = "/dev/sda1";
5114 device[5] = devchar;
5115 char mountpoint[] = "/";
5118 r = guestfs_mount (g, device, mountpoint);
5122 /* TestLastFail for file (2) */
5124 char path[] = "/nofile";
5127 r = guestfs_file (g, path);
5135 static int test_umount_all_0 (void)
5137 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
5139 char device[] = "/dev/sda";
5140 device[5] = devchar;
5143 r = guestfs_blockdev_setrw (g, device);
5150 r = guestfs_umount_all (g);
5157 r = guestfs_lvm_remove_all (g);
5162 char device[] = "/dev/sda";
5163 device[5] = devchar;
5164 char lines_0[] = ",";
5171 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5176 char fstype[] = "ext2";
5177 char device[] = "/dev/sda1";
5178 device[5] = devchar;
5181 r = guestfs_mkfs (g, fstype, device);
5186 char device[] = "/dev/sda1";
5187 device[5] = devchar;
5188 char mountpoint[] = "/";
5191 r = guestfs_mount (g, device, mountpoint);
5195 /* TestOutputList for umount_all (0) */
5199 r = guestfs_umount_all (g);
5207 r = guestfs_mounts (g);
5211 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
5215 for (i = 0; r[i] != NULL; ++i)
5222 static int test_umount_all_1 (void)
5224 /* InitEmpty for umount_all (1) */
5226 char device[] = "/dev/sda";
5227 device[5] = devchar;
5230 r = guestfs_blockdev_setrw (g, device);
5237 r = guestfs_umount_all (g);
5244 r = guestfs_lvm_remove_all (g);
5248 /* TestOutputList for umount_all (1) */
5250 char device[] = "/dev/sda";
5251 device[5] = devchar;
5252 char lines_0[] = ",10";
5253 char lines_1[] = ",20";
5254 char lines_2[] = ",";
5263 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5268 char fstype[] = "ext2";
5269 char device[] = "/dev/sda1";
5270 device[5] = devchar;
5273 r = guestfs_mkfs (g, fstype, device);
5278 char fstype[] = "ext2";
5279 char device[] = "/dev/sda2";
5280 device[5] = devchar;
5283 r = guestfs_mkfs (g, fstype, device);
5288 char fstype[] = "ext2";
5289 char device[] = "/dev/sda3";
5290 device[5] = devchar;
5293 r = guestfs_mkfs (g, fstype, device);
5298 char device[] = "/dev/sda1";
5299 device[5] = devchar;
5300 char mountpoint[] = "/";
5303 r = guestfs_mount (g, device, mountpoint);
5308 char path[] = "/mp1";
5311 r = guestfs_mkdir (g, path);
5316 char device[] = "/dev/sda2";
5317 device[5] = devchar;
5318 char mountpoint[] = "/mp1";
5321 r = guestfs_mount (g, device, mountpoint);
5326 char path[] = "/mp1/mp2";
5329 r = guestfs_mkdir (g, path);
5334 char device[] = "/dev/sda3";
5335 device[5] = devchar;
5336 char mountpoint[] = "/mp1/mp2";
5339 r = guestfs_mount (g, device, mountpoint);
5344 char path[] = "/mp1/mp2/mp3";
5347 r = guestfs_mkdir (g, path);
5354 r = guestfs_umount_all (g);
5362 r = guestfs_mounts (g);
5366 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
5370 for (i = 0; r[i] != NULL; ++i)
5377 static int test_mounts_0 (void)
5379 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
5381 char device[] = "/dev/sda";
5382 device[5] = devchar;
5385 r = guestfs_blockdev_setrw (g, device);
5392 r = guestfs_umount_all (g);
5399 r = guestfs_lvm_remove_all (g);
5404 char device[] = "/dev/sda";
5405 device[5] = devchar;
5406 char lines_0[] = ",";
5413 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5418 char fstype[] = "ext2";
5419 char device[] = "/dev/sda1";
5420 device[5] = devchar;
5423 r = guestfs_mkfs (g, fstype, device);
5428 char device[] = "/dev/sda1";
5429 device[5] = devchar;
5430 char mountpoint[] = "/";
5433 r = guestfs_mount (g, device, mountpoint);
5437 /* TestOutputList for mounts (0) */
5442 r = guestfs_mounts (g);
5446 fprintf (stderr, "test_mounts_0: short list returned from command\n");
5451 char expected[] = "/dev/sda1";
5452 expected[5] = devchar;
5453 if (strcmp (r[0], expected) != 0) {
5454 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5459 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
5463 for (i = 0; r[i] != NULL; ++i)
5470 static int test_umount_0 (void)
5472 /* InitEmpty for umount (0) */
5474 char device[] = "/dev/sda";
5475 device[5] = devchar;
5478 r = guestfs_blockdev_setrw (g, device);
5485 r = guestfs_umount_all (g);
5492 r = guestfs_lvm_remove_all (g);
5496 /* TestOutputList for umount (0) */
5498 char device[] = "/dev/sda";
5499 device[5] = devchar;
5500 char lines_0[] = ",";
5507 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5512 char fstype[] = "ext2";
5513 char device[] = "/dev/sda1";
5514 device[5] = devchar;
5517 r = guestfs_mkfs (g, fstype, device);
5522 char device[] = "/dev/sda1";
5523 device[5] = devchar;
5524 char mountpoint[] = "/";
5527 r = guestfs_mount (g, device, mountpoint);
5535 r = guestfs_mounts (g);
5539 fprintf (stderr, "test_umount_0: short list returned from command\n");
5544 char expected[] = "/dev/sda1";
5545 expected[5] = devchar;
5546 if (strcmp (r[0], expected) != 0) {
5547 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5552 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
5556 for (i = 0; r[i] != NULL; ++i)
5563 static int test_umount_1 (void)
5565 /* InitEmpty for umount (1) */
5567 char device[] = "/dev/sda";
5568 device[5] = devchar;
5571 r = guestfs_blockdev_setrw (g, device);
5578 r = guestfs_umount_all (g);
5585 r = guestfs_lvm_remove_all (g);
5589 /* TestOutputList for umount (1) */
5591 char device[] = "/dev/sda";
5592 device[5] = devchar;
5593 char lines_0[] = ",";
5600 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5605 char fstype[] = "ext2";
5606 char device[] = "/dev/sda1";
5607 device[5] = devchar;
5610 r = guestfs_mkfs (g, fstype, device);
5615 char device[] = "/dev/sda1";
5616 device[5] = devchar;
5617 char mountpoint[] = "/";
5620 r = guestfs_mount (g, device, mountpoint);
5625 char pathordevice[] = "/";
5628 r = guestfs_umount (g, pathordevice);
5636 r = guestfs_mounts (g);
5640 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
5644 for (i = 0; r[i] != NULL; ++i)
5651 static int test_write_file_0 (void)
5653 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
5655 char device[] = "/dev/sda";
5656 device[5] = devchar;
5659 r = guestfs_blockdev_setrw (g, device);
5666 r = guestfs_umount_all (g);
5673 r = guestfs_lvm_remove_all (g);
5678 char device[] = "/dev/sda";
5679 device[5] = devchar;
5680 char lines_0[] = ",";
5687 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5692 char fstype[] = "ext2";
5693 char device[] = "/dev/sda1";
5694 device[5] = devchar;
5697 r = guestfs_mkfs (g, fstype, device);
5702 char device[] = "/dev/sda1";
5703 device[5] = devchar;
5704 char mountpoint[] = "/";
5707 r = guestfs_mount (g, device, mountpoint);
5711 /* TestOutput for write_file (0) */
5712 char expected[] = "new file contents";
5714 char path[] = "/new";
5715 char content[] = "new file contents";
5718 r = guestfs_write_file (g, path, content, 0);
5723 char path[] = "/new";
5726 r = guestfs_cat (g, path);
5729 if (strcmp (r, expected) != 0) {
5730 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
5738 static int test_write_file_1 (void)
5740 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
5742 char device[] = "/dev/sda";
5743 device[5] = devchar;
5746 r = guestfs_blockdev_setrw (g, device);
5753 r = guestfs_umount_all (g);
5760 r = guestfs_lvm_remove_all (g);
5765 char device[] = "/dev/sda";
5766 device[5] = devchar;
5767 char lines_0[] = ",";
5774 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5779 char fstype[] = "ext2";
5780 char device[] = "/dev/sda1";
5781 device[5] = devchar;
5784 r = guestfs_mkfs (g, fstype, device);
5789 char device[] = "/dev/sda1";
5790 device[5] = devchar;
5791 char mountpoint[] = "/";
5794 r = guestfs_mount (g, device, mountpoint);
5798 /* TestOutput for write_file (1) */
5799 char expected[] = "\nnew file contents\n";
5801 char path[] = "/new";
5802 char content[] = "\nnew file contents\n";
5805 r = guestfs_write_file (g, path, content, 0);
5810 char path[] = "/new";
5813 r = guestfs_cat (g, path);
5816 if (strcmp (r, expected) != 0) {
5817 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5825 static int test_write_file_2 (void)
5827 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
5829 char device[] = "/dev/sda";
5830 device[5] = devchar;
5833 r = guestfs_blockdev_setrw (g, device);
5840 r = guestfs_umount_all (g);
5847 r = guestfs_lvm_remove_all (g);
5852 char device[] = "/dev/sda";
5853 device[5] = devchar;
5854 char lines_0[] = ",";
5861 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5866 char fstype[] = "ext2";
5867 char device[] = "/dev/sda1";
5868 device[5] = devchar;
5871 r = guestfs_mkfs (g, fstype, device);
5876 char device[] = "/dev/sda1";
5877 device[5] = devchar;
5878 char mountpoint[] = "/";
5881 r = guestfs_mount (g, device, mountpoint);
5885 /* TestOutput for write_file (2) */
5886 char expected[] = "\n\n";
5888 char path[] = "/new";
5889 char content[] = "\n\n";
5892 r = guestfs_write_file (g, path, content, 0);
5897 char path[] = "/new";
5900 r = guestfs_cat (g, path);
5903 if (strcmp (r, expected) != 0) {
5904 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
5912 static int test_write_file_3 (void)
5914 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
5916 char device[] = "/dev/sda";
5917 device[5] = devchar;
5920 r = guestfs_blockdev_setrw (g, device);
5927 r = guestfs_umount_all (g);
5934 r = guestfs_lvm_remove_all (g);
5939 char device[] = "/dev/sda";
5940 device[5] = devchar;
5941 char lines_0[] = ",";
5948 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5953 char fstype[] = "ext2";
5954 char device[] = "/dev/sda1";
5955 device[5] = devchar;
5958 r = guestfs_mkfs (g, fstype, device);
5963 char device[] = "/dev/sda1";
5964 device[5] = devchar;
5965 char mountpoint[] = "/";
5968 r = guestfs_mount (g, device, mountpoint);
5972 /* TestOutput for write_file (3) */
5973 char expected[] = "";
5975 char path[] = "/new";
5976 char content[] = "";
5979 r = guestfs_write_file (g, path, content, 0);
5984 char path[] = "/new";
5987 r = guestfs_cat (g, path);
5990 if (strcmp (r, expected) != 0) {
5991 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
5999 static int test_write_file_4 (void)
6001 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
6003 char device[] = "/dev/sda";
6004 device[5] = devchar;
6007 r = guestfs_blockdev_setrw (g, device);
6014 r = guestfs_umount_all (g);
6021 r = guestfs_lvm_remove_all (g);
6026 char device[] = "/dev/sda";
6027 device[5] = devchar;
6028 char lines_0[] = ",";
6035 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6040 char fstype[] = "ext2";
6041 char device[] = "/dev/sda1";
6042 device[5] = devchar;
6045 r = guestfs_mkfs (g, fstype, device);
6050 char device[] = "/dev/sda1";
6051 device[5] = devchar;
6052 char mountpoint[] = "/";
6055 r = guestfs_mount (g, device, mountpoint);
6059 /* TestOutput for write_file (4) */
6060 char expected[] = "\n\n\n";
6062 char path[] = "/new";
6063 char content[] = "\n\n\n";
6066 r = guestfs_write_file (g, path, content, 0);
6071 char path[] = "/new";
6074 r = guestfs_cat (g, path);
6077 if (strcmp (r, expected) != 0) {
6078 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
6086 static int test_write_file_5 (void)
6088 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
6090 char device[] = "/dev/sda";
6091 device[5] = devchar;
6094 r = guestfs_blockdev_setrw (g, device);
6101 r = guestfs_umount_all (g);
6108 r = guestfs_lvm_remove_all (g);
6113 char device[] = "/dev/sda";
6114 device[5] = devchar;
6115 char lines_0[] = ",";
6122 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6127 char fstype[] = "ext2";
6128 char device[] = "/dev/sda1";
6129 device[5] = devchar;
6132 r = guestfs_mkfs (g, fstype, device);
6137 char device[] = "/dev/sda1";
6138 device[5] = devchar;
6139 char mountpoint[] = "/";
6142 r = guestfs_mount (g, device, mountpoint);
6146 /* TestOutput for write_file (5) */
6147 char expected[] = "\n";
6149 char path[] = "/new";
6150 char content[] = "\n";
6153 r = guestfs_write_file (g, path, content, 0);
6158 char path[] = "/new";
6161 r = guestfs_cat (g, path);
6164 if (strcmp (r, expected) != 0) {
6165 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
6173 static int test_mkfs_0 (void)
6175 /* InitEmpty for mkfs (0) */
6177 char device[] = "/dev/sda";
6178 device[5] = devchar;
6181 r = guestfs_blockdev_setrw (g, device);
6188 r = guestfs_umount_all (g);
6195 r = guestfs_lvm_remove_all (g);
6199 /* TestOutput for mkfs (0) */
6200 char expected[] = "new file contents";
6202 char device[] = "/dev/sda";
6203 device[5] = devchar;
6204 char lines_0[] = ",";
6211 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6216 char fstype[] = "ext2";
6217 char device[] = "/dev/sda1";
6218 device[5] = devchar;
6221 r = guestfs_mkfs (g, fstype, device);
6226 char device[] = "/dev/sda1";
6227 device[5] = devchar;
6228 char mountpoint[] = "/";
6231 r = guestfs_mount (g, device, mountpoint);
6236 char path[] = "/new";
6237 char content[] = "new file contents";
6240 r = guestfs_write_file (g, path, content, 0);
6245 char path[] = "/new";
6248 r = guestfs_cat (g, path);
6251 if (strcmp (r, expected) != 0) {
6252 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
6260 static int test_lvcreate_0 (void)
6262 /* InitEmpty for lvcreate (0) */
6264 char device[] = "/dev/sda";
6265 device[5] = devchar;
6268 r = guestfs_blockdev_setrw (g, device);
6275 r = guestfs_umount_all (g);
6282 r = guestfs_lvm_remove_all (g);
6286 /* TestOutputList for lvcreate (0) */
6288 char device[] = "/dev/sda";
6289 device[5] = devchar;
6290 char lines_0[] = ",10";
6291 char lines_1[] = ",20";
6292 char lines_2[] = ",";
6301 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6306 char device[] = "/dev/sda1";
6307 device[5] = devchar;
6310 r = guestfs_pvcreate (g, device);
6315 char device[] = "/dev/sda2";
6316 device[5] = devchar;
6319 r = guestfs_pvcreate (g, device);
6324 char device[] = "/dev/sda3";
6325 device[5] = devchar;
6328 r = guestfs_pvcreate (g, device);
6333 char volgroup[] = "VG1";
6334 char physvols_0[] = "/dev/sda1";
6335 physvols_0[5] = devchar;
6336 char physvols_1[] = "/dev/sda2";
6337 physvols_1[5] = devchar;
6338 char *physvols[] = {
6345 r = guestfs_vgcreate (g, volgroup, physvols);
6350 char volgroup[] = "VG2";
6351 char physvols_0[] = "/dev/sda3";
6352 physvols_0[5] = devchar;
6353 char *physvols[] = {
6359 r = guestfs_vgcreate (g, volgroup, physvols);
6364 char logvol[] = "LV1";
6365 char volgroup[] = "VG1";
6368 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6373 char logvol[] = "LV2";
6374 char volgroup[] = "VG1";
6377 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6382 char logvol[] = "LV3";
6383 char volgroup[] = "VG2";
6386 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6391 char logvol[] = "LV4";
6392 char volgroup[] = "VG2";
6395 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6400 char logvol[] = "LV5";
6401 char volgroup[] = "VG2";
6404 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6412 r = guestfs_lvs (g);
6416 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6421 char expected[] = "/dev/VG1/LV1";
6422 if (strcmp (r[0], expected) != 0) {
6423 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6428 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6433 char expected[] = "/dev/VG1/LV2";
6434 if (strcmp (r[1], expected) != 0) {
6435 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6440 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6445 char expected[] = "/dev/VG2/LV3";
6446 if (strcmp (r[2], expected) != 0) {
6447 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6452 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6457 char expected[] = "/dev/VG2/LV4";
6458 if (strcmp (r[3], expected) != 0) {
6459 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
6464 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6469 char expected[] = "/dev/VG2/LV5";
6470 if (strcmp (r[4], expected) != 0) {
6471 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
6476 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
6480 for (i = 0; r[i] != NULL; ++i)
6487 static int test_vgcreate_0 (void)
6489 /* InitEmpty for vgcreate (0) */
6491 char device[] = "/dev/sda";
6492 device[5] = devchar;
6495 r = guestfs_blockdev_setrw (g, device);
6502 r = guestfs_umount_all (g);
6509 r = guestfs_lvm_remove_all (g);
6513 /* TestOutputList for vgcreate (0) */
6515 char device[] = "/dev/sda";
6516 device[5] = devchar;
6517 char lines_0[] = ",10";
6518 char lines_1[] = ",20";
6519 char lines_2[] = ",";
6528 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6533 char device[] = "/dev/sda1";
6534 device[5] = devchar;
6537 r = guestfs_pvcreate (g, device);
6542 char device[] = "/dev/sda2";
6543 device[5] = devchar;
6546 r = guestfs_pvcreate (g, device);
6551 char device[] = "/dev/sda3";
6552 device[5] = devchar;
6555 r = guestfs_pvcreate (g, device);
6560 char volgroup[] = "VG1";
6561 char physvols_0[] = "/dev/sda1";
6562 physvols_0[5] = devchar;
6563 char physvols_1[] = "/dev/sda2";
6564 physvols_1[5] = devchar;
6565 char *physvols[] = {
6572 r = guestfs_vgcreate (g, volgroup, physvols);
6577 char volgroup[] = "VG2";
6578 char physvols_0[] = "/dev/sda3";
6579 physvols_0[5] = devchar;
6580 char *physvols[] = {
6586 r = guestfs_vgcreate (g, volgroup, physvols);
6594 r = guestfs_vgs (g);
6598 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6603 char expected[] = "VG1";
6604 if (strcmp (r[0], expected) != 0) {
6605 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6610 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6615 char expected[] = "VG2";
6616 if (strcmp (r[1], expected) != 0) {
6617 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6622 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
6626 for (i = 0; r[i] != NULL; ++i)
6633 static int test_pvcreate_0 (void)
6635 /* InitEmpty for pvcreate (0) */
6637 char device[] = "/dev/sda";
6638 device[5] = devchar;
6641 r = guestfs_blockdev_setrw (g, device);
6648 r = guestfs_umount_all (g);
6655 r = guestfs_lvm_remove_all (g);
6659 /* TestOutputList for pvcreate (0) */
6661 char device[] = "/dev/sda";
6662 device[5] = devchar;
6663 char lines_0[] = ",10";
6664 char lines_1[] = ",20";
6665 char lines_2[] = ",";
6674 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6679 char device[] = "/dev/sda1";
6680 device[5] = devchar;
6683 r = guestfs_pvcreate (g, device);
6688 char device[] = "/dev/sda2";
6689 device[5] = devchar;
6692 r = guestfs_pvcreate (g, device);
6697 char device[] = "/dev/sda3";
6698 device[5] = devchar;
6701 r = guestfs_pvcreate (g, device);
6709 r = guestfs_pvs (g);
6713 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6718 char expected[] = "/dev/sda1";
6719 expected[5] = devchar;
6720 if (strcmp (r[0], expected) != 0) {
6721 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6726 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6731 char expected[] = "/dev/sda2";
6732 expected[5] = devchar;
6733 if (strcmp (r[1], expected) != 0) {
6734 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6739 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6744 char expected[] = "/dev/sda3";
6745 expected[5] = devchar;
6746 if (strcmp (r[2], expected) != 0) {
6747 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6752 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
6756 for (i = 0; r[i] != NULL; ++i)
6763 static int test_is_dir_0 (void)
6765 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
6767 char device[] = "/dev/sda";
6768 device[5] = devchar;
6771 r = guestfs_blockdev_setrw (g, device);
6778 r = guestfs_umount_all (g);
6785 r = guestfs_lvm_remove_all (g);
6790 char device[] = "/dev/sda";
6791 device[5] = devchar;
6792 char lines_0[] = ",";
6799 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6804 char fstype[] = "ext2";
6805 char device[] = "/dev/sda1";
6806 device[5] = devchar;
6809 r = guestfs_mkfs (g, fstype, device);
6814 char device[] = "/dev/sda1";
6815 device[5] = devchar;
6816 char mountpoint[] = "/";
6819 r = guestfs_mount (g, device, mountpoint);
6823 /* TestOutputFalse for is_dir (0) */
6825 char path[] = "/new";
6828 r = guestfs_touch (g, path);
6833 char path[] = "/new";
6836 r = guestfs_is_dir (g, path);
6840 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
6847 static int test_is_dir_1 (void)
6849 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
6851 char device[] = "/dev/sda";
6852 device[5] = devchar;
6855 r = guestfs_blockdev_setrw (g, device);
6862 r = guestfs_umount_all (g);
6869 r = guestfs_lvm_remove_all (g);
6874 char device[] = "/dev/sda";
6875 device[5] = devchar;
6876 char lines_0[] = ",";
6883 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6888 char fstype[] = "ext2";
6889 char device[] = "/dev/sda1";
6890 device[5] = devchar;
6893 r = guestfs_mkfs (g, fstype, device);
6898 char device[] = "/dev/sda1";
6899 device[5] = devchar;
6900 char mountpoint[] = "/";
6903 r = guestfs_mount (g, device, mountpoint);
6907 /* TestOutputTrue for is_dir (1) */
6909 char path[] = "/new";
6912 r = guestfs_mkdir (g, path);
6917 char path[] = "/new";
6920 r = guestfs_is_dir (g, path);
6924 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
6931 static int test_is_file_0 (void)
6933 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
6935 char device[] = "/dev/sda";
6936 device[5] = devchar;
6939 r = guestfs_blockdev_setrw (g, device);
6946 r = guestfs_umount_all (g);
6953 r = guestfs_lvm_remove_all (g);
6958 char device[] = "/dev/sda";
6959 device[5] = devchar;
6960 char lines_0[] = ",";
6967 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6972 char fstype[] = "ext2";
6973 char device[] = "/dev/sda1";
6974 device[5] = devchar;
6977 r = guestfs_mkfs (g, fstype, device);
6982 char device[] = "/dev/sda1";
6983 device[5] = devchar;
6984 char mountpoint[] = "/";
6987 r = guestfs_mount (g, device, mountpoint);
6991 /* TestOutputTrue for is_file (0) */
6993 char path[] = "/new";
6996 r = guestfs_touch (g, path);
7001 char path[] = "/new";
7004 r = guestfs_is_file (g, path);
7008 fprintf (stderr, "test_is_file_0: expected true, got false\n");
7015 static int test_is_file_1 (void)
7017 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
7019 char device[] = "/dev/sda";
7020 device[5] = devchar;
7023 r = guestfs_blockdev_setrw (g, device);
7030 r = guestfs_umount_all (g);
7037 r = guestfs_lvm_remove_all (g);
7042 char device[] = "/dev/sda";
7043 device[5] = devchar;
7044 char lines_0[] = ",";
7051 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7056 char fstype[] = "ext2";
7057 char device[] = "/dev/sda1";
7058 device[5] = devchar;
7061 r = guestfs_mkfs (g, fstype, device);
7066 char device[] = "/dev/sda1";
7067 device[5] = devchar;
7068 char mountpoint[] = "/";
7071 r = guestfs_mount (g, device, mountpoint);
7075 /* TestOutputFalse for is_file (1) */
7077 char path[] = "/new";
7080 r = guestfs_mkdir (g, path);
7085 char path[] = "/new";
7088 r = guestfs_is_file (g, path);
7092 fprintf (stderr, "test_is_file_1: expected false, got true\n");
7099 static int test_exists_0 (void)
7101 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
7103 char device[] = "/dev/sda";
7104 device[5] = devchar;
7107 r = guestfs_blockdev_setrw (g, device);
7114 r = guestfs_umount_all (g);
7121 r = guestfs_lvm_remove_all (g);
7126 char device[] = "/dev/sda";
7127 device[5] = devchar;
7128 char lines_0[] = ",";
7135 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7140 char fstype[] = "ext2";
7141 char device[] = "/dev/sda1";
7142 device[5] = devchar;
7145 r = guestfs_mkfs (g, fstype, device);
7150 char device[] = "/dev/sda1";
7151 device[5] = devchar;
7152 char mountpoint[] = "/";
7155 r = guestfs_mount (g, device, mountpoint);
7159 /* TestOutputTrue for exists (0) */
7161 char path[] = "/new";
7164 r = guestfs_touch (g, path);
7169 char path[] = "/new";
7172 r = guestfs_exists (g, path);
7176 fprintf (stderr, "test_exists_0: expected true, got false\n");
7183 static int test_exists_1 (void)
7185 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
7187 char device[] = "/dev/sda";
7188 device[5] = devchar;
7191 r = guestfs_blockdev_setrw (g, device);
7198 r = guestfs_umount_all (g);
7205 r = guestfs_lvm_remove_all (g);
7210 char device[] = "/dev/sda";
7211 device[5] = devchar;
7212 char lines_0[] = ",";
7219 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7224 char fstype[] = "ext2";
7225 char device[] = "/dev/sda1";
7226 device[5] = devchar;
7229 r = guestfs_mkfs (g, fstype, device);
7234 char device[] = "/dev/sda1";
7235 device[5] = devchar;
7236 char mountpoint[] = "/";
7239 r = guestfs_mount (g, device, mountpoint);
7243 /* TestOutputTrue for exists (1) */
7245 char path[] = "/new";
7248 r = guestfs_mkdir (g, path);
7253 char path[] = "/new";
7256 r = guestfs_exists (g, path);
7260 fprintf (stderr, "test_exists_1: expected true, got false\n");
7267 static int test_mkdir_p_0 (void)
7269 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
7271 char device[] = "/dev/sda";
7272 device[5] = devchar;
7275 r = guestfs_blockdev_setrw (g, device);
7282 r = guestfs_umount_all (g);
7289 r = guestfs_lvm_remove_all (g);
7294 char device[] = "/dev/sda";
7295 device[5] = devchar;
7296 char lines_0[] = ",";
7303 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7308 char fstype[] = "ext2";
7309 char device[] = "/dev/sda1";
7310 device[5] = devchar;
7313 r = guestfs_mkfs (g, fstype, device);
7318 char device[] = "/dev/sda1";
7319 device[5] = devchar;
7320 char mountpoint[] = "/";
7323 r = guestfs_mount (g, device, mountpoint);
7327 /* TestOutputTrue for mkdir_p (0) */
7329 char path[] = "/new/foo/bar";
7332 r = guestfs_mkdir_p (g, path);
7337 char path[] = "/new/foo/bar";
7340 r = guestfs_is_dir (g, path);
7344 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
7351 static int test_mkdir_p_1 (void)
7353 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
7355 char device[] = "/dev/sda";
7356 device[5] = devchar;
7359 r = guestfs_blockdev_setrw (g, device);
7366 r = guestfs_umount_all (g);
7373 r = guestfs_lvm_remove_all (g);
7378 char device[] = "/dev/sda";
7379 device[5] = devchar;
7380 char lines_0[] = ",";
7387 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7392 char fstype[] = "ext2";
7393 char device[] = "/dev/sda1";
7394 device[5] = devchar;
7397 r = guestfs_mkfs (g, fstype, device);
7402 char device[] = "/dev/sda1";
7403 device[5] = devchar;
7404 char mountpoint[] = "/";
7407 r = guestfs_mount (g, device, mountpoint);
7411 /* TestOutputTrue for mkdir_p (1) */
7413 char path[] = "/new/foo/bar";
7416 r = guestfs_mkdir_p (g, path);
7421 char path[] = "/new/foo";
7424 r = guestfs_is_dir (g, path);
7428 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
7435 static int test_mkdir_p_2 (void)
7437 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
7439 char device[] = "/dev/sda";
7440 device[5] = devchar;
7443 r = guestfs_blockdev_setrw (g, device);
7450 r = guestfs_umount_all (g);
7457 r = guestfs_lvm_remove_all (g);
7462 char device[] = "/dev/sda";
7463 device[5] = devchar;
7464 char lines_0[] = ",";
7471 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7476 char fstype[] = "ext2";
7477 char device[] = "/dev/sda1";
7478 device[5] = devchar;
7481 r = guestfs_mkfs (g, fstype, device);
7486 char device[] = "/dev/sda1";
7487 device[5] = devchar;
7488 char mountpoint[] = "/";
7491 r = guestfs_mount (g, device, mountpoint);
7495 /* TestOutputTrue for mkdir_p (2) */
7497 char path[] = "/new/foo/bar";
7500 r = guestfs_mkdir_p (g, path);
7505 char path[] = "/new";
7508 r = guestfs_is_dir (g, path);
7512 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
7519 static int test_mkdir_0 (void)
7521 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
7523 char device[] = "/dev/sda";
7524 device[5] = devchar;
7527 r = guestfs_blockdev_setrw (g, device);
7534 r = guestfs_umount_all (g);
7541 r = guestfs_lvm_remove_all (g);
7546 char device[] = "/dev/sda";
7547 device[5] = devchar;
7548 char lines_0[] = ",";
7555 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7560 char fstype[] = "ext2";
7561 char device[] = "/dev/sda1";
7562 device[5] = devchar;
7565 r = guestfs_mkfs (g, fstype, device);
7570 char device[] = "/dev/sda1";
7571 device[5] = devchar;
7572 char mountpoint[] = "/";
7575 r = guestfs_mount (g, device, mountpoint);
7579 /* TestOutputTrue for mkdir (0) */
7581 char path[] = "/new";
7584 r = guestfs_mkdir (g, path);
7589 char path[] = "/new";
7592 r = guestfs_is_dir (g, path);
7596 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
7603 static int test_mkdir_1 (void)
7605 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
7607 char device[] = "/dev/sda";
7608 device[5] = devchar;
7611 r = guestfs_blockdev_setrw (g, device);
7618 r = guestfs_umount_all (g);
7625 r = guestfs_lvm_remove_all (g);
7630 char device[] = "/dev/sda";
7631 device[5] = devchar;
7632 char lines_0[] = ",";
7639 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7644 char fstype[] = "ext2";
7645 char device[] = "/dev/sda1";
7646 device[5] = devchar;
7649 r = guestfs_mkfs (g, fstype, device);
7654 char device[] = "/dev/sda1";
7655 device[5] = devchar;
7656 char mountpoint[] = "/";
7659 r = guestfs_mount (g, device, mountpoint);
7663 /* TestLastFail for mkdir (1) */
7665 char path[] = "/new/foo/bar";
7668 r = guestfs_mkdir (g, path);
7675 static int test_rm_rf_0 (void)
7677 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
7679 char device[] = "/dev/sda";
7680 device[5] = devchar;
7683 r = guestfs_blockdev_setrw (g, device);
7690 r = guestfs_umount_all (g);
7697 r = guestfs_lvm_remove_all (g);
7702 char device[] = "/dev/sda";
7703 device[5] = devchar;
7704 char lines_0[] = ",";
7711 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7716 char fstype[] = "ext2";
7717 char device[] = "/dev/sda1";
7718 device[5] = devchar;
7721 r = guestfs_mkfs (g, fstype, device);
7726 char device[] = "/dev/sda1";
7727 device[5] = devchar;
7728 char mountpoint[] = "/";
7731 r = guestfs_mount (g, device, mountpoint);
7735 /* TestOutputFalse for rm_rf (0) */
7737 char path[] = "/new";
7740 r = guestfs_mkdir (g, path);
7745 char path[] = "/new/foo";
7748 r = guestfs_mkdir (g, path);
7753 char path[] = "/new/foo/bar";
7756 r = guestfs_touch (g, path);
7761 char path[] = "/new";
7764 r = guestfs_rm_rf (g, path);
7769 char path[] = "/new";
7772 r = guestfs_exists (g, path);
7776 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
7783 static int test_rmdir_0 (void)
7785 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
7787 char device[] = "/dev/sda";
7788 device[5] = devchar;
7791 r = guestfs_blockdev_setrw (g, device);
7798 r = guestfs_umount_all (g);
7805 r = guestfs_lvm_remove_all (g);
7810 char device[] = "/dev/sda";
7811 device[5] = devchar;
7812 char lines_0[] = ",";
7819 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7824 char fstype[] = "ext2";
7825 char device[] = "/dev/sda1";
7826 device[5] = devchar;
7829 r = guestfs_mkfs (g, fstype, device);
7834 char device[] = "/dev/sda1";
7835 device[5] = devchar;
7836 char mountpoint[] = "/";
7839 r = guestfs_mount (g, device, mountpoint);
7843 /* TestRun for rmdir (0) */
7845 char path[] = "/new";
7848 r = guestfs_mkdir (g, path);
7853 char path[] = "/new";
7856 r = guestfs_rmdir (g, path);
7863 static int test_rmdir_1 (void)
7865 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
7867 char device[] = "/dev/sda";
7868 device[5] = devchar;
7871 r = guestfs_blockdev_setrw (g, device);
7878 r = guestfs_umount_all (g);
7885 r = guestfs_lvm_remove_all (g);
7890 char device[] = "/dev/sda";
7891 device[5] = devchar;
7892 char lines_0[] = ",";
7899 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7904 char fstype[] = "ext2";
7905 char device[] = "/dev/sda1";
7906 device[5] = devchar;
7909 r = guestfs_mkfs (g, fstype, device);
7914 char device[] = "/dev/sda1";
7915 device[5] = devchar;
7916 char mountpoint[] = "/";
7919 r = guestfs_mount (g, device, mountpoint);
7923 /* TestLastFail for rmdir (1) */
7925 char path[] = "/new";
7928 r = guestfs_rmdir (g, path);
7935 static int test_rmdir_2 (void)
7937 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
7939 char device[] = "/dev/sda";
7940 device[5] = devchar;
7943 r = guestfs_blockdev_setrw (g, device);
7950 r = guestfs_umount_all (g);
7957 r = guestfs_lvm_remove_all (g);
7962 char device[] = "/dev/sda";
7963 device[5] = devchar;
7964 char lines_0[] = ",";
7971 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7976 char fstype[] = "ext2";
7977 char device[] = "/dev/sda1";
7978 device[5] = devchar;
7981 r = guestfs_mkfs (g, fstype, device);
7986 char device[] = "/dev/sda1";
7987 device[5] = devchar;
7988 char mountpoint[] = "/";
7991 r = guestfs_mount (g, device, mountpoint);
7995 /* TestLastFail for rmdir (2) */
7997 char path[] = "/new";
8000 r = guestfs_touch (g, path);
8005 char path[] = "/new";
8008 r = guestfs_rmdir (g, path);
8015 static int test_rm_0 (void)
8017 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
8019 char device[] = "/dev/sda";
8020 device[5] = devchar;
8023 r = guestfs_blockdev_setrw (g, device);
8030 r = guestfs_umount_all (g);
8037 r = guestfs_lvm_remove_all (g);
8042 char device[] = "/dev/sda";
8043 device[5] = devchar;
8044 char lines_0[] = ",";
8051 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8056 char fstype[] = "ext2";
8057 char device[] = "/dev/sda1";
8058 device[5] = devchar;
8061 r = guestfs_mkfs (g, fstype, device);
8066 char device[] = "/dev/sda1";
8067 device[5] = devchar;
8068 char mountpoint[] = "/";
8071 r = guestfs_mount (g, device, mountpoint);
8075 /* TestRun for rm (0) */
8077 char path[] = "/new";
8080 r = guestfs_touch (g, path);
8085 char path[] = "/new";
8088 r = guestfs_rm (g, path);
8095 static int test_rm_1 (void)
8097 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
8099 char device[] = "/dev/sda";
8100 device[5] = devchar;
8103 r = guestfs_blockdev_setrw (g, device);
8110 r = guestfs_umount_all (g);
8117 r = guestfs_lvm_remove_all (g);
8122 char device[] = "/dev/sda";
8123 device[5] = devchar;
8124 char lines_0[] = ",";
8131 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8136 char fstype[] = "ext2";
8137 char device[] = "/dev/sda1";
8138 device[5] = devchar;
8141 r = guestfs_mkfs (g, fstype, device);
8146 char device[] = "/dev/sda1";
8147 device[5] = devchar;
8148 char mountpoint[] = "/";
8151 r = guestfs_mount (g, device, mountpoint);
8155 /* TestLastFail for rm (1) */
8157 char path[] = "/new";
8160 r = guestfs_rm (g, path);
8167 static int test_rm_2 (void)
8169 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
8171 char device[] = "/dev/sda";
8172 device[5] = devchar;
8175 r = guestfs_blockdev_setrw (g, device);
8182 r = guestfs_umount_all (g);
8189 r = guestfs_lvm_remove_all (g);
8194 char device[] = "/dev/sda";
8195 device[5] = devchar;
8196 char lines_0[] = ",";
8203 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8208 char fstype[] = "ext2";
8209 char device[] = "/dev/sda1";
8210 device[5] = devchar;
8213 r = guestfs_mkfs (g, fstype, device);
8218 char device[] = "/dev/sda1";
8219 device[5] = devchar;
8220 char mountpoint[] = "/";
8223 r = guestfs_mount (g, device, mountpoint);
8227 /* TestLastFail for rm (2) */
8229 char path[] = "/new";
8232 r = guestfs_mkdir (g, path);
8237 char path[] = "/new";
8240 r = guestfs_rm (g, path);
8247 static int test_read_lines_0 (void)
8249 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
8251 char device[] = "/dev/sda";
8252 device[5] = devchar;
8255 r = guestfs_blockdev_setrw (g, device);
8262 r = guestfs_umount_all (g);
8269 r = guestfs_lvm_remove_all (g);
8274 char device[] = "/dev/sda";
8275 device[5] = devchar;
8276 char lines_0[] = ",";
8283 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8288 char fstype[] = "ext2";
8289 char device[] = "/dev/sda1";
8290 device[5] = devchar;
8293 r = guestfs_mkfs (g, fstype, device);
8298 char device[] = "/dev/sda1";
8299 device[5] = devchar;
8300 char mountpoint[] = "/";
8303 r = guestfs_mount (g, device, mountpoint);
8307 /* TestOutputList for read_lines (0) */
8309 char path[] = "/new";
8310 char content[] = "line1\r\nline2\nline3";
8313 r = guestfs_write_file (g, path, content, 0);
8318 char path[] = "/new";
8322 r = guestfs_read_lines (g, path);
8326 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8331 char expected[] = "line1";
8332 if (strcmp (r[0], expected) != 0) {
8333 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8338 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8343 char expected[] = "line2";
8344 if (strcmp (r[1], expected) != 0) {
8345 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8350 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8355 char expected[] = "line3";
8356 if (strcmp (r[2], expected) != 0) {
8357 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8362 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
8366 for (i = 0; r[i] != NULL; ++i)
8373 static int test_read_lines_1 (void)
8375 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
8377 char device[] = "/dev/sda";
8378 device[5] = devchar;
8381 r = guestfs_blockdev_setrw (g, device);
8388 r = guestfs_umount_all (g);
8395 r = guestfs_lvm_remove_all (g);
8400 char device[] = "/dev/sda";
8401 device[5] = devchar;
8402 char lines_0[] = ",";
8409 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8414 char fstype[] = "ext2";
8415 char device[] = "/dev/sda1";
8416 device[5] = devchar;
8419 r = guestfs_mkfs (g, fstype, device);
8424 char device[] = "/dev/sda1";
8425 device[5] = devchar;
8426 char mountpoint[] = "/";
8429 r = guestfs_mount (g, device, mountpoint);
8433 /* TestOutputList for read_lines (1) */
8435 char path[] = "/new";
8436 char content[] = "";
8439 r = guestfs_write_file (g, path, content, 0);
8444 char path[] = "/new";
8448 r = guestfs_read_lines (g, path);
8452 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
8456 for (i = 0; r[i] != NULL; ++i)
8463 static int test_lvs_0 (void)
8465 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
8467 char device[] = "/dev/sda";
8468 device[5] = devchar;
8471 r = guestfs_blockdev_setrw (g, device);
8478 r = guestfs_umount_all (g);
8485 r = guestfs_lvm_remove_all (g);
8490 char device[] = "/dev/sda";
8491 device[5] = devchar;
8492 char lines_0[] = ",";
8499 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8504 char device[] = "/dev/sda1";
8505 device[5] = devchar;
8508 r = guestfs_pvcreate (g, device);
8513 char volgroup[] = "VG";
8514 char physvols_0[] = "/dev/sda1";
8515 physvols_0[5] = devchar;
8516 char *physvols[] = {
8522 r = guestfs_vgcreate (g, volgroup, physvols);
8527 char logvol[] = "LV";
8528 char volgroup[] = "VG";
8531 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8536 char fstype[] = "ext2";
8537 char device[] = "/dev/VG/LV";
8540 r = guestfs_mkfs (g, fstype, device);
8545 char device[] = "/dev/VG/LV";
8546 char mountpoint[] = "/";
8549 r = guestfs_mount (g, device, mountpoint);
8553 /* TestOutputList for lvs (0) */
8558 r = guestfs_lvs (g);
8562 fprintf (stderr, "test_lvs_0: short list returned from command\n");
8567 char expected[] = "/dev/VG/LV";
8568 if (strcmp (r[0], expected) != 0) {
8569 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8574 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
8578 for (i = 0; r[i] != NULL; ++i)
8585 static int test_lvs_1 (void)
8587 /* InitEmpty for lvs (1) */
8589 char device[] = "/dev/sda";
8590 device[5] = devchar;
8593 r = guestfs_blockdev_setrw (g, device);
8600 r = guestfs_umount_all (g);
8607 r = guestfs_lvm_remove_all (g);
8611 /* TestOutputList for lvs (1) */
8613 char device[] = "/dev/sda";
8614 device[5] = devchar;
8615 char lines_0[] = ",10";
8616 char lines_1[] = ",20";
8617 char lines_2[] = ",";
8626 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8631 char device[] = "/dev/sda1";
8632 device[5] = devchar;
8635 r = guestfs_pvcreate (g, device);
8640 char device[] = "/dev/sda2";
8641 device[5] = devchar;
8644 r = guestfs_pvcreate (g, device);
8649 char device[] = "/dev/sda3";
8650 device[5] = devchar;
8653 r = guestfs_pvcreate (g, device);
8658 char volgroup[] = "VG1";
8659 char physvols_0[] = "/dev/sda1";
8660 physvols_0[5] = devchar;
8661 char physvols_1[] = "/dev/sda2";
8662 physvols_1[5] = devchar;
8663 char *physvols[] = {
8670 r = guestfs_vgcreate (g, volgroup, physvols);
8675 char volgroup[] = "VG2";
8676 char physvols_0[] = "/dev/sda3";
8677 physvols_0[5] = devchar;
8678 char *physvols[] = {
8684 r = guestfs_vgcreate (g, volgroup, physvols);
8689 char logvol[] = "LV1";
8690 char volgroup[] = "VG1";
8693 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8698 char logvol[] = "LV2";
8699 char volgroup[] = "VG1";
8702 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8707 char logvol[] = "LV3";
8708 char volgroup[] = "VG2";
8711 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8719 r = guestfs_lvs (g);
8723 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8728 char expected[] = "/dev/VG1/LV1";
8729 if (strcmp (r[0], expected) != 0) {
8730 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8735 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8740 char expected[] = "/dev/VG1/LV2";
8741 if (strcmp (r[1], expected) != 0) {
8742 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8747 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8752 char expected[] = "/dev/VG2/LV3";
8753 if (strcmp (r[2], expected) != 0) {
8754 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8759 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
8763 for (i = 0; r[i] != NULL; ++i)
8770 static int test_vgs_0 (void)
8772 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
8774 char device[] = "/dev/sda";
8775 device[5] = devchar;
8778 r = guestfs_blockdev_setrw (g, device);
8785 r = guestfs_umount_all (g);
8792 r = guestfs_lvm_remove_all (g);
8797 char device[] = "/dev/sda";
8798 device[5] = devchar;
8799 char lines_0[] = ",";
8806 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8811 char device[] = "/dev/sda1";
8812 device[5] = devchar;
8815 r = guestfs_pvcreate (g, device);
8820 char volgroup[] = "VG";
8821 char physvols_0[] = "/dev/sda1";
8822 physvols_0[5] = devchar;
8823 char *physvols[] = {
8829 r = guestfs_vgcreate (g, volgroup, physvols);
8834 char logvol[] = "LV";
8835 char volgroup[] = "VG";
8838 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8843 char fstype[] = "ext2";
8844 char device[] = "/dev/VG/LV";
8847 r = guestfs_mkfs (g, fstype, device);
8852 char device[] = "/dev/VG/LV";
8853 char mountpoint[] = "/";
8856 r = guestfs_mount (g, device, mountpoint);
8860 /* TestOutputList for vgs (0) */
8865 r = guestfs_vgs (g);
8869 fprintf (stderr, "test_vgs_0: short list returned from command\n");
8874 char expected[] = "VG";
8875 if (strcmp (r[0], expected) != 0) {
8876 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8881 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
8885 for (i = 0; r[i] != NULL; ++i)
8892 static int test_vgs_1 (void)
8894 /* InitEmpty for vgs (1) */
8896 char device[] = "/dev/sda";
8897 device[5] = devchar;
8900 r = guestfs_blockdev_setrw (g, device);
8907 r = guestfs_umount_all (g);
8914 r = guestfs_lvm_remove_all (g);
8918 /* TestOutputList for vgs (1) */
8920 char device[] = "/dev/sda";
8921 device[5] = devchar;
8922 char lines_0[] = ",10";
8923 char lines_1[] = ",20";
8924 char lines_2[] = ",";
8933 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8938 char device[] = "/dev/sda1";
8939 device[5] = devchar;
8942 r = guestfs_pvcreate (g, device);
8947 char device[] = "/dev/sda2";
8948 device[5] = devchar;
8951 r = guestfs_pvcreate (g, device);
8956 char device[] = "/dev/sda3";
8957 device[5] = devchar;
8960 r = guestfs_pvcreate (g, device);
8965 char volgroup[] = "VG1";
8966 char physvols_0[] = "/dev/sda1";
8967 physvols_0[5] = devchar;
8968 char physvols_1[] = "/dev/sda2";
8969 physvols_1[5] = devchar;
8970 char *physvols[] = {
8977 r = guestfs_vgcreate (g, volgroup, physvols);
8982 char volgroup[] = "VG2";
8983 char physvols_0[] = "/dev/sda3";
8984 physvols_0[5] = devchar;
8985 char *physvols[] = {
8991 r = guestfs_vgcreate (g, volgroup, physvols);
8999 r = guestfs_vgs (g);
9003 fprintf (stderr, "test_vgs_1: short list returned from command\n");
9008 char expected[] = "VG1";
9009 if (strcmp (r[0], expected) != 0) {
9010 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9015 fprintf (stderr, "test_vgs_1: short list returned from command\n");
9020 char expected[] = "VG2";
9021 if (strcmp (r[1], expected) != 0) {
9022 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9027 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
9031 for (i = 0; r[i] != NULL; ++i)
9038 static int test_pvs_0 (void)
9040 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
9042 char device[] = "/dev/sda";
9043 device[5] = devchar;
9046 r = guestfs_blockdev_setrw (g, device);
9053 r = guestfs_umount_all (g);
9060 r = guestfs_lvm_remove_all (g);
9065 char device[] = "/dev/sda";
9066 device[5] = devchar;
9067 char lines_0[] = ",";
9074 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9079 char device[] = "/dev/sda1";
9080 device[5] = devchar;
9083 r = guestfs_pvcreate (g, device);
9088 char volgroup[] = "VG";
9089 char physvols_0[] = "/dev/sda1";
9090 physvols_0[5] = devchar;
9091 char *physvols[] = {
9097 r = guestfs_vgcreate (g, volgroup, physvols);
9102 char logvol[] = "LV";
9103 char volgroup[] = "VG";
9106 r = guestfs_lvcreate (g, logvol, volgroup, 8);
9111 char fstype[] = "ext2";
9112 char device[] = "/dev/VG/LV";
9115 r = guestfs_mkfs (g, fstype, device);
9120 char device[] = "/dev/VG/LV";
9121 char mountpoint[] = "/";
9124 r = guestfs_mount (g, device, mountpoint);
9128 /* TestOutputList for pvs (0) */
9133 r = guestfs_pvs (g);
9137 fprintf (stderr, "test_pvs_0: short list returned from command\n");
9142 char expected[] = "/dev/sda1";
9143 expected[5] = devchar;
9144 if (strcmp (r[0], expected) != 0) {
9145 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9150 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
9154 for (i = 0; r[i] != NULL; ++i)
9161 static int test_pvs_1 (void)
9163 /* InitEmpty for pvs (1) */
9165 char device[] = "/dev/sda";
9166 device[5] = devchar;
9169 r = guestfs_blockdev_setrw (g, device);
9176 r = guestfs_umount_all (g);
9183 r = guestfs_lvm_remove_all (g);
9187 /* TestOutputList for pvs (1) */
9189 char device[] = "/dev/sda";
9190 device[5] = devchar;
9191 char lines_0[] = ",10";
9192 char lines_1[] = ",20";
9193 char lines_2[] = ",";
9202 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9207 char device[] = "/dev/sda1";
9208 device[5] = devchar;
9211 r = guestfs_pvcreate (g, device);
9216 char device[] = "/dev/sda2";
9217 device[5] = devchar;
9220 r = guestfs_pvcreate (g, device);
9225 char device[] = "/dev/sda3";
9226 device[5] = devchar;
9229 r = guestfs_pvcreate (g, device);
9237 r = guestfs_pvs (g);
9241 fprintf (stderr, "test_pvs_1: short list returned from command\n");
9246 char expected[] = "/dev/sda1";
9247 expected[5] = devchar;
9248 if (strcmp (r[0], expected) != 0) {
9249 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9254 fprintf (stderr, "test_pvs_1: short list returned from command\n");
9259 char expected[] = "/dev/sda2";
9260 expected[5] = devchar;
9261 if (strcmp (r[1], expected) != 0) {
9262 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9267 fprintf (stderr, "test_pvs_1: short list returned from command\n");
9272 char expected[] = "/dev/sda3";
9273 expected[5] = devchar;
9274 if (strcmp (r[2], expected) != 0) {
9275 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9280 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
9284 for (i = 0; r[i] != NULL; ++i)
9291 static int test_list_partitions_0 (void)
9293 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
9295 char device[] = "/dev/sda";
9296 device[5] = devchar;
9299 r = guestfs_blockdev_setrw (g, device);
9306 r = guestfs_umount_all (g);
9313 r = guestfs_lvm_remove_all (g);
9318 char device[] = "/dev/sda";
9319 device[5] = devchar;
9320 char lines_0[] = ",";
9327 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9332 char fstype[] = "ext2";
9333 char device[] = "/dev/sda1";
9334 device[5] = devchar;
9337 r = guestfs_mkfs (g, fstype, device);
9342 char device[] = "/dev/sda1";
9343 device[5] = devchar;
9344 char mountpoint[] = "/";
9347 r = guestfs_mount (g, device, mountpoint);
9351 /* TestOutputList for list_partitions (0) */
9356 r = guestfs_list_partitions (g);
9360 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
9365 char expected[] = "/dev/sda1";
9366 expected[5] = devchar;
9367 if (strcmp (r[0], expected) != 0) {
9368 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9373 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
9377 for (i = 0; r[i] != NULL; ++i)
9384 static int test_list_partitions_1 (void)
9386 /* InitEmpty for list_partitions (1) */
9388 char device[] = "/dev/sda";
9389 device[5] = devchar;
9392 r = guestfs_blockdev_setrw (g, device);
9399 r = guestfs_umount_all (g);
9406 r = guestfs_lvm_remove_all (g);
9410 /* TestOutputList for list_partitions (1) */
9412 char device[] = "/dev/sda";
9413 device[5] = devchar;
9414 char lines_0[] = ",10";
9415 char lines_1[] = ",20";
9416 char lines_2[] = ",";
9425 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9433 r = guestfs_list_partitions (g);
9437 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9442 char expected[] = "/dev/sda1";
9443 expected[5] = devchar;
9444 if (strcmp (r[0], expected) != 0) {
9445 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9450 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9455 char expected[] = "/dev/sda2";
9456 expected[5] = devchar;
9457 if (strcmp (r[1], expected) != 0) {
9458 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9463 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9468 char expected[] = "/dev/sda3";
9469 expected[5] = devchar;
9470 if (strcmp (r[2], expected) != 0) {
9471 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9476 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
9480 for (i = 0; r[i] != NULL; ++i)
9487 static int test_list_devices_0 (void)
9489 /* InitEmpty for list_devices (0) */
9491 char device[] = "/dev/sda";
9492 device[5] = devchar;
9495 r = guestfs_blockdev_setrw (g, device);
9502 r = guestfs_umount_all (g);
9509 r = guestfs_lvm_remove_all (g);
9513 /* TestOutputList for list_devices (0) */
9518 r = guestfs_list_devices (g);
9522 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9527 char expected[] = "/dev/sda";
9528 expected[5] = devchar;
9529 if (strcmp (r[0], expected) != 0) {
9530 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9535 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9540 char expected[] = "/dev/sdb";
9541 expected[5] = devchar;
9542 if (strcmp (r[1], expected) != 0) {
9543 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9548 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9553 char expected[] = "/dev/sdc";
9554 expected[5] = devchar;
9555 if (strcmp (r[2], expected) != 0) {
9556 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9561 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
9565 for (i = 0; r[i] != NULL; ++i)
9572 static int test_ls_0 (void)
9574 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
9576 char device[] = "/dev/sda";
9577 device[5] = devchar;
9580 r = guestfs_blockdev_setrw (g, device);
9587 r = guestfs_umount_all (g);
9594 r = guestfs_lvm_remove_all (g);
9599 char device[] = "/dev/sda";
9600 device[5] = devchar;
9601 char lines_0[] = ",";
9608 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9613 char fstype[] = "ext2";
9614 char device[] = "/dev/sda1";
9615 device[5] = devchar;
9618 r = guestfs_mkfs (g, fstype, device);
9623 char device[] = "/dev/sda1";
9624 device[5] = devchar;
9625 char mountpoint[] = "/";
9628 r = guestfs_mount (g, device, mountpoint);
9632 /* TestOutputList for ls (0) */
9634 char path[] = "/new";
9637 r = guestfs_touch (g, path);
9642 char path[] = "/newer";
9645 r = guestfs_touch (g, path);
9650 char path[] = "/newest";
9653 r = guestfs_touch (g, path);
9658 char directory[] = "/";
9662 r = guestfs_ls (g, directory);
9666 fprintf (stderr, "test_ls_0: short list returned from command\n");
9671 char expected[] = "lost+found";
9672 if (strcmp (r[0], expected) != 0) {
9673 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9678 fprintf (stderr, "test_ls_0: short list returned from command\n");
9683 char expected[] = "new";
9684 if (strcmp (r[1], expected) != 0) {
9685 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9690 fprintf (stderr, "test_ls_0: short list returned from command\n");
9695 char expected[] = "newer";
9696 if (strcmp (r[2], expected) != 0) {
9697 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9702 fprintf (stderr, "test_ls_0: short list returned from command\n");
9707 char expected[] = "newest";
9708 if (strcmp (r[3], expected) != 0) {
9709 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
9714 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
9718 for (i = 0; r[i] != NULL; ++i)
9725 static int test_cat_0 (void)
9727 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
9729 char device[] = "/dev/sda";
9730 device[5] = devchar;
9733 r = guestfs_blockdev_setrw (g, device);
9740 r = guestfs_umount_all (g);
9747 r = guestfs_lvm_remove_all (g);
9752 char device[] = "/dev/sda";
9753 device[5] = devchar;
9754 char lines_0[] = ",";
9761 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9766 char fstype[] = "ext2";
9767 char device[] = "/dev/sda1";
9768 device[5] = devchar;
9771 r = guestfs_mkfs (g, fstype, device);
9776 char device[] = "/dev/sda1";
9777 device[5] = devchar;
9778 char mountpoint[] = "/";
9781 r = guestfs_mount (g, device, mountpoint);
9785 /* TestOutput for cat (0) */
9786 char expected[] = "new file contents";
9788 char path[] = "/new";
9789 char content[] = "new file contents";
9792 r = guestfs_write_file (g, path, content, 0);
9797 char path[] = "/new";
9800 r = guestfs_cat (g, path);
9803 if (strcmp (r, expected) != 0) {
9804 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
9812 static int test_touch_0 (void)
9814 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
9816 char device[] = "/dev/sda";
9817 device[5] = devchar;
9820 r = guestfs_blockdev_setrw (g, device);
9827 r = guestfs_umount_all (g);
9834 r = guestfs_lvm_remove_all (g);
9839 char device[] = "/dev/sda";
9840 device[5] = devchar;
9841 char lines_0[] = ",";
9848 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9853 char fstype[] = "ext2";
9854 char device[] = "/dev/sda1";
9855 device[5] = devchar;
9858 r = guestfs_mkfs (g, fstype, device);
9863 char device[] = "/dev/sda1";
9864 device[5] = devchar;
9865 char mountpoint[] = "/";
9868 r = guestfs_mount (g, device, mountpoint);
9872 /* TestOutputTrue for touch (0) */
9874 char path[] = "/new";
9877 r = guestfs_touch (g, path);
9882 char path[] = "/new";
9885 r = guestfs_exists (g, path);
9889 fprintf (stderr, "test_touch_0: expected true, got false\n");
9896 static int test_sync_0 (void)
9898 /* InitEmpty for sync (0) */
9900 char device[] = "/dev/sda";
9901 device[5] = devchar;
9904 r = guestfs_blockdev_setrw (g, device);
9911 r = guestfs_umount_all (g);
9918 r = guestfs_lvm_remove_all (g);
9922 /* TestRun for sync (0) */
9926 r = guestfs_sync (g);
9933 static int test_mount_0 (void)
9935 /* InitEmpty for mount (0) */
9937 char device[] = "/dev/sda";
9938 device[5] = devchar;
9941 r = guestfs_blockdev_setrw (g, device);
9948 r = guestfs_umount_all (g);
9955 r = guestfs_lvm_remove_all (g);
9959 /* TestOutput for mount (0) */
9960 char expected[] = "new file contents";
9962 char device[] = "/dev/sda";
9963 device[5] = devchar;
9964 char lines_0[] = ",";
9971 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9976 char fstype[] = "ext2";
9977 char device[] = "/dev/sda1";
9978 device[5] = devchar;
9981 r = guestfs_mkfs (g, fstype, device);
9986 char device[] = "/dev/sda1";
9987 device[5] = devchar;
9988 char mountpoint[] = "/";
9991 r = guestfs_mount (g, device, mountpoint);
9996 char path[] = "/new";
9997 char content[] = "new file contents";
10000 r = guestfs_write_file (g, path, content, 0);
10005 char path[] = "/new";
10007 suppress_error = 0;
10008 r = guestfs_cat (g, path);
10011 if (strcmp (r, expected) != 0) {
10012 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
10020 int main (int argc, char *argv[])
10024 const char *srcdir;
10025 const char *filename;
10027 int nr_tests, test_num = 0;
10030 no_test_warnings ();
10032 g = guestfs_create ();
10034 printf ("guestfs_create FAILED\n");
10038 guestfs_set_error_handler (g, print_error, NULL);
10040 srcdir = getenv ("srcdir");
10041 if (!srcdir) srcdir = ".";
10043 guestfs_set_path (g, ".");
10045 filename = "test1.img";
10046 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10051 if (lseek (fd, 524288000, SEEK_SET) == -1) {
10057 if (write (fd, &c, 1) == -1) {
10063 if (close (fd) == -1) {
10068 if (guestfs_add_drive (g, filename) == -1) {
10069 printf ("guestfs_add_drive %s FAILED\n", filename);
10073 filename = "test2.img";
10074 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10079 if (lseek (fd, 52428800, SEEK_SET) == -1) {
10085 if (write (fd, &c, 1) == -1) {
10091 if (close (fd) == -1) {
10096 if (guestfs_add_drive (g, filename) == -1) {
10097 printf ("guestfs_add_drive %s FAILED\n", filename);
10101 filename = "test3.img";
10102 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10107 if (lseek (fd, 10485760, SEEK_SET) == -1) {
10113 if (write (fd, &c, 1) == -1) {
10119 if (close (fd) == -1) {
10124 if (guestfs_add_drive (g, filename) == -1) {
10125 printf ("guestfs_add_drive %s FAILED\n", filename);
10129 if (guestfs_launch (g) == -1) {
10130 printf ("guestfs_launch FAILED\n");
10133 if (guestfs_wait_ready (g) == -1) {
10134 printf ("guestfs_wait_ready FAILED\n");
10138 /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
10139 * names. This changed between RHEL 5 and RHEL 6 so we have to
10142 devs = guestfs_list_devices (g);
10143 if (devs == NULL || devs[0] == NULL) {
10144 printf ("guestfs_list_devices FAILED\n");
10147 if (strncmp (devs[0], "/dev/sd", 7) == 0)
10149 else if (strncmp (devs[0], "/dev/hd", 7) == 0)
10152 printf ("guestfs_list_devices returned unexpected string '%s'\n",
10156 for (i = 0; devs[i] != NULL; ++i)
10163 printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
10164 if (test_hexdump_0 () == -1) {
10165 printf ("test_hexdump_0 FAILED\n");
10169 printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
10170 if (test_strings_e_0 () == -1) {
10171 printf ("test_strings_e_0 FAILED\n");
10175 printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
10176 if (test_strings_0 () == -1) {
10177 printf ("test_strings_0 FAILED\n");
10181 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
10182 if (test_equal_0 () == -1) {
10183 printf ("test_equal_0 FAILED\n");
10187 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
10188 if (test_equal_1 () == -1) {
10189 printf ("test_equal_1 FAILED\n");
10193 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
10194 if (test_equal_2 () == -1) {
10195 printf ("test_equal_2 FAILED\n");
10199 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
10200 if (test_ping_daemon_0 () == -1) {
10201 printf ("test_ping_daemon_0 FAILED\n");
10205 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
10206 if (test_dmesg_0 () == -1) {
10207 printf ("test_dmesg_0 FAILED\n");
10211 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
10212 if (test_drop_caches_0 () == -1) {
10213 printf ("test_drop_caches_0 FAILED\n");
10217 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
10218 if (test_mv_0 () == -1) {
10219 printf ("test_mv_0 FAILED\n");
10223 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
10224 if (test_mv_1 () == -1) {
10225 printf ("test_mv_1 FAILED\n");
10229 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
10230 if (test_cp_a_0 () == -1) {
10231 printf ("test_cp_a_0 FAILED\n");
10235 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
10236 if (test_cp_0 () == -1) {
10237 printf ("test_cp_0 FAILED\n");
10241 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
10242 if (test_cp_1 () == -1) {
10243 printf ("test_cp_1 FAILED\n");
10247 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
10248 if (test_cp_2 () == -1) {
10249 printf ("test_cp_2 FAILED\n");
10253 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
10254 if (test_grub_install_0 () == -1) {
10255 printf ("test_grub_install_0 FAILED\n");
10259 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
10260 if (test_zero_0 () == -1) {
10261 printf ("test_zero_0 FAILED\n");
10265 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
10266 if (test_fsck_0 () == -1) {
10267 printf ("test_fsck_0 FAILED\n");
10271 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
10272 if (test_fsck_1 () == -1) {
10273 printf ("test_fsck_1 FAILED\n");
10277 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
10278 if (test_set_e2uuid_0 () == -1) {
10279 printf ("test_set_e2uuid_0 FAILED\n");
10283 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
10284 if (test_set_e2uuid_1 () == -1) {
10285 printf ("test_set_e2uuid_1 FAILED\n");
10289 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
10290 if (test_set_e2uuid_2 () == -1) {
10291 printf ("test_set_e2uuid_2 FAILED\n");
10295 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
10296 if (test_set_e2uuid_3 () == -1) {
10297 printf ("test_set_e2uuid_3 FAILED\n");
10301 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
10302 if (test_set_e2label_0 () == -1) {
10303 printf ("test_set_e2label_0 FAILED\n");
10307 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
10308 if (test_pvremove_0 () == -1) {
10309 printf ("test_pvremove_0 FAILED\n");
10313 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
10314 if (test_pvremove_1 () == -1) {
10315 printf ("test_pvremove_1 FAILED\n");
10319 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
10320 if (test_pvremove_2 () == -1) {
10321 printf ("test_pvremove_2 FAILED\n");
10325 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
10326 if (test_vgremove_0 () == -1) {
10327 printf ("test_vgremove_0 FAILED\n");
10331 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
10332 if (test_vgremove_1 () == -1) {
10333 printf ("test_vgremove_1 FAILED\n");
10337 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
10338 if (test_lvremove_0 () == -1) {
10339 printf ("test_lvremove_0 FAILED\n");
10343 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
10344 if (test_lvremove_1 () == -1) {
10345 printf ("test_lvremove_1 FAILED\n");
10349 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
10350 if (test_lvremove_2 () == -1) {
10351 printf ("test_lvremove_2 FAILED\n");
10355 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
10356 if (test_mount_ro_0 () == -1) {
10357 printf ("test_mount_ro_0 FAILED\n");
10361 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
10362 if (test_mount_ro_1 () == -1) {
10363 printf ("test_mount_ro_1 FAILED\n");
10367 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
10368 if (test_tgz_in_0 () == -1) {
10369 printf ("test_tgz_in_0 FAILED\n");
10373 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
10374 if (test_tar_in_0 () == -1) {
10375 printf ("test_tar_in_0 FAILED\n");
10379 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
10380 if (test_checksum_0 () == -1) {
10381 printf ("test_checksum_0 FAILED\n");
10385 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
10386 if (test_checksum_1 () == -1) {
10387 printf ("test_checksum_1 FAILED\n");
10391 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
10392 if (test_checksum_2 () == -1) {
10393 printf ("test_checksum_2 FAILED\n");
10397 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
10398 if (test_checksum_3 () == -1) {
10399 printf ("test_checksum_3 FAILED\n");
10403 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
10404 if (test_checksum_4 () == -1) {
10405 printf ("test_checksum_4 FAILED\n");
10409 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
10410 if (test_checksum_5 () == -1) {
10411 printf ("test_checksum_5 FAILED\n");
10415 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
10416 if (test_checksum_6 () == -1) {
10417 printf ("test_checksum_6 FAILED\n");
10421 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
10422 if (test_checksum_7 () == -1) {
10423 printf ("test_checksum_7 FAILED\n");
10427 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
10428 if (test_download_0 () == -1) {
10429 printf ("test_download_0 FAILED\n");
10433 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
10434 if (test_upload_0 () == -1) {
10435 printf ("test_upload_0 FAILED\n");
10439 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
10440 if (test_blockdev_rereadpt_0 () == -1) {
10441 printf ("test_blockdev_rereadpt_0 FAILED\n");
10445 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
10446 if (test_blockdev_flushbufs_0 () == -1) {
10447 printf ("test_blockdev_flushbufs_0 FAILED\n");
10451 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
10452 if (test_blockdev_getsize64_0 () == -1) {
10453 printf ("test_blockdev_getsize64_0 FAILED\n");
10457 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
10458 if (test_blockdev_getsz_0 () == -1) {
10459 printf ("test_blockdev_getsz_0 FAILED\n");
10463 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
10464 if (test_blockdev_getbsz_0 () == -1) {
10465 printf ("test_blockdev_getbsz_0 FAILED\n");
10469 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
10470 if (test_blockdev_getss_0 () == -1) {
10471 printf ("test_blockdev_getss_0 FAILED\n");
10475 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
10476 if (test_blockdev_getro_0 () == -1) {
10477 printf ("test_blockdev_getro_0 FAILED\n");
10481 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
10482 if (test_blockdev_setrw_0 () == -1) {
10483 printf ("test_blockdev_setrw_0 FAILED\n");
10487 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
10488 if (test_blockdev_setro_0 () == -1) {
10489 printf ("test_blockdev_setro_0 FAILED\n");
10493 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
10494 if (test_statvfs_0 () == -1) {
10495 printf ("test_statvfs_0 FAILED\n");
10499 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
10500 if (test_lstat_0 () == -1) {
10501 printf ("test_lstat_0 FAILED\n");
10505 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
10506 if (test_stat_0 () == -1) {
10507 printf ("test_stat_0 FAILED\n");
10511 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
10512 if (test_file_0 () == -1) {
10513 printf ("test_file_0 FAILED\n");
10517 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
10518 if (test_file_1 () == -1) {
10519 printf ("test_file_1 FAILED\n");
10523 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
10524 if (test_file_2 () == -1) {
10525 printf ("test_file_2 FAILED\n");
10529 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
10530 if (test_umount_all_0 () == -1) {
10531 printf ("test_umount_all_0 FAILED\n");
10535 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
10536 if (test_umount_all_1 () == -1) {
10537 printf ("test_umount_all_1 FAILED\n");
10541 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
10542 if (test_mounts_0 () == -1) {
10543 printf ("test_mounts_0 FAILED\n");
10547 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
10548 if (test_umount_0 () == -1) {
10549 printf ("test_umount_0 FAILED\n");
10553 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
10554 if (test_umount_1 () == -1) {
10555 printf ("test_umount_1 FAILED\n");
10559 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
10560 if (test_write_file_0 () == -1) {
10561 printf ("test_write_file_0 FAILED\n");
10565 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
10566 if (test_write_file_1 () == -1) {
10567 printf ("test_write_file_1 FAILED\n");
10571 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
10572 if (test_write_file_2 () == -1) {
10573 printf ("test_write_file_2 FAILED\n");
10577 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
10578 if (test_write_file_3 () == -1) {
10579 printf ("test_write_file_3 FAILED\n");
10583 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
10584 if (test_write_file_4 () == -1) {
10585 printf ("test_write_file_4 FAILED\n");
10589 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
10590 if (test_write_file_5 () == -1) {
10591 printf ("test_write_file_5 FAILED\n");
10595 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
10596 if (test_mkfs_0 () == -1) {
10597 printf ("test_mkfs_0 FAILED\n");
10601 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
10602 if (test_lvcreate_0 () == -1) {
10603 printf ("test_lvcreate_0 FAILED\n");
10607 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
10608 if (test_vgcreate_0 () == -1) {
10609 printf ("test_vgcreate_0 FAILED\n");
10613 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
10614 if (test_pvcreate_0 () == -1) {
10615 printf ("test_pvcreate_0 FAILED\n");
10619 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
10620 if (test_is_dir_0 () == -1) {
10621 printf ("test_is_dir_0 FAILED\n");
10625 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
10626 if (test_is_dir_1 () == -1) {
10627 printf ("test_is_dir_1 FAILED\n");
10631 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
10632 if (test_is_file_0 () == -1) {
10633 printf ("test_is_file_0 FAILED\n");
10637 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
10638 if (test_is_file_1 () == -1) {
10639 printf ("test_is_file_1 FAILED\n");
10643 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
10644 if (test_exists_0 () == -1) {
10645 printf ("test_exists_0 FAILED\n");
10649 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
10650 if (test_exists_1 () == -1) {
10651 printf ("test_exists_1 FAILED\n");
10655 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
10656 if (test_mkdir_p_0 () == -1) {
10657 printf ("test_mkdir_p_0 FAILED\n");
10661 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
10662 if (test_mkdir_p_1 () == -1) {
10663 printf ("test_mkdir_p_1 FAILED\n");
10667 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
10668 if (test_mkdir_p_2 () == -1) {
10669 printf ("test_mkdir_p_2 FAILED\n");
10673 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
10674 if (test_mkdir_0 () == -1) {
10675 printf ("test_mkdir_0 FAILED\n");
10679 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
10680 if (test_mkdir_1 () == -1) {
10681 printf ("test_mkdir_1 FAILED\n");
10685 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
10686 if (test_rm_rf_0 () == -1) {
10687 printf ("test_rm_rf_0 FAILED\n");
10691 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
10692 if (test_rmdir_0 () == -1) {
10693 printf ("test_rmdir_0 FAILED\n");
10697 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
10698 if (test_rmdir_1 () == -1) {
10699 printf ("test_rmdir_1 FAILED\n");
10703 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
10704 if (test_rmdir_2 () == -1) {
10705 printf ("test_rmdir_2 FAILED\n");
10709 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
10710 if (test_rm_0 () == -1) {
10711 printf ("test_rm_0 FAILED\n");
10715 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
10716 if (test_rm_1 () == -1) {
10717 printf ("test_rm_1 FAILED\n");
10721 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
10722 if (test_rm_2 () == -1) {
10723 printf ("test_rm_2 FAILED\n");
10727 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
10728 if (test_read_lines_0 () == -1) {
10729 printf ("test_read_lines_0 FAILED\n");
10733 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
10734 if (test_read_lines_1 () == -1) {
10735 printf ("test_read_lines_1 FAILED\n");
10739 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
10740 if (test_lvs_0 () == -1) {
10741 printf ("test_lvs_0 FAILED\n");
10745 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
10746 if (test_lvs_1 () == -1) {
10747 printf ("test_lvs_1 FAILED\n");
10751 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
10752 if (test_vgs_0 () == -1) {
10753 printf ("test_vgs_0 FAILED\n");
10757 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
10758 if (test_vgs_1 () == -1) {
10759 printf ("test_vgs_1 FAILED\n");
10763 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
10764 if (test_pvs_0 () == -1) {
10765 printf ("test_pvs_0 FAILED\n");
10769 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
10770 if (test_pvs_1 () == -1) {
10771 printf ("test_pvs_1 FAILED\n");
10775 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
10776 if (test_list_partitions_0 () == -1) {
10777 printf ("test_list_partitions_0 FAILED\n");
10781 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
10782 if (test_list_partitions_1 () == -1) {
10783 printf ("test_list_partitions_1 FAILED\n");
10787 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
10788 if (test_list_devices_0 () == -1) {
10789 printf ("test_list_devices_0 FAILED\n");
10793 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
10794 if (test_ls_0 () == -1) {
10795 printf ("test_ls_0 FAILED\n");
10799 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
10800 if (test_cat_0 () == -1) {
10801 printf ("test_cat_0 FAILED\n");
10805 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
10806 if (test_touch_0 () == -1) {
10807 printf ("test_touch_0 FAILED\n");
10811 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
10812 if (test_sync_0 () == -1) {
10813 printf ("test_sync_0 FAILED\n");
10817 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
10818 if (test_mount_0 () == -1) {
10819 printf ("test_mount_0 FAILED\n");
10824 unlink ("test1.img");
10825 unlink ("test2.img");
10826 unlink ("test3.img");
10829 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);