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_hexdump_0 (void)
122 /* InitBasicFS for hexdump (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 /* TestOutput for hexdump (0) */
181 char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
183 char path[] = "/new";
184 char content[] = "hello\nworld\n";
187 r = guestfs_write_file (g, path, content, 12);
192 char path[] = "/new";
195 r = guestfs_hexdump (g, path);
198 if (strcmp (r, expected) != 0) {
199 fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
207 static int test_strings_e_0 (void)
209 /* InitBasicFS for strings_e (0): create ext2 on /dev/sda1 */
211 char device[] = "/dev/sda";
215 r = guestfs_blockdev_setrw (g, device);
222 r = guestfs_umount_all (g);
229 r = guestfs_lvm_remove_all (g);
234 char device[] = "/dev/sda";
236 char lines_0[] = ",";
243 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
248 char fstype[] = "ext2";
249 char device[] = "/dev/sda1";
253 r = guestfs_mkfs (g, fstype, device);
258 char device[] = "/dev/sda1";
260 char mountpoint[] = "/";
263 r = guestfs_mount (g, device, mountpoint);
267 /* TestOutputList for strings_e (0) */
269 char path[] = "/new";
270 char content[] = "hello\nworld\n";
273 r = guestfs_write_file (g, path, content, 0);
278 char encoding[] = "b";
279 char path[] = "/new";
283 r = guestfs_strings_e (g, encoding, path);
287 fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
291 for (i = 0; r[i] != NULL; ++i)
298 static int test_strings_0 (void)
300 /* InitBasicFS for strings (0): create ext2 on /dev/sda1 */
302 char device[] = "/dev/sda";
306 r = guestfs_blockdev_setrw (g, device);
313 r = guestfs_umount_all (g);
320 r = guestfs_lvm_remove_all (g);
325 char device[] = "/dev/sda";
327 char lines_0[] = ",";
334 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
339 char fstype[] = "ext2";
340 char device[] = "/dev/sda1";
344 r = guestfs_mkfs (g, fstype, device);
349 char device[] = "/dev/sda1";
351 char mountpoint[] = "/";
354 r = guestfs_mount (g, device, mountpoint);
358 /* TestOutputList for strings (0) */
360 char path[] = "/new";
361 char content[] = "hello\nworld\n";
364 r = guestfs_write_file (g, path, content, 0);
369 char path[] = "/new";
373 r = guestfs_strings (g, path);
377 fprintf (stderr, "test_strings_0: short list returned from command\n");
382 char expected[] = "hello";
383 if (strcmp (r[0], expected) != 0) {
384 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
389 fprintf (stderr, "test_strings_0: short list returned from command\n");
394 char expected[] = "world";
395 if (strcmp (r[1], expected) != 0) {
396 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
401 fprintf (stderr, "test_strings_0: extra elements returned from command\n");
405 for (i = 0; r[i] != NULL; ++i)
412 static int test_equal_0 (void)
414 /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */
416 char device[] = "/dev/sda";
420 r = guestfs_blockdev_setrw (g, device);
427 r = guestfs_umount_all (g);
434 r = guestfs_lvm_remove_all (g);
439 char device[] = "/dev/sda";
441 char lines_0[] = ",";
448 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
453 char fstype[] = "ext2";
454 char device[] = "/dev/sda1";
458 r = guestfs_mkfs (g, fstype, device);
463 char device[] = "/dev/sda1";
465 char mountpoint[] = "/";
468 r = guestfs_mount (g, device, mountpoint);
472 /* TestOutputTrue for equal (0) */
474 char path[] = "/file1";
475 char content[] = "contents of a file";
478 r = guestfs_write_file (g, path, content, 0);
483 char src[] = "/file1";
484 char dest[] = "/file2";
487 r = guestfs_cp (g, src, dest);
492 char file1[] = "/file1";
493 char file2[] = "/file2";
496 r = guestfs_equal (g, file1, file2);
500 fprintf (stderr, "test_equal_0: expected true, got false\n");
507 static int test_equal_1 (void)
509 /* InitBasicFS for equal (1): create ext2 on /dev/sda1 */
511 char device[] = "/dev/sda";
515 r = guestfs_blockdev_setrw (g, device);
522 r = guestfs_umount_all (g);
529 r = guestfs_lvm_remove_all (g);
534 char device[] = "/dev/sda";
536 char lines_0[] = ",";
543 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
548 char fstype[] = "ext2";
549 char device[] = "/dev/sda1";
553 r = guestfs_mkfs (g, fstype, device);
558 char device[] = "/dev/sda1";
560 char mountpoint[] = "/";
563 r = guestfs_mount (g, device, mountpoint);
567 /* TestOutputFalse for equal (1) */
569 char path[] = "/file1";
570 char content[] = "contents of a file";
573 r = guestfs_write_file (g, path, content, 0);
578 char path[] = "/file2";
579 char content[] = "contents of another file";
582 r = guestfs_write_file (g, path, content, 0);
587 char file1[] = "/file1";
588 char file2[] = "/file2";
591 r = guestfs_equal (g, file1, file2);
595 fprintf (stderr, "test_equal_1: expected false, got true\n");
602 static int test_equal_2 (void)
604 /* InitBasicFS for equal (2): create ext2 on /dev/sda1 */
606 char device[] = "/dev/sda";
610 r = guestfs_blockdev_setrw (g, device);
617 r = guestfs_umount_all (g);
624 r = guestfs_lvm_remove_all (g);
629 char device[] = "/dev/sda";
631 char lines_0[] = ",";
638 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
643 char fstype[] = "ext2";
644 char device[] = "/dev/sda1";
648 r = guestfs_mkfs (g, fstype, device);
653 char device[] = "/dev/sda1";
655 char mountpoint[] = "/";
658 r = guestfs_mount (g, device, mountpoint);
662 /* TestLastFail for equal (2) */
664 char file1[] = "/file1";
665 char file2[] = "/file2";
668 r = guestfs_equal (g, file1, file2);
675 static int test_ping_daemon_0 (void)
677 /* InitEmpty for ping_daemon (0) */
679 char device[] = "/dev/sda";
683 r = guestfs_blockdev_setrw (g, device);
690 r = guestfs_umount_all (g);
697 r = guestfs_lvm_remove_all (g);
701 /* TestRun for ping_daemon (0) */
705 r = guestfs_ping_daemon (g);
712 static int test_dmesg_0 (void)
714 /* InitEmpty for dmesg (0) */
716 char device[] = "/dev/sda";
720 r = guestfs_blockdev_setrw (g, device);
727 r = guestfs_umount_all (g);
734 r = guestfs_lvm_remove_all (g);
738 /* TestRun for dmesg (0) */
742 r = guestfs_dmesg (g);
750 static int test_drop_caches_0 (void)
752 /* InitEmpty for drop_caches (0) */
754 char device[] = "/dev/sda";
758 r = guestfs_blockdev_setrw (g, device);
765 r = guestfs_umount_all (g);
772 r = guestfs_lvm_remove_all (g);
776 /* TestRun for drop_caches (0) */
780 r = guestfs_drop_caches (g, 3);
787 static int test_mv_0 (void)
789 /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
791 char device[] = "/dev/sda";
795 r = guestfs_blockdev_setrw (g, device);
802 r = guestfs_umount_all (g);
809 r = guestfs_lvm_remove_all (g);
814 char device[] = "/dev/sda";
816 char lines_0[] = ",";
823 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
828 char fstype[] = "ext2";
829 char device[] = "/dev/sda1";
833 r = guestfs_mkfs (g, fstype, device);
838 char device[] = "/dev/sda1";
840 char mountpoint[] = "/";
843 r = guestfs_mount (g, device, mountpoint);
847 /* TestOutput for mv (0) */
848 char expected[] = "file content";
850 char path[] = "/old";
851 char content[] = "file content";
854 r = guestfs_write_file (g, path, content, 0);
860 char dest[] = "/new";
863 r = guestfs_mv (g, src, dest);
868 char path[] = "/new";
871 r = guestfs_cat (g, path);
874 if (strcmp (r, expected) != 0) {
875 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
883 static int test_mv_1 (void)
885 /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
887 char device[] = "/dev/sda";
891 r = guestfs_blockdev_setrw (g, device);
898 r = guestfs_umount_all (g);
905 r = guestfs_lvm_remove_all (g);
910 char device[] = "/dev/sda";
912 char lines_0[] = ",";
919 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
924 char fstype[] = "ext2";
925 char device[] = "/dev/sda1";
929 r = guestfs_mkfs (g, fstype, device);
934 char device[] = "/dev/sda1";
936 char mountpoint[] = "/";
939 r = guestfs_mount (g, device, mountpoint);
943 /* TestOutputFalse for mv (1) */
945 char path[] = "/old";
946 char content[] = "file content";
949 r = guestfs_write_file (g, path, content, 0);
955 char dest[] = "/new";
958 r = guestfs_mv (g, src, dest);
963 char path[] = "/old";
966 r = guestfs_is_file (g, path);
970 fprintf (stderr, "test_mv_1: expected false, got true\n");
977 static int test_cp_a_0 (void)
979 /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
981 char device[] = "/dev/sda";
985 r = guestfs_blockdev_setrw (g, device);
992 r = guestfs_umount_all (g);
999 r = guestfs_lvm_remove_all (g);
1004 char device[] = "/dev/sda";
1005 device[5] = devchar;
1006 char lines_0[] = ",";
1013 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1018 char fstype[] = "ext2";
1019 char device[] = "/dev/sda1";
1020 device[5] = devchar;
1023 r = guestfs_mkfs (g, fstype, device);
1028 char device[] = "/dev/sda1";
1029 device[5] = devchar;
1030 char mountpoint[] = "/";
1033 r = guestfs_mount (g, device, mountpoint);
1037 /* TestOutput for cp_a (0) */
1038 char expected[] = "file content";
1040 char path[] = "/olddir";
1043 r = guestfs_mkdir (g, path);
1048 char path[] = "/newdir";
1051 r = guestfs_mkdir (g, path);
1056 char path[] = "/olddir/file";
1057 char content[] = "file content";
1060 r = guestfs_write_file (g, path, content, 0);
1065 char src[] = "/olddir";
1066 char dest[] = "/newdir";
1069 r = guestfs_cp_a (g, src, dest);
1074 char path[] = "/newdir/olddir/file";
1077 r = guestfs_cat (g, path);
1080 if (strcmp (r, expected) != 0) {
1081 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
1089 static int test_cp_0 (void)
1091 /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
1093 char device[] = "/dev/sda";
1094 device[5] = devchar;
1097 r = guestfs_blockdev_setrw (g, device);
1104 r = guestfs_umount_all (g);
1111 r = guestfs_lvm_remove_all (g);
1116 char device[] = "/dev/sda";
1117 device[5] = devchar;
1118 char lines_0[] = ",";
1125 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1130 char fstype[] = "ext2";
1131 char device[] = "/dev/sda1";
1132 device[5] = devchar;
1135 r = guestfs_mkfs (g, fstype, device);
1140 char device[] = "/dev/sda1";
1141 device[5] = devchar;
1142 char mountpoint[] = "/";
1145 r = guestfs_mount (g, device, mountpoint);
1149 /* TestOutput for cp (0) */
1150 char expected[] = "file content";
1152 char path[] = "/old";
1153 char content[] = "file content";
1156 r = guestfs_write_file (g, path, content, 0);
1161 char src[] = "/old";
1162 char dest[] = "/new";
1165 r = guestfs_cp (g, src, dest);
1170 char path[] = "/new";
1173 r = guestfs_cat (g, path);
1176 if (strcmp (r, expected) != 0) {
1177 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
1185 static int test_cp_1 (void)
1187 /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
1189 char device[] = "/dev/sda";
1190 device[5] = devchar;
1193 r = guestfs_blockdev_setrw (g, device);
1200 r = guestfs_umount_all (g);
1207 r = guestfs_lvm_remove_all (g);
1212 char device[] = "/dev/sda";
1213 device[5] = devchar;
1214 char lines_0[] = ",";
1221 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1226 char fstype[] = "ext2";
1227 char device[] = "/dev/sda1";
1228 device[5] = devchar;
1231 r = guestfs_mkfs (g, fstype, device);
1236 char device[] = "/dev/sda1";
1237 device[5] = devchar;
1238 char mountpoint[] = "/";
1241 r = guestfs_mount (g, device, mountpoint);
1245 /* TestOutputTrue for cp (1) */
1247 char path[] = "/old";
1248 char content[] = "file content";
1251 r = guestfs_write_file (g, path, content, 0);
1256 char src[] = "/old";
1257 char dest[] = "/new";
1260 r = guestfs_cp (g, src, dest);
1265 char path[] = "/old";
1268 r = guestfs_is_file (g, path);
1272 fprintf (stderr, "test_cp_1: expected true, got false\n");
1279 static int test_cp_2 (void)
1281 /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
1283 char device[] = "/dev/sda";
1284 device[5] = devchar;
1287 r = guestfs_blockdev_setrw (g, device);
1294 r = guestfs_umount_all (g);
1301 r = guestfs_lvm_remove_all (g);
1306 char device[] = "/dev/sda";
1307 device[5] = devchar;
1308 char lines_0[] = ",";
1315 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1320 char fstype[] = "ext2";
1321 char device[] = "/dev/sda1";
1322 device[5] = devchar;
1325 r = guestfs_mkfs (g, fstype, device);
1330 char device[] = "/dev/sda1";
1331 device[5] = devchar;
1332 char mountpoint[] = "/";
1335 r = guestfs_mount (g, device, mountpoint);
1339 /* TestOutput for cp (2) */
1340 char expected[] = "file content";
1342 char path[] = "/old";
1343 char content[] = "file content";
1346 r = guestfs_write_file (g, path, content, 0);
1351 char path[] = "/dir";
1354 r = guestfs_mkdir (g, path);
1359 char src[] = "/old";
1360 char dest[] = "/dir/new";
1363 r = guestfs_cp (g, src, dest);
1368 char path[] = "/dir/new";
1371 r = guestfs_cat (g, path);
1374 if (strcmp (r, expected) != 0) {
1375 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
1383 static int test_grub_install_0 (void)
1385 /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
1387 char device[] = "/dev/sda";
1388 device[5] = devchar;
1391 r = guestfs_blockdev_setrw (g, device);
1398 r = guestfs_umount_all (g);
1405 r = guestfs_lvm_remove_all (g);
1410 char device[] = "/dev/sda";
1411 device[5] = devchar;
1412 char lines_0[] = ",";
1419 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1424 char fstype[] = "ext2";
1425 char device[] = "/dev/sda1";
1426 device[5] = devchar;
1429 r = guestfs_mkfs (g, fstype, device);
1434 char device[] = "/dev/sda1";
1435 device[5] = devchar;
1436 char mountpoint[] = "/";
1439 r = guestfs_mount (g, device, mountpoint);
1443 /* TestOutputTrue for grub_install (0) */
1446 char device[] = "/dev/sda1";
1447 device[5] = devchar;
1450 r = guestfs_grub_install (g, root, device);
1455 char path[] = "/boot";
1458 r = guestfs_is_dir (g, path);
1462 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
1469 static int test_zero_0 (void)
1471 /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */
1473 char device[] = "/dev/sda";
1474 device[5] = devchar;
1477 r = guestfs_blockdev_setrw (g, device);
1484 r = guestfs_umount_all (g);
1491 r = guestfs_lvm_remove_all (g);
1496 char device[] = "/dev/sda";
1497 device[5] = devchar;
1498 char lines_0[] = ",";
1505 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1510 char fstype[] = "ext2";
1511 char device[] = "/dev/sda1";
1512 device[5] = devchar;
1515 r = guestfs_mkfs (g, fstype, device);
1520 char device[] = "/dev/sda1";
1521 device[5] = devchar;
1522 char mountpoint[] = "/";
1525 r = guestfs_mount (g, device, mountpoint);
1529 /* TestOutput for zero (0) */
1530 char expected[] = "data";
1532 char pathordevice[] = "/dev/sda1";
1533 pathordevice[5] = devchar;
1536 r = guestfs_umount (g, pathordevice);
1541 char device[] = "/dev/sda1";
1542 device[5] = devchar;
1545 r = guestfs_zero (g, device);
1550 char path[] = "/dev/sda1";
1554 r = guestfs_file (g, path);
1557 if (strcmp (r, expected) != 0) {
1558 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
1566 static int test_fsck_0 (void)
1568 /* InitBasicFS for fsck (0): create ext2 on /dev/sda1 */
1570 char device[] = "/dev/sda";
1571 device[5] = devchar;
1574 r = guestfs_blockdev_setrw (g, device);
1581 r = guestfs_umount_all (g);
1588 r = guestfs_lvm_remove_all (g);
1593 char device[] = "/dev/sda";
1594 device[5] = devchar;
1595 char lines_0[] = ",";
1602 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1607 char fstype[] = "ext2";
1608 char device[] = "/dev/sda1";
1609 device[5] = devchar;
1612 r = guestfs_mkfs (g, fstype, device);
1617 char device[] = "/dev/sda1";
1618 device[5] = devchar;
1619 char mountpoint[] = "/";
1622 r = guestfs_mount (g, device, mountpoint);
1626 /* TestOutputInt for fsck (0) */
1628 char pathordevice[] = "/dev/sda1";
1629 pathordevice[5] = devchar;
1632 r = guestfs_umount (g, pathordevice);
1637 char fstype[] = "ext2";
1638 char device[] = "/dev/sda1";
1639 device[5] = devchar;
1642 r = guestfs_fsck (g, fstype, device);
1646 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
1653 static int test_fsck_1 (void)
1655 /* InitBasicFS for fsck (1): create ext2 on /dev/sda1 */
1657 char device[] = "/dev/sda";
1658 device[5] = devchar;
1661 r = guestfs_blockdev_setrw (g, device);
1668 r = guestfs_umount_all (g);
1675 r = guestfs_lvm_remove_all (g);
1680 char device[] = "/dev/sda";
1681 device[5] = devchar;
1682 char lines_0[] = ",";
1689 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1694 char fstype[] = "ext2";
1695 char device[] = "/dev/sda1";
1696 device[5] = devchar;
1699 r = guestfs_mkfs (g, fstype, device);
1704 char device[] = "/dev/sda1";
1705 device[5] = devchar;
1706 char mountpoint[] = "/";
1709 r = guestfs_mount (g, device, mountpoint);
1713 /* TestOutputInt for fsck (1) */
1715 char pathordevice[] = "/dev/sda1";
1716 pathordevice[5] = devchar;
1719 r = guestfs_umount (g, pathordevice);
1724 char device[] = "/dev/sda1";
1725 device[5] = devchar;
1728 r = guestfs_zero (g, device);
1733 char fstype[] = "ext2";
1734 char device[] = "/dev/sda1";
1735 device[5] = devchar;
1738 r = guestfs_fsck (g, fstype, device);
1742 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
1749 static int test_set_e2uuid_0 (void)
1751 /* InitBasicFS for set_e2uuid (0): create ext2 on /dev/sda1 */
1753 char device[] = "/dev/sda";
1754 device[5] = devchar;
1757 r = guestfs_blockdev_setrw (g, device);
1764 r = guestfs_umount_all (g);
1771 r = guestfs_lvm_remove_all (g);
1776 char device[] = "/dev/sda";
1777 device[5] = devchar;
1778 char lines_0[] = ",";
1785 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1790 char fstype[] = "ext2";
1791 char device[] = "/dev/sda1";
1792 device[5] = devchar;
1795 r = guestfs_mkfs (g, fstype, device);
1800 char device[] = "/dev/sda1";
1801 device[5] = devchar;
1802 char mountpoint[] = "/";
1805 r = guestfs_mount (g, device, mountpoint);
1809 /* TestOutput for set_e2uuid (0) */
1810 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1812 char device[] = "/dev/sda1";
1813 device[5] = devchar;
1814 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
1817 r = guestfs_set_e2uuid (g, device, uuid);
1822 char device[] = "/dev/sda1";
1823 device[5] = devchar;
1826 r = guestfs_get_e2uuid (g, device);
1829 if (strcmp (r, expected) != 0) {
1830 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
1838 static int test_set_e2uuid_1 (void)
1840 /* InitBasicFS for set_e2uuid (1): create ext2 on /dev/sda1 */
1842 char device[] = "/dev/sda";
1843 device[5] = devchar;
1846 r = guestfs_blockdev_setrw (g, device);
1853 r = guestfs_umount_all (g);
1860 r = guestfs_lvm_remove_all (g);
1865 char device[] = "/dev/sda";
1866 device[5] = devchar;
1867 char lines_0[] = ",";
1874 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1879 char fstype[] = "ext2";
1880 char device[] = "/dev/sda1";
1881 device[5] = devchar;
1884 r = guestfs_mkfs (g, fstype, device);
1889 char device[] = "/dev/sda1";
1890 device[5] = devchar;
1891 char mountpoint[] = "/";
1894 r = guestfs_mount (g, device, mountpoint);
1898 /* TestOutput for set_e2uuid (1) */
1899 char expected[] = "";
1901 char device[] = "/dev/sda1";
1902 device[5] = devchar;
1903 char uuid[] = "clear";
1906 r = guestfs_set_e2uuid (g, device, uuid);
1911 char device[] = "/dev/sda1";
1912 device[5] = devchar;
1915 r = guestfs_get_e2uuid (g, device);
1918 if (strcmp (r, expected) != 0) {
1919 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
1927 static int test_set_e2uuid_2 (void)
1929 /* InitBasicFS for set_e2uuid (2): create ext2 on /dev/sda1 */
1931 char device[] = "/dev/sda";
1932 device[5] = devchar;
1935 r = guestfs_blockdev_setrw (g, device);
1942 r = guestfs_umount_all (g);
1949 r = guestfs_lvm_remove_all (g);
1954 char device[] = "/dev/sda";
1955 device[5] = devchar;
1956 char lines_0[] = ",";
1963 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1968 char fstype[] = "ext2";
1969 char device[] = "/dev/sda1";
1970 device[5] = devchar;
1973 r = guestfs_mkfs (g, fstype, device);
1978 char device[] = "/dev/sda1";
1979 device[5] = devchar;
1980 char mountpoint[] = "/";
1983 r = guestfs_mount (g, device, mountpoint);
1987 /* TestRun for set_e2uuid (2) */
1989 char device[] = "/dev/sda1";
1990 device[5] = devchar;
1991 char uuid[] = "random";
1994 r = guestfs_set_e2uuid (g, device, uuid);
2001 static int test_set_e2uuid_3 (void)
2003 /* InitBasicFS for set_e2uuid (3): create ext2 on /dev/sda1 */
2005 char device[] = "/dev/sda";
2006 device[5] = devchar;
2009 r = guestfs_blockdev_setrw (g, device);
2016 r = guestfs_umount_all (g);
2023 r = guestfs_lvm_remove_all (g);
2028 char device[] = "/dev/sda";
2029 device[5] = devchar;
2030 char lines_0[] = ",";
2037 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2042 char fstype[] = "ext2";
2043 char device[] = "/dev/sda1";
2044 device[5] = devchar;
2047 r = guestfs_mkfs (g, fstype, device);
2052 char device[] = "/dev/sda1";
2053 device[5] = devchar;
2054 char mountpoint[] = "/";
2057 r = guestfs_mount (g, device, mountpoint);
2061 /* TestRun for set_e2uuid (3) */
2063 char device[] = "/dev/sda1";
2064 device[5] = devchar;
2065 char uuid[] = "time";
2068 r = guestfs_set_e2uuid (g, device, uuid);
2075 static int test_set_e2label_0 (void)
2077 /* InitBasicFS for set_e2label (0): create ext2 on /dev/sda1 */
2079 char device[] = "/dev/sda";
2080 device[5] = devchar;
2083 r = guestfs_blockdev_setrw (g, device);
2090 r = guestfs_umount_all (g);
2097 r = guestfs_lvm_remove_all (g);
2102 char device[] = "/dev/sda";
2103 device[5] = devchar;
2104 char lines_0[] = ",";
2111 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2116 char fstype[] = "ext2";
2117 char device[] = "/dev/sda1";
2118 device[5] = devchar;
2121 r = guestfs_mkfs (g, fstype, device);
2126 char device[] = "/dev/sda1";
2127 device[5] = devchar;
2128 char mountpoint[] = "/";
2131 r = guestfs_mount (g, device, mountpoint);
2135 /* TestOutput for set_e2label (0) */
2136 char expected[] = "testlabel";
2138 char device[] = "/dev/sda1";
2139 device[5] = devchar;
2140 char label[] = "testlabel";
2143 r = guestfs_set_e2label (g, device, label);
2148 char device[] = "/dev/sda1";
2149 device[5] = devchar;
2152 r = guestfs_get_e2label (g, device);
2155 if (strcmp (r, expected) != 0) {
2156 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
2164 static int test_pvremove_0 (void)
2166 /* InitEmpty for pvremove (0) */
2168 char device[] = "/dev/sda";
2169 device[5] = devchar;
2172 r = guestfs_blockdev_setrw (g, device);
2179 r = guestfs_umount_all (g);
2186 r = guestfs_lvm_remove_all (g);
2190 /* TestOutputList for pvremove (0) */
2192 char device[] = "/dev/sda";
2193 device[5] = devchar;
2196 r = guestfs_pvcreate (g, device);
2201 char volgroup[] = "VG";
2202 char physvols_0[] = "/dev/sda";
2203 physvols_0[5] = devchar;
2204 char *physvols[] = {
2210 r = guestfs_vgcreate (g, volgroup, physvols);
2215 char logvol[] = "LV1";
2216 char volgroup[] = "VG";
2219 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2224 char logvol[] = "LV2";
2225 char volgroup[] = "VG";
2228 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2233 char vgname[] = "VG";
2236 r = guestfs_vgremove (g, vgname);
2241 char device[] = "/dev/sda";
2242 device[5] = devchar;
2245 r = guestfs_pvremove (g, device);
2253 r = guestfs_lvs (g);
2257 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
2261 for (i = 0; r[i] != NULL; ++i)
2268 static int test_pvremove_1 (void)
2270 /* InitEmpty for pvremove (1) */
2272 char device[] = "/dev/sda";
2273 device[5] = devchar;
2276 r = guestfs_blockdev_setrw (g, device);
2283 r = guestfs_umount_all (g);
2290 r = guestfs_lvm_remove_all (g);
2294 /* TestOutputList for pvremove (1) */
2296 char device[] = "/dev/sda";
2297 device[5] = devchar;
2300 r = guestfs_pvcreate (g, device);
2305 char volgroup[] = "VG";
2306 char physvols_0[] = "/dev/sda";
2307 physvols_0[5] = devchar;
2308 char *physvols[] = {
2314 r = guestfs_vgcreate (g, volgroup, physvols);
2319 char logvol[] = "LV1";
2320 char volgroup[] = "VG";
2323 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2328 char logvol[] = "LV2";
2329 char volgroup[] = "VG";
2332 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2337 char vgname[] = "VG";
2340 r = guestfs_vgremove (g, vgname);
2345 char device[] = "/dev/sda";
2346 device[5] = devchar;
2349 r = guestfs_pvremove (g, device);
2357 r = guestfs_vgs (g);
2361 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
2365 for (i = 0; r[i] != NULL; ++i)
2372 static int test_pvremove_2 (void)
2374 /* InitEmpty for pvremove (2) */
2376 char device[] = "/dev/sda";
2377 device[5] = devchar;
2380 r = guestfs_blockdev_setrw (g, device);
2387 r = guestfs_umount_all (g);
2394 r = guestfs_lvm_remove_all (g);
2398 /* TestOutputList for pvremove (2) */
2400 char device[] = "/dev/sda";
2401 device[5] = devchar;
2404 r = guestfs_pvcreate (g, device);
2409 char volgroup[] = "VG";
2410 char physvols_0[] = "/dev/sda";
2411 physvols_0[5] = devchar;
2412 char *physvols[] = {
2418 r = guestfs_vgcreate (g, volgroup, physvols);
2423 char logvol[] = "LV1";
2424 char volgroup[] = "VG";
2427 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2432 char logvol[] = "LV2";
2433 char volgroup[] = "VG";
2436 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2441 char vgname[] = "VG";
2444 r = guestfs_vgremove (g, vgname);
2449 char device[] = "/dev/sda";
2450 device[5] = devchar;
2453 r = guestfs_pvremove (g, device);
2461 r = guestfs_pvs (g);
2465 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
2469 for (i = 0; r[i] != NULL; ++i)
2476 static int test_vgremove_0 (void)
2478 /* InitEmpty for vgremove (0) */
2480 char device[] = "/dev/sda";
2481 device[5] = devchar;
2484 r = guestfs_blockdev_setrw (g, device);
2491 r = guestfs_umount_all (g);
2498 r = guestfs_lvm_remove_all (g);
2502 /* TestOutputList for vgremove (0) */
2504 char device[] = "/dev/sda";
2505 device[5] = devchar;
2508 r = guestfs_pvcreate (g, device);
2513 char volgroup[] = "VG";
2514 char physvols_0[] = "/dev/sda";
2515 physvols_0[5] = devchar;
2516 char *physvols[] = {
2522 r = guestfs_vgcreate (g, volgroup, physvols);
2527 char logvol[] = "LV1";
2528 char volgroup[] = "VG";
2531 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2536 char logvol[] = "LV2";
2537 char volgroup[] = "VG";
2540 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2545 char vgname[] = "VG";
2548 r = guestfs_vgremove (g, vgname);
2556 r = guestfs_lvs (g);
2560 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
2564 for (i = 0; r[i] != NULL; ++i)
2571 static int test_vgremove_1 (void)
2573 /* InitEmpty for vgremove (1) */
2575 char device[] = "/dev/sda";
2576 device[5] = devchar;
2579 r = guestfs_blockdev_setrw (g, device);
2586 r = guestfs_umount_all (g);
2593 r = guestfs_lvm_remove_all (g);
2597 /* TestOutputList for vgremove (1) */
2599 char device[] = "/dev/sda";
2600 device[5] = devchar;
2603 r = guestfs_pvcreate (g, device);
2608 char volgroup[] = "VG";
2609 char physvols_0[] = "/dev/sda";
2610 physvols_0[5] = devchar;
2611 char *physvols[] = {
2617 r = guestfs_vgcreate (g, volgroup, physvols);
2622 char logvol[] = "LV1";
2623 char volgroup[] = "VG";
2626 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2631 char logvol[] = "LV2";
2632 char volgroup[] = "VG";
2635 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2640 char vgname[] = "VG";
2643 r = guestfs_vgremove (g, vgname);
2651 r = guestfs_vgs (g);
2655 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
2659 for (i = 0; r[i] != NULL; ++i)
2666 static int test_lvremove_0 (void)
2668 /* InitEmpty for lvremove (0) */
2670 char device[] = "/dev/sda";
2671 device[5] = devchar;
2674 r = guestfs_blockdev_setrw (g, device);
2681 r = guestfs_umount_all (g);
2688 r = guestfs_lvm_remove_all (g);
2692 /* TestOutputList for lvremove (0) */
2694 char device[] = "/dev/sda";
2695 device[5] = devchar;
2698 r = guestfs_pvcreate (g, device);
2703 char volgroup[] = "VG";
2704 char physvols_0[] = "/dev/sda";
2705 physvols_0[5] = devchar;
2706 char *physvols[] = {
2712 r = guestfs_vgcreate (g, volgroup, physvols);
2717 char logvol[] = "LV1";
2718 char volgroup[] = "VG";
2721 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2726 char logvol[] = "LV2";
2727 char volgroup[] = "VG";
2730 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2735 char device[] = "/dev/VG/LV1";
2738 r = guestfs_lvremove (g, device);
2746 r = guestfs_lvs (g);
2750 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
2755 char expected[] = "/dev/VG/LV2";
2756 if (strcmp (r[0], expected) != 0) {
2757 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2762 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
2766 for (i = 0; r[i] != NULL; ++i)
2773 static int test_lvremove_1 (void)
2775 /* InitEmpty for lvremove (1) */
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);
2799 /* TestOutputList for lvremove (1) */
2801 char device[] = "/dev/sda";
2802 device[5] = devchar;
2805 r = guestfs_pvcreate (g, device);
2810 char volgroup[] = "VG";
2811 char physvols_0[] = "/dev/sda";
2812 physvols_0[5] = devchar;
2813 char *physvols[] = {
2819 r = guestfs_vgcreate (g, volgroup, physvols);
2824 char logvol[] = "LV1";
2825 char volgroup[] = "VG";
2828 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2833 char logvol[] = "LV2";
2834 char volgroup[] = "VG";
2837 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2842 char device[] = "/dev/VG";
2845 r = guestfs_lvremove (g, device);
2853 r = guestfs_lvs (g);
2857 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
2861 for (i = 0; r[i] != NULL; ++i)
2868 static int test_lvremove_2 (void)
2870 /* InitEmpty for lvremove (2) */
2872 char device[] = "/dev/sda";
2873 device[5] = devchar;
2876 r = guestfs_blockdev_setrw (g, device);
2883 r = guestfs_umount_all (g);
2890 r = guestfs_lvm_remove_all (g);
2894 /* TestOutputList for lvremove (2) */
2896 char device[] = "/dev/sda";
2897 device[5] = devchar;
2900 r = guestfs_pvcreate (g, device);
2905 char volgroup[] = "VG";
2906 char physvols_0[] = "/dev/sda";
2907 physvols_0[5] = devchar;
2908 char *physvols[] = {
2914 r = guestfs_vgcreate (g, volgroup, physvols);
2919 char logvol[] = "LV1";
2920 char volgroup[] = "VG";
2923 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2928 char logvol[] = "LV2";
2929 char volgroup[] = "VG";
2932 r = guestfs_lvcreate (g, logvol, volgroup, 50);
2937 char device[] = "/dev/VG";
2940 r = guestfs_lvremove (g, device);
2948 r = guestfs_vgs (g);
2952 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
2957 char expected[] = "VG";
2958 if (strcmp (r[0], expected) != 0) {
2959 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
2964 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
2968 for (i = 0; r[i] != NULL; ++i)
2975 static int test_mount_ro_0 (void)
2977 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
2979 char device[] = "/dev/sda";
2980 device[5] = devchar;
2983 r = guestfs_blockdev_setrw (g, device);
2990 r = guestfs_umount_all (g);
2997 r = guestfs_lvm_remove_all (g);
3002 char device[] = "/dev/sda";
3003 device[5] = devchar;
3004 char lines_0[] = ",";
3011 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3016 char fstype[] = "ext2";
3017 char device[] = "/dev/sda1";
3018 device[5] = devchar;
3021 r = guestfs_mkfs (g, fstype, device);
3026 char device[] = "/dev/sda1";
3027 device[5] = devchar;
3028 char mountpoint[] = "/";
3031 r = guestfs_mount (g, device, mountpoint);
3035 /* TestLastFail for mount_ro (0) */
3037 char pathordevice[] = "/";
3040 r = guestfs_umount (g, pathordevice);
3045 char device[] = "/dev/sda1";
3046 device[5] = devchar;
3047 char mountpoint[] = "/";
3050 r = guestfs_mount_ro (g, device, mountpoint);
3055 char path[] = "/new";
3058 r = guestfs_touch (g, path);
3065 static int test_mount_ro_1 (void)
3067 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
3069 char device[] = "/dev/sda";
3070 device[5] = devchar;
3073 r = guestfs_blockdev_setrw (g, device);
3080 r = guestfs_umount_all (g);
3087 r = guestfs_lvm_remove_all (g);
3092 char device[] = "/dev/sda";
3093 device[5] = devchar;
3094 char lines_0[] = ",";
3101 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3106 char fstype[] = "ext2";
3107 char device[] = "/dev/sda1";
3108 device[5] = devchar;
3111 r = guestfs_mkfs (g, fstype, device);
3116 char device[] = "/dev/sda1";
3117 device[5] = devchar;
3118 char mountpoint[] = "/";
3121 r = guestfs_mount (g, device, mountpoint);
3125 /* TestOutput for mount_ro (1) */
3126 char expected[] = "data";
3128 char path[] = "/new";
3129 char content[] = "data";
3132 r = guestfs_write_file (g, path, content, 0);
3137 char pathordevice[] = "/";
3140 r = guestfs_umount (g, pathordevice);
3145 char device[] = "/dev/sda1";
3146 device[5] = devchar;
3147 char mountpoint[] = "/";
3150 r = guestfs_mount_ro (g, device, mountpoint);
3155 char path[] = "/new";
3158 r = guestfs_cat (g, path);
3161 if (strcmp (r, expected) != 0) {
3162 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
3170 static int test_tgz_in_0 (void)
3172 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
3174 char device[] = "/dev/sda";
3175 device[5] = devchar;
3178 r = guestfs_blockdev_setrw (g, device);
3185 r = guestfs_umount_all (g);
3192 r = guestfs_lvm_remove_all (g);
3197 char device[] = "/dev/sda";
3198 device[5] = devchar;
3199 char lines_0[] = ",";
3206 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3211 char fstype[] = "ext2";
3212 char device[] = "/dev/sda1";
3213 device[5] = devchar;
3216 r = guestfs_mkfs (g, fstype, device);
3221 char device[] = "/dev/sda1";
3222 device[5] = devchar;
3223 char mountpoint[] = "/";
3226 r = guestfs_mount (g, device, mountpoint);
3230 /* TestOutput for tgz_in (0) */
3231 char expected[] = "hello\n";
3233 char directory[] = "/";
3236 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory);
3241 char path[] = "/hello";
3244 r = guestfs_cat (g, path);
3247 if (strcmp (r, expected) != 0) {
3248 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3256 static int test_tar_in_0 (void)
3258 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
3260 char device[] = "/dev/sda";
3261 device[5] = devchar;
3264 r = guestfs_blockdev_setrw (g, device);
3271 r = guestfs_umount_all (g);
3278 r = guestfs_lvm_remove_all (g);
3283 char device[] = "/dev/sda";
3284 device[5] = devchar;
3285 char lines_0[] = ",";
3292 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3297 char fstype[] = "ext2";
3298 char device[] = "/dev/sda1";
3299 device[5] = devchar;
3302 r = guestfs_mkfs (g, fstype, device);
3307 char device[] = "/dev/sda1";
3308 device[5] = devchar;
3309 char mountpoint[] = "/";
3312 r = guestfs_mount (g, device, mountpoint);
3316 /* TestOutput for tar_in (0) */
3317 char expected[] = "hello\n";
3319 char directory[] = "/";
3322 r = guestfs_tar_in (g, "images/helloworld.tar", directory);
3327 char path[] = "/hello";
3330 r = guestfs_cat (g, path);
3333 if (strcmp (r, expected) != 0) {
3334 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
3342 static int test_checksum_0 (void)
3344 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
3346 char device[] = "/dev/sda";
3347 device[5] = devchar;
3350 r = guestfs_blockdev_setrw (g, device);
3357 r = guestfs_umount_all (g);
3364 r = guestfs_lvm_remove_all (g);
3369 char device[] = "/dev/sda";
3370 device[5] = devchar;
3371 char lines_0[] = ",";
3378 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3383 char fstype[] = "ext2";
3384 char device[] = "/dev/sda1";
3385 device[5] = devchar;
3388 r = guestfs_mkfs (g, fstype, device);
3393 char device[] = "/dev/sda1";
3394 device[5] = devchar;
3395 char mountpoint[] = "/";
3398 r = guestfs_mount (g, device, mountpoint);
3402 /* TestOutput for checksum (0) */
3403 char expected[] = "935282863";
3405 char path[] = "/new";
3406 char content[] = "test\n";
3409 r = guestfs_write_file (g, path, content, 0);
3414 char csumtype[] = "crc";
3415 char path[] = "/new";
3418 r = guestfs_checksum (g, csumtype, path);
3421 if (strcmp (r, expected) != 0) {
3422 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
3430 static int test_checksum_1 (void)
3432 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
3434 char device[] = "/dev/sda";
3435 device[5] = devchar;
3438 r = guestfs_blockdev_setrw (g, device);
3445 r = guestfs_umount_all (g);
3452 r = guestfs_lvm_remove_all (g);
3457 char device[] = "/dev/sda";
3458 device[5] = devchar;
3459 char lines_0[] = ",";
3466 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3471 char fstype[] = "ext2";
3472 char device[] = "/dev/sda1";
3473 device[5] = devchar;
3476 r = guestfs_mkfs (g, fstype, device);
3481 char device[] = "/dev/sda1";
3482 device[5] = devchar;
3483 char mountpoint[] = "/";
3486 r = guestfs_mount (g, device, mountpoint);
3490 /* TestLastFail for checksum (1) */
3492 char csumtype[] = "crc";
3493 char path[] = "/new";
3496 r = guestfs_checksum (g, csumtype, path);
3504 static int test_checksum_2 (void)
3506 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
3508 char device[] = "/dev/sda";
3509 device[5] = devchar;
3512 r = guestfs_blockdev_setrw (g, device);
3519 r = guestfs_umount_all (g);
3526 r = guestfs_lvm_remove_all (g);
3531 char device[] = "/dev/sda";
3532 device[5] = devchar;
3533 char lines_0[] = ",";
3540 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3545 char fstype[] = "ext2";
3546 char device[] = "/dev/sda1";
3547 device[5] = devchar;
3550 r = guestfs_mkfs (g, fstype, device);
3555 char device[] = "/dev/sda1";
3556 device[5] = devchar;
3557 char mountpoint[] = "/";
3560 r = guestfs_mount (g, device, mountpoint);
3564 /* TestOutput for checksum (2) */
3565 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
3567 char path[] = "/new";
3568 char content[] = "test\n";
3571 r = guestfs_write_file (g, path, content, 0);
3576 char csumtype[] = "md5";
3577 char path[] = "/new";
3580 r = guestfs_checksum (g, csumtype, path);
3583 if (strcmp (r, expected) != 0) {
3584 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
3592 static int test_checksum_3 (void)
3594 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
3596 char device[] = "/dev/sda";
3597 device[5] = devchar;
3600 r = guestfs_blockdev_setrw (g, device);
3607 r = guestfs_umount_all (g);
3614 r = guestfs_lvm_remove_all (g);
3619 char device[] = "/dev/sda";
3620 device[5] = devchar;
3621 char lines_0[] = ",";
3628 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3633 char fstype[] = "ext2";
3634 char device[] = "/dev/sda1";
3635 device[5] = devchar;
3638 r = guestfs_mkfs (g, fstype, device);
3643 char device[] = "/dev/sda1";
3644 device[5] = devchar;
3645 char mountpoint[] = "/";
3648 r = guestfs_mount (g, device, mountpoint);
3652 /* TestOutput for checksum (3) */
3653 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
3655 char path[] = "/new";
3656 char content[] = "test\n";
3659 r = guestfs_write_file (g, path, content, 0);
3664 char csumtype[] = "sha1";
3665 char path[] = "/new";
3668 r = guestfs_checksum (g, csumtype, path);
3671 if (strcmp (r, expected) != 0) {
3672 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
3680 static int test_checksum_4 (void)
3682 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
3684 char device[] = "/dev/sda";
3685 device[5] = devchar;
3688 r = guestfs_blockdev_setrw (g, device);
3695 r = guestfs_umount_all (g);
3702 r = guestfs_lvm_remove_all (g);
3707 char device[] = "/dev/sda";
3708 device[5] = devchar;
3709 char lines_0[] = ",";
3716 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3721 char fstype[] = "ext2";
3722 char device[] = "/dev/sda1";
3723 device[5] = devchar;
3726 r = guestfs_mkfs (g, fstype, device);
3731 char device[] = "/dev/sda1";
3732 device[5] = devchar;
3733 char mountpoint[] = "/";
3736 r = guestfs_mount (g, device, mountpoint);
3740 /* TestOutput for checksum (4) */
3741 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
3743 char path[] = "/new";
3744 char content[] = "test\n";
3747 r = guestfs_write_file (g, path, content, 0);
3752 char csumtype[] = "sha224";
3753 char path[] = "/new";
3756 r = guestfs_checksum (g, csumtype, path);
3759 if (strcmp (r, expected) != 0) {
3760 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
3768 static int test_checksum_5 (void)
3770 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
3772 char device[] = "/dev/sda";
3773 device[5] = devchar;
3776 r = guestfs_blockdev_setrw (g, device);
3783 r = guestfs_umount_all (g);
3790 r = guestfs_lvm_remove_all (g);
3795 char device[] = "/dev/sda";
3796 device[5] = devchar;
3797 char lines_0[] = ",";
3804 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3809 char fstype[] = "ext2";
3810 char device[] = "/dev/sda1";
3811 device[5] = devchar;
3814 r = guestfs_mkfs (g, fstype, device);
3819 char device[] = "/dev/sda1";
3820 device[5] = devchar;
3821 char mountpoint[] = "/";
3824 r = guestfs_mount (g, device, mountpoint);
3828 /* TestOutput for checksum (5) */
3829 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
3831 char path[] = "/new";
3832 char content[] = "test\n";
3835 r = guestfs_write_file (g, path, content, 0);
3840 char csumtype[] = "sha256";
3841 char path[] = "/new";
3844 r = guestfs_checksum (g, csumtype, path);
3847 if (strcmp (r, expected) != 0) {
3848 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
3856 static int test_checksum_6 (void)
3858 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
3860 char device[] = "/dev/sda";
3861 device[5] = devchar;
3864 r = guestfs_blockdev_setrw (g, device);
3871 r = guestfs_umount_all (g);
3878 r = guestfs_lvm_remove_all (g);
3883 char device[] = "/dev/sda";
3884 device[5] = devchar;
3885 char lines_0[] = ",";
3892 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3897 char fstype[] = "ext2";
3898 char device[] = "/dev/sda1";
3899 device[5] = devchar;
3902 r = guestfs_mkfs (g, fstype, device);
3907 char device[] = "/dev/sda1";
3908 device[5] = devchar;
3909 char mountpoint[] = "/";
3912 r = guestfs_mount (g, device, mountpoint);
3916 /* TestOutput for checksum (6) */
3917 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
3919 char path[] = "/new";
3920 char content[] = "test\n";
3923 r = guestfs_write_file (g, path, content, 0);
3928 char csumtype[] = "sha384";
3929 char path[] = "/new";
3932 r = guestfs_checksum (g, csumtype, path);
3935 if (strcmp (r, expected) != 0) {
3936 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
3944 static int test_checksum_7 (void)
3946 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
3948 char device[] = "/dev/sda";
3949 device[5] = devchar;
3952 r = guestfs_blockdev_setrw (g, device);
3959 r = guestfs_umount_all (g);
3966 r = guestfs_lvm_remove_all (g);
3971 char device[] = "/dev/sda";
3972 device[5] = devchar;
3973 char lines_0[] = ",";
3980 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3985 char fstype[] = "ext2";
3986 char device[] = "/dev/sda1";
3987 device[5] = devchar;
3990 r = guestfs_mkfs (g, fstype, device);
3995 char device[] = "/dev/sda1";
3996 device[5] = devchar;
3997 char mountpoint[] = "/";
4000 r = guestfs_mount (g, device, mountpoint);
4004 /* TestOutput for checksum (7) */
4005 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
4007 char path[] = "/new";
4008 char content[] = "test\n";
4011 r = guestfs_write_file (g, path, content, 0);
4016 char csumtype[] = "sha512";
4017 char path[] = "/new";
4020 r = guestfs_checksum (g, csumtype, path);
4023 if (strcmp (r, expected) != 0) {
4024 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
4032 static int test_download_0 (void)
4034 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
4036 char device[] = "/dev/sda";
4037 device[5] = devchar;
4040 r = guestfs_blockdev_setrw (g, device);
4047 r = guestfs_umount_all (g);
4054 r = guestfs_lvm_remove_all (g);
4059 char device[] = "/dev/sda";
4060 device[5] = devchar;
4061 char lines_0[] = ",";
4068 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4073 char fstype[] = "ext2";
4074 char device[] = "/dev/sda1";
4075 device[5] = devchar;
4078 r = guestfs_mkfs (g, fstype, device);
4083 char device[] = "/dev/sda1";
4084 device[5] = devchar;
4085 char mountpoint[] = "/";
4088 r = guestfs_mount (g, device, mountpoint);
4092 /* TestOutput for download (0) */
4093 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4095 char remotefilename[] = "/COPYING.LIB";
4098 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4103 char remotefilename[] = "/COPYING.LIB";
4106 r = guestfs_download (g, remotefilename, "testdownload.tmp");
4111 char remotefilename[] = "/upload";
4114 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
4119 char csumtype[] = "md5";
4120 char path[] = "/upload";
4123 r = guestfs_checksum (g, csumtype, path);
4126 if (strcmp (r, expected) != 0) {
4127 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
4135 static int test_upload_0 (void)
4137 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
4139 char device[] = "/dev/sda";
4140 device[5] = devchar;
4143 r = guestfs_blockdev_setrw (g, device);
4150 r = guestfs_umount_all (g);
4157 r = guestfs_lvm_remove_all (g);
4162 char device[] = "/dev/sda";
4163 device[5] = devchar;
4164 char lines_0[] = ",";
4171 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4176 char fstype[] = "ext2";
4177 char device[] = "/dev/sda1";
4178 device[5] = devchar;
4181 r = guestfs_mkfs (g, fstype, device);
4186 char device[] = "/dev/sda1";
4187 device[5] = devchar;
4188 char mountpoint[] = "/";
4191 r = guestfs_mount (g, device, mountpoint);
4195 /* TestOutput for upload (0) */
4196 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
4198 char remotefilename[] = "/COPYING.LIB";
4201 r = guestfs_upload (g, "COPYING.LIB", remotefilename);
4206 char csumtype[] = "md5";
4207 char path[] = "/COPYING.LIB";
4210 r = guestfs_checksum (g, csumtype, path);
4213 if (strcmp (r, expected) != 0) {
4214 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
4222 static int test_blockdev_rereadpt_0 (void)
4224 /* InitEmpty for blockdev_rereadpt (0) */
4226 char device[] = "/dev/sda";
4227 device[5] = devchar;
4230 r = guestfs_blockdev_setrw (g, device);
4237 r = guestfs_umount_all (g);
4244 r = guestfs_lvm_remove_all (g);
4248 /* TestRun for blockdev_rereadpt (0) */
4250 char device[] = "/dev/sda";
4251 device[5] = devchar;
4254 r = guestfs_blockdev_rereadpt (g, device);
4261 static int test_blockdev_flushbufs_0 (void)
4263 /* InitEmpty for blockdev_flushbufs (0) */
4265 char device[] = "/dev/sda";
4266 device[5] = devchar;
4269 r = guestfs_blockdev_setrw (g, device);
4276 r = guestfs_umount_all (g);
4283 r = guestfs_lvm_remove_all (g);
4287 /* TestRun for blockdev_flushbufs (0) */
4289 char device[] = "/dev/sda";
4290 device[5] = devchar;
4293 r = guestfs_blockdev_flushbufs (g, device);
4300 static int test_blockdev_getsize64_0 (void)
4302 /* InitEmpty for blockdev_getsize64 (0) */
4304 char device[] = "/dev/sda";
4305 device[5] = devchar;
4308 r = guestfs_blockdev_setrw (g, device);
4315 r = guestfs_umount_all (g);
4322 r = guestfs_lvm_remove_all (g);
4326 /* TestOutputInt for blockdev_getsize64 (0) */
4328 char device[] = "/dev/sda";
4329 device[5] = devchar;
4332 r = guestfs_blockdev_getsize64 (g, device);
4335 if (r != 524288000) {
4336 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
4343 static int test_blockdev_getsz_0 (void)
4345 /* InitEmpty for blockdev_getsz (0) */
4347 char device[] = "/dev/sda";
4348 device[5] = devchar;
4351 r = guestfs_blockdev_setrw (g, device);
4358 r = guestfs_umount_all (g);
4365 r = guestfs_lvm_remove_all (g);
4369 /* TestOutputInt for blockdev_getsz (0) */
4371 char device[] = "/dev/sda";
4372 device[5] = devchar;
4375 r = guestfs_blockdev_getsz (g, device);
4379 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
4386 static int test_blockdev_getbsz_0 (void)
4388 /* InitEmpty for blockdev_getbsz (0) */
4390 char device[] = "/dev/sda";
4391 device[5] = devchar;
4394 r = guestfs_blockdev_setrw (g, device);
4401 r = guestfs_umount_all (g);
4408 r = guestfs_lvm_remove_all (g);
4412 /* TestOutputInt for blockdev_getbsz (0) */
4414 char device[] = "/dev/sda";
4415 device[5] = devchar;
4418 r = guestfs_blockdev_getbsz (g, device);
4422 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
4429 static int test_blockdev_getss_0 (void)
4431 /* InitEmpty for blockdev_getss (0) */
4433 char device[] = "/dev/sda";
4434 device[5] = devchar;
4437 r = guestfs_blockdev_setrw (g, device);
4444 r = guestfs_umount_all (g);
4451 r = guestfs_lvm_remove_all (g);
4455 /* TestOutputInt for blockdev_getss (0) */
4457 char device[] = "/dev/sda";
4458 device[5] = devchar;
4461 r = guestfs_blockdev_getss (g, device);
4465 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
4472 static int test_blockdev_getro_0 (void)
4474 /* InitEmpty for blockdev_getro (0) */
4476 char device[] = "/dev/sda";
4477 device[5] = devchar;
4480 r = guestfs_blockdev_setrw (g, device);
4487 r = guestfs_umount_all (g);
4494 r = guestfs_lvm_remove_all (g);
4498 /* TestOutputTrue for blockdev_getro (0) */
4500 char device[] = "/dev/sda";
4501 device[5] = devchar;
4504 r = guestfs_blockdev_setro (g, device);
4509 char device[] = "/dev/sda";
4510 device[5] = devchar;
4513 r = guestfs_blockdev_getro (g, device);
4517 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
4524 static int test_blockdev_setrw_0 (void)
4526 /* InitEmpty for blockdev_setrw (0) */
4528 char device[] = "/dev/sda";
4529 device[5] = devchar;
4532 r = guestfs_blockdev_setrw (g, device);
4539 r = guestfs_umount_all (g);
4546 r = guestfs_lvm_remove_all (g);
4550 /* TestOutputFalse for blockdev_setrw (0) */
4552 char device[] = "/dev/sda";
4553 device[5] = devchar;
4556 r = guestfs_blockdev_setrw (g, device);
4561 char device[] = "/dev/sda";
4562 device[5] = devchar;
4565 r = guestfs_blockdev_getro (g, device);
4569 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
4576 static int test_blockdev_setro_0 (void)
4578 /* InitEmpty for blockdev_setro (0) */
4580 char device[] = "/dev/sda";
4581 device[5] = devchar;
4584 r = guestfs_blockdev_setrw (g, device);
4591 r = guestfs_umount_all (g);
4598 r = guestfs_lvm_remove_all (g);
4602 /* TestOutputTrue for blockdev_setro (0) */
4604 char device[] = "/dev/sda";
4605 device[5] = devchar;
4608 r = guestfs_blockdev_setro (g, device);
4613 char device[] = "/dev/sda";
4614 device[5] = devchar;
4617 r = guestfs_blockdev_getro (g, device);
4621 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
4628 static int test_statvfs_0 (void)
4630 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
4632 char device[] = "/dev/sda";
4633 device[5] = devchar;
4636 r = guestfs_blockdev_setrw (g, device);
4643 r = guestfs_umount_all (g);
4650 r = guestfs_lvm_remove_all (g);
4655 char device[] = "/dev/sda";
4656 device[5] = devchar;
4657 char lines_0[] = ",";
4664 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4669 char fstype[] = "ext2";
4670 char device[] = "/dev/sda1";
4671 device[5] = devchar;
4674 r = guestfs_mkfs (g, fstype, device);
4679 char device[] = "/dev/sda1";
4680 device[5] = devchar;
4681 char mountpoint[] = "/";
4684 r = guestfs_mount (g, device, mountpoint);
4688 /* TestOutputStruct for statvfs (0) */
4691 struct guestfs_statvfs *r;
4693 r = guestfs_statvfs (g, path);
4696 if (r->bfree != 487702) {
4697 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
4701 if (r->blocks != 490020) {
4702 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
4706 if (r->bsize != 1024) {
4707 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
4716 static int test_lstat_0 (void)
4718 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
4720 char device[] = "/dev/sda";
4721 device[5] = devchar;
4724 r = guestfs_blockdev_setrw (g, device);
4731 r = guestfs_umount_all (g);
4738 r = guestfs_lvm_remove_all (g);
4743 char device[] = "/dev/sda";
4744 device[5] = devchar;
4745 char lines_0[] = ",";
4752 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4757 char fstype[] = "ext2";
4758 char device[] = "/dev/sda1";
4759 device[5] = devchar;
4762 r = guestfs_mkfs (g, fstype, device);
4767 char device[] = "/dev/sda1";
4768 device[5] = devchar;
4769 char mountpoint[] = "/";
4772 r = guestfs_mount (g, device, mountpoint);
4776 /* TestOutputStruct for lstat (0) */
4778 char path[] = "/new";
4781 r = guestfs_touch (g, path);
4786 char path[] = "/new";
4787 struct guestfs_stat *r;
4789 r = guestfs_lstat (g, path);
4793 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
4802 static int test_stat_0 (void)
4804 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
4806 char device[] = "/dev/sda";
4807 device[5] = devchar;
4810 r = guestfs_blockdev_setrw (g, device);
4817 r = guestfs_umount_all (g);
4824 r = guestfs_lvm_remove_all (g);
4829 char device[] = "/dev/sda";
4830 device[5] = devchar;
4831 char lines_0[] = ",";
4838 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4843 char fstype[] = "ext2";
4844 char device[] = "/dev/sda1";
4845 device[5] = devchar;
4848 r = guestfs_mkfs (g, fstype, device);
4853 char device[] = "/dev/sda1";
4854 device[5] = devchar;
4855 char mountpoint[] = "/";
4858 r = guestfs_mount (g, device, mountpoint);
4862 /* TestOutputStruct for stat (0) */
4864 char path[] = "/new";
4867 r = guestfs_touch (g, path);
4872 char path[] = "/new";
4873 struct guestfs_stat *r;
4875 r = guestfs_stat (g, path);
4879 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
4888 static int test_file_0 (void)
4890 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
4892 char device[] = "/dev/sda";
4893 device[5] = devchar;
4896 r = guestfs_blockdev_setrw (g, device);
4903 r = guestfs_umount_all (g);
4910 r = guestfs_lvm_remove_all (g);
4915 char device[] = "/dev/sda";
4916 device[5] = devchar;
4917 char lines_0[] = ",";
4924 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4929 char fstype[] = "ext2";
4930 char device[] = "/dev/sda1";
4931 device[5] = devchar;
4934 r = guestfs_mkfs (g, fstype, device);
4939 char device[] = "/dev/sda1";
4940 device[5] = devchar;
4941 char mountpoint[] = "/";
4944 r = guestfs_mount (g, device, mountpoint);
4948 /* TestOutput for file (0) */
4949 char expected[] = "empty";
4951 char path[] = "/new";
4954 r = guestfs_touch (g, path);
4959 char path[] = "/new";
4962 r = guestfs_file (g, path);
4965 if (strcmp (r, expected) != 0) {
4966 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
4974 static int test_file_1 (void)
4976 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
4978 char device[] = "/dev/sda";
4979 device[5] = devchar;
4982 r = guestfs_blockdev_setrw (g, device);
4989 r = guestfs_umount_all (g);
4996 r = guestfs_lvm_remove_all (g);
5001 char device[] = "/dev/sda";
5002 device[5] = devchar;
5003 char lines_0[] = ",";
5010 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5015 char fstype[] = "ext2";
5016 char device[] = "/dev/sda1";
5017 device[5] = devchar;
5020 r = guestfs_mkfs (g, fstype, device);
5025 char device[] = "/dev/sda1";
5026 device[5] = devchar;
5027 char mountpoint[] = "/";
5030 r = guestfs_mount (g, device, mountpoint);
5034 /* TestOutput for file (1) */
5035 char expected[] = "ASCII text";
5037 char path[] = "/new";
5038 char content[] = "some content\n";
5041 r = guestfs_write_file (g, path, content, 0);
5046 char path[] = "/new";
5049 r = guestfs_file (g, path);
5052 if (strcmp (r, expected) != 0) {
5053 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5061 static int test_file_2 (void)
5063 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
5065 char device[] = "/dev/sda";
5066 device[5] = devchar;
5069 r = guestfs_blockdev_setrw (g, device);
5076 r = guestfs_umount_all (g);
5083 r = guestfs_lvm_remove_all (g);
5088 char device[] = "/dev/sda";
5089 device[5] = devchar;
5090 char lines_0[] = ",";
5097 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5102 char fstype[] = "ext2";
5103 char device[] = "/dev/sda1";
5104 device[5] = devchar;
5107 r = guestfs_mkfs (g, fstype, device);
5112 char device[] = "/dev/sda1";
5113 device[5] = devchar;
5114 char mountpoint[] = "/";
5117 r = guestfs_mount (g, device, mountpoint);
5121 /* TestLastFail for file (2) */
5123 char path[] = "/nofile";
5126 r = guestfs_file (g, path);
5134 static int test_umount_all_0 (void)
5136 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
5138 char device[] = "/dev/sda";
5139 device[5] = devchar;
5142 r = guestfs_blockdev_setrw (g, device);
5149 r = guestfs_umount_all (g);
5156 r = guestfs_lvm_remove_all (g);
5161 char device[] = "/dev/sda";
5162 device[5] = devchar;
5163 char lines_0[] = ",";
5170 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5175 char fstype[] = "ext2";
5176 char device[] = "/dev/sda1";
5177 device[5] = devchar;
5180 r = guestfs_mkfs (g, fstype, device);
5185 char device[] = "/dev/sda1";
5186 device[5] = devchar;
5187 char mountpoint[] = "/";
5190 r = guestfs_mount (g, device, mountpoint);
5194 /* TestOutputList for umount_all (0) */
5198 r = guestfs_umount_all (g);
5206 r = guestfs_mounts (g);
5210 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
5214 for (i = 0; r[i] != NULL; ++i)
5221 static int test_umount_all_1 (void)
5223 /* InitEmpty for umount_all (1) */
5225 char device[] = "/dev/sda";
5226 device[5] = devchar;
5229 r = guestfs_blockdev_setrw (g, device);
5236 r = guestfs_umount_all (g);
5243 r = guestfs_lvm_remove_all (g);
5247 /* TestOutputList for umount_all (1) */
5249 char device[] = "/dev/sda";
5250 device[5] = devchar;
5251 char lines_0[] = ",10";
5252 char lines_1[] = ",20";
5253 char lines_2[] = ",";
5262 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5267 char fstype[] = "ext2";
5268 char device[] = "/dev/sda1";
5269 device[5] = devchar;
5272 r = guestfs_mkfs (g, fstype, device);
5277 char fstype[] = "ext2";
5278 char device[] = "/dev/sda2";
5279 device[5] = devchar;
5282 r = guestfs_mkfs (g, fstype, device);
5287 char fstype[] = "ext2";
5288 char device[] = "/dev/sda3";
5289 device[5] = devchar;
5292 r = guestfs_mkfs (g, fstype, device);
5297 char device[] = "/dev/sda1";
5298 device[5] = devchar;
5299 char mountpoint[] = "/";
5302 r = guestfs_mount (g, device, mountpoint);
5307 char path[] = "/mp1";
5310 r = guestfs_mkdir (g, path);
5315 char device[] = "/dev/sda2";
5316 device[5] = devchar;
5317 char mountpoint[] = "/mp1";
5320 r = guestfs_mount (g, device, mountpoint);
5325 char path[] = "/mp1/mp2";
5328 r = guestfs_mkdir (g, path);
5333 char device[] = "/dev/sda3";
5334 device[5] = devchar;
5335 char mountpoint[] = "/mp1/mp2";
5338 r = guestfs_mount (g, device, mountpoint);
5343 char path[] = "/mp1/mp2/mp3";
5346 r = guestfs_mkdir (g, path);
5353 r = guestfs_umount_all (g);
5361 r = guestfs_mounts (g);
5365 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
5369 for (i = 0; r[i] != NULL; ++i)
5376 static int test_mounts_0 (void)
5378 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
5380 char device[] = "/dev/sda";
5381 device[5] = devchar;
5384 r = guestfs_blockdev_setrw (g, device);
5391 r = guestfs_umount_all (g);
5398 r = guestfs_lvm_remove_all (g);
5403 char device[] = "/dev/sda";
5404 device[5] = devchar;
5405 char lines_0[] = ",";
5412 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5417 char fstype[] = "ext2";
5418 char device[] = "/dev/sda1";
5419 device[5] = devchar;
5422 r = guestfs_mkfs (g, fstype, device);
5427 char device[] = "/dev/sda1";
5428 device[5] = devchar;
5429 char mountpoint[] = "/";
5432 r = guestfs_mount (g, device, mountpoint);
5436 /* TestOutputList for mounts (0) */
5441 r = guestfs_mounts (g);
5445 fprintf (stderr, "test_mounts_0: short list returned from command\n");
5450 char expected[] = "/dev/sda1";
5451 expected[5] = devchar;
5452 if (strcmp (r[0], expected) != 0) {
5453 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5458 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
5462 for (i = 0; r[i] != NULL; ++i)
5469 static int test_umount_0 (void)
5471 /* InitEmpty for umount (0) */
5473 char device[] = "/dev/sda";
5474 device[5] = devchar;
5477 r = guestfs_blockdev_setrw (g, device);
5484 r = guestfs_umount_all (g);
5491 r = guestfs_lvm_remove_all (g);
5495 /* TestOutputList for umount (0) */
5497 char device[] = "/dev/sda";
5498 device[5] = devchar;
5499 char lines_0[] = ",";
5506 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5511 char fstype[] = "ext2";
5512 char device[] = "/dev/sda1";
5513 device[5] = devchar;
5516 r = guestfs_mkfs (g, fstype, device);
5521 char device[] = "/dev/sda1";
5522 device[5] = devchar;
5523 char mountpoint[] = "/";
5526 r = guestfs_mount (g, device, mountpoint);
5534 r = guestfs_mounts (g);
5538 fprintf (stderr, "test_umount_0: short list returned from command\n");
5543 char expected[] = "/dev/sda1";
5544 expected[5] = devchar;
5545 if (strcmp (r[0], expected) != 0) {
5546 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
5551 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
5555 for (i = 0; r[i] != NULL; ++i)
5562 static int test_umount_1 (void)
5564 /* InitEmpty for umount (1) */
5566 char device[] = "/dev/sda";
5567 device[5] = devchar;
5570 r = guestfs_blockdev_setrw (g, device);
5577 r = guestfs_umount_all (g);
5584 r = guestfs_lvm_remove_all (g);
5588 /* TestOutputList for umount (1) */
5590 char device[] = "/dev/sda";
5591 device[5] = devchar;
5592 char lines_0[] = ",";
5599 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5604 char fstype[] = "ext2";
5605 char device[] = "/dev/sda1";
5606 device[5] = devchar;
5609 r = guestfs_mkfs (g, fstype, device);
5614 char device[] = "/dev/sda1";
5615 device[5] = devchar;
5616 char mountpoint[] = "/";
5619 r = guestfs_mount (g, device, mountpoint);
5624 char pathordevice[] = "/";
5627 r = guestfs_umount (g, pathordevice);
5635 r = guestfs_mounts (g);
5639 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
5643 for (i = 0; r[i] != NULL; ++i)
5650 static int test_write_file_0 (void)
5652 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
5654 char device[] = "/dev/sda";
5655 device[5] = devchar;
5658 r = guestfs_blockdev_setrw (g, device);
5665 r = guestfs_umount_all (g);
5672 r = guestfs_lvm_remove_all (g);
5677 char device[] = "/dev/sda";
5678 device[5] = devchar;
5679 char lines_0[] = ",";
5686 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5691 char fstype[] = "ext2";
5692 char device[] = "/dev/sda1";
5693 device[5] = devchar;
5696 r = guestfs_mkfs (g, fstype, device);
5701 char device[] = "/dev/sda1";
5702 device[5] = devchar;
5703 char mountpoint[] = "/";
5706 r = guestfs_mount (g, device, mountpoint);
5710 /* TestOutput for write_file (0) */
5711 char expected[] = "new file contents";
5713 char path[] = "/new";
5714 char content[] = "new file contents";
5717 r = guestfs_write_file (g, path, content, 0);
5722 char path[] = "/new";
5725 r = guestfs_cat (g, path);
5728 if (strcmp (r, expected) != 0) {
5729 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
5737 static int test_write_file_1 (void)
5739 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
5741 char device[] = "/dev/sda";
5742 device[5] = devchar;
5745 r = guestfs_blockdev_setrw (g, device);
5752 r = guestfs_umount_all (g);
5759 r = guestfs_lvm_remove_all (g);
5764 char device[] = "/dev/sda";
5765 device[5] = devchar;
5766 char lines_0[] = ",";
5773 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5778 char fstype[] = "ext2";
5779 char device[] = "/dev/sda1";
5780 device[5] = devchar;
5783 r = guestfs_mkfs (g, fstype, device);
5788 char device[] = "/dev/sda1";
5789 device[5] = devchar;
5790 char mountpoint[] = "/";
5793 r = guestfs_mount (g, device, mountpoint);
5797 /* TestOutput for write_file (1) */
5798 char expected[] = "\nnew file contents\n";
5800 char path[] = "/new";
5801 char content[] = "\nnew file contents\n";
5804 r = guestfs_write_file (g, path, content, 0);
5809 char path[] = "/new";
5812 r = guestfs_cat (g, path);
5815 if (strcmp (r, expected) != 0) {
5816 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
5824 static int test_write_file_2 (void)
5826 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
5828 char device[] = "/dev/sda";
5829 device[5] = devchar;
5832 r = guestfs_blockdev_setrw (g, device);
5839 r = guestfs_umount_all (g);
5846 r = guestfs_lvm_remove_all (g);
5851 char device[] = "/dev/sda";
5852 device[5] = devchar;
5853 char lines_0[] = ",";
5860 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5865 char fstype[] = "ext2";
5866 char device[] = "/dev/sda1";
5867 device[5] = devchar;
5870 r = guestfs_mkfs (g, fstype, device);
5875 char device[] = "/dev/sda1";
5876 device[5] = devchar;
5877 char mountpoint[] = "/";
5880 r = guestfs_mount (g, device, mountpoint);
5884 /* TestOutput for write_file (2) */
5885 char expected[] = "\n\n";
5887 char path[] = "/new";
5888 char content[] = "\n\n";
5891 r = guestfs_write_file (g, path, content, 0);
5896 char path[] = "/new";
5899 r = guestfs_cat (g, path);
5902 if (strcmp (r, expected) != 0) {
5903 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
5911 static int test_write_file_3 (void)
5913 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
5915 char device[] = "/dev/sda";
5916 device[5] = devchar;
5919 r = guestfs_blockdev_setrw (g, device);
5926 r = guestfs_umount_all (g);
5933 r = guestfs_lvm_remove_all (g);
5938 char device[] = "/dev/sda";
5939 device[5] = devchar;
5940 char lines_0[] = ",";
5947 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5952 char fstype[] = "ext2";
5953 char device[] = "/dev/sda1";
5954 device[5] = devchar;
5957 r = guestfs_mkfs (g, fstype, device);
5962 char device[] = "/dev/sda1";
5963 device[5] = devchar;
5964 char mountpoint[] = "/";
5967 r = guestfs_mount (g, device, mountpoint);
5971 /* TestOutput for write_file (3) */
5972 char expected[] = "";
5974 char path[] = "/new";
5975 char content[] = "";
5978 r = guestfs_write_file (g, path, content, 0);
5983 char path[] = "/new";
5986 r = guestfs_cat (g, path);
5989 if (strcmp (r, expected) != 0) {
5990 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
5998 static int test_write_file_4 (void)
6000 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
6002 char device[] = "/dev/sda";
6003 device[5] = devchar;
6006 r = guestfs_blockdev_setrw (g, device);
6013 r = guestfs_umount_all (g);
6020 r = guestfs_lvm_remove_all (g);
6025 char device[] = "/dev/sda";
6026 device[5] = devchar;
6027 char lines_0[] = ",";
6034 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6039 char fstype[] = "ext2";
6040 char device[] = "/dev/sda1";
6041 device[5] = devchar;
6044 r = guestfs_mkfs (g, fstype, device);
6049 char device[] = "/dev/sda1";
6050 device[5] = devchar;
6051 char mountpoint[] = "/";
6054 r = guestfs_mount (g, device, mountpoint);
6058 /* TestOutput for write_file (4) */
6059 char expected[] = "\n\n\n";
6061 char path[] = "/new";
6062 char content[] = "\n\n\n";
6065 r = guestfs_write_file (g, path, content, 0);
6070 char path[] = "/new";
6073 r = guestfs_cat (g, path);
6076 if (strcmp (r, expected) != 0) {
6077 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
6085 static int test_write_file_5 (void)
6087 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
6089 char device[] = "/dev/sda";
6090 device[5] = devchar;
6093 r = guestfs_blockdev_setrw (g, device);
6100 r = guestfs_umount_all (g);
6107 r = guestfs_lvm_remove_all (g);
6112 char device[] = "/dev/sda";
6113 device[5] = devchar;
6114 char lines_0[] = ",";
6121 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6126 char fstype[] = "ext2";
6127 char device[] = "/dev/sda1";
6128 device[5] = devchar;
6131 r = guestfs_mkfs (g, fstype, device);
6136 char device[] = "/dev/sda1";
6137 device[5] = devchar;
6138 char mountpoint[] = "/";
6141 r = guestfs_mount (g, device, mountpoint);
6145 /* TestOutput for write_file (5) */
6146 char expected[] = "\n";
6148 char path[] = "/new";
6149 char content[] = "\n";
6152 r = guestfs_write_file (g, path, content, 0);
6157 char path[] = "/new";
6160 r = guestfs_cat (g, path);
6163 if (strcmp (r, expected) != 0) {
6164 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
6172 static int test_mkfs_0 (void)
6174 /* InitEmpty for mkfs (0) */
6176 char device[] = "/dev/sda";
6177 device[5] = devchar;
6180 r = guestfs_blockdev_setrw (g, device);
6187 r = guestfs_umount_all (g);
6194 r = guestfs_lvm_remove_all (g);
6198 /* TestOutput for mkfs (0) */
6199 char expected[] = "new file contents";
6201 char device[] = "/dev/sda";
6202 device[5] = devchar;
6203 char lines_0[] = ",";
6210 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6215 char fstype[] = "ext2";
6216 char device[] = "/dev/sda1";
6217 device[5] = devchar;
6220 r = guestfs_mkfs (g, fstype, device);
6225 char device[] = "/dev/sda1";
6226 device[5] = devchar;
6227 char mountpoint[] = "/";
6230 r = guestfs_mount (g, device, mountpoint);
6235 char path[] = "/new";
6236 char content[] = "new file contents";
6239 r = guestfs_write_file (g, path, content, 0);
6244 char path[] = "/new";
6247 r = guestfs_cat (g, path);
6250 if (strcmp (r, expected) != 0) {
6251 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
6259 static int test_lvcreate_0 (void)
6261 /* InitEmpty for lvcreate (0) */
6263 char device[] = "/dev/sda";
6264 device[5] = devchar;
6267 r = guestfs_blockdev_setrw (g, device);
6274 r = guestfs_umount_all (g);
6281 r = guestfs_lvm_remove_all (g);
6285 /* TestOutputList for lvcreate (0) */
6287 char device[] = "/dev/sda";
6288 device[5] = devchar;
6289 char lines_0[] = ",10";
6290 char lines_1[] = ",20";
6291 char lines_2[] = ",";
6300 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6305 char device[] = "/dev/sda1";
6306 device[5] = devchar;
6309 r = guestfs_pvcreate (g, device);
6314 char device[] = "/dev/sda2";
6315 device[5] = devchar;
6318 r = guestfs_pvcreate (g, device);
6323 char device[] = "/dev/sda3";
6324 device[5] = devchar;
6327 r = guestfs_pvcreate (g, device);
6332 char volgroup[] = "VG1";
6333 char physvols_0[] = "/dev/sda1";
6334 physvols_0[5] = devchar;
6335 char physvols_1[] = "/dev/sda2";
6336 physvols_1[5] = devchar;
6337 char *physvols[] = {
6344 r = guestfs_vgcreate (g, volgroup, physvols);
6349 char volgroup[] = "VG2";
6350 char physvols_0[] = "/dev/sda3";
6351 physvols_0[5] = devchar;
6352 char *physvols[] = {
6358 r = guestfs_vgcreate (g, volgroup, physvols);
6363 char logvol[] = "LV1";
6364 char volgroup[] = "VG1";
6367 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6372 char logvol[] = "LV2";
6373 char volgroup[] = "VG1";
6376 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6381 char logvol[] = "LV3";
6382 char volgroup[] = "VG2";
6385 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6390 char logvol[] = "LV4";
6391 char volgroup[] = "VG2";
6394 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6399 char logvol[] = "LV5";
6400 char volgroup[] = "VG2";
6403 r = guestfs_lvcreate (g, logvol, volgroup, 50);
6411 r = guestfs_lvs (g);
6415 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6420 char expected[] = "/dev/VG1/LV1";
6421 if (strcmp (r[0], expected) != 0) {
6422 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6427 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6432 char expected[] = "/dev/VG1/LV2";
6433 if (strcmp (r[1], expected) != 0) {
6434 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6439 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6444 char expected[] = "/dev/VG2/LV3";
6445 if (strcmp (r[2], expected) != 0) {
6446 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6451 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6456 char expected[] = "/dev/VG2/LV4";
6457 if (strcmp (r[3], expected) != 0) {
6458 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
6463 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
6468 char expected[] = "/dev/VG2/LV5";
6469 if (strcmp (r[4], expected) != 0) {
6470 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
6475 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
6479 for (i = 0; r[i] != NULL; ++i)
6486 static int test_vgcreate_0 (void)
6488 /* InitEmpty for vgcreate (0) */
6490 char device[] = "/dev/sda";
6491 device[5] = devchar;
6494 r = guestfs_blockdev_setrw (g, device);
6501 r = guestfs_umount_all (g);
6508 r = guestfs_lvm_remove_all (g);
6512 /* TestOutputList for vgcreate (0) */
6514 char device[] = "/dev/sda";
6515 device[5] = devchar;
6516 char lines_0[] = ",10";
6517 char lines_1[] = ",20";
6518 char lines_2[] = ",";
6527 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6532 char device[] = "/dev/sda1";
6533 device[5] = devchar;
6536 r = guestfs_pvcreate (g, device);
6541 char device[] = "/dev/sda2";
6542 device[5] = devchar;
6545 r = guestfs_pvcreate (g, device);
6550 char device[] = "/dev/sda3";
6551 device[5] = devchar;
6554 r = guestfs_pvcreate (g, device);
6559 char volgroup[] = "VG1";
6560 char physvols_0[] = "/dev/sda1";
6561 physvols_0[5] = devchar;
6562 char physvols_1[] = "/dev/sda2";
6563 physvols_1[5] = devchar;
6564 char *physvols[] = {
6571 r = guestfs_vgcreate (g, volgroup, physvols);
6576 char volgroup[] = "VG2";
6577 char physvols_0[] = "/dev/sda3";
6578 physvols_0[5] = devchar;
6579 char *physvols[] = {
6585 r = guestfs_vgcreate (g, volgroup, physvols);
6593 r = guestfs_vgs (g);
6597 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6602 char expected[] = "VG1";
6603 if (strcmp (r[0], expected) != 0) {
6604 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6609 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
6614 char expected[] = "VG2";
6615 if (strcmp (r[1], expected) != 0) {
6616 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6621 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
6625 for (i = 0; r[i] != NULL; ++i)
6632 static int test_pvcreate_0 (void)
6634 /* InitEmpty for pvcreate (0) */
6636 char device[] = "/dev/sda";
6637 device[5] = devchar;
6640 r = guestfs_blockdev_setrw (g, device);
6647 r = guestfs_umount_all (g);
6654 r = guestfs_lvm_remove_all (g);
6658 /* TestOutputList for pvcreate (0) */
6660 char device[] = "/dev/sda";
6661 device[5] = devchar;
6662 char lines_0[] = ",10";
6663 char lines_1[] = ",20";
6664 char lines_2[] = ",";
6673 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6678 char device[] = "/dev/sda1";
6679 device[5] = devchar;
6682 r = guestfs_pvcreate (g, device);
6687 char device[] = "/dev/sda2";
6688 device[5] = devchar;
6691 r = guestfs_pvcreate (g, device);
6696 char device[] = "/dev/sda3";
6697 device[5] = devchar;
6700 r = guestfs_pvcreate (g, device);
6708 r = guestfs_pvs (g);
6712 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6717 char expected[] = "/dev/sda1";
6718 expected[5] = devchar;
6719 if (strcmp (r[0], expected) != 0) {
6720 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
6725 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6730 char expected[] = "/dev/sda2";
6731 expected[5] = devchar;
6732 if (strcmp (r[1], expected) != 0) {
6733 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
6738 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
6743 char expected[] = "/dev/sda3";
6744 expected[5] = devchar;
6745 if (strcmp (r[2], expected) != 0) {
6746 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
6751 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
6755 for (i = 0; r[i] != NULL; ++i)
6762 static int test_is_dir_0 (void)
6764 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
6766 char device[] = "/dev/sda";
6767 device[5] = devchar;
6770 r = guestfs_blockdev_setrw (g, device);
6777 r = guestfs_umount_all (g);
6784 r = guestfs_lvm_remove_all (g);
6789 char device[] = "/dev/sda";
6790 device[5] = devchar;
6791 char lines_0[] = ",";
6798 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6803 char fstype[] = "ext2";
6804 char device[] = "/dev/sda1";
6805 device[5] = devchar;
6808 r = guestfs_mkfs (g, fstype, device);
6813 char device[] = "/dev/sda1";
6814 device[5] = devchar;
6815 char mountpoint[] = "/";
6818 r = guestfs_mount (g, device, mountpoint);
6822 /* TestOutputFalse for is_dir (0) */
6824 char path[] = "/new";
6827 r = guestfs_touch (g, path);
6832 char path[] = "/new";
6835 r = guestfs_is_dir (g, path);
6839 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
6846 static int test_is_dir_1 (void)
6848 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
6850 char device[] = "/dev/sda";
6851 device[5] = devchar;
6854 r = guestfs_blockdev_setrw (g, device);
6861 r = guestfs_umount_all (g);
6868 r = guestfs_lvm_remove_all (g);
6873 char device[] = "/dev/sda";
6874 device[5] = devchar;
6875 char lines_0[] = ",";
6882 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6887 char fstype[] = "ext2";
6888 char device[] = "/dev/sda1";
6889 device[5] = devchar;
6892 r = guestfs_mkfs (g, fstype, device);
6897 char device[] = "/dev/sda1";
6898 device[5] = devchar;
6899 char mountpoint[] = "/";
6902 r = guestfs_mount (g, device, mountpoint);
6906 /* TestOutputTrue for is_dir (1) */
6908 char path[] = "/new";
6911 r = guestfs_mkdir (g, path);
6916 char path[] = "/new";
6919 r = guestfs_is_dir (g, path);
6923 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
6930 static int test_is_file_0 (void)
6932 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
6934 char device[] = "/dev/sda";
6935 device[5] = devchar;
6938 r = guestfs_blockdev_setrw (g, device);
6945 r = guestfs_umount_all (g);
6952 r = guestfs_lvm_remove_all (g);
6957 char device[] = "/dev/sda";
6958 device[5] = devchar;
6959 char lines_0[] = ",";
6966 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6971 char fstype[] = "ext2";
6972 char device[] = "/dev/sda1";
6973 device[5] = devchar;
6976 r = guestfs_mkfs (g, fstype, device);
6981 char device[] = "/dev/sda1";
6982 device[5] = devchar;
6983 char mountpoint[] = "/";
6986 r = guestfs_mount (g, device, mountpoint);
6990 /* TestOutputTrue for is_file (0) */
6992 char path[] = "/new";
6995 r = guestfs_touch (g, path);
7000 char path[] = "/new";
7003 r = guestfs_is_file (g, path);
7007 fprintf (stderr, "test_is_file_0: expected true, got false\n");
7014 static int test_is_file_1 (void)
7016 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
7018 char device[] = "/dev/sda";
7019 device[5] = devchar;
7022 r = guestfs_blockdev_setrw (g, device);
7029 r = guestfs_umount_all (g);
7036 r = guestfs_lvm_remove_all (g);
7041 char device[] = "/dev/sda";
7042 device[5] = devchar;
7043 char lines_0[] = ",";
7050 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7055 char fstype[] = "ext2";
7056 char device[] = "/dev/sda1";
7057 device[5] = devchar;
7060 r = guestfs_mkfs (g, fstype, device);
7065 char device[] = "/dev/sda1";
7066 device[5] = devchar;
7067 char mountpoint[] = "/";
7070 r = guestfs_mount (g, device, mountpoint);
7074 /* TestOutputFalse for is_file (1) */
7076 char path[] = "/new";
7079 r = guestfs_mkdir (g, path);
7084 char path[] = "/new";
7087 r = guestfs_is_file (g, path);
7091 fprintf (stderr, "test_is_file_1: expected false, got true\n");
7098 static int test_exists_0 (void)
7100 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
7102 char device[] = "/dev/sda";
7103 device[5] = devchar;
7106 r = guestfs_blockdev_setrw (g, device);
7113 r = guestfs_umount_all (g);
7120 r = guestfs_lvm_remove_all (g);
7125 char device[] = "/dev/sda";
7126 device[5] = devchar;
7127 char lines_0[] = ",";
7134 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7139 char fstype[] = "ext2";
7140 char device[] = "/dev/sda1";
7141 device[5] = devchar;
7144 r = guestfs_mkfs (g, fstype, device);
7149 char device[] = "/dev/sda1";
7150 device[5] = devchar;
7151 char mountpoint[] = "/";
7154 r = guestfs_mount (g, device, mountpoint);
7158 /* TestOutputTrue for exists (0) */
7160 char path[] = "/new";
7163 r = guestfs_touch (g, path);
7168 char path[] = "/new";
7171 r = guestfs_exists (g, path);
7175 fprintf (stderr, "test_exists_0: expected true, got false\n");
7182 static int test_exists_1 (void)
7184 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
7186 char device[] = "/dev/sda";
7187 device[5] = devchar;
7190 r = guestfs_blockdev_setrw (g, device);
7197 r = guestfs_umount_all (g);
7204 r = guestfs_lvm_remove_all (g);
7209 char device[] = "/dev/sda";
7210 device[5] = devchar;
7211 char lines_0[] = ",";
7218 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7223 char fstype[] = "ext2";
7224 char device[] = "/dev/sda1";
7225 device[5] = devchar;
7228 r = guestfs_mkfs (g, fstype, device);
7233 char device[] = "/dev/sda1";
7234 device[5] = devchar;
7235 char mountpoint[] = "/";
7238 r = guestfs_mount (g, device, mountpoint);
7242 /* TestOutputTrue for exists (1) */
7244 char path[] = "/new";
7247 r = guestfs_mkdir (g, path);
7252 char path[] = "/new";
7255 r = guestfs_exists (g, path);
7259 fprintf (stderr, "test_exists_1: expected true, got false\n");
7266 static int test_mkdir_p_0 (void)
7268 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
7270 char device[] = "/dev/sda";
7271 device[5] = devchar;
7274 r = guestfs_blockdev_setrw (g, device);
7281 r = guestfs_umount_all (g);
7288 r = guestfs_lvm_remove_all (g);
7293 char device[] = "/dev/sda";
7294 device[5] = devchar;
7295 char lines_0[] = ",";
7302 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7307 char fstype[] = "ext2";
7308 char device[] = "/dev/sda1";
7309 device[5] = devchar;
7312 r = guestfs_mkfs (g, fstype, device);
7317 char device[] = "/dev/sda1";
7318 device[5] = devchar;
7319 char mountpoint[] = "/";
7322 r = guestfs_mount (g, device, mountpoint);
7326 /* TestOutputTrue for mkdir_p (0) */
7328 char path[] = "/new/foo/bar";
7331 r = guestfs_mkdir_p (g, path);
7336 char path[] = "/new/foo/bar";
7339 r = guestfs_is_dir (g, path);
7343 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
7350 static int test_mkdir_p_1 (void)
7352 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
7354 char device[] = "/dev/sda";
7355 device[5] = devchar;
7358 r = guestfs_blockdev_setrw (g, device);
7365 r = guestfs_umount_all (g);
7372 r = guestfs_lvm_remove_all (g);
7377 char device[] = "/dev/sda";
7378 device[5] = devchar;
7379 char lines_0[] = ",";
7386 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7391 char fstype[] = "ext2";
7392 char device[] = "/dev/sda1";
7393 device[5] = devchar;
7396 r = guestfs_mkfs (g, fstype, device);
7401 char device[] = "/dev/sda1";
7402 device[5] = devchar;
7403 char mountpoint[] = "/";
7406 r = guestfs_mount (g, device, mountpoint);
7410 /* TestOutputTrue for mkdir_p (1) */
7412 char path[] = "/new/foo/bar";
7415 r = guestfs_mkdir_p (g, path);
7420 char path[] = "/new/foo";
7423 r = guestfs_is_dir (g, path);
7427 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
7434 static int test_mkdir_p_2 (void)
7436 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
7438 char device[] = "/dev/sda";
7439 device[5] = devchar;
7442 r = guestfs_blockdev_setrw (g, device);
7449 r = guestfs_umount_all (g);
7456 r = guestfs_lvm_remove_all (g);
7461 char device[] = "/dev/sda";
7462 device[5] = devchar;
7463 char lines_0[] = ",";
7470 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7475 char fstype[] = "ext2";
7476 char device[] = "/dev/sda1";
7477 device[5] = devchar;
7480 r = guestfs_mkfs (g, fstype, device);
7485 char device[] = "/dev/sda1";
7486 device[5] = devchar;
7487 char mountpoint[] = "/";
7490 r = guestfs_mount (g, device, mountpoint);
7494 /* TestOutputTrue for mkdir_p (2) */
7496 char path[] = "/new/foo/bar";
7499 r = guestfs_mkdir_p (g, path);
7504 char path[] = "/new";
7507 r = guestfs_is_dir (g, path);
7511 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
7518 static int test_mkdir_0 (void)
7520 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
7522 char device[] = "/dev/sda";
7523 device[5] = devchar;
7526 r = guestfs_blockdev_setrw (g, device);
7533 r = guestfs_umount_all (g);
7540 r = guestfs_lvm_remove_all (g);
7545 char device[] = "/dev/sda";
7546 device[5] = devchar;
7547 char lines_0[] = ",";
7554 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7559 char fstype[] = "ext2";
7560 char device[] = "/dev/sda1";
7561 device[5] = devchar;
7564 r = guestfs_mkfs (g, fstype, device);
7569 char device[] = "/dev/sda1";
7570 device[5] = devchar;
7571 char mountpoint[] = "/";
7574 r = guestfs_mount (g, device, mountpoint);
7578 /* TestOutputTrue for mkdir (0) */
7580 char path[] = "/new";
7583 r = guestfs_mkdir (g, path);
7588 char path[] = "/new";
7591 r = guestfs_is_dir (g, path);
7595 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
7602 static int test_mkdir_1 (void)
7604 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
7606 char device[] = "/dev/sda";
7607 device[5] = devchar;
7610 r = guestfs_blockdev_setrw (g, device);
7617 r = guestfs_umount_all (g);
7624 r = guestfs_lvm_remove_all (g);
7629 char device[] = "/dev/sda";
7630 device[5] = devchar;
7631 char lines_0[] = ",";
7638 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7643 char fstype[] = "ext2";
7644 char device[] = "/dev/sda1";
7645 device[5] = devchar;
7648 r = guestfs_mkfs (g, fstype, device);
7653 char device[] = "/dev/sda1";
7654 device[5] = devchar;
7655 char mountpoint[] = "/";
7658 r = guestfs_mount (g, device, mountpoint);
7662 /* TestLastFail for mkdir (1) */
7664 char path[] = "/new/foo/bar";
7667 r = guestfs_mkdir (g, path);
7674 static int test_rm_rf_0 (void)
7676 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
7678 char device[] = "/dev/sda";
7679 device[5] = devchar;
7682 r = guestfs_blockdev_setrw (g, device);
7689 r = guestfs_umount_all (g);
7696 r = guestfs_lvm_remove_all (g);
7701 char device[] = "/dev/sda";
7702 device[5] = devchar;
7703 char lines_0[] = ",";
7710 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7715 char fstype[] = "ext2";
7716 char device[] = "/dev/sda1";
7717 device[5] = devchar;
7720 r = guestfs_mkfs (g, fstype, device);
7725 char device[] = "/dev/sda1";
7726 device[5] = devchar;
7727 char mountpoint[] = "/";
7730 r = guestfs_mount (g, device, mountpoint);
7734 /* TestOutputFalse for rm_rf (0) */
7736 char path[] = "/new";
7739 r = guestfs_mkdir (g, path);
7744 char path[] = "/new/foo";
7747 r = guestfs_mkdir (g, path);
7752 char path[] = "/new/foo/bar";
7755 r = guestfs_touch (g, path);
7760 char path[] = "/new";
7763 r = guestfs_rm_rf (g, path);
7768 char path[] = "/new";
7771 r = guestfs_exists (g, path);
7775 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
7782 static int test_rmdir_0 (void)
7784 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
7786 char device[] = "/dev/sda";
7787 device[5] = devchar;
7790 r = guestfs_blockdev_setrw (g, device);
7797 r = guestfs_umount_all (g);
7804 r = guestfs_lvm_remove_all (g);
7809 char device[] = "/dev/sda";
7810 device[5] = devchar;
7811 char lines_0[] = ",";
7818 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7823 char fstype[] = "ext2";
7824 char device[] = "/dev/sda1";
7825 device[5] = devchar;
7828 r = guestfs_mkfs (g, fstype, device);
7833 char device[] = "/dev/sda1";
7834 device[5] = devchar;
7835 char mountpoint[] = "/";
7838 r = guestfs_mount (g, device, mountpoint);
7842 /* TestRun for rmdir (0) */
7844 char path[] = "/new";
7847 r = guestfs_mkdir (g, path);
7852 char path[] = "/new";
7855 r = guestfs_rmdir (g, path);
7862 static int test_rmdir_1 (void)
7864 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
7866 char device[] = "/dev/sda";
7867 device[5] = devchar;
7870 r = guestfs_blockdev_setrw (g, device);
7877 r = guestfs_umount_all (g);
7884 r = guestfs_lvm_remove_all (g);
7889 char device[] = "/dev/sda";
7890 device[5] = devchar;
7891 char lines_0[] = ",";
7898 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7903 char fstype[] = "ext2";
7904 char device[] = "/dev/sda1";
7905 device[5] = devchar;
7908 r = guestfs_mkfs (g, fstype, device);
7913 char device[] = "/dev/sda1";
7914 device[5] = devchar;
7915 char mountpoint[] = "/";
7918 r = guestfs_mount (g, device, mountpoint);
7922 /* TestLastFail for rmdir (1) */
7924 char path[] = "/new";
7927 r = guestfs_rmdir (g, path);
7934 static int test_rmdir_2 (void)
7936 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
7938 char device[] = "/dev/sda";
7939 device[5] = devchar;
7942 r = guestfs_blockdev_setrw (g, device);
7949 r = guestfs_umount_all (g);
7956 r = guestfs_lvm_remove_all (g);
7961 char device[] = "/dev/sda";
7962 device[5] = devchar;
7963 char lines_0[] = ",";
7970 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7975 char fstype[] = "ext2";
7976 char device[] = "/dev/sda1";
7977 device[5] = devchar;
7980 r = guestfs_mkfs (g, fstype, device);
7985 char device[] = "/dev/sda1";
7986 device[5] = devchar;
7987 char mountpoint[] = "/";
7990 r = guestfs_mount (g, device, mountpoint);
7994 /* TestLastFail for rmdir (2) */
7996 char path[] = "/new";
7999 r = guestfs_touch (g, path);
8004 char path[] = "/new";
8007 r = guestfs_rmdir (g, path);
8014 static int test_rm_0 (void)
8016 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
8018 char device[] = "/dev/sda";
8019 device[5] = devchar;
8022 r = guestfs_blockdev_setrw (g, device);
8029 r = guestfs_umount_all (g);
8036 r = guestfs_lvm_remove_all (g);
8041 char device[] = "/dev/sda";
8042 device[5] = devchar;
8043 char lines_0[] = ",";
8050 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8055 char fstype[] = "ext2";
8056 char device[] = "/dev/sda1";
8057 device[5] = devchar;
8060 r = guestfs_mkfs (g, fstype, device);
8065 char device[] = "/dev/sda1";
8066 device[5] = devchar;
8067 char mountpoint[] = "/";
8070 r = guestfs_mount (g, device, mountpoint);
8074 /* TestRun for rm (0) */
8076 char path[] = "/new";
8079 r = guestfs_touch (g, path);
8084 char path[] = "/new";
8087 r = guestfs_rm (g, path);
8094 static int test_rm_1 (void)
8096 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
8098 char device[] = "/dev/sda";
8099 device[5] = devchar;
8102 r = guestfs_blockdev_setrw (g, device);
8109 r = guestfs_umount_all (g);
8116 r = guestfs_lvm_remove_all (g);
8121 char device[] = "/dev/sda";
8122 device[5] = devchar;
8123 char lines_0[] = ",";
8130 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8135 char fstype[] = "ext2";
8136 char device[] = "/dev/sda1";
8137 device[5] = devchar;
8140 r = guestfs_mkfs (g, fstype, device);
8145 char device[] = "/dev/sda1";
8146 device[5] = devchar;
8147 char mountpoint[] = "/";
8150 r = guestfs_mount (g, device, mountpoint);
8154 /* TestLastFail for rm (1) */
8156 char path[] = "/new";
8159 r = guestfs_rm (g, path);
8166 static int test_rm_2 (void)
8168 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
8170 char device[] = "/dev/sda";
8171 device[5] = devchar;
8174 r = guestfs_blockdev_setrw (g, device);
8181 r = guestfs_umount_all (g);
8188 r = guestfs_lvm_remove_all (g);
8193 char device[] = "/dev/sda";
8194 device[5] = devchar;
8195 char lines_0[] = ",";
8202 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8207 char fstype[] = "ext2";
8208 char device[] = "/dev/sda1";
8209 device[5] = devchar;
8212 r = guestfs_mkfs (g, fstype, device);
8217 char device[] = "/dev/sda1";
8218 device[5] = devchar;
8219 char mountpoint[] = "/";
8222 r = guestfs_mount (g, device, mountpoint);
8226 /* TestLastFail for rm (2) */
8228 char path[] = "/new";
8231 r = guestfs_mkdir (g, path);
8236 char path[] = "/new";
8239 r = guestfs_rm (g, path);
8246 static int test_read_lines_0 (void)
8248 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
8250 char device[] = "/dev/sda";
8251 device[5] = devchar;
8254 r = guestfs_blockdev_setrw (g, device);
8261 r = guestfs_umount_all (g);
8268 r = guestfs_lvm_remove_all (g);
8273 char device[] = "/dev/sda";
8274 device[5] = devchar;
8275 char lines_0[] = ",";
8282 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8287 char fstype[] = "ext2";
8288 char device[] = "/dev/sda1";
8289 device[5] = devchar;
8292 r = guestfs_mkfs (g, fstype, device);
8297 char device[] = "/dev/sda1";
8298 device[5] = devchar;
8299 char mountpoint[] = "/";
8302 r = guestfs_mount (g, device, mountpoint);
8306 /* TestOutputList for read_lines (0) */
8308 char path[] = "/new";
8309 char content[] = "line1\r\nline2\nline3";
8312 r = guestfs_write_file (g, path, content, 0);
8317 char path[] = "/new";
8321 r = guestfs_read_lines (g, path);
8325 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8330 char expected[] = "line1";
8331 if (strcmp (r[0], expected) != 0) {
8332 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8337 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8342 char expected[] = "line2";
8343 if (strcmp (r[1], expected) != 0) {
8344 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8349 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
8354 char expected[] = "line3";
8355 if (strcmp (r[2], expected) != 0) {
8356 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8361 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
8365 for (i = 0; r[i] != NULL; ++i)
8372 static int test_read_lines_1 (void)
8374 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
8376 char device[] = "/dev/sda";
8377 device[5] = devchar;
8380 r = guestfs_blockdev_setrw (g, device);
8387 r = guestfs_umount_all (g);
8394 r = guestfs_lvm_remove_all (g);
8399 char device[] = "/dev/sda";
8400 device[5] = devchar;
8401 char lines_0[] = ",";
8408 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8413 char fstype[] = "ext2";
8414 char device[] = "/dev/sda1";
8415 device[5] = devchar;
8418 r = guestfs_mkfs (g, fstype, device);
8423 char device[] = "/dev/sda1";
8424 device[5] = devchar;
8425 char mountpoint[] = "/";
8428 r = guestfs_mount (g, device, mountpoint);
8432 /* TestOutputList for read_lines (1) */
8434 char path[] = "/new";
8435 char content[] = "";
8438 r = guestfs_write_file (g, path, content, 0);
8443 char path[] = "/new";
8447 r = guestfs_read_lines (g, path);
8451 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
8455 for (i = 0; r[i] != NULL; ++i)
8462 static int test_lvs_0 (void)
8464 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
8466 char device[] = "/dev/sda";
8467 device[5] = devchar;
8470 r = guestfs_blockdev_setrw (g, device);
8477 r = guestfs_umount_all (g);
8484 r = guestfs_lvm_remove_all (g);
8489 char device[] = "/dev/sda";
8490 device[5] = devchar;
8491 char lines_0[] = ",";
8498 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8503 char device[] = "/dev/sda1";
8504 device[5] = devchar;
8507 r = guestfs_pvcreate (g, device);
8512 char volgroup[] = "VG";
8513 char physvols_0[] = "/dev/sda1";
8514 physvols_0[5] = devchar;
8515 char *physvols[] = {
8521 r = guestfs_vgcreate (g, volgroup, physvols);
8526 char logvol[] = "LV";
8527 char volgroup[] = "VG";
8530 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8535 char fstype[] = "ext2";
8536 char device[] = "/dev/VG/LV";
8539 r = guestfs_mkfs (g, fstype, device);
8544 char device[] = "/dev/VG/LV";
8545 char mountpoint[] = "/";
8548 r = guestfs_mount (g, device, mountpoint);
8552 /* TestOutputList for lvs (0) */
8557 r = guestfs_lvs (g);
8561 fprintf (stderr, "test_lvs_0: short list returned from command\n");
8566 char expected[] = "/dev/VG/LV";
8567 if (strcmp (r[0], expected) != 0) {
8568 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8573 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
8577 for (i = 0; r[i] != NULL; ++i)
8584 static int test_lvs_1 (void)
8586 /* InitEmpty for lvs (1) */
8588 char device[] = "/dev/sda";
8589 device[5] = devchar;
8592 r = guestfs_blockdev_setrw (g, device);
8599 r = guestfs_umount_all (g);
8606 r = guestfs_lvm_remove_all (g);
8610 /* TestOutputList for lvs (1) */
8612 char device[] = "/dev/sda";
8613 device[5] = devchar;
8614 char lines_0[] = ",10";
8615 char lines_1[] = ",20";
8616 char lines_2[] = ",";
8625 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8630 char device[] = "/dev/sda1";
8631 device[5] = devchar;
8634 r = guestfs_pvcreate (g, device);
8639 char device[] = "/dev/sda2";
8640 device[5] = devchar;
8643 r = guestfs_pvcreate (g, device);
8648 char device[] = "/dev/sda3";
8649 device[5] = devchar;
8652 r = guestfs_pvcreate (g, device);
8657 char volgroup[] = "VG1";
8658 char physvols_0[] = "/dev/sda1";
8659 physvols_0[5] = devchar;
8660 char physvols_1[] = "/dev/sda2";
8661 physvols_1[5] = devchar;
8662 char *physvols[] = {
8669 r = guestfs_vgcreate (g, volgroup, physvols);
8674 char volgroup[] = "VG2";
8675 char physvols_0[] = "/dev/sda3";
8676 physvols_0[5] = devchar;
8677 char *physvols[] = {
8683 r = guestfs_vgcreate (g, volgroup, physvols);
8688 char logvol[] = "LV1";
8689 char volgroup[] = "VG1";
8692 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8697 char logvol[] = "LV2";
8698 char volgroup[] = "VG1";
8701 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8706 char logvol[] = "LV3";
8707 char volgroup[] = "VG2";
8710 r = guestfs_lvcreate (g, logvol, volgroup, 50);
8718 r = guestfs_lvs (g);
8722 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8727 char expected[] = "/dev/VG1/LV1";
8728 if (strcmp (r[0], expected) != 0) {
8729 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8734 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8739 char expected[] = "/dev/VG1/LV2";
8740 if (strcmp (r[1], expected) != 0) {
8741 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8746 fprintf (stderr, "test_lvs_1: short list returned from command\n");
8751 char expected[] = "/dev/VG2/LV3";
8752 if (strcmp (r[2], expected) != 0) {
8753 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
8758 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
8762 for (i = 0; r[i] != NULL; ++i)
8769 static int test_vgs_0 (void)
8771 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
8773 char device[] = "/dev/sda";
8774 device[5] = devchar;
8777 r = guestfs_blockdev_setrw (g, device);
8784 r = guestfs_umount_all (g);
8791 r = guestfs_lvm_remove_all (g);
8796 char device[] = "/dev/sda";
8797 device[5] = devchar;
8798 char lines_0[] = ",";
8805 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8810 char device[] = "/dev/sda1";
8811 device[5] = devchar;
8814 r = guestfs_pvcreate (g, device);
8819 char volgroup[] = "VG";
8820 char physvols_0[] = "/dev/sda1";
8821 physvols_0[5] = devchar;
8822 char *physvols[] = {
8828 r = guestfs_vgcreate (g, volgroup, physvols);
8833 char logvol[] = "LV";
8834 char volgroup[] = "VG";
8837 r = guestfs_lvcreate (g, logvol, volgroup, 8);
8842 char fstype[] = "ext2";
8843 char device[] = "/dev/VG/LV";
8846 r = guestfs_mkfs (g, fstype, device);
8851 char device[] = "/dev/VG/LV";
8852 char mountpoint[] = "/";
8855 r = guestfs_mount (g, device, mountpoint);
8859 /* TestOutputList for vgs (0) */
8864 r = guestfs_vgs (g);
8868 fprintf (stderr, "test_vgs_0: short list returned from command\n");
8873 char expected[] = "VG";
8874 if (strcmp (r[0], expected) != 0) {
8875 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8880 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
8884 for (i = 0; r[i] != NULL; ++i)
8891 static int test_vgs_1 (void)
8893 /* InitEmpty for vgs (1) */
8895 char device[] = "/dev/sda";
8896 device[5] = devchar;
8899 r = guestfs_blockdev_setrw (g, device);
8906 r = guestfs_umount_all (g);
8913 r = guestfs_lvm_remove_all (g);
8917 /* TestOutputList for vgs (1) */
8919 char device[] = "/dev/sda";
8920 device[5] = devchar;
8921 char lines_0[] = ",10";
8922 char lines_1[] = ",20";
8923 char lines_2[] = ",";
8932 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8937 char device[] = "/dev/sda1";
8938 device[5] = devchar;
8941 r = guestfs_pvcreate (g, device);
8946 char device[] = "/dev/sda2";
8947 device[5] = devchar;
8950 r = guestfs_pvcreate (g, device);
8955 char device[] = "/dev/sda3";
8956 device[5] = devchar;
8959 r = guestfs_pvcreate (g, device);
8964 char volgroup[] = "VG1";
8965 char physvols_0[] = "/dev/sda1";
8966 physvols_0[5] = devchar;
8967 char physvols_1[] = "/dev/sda2";
8968 physvols_1[5] = devchar;
8969 char *physvols[] = {
8976 r = guestfs_vgcreate (g, volgroup, physvols);
8981 char volgroup[] = "VG2";
8982 char physvols_0[] = "/dev/sda3";
8983 physvols_0[5] = devchar;
8984 char *physvols[] = {
8990 r = guestfs_vgcreate (g, volgroup, physvols);
8998 r = guestfs_vgs (g);
9002 fprintf (stderr, "test_vgs_1: short list returned from command\n");
9007 char expected[] = "VG1";
9008 if (strcmp (r[0], expected) != 0) {
9009 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9014 fprintf (stderr, "test_vgs_1: short list returned from command\n");
9019 char expected[] = "VG2";
9020 if (strcmp (r[1], expected) != 0) {
9021 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9026 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
9030 for (i = 0; r[i] != NULL; ++i)
9037 static int test_pvs_0 (void)
9039 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
9041 char device[] = "/dev/sda";
9042 device[5] = devchar;
9045 r = guestfs_blockdev_setrw (g, device);
9052 r = guestfs_umount_all (g);
9059 r = guestfs_lvm_remove_all (g);
9064 char device[] = "/dev/sda";
9065 device[5] = devchar;
9066 char lines_0[] = ",";
9073 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9078 char device[] = "/dev/sda1";
9079 device[5] = devchar;
9082 r = guestfs_pvcreate (g, device);
9087 char volgroup[] = "VG";
9088 char physvols_0[] = "/dev/sda1";
9089 physvols_0[5] = devchar;
9090 char *physvols[] = {
9096 r = guestfs_vgcreate (g, volgroup, physvols);
9101 char logvol[] = "LV";
9102 char volgroup[] = "VG";
9105 r = guestfs_lvcreate (g, logvol, volgroup, 8);
9110 char fstype[] = "ext2";
9111 char device[] = "/dev/VG/LV";
9114 r = guestfs_mkfs (g, fstype, device);
9119 char device[] = "/dev/VG/LV";
9120 char mountpoint[] = "/";
9123 r = guestfs_mount (g, device, mountpoint);
9127 /* TestOutputList for pvs (0) */
9132 r = guestfs_pvs (g);
9136 fprintf (stderr, "test_pvs_0: short list returned from command\n");
9141 char expected[] = "/dev/sda1";
9142 expected[5] = devchar;
9143 if (strcmp (r[0], expected) != 0) {
9144 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9149 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
9153 for (i = 0; r[i] != NULL; ++i)
9160 static int test_pvs_1 (void)
9162 /* InitEmpty for pvs (1) */
9164 char device[] = "/dev/sda";
9165 device[5] = devchar;
9168 r = guestfs_blockdev_setrw (g, device);
9175 r = guestfs_umount_all (g);
9182 r = guestfs_lvm_remove_all (g);
9186 /* TestOutputList for pvs (1) */
9188 char device[] = "/dev/sda";
9189 device[5] = devchar;
9190 char lines_0[] = ",10";
9191 char lines_1[] = ",20";
9192 char lines_2[] = ",";
9201 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9206 char device[] = "/dev/sda1";
9207 device[5] = devchar;
9210 r = guestfs_pvcreate (g, device);
9215 char device[] = "/dev/sda2";
9216 device[5] = devchar;
9219 r = guestfs_pvcreate (g, device);
9224 char device[] = "/dev/sda3";
9225 device[5] = devchar;
9228 r = guestfs_pvcreate (g, device);
9236 r = guestfs_pvs (g);
9240 fprintf (stderr, "test_pvs_1: short list returned from command\n");
9245 char expected[] = "/dev/sda1";
9246 expected[5] = devchar;
9247 if (strcmp (r[0], expected) != 0) {
9248 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9253 fprintf (stderr, "test_pvs_1: short list returned from command\n");
9258 char expected[] = "/dev/sda2";
9259 expected[5] = devchar;
9260 if (strcmp (r[1], expected) != 0) {
9261 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9266 fprintf (stderr, "test_pvs_1: short list returned from command\n");
9271 char expected[] = "/dev/sda3";
9272 expected[5] = devchar;
9273 if (strcmp (r[2], expected) != 0) {
9274 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9279 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
9283 for (i = 0; r[i] != NULL; ++i)
9290 static int test_list_partitions_0 (void)
9292 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
9294 char device[] = "/dev/sda";
9295 device[5] = devchar;
9298 r = guestfs_blockdev_setrw (g, device);
9305 r = guestfs_umount_all (g);
9312 r = guestfs_lvm_remove_all (g);
9317 char device[] = "/dev/sda";
9318 device[5] = devchar;
9319 char lines_0[] = ",";
9326 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9331 char fstype[] = "ext2";
9332 char device[] = "/dev/sda1";
9333 device[5] = devchar;
9336 r = guestfs_mkfs (g, fstype, device);
9341 char device[] = "/dev/sda1";
9342 device[5] = devchar;
9343 char mountpoint[] = "/";
9346 r = guestfs_mount (g, device, mountpoint);
9350 /* TestOutputList for list_partitions (0) */
9355 r = guestfs_list_partitions (g);
9359 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
9364 char expected[] = "/dev/sda1";
9365 expected[5] = devchar;
9366 if (strcmp (r[0], expected) != 0) {
9367 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9372 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
9376 for (i = 0; r[i] != NULL; ++i)
9383 static int test_list_partitions_1 (void)
9385 /* InitEmpty for list_partitions (1) */
9387 char device[] = "/dev/sda";
9388 device[5] = devchar;
9391 r = guestfs_blockdev_setrw (g, device);
9398 r = guestfs_umount_all (g);
9405 r = guestfs_lvm_remove_all (g);
9409 /* TestOutputList for list_partitions (1) */
9411 char device[] = "/dev/sda";
9412 device[5] = devchar;
9413 char lines_0[] = ",10";
9414 char lines_1[] = ",20";
9415 char lines_2[] = ",";
9424 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9432 r = guestfs_list_partitions (g);
9436 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9441 char expected[] = "/dev/sda1";
9442 expected[5] = devchar;
9443 if (strcmp (r[0], expected) != 0) {
9444 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9449 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9454 char expected[] = "/dev/sda2";
9455 expected[5] = devchar;
9456 if (strcmp (r[1], expected) != 0) {
9457 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9462 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
9467 char expected[] = "/dev/sda3";
9468 expected[5] = devchar;
9469 if (strcmp (r[2], expected) != 0) {
9470 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9475 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
9479 for (i = 0; r[i] != NULL; ++i)
9486 static int test_list_devices_0 (void)
9488 /* InitEmpty for list_devices (0) */
9490 char device[] = "/dev/sda";
9491 device[5] = devchar;
9494 r = guestfs_blockdev_setrw (g, device);
9501 r = guestfs_umount_all (g);
9508 r = guestfs_lvm_remove_all (g);
9512 /* TestOutputList for list_devices (0) */
9517 r = guestfs_list_devices (g);
9521 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9526 char expected[] = "/dev/sda";
9527 expected[5] = devchar;
9528 if (strcmp (r[0], expected) != 0) {
9529 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9534 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9539 char expected[] = "/dev/sdb";
9540 expected[5] = devchar;
9541 if (strcmp (r[1], expected) != 0) {
9542 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9547 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
9552 char expected[] = "/dev/sdc";
9553 expected[5] = devchar;
9554 if (strcmp (r[2], expected) != 0) {
9555 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9560 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
9564 for (i = 0; r[i] != NULL; ++i)
9571 static int test_ls_0 (void)
9573 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
9575 char device[] = "/dev/sda";
9576 device[5] = devchar;
9579 r = guestfs_blockdev_setrw (g, device);
9586 r = guestfs_umount_all (g);
9593 r = guestfs_lvm_remove_all (g);
9598 char device[] = "/dev/sda";
9599 device[5] = devchar;
9600 char lines_0[] = ",";
9607 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9612 char fstype[] = "ext2";
9613 char device[] = "/dev/sda1";
9614 device[5] = devchar;
9617 r = guestfs_mkfs (g, fstype, device);
9622 char device[] = "/dev/sda1";
9623 device[5] = devchar;
9624 char mountpoint[] = "/";
9627 r = guestfs_mount (g, device, mountpoint);
9631 /* TestOutputList for ls (0) */
9633 char path[] = "/new";
9636 r = guestfs_touch (g, path);
9641 char path[] = "/newer";
9644 r = guestfs_touch (g, path);
9649 char path[] = "/newest";
9652 r = guestfs_touch (g, path);
9657 char directory[] = "/";
9661 r = guestfs_ls (g, directory);
9665 fprintf (stderr, "test_ls_0: short list returned from command\n");
9670 char expected[] = "lost+found";
9671 if (strcmp (r[0], expected) != 0) {
9672 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
9677 fprintf (stderr, "test_ls_0: short list returned from command\n");
9682 char expected[] = "new";
9683 if (strcmp (r[1], expected) != 0) {
9684 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
9689 fprintf (stderr, "test_ls_0: short list returned from command\n");
9694 char expected[] = "newer";
9695 if (strcmp (r[2], expected) != 0) {
9696 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
9701 fprintf (stderr, "test_ls_0: short list returned from command\n");
9706 char expected[] = "newest";
9707 if (strcmp (r[3], expected) != 0) {
9708 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
9713 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
9717 for (i = 0; r[i] != NULL; ++i)
9724 static int test_cat_0 (void)
9726 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
9728 char device[] = "/dev/sda";
9729 device[5] = devchar;
9732 r = guestfs_blockdev_setrw (g, device);
9739 r = guestfs_umount_all (g);
9746 r = guestfs_lvm_remove_all (g);
9751 char device[] = "/dev/sda";
9752 device[5] = devchar;
9753 char lines_0[] = ",";
9760 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9765 char fstype[] = "ext2";
9766 char device[] = "/dev/sda1";
9767 device[5] = devchar;
9770 r = guestfs_mkfs (g, fstype, device);
9775 char device[] = "/dev/sda1";
9776 device[5] = devchar;
9777 char mountpoint[] = "/";
9780 r = guestfs_mount (g, device, mountpoint);
9784 /* TestOutput for cat (0) */
9785 char expected[] = "new file contents";
9787 char path[] = "/new";
9788 char content[] = "new file contents";
9791 r = guestfs_write_file (g, path, content, 0);
9796 char path[] = "/new";
9799 r = guestfs_cat (g, path);
9802 if (strcmp (r, expected) != 0) {
9803 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
9811 static int test_touch_0 (void)
9813 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
9815 char device[] = "/dev/sda";
9816 device[5] = devchar;
9819 r = guestfs_blockdev_setrw (g, device);
9826 r = guestfs_umount_all (g);
9833 r = guestfs_lvm_remove_all (g);
9838 char device[] = "/dev/sda";
9839 device[5] = devchar;
9840 char lines_0[] = ",";
9847 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9852 char fstype[] = "ext2";
9853 char device[] = "/dev/sda1";
9854 device[5] = devchar;
9857 r = guestfs_mkfs (g, fstype, device);
9862 char device[] = "/dev/sda1";
9863 device[5] = devchar;
9864 char mountpoint[] = "/";
9867 r = guestfs_mount (g, device, mountpoint);
9871 /* TestOutputTrue for touch (0) */
9873 char path[] = "/new";
9876 r = guestfs_touch (g, path);
9881 char path[] = "/new";
9884 r = guestfs_exists (g, path);
9888 fprintf (stderr, "test_touch_0: expected true, got false\n");
9895 static int test_sync_0 (void)
9897 /* InitEmpty for sync (0) */
9899 char device[] = "/dev/sda";
9900 device[5] = devchar;
9903 r = guestfs_blockdev_setrw (g, device);
9910 r = guestfs_umount_all (g);
9917 r = guestfs_lvm_remove_all (g);
9921 /* TestRun for sync (0) */
9925 r = guestfs_sync (g);
9932 static int test_mount_0 (void)
9934 /* InitEmpty for mount (0) */
9936 char device[] = "/dev/sda";
9937 device[5] = devchar;
9940 r = guestfs_blockdev_setrw (g, device);
9947 r = guestfs_umount_all (g);
9954 r = guestfs_lvm_remove_all (g);
9958 /* TestOutput for mount (0) */
9959 char expected[] = "new file contents";
9961 char device[] = "/dev/sda";
9962 device[5] = devchar;
9963 char lines_0[] = ",";
9970 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9975 char fstype[] = "ext2";
9976 char device[] = "/dev/sda1";
9977 device[5] = devchar;
9980 r = guestfs_mkfs (g, fstype, device);
9985 char device[] = "/dev/sda1";
9986 device[5] = devchar;
9987 char mountpoint[] = "/";
9990 r = guestfs_mount (g, device, mountpoint);
9995 char path[] = "/new";
9996 char content[] = "new file contents";
9999 r = guestfs_write_file (g, path, content, 0);
10004 char path[] = "/new";
10006 suppress_error = 0;
10007 r = guestfs_cat (g, path);
10010 if (strcmp (r, expected) != 0) {
10011 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
10019 int main (int argc, char *argv[])
10023 const char *srcdir;
10024 const char *filename;
10026 int nr_tests, test_num = 0;
10029 no_test_warnings ();
10031 g = guestfs_create ();
10033 printf ("guestfs_create FAILED\n");
10037 guestfs_set_error_handler (g, print_error, NULL);
10039 srcdir = getenv ("srcdir");
10040 if (!srcdir) srcdir = ".";
10042 guestfs_set_path (g, ".");
10044 filename = "test1.img";
10045 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10050 if (lseek (fd, 524288000, SEEK_SET) == -1) {
10056 if (write (fd, &c, 1) == -1) {
10062 if (close (fd) == -1) {
10067 if (guestfs_add_drive (g, filename) == -1) {
10068 printf ("guestfs_add_drive %s FAILED\n", filename);
10072 filename = "test2.img";
10073 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10078 if (lseek (fd, 52428800, SEEK_SET) == -1) {
10084 if (write (fd, &c, 1) == -1) {
10090 if (close (fd) == -1) {
10095 if (guestfs_add_drive (g, filename) == -1) {
10096 printf ("guestfs_add_drive %s FAILED\n", filename);
10100 filename = "test3.img";
10101 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
10106 if (lseek (fd, 10485760, SEEK_SET) == -1) {
10112 if (write (fd, &c, 1) == -1) {
10118 if (close (fd) == -1) {
10123 if (guestfs_add_drive (g, filename) == -1) {
10124 printf ("guestfs_add_drive %s FAILED\n", filename);
10128 if (guestfs_launch (g) == -1) {
10129 printf ("guestfs_launch FAILED\n");
10132 if (guestfs_wait_ready (g) == -1) {
10133 printf ("guestfs_wait_ready FAILED\n");
10137 /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
10138 * names. This changed between RHEL 5 and RHEL 6 so we have to
10141 devs = guestfs_list_devices (g);
10142 if (devs == NULL || devs[0] == NULL) {
10143 printf ("guestfs_list_devices FAILED\n");
10146 if (strncmp (devs[0], "/dev/sd", 7) == 0)
10148 else if (strncmp (devs[0], "/dev/hd", 7) == 0)
10151 printf ("guestfs_list_devices returned unexpected string '%s'\n",
10155 for (i = 0; devs[i] != NULL; ++i)
10162 printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
10163 if (test_hexdump_0 () == -1) {
10164 printf ("test_hexdump_0 FAILED\n");
10168 printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
10169 if (test_strings_e_0 () == -1) {
10170 printf ("test_strings_e_0 FAILED\n");
10174 printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
10175 if (test_strings_0 () == -1) {
10176 printf ("test_strings_0 FAILED\n");
10180 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
10181 if (test_equal_0 () == -1) {
10182 printf ("test_equal_0 FAILED\n");
10186 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
10187 if (test_equal_1 () == -1) {
10188 printf ("test_equal_1 FAILED\n");
10192 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
10193 if (test_equal_2 () == -1) {
10194 printf ("test_equal_2 FAILED\n");
10198 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
10199 if (test_ping_daemon_0 () == -1) {
10200 printf ("test_ping_daemon_0 FAILED\n");
10204 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
10205 if (test_dmesg_0 () == -1) {
10206 printf ("test_dmesg_0 FAILED\n");
10210 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
10211 if (test_drop_caches_0 () == -1) {
10212 printf ("test_drop_caches_0 FAILED\n");
10216 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
10217 if (test_mv_0 () == -1) {
10218 printf ("test_mv_0 FAILED\n");
10222 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
10223 if (test_mv_1 () == -1) {
10224 printf ("test_mv_1 FAILED\n");
10228 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
10229 if (test_cp_a_0 () == -1) {
10230 printf ("test_cp_a_0 FAILED\n");
10234 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
10235 if (test_cp_0 () == -1) {
10236 printf ("test_cp_0 FAILED\n");
10240 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
10241 if (test_cp_1 () == -1) {
10242 printf ("test_cp_1 FAILED\n");
10246 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
10247 if (test_cp_2 () == -1) {
10248 printf ("test_cp_2 FAILED\n");
10252 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
10253 if (test_grub_install_0 () == -1) {
10254 printf ("test_grub_install_0 FAILED\n");
10258 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
10259 if (test_zero_0 () == -1) {
10260 printf ("test_zero_0 FAILED\n");
10264 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
10265 if (test_fsck_0 () == -1) {
10266 printf ("test_fsck_0 FAILED\n");
10270 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
10271 if (test_fsck_1 () == -1) {
10272 printf ("test_fsck_1 FAILED\n");
10276 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
10277 if (test_set_e2uuid_0 () == -1) {
10278 printf ("test_set_e2uuid_0 FAILED\n");
10282 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
10283 if (test_set_e2uuid_1 () == -1) {
10284 printf ("test_set_e2uuid_1 FAILED\n");
10288 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
10289 if (test_set_e2uuid_2 () == -1) {
10290 printf ("test_set_e2uuid_2 FAILED\n");
10294 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
10295 if (test_set_e2uuid_3 () == -1) {
10296 printf ("test_set_e2uuid_3 FAILED\n");
10300 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
10301 if (test_set_e2label_0 () == -1) {
10302 printf ("test_set_e2label_0 FAILED\n");
10306 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
10307 if (test_pvremove_0 () == -1) {
10308 printf ("test_pvremove_0 FAILED\n");
10312 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
10313 if (test_pvremove_1 () == -1) {
10314 printf ("test_pvremove_1 FAILED\n");
10318 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
10319 if (test_pvremove_2 () == -1) {
10320 printf ("test_pvremove_2 FAILED\n");
10324 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
10325 if (test_vgremove_0 () == -1) {
10326 printf ("test_vgremove_0 FAILED\n");
10330 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
10331 if (test_vgremove_1 () == -1) {
10332 printf ("test_vgremove_1 FAILED\n");
10336 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
10337 if (test_lvremove_0 () == -1) {
10338 printf ("test_lvremove_0 FAILED\n");
10342 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
10343 if (test_lvremove_1 () == -1) {
10344 printf ("test_lvremove_1 FAILED\n");
10348 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
10349 if (test_lvremove_2 () == -1) {
10350 printf ("test_lvremove_2 FAILED\n");
10354 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
10355 if (test_mount_ro_0 () == -1) {
10356 printf ("test_mount_ro_0 FAILED\n");
10360 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
10361 if (test_mount_ro_1 () == -1) {
10362 printf ("test_mount_ro_1 FAILED\n");
10366 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
10367 if (test_tgz_in_0 () == -1) {
10368 printf ("test_tgz_in_0 FAILED\n");
10372 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
10373 if (test_tar_in_0 () == -1) {
10374 printf ("test_tar_in_0 FAILED\n");
10378 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
10379 if (test_checksum_0 () == -1) {
10380 printf ("test_checksum_0 FAILED\n");
10384 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
10385 if (test_checksum_1 () == -1) {
10386 printf ("test_checksum_1 FAILED\n");
10390 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
10391 if (test_checksum_2 () == -1) {
10392 printf ("test_checksum_2 FAILED\n");
10396 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
10397 if (test_checksum_3 () == -1) {
10398 printf ("test_checksum_3 FAILED\n");
10402 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
10403 if (test_checksum_4 () == -1) {
10404 printf ("test_checksum_4 FAILED\n");
10408 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
10409 if (test_checksum_5 () == -1) {
10410 printf ("test_checksum_5 FAILED\n");
10414 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
10415 if (test_checksum_6 () == -1) {
10416 printf ("test_checksum_6 FAILED\n");
10420 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
10421 if (test_checksum_7 () == -1) {
10422 printf ("test_checksum_7 FAILED\n");
10426 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
10427 if (test_download_0 () == -1) {
10428 printf ("test_download_0 FAILED\n");
10432 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
10433 if (test_upload_0 () == -1) {
10434 printf ("test_upload_0 FAILED\n");
10438 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
10439 if (test_blockdev_rereadpt_0 () == -1) {
10440 printf ("test_blockdev_rereadpt_0 FAILED\n");
10444 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
10445 if (test_blockdev_flushbufs_0 () == -1) {
10446 printf ("test_blockdev_flushbufs_0 FAILED\n");
10450 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
10451 if (test_blockdev_getsize64_0 () == -1) {
10452 printf ("test_blockdev_getsize64_0 FAILED\n");
10456 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
10457 if (test_blockdev_getsz_0 () == -1) {
10458 printf ("test_blockdev_getsz_0 FAILED\n");
10462 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
10463 if (test_blockdev_getbsz_0 () == -1) {
10464 printf ("test_blockdev_getbsz_0 FAILED\n");
10468 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
10469 if (test_blockdev_getss_0 () == -1) {
10470 printf ("test_blockdev_getss_0 FAILED\n");
10474 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
10475 if (test_blockdev_getro_0 () == -1) {
10476 printf ("test_blockdev_getro_0 FAILED\n");
10480 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
10481 if (test_blockdev_setrw_0 () == -1) {
10482 printf ("test_blockdev_setrw_0 FAILED\n");
10486 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
10487 if (test_blockdev_setro_0 () == -1) {
10488 printf ("test_blockdev_setro_0 FAILED\n");
10492 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
10493 if (test_statvfs_0 () == -1) {
10494 printf ("test_statvfs_0 FAILED\n");
10498 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
10499 if (test_lstat_0 () == -1) {
10500 printf ("test_lstat_0 FAILED\n");
10504 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
10505 if (test_stat_0 () == -1) {
10506 printf ("test_stat_0 FAILED\n");
10510 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
10511 if (test_file_0 () == -1) {
10512 printf ("test_file_0 FAILED\n");
10516 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
10517 if (test_file_1 () == -1) {
10518 printf ("test_file_1 FAILED\n");
10522 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
10523 if (test_file_2 () == -1) {
10524 printf ("test_file_2 FAILED\n");
10528 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
10529 if (test_umount_all_0 () == -1) {
10530 printf ("test_umount_all_0 FAILED\n");
10534 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
10535 if (test_umount_all_1 () == -1) {
10536 printf ("test_umount_all_1 FAILED\n");
10540 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
10541 if (test_mounts_0 () == -1) {
10542 printf ("test_mounts_0 FAILED\n");
10546 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
10547 if (test_umount_0 () == -1) {
10548 printf ("test_umount_0 FAILED\n");
10552 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
10553 if (test_umount_1 () == -1) {
10554 printf ("test_umount_1 FAILED\n");
10558 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
10559 if (test_write_file_0 () == -1) {
10560 printf ("test_write_file_0 FAILED\n");
10564 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
10565 if (test_write_file_1 () == -1) {
10566 printf ("test_write_file_1 FAILED\n");
10570 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
10571 if (test_write_file_2 () == -1) {
10572 printf ("test_write_file_2 FAILED\n");
10576 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
10577 if (test_write_file_3 () == -1) {
10578 printf ("test_write_file_3 FAILED\n");
10582 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
10583 if (test_write_file_4 () == -1) {
10584 printf ("test_write_file_4 FAILED\n");
10588 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
10589 if (test_write_file_5 () == -1) {
10590 printf ("test_write_file_5 FAILED\n");
10594 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
10595 if (test_mkfs_0 () == -1) {
10596 printf ("test_mkfs_0 FAILED\n");
10600 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
10601 if (test_lvcreate_0 () == -1) {
10602 printf ("test_lvcreate_0 FAILED\n");
10606 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
10607 if (test_vgcreate_0 () == -1) {
10608 printf ("test_vgcreate_0 FAILED\n");
10612 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
10613 if (test_pvcreate_0 () == -1) {
10614 printf ("test_pvcreate_0 FAILED\n");
10618 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
10619 if (test_is_dir_0 () == -1) {
10620 printf ("test_is_dir_0 FAILED\n");
10624 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
10625 if (test_is_dir_1 () == -1) {
10626 printf ("test_is_dir_1 FAILED\n");
10630 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
10631 if (test_is_file_0 () == -1) {
10632 printf ("test_is_file_0 FAILED\n");
10636 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
10637 if (test_is_file_1 () == -1) {
10638 printf ("test_is_file_1 FAILED\n");
10642 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
10643 if (test_exists_0 () == -1) {
10644 printf ("test_exists_0 FAILED\n");
10648 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
10649 if (test_exists_1 () == -1) {
10650 printf ("test_exists_1 FAILED\n");
10654 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
10655 if (test_mkdir_p_0 () == -1) {
10656 printf ("test_mkdir_p_0 FAILED\n");
10660 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
10661 if (test_mkdir_p_1 () == -1) {
10662 printf ("test_mkdir_p_1 FAILED\n");
10666 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
10667 if (test_mkdir_p_2 () == -1) {
10668 printf ("test_mkdir_p_2 FAILED\n");
10672 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
10673 if (test_mkdir_0 () == -1) {
10674 printf ("test_mkdir_0 FAILED\n");
10678 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
10679 if (test_mkdir_1 () == -1) {
10680 printf ("test_mkdir_1 FAILED\n");
10684 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
10685 if (test_rm_rf_0 () == -1) {
10686 printf ("test_rm_rf_0 FAILED\n");
10690 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
10691 if (test_rmdir_0 () == -1) {
10692 printf ("test_rmdir_0 FAILED\n");
10696 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
10697 if (test_rmdir_1 () == -1) {
10698 printf ("test_rmdir_1 FAILED\n");
10702 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
10703 if (test_rmdir_2 () == -1) {
10704 printf ("test_rmdir_2 FAILED\n");
10708 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
10709 if (test_rm_0 () == -1) {
10710 printf ("test_rm_0 FAILED\n");
10714 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
10715 if (test_rm_1 () == -1) {
10716 printf ("test_rm_1 FAILED\n");
10720 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
10721 if (test_rm_2 () == -1) {
10722 printf ("test_rm_2 FAILED\n");
10726 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
10727 if (test_read_lines_0 () == -1) {
10728 printf ("test_read_lines_0 FAILED\n");
10732 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
10733 if (test_read_lines_1 () == -1) {
10734 printf ("test_read_lines_1 FAILED\n");
10738 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
10739 if (test_lvs_0 () == -1) {
10740 printf ("test_lvs_0 FAILED\n");
10744 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
10745 if (test_lvs_1 () == -1) {
10746 printf ("test_lvs_1 FAILED\n");
10750 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
10751 if (test_vgs_0 () == -1) {
10752 printf ("test_vgs_0 FAILED\n");
10756 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
10757 if (test_vgs_1 () == -1) {
10758 printf ("test_vgs_1 FAILED\n");
10762 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
10763 if (test_pvs_0 () == -1) {
10764 printf ("test_pvs_0 FAILED\n");
10768 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
10769 if (test_pvs_1 () == -1) {
10770 printf ("test_pvs_1 FAILED\n");
10774 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
10775 if (test_list_partitions_0 () == -1) {
10776 printf ("test_list_partitions_0 FAILED\n");
10780 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
10781 if (test_list_partitions_1 () == -1) {
10782 printf ("test_list_partitions_1 FAILED\n");
10786 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
10787 if (test_list_devices_0 () == -1) {
10788 printf ("test_list_devices_0 FAILED\n");
10792 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
10793 if (test_ls_0 () == -1) {
10794 printf ("test_ls_0 FAILED\n");
10798 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
10799 if (test_cat_0 () == -1) {
10800 printf ("test_cat_0 FAILED\n");
10804 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
10805 if (test_touch_0 () == -1) {
10806 printf ("test_touch_0 FAILED\n");
10810 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
10811 if (test_sync_0 () == -1) {
10812 printf ("test_sync_0 FAILED\n");
10816 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
10817 if (test_mount_0 () == -1) {
10818 printf ("test_mount_0 FAILED\n");
10823 unlink ("test1.img");
10824 unlink ("test2.img");
10825 unlink ("test3.img");
10828 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);