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_ll\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
113 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
114 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
115 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
116 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
117 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
120 static int test_equal_0 (void)
122 /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */
124 char device[] = "/dev/sda";
128 r = guestfs_blockdev_setrw (g, device);
135 r = guestfs_umount_all (g);
142 r = guestfs_lvm_remove_all (g);
147 char device[] = "/dev/sda";
149 char lines_0[] = ",";
156 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
161 char fstype[] = "ext2";
162 char device[] = "/dev/sda1";
166 r = guestfs_mkfs (g, fstype, device);
171 char device[] = "/dev/sda1";
173 char mountpoint[] = "/";
176 r = guestfs_mount (g, device, mountpoint);
180 /* TestOutputTrue for equal (0) */
182 char path[] = "/file1";
183 char content[] = "contents of a file";
186 r = guestfs_write_file (g, path, content, 0);
191 char src[] = "/file1";
192 char dest[] = "/file2";
195 r = guestfs_cp (g, src, dest);
200 char file1[] = "/file1";
201 char file2[] = "/file2";
204 r = guestfs_equal (g, file1, file2);
208 fprintf (stderr, "test_equal_0: expected true, got false\n");
215 static int test_equal_1 (void)
217 /* InitBasicFS for equal (1): create ext2 on /dev/sda1 */
219 char device[] = "/dev/sda";
223 r = guestfs_blockdev_setrw (g, device);
230 r = guestfs_umount_all (g);
237 r = guestfs_lvm_remove_all (g);
242 char device[] = "/dev/sda";
244 char lines_0[] = ",";
251 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
256 char fstype[] = "ext2";
257 char device[] = "/dev/sda1";
261 r = guestfs_mkfs (g, fstype, device);
266 char device[] = "/dev/sda1";
268 char mountpoint[] = "/";
271 r = guestfs_mount (g, device, mountpoint);
275 /* TestOutputFalse for equal (1) */
277 char path[] = "/file1";
278 char content[] = "contents of a file";
281 r = guestfs_write_file (g, path, content, 0);
286 char path[] = "/file2";
287 char content[] = "contents of another file";
290 r = guestfs_write_file (g, path, content, 0);
295 char file1[] = "/file1";
296 char file2[] = "/file2";
299 r = guestfs_equal (g, file1, file2);
303 fprintf (stderr, "test_equal_1: expected false, got true\n");
310 static int test_equal_2 (void)
312 /* InitBasicFS for equal (2): create ext2 on /dev/sda1 */
314 char device[] = "/dev/sda";
318 r = guestfs_blockdev_setrw (g, device);
325 r = guestfs_umount_all (g);
332 r = guestfs_lvm_remove_all (g);
337 char device[] = "/dev/sda";
339 char lines_0[] = ",";
346 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
351 char fstype[] = "ext2";
352 char device[] = "/dev/sda1";
356 r = guestfs_mkfs (g, fstype, device);
361 char device[] = "/dev/sda1";
363 char mountpoint[] = "/";
366 r = guestfs_mount (g, device, mountpoint);
370 /* TestLastFail for equal (2) */
372 char file1[] = "/file1";
373 char file2[] = "/file2";
376 r = guestfs_equal (g, file1, file2);
383 static int test_ping_daemon_0 (void)
385 /* InitEmpty for ping_daemon (0) */
387 char device[] = "/dev/sda";
391 r = guestfs_blockdev_setrw (g, device);
398 r = guestfs_umount_all (g);
405 r = guestfs_lvm_remove_all (g);
409 /* TestRun for ping_daemon (0) */
413 r = guestfs_ping_daemon (g);
420 static int test_dmesg_0 (void)
422 /* InitEmpty for dmesg (0) */
424 char device[] = "/dev/sda";
428 r = guestfs_blockdev_setrw (g, device);
435 r = guestfs_umount_all (g);
442 r = guestfs_lvm_remove_all (g);
446 /* TestRun for dmesg (0) */
450 r = guestfs_dmesg (g);
458 static int test_drop_caches_0 (void)
460 /* InitEmpty for drop_caches (0) */
462 char device[] = "/dev/sda";
466 r = guestfs_blockdev_setrw (g, device);
473 r = guestfs_umount_all (g);
480 r = guestfs_lvm_remove_all (g);
484 /* TestRun for drop_caches (0) */
488 r = guestfs_drop_caches (g, 3);
495 static int test_mv_0 (void)
497 /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
499 char device[] = "/dev/sda";
503 r = guestfs_blockdev_setrw (g, device);
510 r = guestfs_umount_all (g);
517 r = guestfs_lvm_remove_all (g);
522 char device[] = "/dev/sda";
524 char lines_0[] = ",";
531 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
536 char fstype[] = "ext2";
537 char device[] = "/dev/sda1";
541 r = guestfs_mkfs (g, fstype, device);
546 char device[] = "/dev/sda1";
548 char mountpoint[] = "/";
551 r = guestfs_mount (g, device, mountpoint);
555 /* TestOutput for mv (0) */
556 char expected[] = "file content";
558 char path[] = "/old";
559 char content[] = "file content";
562 r = guestfs_write_file (g, path, content, 0);
568 char dest[] = "/new";
571 r = guestfs_mv (g, src, dest);
576 char path[] = "/new";
579 r = guestfs_cat (g, path);
582 if (strcmp (r, expected) != 0) {
583 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
591 static int test_mv_1 (void)
593 /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
595 char device[] = "/dev/sda";
599 r = guestfs_blockdev_setrw (g, device);
606 r = guestfs_umount_all (g);
613 r = guestfs_lvm_remove_all (g);
618 char device[] = "/dev/sda";
620 char lines_0[] = ",";
627 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
632 char fstype[] = "ext2";
633 char device[] = "/dev/sda1";
637 r = guestfs_mkfs (g, fstype, device);
642 char device[] = "/dev/sda1";
644 char mountpoint[] = "/";
647 r = guestfs_mount (g, device, mountpoint);
651 /* TestOutputFalse for mv (1) */
653 char path[] = "/old";
654 char content[] = "file content";
657 r = guestfs_write_file (g, path, content, 0);
663 char dest[] = "/new";
666 r = guestfs_mv (g, src, dest);
671 char path[] = "/old";
674 r = guestfs_is_file (g, path);
678 fprintf (stderr, "test_mv_1: expected false, got true\n");
685 static int test_cp_a_0 (void)
687 /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
689 char device[] = "/dev/sda";
693 r = guestfs_blockdev_setrw (g, device);
700 r = guestfs_umount_all (g);
707 r = guestfs_lvm_remove_all (g);
712 char device[] = "/dev/sda";
714 char lines_0[] = ",";
721 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
726 char fstype[] = "ext2";
727 char device[] = "/dev/sda1";
731 r = guestfs_mkfs (g, fstype, device);
736 char device[] = "/dev/sda1";
738 char mountpoint[] = "/";
741 r = guestfs_mount (g, device, mountpoint);
745 /* TestOutput for cp_a (0) */
746 char expected[] = "file content";
748 char path[] = "/olddir";
751 r = guestfs_mkdir (g, path);
756 char path[] = "/newdir";
759 r = guestfs_mkdir (g, path);
764 char path[] = "/olddir/file";
765 char content[] = "file content";
768 r = guestfs_write_file (g, path, content, 0);
773 char src[] = "/olddir";
774 char dest[] = "/newdir";
777 r = guestfs_cp_a (g, src, dest);
782 char path[] = "/newdir/olddir/file";
785 r = guestfs_cat (g, path);
788 if (strcmp (r, expected) != 0) {
789 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
797 static int test_cp_0 (void)
799 /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
801 char device[] = "/dev/sda";
805 r = guestfs_blockdev_setrw (g, device);
812 r = guestfs_umount_all (g);
819 r = guestfs_lvm_remove_all (g);
824 char device[] = "/dev/sda";
826 char lines_0[] = ",";
833 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
838 char fstype[] = "ext2";
839 char device[] = "/dev/sda1";
843 r = guestfs_mkfs (g, fstype, device);
848 char device[] = "/dev/sda1";
850 char mountpoint[] = "/";
853 r = guestfs_mount (g, device, mountpoint);
857 /* TestOutput for cp (0) */
858 char expected[] = "file content";
860 char path[] = "/old";
861 char content[] = "file content";
864 r = guestfs_write_file (g, path, content, 0);
870 char dest[] = "/new";
873 r = guestfs_cp (g, src, dest);
878 char path[] = "/new";
881 r = guestfs_cat (g, path);
884 if (strcmp (r, expected) != 0) {
885 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
893 static int test_cp_1 (void)
895 /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
897 char device[] = "/dev/sda";
901 r = guestfs_blockdev_setrw (g, device);
908 r = guestfs_umount_all (g);
915 r = guestfs_lvm_remove_all (g);
920 char device[] = "/dev/sda";
922 char lines_0[] = ",";
929 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
934 char fstype[] = "ext2";
935 char device[] = "/dev/sda1";
939 r = guestfs_mkfs (g, fstype, device);
944 char device[] = "/dev/sda1";
946 char mountpoint[] = "/";
949 r = guestfs_mount (g, device, mountpoint);
953 /* TestOutputTrue for cp (1) */
955 char path[] = "/old";
956 char content[] = "file content";
959 r = guestfs_write_file (g, path, content, 0);
965 char dest[] = "/new";
968 r = guestfs_cp (g, src, dest);
973 char path[] = "/old";
976 r = guestfs_is_file (g, path);
980 fprintf (stderr, "test_cp_1: expected true, got false\n");
987 static int test_cp_2 (void)
989 /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
991 char device[] = "/dev/sda";
995 r = guestfs_blockdev_setrw (g, device);
1002 r = guestfs_umount_all (g);
1009 r = guestfs_lvm_remove_all (g);
1014 char device[] = "/dev/sda";
1015 device[5] = devchar;
1016 char lines_0[] = ",";
1023 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1028 char fstype[] = "ext2";
1029 char device[] = "/dev/sda1";
1030 device[5] = devchar;
1033 r = guestfs_mkfs (g, fstype, device);
1038 char device[] = "/dev/sda1";
1039 device[5] = devchar;
1040 char mountpoint[] = "/";
1043 r = guestfs_mount (g, device, mountpoint);
1047 /* TestOutput for cp (2) */
1048 char expected[] = "file content";
1050 char path[] = "/old";
1051 char content[] = "file content";
1054 r = guestfs_write_file (g, path, content, 0);
1059 char path[] = "/dir";
1062 r = guestfs_mkdir (g, path);
1067 char src[] = "/old";
1068 char dest[] = "/dir/new";
1071 r = guestfs_cp (g, src, dest);
1076 char path[] = "/dir/new";
1079 r = guestfs_cat (g, path);
1082 if (strcmp (r, expected) != 0) {
1083 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
1091 static int test_grub_install_0 (void)
1093 /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
1095 char device[] = "/dev/sda";
1096 device[5] = devchar;
1099 r = guestfs_blockdev_setrw (g, device);
1106 r = guestfs_umount_all (g);
1113 r = guestfs_lvm_remove_all (g);
1118 char device[] = "/dev/sda";
1119 device[5] = devchar;
1120 char lines_0[] = ",";
1127 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1132 char fstype[] = "ext2";
1133 char device[] = "/dev/sda1";
1134 device[5] = devchar;
1137 r = guestfs_mkfs (g, fstype, device);
1142 char device[] = "/dev/sda1";
1143 device[5] = devchar;
1144 char mountpoint[] = "/";
1147 r = guestfs_mount (g, device, mountpoint);
1151 /* TestOutputTrue for grub_install (0) */
1154 char device[] = "/dev/sda1";
1155 device[5] = devchar;
1158 r = guestfs_grub_install (g, root, device);
1163 char path[] = "/boot";
1166 r = guestfs_is_dir (g, path);
1170 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
1177 static int test_zero_0 (void)
1179 /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
1181 char device[] = "/dev/sda";
1182 device[5] = devchar;
1185 r = guestfs_blockdev_setrw (g, device);
1192 r = guestfs_umount_all (g);
1199 r = guestfs_lvm_remove_all (g);
1204 char device[] = "/dev/sda";
1205 device[5] = devchar;
1206 char lines_0[] = ",";
1213 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1218 char fstype[] = "ext2";
1219 char device[] = "/dev/sda1";
1220 device[5] = devchar;
1223 r = guestfs_mkfs (g, fstype, device);
1228 char device[] = "/dev/sda1";
1229 device[5] = devchar;
1230 char mountpoint[] = "/";
1233 r = guestfs_mount (g, device, mountpoint);
1237 /* TestOutput for zero (0) */
1238 char expected[] = "data";
1240 char pathordevice[] = "/dev/sda1";
1241 pathordevice[5] = devchar;
1244 r = guestfs_umount (g, pathordevice);
1249 char device[] = "/dev/sda1";
1250 device[5] = devchar;
1253 r = guestfs_zero (g, device);
1258 char path[] = "/dev/sda1";
1262 r = guestfs_file (g, path);
1265 if (strcmp (r, expected) != 0) {
1266 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
1274 static int test_fsck_0 (void)
1276 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
1278 char device[] = "/dev/sda";
1279 device[5] = devchar;
1282 r = guestfs_blockdev_setrw (g, device);
1289 r = guestfs_umount_all (g);
1296 r = guestfs_lvm_remove_all (g);
1301 char device[] = "/dev/sda";
1302 device[5] = devchar;
1303 char lines_0[] = ",";
1310 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1315 char fstype[] = "ext2";
1316 char device[] = "/dev/sda1";
1317 device[5] = devchar;
1320 r = guestfs_mkfs (g, fstype, device);
1325 char device[] = "/dev/sda1";
1326 device[5] = devchar;
1327 char mountpoint[] = "/";
1330 r = guestfs_mount (g, device, mountpoint);
1334 /* TestOutputInt for fsck (0) */
1336 char pathordevice[] = "/dev/sda1";
1337 pathordevice[5] = devchar;
1340 r = guestfs_umount (g, pathordevice);
1345 char fstype[] = "ext2";
1346 char device[] = "/dev/sda1";
1347 device[5] = devchar;
1350 r = guestfs_fsck (g, fstype, device);
1354 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
1361 static int test_fsck_1 (void)
1363 /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
1365 char device[] = "/dev/sda";
1366 device[5] = devchar;
1369 r = guestfs_blockdev_setrw (g, device);
1376 r = guestfs_umount_all (g);
1383 r = guestfs_lvm_remove_all (g);
1388 char device[] = "/dev/sda";
1389 device[5] = devchar;
1390 char lines_0[] = ",";
1397 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1402 char fstype[] = "ext2";
1403 char device[] = "/dev/sda1";
1404 device[5] = devchar;
1407 r = guestfs_mkfs (g, fstype, device);
1412 char device[] = "/dev/sda1";
1413 device[5] = devchar;
1414 char mountpoint[] = "/";
1417 r = guestfs_mount (g, device, mountpoint);
1421 /* TestOutputInt for fsck (1) */
1423 char pathordevice[] = "/dev/sda1";
1424 pathordevice[5] = devchar;
1427 r = guestfs_umount (g, pathordevice);
1432 char device[] = "/dev/sda1";
1433 device[5] = devchar;
1436 r = guestfs_zero (g, device);
1441 char fstype[] = "ext2";
1442 char device[] = "/dev/sda1";
1443 device[5] = devchar;
1446 r = guestfs_fsck (g, fstype, device);
1450 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
1457 static int test_set_e2uuid_0 (void)
1459 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
1461 char device[] = "/dev/sda";
1462 device[5] = devchar;
1465 r = guestfs_blockdev_setrw (g, device);
1472 r = guestfs_umount_all (g);
1479 r = guestfs_lvm_remove_all (g);
1484 char device[] = "/dev/sda";
1485 device[5] = devchar;
1486 char lines_0[] = ",";
1493 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1498 char fstype[] = "ext2";
1499 char device[] = "/dev/sda1";
1500 device[5] = devchar;
1503 r = guestfs_mkfs (g, fstype, device);
1508 char device[] = "/dev/sda1";
1509 device[5] = devchar;
1510 char mountpoint[] = "/";
1513 r = guestfs_mount (g, device, mountpoint);
1517 /* TestOutput for set_e2uuid (0) */
1518 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1520 char device[] = "/dev/sda1";
1521 device[5] = devchar;
1522 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1525 r = guestfs_set_e2uuid (g, device, uuid);
1530 char device[] = "/dev/sda1";
1531 device[5] = devchar;
1534 r = guestfs_get_e2uuid (g, device);
1537 if (strcmp (r, expected) != 0) {
1538 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
1546 static int test_set_e2uuid_1 (void)
1548 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
1550 char device[] = "/dev/sda";
1551 device[5] = devchar;
1554 r = guestfs_blockdev_setrw (g, device);
1561 r = guestfs_umount_all (g);
1568 r = guestfs_lvm_remove_all (g);
1573 char device[] = "/dev/sda";
1574 device[5] = devchar;
1575 char lines_0[] = ",";
1582 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1587 char fstype[] = "ext2";
1588 char device[] = "/dev/sda1";
1589 device[5] = devchar;
1592 r = guestfs_mkfs (g, fstype, device);
1597 char device[] = "/dev/sda1";
1598 device[5] = devchar;
1599 char mountpoint[] = "/";
1602 r = guestfs_mount (g, device, mountpoint);
1606 /* TestOutput for set_e2uuid (1) */
1607 char expected[] = "";
1609 char device[] = "/dev/sda1";
1610 device[5] = devchar;
1611 char uuid[] = "clear";
1614 r = guestfs_set_e2uuid (g, device, uuid);
1619 char device[] = "/dev/sda1";
1620 device[5] = devchar;
1623 r = guestfs_get_e2uuid (g, device);
1626 if (strcmp (r, expected) != 0) {
1627 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
1635 static int test_set_e2uuid_2 (void)
1637 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1639 char device[] = "/dev/sda";
1640 device[5] = devchar;
1643 r = guestfs_blockdev_setrw (g, device);
1650 r = guestfs_umount_all (g);
1657 r = guestfs_lvm_remove_all (g);
1662 char device[] = "/dev/sda";
1663 device[5] = devchar;
1664 char lines_0[] = ",";
1671 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1676 char fstype[] = "ext2";
1677 char device[] = "/dev/sda1";
1678 device[5] = devchar;
1681 r = guestfs_mkfs (g, fstype, device);
1686 char device[] = "/dev/sda1";
1687 device[5] = devchar;
1688 char mountpoint[] = "/";
1691 r = guestfs_mount (g, device, mountpoint);
1695 /* TestRun for set_e2uuid (2) */
1697 char device[] = "/dev/sda1";
1698 device[5] = devchar;
1699 char uuid[] = "random";
1702 r = guestfs_set_e2uuid (g, device, uuid);
1709 static int test_set_e2uuid_3 (void)
1711 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
1713 char device[] = "/dev/sda";
1714 device[5] = devchar;
1717 r = guestfs_blockdev_setrw (g, device);
1724 r = guestfs_umount_all (g);
1731 r = guestfs_lvm_remove_all (g);
1736 char device[] = "/dev/sda";
1737 device[5] = devchar;
1738 char lines_0[] = ",";
1745 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1750 char fstype[] = "ext2";
1751 char device[] = "/dev/sda1";
1752 device[5] = devchar;
1755 r = guestfs_mkfs (g, fstype, device);
1760 char device[] = "/dev/sda1";
1761 device[5] = devchar;
1762 char mountpoint[] = "/";
1765 r = guestfs_mount (g, device, mountpoint);
1769 /* TestRun for set_e2uuid (3) */
1771 char device[] = "/dev/sda1";
1772 device[5] = devchar;
1773 char uuid[] = "time";
1776 r = guestfs_set_e2uuid (g, device, uuid);
1783 static int test_set_e2label_0 (void)
1785 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
1787 char device[] = "/dev/sda";
1788 device[5] = devchar;
1791 r = guestfs_blockdev_setrw (g, device);
1798 r = guestfs_umount_all (g);
1805 r = guestfs_lvm_remove_all (g);
1810 char device[] = "/dev/sda";
1811 device[5] = devchar;
1812 char lines_0[] = ",";
1819 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1824 char fstype[] = "ext2";
1825 char device[] = "/dev/sda1";
1826 device[5] = devchar;
1829 r = guestfs_mkfs (g, fstype, device);
1834 char device[] = "/dev/sda1";
1835 device[5] = devchar;
1836 char mountpoint[] = "/";
1839 r = guestfs_mount (g, device, mountpoint);
1843 /* TestOutput for set_e2label (0) */
1844 char expected[] = "testlabel";
1846 char device[] = "/dev/sda1";
1847 device[5] = devchar;
1848 char label[] = "testlabel";
1851 r = guestfs_set_e2label (g, device, label);
1856 char device[] = "/dev/sda1";
1857 device[5] = devchar;
1860 r = guestfs_get_e2label (g, device);
1863 if (strcmp (r, expected) != 0) {
1864 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
1872 static int test_pvremove_0 (void)
1874 /* InitEmpty for pvremove (0) */
1876 char device[] = "/dev/sda";
1877 device[5] = devchar;
1880 r = guestfs_blockdev_setrw (g, device);
1887 r = guestfs_umount_all (g);
1894 r = guestfs_lvm_remove_all (g);
1898 /* TestOutputList for pvremove (0) */
1900 char device[] = "/dev/sda";
1901 device[5] = devchar;
1904 r = guestfs_pvcreate (g, device);
1909 char volgroup[] = "VG";
1910 char physvols_0[] = "/dev/sda";
1911 physvols_0[5] = devchar;
1912 char *physvols[] = {
1918 r = guestfs_vgcreate (g, volgroup, physvols);
1923 char logvol[] = "LV1";
1924 char volgroup[] = "VG";
1927 r = guestfs_lvcreate (g, logvol, volgroup, 50);
1932 char logvol[] = "LV2";
1933 char volgroup[] = "VG";
1936 r = guestfs_lvcreate (g, logvol, volgroup, 50);
1941 char vgname[] = "VG";
1944 r = guestfs_vgremove (g, vgname);
1949 char device[] = "/dev/sda";
1950 device[5] = devchar;
1953 r = guestfs_pvremove (g, device);
1961 r = guestfs_lvs (g);
1965 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
1969 for (i = 0; r[i] != NULL; ++i)
1976 static int test_pvremove_1 (void)
1978 /* InitEmpty for pvremove (1) */
1980 char device[] = "/dev/sda";
1981 device[5] = devchar;
1984 r = guestfs_blockdev_setrw (g, device);
1991 r = guestfs_umount_all (g);
1998 r = guestfs_lvm_remove_all (g);
2002 /* TestOutputList for pvremove (1) */
2004 char device[] = "/dev/sda";
2005 device[5] = devchar;
2008 r = guestfs_pvcreate (g, device);
2013 char volgroup[] = "VG";
2014 char physvols_0[] = "/dev/sda";
2015 physvols_0[5] = devchar;
2016 char *physvols[] = {
2022 r = guestfs_vgcreate (g, volgroup, physvols);
2027 char logvol[] = "LV1";
2028 char volgroup[] = "VG";
2031 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2036 char logvol[] = "LV2";
2037 char volgroup[] = "VG";
2040 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2045 char vgname[] = "VG";
2048 r = guestfs_vgremove (g, vgname);
2053 char device[] = "/dev/sda";
2054 device[5] = devchar;
2057 r = guestfs_pvremove (g, device);
2065 r = guestfs_vgs (g);
2069 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
2073 for (i = 0; r[i] != NULL; ++i)
2080 static int test_pvremove_2 (void)
2082 /* InitEmpty for pvremove (2) */
2084 char device[] = "/dev/sda";
2085 device[5] = devchar;
2088 r = guestfs_blockdev_setrw (g, device);
2095 r = guestfs_umount_all (g);
2102 r = guestfs_lvm_remove_all (g);
2106 /* TestOutputList for pvremove (2) */
2108 char device[] = "/dev/sda";
2109 device[5] = devchar;
2112 r = guestfs_pvcreate (g, device);
2117 char volgroup[] = "VG";
2118 char physvols_0[] = "/dev/sda";
2119 physvols_0[5] = devchar;
2120 char *physvols[] = {
2126 r = guestfs_vgcreate (g, volgroup, physvols);
2131 char logvol[] = "LV1";
2132 char volgroup[] = "VG";
2135 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2140 char logvol[] = "LV2";
2141 char volgroup[] = "VG";
2144 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2149 char vgname[] = "VG";
2152 r = guestfs_vgremove (g, vgname);
2157 char device[] = "/dev/sda";
2158 device[5] = devchar;
2161 r = guestfs_pvremove (g, device);
2169 r = guestfs_pvs (g);
2173 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
2177 for (i = 0; r[i] != NULL; ++i)
2184 static int test_vgremove_0 (void)
2186 /* InitEmpty for vgremove (0) */
2188 char device[] = "/dev/sda";
2189 device[5] = devchar;
2192 r = guestfs_blockdev_setrw (g, device);
2199 r = guestfs_umount_all (g);
2206 r = guestfs_lvm_remove_all (g);
2210 /* TestOutputList for vgremove (0) */
2212 char device[] = "/dev/sda";
2213 device[5] = devchar;
2216 r = guestfs_pvcreate (g, device);
2221 char volgroup[] = "VG";
2222 char physvols_0[] = "/dev/sda";
2223 physvols_0[5] = devchar;
2224 char *physvols[] = {
2230 r = guestfs_vgcreate (g, volgroup, physvols);
2235 char logvol[] = "LV1";
2236 char volgroup[] = "VG";
2239 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2244 char logvol[] = "LV2";
2245 char volgroup[] = "VG";
2248 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2253 char vgname[] = "VG";
2256 r = guestfs_vgremove (g, vgname);
2264 r = guestfs_lvs (g);
2268 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
2272 for (i = 0; r[i] != NULL; ++i)
2279 static int test_vgremove_1 (void)
2281 /* InitEmpty for vgremove (1) */
2283 char device[] = "/dev/sda";
2284 device[5] = devchar;
2287 r = guestfs_blockdev_setrw (g, device);
2294 r = guestfs_umount_all (g);
2301 r = guestfs_lvm_remove_all (g);
2305 /* TestOutputList for vgremove (1) */
2307 char device[] = "/dev/sda";
2308 device[5] = devchar;
2311 r = guestfs_pvcreate (g, device);
2316 char volgroup[] = "VG";
2317 char physvols_0[] = "/dev/sda";
2318 physvols_0[5] = devchar;
2319 char *physvols[] = {
2325 r = guestfs_vgcreate (g, volgroup, physvols);
2330 char logvol[] = "LV1";
2331 char volgroup[] = "VG";
2334 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2339 char logvol[] = "LV2";
2340 char volgroup[] = "VG";
2343 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2348 char vgname[] = "VG";
2351 r = guestfs_vgremove (g, vgname);
2359 r = guestfs_vgs (g);
2363 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
2367 for (i = 0; r[i] != NULL; ++i)
2374 static int test_lvremove_0 (void)
2376 /* InitEmpty for lvremove (0) */
2378 char device[] = "/dev/sda";
2379 device[5] = devchar;
2382 r = guestfs_blockdev_setrw (g, device);
2389 r = guestfs_umount_all (g);
2396 r = guestfs_lvm_remove_all (g);
2400 /* TestOutputList for lvremove (0) */
2402 char device[] = "/dev/sda";
2403 device[5] = devchar;
2406 r = guestfs_pvcreate (g, device);
2411 char volgroup[] = "VG";
2412 char physvols_0[] = "/dev/sda";
2413 physvols_0[5] = devchar;
2414 char *physvols[] = {
2420 r = guestfs_vgcreate (g, volgroup, physvols);
2425 char logvol[] = "LV1";
2426 char volgroup[] = "VG";
2429 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2434 char logvol[] = "LV2";
2435 char volgroup[] = "VG";
2438 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2443 char device[] = "/dev/VG/LV1";
2446 r = guestfs_lvremove (g, device);
2454 r = guestfs_lvs (g);
2458 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
2463 char expected[] = "/dev/VG/LV2";
2464 if (strcmp (r[0], expected) != 0) {
2465 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2470 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
2474 for (i = 0; r[i] != NULL; ++i)
2481 static int test_lvremove_1 (void)
2483 /* InitEmpty for lvremove (1) */
2485 char device[] = "/dev/sda";
2486 device[5] = devchar;
2489 r = guestfs_blockdev_setrw (g, device);
2496 r = guestfs_umount_all (g);
2503 r = guestfs_lvm_remove_all (g);
2507 /* TestOutputList for lvremove (1) */
2509 char device[] = "/dev/sda";
2510 device[5] = devchar;
2513 r = guestfs_pvcreate (g, device);
2518 char volgroup[] = "VG";
2519 char physvols_0[] = "/dev/sda";
2520 physvols_0[5] = devchar;
2521 char *physvols[] = {
2527 r = guestfs_vgcreate (g, volgroup, physvols);
2532 char logvol[] = "LV1";
2533 char volgroup[] = "VG";
2536 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2541 char logvol[] = "LV2";
2542 char volgroup[] = "VG";
2545 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2550 char device[] = "/dev/VG";
2553 r = guestfs_lvremove (g, device);
2561 r = guestfs_lvs (g);
2565 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
2569 for (i = 0; r[i] != NULL; ++i)
2576 static int test_lvremove_2 (void)
2578 /* InitEmpty for lvremove (2) */
2580 char device[] = "/dev/sda";
2581 device[5] = devchar;
2584 r = guestfs_blockdev_setrw (g, device);
2591 r = guestfs_umount_all (g);
2598 r = guestfs_lvm_remove_all (g);
2602 /* TestOutputList for lvremove (2) */
2604 char device[] = "/dev/sda";
2605 device[5] = devchar;
2608 r = guestfs_pvcreate (g, device);
2613 char volgroup[] = "VG";
2614 char physvols_0[] = "/dev/sda";
2615 physvols_0[5] = devchar;
2616 char *physvols[] = {
2622 r = guestfs_vgcreate (g, volgroup, physvols);
2627 char logvol[] = "LV1";
2628 char volgroup[] = "VG";
2631 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2636 char logvol[] = "LV2";
2637 char volgroup[] = "VG";
2640 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2645 char device[] = "/dev/VG";
2648 r = guestfs_lvremove (g, device);
2656 r = guestfs_vgs (g);
2660 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
2665 char expected[] = "VG";
2666 if (strcmp (r[0], expected) != 0) {
2667 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2672 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
2676 for (i = 0; r[i] != NULL; ++i)
2683 static int test_mount_ro_0 (void)
2685 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
2687 char device[] = "/dev/sda";
2688 device[5] = devchar;
2691 r = guestfs_blockdev_setrw (g, device);
2698 r = guestfs_umount_all (g);
2705 r = guestfs_lvm_remove_all (g);
2710 char device[] = "/dev/sda";
2711 device[5] = devchar;
2712 char lines_0[] = ",";
2719 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2724 char fstype[] = "ext2";
2725 char device[] = "/dev/sda1";
2726 device[5] = devchar;
2729 r = guestfs_mkfs (g, fstype, device);
2734 char device[] = "/dev/sda1";
2735 device[5] = devchar;
2736 char mountpoint[] = "/";
2739 r = guestfs_mount (g, device, mountpoint);
2743 /* TestLastFail for mount_ro (0) */
2745 char pathordevice[] = "/";
2748 r = guestfs_umount (g, pathordevice);
2753 char device[] = "/dev/sda1";
2754 device[5] = devchar;
2755 char mountpoint[] = "/";
2758 r = guestfs_mount_ro (g, device, mountpoint);
2763 char path[] = "/new";
2766 r = guestfs_touch (g, path);
2773 static int test_mount_ro_1 (void)
2775 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
2777 char device[] = "/dev/sda";
2778 device[5] = devchar;
2781 r = guestfs_blockdev_setrw (g, device);
2788 r = guestfs_umount_all (g);
2795 r = guestfs_lvm_remove_all (g);
2800 char device[] = "/dev/sda";
2801 device[5] = devchar;
2802 char lines_0[] = ",";
2809 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2814 char fstype[] = "ext2";
2815 char device[] = "/dev/sda1";
2816 device[5] = devchar;
2819 r = guestfs_mkfs (g, fstype, device);
2824 char device[] = "/dev/sda1";
2825 device[5] = devchar;
2826 char mountpoint[] = "/";
2829 r = guestfs_mount (g, device, mountpoint);
2833 /* TestOutput for mount_ro (1) */
2834 char expected[] = "data";
2836 char path[] = "/new";
2837 char content[] = "data";
2840 r = guestfs_write_file (g, path, content, 0);
2845 char pathordevice[] = "/";
2848 r = guestfs_umount (g, pathordevice);
2853 char device[] = "/dev/sda1";
2854 device[5] = devchar;
2855 char mountpoint[] = "/";
2858 r = guestfs_mount_ro (g, device, mountpoint);
2863 char path[] = "/new";
2866 r = guestfs_cat (g, path);
2869 if (strcmp (r, expected) != 0) {
2870 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
2878 static int test_tgz_in_0 (void)
2880 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
2882 char device[] = "/dev/sda";
2883 device[5] = devchar;
2886 r = guestfs_blockdev_setrw (g, device);
2893 r = guestfs_umount_all (g);
2900 r = guestfs_lvm_remove_all (g);
2905 char device[] = "/dev/sda";
2906 device[5] = devchar;
2907 char lines_0[] = ",";
2914 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2919 char fstype[] = "ext2";
2920 char device[] = "/dev/sda1";
2921 device[5] = devchar;
2924 r = guestfs_mkfs (g, fstype, device);
2929 char device[] = "/dev/sda1";
2930 device[5] = devchar;
2931 char mountpoint[] = "/";
2934 r = guestfs_mount (g, device, mountpoint);
2938 /* TestOutput for tgz_in (0) */
2939 char expected[] = "hello\n";
2941 char directory[] = "/";
2944 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory);
2949 char path[] = "/hello";
2952 r = guestfs_cat (g, path);
2955 if (strcmp (r, expected) != 0) {
2956 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
2964 static int test_tar_in_0 (void)
2966 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
2968 char device[] = "/dev/sda";
2969 device[5] = devchar;
2972 r = guestfs_blockdev_setrw (g, device);
2979 r = guestfs_umount_all (g);
2986 r = guestfs_lvm_remove_all (g);
2991 char device[] = "/dev/sda";
2992 device[5] = devchar;
2993 char lines_0[] = ",";
3000 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3005 char fstype[] = "ext2";
3006 char device[] = "/dev/sda1";
3007 device[5] = devchar;
3010 r = guestfs_mkfs (g, fstype, device);
3015 char device[] = "/dev/sda1";
3016 device[5] = devchar;
3017 char mountpoint[] = "/";
3020 r = guestfs_mount (g, device, mountpoint);
3024 /* TestOutput for tar_in (0) */
3025 char expected[] = "hello\n";
3027 char directory[] = "/";
3030 r = guestfs_tar_in (g, "images/helloworld.tar", directory);
3035 char path[] = "/hello";
3038 r = guestfs_cat (g, path);
3041 if (strcmp (r, expected) != 0) {
3042 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3050 static int test_checksum_0 (void)
3052 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
3054 char device[] = "/dev/sda";
3055 device[5] = devchar;
3058 r = guestfs_blockdev_setrw (g, device);
3065 r = guestfs_umount_all (g);
3072 r = guestfs_lvm_remove_all (g);
3077 char device[] = "/dev/sda";
3078 device[5] = devchar;
3079 char lines_0[] = ",";
3086 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3091 char fstype[] = "ext2";
3092 char device[] = "/dev/sda1";
3093 device[5] = devchar;
3096 r = guestfs_mkfs (g, fstype, device);
3101 char device[] = "/dev/sda1";
3102 device[5] = devchar;
3103 char mountpoint[] = "/";
3106 r = guestfs_mount (g, device, mountpoint);
3110 /* TestOutput for checksum (0) */
3111 char expected[] = "935282863";
3113 char path[] = "/new";
3114 char content[] = "test\n";
3117 r = guestfs_write_file (g, path, content, 0);
3122 char csumtype[] = "crc";
3123 char path[] = "/new";
3126 r = guestfs_checksum (g, csumtype, path);
3129 if (strcmp (r, expected) != 0) {
3130 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
3138 static int test_checksum_1 (void)
3140 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
3142 char device[] = "/dev/sda";
3143 device[5] = devchar;
3146 r = guestfs_blockdev_setrw (g, device);
3153 r = guestfs_umount_all (g);
3160 r = guestfs_lvm_remove_all (g);
3165 char device[] = "/dev/sda";
3166 device[5] = devchar;
3167 char lines_0[] = ",";
3174 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3179 char fstype[] = "ext2";
3180 char device[] = "/dev/sda1";
3181 device[5] = devchar;
3184 r = guestfs_mkfs (g, fstype, device);
3189 char device[] = "/dev/sda1";
3190 device[5] = devchar;
3191 char mountpoint[] = "/";
3194 r = guestfs_mount (g, device, mountpoint);
3198 /* TestLastFail for checksum (1) */
3200 char csumtype[] = "crc";
3201 char path[] = "/new";
3204 r = guestfs_checksum (g, csumtype, path);
3212 static int test_checksum_2 (void)
3214 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
3216 char device[] = "/dev/sda";
3217 device[5] = devchar;
3220 r = guestfs_blockdev_setrw (g, device);
3227 r = guestfs_umount_all (g);
3234 r = guestfs_lvm_remove_all (g);
3239 char device[] = "/dev/sda";
3240 device[5] = devchar;
3241 char lines_0[] = ",";
3248 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3253 char fstype[] = "ext2";
3254 char device[] = "/dev/sda1";
3255 device[5] = devchar;
3258 r = guestfs_mkfs (g, fstype, device);
3263 char device[] = "/dev/sda1";
3264 device[5] = devchar;
3265 char mountpoint[] = "/";
3268 r = guestfs_mount (g, device, mountpoint);
3272 /* TestOutput for checksum (2) */
3273 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
3275 char path[] = "/new";
3276 char content[] = "test\n";
3279 r = guestfs_write_file (g, path, content, 0);
3284 char csumtype[] = "md5";
3285 char path[] = "/new";
3288 r = guestfs_checksum (g, csumtype, path);
3291 if (strcmp (r, expected) != 0) {
3292 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
3300 static int test_checksum_3 (void)
3302 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
3304 char device[] = "/dev/sda";
3305 device[5] = devchar;
3308 r = guestfs_blockdev_setrw (g, device);
3315 r = guestfs_umount_all (g);
3322 r = guestfs_lvm_remove_all (g);
3327 char device[] = "/dev/sda";
3328 device[5] = devchar;
3329 char lines_0[] = ",";
3336 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3341 char fstype[] = "ext2";
3342 char device[] = "/dev/sda1";
3343 device[5] = devchar;
3346 r = guestfs_mkfs (g, fstype, device);
3351 char device[] = "/dev/sda1";
3352 device[5] = devchar;
3353 char mountpoint[] = "/";
3356 r = guestfs_mount (g, device, mountpoint);
3360 /* TestOutput for checksum (3) */
3361 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
3363 char path[] = "/new";
3364 char content[] = "test\n";
3367 r = guestfs_write_file (g, path, content, 0);
3372 char csumtype[] = "sha1";
3373 char path[] = "/new";
3376 r = guestfs_checksum (g, csumtype, path);
3379 if (strcmp (r, expected) != 0) {
3380 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
3388 static int test_checksum_4 (void)
3390 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
3392 char device[] = "/dev/sda";
3393 device[5] = devchar;
3396 r = guestfs_blockdev_setrw (g, device);
3403 r = guestfs_umount_all (g);
3410 r = guestfs_lvm_remove_all (g);
3415 char device[] = "/dev/sda";
3416 device[5] = devchar;
3417 char lines_0[] = ",";
3424 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3429 char fstype[] = "ext2";
3430 char device[] = "/dev/sda1";
3431 device[5] = devchar;
3434 r = guestfs_mkfs (g, fstype, device);
3439 char device[] = "/dev/sda1";
3440 device[5] = devchar;
3441 char mountpoint[] = "/";
3444 r = guestfs_mount (g, device, mountpoint);
3448 /* TestOutput for checksum (4) */
3449 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
3451 char path[] = "/new";
3452 char content[] = "test\n";
3455 r = guestfs_write_file (g, path, content, 0);
3460 char csumtype[] = "sha224";
3461 char path[] = "/new";
3464 r = guestfs_checksum (g, csumtype, path);
3467 if (strcmp (r, expected) != 0) {
3468 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
3476 static int test_checksum_5 (void)
3478 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
3480 char device[] = "/dev/sda";
3481 device[5] = devchar;
3484 r = guestfs_blockdev_setrw (g, device);
3491 r = guestfs_umount_all (g);
3498 r = guestfs_lvm_remove_all (g);
3503 char device[] = "/dev/sda";
3504 device[5] = devchar;
3505 char lines_0[] = ",";
3512 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3517 char fstype[] = "ext2";
3518 char device[] = "/dev/sda1";
3519 device[5] = devchar;
3522 r = guestfs_mkfs (g, fstype, device);
3527 char device[] = "/dev/sda1";
3528 device[5] = devchar;
3529 char mountpoint[] = "/";
3532 r = guestfs_mount (g, device, mountpoint);
3536 /* TestOutput for checksum (5) */
3537 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
3539 char path[] = "/new";
3540 char content[] = "test\n";
3543 r = guestfs_write_file (g, path, content, 0);
3548 char csumtype[] = "sha256";
3549 char path[] = "/new";
3552 r = guestfs_checksum (g, csumtype, path);
3555 if (strcmp (r, expected) != 0) {
3556 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
3564 static int test_checksum_6 (void)
3566 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
3568 char device[] = "/dev/sda";
3569 device[5] = devchar;
3572 r = guestfs_blockdev_setrw (g, device);
3579 r = guestfs_umount_all (g);
3586 r = guestfs_lvm_remove_all (g);
3591 char device[] = "/dev/sda";
3592 device[5] = devchar;
3593 char lines_0[] = ",";
3600 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3605 char fstype[] = "ext2";
3606 char device[] = "/dev/sda1";
3607 device[5] = devchar;
3610 r = guestfs_mkfs (g, fstype, device);
3615 char device[] = "/dev/sda1";
3616 device[5] = devchar;
3617 char mountpoint[] = "/";
3620 r = guestfs_mount (g, device, mountpoint);
3624 /* TestOutput for checksum (6) */
3625 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
3627 char path[] = "/new";
3628 char content[] = "test\n";
3631 r = guestfs_write_file (g, path, content, 0);
3636 char csumtype[] = "sha384";
3637 char path[] = "/new";
3640 r = guestfs_checksum (g, csumtype, path);
3643 if (strcmp (r, expected) != 0) {
3644 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
3652 static int test_checksum_7 (void)
3654 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
3656 char device[] = "/dev/sda";
3657 device[5] = devchar;
3660 r = guestfs_blockdev_setrw (g, device);
3667 r = guestfs_umount_all (g);
3674 r = guestfs_lvm_remove_all (g);
3679 char device[] = "/dev/sda";
3680 device[5] = devchar;
3681 char lines_0[] = ",";
3688 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3693 char fstype[] = "ext2";
3694 char device[] = "/dev/sda1";
3695 device[5] = devchar;
3698 r = guestfs_mkfs (g, fstype, device);
3703 char device[] = "/dev/sda1";
3704 device[5] = devchar;
3705 char mountpoint[] = "/";
3708 r = guestfs_mount (g, device, mountpoint);
3712 /* TestOutput for checksum (7) */
3713 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
3715 char path[] = "/new";
3716 char content[] = "test\n";
3719 r = guestfs_write_file (g, path, content, 0);
3724 char csumtype[] = "sha512";
3725 char path[] = "/new";
3728 r = guestfs_checksum (g, csumtype, path);
3731 if (strcmp (r, expected) != 0) {
3732 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
3740 static int test_download_0 (void)
3742 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
3744 char device[] = "/dev/sda";
3745 device[5] = devchar;
3748 r = guestfs_blockdev_setrw (g, device);
3755 r = guestfs_umount_all (g);
3762 r = guestfs_lvm_remove_all (g);
3767 char device[] = "/dev/sda";
3768 device[5] = devchar;
3769 char lines_0[] = ",";
3776 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3781 char fstype[] = "ext2";
3782 char device[] = "/dev/sda1";
3783 device[5] = devchar;
3786 r = guestfs_mkfs (g, fstype, device);
3791 char device[] = "/dev/sda1";
3792 device[5] = devchar;
3793 char mountpoint[] = "/";
3796 r = guestfs_mount (g, device, mountpoint);
3800 /* TestOutput for download (0) */
3801 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
3803 char remotefilename[] = "/COPYING.LIB";
3806 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
3811 char remotefilename[] = "/COPYING.LIB";
3814 r = guestfs_download (g, remotefilename, "testdownload.tmp");
3819 char remotefilename[] = "/upload";
3822 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
3827 char csumtype[] = "md5";
3828 char path[] = "/upload";
3831 r = guestfs_checksum (g, csumtype, path);
3834 if (strcmp (r, expected) != 0) {
3835 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
3843 static int test_upload_0 (void)
3845 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
3847 char device[] = "/dev/sda";
3848 device[5] = devchar;
3851 r = guestfs_blockdev_setrw (g, device);
3858 r = guestfs_umount_all (g);
3865 r = guestfs_lvm_remove_all (g);
3870 char device[] = "/dev/sda";
3871 device[5] = devchar;
3872 char lines_0[] = ",";
3879 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3884 char fstype[] = "ext2";
3885 char device[] = "/dev/sda1";
3886 device[5] = devchar;
3889 r = guestfs_mkfs (g, fstype, device);
3894 char device[] = "/dev/sda1";
3895 device[5] = devchar;
3896 char mountpoint[] = "/";
3899 r = guestfs_mount (g, device, mountpoint);
3903 /* TestOutput for upload (0) */
3904 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
3906 char remotefilename[] = "/COPYING.LIB";
3909 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
3914 char csumtype[] = "md5";
3915 char path[] = "/COPYING.LIB";
3918 r = guestfs_checksum (g, csumtype, path);
3921 if (strcmp (r, expected) != 0) {
3922 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
3930 static int test_blockdev_rereadpt_0 (void)
3932 /* InitEmpty for blockdev_rereadpt (0) */
3934 char device[] = "/dev/sda";
3935 device[5] = devchar;
3938 r = guestfs_blockdev_setrw (g, device);
3945 r = guestfs_umount_all (g);
3952 r = guestfs_lvm_remove_all (g);
3956 /* TestRun for blockdev_rereadpt (0) */
3958 char device[] = "/dev/sda";
3959 device[5] = devchar;
3962 r = guestfs_blockdev_rereadpt (g, device);
3969 static int test_blockdev_flushbufs_0 (void)
3971 /* InitEmpty for blockdev_flushbufs (0) */
3973 char device[] = "/dev/sda";
3974 device[5] = devchar;
3977 r = guestfs_blockdev_setrw (g, device);
3984 r = guestfs_umount_all (g);
3991 r = guestfs_lvm_remove_all (g);
3995 /* TestRun for blockdev_flushbufs (0) */
3997 char device[] = "/dev/sda";
3998 device[5] = devchar;
4001 r = guestfs_blockdev_flushbufs (g, device);
4008 static int test_blockdev_getsize64_0 (void)
4010 /* InitEmpty for blockdev_getsize64 (0) */
4012 char device[] = "/dev/sda";
4013 device[5] = devchar;
4016 r = guestfs_blockdev_setrw (g, device);
4023 r = guestfs_umount_all (g);
4030 r = guestfs_lvm_remove_all (g);
4034 /* TestOutputInt for blockdev_getsize64 (0) */
4036 char device[] = "/dev/sda";
4037 device[5] = devchar;
4040 r = guestfs_blockdev_getsize64 (g, device);
4043 if (r != 524288000) {
4044 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
4051 static int test_blockdev_getsz_0 (void)
4053 /* InitEmpty for blockdev_getsz (0) */
4055 char device[] = "/dev/sda";
4056 device[5] = devchar;
4059 r = guestfs_blockdev_setrw (g, device);
4066 r = guestfs_umount_all (g);
4073 r = guestfs_lvm_remove_all (g);
4077 /* TestOutputInt for blockdev_getsz (0) */
4079 char device[] = "/dev/sda";
4080 device[5] = devchar;
4083 r = guestfs_blockdev_getsz (g, device);
4087 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
4094 static int test_blockdev_getbsz_0 (void)
4096 /* InitEmpty for blockdev_getbsz (0) */
4098 char device[] = "/dev/sda";
4099 device[5] = devchar;
4102 r = guestfs_blockdev_setrw (g, device);
4109 r = guestfs_umount_all (g);
4116 r = guestfs_lvm_remove_all (g);
4120 /* TestOutputInt for blockdev_getbsz (0) */
4122 char device[] = "/dev/sda";
4123 device[5] = devchar;
4126 r = guestfs_blockdev_getbsz (g, device);
4130 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
4137 static int test_blockdev_getss_0 (void)
4139 /* InitEmpty for blockdev_getss (0) */
4141 char device[] = "/dev/sda";
4142 device[5] = devchar;
4145 r = guestfs_blockdev_setrw (g, device);
4152 r = guestfs_umount_all (g);
4159 r = guestfs_lvm_remove_all (g);
4163 /* TestOutputInt for blockdev_getss (0) */
4165 char device[] = "/dev/sda";
4166 device[5] = devchar;
4169 r = guestfs_blockdev_getss (g, device);
4173 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
4180 static int test_blockdev_getro_0 (void)
4182 /* InitEmpty for blockdev_getro (0) */
4184 char device[] = "/dev/sda";
4185 device[5] = devchar;
4188 r = guestfs_blockdev_setrw (g, device);
4195 r = guestfs_umount_all (g);
4202 r = guestfs_lvm_remove_all (g);
4206 /* TestOutputTrue for blockdev_getro (0) */
4208 char device[] = "/dev/sda";
4209 device[5] = devchar;
4212 r = guestfs_blockdev_setro (g, device);
4217 char device[] = "/dev/sda";
4218 device[5] = devchar;
4221 r = guestfs_blockdev_getro (g, device);
4225 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
4232 static int test_blockdev_setrw_0 (void)
4234 /* InitEmpty for blockdev_setrw (0) */
4236 char device[] = "/dev/sda";
4237 device[5] = devchar;
4240 r = guestfs_blockdev_setrw (g, device);
4247 r = guestfs_umount_all (g);
4254 r = guestfs_lvm_remove_all (g);
4258 /* TestOutputFalse for blockdev_setrw (0) */
4260 char device[] = "/dev/sda";
4261 device[5] = devchar;
4264 r = guestfs_blockdev_setrw (g, device);
4269 char device[] = "/dev/sda";
4270 device[5] = devchar;
4273 r = guestfs_blockdev_getro (g, device);
4277 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
4284 static int test_blockdev_setro_0 (void)
4286 /* InitEmpty for blockdev_setro (0) */
4288 char device[] = "/dev/sda";
4289 device[5] = devchar;
4292 r = guestfs_blockdev_setrw (g, device);
4299 r = guestfs_umount_all (g);
4306 r = guestfs_lvm_remove_all (g);
4310 /* TestOutputTrue for blockdev_setro (0) */
4312 char device[] = "/dev/sda";
4313 device[5] = devchar;
4316 r = guestfs_blockdev_setro (g, device);
4321 char device[] = "/dev/sda";
4322 device[5] = devchar;
4325 r = guestfs_blockdev_getro (g, device);
4329 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
4336 static int test_statvfs_0 (void)
4338 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
4340 char device[] = "/dev/sda";
4341 device[5] = devchar;
4344 r = guestfs_blockdev_setrw (g, device);
4351 r = guestfs_umount_all (g);
4358 r = guestfs_lvm_remove_all (g);
4363 char device[] = "/dev/sda";
4364 device[5] = devchar;
4365 char lines_0[] = ",";
4372 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4377 char fstype[] = "ext2";
4378 char device[] = "/dev/sda1";
4379 device[5] = devchar;
4382 r = guestfs_mkfs (g, fstype, device);
4387 char device[] = "/dev/sda1";
4388 device[5] = devchar;
4389 char mountpoint[] = "/";
4392 r = guestfs_mount (g, device, mountpoint);
4396 /* TestOutputStruct for statvfs (0) */
4399 struct guestfs_statvfs *r;
4401 r = guestfs_statvfs (g, path);
4404 if (r->bfree != 487702) {
4405 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
4409 if (r->blocks != 490020) {
4410 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
4414 if (r->bsize != 1024) {
4415 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
4424 static int test_lstat_0 (void)
4426 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
4428 char device[] = "/dev/sda";
4429 device[5] = devchar;
4432 r = guestfs_blockdev_setrw (g, device);
4439 r = guestfs_umount_all (g);
4446 r = guestfs_lvm_remove_all (g);
4451 char device[] = "/dev/sda";
4452 device[5] = devchar;
4453 char lines_0[] = ",";
4460 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4465 char fstype[] = "ext2";
4466 char device[] = "/dev/sda1";
4467 device[5] = devchar;
4470 r = guestfs_mkfs (g, fstype, device);
4475 char device[] = "/dev/sda1";
4476 device[5] = devchar;
4477 char mountpoint[] = "/";
4480 r = guestfs_mount (g, device, mountpoint);
4484 /* TestOutputStruct for lstat (0) */
4486 char path[] = "/new";
4489 r = guestfs_touch (g, path);
4494 char path[] = "/new";
4495 struct guestfs_stat *r;
4497 r = guestfs_lstat (g, path);
4501 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
4510 static int test_stat_0 (void)
4512 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
4514 char device[] = "/dev/sda";
4515 device[5] = devchar;
4518 r = guestfs_blockdev_setrw (g, device);
4525 r = guestfs_umount_all (g);
4532 r = guestfs_lvm_remove_all (g);
4537 char device[] = "/dev/sda";
4538 device[5] = devchar;
4539 char lines_0[] = ",";
4546 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4551 char fstype[] = "ext2";
4552 char device[] = "/dev/sda1";
4553 device[5] = devchar;
4556 r = guestfs_mkfs (g, fstype, device);
4561 char device[] = "/dev/sda1";
4562 device[5] = devchar;
4563 char mountpoint[] = "/";
4566 r = guestfs_mount (g, device, mountpoint);
4570 /* TestOutputStruct for stat (0) */
4572 char path[] = "/new";
4575 r = guestfs_touch (g, path);
4580 char path[] = "/new";
4581 struct guestfs_stat *r;
4583 r = guestfs_stat (g, path);
4587 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
4596 static int test_file_0 (void)
4598 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
4600 char device[] = "/dev/sda";
4601 device[5] = devchar;
4604 r = guestfs_blockdev_setrw (g, device);
4611 r = guestfs_umount_all (g);
4618 r = guestfs_lvm_remove_all (g);
4623 char device[] = "/dev/sda";
4624 device[5] = devchar;
4625 char lines_0[] = ",";
4632 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4637 char fstype[] = "ext2";
4638 char device[] = "/dev/sda1";
4639 device[5] = devchar;
4642 r = guestfs_mkfs (g, fstype, device);
4647 char device[] = "/dev/sda1";
4648 device[5] = devchar;
4649 char mountpoint[] = "/";
4652 r = guestfs_mount (g, device, mountpoint);
4656 /* TestOutput for file (0) */
4657 char expected[] = "empty";
4659 char path[] = "/new";
4662 r = guestfs_touch (g, path);
4667 char path[] = "/new";
4670 r = guestfs_file (g, path);
4673 if (strcmp (r, expected) != 0) {
4674 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
4682 static int test_file_1 (void)
4684 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
4686 char device[] = "/dev/sda";
4687 device[5] = devchar;
4690 r = guestfs_blockdev_setrw (g, device);
4697 r = guestfs_umount_all (g);
4704 r = guestfs_lvm_remove_all (g);
4709 char device[] = "/dev/sda";
4710 device[5] = devchar;
4711 char lines_0[] = ",";
4718 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4723 char fstype[] = "ext2";
4724 char device[] = "/dev/sda1";
4725 device[5] = devchar;
4728 r = guestfs_mkfs (g, fstype, device);
4733 char device[] = "/dev/sda1";
4734 device[5] = devchar;
4735 char mountpoint[] = "/";
4738 r = guestfs_mount (g, device, mountpoint);
4742 /* TestOutput for file (1) */
4743 char expected[] = "ASCII text";
4745 char path[] = "/new";
4746 char content[] = "some content\n";
4749 r = guestfs_write_file (g, path, content, 0);
4754 char path[] = "/new";
4757 r = guestfs_file (g, path);
4760 if (strcmp (r, expected) != 0) {
4761 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
4769 static int test_file_2 (void)
4771 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
4773 char device[] = "/dev/sda";
4774 device[5] = devchar;
4777 r = guestfs_blockdev_setrw (g, device);
4784 r = guestfs_umount_all (g);
4791 r = guestfs_lvm_remove_all (g);
4796 char device[] = "/dev/sda";
4797 device[5] = devchar;
4798 char lines_0[] = ",";
4805 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4810 char fstype[] = "ext2";
4811 char device[] = "/dev/sda1";
4812 device[5] = devchar;
4815 r = guestfs_mkfs (g, fstype, device);
4820 char device[] = "/dev/sda1";
4821 device[5] = devchar;
4822 char mountpoint[] = "/";
4825 r = guestfs_mount (g, device, mountpoint);
4829 /* TestLastFail for file (2) */
4831 char path[] = "/nofile";
4834 r = guestfs_file (g, path);
4842 static int test_umount_all_0 (void)
4844 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
4846 char device[] = "/dev/sda";
4847 device[5] = devchar;
4850 r = guestfs_blockdev_setrw (g, device);
4857 r = guestfs_umount_all (g);
4864 r = guestfs_lvm_remove_all (g);
4869 char device[] = "/dev/sda";
4870 device[5] = devchar;
4871 char lines_0[] = ",";
4878 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4883 char fstype[] = "ext2";
4884 char device[] = "/dev/sda1";
4885 device[5] = devchar;
4888 r = guestfs_mkfs (g, fstype, device);
4893 char device[] = "/dev/sda1";
4894 device[5] = devchar;
4895 char mountpoint[] = "/";
4898 r = guestfs_mount (g, device, mountpoint);
4902 /* TestOutputList for umount_all (0) */
4906 r = guestfs_umount_all (g);
4914 r = guestfs_mounts (g);
4918 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
4922 for (i = 0; r[i] != NULL; ++i)
4929 static int test_umount_all_1 (void)
4931 /* InitEmpty for umount_all (1) */
4933 char device[] = "/dev/sda";
4934 device[5] = devchar;
4937 r = guestfs_blockdev_setrw (g, device);
4944 r = guestfs_umount_all (g);
4951 r = guestfs_lvm_remove_all (g);
4955 /* TestOutputList for umount_all (1) */
4957 char device[] = "/dev/sda";
4958 device[5] = devchar;
4959 char lines_0[] = ",10";
4960 char lines_1[] = ",20";
4961 char lines_2[] = ",";
4970 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4975 char fstype[] = "ext2";
4976 char device[] = "/dev/sda1";
4977 device[5] = devchar;
4980 r = guestfs_mkfs (g, fstype, device);
4985 char fstype[] = "ext2";
4986 char device[] = "/dev/sda2";
4987 device[5] = devchar;
4990 r = guestfs_mkfs (g, fstype, device);
4995 char fstype[] = "ext2";
4996 char device[] = "/dev/sda3";
4997 device[5] = devchar;
5000 r = guestfs_mkfs (g, fstype, device);
5005 char device[] = "/dev/sda1";
5006 device[5] = devchar;
5007 char mountpoint[] = "/";
5010 r = guestfs_mount (g, device, mountpoint);
5015 char path[] = "/mp1";
5018 r = guestfs_mkdir (g, path);
5023 char device[] = "/dev/sda2";
5024 device[5] = devchar;
5025 char mountpoint[] = "/mp1";
5028 r = guestfs_mount (g, device, mountpoint);
5033 char path[] = "/mp1/mp2";
5036 r = guestfs_mkdir (g, path);
5041 char device[] = "/dev/sda3";
5042 device[5] = devchar;
5043 char mountpoint[] = "/mp1/mp2";
5046 r = guestfs_mount (g, device, mountpoint);
5051 char path[] = "/mp1/mp2/mp3";
5054 r = guestfs_mkdir (g, path);
5061 r = guestfs_umount_all (g);
5069 r = guestfs_mounts (g);
5073 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
5077 for (i = 0; r[i] != NULL; ++i)
5084 static int test_mounts_0 (void)
5086 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
5088 char device[] = "/dev/sda";
5089 device[5] = devchar;
5092 r = guestfs_blockdev_setrw (g, device);
5099 r = guestfs_umount_all (g);
5106 r = guestfs_lvm_remove_all (g);
5111 char device[] = "/dev/sda";
5112 device[5] = devchar;
5113 char lines_0[] = ",";
5120 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5125 char fstype[] = "ext2";
5126 char device[] = "/dev/sda1";
5127 device[5] = devchar;
5130 r = guestfs_mkfs (g, fstype, device);
5135 char device[] = "/dev/sda1";
5136 device[5] = devchar;
5137 char mountpoint[] = "/";
5140 r = guestfs_mount (g, device, mountpoint);
5144 /* TestOutputList for mounts (0) */
5149 r = guestfs_mounts (g);
5153 fprintf (stderr, "test_mounts_0: short list returned from command\n");
5158 char expected[] = "/dev/sda1";
5159 expected[5] = devchar;
5160 if (strcmp (r[0], expected) != 0) {
5161 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5166 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
5170 for (i = 0; r[i] != NULL; ++i)
5177 static int test_umount_0 (void)
5179 /* InitEmpty for umount (0) */
5181 char device[] = "/dev/sda";
5182 device[5] = devchar;
5185 r = guestfs_blockdev_setrw (g, device);
5192 r = guestfs_umount_all (g);
5199 r = guestfs_lvm_remove_all (g);
5203 /* TestOutputList for umount (0) */
5205 char device[] = "/dev/sda";
5206 device[5] = devchar;
5207 char lines_0[] = ",";
5214 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5219 char fstype[] = "ext2";
5220 char device[] = "/dev/sda1";
5221 device[5] = devchar;
5224 r = guestfs_mkfs (g, fstype, device);
5229 char device[] = "/dev/sda1";
5230 device[5] = devchar;
5231 char mountpoint[] = "/";
5234 r = guestfs_mount (g, device, mountpoint);
5242 r = guestfs_mounts (g);
5246 fprintf (stderr, "test_umount_0: short list returned from command\n");
5251 char expected[] = "/dev/sda1";
5252 expected[5] = devchar;
5253 if (strcmp (r[0], expected) != 0) {
5254 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5259 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
5263 for (i = 0; r[i] != NULL; ++i)
5270 static int test_umount_1 (void)
5272 /* InitEmpty for umount (1) */
5274 char device[] = "/dev/sda";
5275 device[5] = devchar;
5278 r = guestfs_blockdev_setrw (g, device);
5285 r = guestfs_umount_all (g);
5292 r = guestfs_lvm_remove_all (g);
5296 /* TestOutputList for umount (1) */
5298 char device[] = "/dev/sda";
5299 device[5] = devchar;
5300 char lines_0[] = ",";
5307 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5312 char fstype[] = "ext2";
5313 char device[] = "/dev/sda1";
5314 device[5] = devchar;
5317 r = guestfs_mkfs (g, fstype, device);
5322 char device[] = "/dev/sda1";
5323 device[5] = devchar;
5324 char mountpoint[] = "/";
5327 r = guestfs_mount (g, device, mountpoint);
5332 char pathordevice[] = "/";
5335 r = guestfs_umount (g, pathordevice);
5343 r = guestfs_mounts (g);
5347 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
5351 for (i = 0; r[i] != NULL; ++i)
5358 static int test_write_file_0 (void)
5360 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
5362 char device[] = "/dev/sda";
5363 device[5] = devchar;
5366 r = guestfs_blockdev_setrw (g, device);
5373 r = guestfs_umount_all (g);
5380 r = guestfs_lvm_remove_all (g);
5385 char device[] = "/dev/sda";
5386 device[5] = devchar;
5387 char lines_0[] = ",";
5394 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5399 char fstype[] = "ext2";
5400 char device[] = "/dev/sda1";
5401 device[5] = devchar;
5404 r = guestfs_mkfs (g, fstype, device);
5409 char device[] = "/dev/sda1";
5410 device[5] = devchar;
5411 char mountpoint[] = "/";
5414 r = guestfs_mount (g, device, mountpoint);
5418 /* TestOutput for write_file (0) */
5419 char expected[] = "new file contents";
5421 char path[] = "/new";
5422 char content[] = "new file contents";
5425 r = guestfs_write_file (g, path, content, 0);
5430 char path[] = "/new";
5433 r = guestfs_cat (g, path);
5436 if (strcmp (r, expected) != 0) {
5437 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
5445 static int test_write_file_1 (void)
5447 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
5449 char device[] = "/dev/sda";
5450 device[5] = devchar;
5453 r = guestfs_blockdev_setrw (g, device);
5460 r = guestfs_umount_all (g);
5467 r = guestfs_lvm_remove_all (g);
5472 char device[] = "/dev/sda";
5473 device[5] = devchar;
5474 char lines_0[] = ",";
5481 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5486 char fstype[] = "ext2";
5487 char device[] = "/dev/sda1";
5488 device[5] = devchar;
5491 r = guestfs_mkfs (g, fstype, device);
5496 char device[] = "/dev/sda1";
5497 device[5] = devchar;
5498 char mountpoint[] = "/";
5501 r = guestfs_mount (g, device, mountpoint);
5505 /* TestOutput for write_file (1) */
5506 char expected[] = "\nnew file contents\n";
5508 char path[] = "/new";
5509 char content[] = "\nnew file contents\n";
5512 r = guestfs_write_file (g, path, content, 0);
5517 char path[] = "/new";
5520 r = guestfs_cat (g, path);
5523 if (strcmp (r, expected) != 0) {
5524 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5532 static int test_write_file_2 (void)
5534 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
5536 char device[] = "/dev/sda";
5537 device[5] = devchar;
5540 r = guestfs_blockdev_setrw (g, device);
5547 r = guestfs_umount_all (g);
5554 r = guestfs_lvm_remove_all (g);
5559 char device[] = "/dev/sda";
5560 device[5] = devchar;
5561 char lines_0[] = ",";
5568 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5573 char fstype[] = "ext2";
5574 char device[] = "/dev/sda1";
5575 device[5] = devchar;
5578 r = guestfs_mkfs (g, fstype, device);
5583 char device[] = "/dev/sda1";
5584 device[5] = devchar;
5585 char mountpoint[] = "/";
5588 r = guestfs_mount (g, device, mountpoint);
5592 /* TestOutput for write_file (2) */
5593 char expected[] = "\n\n";
5595 char path[] = "/new";
5596 char content[] = "\n\n";
5599 r = guestfs_write_file (g, path, content, 0);
5604 char path[] = "/new";
5607 r = guestfs_cat (g, path);
5610 if (strcmp (r, expected) != 0) {
5611 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
5619 static int test_write_file_3 (void)
5621 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
5623 char device[] = "/dev/sda";
5624 device[5] = devchar;
5627 r = guestfs_blockdev_setrw (g, device);
5634 r = guestfs_umount_all (g);
5641 r = guestfs_lvm_remove_all (g);
5646 char device[] = "/dev/sda";
5647 device[5] = devchar;
5648 char lines_0[] = ",";
5655 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5660 char fstype[] = "ext2";
5661 char device[] = "/dev/sda1";
5662 device[5] = devchar;
5665 r = guestfs_mkfs (g, fstype, device);
5670 char device[] = "/dev/sda1";
5671 device[5] = devchar;
5672 char mountpoint[] = "/";
5675 r = guestfs_mount (g, device, mountpoint);
5679 /* TestOutput for write_file (3) */
5680 char expected[] = "";
5682 char path[] = "/new";
5683 char content[] = "";
5686 r = guestfs_write_file (g, path, content, 0);
5691 char path[] = "/new";
5694 r = guestfs_cat (g, path);
5697 if (strcmp (r, expected) != 0) {
5698 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
5706 static int test_write_file_4 (void)
5708 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
5710 char device[] = "/dev/sda";
5711 device[5] = devchar;
5714 r = guestfs_blockdev_setrw (g, device);
5721 r = guestfs_umount_all (g);
5728 r = guestfs_lvm_remove_all (g);
5733 char device[] = "/dev/sda";
5734 device[5] = devchar;
5735 char lines_0[] = ",";
5742 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5747 char fstype[] = "ext2";
5748 char device[] = "/dev/sda1";
5749 device[5] = devchar;
5752 r = guestfs_mkfs (g, fstype, device);
5757 char device[] = "/dev/sda1";
5758 device[5] = devchar;
5759 char mountpoint[] = "/";
5762 r = guestfs_mount (g, device, mountpoint);
5766 /* TestOutput for write_file (4) */
5767 char expected[] = "\n\n\n";
5769 char path[] = "/new";
5770 char content[] = "\n\n\n";
5773 r = guestfs_write_file (g, path, content, 0);
5778 char path[] = "/new";
5781 r = guestfs_cat (g, path);
5784 if (strcmp (r, expected) != 0) {
5785 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
5793 static int test_write_file_5 (void)
5795 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
5797 char device[] = "/dev/sda";
5798 device[5] = devchar;
5801 r = guestfs_blockdev_setrw (g, device);
5808 r = guestfs_umount_all (g);
5815 r = guestfs_lvm_remove_all (g);
5820 char device[] = "/dev/sda";
5821 device[5] = devchar;
5822 char lines_0[] = ",";
5829 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5834 char fstype[] = "ext2";
5835 char device[] = "/dev/sda1";
5836 device[5] = devchar;
5839 r = guestfs_mkfs (g, fstype, device);
5844 char device[] = "/dev/sda1";
5845 device[5] = devchar;
5846 char mountpoint[] = "/";
5849 r = guestfs_mount (g, device, mountpoint);
5853 /* TestOutput for write_file (5) */
5854 char expected[] = "\n";
5856 char path[] = "/new";
5857 char content[] = "\n";
5860 r = guestfs_write_file (g, path, content, 0);
5865 char path[] = "/new";
5868 r = guestfs_cat (g, path);
5871 if (strcmp (r, expected) != 0) {
5872 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
5880 static int test_mkfs_0 (void)
5882 /* InitEmpty for mkfs (0) */
5884 char device[] = "/dev/sda";
5885 device[5] = devchar;
5888 r = guestfs_blockdev_setrw (g, device);
5895 r = guestfs_umount_all (g);
5902 r = guestfs_lvm_remove_all (g);
5906 /* TestOutput for mkfs (0) */
5907 char expected[] = "new file contents";
5909 char device[] = "/dev/sda";
5910 device[5] = devchar;
5911 char lines_0[] = ",";
5918 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5923 char fstype[] = "ext2";
5924 char device[] = "/dev/sda1";
5925 device[5] = devchar;
5928 r = guestfs_mkfs (g, fstype, device);
5933 char device[] = "/dev/sda1";
5934 device[5] = devchar;
5935 char mountpoint[] = "/";
5938 r = guestfs_mount (g, device, mountpoint);
5943 char path[] = "/new";
5944 char content[] = "new file contents";
5947 r = guestfs_write_file (g, path, content, 0);
5952 char path[] = "/new";
5955 r = guestfs_cat (g, path);
5958 if (strcmp (r, expected) != 0) {
5959 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
5967 static int test_lvcreate_0 (void)
5969 /* InitEmpty for lvcreate (0) */
5971 char device[] = "/dev/sda";
5972 device[5] = devchar;
5975 r = guestfs_blockdev_setrw (g, device);
5982 r = guestfs_umount_all (g);
5989 r = guestfs_lvm_remove_all (g);
5993 /* TestOutputList for lvcreate (0) */
5995 char device[] = "/dev/sda";
5996 device[5] = devchar;
5997 char lines_0[] = ",10";
5998 char lines_1[] = ",20";
5999 char lines_2[] = ",";
6008 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6013 char device[] = "/dev/sda1";
6014 device[5] = devchar;
6017 r = guestfs_pvcreate (g, device);
6022 char device[] = "/dev/sda2";
6023 device[5] = devchar;
6026 r = guestfs_pvcreate (g, device);
6031 char device[] = "/dev/sda3";
6032 device[5] = devchar;
6035 r = guestfs_pvcreate (g, device);
6040 char volgroup[] = "VG1";
6041 char physvols_0[] = "/dev/sda1";
6042 physvols_0[5] = devchar;
6043 char physvols_1[] = "/dev/sda2";
6044 physvols_1[5] = devchar;
6045 char *physvols[] = {
6052 r = guestfs_vgcreate (g, volgroup, physvols);
6057 char volgroup[] = "VG2";
6058 char physvols_0[] = "/dev/sda3";
6059 physvols_0[5] = devchar;
6060 char *physvols[] = {
6066 r = guestfs_vgcreate (g, volgroup, physvols);
6071 char logvol[] = "LV1";
6072 char volgroup[] = "VG1";
6075 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6080 char logvol[] = "LV2";
6081 char volgroup[] = "VG1";
6084 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6089 char logvol[] = "LV3";
6090 char volgroup[] = "VG2";
6093 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6098 char logvol[] = "LV4";
6099 char volgroup[] = "VG2";
6102 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6107 char logvol[] = "LV5";
6108 char volgroup[] = "VG2";
6111 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6119 r = guestfs_lvs (g);
6123 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6128 char expected[] = "/dev/VG1/LV1";
6129 if (strcmp (r[0], expected) != 0) {
6130 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6135 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6140 char expected[] = "/dev/VG1/LV2";
6141 if (strcmp (r[1], expected) != 0) {
6142 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6147 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6152 char expected[] = "/dev/VG2/LV3";
6153 if (strcmp (r[2], expected) != 0) {
6154 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6159 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6164 char expected[] = "/dev/VG2/LV4";
6165 if (strcmp (r[3], expected) != 0) {
6166 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
6171 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6176 char expected[] = "/dev/VG2/LV5";
6177 if (strcmp (r[4], expected) != 0) {
6178 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
6183 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
6187 for (i = 0; r[i] != NULL; ++i)
6194 static int test_vgcreate_0 (void)
6196 /* InitEmpty for vgcreate (0) */
6198 char device[] = "/dev/sda";
6199 device[5] = devchar;
6202 r = guestfs_blockdev_setrw (g, device);
6209 r = guestfs_umount_all (g);
6216 r = guestfs_lvm_remove_all (g);
6220 /* TestOutputList for vgcreate (0) */
6222 char device[] = "/dev/sda";
6223 device[5] = devchar;
6224 char lines_0[] = ",10";
6225 char lines_1[] = ",20";
6226 char lines_2[] = ",";
6235 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6240 char device[] = "/dev/sda1";
6241 device[5] = devchar;
6244 r = guestfs_pvcreate (g, device);
6249 char device[] = "/dev/sda2";
6250 device[5] = devchar;
6253 r = guestfs_pvcreate (g, device);
6258 char device[] = "/dev/sda3";
6259 device[5] = devchar;
6262 r = guestfs_pvcreate (g, device);
6267 char volgroup[] = "VG1";
6268 char physvols_0[] = "/dev/sda1";
6269 physvols_0[5] = devchar;
6270 char physvols_1[] = "/dev/sda2";
6271 physvols_1[5] = devchar;
6272 char *physvols[] = {
6279 r = guestfs_vgcreate (g, volgroup, physvols);
6284 char volgroup[] = "VG2";
6285 char physvols_0[] = "/dev/sda3";
6286 physvols_0[5] = devchar;
6287 char *physvols[] = {
6293 r = guestfs_vgcreate (g, volgroup, physvols);
6301 r = guestfs_vgs (g);
6305 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6310 char expected[] = "VG1";
6311 if (strcmp (r[0], expected) != 0) {
6312 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6317 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6322 char expected[] = "VG2";
6323 if (strcmp (r[1], expected) != 0) {
6324 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6329 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
6333 for (i = 0; r[i] != NULL; ++i)
6340 static int test_pvcreate_0 (void)
6342 /* InitEmpty for pvcreate (0) */
6344 char device[] = "/dev/sda";
6345 device[5] = devchar;
6348 r = guestfs_blockdev_setrw (g, device);
6355 r = guestfs_umount_all (g);
6362 r = guestfs_lvm_remove_all (g);
6366 /* TestOutputList for pvcreate (0) */
6368 char device[] = "/dev/sda";
6369 device[5] = devchar;
6370 char lines_0[] = ",10";
6371 char lines_1[] = ",20";
6372 char lines_2[] = ",";
6381 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6386 char device[] = "/dev/sda1";
6387 device[5] = devchar;
6390 r = guestfs_pvcreate (g, device);
6395 char device[] = "/dev/sda2";
6396 device[5] = devchar;
6399 r = guestfs_pvcreate (g, device);
6404 char device[] = "/dev/sda3";
6405 device[5] = devchar;
6408 r = guestfs_pvcreate (g, device);
6416 r = guestfs_pvs (g);
6420 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6425 char expected[] = "/dev/sda1";
6426 expected[5] = devchar;
6427 if (strcmp (r[0], expected) != 0) {
6428 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6433 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6438 char expected[] = "/dev/sda2";
6439 expected[5] = devchar;
6440 if (strcmp (r[1], expected) != 0) {
6441 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6446 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6451 char expected[] = "/dev/sda3";
6452 expected[5] = devchar;
6453 if (strcmp (r[2], expected) != 0) {
6454 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6459 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
6463 for (i = 0; r[i] != NULL; ++i)
6470 static int test_is_dir_0 (void)
6472 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
6474 char device[] = "/dev/sda";
6475 device[5] = devchar;
6478 r = guestfs_blockdev_setrw (g, device);
6485 r = guestfs_umount_all (g);
6492 r = guestfs_lvm_remove_all (g);
6497 char device[] = "/dev/sda";
6498 device[5] = devchar;
6499 char lines_0[] = ",";
6506 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6511 char fstype[] = "ext2";
6512 char device[] = "/dev/sda1";
6513 device[5] = devchar;
6516 r = guestfs_mkfs (g, fstype, device);
6521 char device[] = "/dev/sda1";
6522 device[5] = devchar;
6523 char mountpoint[] = "/";
6526 r = guestfs_mount (g, device, mountpoint);
6530 /* TestOutputFalse for is_dir (0) */
6532 char path[] = "/new";
6535 r = guestfs_touch (g, path);
6540 char path[] = "/new";
6543 r = guestfs_is_dir (g, path);
6547 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
6554 static int test_is_dir_1 (void)
6556 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
6558 char device[] = "/dev/sda";
6559 device[5] = devchar;
6562 r = guestfs_blockdev_setrw (g, device);
6569 r = guestfs_umount_all (g);
6576 r = guestfs_lvm_remove_all (g);
6581 char device[] = "/dev/sda";
6582 device[5] = devchar;
6583 char lines_0[] = ",";
6590 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6595 char fstype[] = "ext2";
6596 char device[] = "/dev/sda1";
6597 device[5] = devchar;
6600 r = guestfs_mkfs (g, fstype, device);
6605 char device[] = "/dev/sda1";
6606 device[5] = devchar;
6607 char mountpoint[] = "/";
6610 r = guestfs_mount (g, device, mountpoint);
6614 /* TestOutputTrue for is_dir (1) */
6616 char path[] = "/new";
6619 r = guestfs_mkdir (g, path);
6624 char path[] = "/new";
6627 r = guestfs_is_dir (g, path);
6631 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
6638 static int test_is_file_0 (void)
6640 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
6642 char device[] = "/dev/sda";
6643 device[5] = devchar;
6646 r = guestfs_blockdev_setrw (g, device);
6653 r = guestfs_umount_all (g);
6660 r = guestfs_lvm_remove_all (g);
6665 char device[] = "/dev/sda";
6666 device[5] = devchar;
6667 char lines_0[] = ",";
6674 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6679 char fstype[] = "ext2";
6680 char device[] = "/dev/sda1";
6681 device[5] = devchar;
6684 r = guestfs_mkfs (g, fstype, device);
6689 char device[] = "/dev/sda1";
6690 device[5] = devchar;
6691 char mountpoint[] = "/";
6694 r = guestfs_mount (g, device, mountpoint);
6698 /* TestOutputTrue for is_file (0) */
6700 char path[] = "/new";
6703 r = guestfs_touch (g, path);
6708 char path[] = "/new";
6711 r = guestfs_is_file (g, path);
6715 fprintf (stderr, "test_is_file_0: expected true, got false\n");
6722 static int test_is_file_1 (void)
6724 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
6726 char device[] = "/dev/sda";
6727 device[5] = devchar;
6730 r = guestfs_blockdev_setrw (g, device);
6737 r = guestfs_umount_all (g);
6744 r = guestfs_lvm_remove_all (g);
6749 char device[] = "/dev/sda";
6750 device[5] = devchar;
6751 char lines_0[] = ",";
6758 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6763 char fstype[] = "ext2";
6764 char device[] = "/dev/sda1";
6765 device[5] = devchar;
6768 r = guestfs_mkfs (g, fstype, device);
6773 char device[] = "/dev/sda1";
6774 device[5] = devchar;
6775 char mountpoint[] = "/";
6778 r = guestfs_mount (g, device, mountpoint);
6782 /* TestOutputFalse for is_file (1) */
6784 char path[] = "/new";
6787 r = guestfs_mkdir (g, path);
6792 char path[] = "/new";
6795 r = guestfs_is_file (g, path);
6799 fprintf (stderr, "test_is_file_1: expected false, got true\n");
6806 static int test_exists_0 (void)
6808 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
6810 char device[] = "/dev/sda";
6811 device[5] = devchar;
6814 r = guestfs_blockdev_setrw (g, device);
6821 r = guestfs_umount_all (g);
6828 r = guestfs_lvm_remove_all (g);
6833 char device[] = "/dev/sda";
6834 device[5] = devchar;
6835 char lines_0[] = ",";
6842 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6847 char fstype[] = "ext2";
6848 char device[] = "/dev/sda1";
6849 device[5] = devchar;
6852 r = guestfs_mkfs (g, fstype, device);
6857 char device[] = "/dev/sda1";
6858 device[5] = devchar;
6859 char mountpoint[] = "/";
6862 r = guestfs_mount (g, device, mountpoint);
6866 /* TestOutputTrue for exists (0) */
6868 char path[] = "/new";
6871 r = guestfs_touch (g, path);
6876 char path[] = "/new";
6879 r = guestfs_exists (g, path);
6883 fprintf (stderr, "test_exists_0: expected true, got false\n");
6890 static int test_exists_1 (void)
6892 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
6894 char device[] = "/dev/sda";
6895 device[5] = devchar;
6898 r = guestfs_blockdev_setrw (g, device);
6905 r = guestfs_umount_all (g);
6912 r = guestfs_lvm_remove_all (g);
6917 char device[] = "/dev/sda";
6918 device[5] = devchar;
6919 char lines_0[] = ",";
6926 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6931 char fstype[] = "ext2";
6932 char device[] = "/dev/sda1";
6933 device[5] = devchar;
6936 r = guestfs_mkfs (g, fstype, device);
6941 char device[] = "/dev/sda1";
6942 device[5] = devchar;
6943 char mountpoint[] = "/";
6946 r = guestfs_mount (g, device, mountpoint);
6950 /* TestOutputTrue for exists (1) */
6952 char path[] = "/new";
6955 r = guestfs_mkdir (g, path);
6960 char path[] = "/new";
6963 r = guestfs_exists (g, path);
6967 fprintf (stderr, "test_exists_1: expected true, got false\n");
6974 static int test_mkdir_p_0 (void)
6976 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
6978 char device[] = "/dev/sda";
6979 device[5] = devchar;
6982 r = guestfs_blockdev_setrw (g, device);
6989 r = guestfs_umount_all (g);
6996 r = guestfs_lvm_remove_all (g);
7001 char device[] = "/dev/sda";
7002 device[5] = devchar;
7003 char lines_0[] = ",";
7010 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7015 char fstype[] = "ext2";
7016 char device[] = "/dev/sda1";
7017 device[5] = devchar;
7020 r = guestfs_mkfs (g, fstype, device);
7025 char device[] = "/dev/sda1";
7026 device[5] = devchar;
7027 char mountpoint[] = "/";
7030 r = guestfs_mount (g, device, mountpoint);
7034 /* TestOutputTrue for mkdir_p (0) */
7036 char path[] = "/new/foo/bar";
7039 r = guestfs_mkdir_p (g, path);
7044 char path[] = "/new/foo/bar";
7047 r = guestfs_is_dir (g, path);
7051 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
7058 static int test_mkdir_p_1 (void)
7060 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
7062 char device[] = "/dev/sda";
7063 device[5] = devchar;
7066 r = guestfs_blockdev_setrw (g, device);
7073 r = guestfs_umount_all (g);
7080 r = guestfs_lvm_remove_all (g);
7085 char device[] = "/dev/sda";
7086 device[5] = devchar;
7087 char lines_0[] = ",";
7094 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7099 char fstype[] = "ext2";
7100 char device[] = "/dev/sda1";
7101 device[5] = devchar;
7104 r = guestfs_mkfs (g, fstype, device);
7109 char device[] = "/dev/sda1";
7110 device[5] = devchar;
7111 char mountpoint[] = "/";
7114 r = guestfs_mount (g, device, mountpoint);
7118 /* TestOutputTrue for mkdir_p (1) */
7120 char path[] = "/new/foo/bar";
7123 r = guestfs_mkdir_p (g, path);
7128 char path[] = "/new/foo";
7131 r = guestfs_is_dir (g, path);
7135 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
7142 static int test_mkdir_p_2 (void)
7144 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
7146 char device[] = "/dev/sda";
7147 device[5] = devchar;
7150 r = guestfs_blockdev_setrw (g, device);
7157 r = guestfs_umount_all (g);
7164 r = guestfs_lvm_remove_all (g);
7169 char device[] = "/dev/sda";
7170 device[5] = devchar;
7171 char lines_0[] = ",";
7178 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7183 char fstype[] = "ext2";
7184 char device[] = "/dev/sda1";
7185 device[5] = devchar;
7188 r = guestfs_mkfs (g, fstype, device);
7193 char device[] = "/dev/sda1";
7194 device[5] = devchar;
7195 char mountpoint[] = "/";
7198 r = guestfs_mount (g, device, mountpoint);
7202 /* TestOutputTrue for mkdir_p (2) */
7204 char path[] = "/new/foo/bar";
7207 r = guestfs_mkdir_p (g, path);
7212 char path[] = "/new";
7215 r = guestfs_is_dir (g, path);
7219 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
7226 static int test_mkdir_0 (void)
7228 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
7230 char device[] = "/dev/sda";
7231 device[5] = devchar;
7234 r = guestfs_blockdev_setrw (g, device);
7241 r = guestfs_umount_all (g);
7248 r = guestfs_lvm_remove_all (g);
7253 char device[] = "/dev/sda";
7254 device[5] = devchar;
7255 char lines_0[] = ",";
7262 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7267 char fstype[] = "ext2";
7268 char device[] = "/dev/sda1";
7269 device[5] = devchar;
7272 r = guestfs_mkfs (g, fstype, device);
7277 char device[] = "/dev/sda1";
7278 device[5] = devchar;
7279 char mountpoint[] = "/";
7282 r = guestfs_mount (g, device, mountpoint);
7286 /* TestOutputTrue for mkdir (0) */
7288 char path[] = "/new";
7291 r = guestfs_mkdir (g, path);
7296 char path[] = "/new";
7299 r = guestfs_is_dir (g, path);
7303 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
7310 static int test_mkdir_1 (void)
7312 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
7314 char device[] = "/dev/sda";
7315 device[5] = devchar;
7318 r = guestfs_blockdev_setrw (g, device);
7325 r = guestfs_umount_all (g);
7332 r = guestfs_lvm_remove_all (g);
7337 char device[] = "/dev/sda";
7338 device[5] = devchar;
7339 char lines_0[] = ",";
7346 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7351 char fstype[] = "ext2";
7352 char device[] = "/dev/sda1";
7353 device[5] = devchar;
7356 r = guestfs_mkfs (g, fstype, device);
7361 char device[] = "/dev/sda1";
7362 device[5] = devchar;
7363 char mountpoint[] = "/";
7366 r = guestfs_mount (g, device, mountpoint);
7370 /* TestLastFail for mkdir (1) */
7372 char path[] = "/new/foo/bar";
7375 r = guestfs_mkdir (g, path);
7382 static int test_rm_rf_0 (void)
7384 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
7386 char device[] = "/dev/sda";
7387 device[5] = devchar;
7390 r = guestfs_blockdev_setrw (g, device);
7397 r = guestfs_umount_all (g);
7404 r = guestfs_lvm_remove_all (g);
7409 char device[] = "/dev/sda";
7410 device[5] = devchar;
7411 char lines_0[] = ",";
7418 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7423 char fstype[] = "ext2";
7424 char device[] = "/dev/sda1";
7425 device[5] = devchar;
7428 r = guestfs_mkfs (g, fstype, device);
7433 char device[] = "/dev/sda1";
7434 device[5] = devchar;
7435 char mountpoint[] = "/";
7438 r = guestfs_mount (g, device, mountpoint);
7442 /* TestOutputFalse for rm_rf (0) */
7444 char path[] = "/new";
7447 r = guestfs_mkdir (g, path);
7452 char path[] = "/new/foo";
7455 r = guestfs_mkdir (g, path);
7460 char path[] = "/new/foo/bar";
7463 r = guestfs_touch (g, path);
7468 char path[] = "/new";
7471 r = guestfs_rm_rf (g, path);
7476 char path[] = "/new";
7479 r = guestfs_exists (g, path);
7483 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
7490 static int test_rmdir_0 (void)
7492 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
7494 char device[] = "/dev/sda";
7495 device[5] = devchar;
7498 r = guestfs_blockdev_setrw (g, device);
7505 r = guestfs_umount_all (g);
7512 r = guestfs_lvm_remove_all (g);
7517 char device[] = "/dev/sda";
7518 device[5] = devchar;
7519 char lines_0[] = ",";
7526 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7531 char fstype[] = "ext2";
7532 char device[] = "/dev/sda1";
7533 device[5] = devchar;
7536 r = guestfs_mkfs (g, fstype, device);
7541 char device[] = "/dev/sda1";
7542 device[5] = devchar;
7543 char mountpoint[] = "/";
7546 r = guestfs_mount (g, device, mountpoint);
7550 /* TestRun for rmdir (0) */
7552 char path[] = "/new";
7555 r = guestfs_mkdir (g, path);
7560 char path[] = "/new";
7563 r = guestfs_rmdir (g, path);
7570 static int test_rmdir_1 (void)
7572 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
7574 char device[] = "/dev/sda";
7575 device[5] = devchar;
7578 r = guestfs_blockdev_setrw (g, device);
7585 r = guestfs_umount_all (g);
7592 r = guestfs_lvm_remove_all (g);
7597 char device[] = "/dev/sda";
7598 device[5] = devchar;
7599 char lines_0[] = ",";
7606 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7611 char fstype[] = "ext2";
7612 char device[] = "/dev/sda1";
7613 device[5] = devchar;
7616 r = guestfs_mkfs (g, fstype, device);
7621 char device[] = "/dev/sda1";
7622 device[5] = devchar;
7623 char mountpoint[] = "/";
7626 r = guestfs_mount (g, device, mountpoint);
7630 /* TestLastFail for rmdir (1) */
7632 char path[] = "/new";
7635 r = guestfs_rmdir (g, path);
7642 static int test_rmdir_2 (void)
7644 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
7646 char device[] = "/dev/sda";
7647 device[5] = devchar;
7650 r = guestfs_blockdev_setrw (g, device);
7657 r = guestfs_umount_all (g);
7664 r = guestfs_lvm_remove_all (g);
7669 char device[] = "/dev/sda";
7670 device[5] = devchar;
7671 char lines_0[] = ",";
7678 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7683 char fstype[] = "ext2";
7684 char device[] = "/dev/sda1";
7685 device[5] = devchar;
7688 r = guestfs_mkfs (g, fstype, device);
7693 char device[] = "/dev/sda1";
7694 device[5] = devchar;
7695 char mountpoint[] = "/";
7698 r = guestfs_mount (g, device, mountpoint);
7702 /* TestLastFail for rmdir (2) */
7704 char path[] = "/new";
7707 r = guestfs_touch (g, path);
7712 char path[] = "/new";
7715 r = guestfs_rmdir (g, path);
7722 static int test_rm_0 (void)
7724 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
7726 char device[] = "/dev/sda";
7727 device[5] = devchar;
7730 r = guestfs_blockdev_setrw (g, device);
7737 r = guestfs_umount_all (g);
7744 r = guestfs_lvm_remove_all (g);
7749 char device[] = "/dev/sda";
7750 device[5] = devchar;
7751 char lines_0[] = ",";
7758 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7763 char fstype[] = "ext2";
7764 char device[] = "/dev/sda1";
7765 device[5] = devchar;
7768 r = guestfs_mkfs (g, fstype, device);
7773 char device[] = "/dev/sda1";
7774 device[5] = devchar;
7775 char mountpoint[] = "/";
7778 r = guestfs_mount (g, device, mountpoint);
7782 /* TestRun for rm (0) */
7784 char path[] = "/new";
7787 r = guestfs_touch (g, path);
7792 char path[] = "/new";
7795 r = guestfs_rm (g, path);
7802 static int test_rm_1 (void)
7804 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
7806 char device[] = "/dev/sda";
7807 device[5] = devchar;
7810 r = guestfs_blockdev_setrw (g, device);
7817 r = guestfs_umount_all (g);
7824 r = guestfs_lvm_remove_all (g);
7829 char device[] = "/dev/sda";
7830 device[5] = devchar;
7831 char lines_0[] = ",";
7838 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7843 char fstype[] = "ext2";
7844 char device[] = "/dev/sda1";
7845 device[5] = devchar;
7848 r = guestfs_mkfs (g, fstype, device);
7853 char device[] = "/dev/sda1";
7854 device[5] = devchar;
7855 char mountpoint[] = "/";
7858 r = guestfs_mount (g, device, mountpoint);
7862 /* TestLastFail for rm (1) */
7864 char path[] = "/new";
7867 r = guestfs_rm (g, path);
7874 static int test_rm_2 (void)
7876 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
7878 char device[] = "/dev/sda";
7879 device[5] = devchar;
7882 r = guestfs_blockdev_setrw (g, device);
7889 r = guestfs_umount_all (g);
7896 r = guestfs_lvm_remove_all (g);
7901 char device[] = "/dev/sda";
7902 device[5] = devchar;
7903 char lines_0[] = ",";
7910 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7915 char fstype[] = "ext2";
7916 char device[] = "/dev/sda1";
7917 device[5] = devchar;
7920 r = guestfs_mkfs (g, fstype, device);
7925 char device[] = "/dev/sda1";
7926 device[5] = devchar;
7927 char mountpoint[] = "/";
7930 r = guestfs_mount (g, device, mountpoint);
7934 /* TestLastFail for rm (2) */
7936 char path[] = "/new";
7939 r = guestfs_mkdir (g, path);
7944 char path[] = "/new";
7947 r = guestfs_rm (g, path);
7954 static int test_read_lines_0 (void)
7956 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
7958 char device[] = "/dev/sda";
7959 device[5] = devchar;
7962 r = guestfs_blockdev_setrw (g, device);
7969 r = guestfs_umount_all (g);
7976 r = guestfs_lvm_remove_all (g);
7981 char device[] = "/dev/sda";
7982 device[5] = devchar;
7983 char lines_0[] = ",";
7990 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7995 char fstype[] = "ext2";
7996 char device[] = "/dev/sda1";
7997 device[5] = devchar;
8000 r = guestfs_mkfs (g, fstype, device);
8005 char device[] = "/dev/sda1";
8006 device[5] = devchar;
8007 char mountpoint[] = "/";
8010 r = guestfs_mount (g, device, mountpoint);
8014 /* TestOutputList for read_lines (0) */
8016 char path[] = "/new";
8017 char content[] = "line1\r\nline2\nline3";
8020 r = guestfs_write_file (g, path, content, 0);
8025 char path[] = "/new";
8029 r = guestfs_read_lines (g, path);
8033 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8038 char expected[] = "line1";
8039 if (strcmp (r[0], expected) != 0) {
8040 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8045 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8050 char expected[] = "line2";
8051 if (strcmp (r[1], expected) != 0) {
8052 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8057 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8062 char expected[] = "line3";
8063 if (strcmp (r[2], expected) != 0) {
8064 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8069 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
8073 for (i = 0; r[i] != NULL; ++i)
8080 static int test_read_lines_1 (void)
8082 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
8084 char device[] = "/dev/sda";
8085 device[5] = devchar;
8088 r = guestfs_blockdev_setrw (g, device);
8095 r = guestfs_umount_all (g);
8102 r = guestfs_lvm_remove_all (g);
8107 char device[] = "/dev/sda";
8108 device[5] = devchar;
8109 char lines_0[] = ",";
8116 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8121 char fstype[] = "ext2";
8122 char device[] = "/dev/sda1";
8123 device[5] = devchar;
8126 r = guestfs_mkfs (g, fstype, device);
8131 char device[] = "/dev/sda1";
8132 device[5] = devchar;
8133 char mountpoint[] = "/";
8136 r = guestfs_mount (g, device, mountpoint);
8140 /* TestOutputList for read_lines (1) */
8142 char path[] = "/new";
8143 char content[] = "";
8146 r = guestfs_write_file (g, path, content, 0);
8151 char path[] = "/new";
8155 r = guestfs_read_lines (g, path);
8159 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
8163 for (i = 0; r[i] != NULL; ++i)
8170 static int test_lvs_0 (void)
8172 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
8174 char device[] = "/dev/sda";
8175 device[5] = devchar;
8178 r = guestfs_blockdev_setrw (g, device);
8185 r = guestfs_umount_all (g);
8192 r = guestfs_lvm_remove_all (g);
8197 char device[] = "/dev/sda";
8198 device[5] = devchar;
8199 char lines_0[] = ",";
8206 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8211 char device[] = "/dev/sda1";
8212 device[5] = devchar;
8215 r = guestfs_pvcreate (g, device);
8220 char volgroup[] = "VG";
8221 char physvols_0[] = "/dev/sda1";
8222 physvols_0[5] = devchar;
8223 char *physvols[] = {
8229 r = guestfs_vgcreate (g, volgroup, physvols);
8234 char logvol[] = "LV";
8235 char volgroup[] = "VG";
8238 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8243 char fstype[] = "ext2";
8244 char device[] = "/dev/VG/LV";
8247 r = guestfs_mkfs (g, fstype, device);
8252 char device[] = "/dev/VG/LV";
8253 char mountpoint[] = "/";
8256 r = guestfs_mount (g, device, mountpoint);
8260 /* TestOutputList for lvs (0) */
8265 r = guestfs_lvs (g);
8269 fprintf (stderr, "test_lvs_0: short list returned from command\n");
8274 char expected[] = "/dev/VG/LV";
8275 if (strcmp (r[0], expected) != 0) {
8276 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8281 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
8285 for (i = 0; r[i] != NULL; ++i)
8292 static int test_lvs_1 (void)
8294 /* InitEmpty for lvs (1) */
8296 char device[] = "/dev/sda";
8297 device[5] = devchar;
8300 r = guestfs_blockdev_setrw (g, device);
8307 r = guestfs_umount_all (g);
8314 r = guestfs_lvm_remove_all (g);
8318 /* TestOutputList for lvs (1) */
8320 char device[] = "/dev/sda";
8321 device[5] = devchar;
8322 char lines_0[] = ",10";
8323 char lines_1[] = ",20";
8324 char lines_2[] = ",";
8333 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8338 char device[] = "/dev/sda1";
8339 device[5] = devchar;
8342 r = guestfs_pvcreate (g, device);
8347 char device[] = "/dev/sda2";
8348 device[5] = devchar;
8351 r = guestfs_pvcreate (g, device);
8356 char device[] = "/dev/sda3";
8357 device[5] = devchar;
8360 r = guestfs_pvcreate (g, device);
8365 char volgroup[] = "VG1";
8366 char physvols_0[] = "/dev/sda1";
8367 physvols_0[5] = devchar;
8368 char physvols_1[] = "/dev/sda2";
8369 physvols_1[5] = devchar;
8370 char *physvols[] = {
8377 r = guestfs_vgcreate (g, volgroup, physvols);
8382 char volgroup[] = "VG2";
8383 char physvols_0[] = "/dev/sda3";
8384 physvols_0[5] = devchar;
8385 char *physvols[] = {
8391 r = guestfs_vgcreate (g, volgroup, physvols);
8396 char logvol[] = "LV1";
8397 char volgroup[] = "VG1";
8400 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8405 char logvol[] = "LV2";
8406 char volgroup[] = "VG1";
8409 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8414 char logvol[] = "LV3";
8415 char volgroup[] = "VG2";
8418 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8426 r = guestfs_lvs (g);
8430 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8435 char expected[] = "/dev/VG1/LV1";
8436 if (strcmp (r[0], expected) != 0) {
8437 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8442 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8447 char expected[] = "/dev/VG1/LV2";
8448 if (strcmp (r[1], expected) != 0) {
8449 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8454 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8459 char expected[] = "/dev/VG2/LV3";
8460 if (strcmp (r[2], expected) != 0) {
8461 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8466 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
8470 for (i = 0; r[i] != NULL; ++i)
8477 static int test_vgs_0 (void)
8479 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
8481 char device[] = "/dev/sda";
8482 device[5] = devchar;
8485 r = guestfs_blockdev_setrw (g, device);
8492 r = guestfs_umount_all (g);
8499 r = guestfs_lvm_remove_all (g);
8504 char device[] = "/dev/sda";
8505 device[5] = devchar;
8506 char lines_0[] = ",";
8513 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8518 char device[] = "/dev/sda1";
8519 device[5] = devchar;
8522 r = guestfs_pvcreate (g, device);
8527 char volgroup[] = "VG";
8528 char physvols_0[] = "/dev/sda1";
8529 physvols_0[5] = devchar;
8530 char *physvols[] = {
8536 r = guestfs_vgcreate (g, volgroup, physvols);
8541 char logvol[] = "LV";
8542 char volgroup[] = "VG";
8545 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8550 char fstype[] = "ext2";
8551 char device[] = "/dev/VG/LV";
8554 r = guestfs_mkfs (g, fstype, device);
8559 char device[] = "/dev/VG/LV";
8560 char mountpoint[] = "/";
8563 r = guestfs_mount (g, device, mountpoint);
8567 /* TestOutputList for vgs (0) */
8572 r = guestfs_vgs (g);
8576 fprintf (stderr, "test_vgs_0: short list returned from command\n");
8581 char expected[] = "VG";
8582 if (strcmp (r[0], expected) != 0) {
8583 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8588 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
8592 for (i = 0; r[i] != NULL; ++i)
8599 static int test_vgs_1 (void)
8601 /* InitEmpty for vgs (1) */
8603 char device[] = "/dev/sda";
8604 device[5] = devchar;
8607 r = guestfs_blockdev_setrw (g, device);
8614 r = guestfs_umount_all (g);
8621 r = guestfs_lvm_remove_all (g);
8625 /* TestOutputList for vgs (1) */
8627 char device[] = "/dev/sda";
8628 device[5] = devchar;
8629 char lines_0[] = ",10";
8630 char lines_1[] = ",20";
8631 char lines_2[] = ",";
8640 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8645 char device[] = "/dev/sda1";
8646 device[5] = devchar;
8649 r = guestfs_pvcreate (g, device);
8654 char device[] = "/dev/sda2";
8655 device[5] = devchar;
8658 r = guestfs_pvcreate (g, device);
8663 char device[] = "/dev/sda3";
8664 device[5] = devchar;
8667 r = guestfs_pvcreate (g, device);
8672 char volgroup[] = "VG1";
8673 char physvols_0[] = "/dev/sda1";
8674 physvols_0[5] = devchar;
8675 char physvols_1[] = "/dev/sda2";
8676 physvols_1[5] = devchar;
8677 char *physvols[] = {
8684 r = guestfs_vgcreate (g, volgroup, physvols);
8689 char volgroup[] = "VG2";
8690 char physvols_0[] = "/dev/sda3";
8691 physvols_0[5] = devchar;
8692 char *physvols[] = {
8698 r = guestfs_vgcreate (g, volgroup, physvols);
8706 r = guestfs_vgs (g);
8710 fprintf (stderr, "test_vgs_1: short list returned from command\n");
8715 char expected[] = "VG1";
8716 if (strcmp (r[0], expected) != 0) {
8717 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8722 fprintf (stderr, "test_vgs_1: short list returned from command\n");
8727 char expected[] = "VG2";
8728 if (strcmp (r[1], expected) != 0) {
8729 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8734 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
8738 for (i = 0; r[i] != NULL; ++i)
8745 static int test_pvs_0 (void)
8747 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
8749 char device[] = "/dev/sda";
8750 device[5] = devchar;
8753 r = guestfs_blockdev_setrw (g, device);
8760 r = guestfs_umount_all (g);
8767 r = guestfs_lvm_remove_all (g);
8772 char device[] = "/dev/sda";
8773 device[5] = devchar;
8774 char lines_0[] = ",";
8781 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8786 char device[] = "/dev/sda1";
8787 device[5] = devchar;
8790 r = guestfs_pvcreate (g, device);
8795 char volgroup[] = "VG";
8796 char physvols_0[] = "/dev/sda1";
8797 physvols_0[5] = devchar;
8798 char *physvols[] = {
8804 r = guestfs_vgcreate (g, volgroup, physvols);
8809 char logvol[] = "LV";
8810 char volgroup[] = "VG";
8813 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8818 char fstype[] = "ext2";
8819 char device[] = "/dev/VG/LV";
8822 r = guestfs_mkfs (g, fstype, device);
8827 char device[] = "/dev/VG/LV";
8828 char mountpoint[] = "/";
8831 r = guestfs_mount (g, device, mountpoint);
8835 /* TestOutputList for pvs (0) */
8840 r = guestfs_pvs (g);
8844 fprintf (stderr, "test_pvs_0: short list returned from command\n");
8849 char expected[] = "/dev/sda1";
8850 expected[5] = devchar;
8851 if (strcmp (r[0], expected) != 0) {
8852 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8857 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
8861 for (i = 0; r[i] != NULL; ++i)
8868 static int test_pvs_1 (void)
8870 /* InitEmpty for pvs (1) */
8872 char device[] = "/dev/sda";
8873 device[5] = devchar;
8876 r = guestfs_blockdev_setrw (g, device);
8883 r = guestfs_umount_all (g);
8890 r = guestfs_lvm_remove_all (g);
8894 /* TestOutputList for pvs (1) */
8896 char device[] = "/dev/sda";
8897 device[5] = devchar;
8898 char lines_0[] = ",10";
8899 char lines_1[] = ",20";
8900 char lines_2[] = ",";
8909 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8914 char device[] = "/dev/sda1";
8915 device[5] = devchar;
8918 r = guestfs_pvcreate (g, device);
8923 char device[] = "/dev/sda2";
8924 device[5] = devchar;
8927 r = guestfs_pvcreate (g, device);
8932 char device[] = "/dev/sda3";
8933 device[5] = devchar;
8936 r = guestfs_pvcreate (g, device);
8944 r = guestfs_pvs (g);
8948 fprintf (stderr, "test_pvs_1: short list returned from command\n");
8953 char expected[] = "/dev/sda1";
8954 expected[5] = devchar;
8955 if (strcmp (r[0], expected) != 0) {
8956 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8961 fprintf (stderr, "test_pvs_1: short list returned from command\n");
8966 char expected[] = "/dev/sda2";
8967 expected[5] = devchar;
8968 if (strcmp (r[1], expected) != 0) {
8969 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8974 fprintf (stderr, "test_pvs_1: short list returned from command\n");
8979 char expected[] = "/dev/sda3";
8980 expected[5] = devchar;
8981 if (strcmp (r[2], expected) != 0) {
8982 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8987 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
8991 for (i = 0; r[i] != NULL; ++i)
8998 static int test_list_partitions_0 (void)
9000 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
9002 char device[] = "/dev/sda";
9003 device[5] = devchar;
9006 r = guestfs_blockdev_setrw (g, device);
9013 r = guestfs_umount_all (g);
9020 r = guestfs_lvm_remove_all (g);
9025 char device[] = "/dev/sda";
9026 device[5] = devchar;
9027 char lines_0[] = ",";
9034 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9039 char fstype[] = "ext2";
9040 char device[] = "/dev/sda1";
9041 device[5] = devchar;
9044 r = guestfs_mkfs (g, fstype, device);
9049 char device[] = "/dev/sda1";
9050 device[5] = devchar;
9051 char mountpoint[] = "/";
9054 r = guestfs_mount (g, device, mountpoint);
9058 /* TestOutputList for list_partitions (0) */
9063 r = guestfs_list_partitions (g);
9067 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
9072 char expected[] = "/dev/sda1";
9073 expected[5] = devchar;
9074 if (strcmp (r[0], expected) != 0) {
9075 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9080 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
9084 for (i = 0; r[i] != NULL; ++i)
9091 static int test_list_partitions_1 (void)
9093 /* InitEmpty for list_partitions (1) */
9095 char device[] = "/dev/sda";
9096 device[5] = devchar;
9099 r = guestfs_blockdev_setrw (g, device);
9106 r = guestfs_umount_all (g);
9113 r = guestfs_lvm_remove_all (g);
9117 /* TestOutputList for list_partitions (1) */
9119 char device[] = "/dev/sda";
9120 device[5] = devchar;
9121 char lines_0[] = ",10";
9122 char lines_1[] = ",20";
9123 char lines_2[] = ",";
9132 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9140 r = guestfs_list_partitions (g);
9144 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9149 char expected[] = "/dev/sda1";
9150 expected[5] = devchar;
9151 if (strcmp (r[0], expected) != 0) {
9152 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9157 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9162 char expected[] = "/dev/sda2";
9163 expected[5] = devchar;
9164 if (strcmp (r[1], expected) != 0) {
9165 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9170 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9175 char expected[] = "/dev/sda3";
9176 expected[5] = devchar;
9177 if (strcmp (r[2], expected) != 0) {
9178 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9183 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
9187 for (i = 0; r[i] != NULL; ++i)
9194 static int test_list_devices_0 (void)
9196 /* InitEmpty for list_devices (0) */
9198 char device[] = "/dev/sda";
9199 device[5] = devchar;
9202 r = guestfs_blockdev_setrw (g, device);
9209 r = guestfs_umount_all (g);
9216 r = guestfs_lvm_remove_all (g);
9220 /* TestOutputList for list_devices (0) */
9225 r = guestfs_list_devices (g);
9229 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9234 char expected[] = "/dev/sda";
9235 expected[5] = devchar;
9236 if (strcmp (r[0], expected) != 0) {
9237 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9242 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9247 char expected[] = "/dev/sdb";
9248 expected[5] = devchar;
9249 if (strcmp (r[1], expected) != 0) {
9250 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9255 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9260 char expected[] = "/dev/sdc";
9261 expected[5] = devchar;
9262 if (strcmp (r[2], expected) != 0) {
9263 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9268 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
9272 for (i = 0; r[i] != NULL; ++i)
9279 static int test_ls_0 (void)
9281 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
9283 char device[] = "/dev/sda";
9284 device[5] = devchar;
9287 r = guestfs_blockdev_setrw (g, device);
9294 r = guestfs_umount_all (g);
9301 r = guestfs_lvm_remove_all (g);
9306 char device[] = "/dev/sda";
9307 device[5] = devchar;
9308 char lines_0[] = ",";
9315 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9320 char fstype[] = "ext2";
9321 char device[] = "/dev/sda1";
9322 device[5] = devchar;
9325 r = guestfs_mkfs (g, fstype, device);
9330 char device[] = "/dev/sda1";
9331 device[5] = devchar;
9332 char mountpoint[] = "/";
9335 r = guestfs_mount (g, device, mountpoint);
9339 /* TestOutputList for ls (0) */
9341 char path[] = "/new";
9344 r = guestfs_touch (g, path);
9349 char path[] = "/newer";
9352 r = guestfs_touch (g, path);
9357 char path[] = "/newest";
9360 r = guestfs_touch (g, path);
9365 char directory[] = "/";
9369 r = guestfs_ls (g, directory);
9373 fprintf (stderr, "test_ls_0: short list returned from command\n");
9378 char expected[] = "lost+found";
9379 if (strcmp (r[0], expected) != 0) {
9380 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9385 fprintf (stderr, "test_ls_0: short list returned from command\n");
9390 char expected[] = "new";
9391 if (strcmp (r[1], expected) != 0) {
9392 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9397 fprintf (stderr, "test_ls_0: short list returned from command\n");
9402 char expected[] = "newer";
9403 if (strcmp (r[2], expected) != 0) {
9404 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9409 fprintf (stderr, "test_ls_0: short list returned from command\n");
9414 char expected[] = "newest";
9415 if (strcmp (r[3], expected) != 0) {
9416 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
9421 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
9425 for (i = 0; r[i] != NULL; ++i)
9432 static int test_cat_0 (void)
9434 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
9436 char device[] = "/dev/sda";
9437 device[5] = devchar;
9440 r = guestfs_blockdev_setrw (g, device);
9447 r = guestfs_umount_all (g);
9454 r = guestfs_lvm_remove_all (g);
9459 char device[] = "/dev/sda";
9460 device[5] = devchar;
9461 char lines_0[] = ",";
9468 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9473 char fstype[] = "ext2";
9474 char device[] = "/dev/sda1";
9475 device[5] = devchar;
9478 r = guestfs_mkfs (g, fstype, device);
9483 char device[] = "/dev/sda1";
9484 device[5] = devchar;
9485 char mountpoint[] = "/";
9488 r = guestfs_mount (g, device, mountpoint);
9492 /* TestOutput for cat (0) */
9493 char expected[] = "new file contents";
9495 char path[] = "/new";
9496 char content[] = "new file contents";
9499 r = guestfs_write_file (g, path, content, 0);
9504 char path[] = "/new";
9507 r = guestfs_cat (g, path);
9510 if (strcmp (r, expected) != 0) {
9511 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
9519 static int test_touch_0 (void)
9521 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
9523 char device[] = "/dev/sda";
9524 device[5] = devchar;
9527 r = guestfs_blockdev_setrw (g, device);
9534 r = guestfs_umount_all (g);
9541 r = guestfs_lvm_remove_all (g);
9546 char device[] = "/dev/sda";
9547 device[5] = devchar;
9548 char lines_0[] = ",";
9555 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9560 char fstype[] = "ext2";
9561 char device[] = "/dev/sda1";
9562 device[5] = devchar;
9565 r = guestfs_mkfs (g, fstype, device);
9570 char device[] = "/dev/sda1";
9571 device[5] = devchar;
9572 char mountpoint[] = "/";
9575 r = guestfs_mount (g, device, mountpoint);
9579 /* TestOutputTrue for touch (0) */
9581 char path[] = "/new";
9584 r = guestfs_touch (g, path);
9589 char path[] = "/new";
9592 r = guestfs_exists (g, path);
9596 fprintf (stderr, "test_touch_0: expected true, got false\n");
9603 static int test_sync_0 (void)
9605 /* InitEmpty for sync (0) */
9607 char device[] = "/dev/sda";
9608 device[5] = devchar;
9611 r = guestfs_blockdev_setrw (g, device);
9618 r = guestfs_umount_all (g);
9625 r = guestfs_lvm_remove_all (g);
9629 /* TestRun for sync (0) */
9633 r = guestfs_sync (g);
9640 static int test_mount_0 (void)
9642 /* InitEmpty for mount (0) */
9644 char device[] = "/dev/sda";
9645 device[5] = devchar;
9648 r = guestfs_blockdev_setrw (g, device);
9655 r = guestfs_umount_all (g);
9662 r = guestfs_lvm_remove_all (g);
9666 /* TestOutput for mount (0) */
9667 char expected[] = "new file contents";
9669 char device[] = "/dev/sda";
9670 device[5] = devchar;
9671 char lines_0[] = ",";
9678 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9683 char fstype[] = "ext2";
9684 char device[] = "/dev/sda1";
9685 device[5] = devchar;
9688 r = guestfs_mkfs (g, fstype, device);
9693 char device[] = "/dev/sda1";
9694 device[5] = devchar;
9695 char mountpoint[] = "/";
9698 r = guestfs_mount (g, device, mountpoint);
9703 char path[] = "/new";
9704 char content[] = "new file contents";
9707 r = guestfs_write_file (g, path, content, 0);
9712 char path[] = "/new";
9715 r = guestfs_cat (g, path);
9718 if (strcmp (r, expected) != 0) {
9719 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
9727 int main (int argc, char *argv[])
9732 const char *filename;
9734 int nr_tests, test_num = 0;
9737 no_test_warnings ();
9739 g = guestfs_create ();
9741 printf ("guestfs_create FAILED\n");
9745 guestfs_set_error_handler (g, print_error, NULL);
9747 srcdir = getenv ("srcdir");
9748 if (!srcdir) srcdir = ".";
9750 guestfs_set_path (g, ".");
9752 filename = "test1.img";
9753 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
9758 if (lseek (fd, 524288000, SEEK_SET) == -1) {
9764 if (write (fd, &c, 1) == -1) {
9770 if (close (fd) == -1) {
9775 if (guestfs_add_drive (g, filename) == -1) {
9776 printf ("guestfs_add_drive %s FAILED\n", filename);
9780 filename = "test2.img";
9781 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
9786 if (lseek (fd, 52428800, SEEK_SET) == -1) {
9792 if (write (fd, &c, 1) == -1) {
9798 if (close (fd) == -1) {
9803 if (guestfs_add_drive (g, filename) == -1) {
9804 printf ("guestfs_add_drive %s FAILED\n", filename);
9808 filename = "test3.img";
9809 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
9814 if (lseek (fd, 10485760, SEEK_SET) == -1) {
9820 if (write (fd, &c, 1) == -1) {
9826 if (close (fd) == -1) {
9831 if (guestfs_add_drive (g, filename) == -1) {
9832 printf ("guestfs_add_drive %s FAILED\n", filename);
9836 if (guestfs_launch (g) == -1) {
9837 printf ("guestfs_launch FAILED\n");
9840 if (guestfs_wait_ready (g) == -1) {
9841 printf ("guestfs_wait_ready FAILED\n");
9845 /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
9846 * names. This changed between RHEL 5 and RHEL 6 so we have to
9849 devs = guestfs_list_devices (g);
9850 if (devs == NULL || devs[0] == NULL) {
9851 printf ("guestfs_list_devices FAILED\n");
9854 if (strncmp (devs[0], "/dev/sd", 7) == 0)
9856 else if (strncmp (devs[0], "/dev/hd", 7) == 0)
9859 printf ("guestfs_list_devices returned unexpected string '%s'\n",
9863 for (i = 0; devs[i] != NULL; ++i)
9870 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
9871 if (test_equal_0 () == -1) {
9872 printf ("test_equal_0 FAILED\n");
9876 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
9877 if (test_equal_1 () == -1) {
9878 printf ("test_equal_1 FAILED\n");
9882 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
9883 if (test_equal_2 () == -1) {
9884 printf ("test_equal_2 FAILED\n");
9888 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
9889 if (test_ping_daemon_0 () == -1) {
9890 printf ("test_ping_daemon_0 FAILED\n");
9894 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
9895 if (test_dmesg_0 () == -1) {
9896 printf ("test_dmesg_0 FAILED\n");
9900 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
9901 if (test_drop_caches_0 () == -1) {
9902 printf ("test_drop_caches_0 FAILED\n");
9906 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
9907 if (test_mv_0 () == -1) {
9908 printf ("test_mv_0 FAILED\n");
9912 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
9913 if (test_mv_1 () == -1) {
9914 printf ("test_mv_1 FAILED\n");
9918 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
9919 if (test_cp_a_0 () == -1) {
9920 printf ("test_cp_a_0 FAILED\n");
9924 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
9925 if (test_cp_0 () == -1) {
9926 printf ("test_cp_0 FAILED\n");
9930 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
9931 if (test_cp_1 () == -1) {
9932 printf ("test_cp_1 FAILED\n");
9936 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
9937 if (test_cp_2 () == -1) {
9938 printf ("test_cp_2 FAILED\n");
9942 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
9943 if (test_grub_install_0 () == -1) {
9944 printf ("test_grub_install_0 FAILED\n");
9948 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
9949 if (test_zero_0 () == -1) {
9950 printf ("test_zero_0 FAILED\n");
9954 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
9955 if (test_fsck_0 () == -1) {
9956 printf ("test_fsck_0 FAILED\n");
9960 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
9961 if (test_fsck_1 () == -1) {
9962 printf ("test_fsck_1 FAILED\n");
9966 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
9967 if (test_set_e2uuid_0 () == -1) {
9968 printf ("test_set_e2uuid_0 FAILED\n");
9972 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
9973 if (test_set_e2uuid_1 () == -1) {
9974 printf ("test_set_e2uuid_1 FAILED\n");
9978 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
9979 if (test_set_e2uuid_2 () == -1) {
9980 printf ("test_set_e2uuid_2 FAILED\n");
9984 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
9985 if (test_set_e2uuid_3 () == -1) {
9986 printf ("test_set_e2uuid_3 FAILED\n");
9990 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
9991 if (test_set_e2label_0 () == -1) {
9992 printf ("test_set_e2label_0 FAILED\n");
9996 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
9997 if (test_pvremove_0 () == -1) {
9998 printf ("test_pvremove_0 FAILED\n");
10002 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
10003 if (test_pvremove_1 () == -1) {
10004 printf ("test_pvremove_1 FAILED\n");
10008 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
10009 if (test_pvremove_2 () == -1) {
10010 printf ("test_pvremove_2 FAILED\n");
10014 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
10015 if (test_vgremove_0 () == -1) {
10016 printf ("test_vgremove_0 FAILED\n");
10020 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
10021 if (test_vgremove_1 () == -1) {
10022 printf ("test_vgremove_1 FAILED\n");
10026 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
10027 if (test_lvremove_0 () == -1) {
10028 printf ("test_lvremove_0 FAILED\n");
10032 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
10033 if (test_lvremove_1 () == -1) {
10034 printf ("test_lvremove_1 FAILED\n");
10038 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
10039 if (test_lvremove_2 () == -1) {
10040 printf ("test_lvremove_2 FAILED\n");
10044 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
10045 if (test_mount_ro_0 () == -1) {
10046 printf ("test_mount_ro_0 FAILED\n");
10050 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
10051 if (test_mount_ro_1 () == -1) {
10052 printf ("test_mount_ro_1 FAILED\n");
10056 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
10057 if (test_tgz_in_0 () == -1) {
10058 printf ("test_tgz_in_0 FAILED\n");
10062 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
10063 if (test_tar_in_0 () == -1) {
10064 printf ("test_tar_in_0 FAILED\n");
10068 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
10069 if (test_checksum_0 () == -1) {
10070 printf ("test_checksum_0 FAILED\n");
10074 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
10075 if (test_checksum_1 () == -1) {
10076 printf ("test_checksum_1 FAILED\n");
10080 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
10081 if (test_checksum_2 () == -1) {
10082 printf ("test_checksum_2 FAILED\n");
10086 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
10087 if (test_checksum_3 () == -1) {
10088 printf ("test_checksum_3 FAILED\n");
10092 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
10093 if (test_checksum_4 () == -1) {
10094 printf ("test_checksum_4 FAILED\n");
10098 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
10099 if (test_checksum_5 () == -1) {
10100 printf ("test_checksum_5 FAILED\n");
10104 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
10105 if (test_checksum_6 () == -1) {
10106 printf ("test_checksum_6 FAILED\n");
10110 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
10111 if (test_checksum_7 () == -1) {
10112 printf ("test_checksum_7 FAILED\n");
10116 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
10117 if (test_download_0 () == -1) {
10118 printf ("test_download_0 FAILED\n");
10122 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
10123 if (test_upload_0 () == -1) {
10124 printf ("test_upload_0 FAILED\n");
10128 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
10129 if (test_blockdev_rereadpt_0 () == -1) {
10130 printf ("test_blockdev_rereadpt_0 FAILED\n");
10134 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
10135 if (test_blockdev_flushbufs_0 () == -1) {
10136 printf ("test_blockdev_flushbufs_0 FAILED\n");
10140 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
10141 if (test_blockdev_getsize64_0 () == -1) {
10142 printf ("test_blockdev_getsize64_0 FAILED\n");
10146 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
10147 if (test_blockdev_getsz_0 () == -1) {
10148 printf ("test_blockdev_getsz_0 FAILED\n");
10152 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
10153 if (test_blockdev_getbsz_0 () == -1) {
10154 printf ("test_blockdev_getbsz_0 FAILED\n");
10158 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
10159 if (test_blockdev_getss_0 () == -1) {
10160 printf ("test_blockdev_getss_0 FAILED\n");
10164 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
10165 if (test_blockdev_getro_0 () == -1) {
10166 printf ("test_blockdev_getro_0 FAILED\n");
10170 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
10171 if (test_blockdev_setrw_0 () == -1) {
10172 printf ("test_blockdev_setrw_0 FAILED\n");
10176 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
10177 if (test_blockdev_setro_0 () == -1) {
10178 printf ("test_blockdev_setro_0 FAILED\n");
10182 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
10183 if (test_statvfs_0 () == -1) {
10184 printf ("test_statvfs_0 FAILED\n");
10188 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
10189 if (test_lstat_0 () == -1) {
10190 printf ("test_lstat_0 FAILED\n");
10194 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
10195 if (test_stat_0 () == -1) {
10196 printf ("test_stat_0 FAILED\n");
10200 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
10201 if (test_file_0 () == -1) {
10202 printf ("test_file_0 FAILED\n");
10206 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
10207 if (test_file_1 () == -1) {
10208 printf ("test_file_1 FAILED\n");
10212 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
10213 if (test_file_2 () == -1) {
10214 printf ("test_file_2 FAILED\n");
10218 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
10219 if (test_umount_all_0 () == -1) {
10220 printf ("test_umount_all_0 FAILED\n");
10224 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
10225 if (test_umount_all_1 () == -1) {
10226 printf ("test_umount_all_1 FAILED\n");
10230 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
10231 if (test_mounts_0 () == -1) {
10232 printf ("test_mounts_0 FAILED\n");
10236 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
10237 if (test_umount_0 () == -1) {
10238 printf ("test_umount_0 FAILED\n");
10242 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
10243 if (test_umount_1 () == -1) {
10244 printf ("test_umount_1 FAILED\n");
10248 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
10249 if (test_write_file_0 () == -1) {
10250 printf ("test_write_file_0 FAILED\n");
10254 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
10255 if (test_write_file_1 () == -1) {
10256 printf ("test_write_file_1 FAILED\n");
10260 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
10261 if (test_write_file_2 () == -1) {
10262 printf ("test_write_file_2 FAILED\n");
10266 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
10267 if (test_write_file_3 () == -1) {
10268 printf ("test_write_file_3 FAILED\n");
10272 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
10273 if (test_write_file_4 () == -1) {
10274 printf ("test_write_file_4 FAILED\n");
10278 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
10279 if (test_write_file_5 () == -1) {
10280 printf ("test_write_file_5 FAILED\n");
10284 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
10285 if (test_mkfs_0 () == -1) {
10286 printf ("test_mkfs_0 FAILED\n");
10290 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
10291 if (test_lvcreate_0 () == -1) {
10292 printf ("test_lvcreate_0 FAILED\n");
10296 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
10297 if (test_vgcreate_0 () == -1) {
10298 printf ("test_vgcreate_0 FAILED\n");
10302 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
10303 if (test_pvcreate_0 () == -1) {
10304 printf ("test_pvcreate_0 FAILED\n");
10308 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
10309 if (test_is_dir_0 () == -1) {
10310 printf ("test_is_dir_0 FAILED\n");
10314 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
10315 if (test_is_dir_1 () == -1) {
10316 printf ("test_is_dir_1 FAILED\n");
10320 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
10321 if (test_is_file_0 () == -1) {
10322 printf ("test_is_file_0 FAILED\n");
10326 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
10327 if (test_is_file_1 () == -1) {
10328 printf ("test_is_file_1 FAILED\n");
10332 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
10333 if (test_exists_0 () == -1) {
10334 printf ("test_exists_0 FAILED\n");
10338 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
10339 if (test_exists_1 () == -1) {
10340 printf ("test_exists_1 FAILED\n");
10344 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
10345 if (test_mkdir_p_0 () == -1) {
10346 printf ("test_mkdir_p_0 FAILED\n");
10350 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
10351 if (test_mkdir_p_1 () == -1) {
10352 printf ("test_mkdir_p_1 FAILED\n");
10356 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
10357 if (test_mkdir_p_2 () == -1) {
10358 printf ("test_mkdir_p_2 FAILED\n");
10362 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
10363 if (test_mkdir_0 () == -1) {
10364 printf ("test_mkdir_0 FAILED\n");
10368 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
10369 if (test_mkdir_1 () == -1) {
10370 printf ("test_mkdir_1 FAILED\n");
10374 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
10375 if (test_rm_rf_0 () == -1) {
10376 printf ("test_rm_rf_0 FAILED\n");
10380 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
10381 if (test_rmdir_0 () == -1) {
10382 printf ("test_rmdir_0 FAILED\n");
10386 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
10387 if (test_rmdir_1 () == -1) {
10388 printf ("test_rmdir_1 FAILED\n");
10392 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
10393 if (test_rmdir_2 () == -1) {
10394 printf ("test_rmdir_2 FAILED\n");
10398 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
10399 if (test_rm_0 () == -1) {
10400 printf ("test_rm_0 FAILED\n");
10404 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
10405 if (test_rm_1 () == -1) {
10406 printf ("test_rm_1 FAILED\n");
10410 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
10411 if (test_rm_2 () == -1) {
10412 printf ("test_rm_2 FAILED\n");
10416 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
10417 if (test_read_lines_0 () == -1) {
10418 printf ("test_read_lines_0 FAILED\n");
10422 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
10423 if (test_read_lines_1 () == -1) {
10424 printf ("test_read_lines_1 FAILED\n");
10428 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
10429 if (test_lvs_0 () == -1) {
10430 printf ("test_lvs_0 FAILED\n");
10434 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
10435 if (test_lvs_1 () == -1) {
10436 printf ("test_lvs_1 FAILED\n");
10440 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
10441 if (test_vgs_0 () == -1) {
10442 printf ("test_vgs_0 FAILED\n");
10446 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
10447 if (test_vgs_1 () == -1) {
10448 printf ("test_vgs_1 FAILED\n");
10452 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
10453 if (test_pvs_0 () == -1) {
10454 printf ("test_pvs_0 FAILED\n");
10458 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
10459 if (test_pvs_1 () == -1) {
10460 printf ("test_pvs_1 FAILED\n");
10464 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
10465 if (test_list_partitions_0 () == -1) {
10466 printf ("test_list_partitions_0 FAILED\n");
10470 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
10471 if (test_list_partitions_1 () == -1) {
10472 printf ("test_list_partitions_1 FAILED\n");
10476 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
10477 if (test_list_devices_0 () == -1) {
10478 printf ("test_list_devices_0 FAILED\n");
10482 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
10483 if (test_ls_0 () == -1) {
10484 printf ("test_ls_0 FAILED\n");
10488 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
10489 if (test_cat_0 () == -1) {
10490 printf ("test_cat_0 FAILED\n");
10494 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
10495 if (test_touch_0 () == -1) {
10496 printf ("test_touch_0 FAILED\n");
10500 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
10501 if (test_sync_0 () == -1) {
10502 printf ("test_sync_0 FAILED\n");
10506 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
10507 if (test_mount_0 () == -1) {
10508 printf ("test_mount_0 FAILED\n");
10513 unlink ("test1.img");
10514 unlink ("test2.img");
10515 unlink ("test3.img");
10518 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);