1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
32 static int suppress_error = 0;
34 static void print_error (guestfs_h *g, void *data, const char *msg)
37 fprintf (stderr, "%s\n", msg);
40 static void print_strings (char * const * const argv)
44 for (argc = 0; argv[argc] != NULL; ++argc)
45 printf ("\t%s\n", argv[argc]);
49 static void print_table (char * const * const argv)
53 for (i = 0; argv[i] != NULL; i += 2)
54 printf ("%s: %s\n", argv[i], argv[i+1]);
58 static void no_test_warnings (void)
60 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
61 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
62 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
63 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
64 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
65 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_command\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
113 static int test_pvremove_0 (void)
115 /* InitEmpty for pvremove (0) */
119 r = guestfs_umount_all (g);
126 r = guestfs_lvm_remove_all (g);
130 /* TestOutputList for pvremove (0) */
134 r = guestfs_pvcreate (g, "/dev/sda");
145 r = guestfs_vgcreate (g, "VG", physvols);
152 r = guestfs_lvcreate (g, "LV1", "VG", 50);
159 r = guestfs_lvcreate (g, "LV2", "VG", 50);
166 r = guestfs_vgremove (g, "VG");
173 r = guestfs_pvremove (g, "/dev/sda");
185 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
189 for (i = 0; r[i] != NULL; ++i)
196 static int test_pvremove_1 (void)
198 /* InitEmpty for pvremove (1) */
202 r = guestfs_umount_all (g);
209 r = guestfs_lvm_remove_all (g);
213 /* TestOutputList for pvremove (1) */
217 r = guestfs_pvcreate (g, "/dev/sda");
228 r = guestfs_vgcreate (g, "VG", physvols);
235 r = guestfs_lvcreate (g, "LV1", "VG", 50);
242 r = guestfs_lvcreate (g, "LV2", "VG", 50);
249 r = guestfs_vgremove (g, "VG");
256 r = guestfs_pvremove (g, "/dev/sda");
268 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
272 for (i = 0; r[i] != NULL; ++i)
279 static int test_pvremove_2 (void)
281 /* InitEmpty for pvremove (2) */
285 r = guestfs_umount_all (g);
292 r = guestfs_lvm_remove_all (g);
296 /* TestOutputList for pvremove (2) */
300 r = guestfs_pvcreate (g, "/dev/sda");
311 r = guestfs_vgcreate (g, "VG", physvols);
318 r = guestfs_lvcreate (g, "LV1", "VG", 50);
325 r = guestfs_lvcreate (g, "LV2", "VG", 50);
332 r = guestfs_vgremove (g, "VG");
339 r = guestfs_pvremove (g, "/dev/sda");
351 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
355 for (i = 0; r[i] != NULL; ++i)
362 static int test_vgremove_0 (void)
364 /* InitEmpty for vgremove (0) */
368 r = guestfs_umount_all (g);
375 r = guestfs_lvm_remove_all (g);
379 /* TestOutputList for vgremove (0) */
383 r = guestfs_pvcreate (g, "/dev/sda");
394 r = guestfs_vgcreate (g, "VG", physvols);
401 r = guestfs_lvcreate (g, "LV1", "VG", 50);
408 r = guestfs_lvcreate (g, "LV2", "VG", 50);
415 r = guestfs_vgremove (g, "VG");
427 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
431 for (i = 0; r[i] != NULL; ++i)
438 static int test_vgremove_1 (void)
440 /* InitEmpty for vgremove (1) */
444 r = guestfs_umount_all (g);
451 r = guestfs_lvm_remove_all (g);
455 /* TestOutputList for vgremove (1) */
459 r = guestfs_pvcreate (g, "/dev/sda");
470 r = guestfs_vgcreate (g, "VG", physvols);
477 r = guestfs_lvcreate (g, "LV1", "VG", 50);
484 r = guestfs_lvcreate (g, "LV2", "VG", 50);
491 r = guestfs_vgremove (g, "VG");
503 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
507 for (i = 0; r[i] != NULL; ++i)
514 static int test_lvremove_0 (void)
516 /* InitEmpty for lvremove (0) */
520 r = guestfs_umount_all (g);
527 r = guestfs_lvm_remove_all (g);
531 /* TestOutputList for lvremove (0) */
535 r = guestfs_pvcreate (g, "/dev/sda");
546 r = guestfs_vgcreate (g, "VG", physvols);
553 r = guestfs_lvcreate (g, "LV1", "VG", 50);
560 r = guestfs_lvcreate (g, "LV2", "VG", 50);
567 r = guestfs_lvremove (g, "/dev/VG/LV1");
579 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
583 if (strcmp (r[0], "/dev/VG/LV2") != 0) {
584 fprintf (stderr, "test_lvremove_0: expected \"/dev/VG/LV2\" but got \"%s\"\n", r[0]);
588 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
592 for (i = 0; r[i] != NULL; ++i)
599 static int test_lvremove_1 (void)
601 /* InitEmpty for lvremove (1) */
605 r = guestfs_umount_all (g);
612 r = guestfs_lvm_remove_all (g);
616 /* TestOutputList for lvremove (1) */
620 r = guestfs_pvcreate (g, "/dev/sda");
631 r = guestfs_vgcreate (g, "VG", physvols);
638 r = guestfs_lvcreate (g, "LV1", "VG", 50);
645 r = guestfs_lvcreate (g, "LV2", "VG", 50);
652 r = guestfs_lvremove (g, "/dev/VG");
664 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
668 for (i = 0; r[i] != NULL; ++i)
675 static int test_lvremove_2 (void)
677 /* InitEmpty for lvremove (2) */
681 r = guestfs_umount_all (g);
688 r = guestfs_lvm_remove_all (g);
692 /* TestOutputList for lvremove (2) */
696 r = guestfs_pvcreate (g, "/dev/sda");
707 r = guestfs_vgcreate (g, "VG", physvols);
714 r = guestfs_lvcreate (g, "LV1", "VG", 50);
721 r = guestfs_lvcreate (g, "LV2", "VG", 50);
728 r = guestfs_lvremove (g, "/dev/VG");
740 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
744 if (strcmp (r[0], "VG") != 0) {
745 fprintf (stderr, "test_lvremove_2: expected \"VG\" but got \"%s\"\n", r[0]);
749 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
753 for (i = 0; r[i] != NULL; ++i)
760 static int test_mount_ro_0 (void)
762 /* InitBasicFS for mount_ro (0): create ext2 on /dev/sda1 */
766 r = guestfs_umount_all (g);
773 r = guestfs_lvm_remove_all (g);
784 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
791 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
798 r = guestfs_mount (g, "/dev/sda1", "/");
802 /* TestLastFail for mount_ro (0) */
806 r = guestfs_umount (g, "/");
813 r = guestfs_mount_ro (g, "/dev/sda1", "/");
820 r = guestfs_touch (g, "/new");
827 static int test_mount_ro_1 (void)
829 /* InitBasicFS for mount_ro (1): create ext2 on /dev/sda1 */
833 r = guestfs_umount_all (g);
840 r = guestfs_lvm_remove_all (g);
851 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
858 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
865 r = guestfs_mount (g, "/dev/sda1", "/");
869 /* TestOutput for mount_ro (1) */
873 r = guestfs_write_file (g, "/new", "data", 0);
880 r = guestfs_umount (g, "/");
887 r = guestfs_mount_ro (g, "/dev/sda1", "/");
894 r = guestfs_cat (g, "/new");
897 if (strcmp (r, "data") != 0) {
898 fprintf (stderr, "test_mount_ro_1: expected \"data\" but got \"%s\"\n", r);
906 static int test_tgz_in_0 (void)
908 /* InitBasicFS for tgz_in (0): create ext2 on /dev/sda1 */
912 r = guestfs_umount_all (g);
919 r = guestfs_lvm_remove_all (g);
930 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
937 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
944 r = guestfs_mount (g, "/dev/sda1", "/");
948 /* TestOutput for tgz_in (0) */
952 r = guestfs_tgz_in (g, "images/helloworld.tar.gz", "/");
959 r = guestfs_cat (g, "/hello");
962 if (strcmp (r, "hello\n") != 0) {
963 fprintf (stderr, "test_tgz_in_0: expected \"hello\n\" but got \"%s\"\n", r);
971 static int test_tar_in_0 (void)
973 /* InitBasicFS for tar_in (0): create ext2 on /dev/sda1 */
977 r = guestfs_umount_all (g);
984 r = guestfs_lvm_remove_all (g);
995 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1002 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1009 r = guestfs_mount (g, "/dev/sda1", "/");
1013 /* TestOutput for tar_in (0) */
1017 r = guestfs_tar_in (g, "images/helloworld.tar", "/");
1024 r = guestfs_cat (g, "/hello");
1027 if (strcmp (r, "hello\n") != 0) {
1028 fprintf (stderr, "test_tar_in_0: expected \"hello\n\" but got \"%s\"\n", r);
1036 static int test_checksum_0 (void)
1038 /* InitBasicFS for checksum (0): create ext2 on /dev/sda1 */
1042 r = guestfs_umount_all (g);
1049 r = guestfs_lvm_remove_all (g);
1060 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1067 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1074 r = guestfs_mount (g, "/dev/sda1", "/");
1078 /* TestOutput for checksum (0) */
1082 r = guestfs_write_file (g, "/new", "test\n", 0);
1089 r = guestfs_checksum (g, "crc", "/new");
1092 if (strcmp (r, "935282863") != 0) {
1093 fprintf (stderr, "test_checksum_0: expected \"935282863\" but got \"%s\"\n", r);
1101 static int test_checksum_1 (void)
1103 /* InitBasicFS for checksum (1): create ext2 on /dev/sda1 */
1107 r = guestfs_umount_all (g);
1114 r = guestfs_lvm_remove_all (g);
1125 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1132 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1139 r = guestfs_mount (g, "/dev/sda1", "/");
1143 /* TestLastFail for checksum (1) */
1147 r = guestfs_checksum (g, "crc", "/new");
1155 static int test_checksum_2 (void)
1157 /* InitBasicFS for checksum (2): create ext2 on /dev/sda1 */
1161 r = guestfs_umount_all (g);
1168 r = guestfs_lvm_remove_all (g);
1179 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1186 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1193 r = guestfs_mount (g, "/dev/sda1", "/");
1197 /* TestOutput for checksum (2) */
1201 r = guestfs_write_file (g, "/new", "test\n", 0);
1208 r = guestfs_checksum (g, "md5", "/new");
1211 if (strcmp (r, "d8e8fca2dc0f896fd7cb4cb0031ba249") != 0) {
1212 fprintf (stderr, "test_checksum_2: expected \"d8e8fca2dc0f896fd7cb4cb0031ba249\" but got \"%s\"\n", r);
1220 static int test_checksum_3 (void)
1222 /* InitBasicFS for checksum (3): create ext2 on /dev/sda1 */
1226 r = guestfs_umount_all (g);
1233 r = guestfs_lvm_remove_all (g);
1244 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1251 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1258 r = guestfs_mount (g, "/dev/sda1", "/");
1262 /* TestOutput for checksum (3) */
1266 r = guestfs_write_file (g, "/new", "test\n", 0);
1273 r = guestfs_checksum (g, "sha1", "/new");
1276 if (strcmp (r, "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83") != 0) {
1277 fprintf (stderr, "test_checksum_3: expected \"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83\" but got \"%s\"\n", r);
1285 static int test_checksum_4 (void)
1287 /* InitBasicFS for checksum (4): create ext2 on /dev/sda1 */
1291 r = guestfs_umount_all (g);
1298 r = guestfs_lvm_remove_all (g);
1309 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1316 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1323 r = guestfs_mount (g, "/dev/sda1", "/");
1327 /* TestOutput for checksum (4) */
1331 r = guestfs_write_file (g, "/new", "test\n", 0);
1338 r = guestfs_checksum (g, "sha224", "/new");
1341 if (strcmp (r, "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec") != 0) {
1342 fprintf (stderr, "test_checksum_4: expected \"52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec\" but got \"%s\"\n", r);
1350 static int test_checksum_5 (void)
1352 /* InitBasicFS for checksum (5): create ext2 on /dev/sda1 */
1356 r = guestfs_umount_all (g);
1363 r = guestfs_lvm_remove_all (g);
1374 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1381 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1388 r = guestfs_mount (g, "/dev/sda1", "/");
1392 /* TestOutput for checksum (5) */
1396 r = guestfs_write_file (g, "/new", "test\n", 0);
1403 r = guestfs_checksum (g, "sha256", "/new");
1406 if (strcmp (r, "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") != 0) {
1407 fprintf (stderr, "test_checksum_5: expected \"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2\" but got \"%s\"\n", r);
1415 static int test_checksum_6 (void)
1417 /* InitBasicFS for checksum (6): create ext2 on /dev/sda1 */
1421 r = guestfs_umount_all (g);
1428 r = guestfs_lvm_remove_all (g);
1439 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1446 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1453 r = guestfs_mount (g, "/dev/sda1", "/");
1457 /* TestOutput for checksum (6) */
1461 r = guestfs_write_file (g, "/new", "test\n", 0);
1468 r = guestfs_checksum (g, "sha384", "/new");
1471 if (strcmp (r, "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d") != 0) {
1472 fprintf (stderr, "test_checksum_6: expected \"109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d\" but got \"%s\"\n", r);
1480 static int test_checksum_7 (void)
1482 /* InitBasicFS for checksum (7): create ext2 on /dev/sda1 */
1486 r = guestfs_umount_all (g);
1493 r = guestfs_lvm_remove_all (g);
1504 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1511 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1518 r = guestfs_mount (g, "/dev/sda1", "/");
1522 /* TestOutput for checksum (7) */
1526 r = guestfs_write_file (g, "/new", "test\n", 0);
1533 r = guestfs_checksum (g, "sha512", "/new");
1536 if (strcmp (r, "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123") != 0) {
1537 fprintf (stderr, "test_checksum_7: expected \"0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123\" but got \"%s\"\n", r);
1545 static int test_download_0 (void)
1547 /* InitBasicFS for download (0): create ext2 on /dev/sda1 */
1551 r = guestfs_umount_all (g);
1558 r = guestfs_lvm_remove_all (g);
1569 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1576 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1583 r = guestfs_mount (g, "/dev/sda1", "/");
1587 /* TestOutput for download (0) */
1591 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
1598 r = guestfs_download (g, "/COPYING.LIB", "testdownload.tmp");
1605 r = guestfs_upload (g, "testdownload.tmp", "/upload");
1612 r = guestfs_checksum (g, "md5", "/upload");
1615 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
1616 fprintf (stderr, "test_download_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
1624 static int test_upload_0 (void)
1626 /* InitBasicFS for upload (0): create ext2 on /dev/sda1 */
1630 r = guestfs_umount_all (g);
1637 r = guestfs_lvm_remove_all (g);
1648 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
1655 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
1662 r = guestfs_mount (g, "/dev/sda1", "/");
1666 /* TestOutput for upload (0) */
1670 r = guestfs_upload (g, "COPYING.LIB", "/COPYING.LIB");
1677 r = guestfs_checksum (g, "md5", "/COPYING.LIB");
1680 if (strcmp (r, "e3eda01d9815f8d24aae2dbd89b68b06") != 0) {
1681 fprintf (stderr, "test_upload_0: expected \"e3eda01d9815f8d24aae2dbd89b68b06\" but got \"%s\"\n", r);
1689 static int test_blockdev_rereadpt_0 (void)
1691 /* InitEmpty for blockdev_rereadpt (0) */
1695 r = guestfs_umount_all (g);
1702 r = guestfs_lvm_remove_all (g);
1706 /* TestRun for blockdev_rereadpt (0) */
1710 r = guestfs_blockdev_rereadpt (g, "/dev/sda");
1717 static int test_blockdev_flushbufs_0 (void)
1719 /* InitEmpty for blockdev_flushbufs (0) */
1723 r = guestfs_umount_all (g);
1730 r = guestfs_lvm_remove_all (g);
1734 /* TestRun for blockdev_flushbufs (0) */
1738 r = guestfs_blockdev_flushbufs (g, "/dev/sda");
1745 static int test_blockdev_getsize64_0 (void)
1747 /* InitEmpty for blockdev_getsize64 (0) */
1751 r = guestfs_umount_all (g);
1758 r = guestfs_lvm_remove_all (g);
1762 /* TestOutputInt for blockdev_getsize64 (0) */
1766 r = guestfs_blockdev_getsize64 (g, "/dev/sda");
1769 if (r != 524288000) {
1770 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
1777 static int test_blockdev_getsz_0 (void)
1779 /* InitEmpty for blockdev_getsz (0) */
1783 r = guestfs_umount_all (g);
1790 r = guestfs_lvm_remove_all (g);
1794 /* TestOutputInt for blockdev_getsz (0) */
1798 r = guestfs_blockdev_getsz (g, "/dev/sda");
1802 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
1809 static int test_blockdev_getbsz_0 (void)
1811 /* InitEmpty for blockdev_getbsz (0) */
1815 r = guestfs_umount_all (g);
1822 r = guestfs_lvm_remove_all (g);
1826 /* TestOutputInt for blockdev_getbsz (0) */
1830 r = guestfs_blockdev_getbsz (g, "/dev/sda");
1834 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
1841 static int test_blockdev_getss_0 (void)
1843 /* InitEmpty for blockdev_getss (0) */
1847 r = guestfs_umount_all (g);
1854 r = guestfs_lvm_remove_all (g);
1858 /* TestOutputInt for blockdev_getss (0) */
1862 r = guestfs_blockdev_getss (g, "/dev/sda");
1866 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
1873 static int test_blockdev_getro_0 (void)
1875 /* InitEmpty for blockdev_getro (0) */
1879 r = guestfs_umount_all (g);
1886 r = guestfs_lvm_remove_all (g);
1890 /* TestOutputTrue for blockdev_getro (0) */
1894 r = guestfs_blockdev_setro (g, "/dev/sda");
1901 r = guestfs_blockdev_getro (g, "/dev/sda");
1905 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
1912 static int test_blockdev_setrw_0 (void)
1914 /* InitEmpty for blockdev_setrw (0) */
1918 r = guestfs_umount_all (g);
1925 r = guestfs_lvm_remove_all (g);
1929 /* TestOutputFalse for blockdev_setrw (0) */
1933 r = guestfs_blockdev_setrw (g, "/dev/sda");
1940 r = guestfs_blockdev_getro (g, "/dev/sda");
1944 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
1951 static int test_blockdev_setro_0 (void)
1953 /* InitEmpty for blockdev_setro (0) */
1957 r = guestfs_umount_all (g);
1964 r = guestfs_lvm_remove_all (g);
1968 /* TestOutputTrue for blockdev_setro (0) */
1972 r = guestfs_blockdev_setro (g, "/dev/sda");
1979 r = guestfs_blockdev_getro (g, "/dev/sda");
1983 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
1990 static int test_statvfs_0 (void)
1992 /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */
1996 r = guestfs_umount_all (g);
2003 r = guestfs_lvm_remove_all (g);
2014 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2021 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2028 r = guestfs_mount (g, "/dev/sda1", "/");
2032 /* TestOutputStruct for statvfs (0) */
2034 struct guestfs_statvfs *r;
2036 r = guestfs_statvfs (g, "/");
2039 if (r->bfree != 487702) {
2040 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
2044 if (r->blocks != 490020) {
2045 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
2049 if (r->bsize != 1024) {
2050 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
2059 static int test_lstat_0 (void)
2061 /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */
2065 r = guestfs_umount_all (g);
2072 r = guestfs_lvm_remove_all (g);
2083 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2090 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2097 r = guestfs_mount (g, "/dev/sda1", "/");
2101 /* TestOutputStruct for lstat (0) */
2105 r = guestfs_touch (g, "/new");
2110 struct guestfs_stat *r;
2112 r = guestfs_lstat (g, "/new");
2116 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
2125 static int test_stat_0 (void)
2127 /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */
2131 r = guestfs_umount_all (g);
2138 r = guestfs_lvm_remove_all (g);
2149 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2156 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2163 r = guestfs_mount (g, "/dev/sda1", "/");
2167 /* TestOutputStruct for stat (0) */
2171 r = guestfs_touch (g, "/new");
2176 struct guestfs_stat *r;
2178 r = guestfs_stat (g, "/new");
2182 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
2191 static int test_file_0 (void)
2193 /* InitBasicFS for file (0): create ext2 on /dev/sda1 */
2197 r = guestfs_umount_all (g);
2204 r = guestfs_lvm_remove_all (g);
2215 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2222 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2229 r = guestfs_mount (g, "/dev/sda1", "/");
2233 /* TestOutput for file (0) */
2237 r = guestfs_touch (g, "/new");
2244 r = guestfs_file (g, "/new");
2247 if (strcmp (r, "empty") != 0) {
2248 fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r);
2256 static int test_file_1 (void)
2258 /* InitBasicFS for file (1): create ext2 on /dev/sda1 */
2262 r = guestfs_umount_all (g);
2269 r = guestfs_lvm_remove_all (g);
2280 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2287 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2294 r = guestfs_mount (g, "/dev/sda1", "/");
2298 /* TestOutput for file (1) */
2302 r = guestfs_write_file (g, "/new", "some content\n", 0);
2309 r = guestfs_file (g, "/new");
2312 if (strcmp (r, "ASCII text") != 0) {
2313 fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r);
2321 static int test_file_2 (void)
2323 /* InitBasicFS for file (2): create ext2 on /dev/sda1 */
2327 r = guestfs_umount_all (g);
2334 r = guestfs_lvm_remove_all (g);
2345 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2352 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2359 r = guestfs_mount (g, "/dev/sda1", "/");
2363 /* TestLastFail for file (2) */
2367 r = guestfs_file (g, "/nofile");
2375 static int test_umount_all_0 (void)
2377 /* InitBasicFS for umount_all (0): create ext2 on /dev/sda1 */
2381 r = guestfs_umount_all (g);
2388 r = guestfs_lvm_remove_all (g);
2399 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2406 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2413 r = guestfs_mount (g, "/dev/sda1", "/");
2417 /* TestOutputList for umount_all (0) */
2421 r = guestfs_umount_all (g);
2429 r = guestfs_mounts (g);
2433 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
2437 for (i = 0; r[i] != NULL; ++i)
2444 static int test_mounts_0 (void)
2446 /* InitBasicFS for mounts (0): create ext2 on /dev/sda1 */
2450 r = guestfs_umount_all (g);
2457 r = guestfs_lvm_remove_all (g);
2468 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2475 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2482 r = guestfs_mount (g, "/dev/sda1", "/");
2486 /* TestOutputList for mounts (0) */
2491 r = guestfs_mounts (g);
2495 fprintf (stderr, "test_mounts_0: short list returned from command\n");
2499 if (strcmp (r[0], "/dev/sda1") != 0) {
2500 fprintf (stderr, "test_mounts_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2504 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
2508 for (i = 0; r[i] != NULL; ++i)
2515 static int test_umount_0 (void)
2517 /* InitEmpty for umount (0) */
2521 r = guestfs_umount_all (g);
2528 r = guestfs_lvm_remove_all (g);
2532 /* TestOutputList for umount (0) */
2540 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2547 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2554 r = guestfs_mount (g, "/dev/sda1", "/");
2562 r = guestfs_mounts (g);
2566 fprintf (stderr, "test_umount_0: short list returned from command\n");
2570 if (strcmp (r[0], "/dev/sda1") != 0) {
2571 fprintf (stderr, "test_umount_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
2575 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
2579 for (i = 0; r[i] != NULL; ++i)
2586 static int test_umount_1 (void)
2588 /* InitEmpty for umount (1) */
2592 r = guestfs_umount_all (g);
2599 r = guestfs_lvm_remove_all (g);
2603 /* TestOutputList for umount (1) */
2611 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2618 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2625 r = guestfs_mount (g, "/dev/sda1", "/");
2632 r = guestfs_umount (g, "/");
2640 r = guestfs_mounts (g);
2644 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
2648 for (i = 0; r[i] != NULL; ++i)
2655 static int test_write_file_0 (void)
2657 /* InitBasicFS for write_file (0): create ext2 on /dev/sda1 */
2661 r = guestfs_umount_all (g);
2668 r = guestfs_lvm_remove_all (g);
2679 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2686 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2693 r = guestfs_mount (g, "/dev/sda1", "/");
2697 /* TestOutput for write_file (0) */
2701 r = guestfs_write_file (g, "/new", "new file contents", 0);
2708 r = guestfs_cat (g, "/new");
2711 if (strcmp (r, "new file contents") != 0) {
2712 fprintf (stderr, "test_write_file_0: expected \"new file contents\" but got \"%s\"\n", r);
2720 static int test_write_file_1 (void)
2722 /* InitBasicFS for write_file (1): create ext2 on /dev/sda1 */
2726 r = guestfs_umount_all (g);
2733 r = guestfs_lvm_remove_all (g);
2744 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2751 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2758 r = guestfs_mount (g, "/dev/sda1", "/");
2762 /* TestOutput for write_file (1) */
2766 r = guestfs_write_file (g, "/new", "\nnew file contents\n", 0);
2773 r = guestfs_cat (g, "/new");
2776 if (strcmp (r, "\nnew file contents\n") != 0) {
2777 fprintf (stderr, "test_write_file_1: expected \"\nnew file contents\n\" but got \"%s\"\n", r);
2785 static int test_write_file_2 (void)
2787 /* InitBasicFS for write_file (2): create ext2 on /dev/sda1 */
2791 r = guestfs_umount_all (g);
2798 r = guestfs_lvm_remove_all (g);
2809 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2816 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2823 r = guestfs_mount (g, "/dev/sda1", "/");
2827 /* TestOutput for write_file (2) */
2831 r = guestfs_write_file (g, "/new", "\n\n", 0);
2838 r = guestfs_cat (g, "/new");
2841 if (strcmp (r, "\n\n") != 0) {
2842 fprintf (stderr, "test_write_file_2: expected \"\n\n\" but got \"%s\"\n", r);
2850 static int test_write_file_3 (void)
2852 /* InitBasicFS for write_file (3): create ext2 on /dev/sda1 */
2856 r = guestfs_umount_all (g);
2863 r = guestfs_lvm_remove_all (g);
2874 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2881 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2888 r = guestfs_mount (g, "/dev/sda1", "/");
2892 /* TestOutput for write_file (3) */
2896 r = guestfs_write_file (g, "/new", "", 0);
2903 r = guestfs_cat (g, "/new");
2906 if (strcmp (r, "") != 0) {
2907 fprintf (stderr, "test_write_file_3: expected \"\" but got \"%s\"\n", r);
2915 static int test_write_file_4 (void)
2917 /* InitBasicFS for write_file (4): create ext2 on /dev/sda1 */
2921 r = guestfs_umount_all (g);
2928 r = guestfs_lvm_remove_all (g);
2939 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
2946 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
2953 r = guestfs_mount (g, "/dev/sda1", "/");
2957 /* TestOutput for write_file (4) */
2961 r = guestfs_write_file (g, "/new", "\n\n\n", 0);
2968 r = guestfs_cat (g, "/new");
2971 if (strcmp (r, "\n\n\n") != 0) {
2972 fprintf (stderr, "test_write_file_4: expected \"\n\n\n\" but got \"%s\"\n", r);
2980 static int test_write_file_5 (void)
2982 /* InitBasicFS for write_file (5): create ext2 on /dev/sda1 */
2986 r = guestfs_umount_all (g);
2993 r = guestfs_lvm_remove_all (g);
3004 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3011 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3018 r = guestfs_mount (g, "/dev/sda1", "/");
3022 /* TestOutput for write_file (5) */
3026 r = guestfs_write_file (g, "/new", "\n", 0);
3033 r = guestfs_cat (g, "/new");
3036 if (strcmp (r, "\n") != 0) {
3037 fprintf (stderr, "test_write_file_5: expected \"\n\" but got \"%s\"\n", r);
3045 static int test_mkfs_0 (void)
3047 /* InitEmpty for mkfs (0) */
3051 r = guestfs_umount_all (g);
3058 r = guestfs_lvm_remove_all (g);
3062 /* TestOutput for mkfs (0) */
3070 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3077 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3084 r = guestfs_mount (g, "/dev/sda1", "/");
3091 r = guestfs_write_file (g, "/new", "new file contents", 0);
3098 r = guestfs_cat (g, "/new");
3101 if (strcmp (r, "new file contents") != 0) {
3102 fprintf (stderr, "test_mkfs_0: expected \"new file contents\" but got \"%s\"\n", r);
3110 static int test_lvcreate_0 (void)
3112 /* InitEmpty for lvcreate (0) */
3116 r = guestfs_umount_all (g);
3123 r = guestfs_lvm_remove_all (g);
3127 /* TestOutputList for lvcreate (0) */
3137 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3144 r = guestfs_pvcreate (g, "/dev/sda1");
3151 r = guestfs_pvcreate (g, "/dev/sda2");
3158 r = guestfs_pvcreate (g, "/dev/sda3");
3163 char *physvols[] = {
3170 r = guestfs_vgcreate (g, "VG1", physvols);
3175 char *physvols[] = {
3181 r = guestfs_vgcreate (g, "VG2", physvols);
3188 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
3195 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
3202 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
3209 r = guestfs_lvcreate (g, "LV4", "VG2", 50);
3216 r = guestfs_lvcreate (g, "LV5", "VG2", 50);
3224 r = guestfs_lvs (g);
3228 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3232 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
3233 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
3237 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3241 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
3242 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
3246 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3250 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
3251 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
3255 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3259 if (strcmp (r[3], "/dev/VG2/LV4") != 0) {
3260 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV4\" but got \"%s\"\n", r[3]);
3264 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
3268 if (strcmp (r[4], "/dev/VG2/LV5") != 0) {
3269 fprintf (stderr, "test_lvcreate_0: expected \"/dev/VG2/LV5\" but got \"%s\"\n", r[4]);
3273 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
3277 for (i = 0; r[i] != NULL; ++i)
3284 static int test_vgcreate_0 (void)
3286 /* InitEmpty for vgcreate (0) */
3290 r = guestfs_umount_all (g);
3297 r = guestfs_lvm_remove_all (g);
3301 /* TestOutputList for vgcreate (0) */
3311 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3318 r = guestfs_pvcreate (g, "/dev/sda1");
3325 r = guestfs_pvcreate (g, "/dev/sda2");
3332 r = guestfs_pvcreate (g, "/dev/sda3");
3337 char *physvols[] = {
3344 r = guestfs_vgcreate (g, "VG1", physvols);
3349 char *physvols[] = {
3355 r = guestfs_vgcreate (g, "VG2", physvols);
3363 r = guestfs_vgs (g);
3367 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
3371 if (strcmp (r[0], "VG1") != 0) {
3372 fprintf (stderr, "test_vgcreate_0: expected \"VG1\" but got \"%s\"\n", r[0]);
3376 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
3380 if (strcmp (r[1], "VG2") != 0) {
3381 fprintf (stderr, "test_vgcreate_0: expected \"VG2\" but got \"%s\"\n", r[1]);
3385 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
3389 for (i = 0; r[i] != NULL; ++i)
3396 static int test_pvcreate_0 (void)
3398 /* InitEmpty for pvcreate (0) */
3402 r = guestfs_umount_all (g);
3409 r = guestfs_lvm_remove_all (g);
3413 /* TestOutputList for pvcreate (0) */
3423 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3430 r = guestfs_pvcreate (g, "/dev/sda1");
3437 r = guestfs_pvcreate (g, "/dev/sda2");
3444 r = guestfs_pvcreate (g, "/dev/sda3");
3452 r = guestfs_pvs (g);
3456 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
3460 if (strcmp (r[0], "/dev/sda1") != 0) {
3461 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
3465 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
3469 if (strcmp (r[1], "/dev/sda2") != 0) {
3470 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
3474 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
3478 if (strcmp (r[2], "/dev/sda3") != 0) {
3479 fprintf (stderr, "test_pvcreate_0: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
3483 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
3487 for (i = 0; r[i] != NULL; ++i)
3494 static int test_is_dir_0 (void)
3496 /* InitBasicFS for is_dir (0): create ext2 on /dev/sda1 */
3500 r = guestfs_umount_all (g);
3507 r = guestfs_lvm_remove_all (g);
3518 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3525 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3532 r = guestfs_mount (g, "/dev/sda1", "/");
3536 /* TestOutputFalse for is_dir (0) */
3540 r = guestfs_touch (g, "/new");
3547 r = guestfs_is_dir (g, "/new");
3551 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
3558 static int test_is_dir_1 (void)
3560 /* InitBasicFS for is_dir (1): create ext2 on /dev/sda1 */
3564 r = guestfs_umount_all (g);
3571 r = guestfs_lvm_remove_all (g);
3582 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3589 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3596 r = guestfs_mount (g, "/dev/sda1", "/");
3600 /* TestOutputTrue for is_dir (1) */
3604 r = guestfs_mkdir (g, "/new");
3611 r = guestfs_is_dir (g, "/new");
3615 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
3622 static int test_is_file_0 (void)
3624 /* InitBasicFS for is_file (0): create ext2 on /dev/sda1 */
3628 r = guestfs_umount_all (g);
3635 r = guestfs_lvm_remove_all (g);
3646 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3653 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3660 r = guestfs_mount (g, "/dev/sda1", "/");
3664 /* TestOutputTrue for is_file (0) */
3668 r = guestfs_touch (g, "/new");
3675 r = guestfs_is_file (g, "/new");
3679 fprintf (stderr, "test_is_file_0: expected true, got false\n");
3686 static int test_is_file_1 (void)
3688 /* InitBasicFS for is_file (1): create ext2 on /dev/sda1 */
3692 r = guestfs_umount_all (g);
3699 r = guestfs_lvm_remove_all (g);
3710 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3717 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3724 r = guestfs_mount (g, "/dev/sda1", "/");
3728 /* TestOutputFalse for is_file (1) */
3732 r = guestfs_mkdir (g, "/new");
3739 r = guestfs_is_file (g, "/new");
3743 fprintf (stderr, "test_is_file_1: expected false, got true\n");
3750 static int test_exists_0 (void)
3752 /* InitBasicFS for exists (0): create ext2 on /dev/sda1 */
3756 r = guestfs_umount_all (g);
3763 r = guestfs_lvm_remove_all (g);
3774 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3781 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3788 r = guestfs_mount (g, "/dev/sda1", "/");
3792 /* TestOutputTrue for exists (0) */
3796 r = guestfs_touch (g, "/new");
3803 r = guestfs_exists (g, "/new");
3807 fprintf (stderr, "test_exists_0: expected true, got false\n");
3814 static int test_exists_1 (void)
3816 /* InitBasicFS for exists (1): create ext2 on /dev/sda1 */
3820 r = guestfs_umount_all (g);
3827 r = guestfs_lvm_remove_all (g);
3838 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3845 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3852 r = guestfs_mount (g, "/dev/sda1", "/");
3856 /* TestOutputTrue for exists (1) */
3860 r = guestfs_mkdir (g, "/new");
3867 r = guestfs_exists (g, "/new");
3871 fprintf (stderr, "test_exists_1: expected true, got false\n");
3878 static int test_mkdir_p_0 (void)
3880 /* InitBasicFS for mkdir_p (0): create ext2 on /dev/sda1 */
3884 r = guestfs_umount_all (g);
3891 r = guestfs_lvm_remove_all (g);
3902 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3909 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3916 r = guestfs_mount (g, "/dev/sda1", "/");
3920 /* TestOutputTrue for mkdir_p (0) */
3924 r = guestfs_mkdir_p (g, "/new/foo/bar");
3931 r = guestfs_is_dir (g, "/new/foo/bar");
3935 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
3942 static int test_mkdir_p_1 (void)
3944 /* InitBasicFS for mkdir_p (1): create ext2 on /dev/sda1 */
3948 r = guestfs_umount_all (g);
3955 r = guestfs_lvm_remove_all (g);
3966 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
3973 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
3980 r = guestfs_mount (g, "/dev/sda1", "/");
3984 /* TestOutputTrue for mkdir_p (1) */
3988 r = guestfs_mkdir_p (g, "/new/foo/bar");
3995 r = guestfs_is_dir (g, "/new/foo");
3999 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
4006 static int test_mkdir_p_2 (void)
4008 /* InitBasicFS for mkdir_p (2): create ext2 on /dev/sda1 */
4012 r = guestfs_umount_all (g);
4019 r = guestfs_lvm_remove_all (g);
4030 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4037 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4044 r = guestfs_mount (g, "/dev/sda1", "/");
4048 /* TestOutputTrue for mkdir_p (2) */
4052 r = guestfs_mkdir_p (g, "/new/foo/bar");
4059 r = guestfs_is_dir (g, "/new");
4063 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
4070 static int test_mkdir_0 (void)
4072 /* InitBasicFS for mkdir (0): create ext2 on /dev/sda1 */
4076 r = guestfs_umount_all (g);
4083 r = guestfs_lvm_remove_all (g);
4094 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4101 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4108 r = guestfs_mount (g, "/dev/sda1", "/");
4112 /* TestOutputTrue for mkdir (0) */
4116 r = guestfs_mkdir (g, "/new");
4123 r = guestfs_is_dir (g, "/new");
4127 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
4134 static int test_mkdir_1 (void)
4136 /* InitBasicFS for mkdir (1): create ext2 on /dev/sda1 */
4140 r = guestfs_umount_all (g);
4147 r = guestfs_lvm_remove_all (g);
4158 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4165 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4172 r = guestfs_mount (g, "/dev/sda1", "/");
4176 /* TestLastFail for mkdir (1) */
4180 r = guestfs_mkdir (g, "/new/foo/bar");
4187 static int test_rm_rf_0 (void)
4189 /* InitBasicFS for rm_rf (0): create ext2 on /dev/sda1 */
4193 r = guestfs_umount_all (g);
4200 r = guestfs_lvm_remove_all (g);
4211 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4218 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4225 r = guestfs_mount (g, "/dev/sda1", "/");
4229 /* TestOutputFalse for rm_rf (0) */
4233 r = guestfs_mkdir (g, "/new");
4240 r = guestfs_mkdir (g, "/new/foo");
4247 r = guestfs_touch (g, "/new/foo/bar");
4254 r = guestfs_rm_rf (g, "/new");
4261 r = guestfs_exists (g, "/new");
4265 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
4272 static int test_rmdir_0 (void)
4274 /* InitBasicFS for rmdir (0): create ext2 on /dev/sda1 */
4278 r = guestfs_umount_all (g);
4285 r = guestfs_lvm_remove_all (g);
4296 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4303 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4310 r = guestfs_mount (g, "/dev/sda1", "/");
4314 /* TestRun for rmdir (0) */
4318 r = guestfs_mkdir (g, "/new");
4325 r = guestfs_rmdir (g, "/new");
4332 static int test_rmdir_1 (void)
4334 /* InitBasicFS for rmdir (1): create ext2 on /dev/sda1 */
4338 r = guestfs_umount_all (g);
4345 r = guestfs_lvm_remove_all (g);
4356 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4363 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4370 r = guestfs_mount (g, "/dev/sda1", "/");
4374 /* TestLastFail for rmdir (1) */
4378 r = guestfs_rmdir (g, "/new");
4385 static int test_rmdir_2 (void)
4387 /* InitBasicFS for rmdir (2): create ext2 on /dev/sda1 */
4391 r = guestfs_umount_all (g);
4398 r = guestfs_lvm_remove_all (g);
4409 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4416 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4423 r = guestfs_mount (g, "/dev/sda1", "/");
4427 /* TestLastFail for rmdir (2) */
4431 r = guestfs_touch (g, "/new");
4438 r = guestfs_rmdir (g, "/new");
4445 static int test_rm_0 (void)
4447 /* InitBasicFS for rm (0): create ext2 on /dev/sda1 */
4451 r = guestfs_umount_all (g);
4458 r = guestfs_lvm_remove_all (g);
4469 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4476 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4483 r = guestfs_mount (g, "/dev/sda1", "/");
4487 /* TestRun for rm (0) */
4491 r = guestfs_touch (g, "/new");
4498 r = guestfs_rm (g, "/new");
4505 static int test_rm_1 (void)
4507 /* InitBasicFS for rm (1): create ext2 on /dev/sda1 */
4511 r = guestfs_umount_all (g);
4518 r = guestfs_lvm_remove_all (g);
4529 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4536 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4543 r = guestfs_mount (g, "/dev/sda1", "/");
4547 /* TestLastFail for rm (1) */
4551 r = guestfs_rm (g, "/new");
4558 static int test_rm_2 (void)
4560 /* InitBasicFS for rm (2): create ext2 on /dev/sda1 */
4564 r = guestfs_umount_all (g);
4571 r = guestfs_lvm_remove_all (g);
4582 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4589 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4596 r = guestfs_mount (g, "/dev/sda1", "/");
4600 /* TestLastFail for rm (2) */
4604 r = guestfs_mkdir (g, "/new");
4611 r = guestfs_rm (g, "/new");
4618 static int test_read_lines_0 (void)
4620 /* InitBasicFS for read_lines (0): create ext2 on /dev/sda1 */
4624 r = guestfs_umount_all (g);
4631 r = guestfs_lvm_remove_all (g);
4642 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4649 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4656 r = guestfs_mount (g, "/dev/sda1", "/");
4660 /* TestOutputList for read_lines (0) */
4664 r = guestfs_write_file (g, "/new", "line1\r\nline2\nline3", 0);
4672 r = guestfs_read_lines (g, "/new");
4676 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4680 if (strcmp (r[0], "line1") != 0) {
4681 fprintf (stderr, "test_read_lines_0: expected \"line1\" but got \"%s\"\n", r[0]);
4685 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4689 if (strcmp (r[1], "line2") != 0) {
4690 fprintf (stderr, "test_read_lines_0: expected \"line2\" but got \"%s\"\n", r[1]);
4694 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
4698 if (strcmp (r[2], "line3") != 0) {
4699 fprintf (stderr, "test_read_lines_0: expected \"line3\" but got \"%s\"\n", r[2]);
4703 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
4707 for (i = 0; r[i] != NULL; ++i)
4714 static int test_read_lines_1 (void)
4716 /* InitBasicFS for read_lines (1): create ext2 on /dev/sda1 */
4720 r = guestfs_umount_all (g);
4727 r = guestfs_lvm_remove_all (g);
4738 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4745 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
4752 r = guestfs_mount (g, "/dev/sda1", "/");
4756 /* TestOutputList for read_lines (1) */
4760 r = guestfs_write_file (g, "/new", "", 0);
4768 r = guestfs_read_lines (g, "/new");
4772 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
4776 for (i = 0; r[i] != NULL; ++i)
4783 static int test_lvs_0 (void)
4785 /* InitBasicFSonLVM for lvs (0): create ext2 on /dev/VG/LV */
4789 r = guestfs_umount_all (g);
4796 r = guestfs_lvm_remove_all (g);
4807 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4814 r = guestfs_pvcreate (g, "/dev/sda1");
4819 char *physvols[] = {
4825 r = guestfs_vgcreate (g, "VG", physvols);
4832 r = guestfs_lvcreate (g, "LV", "VG", 8);
4839 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
4846 r = guestfs_mount (g, "/dev/VG/LV", "/");
4850 /* TestOutputList for lvs (0) */
4855 r = guestfs_lvs (g);
4859 fprintf (stderr, "test_lvs_0: short list returned from command\n");
4863 if (strcmp (r[0], "/dev/VG/LV") != 0) {
4864 fprintf (stderr, "test_lvs_0: expected \"/dev/VG/LV\" but got \"%s\"\n", r[0]);
4868 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
4872 for (i = 0; r[i] != NULL; ++i)
4879 static int test_lvs_1 (void)
4881 /* InitEmpty for lvs (1) */
4885 r = guestfs_umount_all (g);
4892 r = guestfs_lvm_remove_all (g);
4896 /* TestOutputList for lvs (1) */
4906 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
4913 r = guestfs_pvcreate (g, "/dev/sda1");
4920 r = guestfs_pvcreate (g, "/dev/sda2");
4927 r = guestfs_pvcreate (g, "/dev/sda3");
4932 char *physvols[] = {
4939 r = guestfs_vgcreate (g, "VG1", physvols);
4944 char *physvols[] = {
4950 r = guestfs_vgcreate (g, "VG2", physvols);
4957 r = guestfs_lvcreate (g, "LV1", "VG1", 50);
4964 r = guestfs_lvcreate (g, "LV2", "VG1", 50);
4971 r = guestfs_lvcreate (g, "LV3", "VG2", 50);
4979 r = guestfs_lvs (g);
4983 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4987 if (strcmp (r[0], "/dev/VG1/LV1") != 0) {
4988 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV1\" but got \"%s\"\n", r[0]);
4992 fprintf (stderr, "test_lvs_1: short list returned from command\n");
4996 if (strcmp (r[1], "/dev/VG1/LV2") != 0) {
4997 fprintf (stderr, "test_lvs_1: expected \"/dev/VG1/LV2\" but got \"%s\"\n", r[1]);
5001 fprintf (stderr, "test_lvs_1: short list returned from command\n");
5005 if (strcmp (r[2], "/dev/VG2/LV3") != 0) {
5006 fprintf (stderr, "test_lvs_1: expected \"/dev/VG2/LV3\" but got \"%s\"\n", r[2]);
5010 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
5014 for (i = 0; r[i] != NULL; ++i)
5021 static int test_vgs_0 (void)
5023 /* InitBasicFSonLVM for vgs (0): create ext2 on /dev/VG/LV */
5027 r = guestfs_umount_all (g);
5034 r = guestfs_lvm_remove_all (g);
5045 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5052 r = guestfs_pvcreate (g, "/dev/sda1");
5057 char *physvols[] = {
5063 r = guestfs_vgcreate (g, "VG", physvols);
5070 r = guestfs_lvcreate (g, "LV", "VG", 8);
5077 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5084 r = guestfs_mount (g, "/dev/VG/LV", "/");
5088 /* TestOutputList for vgs (0) */
5093 r = guestfs_vgs (g);
5097 fprintf (stderr, "test_vgs_0: short list returned from command\n");
5101 if (strcmp (r[0], "VG") != 0) {
5102 fprintf (stderr, "test_vgs_0: expected \"VG\" but got \"%s\"\n", r[0]);
5106 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
5110 for (i = 0; r[i] != NULL; ++i)
5117 static int test_vgs_1 (void)
5119 /* InitEmpty for vgs (1) */
5123 r = guestfs_umount_all (g);
5130 r = guestfs_lvm_remove_all (g);
5134 /* TestOutputList for vgs (1) */
5144 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5151 r = guestfs_pvcreate (g, "/dev/sda1");
5158 r = guestfs_pvcreate (g, "/dev/sda2");
5165 r = guestfs_pvcreate (g, "/dev/sda3");
5170 char *physvols[] = {
5177 r = guestfs_vgcreate (g, "VG1", physvols);
5182 char *physvols[] = {
5188 r = guestfs_vgcreate (g, "VG2", physvols);
5196 r = guestfs_vgs (g);
5200 fprintf (stderr, "test_vgs_1: short list returned from command\n");
5204 if (strcmp (r[0], "VG1") != 0) {
5205 fprintf (stderr, "test_vgs_1: expected \"VG1\" but got \"%s\"\n", r[0]);
5209 fprintf (stderr, "test_vgs_1: short list returned from command\n");
5213 if (strcmp (r[1], "VG2") != 0) {
5214 fprintf (stderr, "test_vgs_1: expected \"VG2\" but got \"%s\"\n", r[1]);
5218 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
5222 for (i = 0; r[i] != NULL; ++i)
5229 static int test_pvs_0 (void)
5231 /* InitBasicFSonLVM for pvs (0): create ext2 on /dev/VG/LV */
5235 r = guestfs_umount_all (g);
5242 r = guestfs_lvm_remove_all (g);
5253 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5260 r = guestfs_pvcreate (g, "/dev/sda1");
5265 char *physvols[] = {
5271 r = guestfs_vgcreate (g, "VG", physvols);
5278 r = guestfs_lvcreate (g, "LV", "VG", 8);
5285 r = guestfs_mkfs (g, "ext2", "/dev/VG/LV");
5292 r = guestfs_mount (g, "/dev/VG/LV", "/");
5296 /* TestOutputList for pvs (0) */
5301 r = guestfs_pvs (g);
5305 fprintf (stderr, "test_pvs_0: short list returned from command\n");
5309 if (strcmp (r[0], "/dev/sda1") != 0) {
5310 fprintf (stderr, "test_pvs_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
5314 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
5318 for (i = 0; r[i] != NULL; ++i)
5325 static int test_pvs_1 (void)
5327 /* InitEmpty for pvs (1) */
5331 r = guestfs_umount_all (g);
5338 r = guestfs_lvm_remove_all (g);
5342 /* TestOutputList for pvs (1) */
5352 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5359 r = guestfs_pvcreate (g, "/dev/sda1");
5366 r = guestfs_pvcreate (g, "/dev/sda2");
5373 r = guestfs_pvcreate (g, "/dev/sda3");
5381 r = guestfs_pvs (g);
5385 fprintf (stderr, "test_pvs_1: short list returned from command\n");
5389 if (strcmp (r[0], "/dev/sda1") != 0) {
5390 fprintf (stderr, "test_pvs_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
5394 fprintf (stderr, "test_pvs_1: short list returned from command\n");
5398 if (strcmp (r[1], "/dev/sda2") != 0) {
5399 fprintf (stderr, "test_pvs_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
5403 fprintf (stderr, "test_pvs_1: short list returned from command\n");
5407 if (strcmp (r[2], "/dev/sda3") != 0) {
5408 fprintf (stderr, "test_pvs_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
5412 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
5416 for (i = 0; r[i] != NULL; ++i)
5423 static int test_list_partitions_0 (void)
5425 /* InitBasicFS for list_partitions (0): create ext2 on /dev/sda1 */
5429 r = guestfs_umount_all (g);
5436 r = guestfs_lvm_remove_all (g);
5447 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5454 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5461 r = guestfs_mount (g, "/dev/sda1", "/");
5465 /* TestOutputList for list_partitions (0) */
5470 r = guestfs_list_partitions (g);
5474 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
5478 if (strcmp (r[0], "/dev/sda1") != 0) {
5479 fprintf (stderr, "test_list_partitions_0: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
5483 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
5487 for (i = 0; r[i] != NULL; ++i)
5494 static int test_list_partitions_1 (void)
5496 /* InitEmpty for list_partitions (1) */
5500 r = guestfs_umount_all (g);
5507 r = guestfs_lvm_remove_all (g);
5511 /* TestOutputList for list_partitions (1) */
5521 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5529 r = guestfs_list_partitions (g);
5533 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
5537 if (strcmp (r[0], "/dev/sda1") != 0) {
5538 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda1\" but got \"%s\"\n", r[0]);
5542 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
5546 if (strcmp (r[1], "/dev/sda2") != 0) {
5547 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda2\" but got \"%s\"\n", r[1]);
5551 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
5555 if (strcmp (r[2], "/dev/sda3") != 0) {
5556 fprintf (stderr, "test_list_partitions_1: expected \"/dev/sda3\" but got \"%s\"\n", r[2]);
5560 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
5564 for (i = 0; r[i] != NULL; ++i)
5571 static int test_list_devices_0 (void)
5573 /* InitEmpty for list_devices (0) */
5577 r = guestfs_umount_all (g);
5584 r = guestfs_lvm_remove_all (g);
5588 /* TestOutputList for list_devices (0) */
5593 r = guestfs_list_devices (g);
5597 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
5601 if (strcmp (r[0], "/dev/sda") != 0) {
5602 fprintf (stderr, "test_list_devices_0: expected \"/dev/sda\" but got \"%s\"\n", r[0]);
5606 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
5610 if (strcmp (r[1], "/dev/sdb") != 0) {
5611 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdb\" but got \"%s\"\n", r[1]);
5615 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
5619 if (strcmp (r[2], "/dev/sdc") != 0) {
5620 fprintf (stderr, "test_list_devices_0: expected \"/dev/sdc\" but got \"%s\"\n", r[2]);
5624 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
5628 for (i = 0; r[i] != NULL; ++i)
5635 static int test_ls_0 (void)
5637 /* InitBasicFS for ls (0): create ext2 on /dev/sda1 */
5641 r = guestfs_umount_all (g);
5648 r = guestfs_lvm_remove_all (g);
5659 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5666 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5673 r = guestfs_mount (g, "/dev/sda1", "/");
5677 /* TestOutputList for ls (0) */
5681 r = guestfs_touch (g, "/new");
5688 r = guestfs_touch (g, "/newer");
5695 r = guestfs_touch (g, "/newest");
5703 r = guestfs_ls (g, "/");
5707 fprintf (stderr, "test_ls_0: short list returned from command\n");
5711 if (strcmp (r[0], "lost+found") != 0) {
5712 fprintf (stderr, "test_ls_0: expected \"lost+found\" but got \"%s\"\n", r[0]);
5716 fprintf (stderr, "test_ls_0: short list returned from command\n");
5720 if (strcmp (r[1], "new") != 0) {
5721 fprintf (stderr, "test_ls_0: expected \"new\" but got \"%s\"\n", r[1]);
5725 fprintf (stderr, "test_ls_0: short list returned from command\n");
5729 if (strcmp (r[2], "newer") != 0) {
5730 fprintf (stderr, "test_ls_0: expected \"newer\" but got \"%s\"\n", r[2]);
5734 fprintf (stderr, "test_ls_0: short list returned from command\n");
5738 if (strcmp (r[3], "newest") != 0) {
5739 fprintf (stderr, "test_ls_0: expected \"newest\" but got \"%s\"\n", r[3]);
5743 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
5747 for (i = 0; r[i] != NULL; ++i)
5754 static int test_cat_0 (void)
5756 /* InitBasicFS for cat (0): create ext2 on /dev/sda1 */
5760 r = guestfs_umount_all (g);
5767 r = guestfs_lvm_remove_all (g);
5778 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5785 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5792 r = guestfs_mount (g, "/dev/sda1", "/");
5796 /* TestOutput for cat (0) */
5800 r = guestfs_write_file (g, "/new", "new file contents", 0);
5807 r = guestfs_cat (g, "/new");
5810 if (strcmp (r, "new file contents") != 0) {
5811 fprintf (stderr, "test_cat_0: expected \"new file contents\" but got \"%s\"\n", r);
5819 static int test_touch_0 (void)
5821 /* InitBasicFS for touch (0): create ext2 on /dev/sda1 */
5825 r = guestfs_umount_all (g);
5832 r = guestfs_lvm_remove_all (g);
5843 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5850 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5857 r = guestfs_mount (g, "/dev/sda1", "/");
5861 /* TestOutputTrue for touch (0) */
5865 r = guestfs_touch (g, "/new");
5872 r = guestfs_exists (g, "/new");
5876 fprintf (stderr, "test_touch_0: expected true, got false\n");
5883 static int test_sync_0 (void)
5885 /* InitEmpty for sync (0) */
5889 r = guestfs_umount_all (g);
5896 r = guestfs_lvm_remove_all (g);
5900 /* TestRun for sync (0) */
5904 r = guestfs_sync (g);
5911 static int test_mount_0 (void)
5913 /* InitEmpty for mount (0) */
5917 r = guestfs_umount_all (g);
5924 r = guestfs_lvm_remove_all (g);
5928 /* TestOutput for mount (0) */
5936 r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
5943 r = guestfs_mkfs (g, "ext2", "/dev/sda1");
5950 r = guestfs_mount (g, "/dev/sda1", "/");
5957 r = guestfs_write_file (g, "/new", "new file contents", 0);
5964 r = guestfs_cat (g, "/new");
5967 if (strcmp (r, "new file contents") != 0) {
5968 fprintf (stderr, "test_mount_0: expected \"new file contents\" but got \"%s\"\n", r);
5976 int main (int argc, char *argv[])
5981 const char *filename;
5983 int nr_tests, test_num = 0;
5985 no_test_warnings ();
5987 g = guestfs_create ();
5989 printf ("guestfs_create FAILED\n");
5993 guestfs_set_error_handler (g, print_error, NULL);
5995 srcdir = getenv ("srcdir");
5996 if (!srcdir) srcdir = ".";
5998 guestfs_set_path (g, ".");
6000 filename = "test1.img";
6001 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6006 if (lseek (fd, 524288000, SEEK_SET) == -1) {
6012 if (write (fd, &c, 1) == -1) {
6018 if (close (fd) == -1) {
6023 if (guestfs_add_drive (g, filename) == -1) {
6024 printf ("guestfs_add_drive %s FAILED\n", filename);
6028 filename = "test2.img";
6029 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6034 if (lseek (fd, 52428800, SEEK_SET) == -1) {
6040 if (write (fd, &c, 1) == -1) {
6046 if (close (fd) == -1) {
6051 if (guestfs_add_drive (g, filename) == -1) {
6052 printf ("guestfs_add_drive %s FAILED\n", filename);
6056 filename = "test3.img";
6057 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
6062 if (lseek (fd, 10485760, SEEK_SET) == -1) {
6068 if (write (fd, &c, 1) == -1) {
6074 if (close (fd) == -1) {
6079 if (guestfs_add_drive (g, filename) == -1) {
6080 printf ("guestfs_add_drive %s FAILED\n", filename);
6084 if (guestfs_launch (g) == -1) {
6085 printf ("guestfs_launch FAILED\n");
6088 if (guestfs_wait_ready (g) == -1) {
6089 printf ("guestfs_wait_ready FAILED\n");
6096 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
6097 if (test_pvremove_0 () == -1) {
6098 printf ("test_pvremove_0 FAILED\n");
6102 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
6103 if (test_pvremove_1 () == -1) {
6104 printf ("test_pvremove_1 FAILED\n");
6108 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
6109 if (test_pvremove_2 () == -1) {
6110 printf ("test_pvremove_2 FAILED\n");
6114 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
6115 if (test_vgremove_0 () == -1) {
6116 printf ("test_vgremove_0 FAILED\n");
6120 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
6121 if (test_vgremove_1 () == -1) {
6122 printf ("test_vgremove_1 FAILED\n");
6126 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
6127 if (test_lvremove_0 () == -1) {
6128 printf ("test_lvremove_0 FAILED\n");
6132 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
6133 if (test_lvremove_1 () == -1) {
6134 printf ("test_lvremove_1 FAILED\n");
6138 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
6139 if (test_lvremove_2 () == -1) {
6140 printf ("test_lvremove_2 FAILED\n");
6144 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
6145 if (test_mount_ro_0 () == -1) {
6146 printf ("test_mount_ro_0 FAILED\n");
6150 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
6151 if (test_mount_ro_1 () == -1) {
6152 printf ("test_mount_ro_1 FAILED\n");
6156 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
6157 if (test_tgz_in_0 () == -1) {
6158 printf ("test_tgz_in_0 FAILED\n");
6162 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
6163 if (test_tar_in_0 () == -1) {
6164 printf ("test_tar_in_0 FAILED\n");
6168 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
6169 if (test_checksum_0 () == -1) {
6170 printf ("test_checksum_0 FAILED\n");
6174 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
6175 if (test_checksum_1 () == -1) {
6176 printf ("test_checksum_1 FAILED\n");
6180 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
6181 if (test_checksum_2 () == -1) {
6182 printf ("test_checksum_2 FAILED\n");
6186 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
6187 if (test_checksum_3 () == -1) {
6188 printf ("test_checksum_3 FAILED\n");
6192 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
6193 if (test_checksum_4 () == -1) {
6194 printf ("test_checksum_4 FAILED\n");
6198 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
6199 if (test_checksum_5 () == -1) {
6200 printf ("test_checksum_5 FAILED\n");
6204 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
6205 if (test_checksum_6 () == -1) {
6206 printf ("test_checksum_6 FAILED\n");
6210 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
6211 if (test_checksum_7 () == -1) {
6212 printf ("test_checksum_7 FAILED\n");
6216 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
6217 if (test_download_0 () == -1) {
6218 printf ("test_download_0 FAILED\n");
6222 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
6223 if (test_upload_0 () == -1) {
6224 printf ("test_upload_0 FAILED\n");
6228 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
6229 if (test_blockdev_rereadpt_0 () == -1) {
6230 printf ("test_blockdev_rereadpt_0 FAILED\n");
6234 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
6235 if (test_blockdev_flushbufs_0 () == -1) {
6236 printf ("test_blockdev_flushbufs_0 FAILED\n");
6240 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
6241 if (test_blockdev_getsize64_0 () == -1) {
6242 printf ("test_blockdev_getsize64_0 FAILED\n");
6246 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
6247 if (test_blockdev_getsz_0 () == -1) {
6248 printf ("test_blockdev_getsz_0 FAILED\n");
6252 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
6253 if (test_blockdev_getbsz_0 () == -1) {
6254 printf ("test_blockdev_getbsz_0 FAILED\n");
6258 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
6259 if (test_blockdev_getss_0 () == -1) {
6260 printf ("test_blockdev_getss_0 FAILED\n");
6264 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
6265 if (test_blockdev_getro_0 () == -1) {
6266 printf ("test_blockdev_getro_0 FAILED\n");
6270 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
6271 if (test_blockdev_setrw_0 () == -1) {
6272 printf ("test_blockdev_setrw_0 FAILED\n");
6276 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
6277 if (test_blockdev_setro_0 () == -1) {
6278 printf ("test_blockdev_setro_0 FAILED\n");
6282 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
6283 if (test_statvfs_0 () == -1) {
6284 printf ("test_statvfs_0 FAILED\n");
6288 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
6289 if (test_lstat_0 () == -1) {
6290 printf ("test_lstat_0 FAILED\n");
6294 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
6295 if (test_stat_0 () == -1) {
6296 printf ("test_stat_0 FAILED\n");
6300 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
6301 if (test_file_0 () == -1) {
6302 printf ("test_file_0 FAILED\n");
6306 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
6307 if (test_file_1 () == -1) {
6308 printf ("test_file_1 FAILED\n");
6312 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
6313 if (test_file_2 () == -1) {
6314 printf ("test_file_2 FAILED\n");
6318 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
6319 if (test_umount_all_0 () == -1) {
6320 printf ("test_umount_all_0 FAILED\n");
6324 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
6325 if (test_mounts_0 () == -1) {
6326 printf ("test_mounts_0 FAILED\n");
6330 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
6331 if (test_umount_0 () == -1) {
6332 printf ("test_umount_0 FAILED\n");
6336 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
6337 if (test_umount_1 () == -1) {
6338 printf ("test_umount_1 FAILED\n");
6342 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
6343 if (test_write_file_0 () == -1) {
6344 printf ("test_write_file_0 FAILED\n");
6348 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
6349 if (test_write_file_1 () == -1) {
6350 printf ("test_write_file_1 FAILED\n");
6354 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
6355 if (test_write_file_2 () == -1) {
6356 printf ("test_write_file_2 FAILED\n");
6360 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
6361 if (test_write_file_3 () == -1) {
6362 printf ("test_write_file_3 FAILED\n");
6366 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
6367 if (test_write_file_4 () == -1) {
6368 printf ("test_write_file_4 FAILED\n");
6372 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
6373 if (test_write_file_5 () == -1) {
6374 printf ("test_write_file_5 FAILED\n");
6378 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
6379 if (test_mkfs_0 () == -1) {
6380 printf ("test_mkfs_0 FAILED\n");
6384 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
6385 if (test_lvcreate_0 () == -1) {
6386 printf ("test_lvcreate_0 FAILED\n");
6390 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
6391 if (test_vgcreate_0 () == -1) {
6392 printf ("test_vgcreate_0 FAILED\n");
6396 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
6397 if (test_pvcreate_0 () == -1) {
6398 printf ("test_pvcreate_0 FAILED\n");
6402 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
6403 if (test_is_dir_0 () == -1) {
6404 printf ("test_is_dir_0 FAILED\n");
6408 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
6409 if (test_is_dir_1 () == -1) {
6410 printf ("test_is_dir_1 FAILED\n");
6414 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
6415 if (test_is_file_0 () == -1) {
6416 printf ("test_is_file_0 FAILED\n");
6420 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
6421 if (test_is_file_1 () == -1) {
6422 printf ("test_is_file_1 FAILED\n");
6426 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
6427 if (test_exists_0 () == -1) {
6428 printf ("test_exists_0 FAILED\n");
6432 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
6433 if (test_exists_1 () == -1) {
6434 printf ("test_exists_1 FAILED\n");
6438 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
6439 if (test_mkdir_p_0 () == -1) {
6440 printf ("test_mkdir_p_0 FAILED\n");
6444 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
6445 if (test_mkdir_p_1 () == -1) {
6446 printf ("test_mkdir_p_1 FAILED\n");
6450 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
6451 if (test_mkdir_p_2 () == -1) {
6452 printf ("test_mkdir_p_2 FAILED\n");
6456 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
6457 if (test_mkdir_0 () == -1) {
6458 printf ("test_mkdir_0 FAILED\n");
6462 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
6463 if (test_mkdir_1 () == -1) {
6464 printf ("test_mkdir_1 FAILED\n");
6468 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
6469 if (test_rm_rf_0 () == -1) {
6470 printf ("test_rm_rf_0 FAILED\n");
6474 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
6475 if (test_rmdir_0 () == -1) {
6476 printf ("test_rmdir_0 FAILED\n");
6480 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
6481 if (test_rmdir_1 () == -1) {
6482 printf ("test_rmdir_1 FAILED\n");
6486 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
6487 if (test_rmdir_2 () == -1) {
6488 printf ("test_rmdir_2 FAILED\n");
6492 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
6493 if (test_rm_0 () == -1) {
6494 printf ("test_rm_0 FAILED\n");
6498 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
6499 if (test_rm_1 () == -1) {
6500 printf ("test_rm_1 FAILED\n");
6504 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
6505 if (test_rm_2 () == -1) {
6506 printf ("test_rm_2 FAILED\n");
6510 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
6511 if (test_read_lines_0 () == -1) {
6512 printf ("test_read_lines_0 FAILED\n");
6516 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
6517 if (test_read_lines_1 () == -1) {
6518 printf ("test_read_lines_1 FAILED\n");
6522 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
6523 if (test_lvs_0 () == -1) {
6524 printf ("test_lvs_0 FAILED\n");
6528 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
6529 if (test_lvs_1 () == -1) {
6530 printf ("test_lvs_1 FAILED\n");
6534 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
6535 if (test_vgs_0 () == -1) {
6536 printf ("test_vgs_0 FAILED\n");
6540 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
6541 if (test_vgs_1 () == -1) {
6542 printf ("test_vgs_1 FAILED\n");
6546 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
6547 if (test_pvs_0 () == -1) {
6548 printf ("test_pvs_0 FAILED\n");
6552 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
6553 if (test_pvs_1 () == -1) {
6554 printf ("test_pvs_1 FAILED\n");
6558 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
6559 if (test_list_partitions_0 () == -1) {
6560 printf ("test_list_partitions_0 FAILED\n");
6564 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
6565 if (test_list_partitions_1 () == -1) {
6566 printf ("test_list_partitions_1 FAILED\n");
6570 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
6571 if (test_list_devices_0 () == -1) {
6572 printf ("test_list_devices_0 FAILED\n");
6576 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
6577 if (test_ls_0 () == -1) {
6578 printf ("test_ls_0 FAILED\n");
6582 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
6583 if (test_cat_0 () == -1) {
6584 printf ("test_cat_0 FAILED\n");
6588 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
6589 if (test_touch_0 () == -1) {
6590 printf ("test_touch_0 FAILED\n");
6594 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
6595 if (test_sync_0 () == -1) {
6596 printf ("test_sync_0 FAILED\n");
6600 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
6601 if (test_mount_0 () == -1) {
6602 printf ("test_mount_0 FAILED\n");
6607 unlink ("test1.img");
6608 unlink ("test2.img");
6609 unlink ("test3.img");
6612 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);