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_test0\" has no tests\n");
66 fprintf (stderr, "warning: \"guestfs_test0rint\" has no tests\n");
67 fprintf (stderr, "warning: \"guestfs_test0rinterr\" has no tests\n");
68 fprintf (stderr, "warning: \"guestfs_test0rint64\" has no tests\n");
69 fprintf (stderr, "warning: \"guestfs_test0rint64err\" has no tests\n");
70 fprintf (stderr, "warning: \"guestfs_test0rbool\" has no tests\n");
71 fprintf (stderr, "warning: \"guestfs_test0rboolerr\" has no tests\n");
72 fprintf (stderr, "warning: \"guestfs_test0rconststring\" has no tests\n");
73 fprintf (stderr, "warning: \"guestfs_test0rconststringerr\" has no tests\n");
74 fprintf (stderr, "warning: \"guestfs_test0rstring\" has no tests\n");
75 fprintf (stderr, "warning: \"guestfs_test0rstringerr\" has no tests\n");
76 fprintf (stderr, "warning: \"guestfs_test0rstringlist\" has no tests\n");
77 fprintf (stderr, "warning: \"guestfs_test0rstringlisterr\" has no tests\n");
78 fprintf (stderr, "warning: \"guestfs_test0rintbool\" has no tests\n");
79 fprintf (stderr, "warning: \"guestfs_test0rintboolerr\" has no tests\n");
80 fprintf (stderr, "warning: \"guestfs_test0rpvlist\" has no tests\n");
81 fprintf (stderr, "warning: \"guestfs_test0rpvlisterr\" has no tests\n");
82 fprintf (stderr, "warning: \"guestfs_test0rvglist\" has no tests\n");
83 fprintf (stderr, "warning: \"guestfs_test0rvglisterr\" has no tests\n");
84 fprintf (stderr, "warning: \"guestfs_test0rlvlist\" has no tests\n");
85 fprintf (stderr, "warning: \"guestfs_test0rlvlisterr\" has no tests\n");
86 fprintf (stderr, "warning: \"guestfs_test0rstat\" has no tests\n");
87 fprintf (stderr, "warning: \"guestfs_test0rstaterr\" has no tests\n");
88 fprintf (stderr, "warning: \"guestfs_test0rstatvfs\" has no tests\n");
89 fprintf (stderr, "warning: \"guestfs_test0rstatvfserr\" has no tests\n");
90 fprintf (stderr, "warning: \"guestfs_test0rhashtable\" has no tests\n");
91 fprintf (stderr, "warning: \"guestfs_test0rhashtableerr\" has no tests\n");
92 fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n");
93 fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n");
94 fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
95 fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
96 fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
97 fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
98 fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
99 fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
100 fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
101 fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
102 fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
103 fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
104 fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
105 fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
106 fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
107 fprintf (stderr, "warning: \"guestfs_get_verbose\" has no tests\n");
108 fprintf (stderr, "warning: \"guestfs_is_ready\" has no tests\n");
109 fprintf (stderr, "warning: \"guestfs_is_config\" has no tests\n");
110 fprintf (stderr, "warning: \"guestfs_is_launching\" has no tests\n");
111 fprintf (stderr, "warning: \"guestfs_is_busy\" has no tests\n");
112 fprintf (stderr, "warning: \"guestfs_get_state\" has no tests\n");
113 fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
114 fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
115 fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
116 fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
117 fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
118 fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
119 fprintf (stderr, "warning: \"guestfs_lvs_full\" has no tests\n");
120 fprintf (stderr, "warning: \"guestfs_aug_init\" has no tests\n");
121 fprintf (stderr, "warning: \"guestfs_aug_close\" has no tests\n");
122 fprintf (stderr, "warning: \"guestfs_aug_defvar\" has no tests\n");
123 fprintf (stderr, "warning: \"guestfs_aug_defnode\" has no tests\n");
124 fprintf (stderr, "warning: \"guestfs_aug_get\" has no tests\n");
125 fprintf (stderr, "warning: \"guestfs_aug_set\" has no tests\n");
126 fprintf (stderr, "warning: \"guestfs_aug_insert\" has no tests\n");
127 fprintf (stderr, "warning: \"guestfs_aug_rm\" has no tests\n");
128 fprintf (stderr, "warning: \"guestfs_aug_mv\" has no tests\n");
129 fprintf (stderr, "warning: \"guestfs_aug_match\" has no tests\n");
130 fprintf (stderr, "warning: \"guestfs_aug_save\" has no tests\n");
131 fprintf (stderr, "warning: \"guestfs_aug_load\" has no tests\n");
132 fprintf (stderr, "warning: \"guestfs_aug_ls\" has no tests\n");
133 fprintf (stderr, "warning: \"guestfs_chmod\" has no tests\n");
134 fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n");
135 fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n");
136 fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n");
137 fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n");
138 fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n");
139 fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n");
140 fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
141 fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
142 fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
143 fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
144 fprintf (stderr, "warning: \"guestfs_get_e2label\" has no tests\n");
145 fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
146 fprintf (stderr, "warning: \"guestfs_pvresize\" has no tests\n");
147 fprintf (stderr, "warning: \"guestfs_sfdisk_N\" has no tests\n");
148 fprintf (stderr, "warning: \"guestfs_sfdisk_l\" has no tests\n");
149 fprintf (stderr, "warning: \"guestfs_sfdisk_kernel_geometry\" has no tests\n");
150 fprintf (stderr, "warning: \"guestfs_sfdisk_disk_geometry\" has no tests\n");
151 fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
152 fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
153 fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
154 fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
157 static int test_find_0_skip (void)
161 str = getenv ("SKIP_TEST_FIND_0");
162 if (str && strcmp (str, "1") == 0) return 1;
163 str = getenv ("SKIP_TEST_FIND");
164 if (str && strcmp (str, "1") == 0) return 1;
168 static int test_find_0 (void)
170 if (test_find_0_skip ()) {
171 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_0");
175 /* InitBasicFS for test_find_0: create ext2 on /dev/sda1 */
177 char device[] = "/dev/sda";
181 r = guestfs_blockdev_setrw (g, device);
188 r = guestfs_umount_all (g);
195 r = guestfs_lvm_remove_all (g);
200 char device[] = "/dev/sda";
202 char lines_0[] = ",";
209 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
214 char fstype[] = "ext2";
215 char device[] = "/dev/sda1";
219 r = guestfs_mkfs (g, fstype, device);
224 char device[] = "/dev/sda1";
226 char mountpoint[] = "/";
229 r = guestfs_mount (g, device, mountpoint);
233 /* TestOutputList for find (0) */
235 char directory[] = "/";
239 r = guestfs_find (g, directory);
243 fprintf (stderr, "test_find_0: short list returned from command\n");
248 char expected[] = "lost+found";
249 if (strcmp (r[0], expected) != 0) {
250 fprintf (stderr, "test_find_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
255 fprintf (stderr, "test_find_0: extra elements returned from command\n");
259 for (i = 0; r[i] != NULL; ++i)
266 static int test_find_1_skip (void)
270 str = getenv ("SKIP_TEST_FIND_1");
271 if (str && strcmp (str, "1") == 0) return 1;
272 str = getenv ("SKIP_TEST_FIND");
273 if (str && strcmp (str, "1") == 0) return 1;
277 static int test_find_1 (void)
279 if (test_find_1_skip ()) {
280 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_1");
284 /* InitBasicFS for test_find_1: create ext2 on /dev/sda1 */
286 char device[] = "/dev/sda";
290 r = guestfs_blockdev_setrw (g, device);
297 r = guestfs_umount_all (g);
304 r = guestfs_lvm_remove_all (g);
309 char device[] = "/dev/sda";
311 char lines_0[] = ",";
318 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
323 char fstype[] = "ext2";
324 char device[] = "/dev/sda1";
328 r = guestfs_mkfs (g, fstype, device);
333 char device[] = "/dev/sda1";
335 char mountpoint[] = "/";
338 r = guestfs_mount (g, device, mountpoint);
342 /* TestOutputList for find (1) */
347 r = guestfs_touch (g, path);
355 r = guestfs_mkdir (g, path);
360 char path[] = "/b/c";
363 r = guestfs_touch (g, path);
368 char directory[] = "/";
372 r = guestfs_find (g, directory);
376 fprintf (stderr, "test_find_1: short list returned from command\n");
381 char expected[] = "a";
382 if (strcmp (r[0], expected) != 0) {
383 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
388 fprintf (stderr, "test_find_1: short list returned from command\n");
393 char expected[] = "b";
394 if (strcmp (r[1], expected) != 0) {
395 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
400 fprintf (stderr, "test_find_1: short list returned from command\n");
405 char expected[] = "b/c";
406 if (strcmp (r[2], expected) != 0) {
407 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
412 fprintf (stderr, "test_find_1: short list returned from command\n");
417 char expected[] = "lost+found";
418 if (strcmp (r[3], expected) != 0) {
419 fprintf (stderr, "test_find_1: expected \"%s\" but got \"%s\"\n", expected, r[3]);
424 fprintf (stderr, "test_find_1: extra elements returned from command\n");
428 for (i = 0; r[i] != NULL; ++i)
435 static int test_find_2_skip (void)
439 str = getenv ("SKIP_TEST_FIND_2");
440 if (str && strcmp (str, "1") == 0) return 1;
441 str = getenv ("SKIP_TEST_FIND");
442 if (str && strcmp (str, "1") == 0) return 1;
446 static int test_find_2 (void)
448 if (test_find_2_skip ()) {
449 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_find_2");
453 /* InitBasicFS for test_find_2: create ext2 on /dev/sda1 */
455 char device[] = "/dev/sda";
459 r = guestfs_blockdev_setrw (g, device);
466 r = guestfs_umount_all (g);
473 r = guestfs_lvm_remove_all (g);
478 char device[] = "/dev/sda";
480 char lines_0[] = ",";
487 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
492 char fstype[] = "ext2";
493 char device[] = "/dev/sda1";
497 r = guestfs_mkfs (g, fstype, device);
502 char device[] = "/dev/sda1";
504 char mountpoint[] = "/";
507 r = guestfs_mount (g, device, mountpoint);
511 /* TestOutputList for find (2) */
513 char path[] = "/a/b/c";
516 r = guestfs_mkdir_p (g, path);
521 char path[] = "/a/b/c/d";
524 r = guestfs_touch (g, path);
529 char directory[] = "/a/b/";
533 r = guestfs_find (g, directory);
537 fprintf (stderr, "test_find_2: short list returned from command\n");
542 char expected[] = "c";
543 if (strcmp (r[0], expected) != 0) {
544 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
549 fprintf (stderr, "test_find_2: short list returned from command\n");
554 char expected[] = "c/d";
555 if (strcmp (r[1], expected) != 0) {
556 fprintf (stderr, "test_find_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
561 fprintf (stderr, "test_find_2: extra elements returned from command\n");
565 for (i = 0; r[i] != NULL; ++i)
572 static int test_lvresize_0_skip (void)
576 str = getenv ("SKIP_TEST_LVRESIZE_0");
577 if (str && strcmp (str, "1") == 0) return 1;
578 str = getenv ("SKIP_TEST_LVRESIZE");
579 if (str && strcmp (str, "1") == 0) return 1;
583 static int test_lvresize_0 (void)
585 if (test_lvresize_0_skip ()) {
586 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvresize_0");
590 /* InitNone|InitEmpty for test_lvresize_0 */
592 char device[] = "/dev/sda";
596 r = guestfs_blockdev_setrw (g, device);
603 r = guestfs_umount_all (g);
610 r = guestfs_lvm_remove_all (g);
614 /* TestOutput for lvresize (0) */
615 char expected[] = "test content";
617 char device[] = "/dev/sda";
619 char lines_0[] = ",";
626 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
631 char device[] = "/dev/sda1";
635 r = guestfs_pvcreate (g, device);
640 char volgroup[] = "VG";
641 char physvols_0[] = "/dev/sda1";
642 physvols_0[5] = devchar;
649 r = guestfs_vgcreate (g, volgroup, physvols);
654 char logvol[] = "LV";
655 char volgroup[] = "VG";
658 r = guestfs_lvcreate (g, logvol, volgroup, 10);
663 char fstype[] = "ext2";
664 char device[] = "/dev/VG/LV";
667 r = guestfs_mkfs (g, fstype, device);
672 char device[] = "/dev/VG/LV";
673 char mountpoint[] = "/";
676 r = guestfs_mount (g, device, mountpoint);
681 char path[] = "/new";
682 char content[] = "test content";
685 r = guestfs_write_file (g, path, content, 0);
690 char pathordevice[] = "/";
693 r = guestfs_umount (g, pathordevice);
698 char device[] = "/dev/VG/LV";
701 r = guestfs_lvresize (g, device, 20);
706 char device[] = "/dev/VG/LV";
709 r = guestfs_e2fsck_f (g, device);
714 char device[] = "/dev/VG/LV";
717 r = guestfs_resize2fs (g, device);
722 char device[] = "/dev/VG/LV";
723 char mountpoint[] = "/";
726 r = guestfs_mount (g, device, mountpoint);
731 char path[] = "/new";
734 r = guestfs_cat (g, path);
737 if (strcmp (r, expected) != 0) {
738 fprintf (stderr, "test_lvresize_0: expected \"%s\" but got \"%s\"\n", expected, r);
746 static int test_zerofree_0_skip (void)
750 str = getenv ("SKIP_TEST_ZEROFREE_0");
751 if (str && strcmp (str, "1") == 0) return 1;
752 str = getenv ("SKIP_TEST_ZEROFREE");
753 if (str && strcmp (str, "1") == 0) return 1;
757 static int test_zerofree_0 (void)
759 if (test_zerofree_0_skip ()) {
760 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zerofree_0");
764 /* InitNone|InitEmpty for test_zerofree_0 */
766 char device[] = "/dev/sda";
770 r = guestfs_blockdev_setrw (g, device);
777 r = guestfs_umount_all (g);
784 r = guestfs_lvm_remove_all (g);
788 /* TestOutput for zerofree (0) */
789 char expected[] = "test file";
791 char device[] = "/dev/sda";
793 char lines_0[] = ",";
800 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
805 char fstype[] = "ext3";
806 char device[] = "/dev/sda1";
810 r = guestfs_mkfs (g, fstype, device);
815 char device[] = "/dev/sda1";
817 char mountpoint[] = "/";
820 r = guestfs_mount (g, device, mountpoint);
825 char path[] = "/new";
826 char content[] = "test file";
829 r = guestfs_write_file (g, path, content, 0);
834 char pathordevice[] = "/dev/sda1";
835 pathordevice[5] = devchar;
838 r = guestfs_umount (g, pathordevice);
843 char device[] = "/dev/sda1";
847 r = guestfs_zerofree (g, device);
852 char device[] = "/dev/sda1";
854 char mountpoint[] = "/";
857 r = guestfs_mount (g, device, mountpoint);
862 char path[] = "/new";
865 r = guestfs_cat (g, path);
868 if (strcmp (r, expected) != 0) {
869 fprintf (stderr, "test_zerofree_0: expected \"%s\" but got \"%s\"\n", expected, r);
877 static int test_hexdump_0_skip (void)
881 str = getenv ("SKIP_TEST_HEXDUMP_0");
882 if (str && strcmp (str, "1") == 0) return 1;
883 str = getenv ("SKIP_TEST_HEXDUMP");
884 if (str && strcmp (str, "1") == 0) return 1;
888 static int test_hexdump_0 (void)
890 if (test_hexdump_0_skip ()) {
891 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_hexdump_0");
895 /* InitBasicFS for test_hexdump_0: create ext2 on /dev/sda1 */
897 char device[] = "/dev/sda";
901 r = guestfs_blockdev_setrw (g, device);
908 r = guestfs_umount_all (g);
915 r = guestfs_lvm_remove_all (g);
920 char device[] = "/dev/sda";
922 char lines_0[] = ",";
929 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
934 char fstype[] = "ext2";
935 char device[] = "/dev/sda1";
939 r = guestfs_mkfs (g, fstype, device);
944 char device[] = "/dev/sda1";
946 char mountpoint[] = "/";
949 r = guestfs_mount (g, device, mountpoint);
953 /* TestOutput for hexdump (0) */
954 char expected[] = "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n";
956 char path[] = "/new";
957 char content[] = "hello\nworld\n";
960 r = guestfs_write_file (g, path, content, 12);
965 char path[] = "/new";
968 r = guestfs_hexdump (g, path);
971 if (strcmp (r, expected) != 0) {
972 fprintf (stderr, "test_hexdump_0: expected \"%s\" but got \"%s\"\n", expected, r);
980 static int test_strings_e_0_skip (void)
984 str = getenv ("SKIP_TEST_STRINGS_E_0");
985 if (str && strcmp (str, "1") == 0) return 1;
986 str = getenv ("SKIP_TEST_STRINGS_E");
987 if (str && strcmp (str, "1") == 0) return 1;
991 static int test_strings_e_0 (void)
993 if (test_strings_e_0_skip ()) {
994 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_0");
998 /* InitBasicFS for test_strings_e_0: create ext2 on /dev/sda1 */
1000 char device[] = "/dev/sda";
1001 device[5] = devchar;
1004 r = guestfs_blockdev_setrw (g, device);
1011 r = guestfs_umount_all (g);
1018 r = guestfs_lvm_remove_all (g);
1023 char device[] = "/dev/sda";
1024 device[5] = devchar;
1025 char lines_0[] = ",";
1032 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1037 char fstype[] = "ext2";
1038 char device[] = "/dev/sda1";
1039 device[5] = devchar;
1042 r = guestfs_mkfs (g, fstype, device);
1047 char device[] = "/dev/sda1";
1048 device[5] = devchar;
1049 char mountpoint[] = "/";
1052 r = guestfs_mount (g, device, mountpoint);
1056 /* TestOutputList for strings_e (0) */
1058 char path[] = "/new";
1059 char content[] = "hello\nworld\n";
1062 r = guestfs_write_file (g, path, content, 0);
1067 char encoding[] = "b";
1068 char path[] = "/new";
1072 r = guestfs_strings_e (g, encoding, path);
1076 fprintf (stderr, "test_strings_e_0: extra elements returned from command\n");
1080 for (i = 0; r[i] != NULL; ++i)
1087 static int test_strings_e_1_skip (void)
1091 str = getenv ("SKIP_TEST_STRINGS_E_1");
1092 if (str && strcmp (str, "1") == 0) return 1;
1093 str = getenv ("SKIP_TEST_STRINGS_E");
1094 if (str && strcmp (str, "1") == 0) return 1;
1098 static int test_strings_e_1 (void)
1100 if (test_strings_e_1_skip ()) {
1101 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_e_1");
1105 printf ("%s skipped (reason: test disabled in generator)\n", "test_strings_e_1");
1109 static int test_strings_0_skip (void)
1113 str = getenv ("SKIP_TEST_STRINGS_0");
1114 if (str && strcmp (str, "1") == 0) return 1;
1115 str = getenv ("SKIP_TEST_STRINGS");
1116 if (str && strcmp (str, "1") == 0) return 1;
1120 static int test_strings_0 (void)
1122 if (test_strings_0_skip ()) {
1123 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_0");
1127 /* InitBasicFS for test_strings_0: create ext2 on /dev/sda1 */
1129 char device[] = "/dev/sda";
1130 device[5] = devchar;
1133 r = guestfs_blockdev_setrw (g, device);
1140 r = guestfs_umount_all (g);
1147 r = guestfs_lvm_remove_all (g);
1152 char device[] = "/dev/sda";
1153 device[5] = devchar;
1154 char lines_0[] = ",";
1161 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1166 char fstype[] = "ext2";
1167 char device[] = "/dev/sda1";
1168 device[5] = devchar;
1171 r = guestfs_mkfs (g, fstype, device);
1176 char device[] = "/dev/sda1";
1177 device[5] = devchar;
1178 char mountpoint[] = "/";
1181 r = guestfs_mount (g, device, mountpoint);
1185 /* TestOutputList for strings (0) */
1187 char path[] = "/new";
1188 char content[] = "hello\nworld\n";
1191 r = guestfs_write_file (g, path, content, 0);
1196 char path[] = "/new";
1200 r = guestfs_strings (g, path);
1204 fprintf (stderr, "test_strings_0: short list returned from command\n");
1209 char expected[] = "hello";
1210 if (strcmp (r[0], expected) != 0) {
1211 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
1216 fprintf (stderr, "test_strings_0: short list returned from command\n");
1221 char expected[] = "world";
1222 if (strcmp (r[1], expected) != 0) {
1223 fprintf (stderr, "test_strings_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
1228 fprintf (stderr, "test_strings_0: extra elements returned from command\n");
1232 for (i = 0; r[i] != NULL; ++i)
1239 static int test_strings_1_skip (void)
1243 str = getenv ("SKIP_TEST_STRINGS_1");
1244 if (str && strcmp (str, "1") == 0) return 1;
1245 str = getenv ("SKIP_TEST_STRINGS");
1246 if (str && strcmp (str, "1") == 0) return 1;
1250 static int test_strings_1 (void)
1252 if (test_strings_1_skip ()) {
1253 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_strings_1");
1257 /* InitBasicFS for test_strings_1: create ext2 on /dev/sda1 */
1259 char device[] = "/dev/sda";
1260 device[5] = devchar;
1263 r = guestfs_blockdev_setrw (g, device);
1270 r = guestfs_umount_all (g);
1277 r = guestfs_lvm_remove_all (g);
1282 char device[] = "/dev/sda";
1283 device[5] = devchar;
1284 char lines_0[] = ",";
1291 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1296 char fstype[] = "ext2";
1297 char device[] = "/dev/sda1";
1298 device[5] = devchar;
1301 r = guestfs_mkfs (g, fstype, device);
1306 char device[] = "/dev/sda1";
1307 device[5] = devchar;
1308 char mountpoint[] = "/";
1311 r = guestfs_mount (g, device, mountpoint);
1315 /* TestOutputList for strings (1) */
1317 char path[] = "/new";
1320 r = guestfs_touch (g, path);
1325 char path[] = "/new";
1329 r = guestfs_strings (g, path);
1333 fprintf (stderr, "test_strings_1: extra elements returned from command\n");
1337 for (i = 0; r[i] != NULL; ++i)
1344 static int test_equal_0_skip (void)
1348 str = getenv ("SKIP_TEST_EQUAL_0");
1349 if (str && strcmp (str, "1") == 0) return 1;
1350 str = getenv ("SKIP_TEST_EQUAL");
1351 if (str && strcmp (str, "1") == 0) return 1;
1355 static int test_equal_0 (void)
1357 if (test_equal_0_skip ()) {
1358 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_0");
1362 /* InitBasicFS for test_equal_0: create ext2 on /dev/sda1 */
1364 char device[] = "/dev/sda";
1365 device[5] = devchar;
1368 r = guestfs_blockdev_setrw (g, device);
1375 r = guestfs_umount_all (g);
1382 r = guestfs_lvm_remove_all (g);
1387 char device[] = "/dev/sda";
1388 device[5] = devchar;
1389 char lines_0[] = ",";
1396 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1401 char fstype[] = "ext2";
1402 char device[] = "/dev/sda1";
1403 device[5] = devchar;
1406 r = guestfs_mkfs (g, fstype, device);
1411 char device[] = "/dev/sda1";
1412 device[5] = devchar;
1413 char mountpoint[] = "/";
1416 r = guestfs_mount (g, device, mountpoint);
1420 /* TestOutputTrue for equal (0) */
1422 char path[] = "/file1";
1423 char content[] = "contents of a file";
1426 r = guestfs_write_file (g, path, content, 0);
1431 char src[] = "/file1";
1432 char dest[] = "/file2";
1435 r = guestfs_cp (g, src, dest);
1440 char file1[] = "/file1";
1441 char file2[] = "/file2";
1444 r = guestfs_equal (g, file1, file2);
1448 fprintf (stderr, "test_equal_0: expected true, got false\n");
1455 static int test_equal_1_skip (void)
1459 str = getenv ("SKIP_TEST_EQUAL_1");
1460 if (str && strcmp (str, "1") == 0) return 1;
1461 str = getenv ("SKIP_TEST_EQUAL");
1462 if (str && strcmp (str, "1") == 0) return 1;
1466 static int test_equal_1 (void)
1468 if (test_equal_1_skip ()) {
1469 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_1");
1473 /* InitBasicFS for test_equal_1: create ext2 on /dev/sda1 */
1475 char device[] = "/dev/sda";
1476 device[5] = devchar;
1479 r = guestfs_blockdev_setrw (g, device);
1486 r = guestfs_umount_all (g);
1493 r = guestfs_lvm_remove_all (g);
1498 char device[] = "/dev/sda";
1499 device[5] = devchar;
1500 char lines_0[] = ",";
1507 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1512 char fstype[] = "ext2";
1513 char device[] = "/dev/sda1";
1514 device[5] = devchar;
1517 r = guestfs_mkfs (g, fstype, device);
1522 char device[] = "/dev/sda1";
1523 device[5] = devchar;
1524 char mountpoint[] = "/";
1527 r = guestfs_mount (g, device, mountpoint);
1531 /* TestOutputFalse for equal (1) */
1533 char path[] = "/file1";
1534 char content[] = "contents of a file";
1537 r = guestfs_write_file (g, path, content, 0);
1542 char path[] = "/file2";
1543 char content[] = "contents of another file";
1546 r = guestfs_write_file (g, path, content, 0);
1551 char file1[] = "/file1";
1552 char file2[] = "/file2";
1555 r = guestfs_equal (g, file1, file2);
1559 fprintf (stderr, "test_equal_1: expected false, got true\n");
1566 static int test_equal_2_skip (void)
1570 str = getenv ("SKIP_TEST_EQUAL_2");
1571 if (str && strcmp (str, "1") == 0) return 1;
1572 str = getenv ("SKIP_TEST_EQUAL");
1573 if (str && strcmp (str, "1") == 0) return 1;
1577 static int test_equal_2 (void)
1579 if (test_equal_2_skip ()) {
1580 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_equal_2");
1584 /* InitBasicFS for test_equal_2: create ext2 on /dev/sda1 */
1586 char device[] = "/dev/sda";
1587 device[5] = devchar;
1590 r = guestfs_blockdev_setrw (g, device);
1597 r = guestfs_umount_all (g);
1604 r = guestfs_lvm_remove_all (g);
1609 char device[] = "/dev/sda";
1610 device[5] = devchar;
1611 char lines_0[] = ",";
1618 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1623 char fstype[] = "ext2";
1624 char device[] = "/dev/sda1";
1625 device[5] = devchar;
1628 r = guestfs_mkfs (g, fstype, device);
1633 char device[] = "/dev/sda1";
1634 device[5] = devchar;
1635 char mountpoint[] = "/";
1638 r = guestfs_mount (g, device, mountpoint);
1642 /* TestLastFail for equal (2) */
1644 char file1[] = "/file1";
1645 char file2[] = "/file2";
1648 r = guestfs_equal (g, file1, file2);
1655 static int test_ping_daemon_0_skip (void)
1659 str = getenv ("SKIP_TEST_PING_DAEMON_0");
1660 if (str && strcmp (str, "1") == 0) return 1;
1661 str = getenv ("SKIP_TEST_PING_DAEMON");
1662 if (str && strcmp (str, "1") == 0) return 1;
1666 static int test_ping_daemon_0 (void)
1668 if (test_ping_daemon_0_skip ()) {
1669 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ping_daemon_0");
1673 /* InitNone|InitEmpty for test_ping_daemon_0 */
1675 char device[] = "/dev/sda";
1676 device[5] = devchar;
1679 r = guestfs_blockdev_setrw (g, device);
1686 r = guestfs_umount_all (g);
1693 r = guestfs_lvm_remove_all (g);
1697 /* TestRun for ping_daemon (0) */
1701 r = guestfs_ping_daemon (g);
1708 static int test_dmesg_0_skip (void)
1712 str = getenv ("SKIP_TEST_DMESG_0");
1713 if (str && strcmp (str, "1") == 0) return 1;
1714 str = getenv ("SKIP_TEST_DMESG");
1715 if (str && strcmp (str, "1") == 0) return 1;
1719 static int test_dmesg_0 (void)
1721 if (test_dmesg_0_skip ()) {
1722 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_dmesg_0");
1726 /* InitNone|InitEmpty for test_dmesg_0 */
1728 char device[] = "/dev/sda";
1729 device[5] = devchar;
1732 r = guestfs_blockdev_setrw (g, device);
1739 r = guestfs_umount_all (g);
1746 r = guestfs_lvm_remove_all (g);
1750 /* TestRun for dmesg (0) */
1754 r = guestfs_dmesg (g);
1762 static int test_drop_caches_0_skip (void)
1766 str = getenv ("SKIP_TEST_DROP_CACHES_0");
1767 if (str && strcmp (str, "1") == 0) return 1;
1768 str = getenv ("SKIP_TEST_DROP_CACHES");
1769 if (str && strcmp (str, "1") == 0) return 1;
1773 static int test_drop_caches_0 (void)
1775 if (test_drop_caches_0_skip ()) {
1776 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_drop_caches_0");
1780 /* InitNone|InitEmpty for test_drop_caches_0 */
1782 char device[] = "/dev/sda";
1783 device[5] = devchar;
1786 r = guestfs_blockdev_setrw (g, device);
1793 r = guestfs_umount_all (g);
1800 r = guestfs_lvm_remove_all (g);
1804 /* TestRun for drop_caches (0) */
1808 r = guestfs_drop_caches (g, 3);
1815 static int test_mv_0_skip (void)
1819 str = getenv ("SKIP_TEST_MV_0");
1820 if (str && strcmp (str, "1") == 0) return 1;
1821 str = getenv ("SKIP_TEST_MV");
1822 if (str && strcmp (str, "1") == 0) return 1;
1826 static int test_mv_0 (void)
1828 if (test_mv_0_skip ()) {
1829 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_0");
1833 /* InitBasicFS for test_mv_0: create ext2 on /dev/sda1 */
1835 char device[] = "/dev/sda";
1836 device[5] = devchar;
1839 r = guestfs_blockdev_setrw (g, device);
1846 r = guestfs_umount_all (g);
1853 r = guestfs_lvm_remove_all (g);
1858 char device[] = "/dev/sda";
1859 device[5] = devchar;
1860 char lines_0[] = ",";
1867 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1872 char fstype[] = "ext2";
1873 char device[] = "/dev/sda1";
1874 device[5] = devchar;
1877 r = guestfs_mkfs (g, fstype, device);
1882 char device[] = "/dev/sda1";
1883 device[5] = devchar;
1884 char mountpoint[] = "/";
1887 r = guestfs_mount (g, device, mountpoint);
1891 /* TestOutput for mv (0) */
1892 char expected[] = "file content";
1894 char path[] = "/old";
1895 char content[] = "file content";
1898 r = guestfs_write_file (g, path, content, 0);
1903 char src[] = "/old";
1904 char dest[] = "/new";
1907 r = guestfs_mv (g, src, dest);
1912 char path[] = "/new";
1915 r = guestfs_cat (g, path);
1918 if (strcmp (r, expected) != 0) {
1919 fprintf (stderr, "test_mv_0: expected \"%s\" but got \"%s\"\n", expected, r);
1927 static int test_mv_1_skip (void)
1931 str = getenv ("SKIP_TEST_MV_1");
1932 if (str && strcmp (str, "1") == 0) return 1;
1933 str = getenv ("SKIP_TEST_MV");
1934 if (str && strcmp (str, "1") == 0) return 1;
1938 static int test_mv_1 (void)
1940 if (test_mv_1_skip ()) {
1941 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mv_1");
1945 /* InitBasicFS for test_mv_1: create ext2 on /dev/sda1 */
1947 char device[] = "/dev/sda";
1948 device[5] = devchar;
1951 r = guestfs_blockdev_setrw (g, device);
1958 r = guestfs_umount_all (g);
1965 r = guestfs_lvm_remove_all (g);
1970 char device[] = "/dev/sda";
1971 device[5] = devchar;
1972 char lines_0[] = ",";
1979 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
1984 char fstype[] = "ext2";
1985 char device[] = "/dev/sda1";
1986 device[5] = devchar;
1989 r = guestfs_mkfs (g, fstype, device);
1994 char device[] = "/dev/sda1";
1995 device[5] = devchar;
1996 char mountpoint[] = "/";
1999 r = guestfs_mount (g, device, mountpoint);
2003 /* TestOutputFalse for mv (1) */
2005 char path[] = "/old";
2006 char content[] = "file content";
2009 r = guestfs_write_file (g, path, content, 0);
2014 char src[] = "/old";
2015 char dest[] = "/new";
2018 r = guestfs_mv (g, src, dest);
2023 char path[] = "/old";
2026 r = guestfs_is_file (g, path);
2030 fprintf (stderr, "test_mv_1: expected false, got true\n");
2037 static int test_cp_a_0_skip (void)
2041 str = getenv ("SKIP_TEST_CP_A_0");
2042 if (str && strcmp (str, "1") == 0) return 1;
2043 str = getenv ("SKIP_TEST_CP_A");
2044 if (str && strcmp (str, "1") == 0) return 1;
2048 static int test_cp_a_0 (void)
2050 if (test_cp_a_0_skip ()) {
2051 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_a_0");
2055 /* InitBasicFS for test_cp_a_0: create ext2 on /dev/sda1 */
2057 char device[] = "/dev/sda";
2058 device[5] = devchar;
2061 r = guestfs_blockdev_setrw (g, device);
2068 r = guestfs_umount_all (g);
2075 r = guestfs_lvm_remove_all (g);
2080 char device[] = "/dev/sda";
2081 device[5] = devchar;
2082 char lines_0[] = ",";
2089 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2094 char fstype[] = "ext2";
2095 char device[] = "/dev/sda1";
2096 device[5] = devchar;
2099 r = guestfs_mkfs (g, fstype, device);
2104 char device[] = "/dev/sda1";
2105 device[5] = devchar;
2106 char mountpoint[] = "/";
2109 r = guestfs_mount (g, device, mountpoint);
2113 /* TestOutput for cp_a (0) */
2114 char expected[] = "file content";
2116 char path[] = "/olddir";
2119 r = guestfs_mkdir (g, path);
2124 char path[] = "/newdir";
2127 r = guestfs_mkdir (g, path);
2132 char path[] = "/olddir/file";
2133 char content[] = "file content";
2136 r = guestfs_write_file (g, path, content, 0);
2141 char src[] = "/olddir";
2142 char dest[] = "/newdir";
2145 r = guestfs_cp_a (g, src, dest);
2150 char path[] = "/newdir/olddir/file";
2153 r = guestfs_cat (g, path);
2156 if (strcmp (r, expected) != 0) {
2157 fprintf (stderr, "test_cp_a_0: expected \"%s\" but got \"%s\"\n", expected, r);
2165 static int test_cp_0_skip (void)
2169 str = getenv ("SKIP_TEST_CP_0");
2170 if (str && strcmp (str, "1") == 0) return 1;
2171 str = getenv ("SKIP_TEST_CP");
2172 if (str && strcmp (str, "1") == 0) return 1;
2176 static int test_cp_0 (void)
2178 if (test_cp_0_skip ()) {
2179 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_0");
2183 /* InitBasicFS for test_cp_0: create ext2 on /dev/sda1 */
2185 char device[] = "/dev/sda";
2186 device[5] = devchar;
2189 r = guestfs_blockdev_setrw (g, device);
2196 r = guestfs_umount_all (g);
2203 r = guestfs_lvm_remove_all (g);
2208 char device[] = "/dev/sda";
2209 device[5] = devchar;
2210 char lines_0[] = ",";
2217 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2222 char fstype[] = "ext2";
2223 char device[] = "/dev/sda1";
2224 device[5] = devchar;
2227 r = guestfs_mkfs (g, fstype, device);
2232 char device[] = "/dev/sda1";
2233 device[5] = devchar;
2234 char mountpoint[] = "/";
2237 r = guestfs_mount (g, device, mountpoint);
2241 /* TestOutput for cp (0) */
2242 char expected[] = "file content";
2244 char path[] = "/old";
2245 char content[] = "file content";
2248 r = guestfs_write_file (g, path, content, 0);
2253 char src[] = "/old";
2254 char dest[] = "/new";
2257 r = guestfs_cp (g, src, dest);
2262 char path[] = "/new";
2265 r = guestfs_cat (g, path);
2268 if (strcmp (r, expected) != 0) {
2269 fprintf (stderr, "test_cp_0: expected \"%s\" but got \"%s\"\n", expected, r);
2277 static int test_cp_1_skip (void)
2281 str = getenv ("SKIP_TEST_CP_1");
2282 if (str && strcmp (str, "1") == 0) return 1;
2283 str = getenv ("SKIP_TEST_CP");
2284 if (str && strcmp (str, "1") == 0) return 1;
2288 static int test_cp_1 (void)
2290 if (test_cp_1_skip ()) {
2291 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_1");
2295 /* InitBasicFS for test_cp_1: create ext2 on /dev/sda1 */
2297 char device[] = "/dev/sda";
2298 device[5] = devchar;
2301 r = guestfs_blockdev_setrw (g, device);
2308 r = guestfs_umount_all (g);
2315 r = guestfs_lvm_remove_all (g);
2320 char device[] = "/dev/sda";
2321 device[5] = devchar;
2322 char lines_0[] = ",";
2329 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2334 char fstype[] = "ext2";
2335 char device[] = "/dev/sda1";
2336 device[5] = devchar;
2339 r = guestfs_mkfs (g, fstype, device);
2344 char device[] = "/dev/sda1";
2345 device[5] = devchar;
2346 char mountpoint[] = "/";
2349 r = guestfs_mount (g, device, mountpoint);
2353 /* TestOutputTrue for cp (1) */
2355 char path[] = "/old";
2356 char content[] = "file content";
2359 r = guestfs_write_file (g, path, content, 0);
2364 char src[] = "/old";
2365 char dest[] = "/new";
2368 r = guestfs_cp (g, src, dest);
2373 char path[] = "/old";
2376 r = guestfs_is_file (g, path);
2380 fprintf (stderr, "test_cp_1: expected true, got false\n");
2387 static int test_cp_2_skip (void)
2391 str = getenv ("SKIP_TEST_CP_2");
2392 if (str && strcmp (str, "1") == 0) return 1;
2393 str = getenv ("SKIP_TEST_CP");
2394 if (str && strcmp (str, "1") == 0) return 1;
2398 static int test_cp_2 (void)
2400 if (test_cp_2_skip ()) {
2401 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cp_2");
2405 /* InitBasicFS for test_cp_2: create ext2 on /dev/sda1 */
2407 char device[] = "/dev/sda";
2408 device[5] = devchar;
2411 r = guestfs_blockdev_setrw (g, device);
2418 r = guestfs_umount_all (g);
2425 r = guestfs_lvm_remove_all (g);
2430 char device[] = "/dev/sda";
2431 device[5] = devchar;
2432 char lines_0[] = ",";
2439 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2444 char fstype[] = "ext2";
2445 char device[] = "/dev/sda1";
2446 device[5] = devchar;
2449 r = guestfs_mkfs (g, fstype, device);
2454 char device[] = "/dev/sda1";
2455 device[5] = devchar;
2456 char mountpoint[] = "/";
2459 r = guestfs_mount (g, device, mountpoint);
2463 /* TestOutput for cp (2) */
2464 char expected[] = "file content";
2466 char path[] = "/old";
2467 char content[] = "file content";
2470 r = guestfs_write_file (g, path, content, 0);
2475 char path[] = "/dir";
2478 r = guestfs_mkdir (g, path);
2483 char src[] = "/old";
2484 char dest[] = "/dir/new";
2487 r = guestfs_cp (g, src, dest);
2492 char path[] = "/dir/new";
2495 r = guestfs_cat (g, path);
2498 if (strcmp (r, expected) != 0) {
2499 fprintf (stderr, "test_cp_2: expected \"%s\" but got \"%s\"\n", expected, r);
2507 static int test_grub_install_0_skip (void)
2511 str = getenv ("SKIP_TEST_GRUB_INSTALL_0");
2512 if (str && strcmp (str, "1") == 0) return 1;
2513 str = getenv ("SKIP_TEST_GRUB_INSTALL");
2514 if (str && strcmp (str, "1") == 0) return 1;
2518 static int test_grub_install_0 (void)
2520 if (test_grub_install_0_skip ()) {
2521 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_grub_install_0");
2525 /* InitBasicFS for test_grub_install_0: create ext2 on /dev/sda1 */
2527 char device[] = "/dev/sda";
2528 device[5] = devchar;
2531 r = guestfs_blockdev_setrw (g, device);
2538 r = guestfs_umount_all (g);
2545 r = guestfs_lvm_remove_all (g);
2550 char device[] = "/dev/sda";
2551 device[5] = devchar;
2552 char lines_0[] = ",";
2559 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2564 char fstype[] = "ext2";
2565 char device[] = "/dev/sda1";
2566 device[5] = devchar;
2569 r = guestfs_mkfs (g, fstype, device);
2574 char device[] = "/dev/sda1";
2575 device[5] = devchar;
2576 char mountpoint[] = "/";
2579 r = guestfs_mount (g, device, mountpoint);
2583 /* TestOutputTrue for grub_install (0) */
2586 char device[] = "/dev/sda1";
2587 device[5] = devchar;
2590 r = guestfs_grub_install (g, root, device);
2595 char path[] = "/boot";
2598 r = guestfs_is_dir (g, path);
2602 fprintf (stderr, "test_grub_install_0: expected true, got false\n");
2609 static int test_zero_0_skip (void)
2613 str = getenv ("SKIP_TEST_ZERO_0");
2614 if (str && strcmp (str, "1") == 0) return 1;
2615 str = getenv ("SKIP_TEST_ZERO");
2616 if (str && strcmp (str, "1") == 0) return 1;
2620 static int test_zero_0 (void)
2622 if (test_zero_0_skip ()) {
2623 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_zero_0");
2627 /* InitBasicFS for test_zero_0: create ext2 on /dev/sda1 */
2629 char device[] = "/dev/sda";
2630 device[5] = devchar;
2633 r = guestfs_blockdev_setrw (g, device);
2640 r = guestfs_umount_all (g);
2647 r = guestfs_lvm_remove_all (g);
2652 char device[] = "/dev/sda";
2653 device[5] = devchar;
2654 char lines_0[] = ",";
2661 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2666 char fstype[] = "ext2";
2667 char device[] = "/dev/sda1";
2668 device[5] = devchar;
2671 r = guestfs_mkfs (g, fstype, device);
2676 char device[] = "/dev/sda1";
2677 device[5] = devchar;
2678 char mountpoint[] = "/";
2681 r = guestfs_mount (g, device, mountpoint);
2685 /* TestOutput for zero (0) */
2686 char expected[] = "data";
2688 char pathordevice[] = "/dev/sda1";
2689 pathordevice[5] = devchar;
2692 r = guestfs_umount (g, pathordevice);
2697 char device[] = "/dev/sda1";
2698 device[5] = devchar;
2701 r = guestfs_zero (g, device);
2706 char path[] = "/dev/sda1";
2710 r = guestfs_file (g, path);
2713 if (strcmp (r, expected) != 0) {
2714 fprintf (stderr, "test_zero_0: expected \"%s\" but got \"%s\"\n", expected, r);
2722 static int test_fsck_0_skip (void)
2726 str = getenv ("SKIP_TEST_FSCK_0");
2727 if (str && strcmp (str, "1") == 0) return 1;
2728 str = getenv ("SKIP_TEST_FSCK");
2729 if (str && strcmp (str, "1") == 0) return 1;
2733 static int test_fsck_0 (void)
2735 if (test_fsck_0_skip ()) {
2736 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_0");
2740 /* InitBasicFS for test_fsck_0: create ext2 on /dev/sda1 */
2742 char device[] = "/dev/sda";
2743 device[5] = devchar;
2746 r = guestfs_blockdev_setrw (g, device);
2753 r = guestfs_umount_all (g);
2760 r = guestfs_lvm_remove_all (g);
2765 char device[] = "/dev/sda";
2766 device[5] = devchar;
2767 char lines_0[] = ",";
2774 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2779 char fstype[] = "ext2";
2780 char device[] = "/dev/sda1";
2781 device[5] = devchar;
2784 r = guestfs_mkfs (g, fstype, device);
2789 char device[] = "/dev/sda1";
2790 device[5] = devchar;
2791 char mountpoint[] = "/";
2794 r = guestfs_mount (g, device, mountpoint);
2798 /* TestOutputInt for fsck (0) */
2800 char pathordevice[] = "/dev/sda1";
2801 pathordevice[5] = devchar;
2804 r = guestfs_umount (g, pathordevice);
2809 char fstype[] = "ext2";
2810 char device[] = "/dev/sda1";
2811 device[5] = devchar;
2814 r = guestfs_fsck (g, fstype, device);
2818 fprintf (stderr, "test_fsck_0: expected 0 but got %d\n", (int) r);
2825 static int test_fsck_1_skip (void)
2829 str = getenv ("SKIP_TEST_FSCK_1");
2830 if (str && strcmp (str, "1") == 0) return 1;
2831 str = getenv ("SKIP_TEST_FSCK");
2832 if (str && strcmp (str, "1") == 0) return 1;
2836 static int test_fsck_1 (void)
2838 if (test_fsck_1_skip ()) {
2839 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_fsck_1");
2843 /* InitBasicFS for test_fsck_1: create ext2 on /dev/sda1 */
2845 char device[] = "/dev/sda";
2846 device[5] = devchar;
2849 r = guestfs_blockdev_setrw (g, device);
2856 r = guestfs_umount_all (g);
2863 r = guestfs_lvm_remove_all (g);
2868 char device[] = "/dev/sda";
2869 device[5] = devchar;
2870 char lines_0[] = ",";
2877 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2882 char fstype[] = "ext2";
2883 char device[] = "/dev/sda1";
2884 device[5] = devchar;
2887 r = guestfs_mkfs (g, fstype, device);
2892 char device[] = "/dev/sda1";
2893 device[5] = devchar;
2894 char mountpoint[] = "/";
2897 r = guestfs_mount (g, device, mountpoint);
2901 /* TestOutputInt for fsck (1) */
2903 char pathordevice[] = "/dev/sda1";
2904 pathordevice[5] = devchar;
2907 r = guestfs_umount (g, pathordevice);
2912 char device[] = "/dev/sda1";
2913 device[5] = devchar;
2916 r = guestfs_zero (g, device);
2921 char fstype[] = "ext2";
2922 char device[] = "/dev/sda1";
2923 device[5] = devchar;
2926 r = guestfs_fsck (g, fstype, device);
2930 fprintf (stderr, "test_fsck_1: expected 8 but got %d\n", (int) r);
2937 static int test_set_e2uuid_0_skip (void)
2941 str = getenv ("SKIP_TEST_SET_E2UUID_0");
2942 if (str && strcmp (str, "1") == 0) return 1;
2943 str = getenv ("SKIP_TEST_SET_E2UUID");
2944 if (str && strcmp (str, "1") == 0) return 1;
2948 static int test_set_e2uuid_0 (void)
2950 if (test_set_e2uuid_0_skip ()) {
2951 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_0");
2955 /* InitBasicFS for test_set_e2uuid_0: create ext2 on /dev/sda1 */
2957 char device[] = "/dev/sda";
2958 device[5] = devchar;
2961 r = guestfs_blockdev_setrw (g, device);
2968 r = guestfs_umount_all (g);
2975 r = guestfs_lvm_remove_all (g);
2980 char device[] = "/dev/sda";
2981 device[5] = devchar;
2982 char lines_0[] = ",";
2989 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
2994 char fstype[] = "ext2";
2995 char device[] = "/dev/sda1";
2996 device[5] = devchar;
2999 r = guestfs_mkfs (g, fstype, device);
3004 char device[] = "/dev/sda1";
3005 device[5] = devchar;
3006 char mountpoint[] = "/";
3009 r = guestfs_mount (g, device, mountpoint);
3013 /* TestOutput for set_e2uuid (0) */
3014 char expected[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
3016 char device[] = "/dev/sda1";
3017 device[5] = devchar;
3018 char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d";
3021 r = guestfs_set_e2uuid (g, device, uuid);
3026 char device[] = "/dev/sda1";
3027 device[5] = devchar;
3030 r = guestfs_get_e2uuid (g, device);
3033 if (strcmp (r, expected) != 0) {
3034 fprintf (stderr, "test_set_e2uuid_0: expected \"%s\" but got \"%s\"\n", expected, r);
3042 static int test_set_e2uuid_1_skip (void)
3046 str = getenv ("SKIP_TEST_SET_E2UUID_1");
3047 if (str && strcmp (str, "1") == 0) return 1;
3048 str = getenv ("SKIP_TEST_SET_E2UUID");
3049 if (str && strcmp (str, "1") == 0) return 1;
3053 static int test_set_e2uuid_1 (void)
3055 if (test_set_e2uuid_1_skip ()) {
3056 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_1");
3060 /* InitBasicFS for test_set_e2uuid_1: create ext2 on /dev/sda1 */
3062 char device[] = "/dev/sda";
3063 device[5] = devchar;
3066 r = guestfs_blockdev_setrw (g, device);
3073 r = guestfs_umount_all (g);
3080 r = guestfs_lvm_remove_all (g);
3085 char device[] = "/dev/sda";
3086 device[5] = devchar;
3087 char lines_0[] = ",";
3094 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3099 char fstype[] = "ext2";
3100 char device[] = "/dev/sda1";
3101 device[5] = devchar;
3104 r = guestfs_mkfs (g, fstype, device);
3109 char device[] = "/dev/sda1";
3110 device[5] = devchar;
3111 char mountpoint[] = "/";
3114 r = guestfs_mount (g, device, mountpoint);
3118 /* TestOutput for set_e2uuid (1) */
3119 char expected[] = "";
3121 char device[] = "/dev/sda1";
3122 device[5] = devchar;
3123 char uuid[] = "clear";
3126 r = guestfs_set_e2uuid (g, device, uuid);
3131 char device[] = "/dev/sda1";
3132 device[5] = devchar;
3135 r = guestfs_get_e2uuid (g, device);
3138 if (strcmp (r, expected) != 0) {
3139 fprintf (stderr, "test_set_e2uuid_1: expected \"%s\" but got \"%s\"\n", expected, r);
3147 static int test_set_e2uuid_2_skip (void)
3151 str = getenv ("SKIP_TEST_SET_E2UUID_2");
3152 if (str && strcmp (str, "1") == 0) return 1;
3153 str = getenv ("SKIP_TEST_SET_E2UUID");
3154 if (str && strcmp (str, "1") == 0) return 1;
3158 static int test_set_e2uuid_2 (void)
3160 if (test_set_e2uuid_2_skip ()) {
3161 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_2");
3165 /* InitBasicFS for test_set_e2uuid_2: create ext2 on /dev/sda1 */
3167 char device[] = "/dev/sda";
3168 device[5] = devchar;
3171 r = guestfs_blockdev_setrw (g, device);
3178 r = guestfs_umount_all (g);
3185 r = guestfs_lvm_remove_all (g);
3190 char device[] = "/dev/sda";
3191 device[5] = devchar;
3192 char lines_0[] = ",";
3199 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3204 char fstype[] = "ext2";
3205 char device[] = "/dev/sda1";
3206 device[5] = devchar;
3209 r = guestfs_mkfs (g, fstype, device);
3214 char device[] = "/dev/sda1";
3215 device[5] = devchar;
3216 char mountpoint[] = "/";
3219 r = guestfs_mount (g, device, mountpoint);
3223 /* TestRun for set_e2uuid (2) */
3225 char device[] = "/dev/sda1";
3226 device[5] = devchar;
3227 char uuid[] = "random";
3230 r = guestfs_set_e2uuid (g, device, uuid);
3237 static int test_set_e2uuid_3_skip (void)
3241 str = getenv ("SKIP_TEST_SET_E2UUID_3");
3242 if (str && strcmp (str, "1") == 0) return 1;
3243 str = getenv ("SKIP_TEST_SET_E2UUID");
3244 if (str && strcmp (str, "1") == 0) return 1;
3248 static int test_set_e2uuid_3 (void)
3250 if (test_set_e2uuid_3_skip ()) {
3251 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2uuid_3");
3255 /* InitBasicFS for test_set_e2uuid_3: create ext2 on /dev/sda1 */
3257 char device[] = "/dev/sda";
3258 device[5] = devchar;
3261 r = guestfs_blockdev_setrw (g, device);
3268 r = guestfs_umount_all (g);
3275 r = guestfs_lvm_remove_all (g);
3280 char device[] = "/dev/sda";
3281 device[5] = devchar;
3282 char lines_0[] = ",";
3289 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3294 char fstype[] = "ext2";
3295 char device[] = "/dev/sda1";
3296 device[5] = devchar;
3299 r = guestfs_mkfs (g, fstype, device);
3304 char device[] = "/dev/sda1";
3305 device[5] = devchar;
3306 char mountpoint[] = "/";
3309 r = guestfs_mount (g, device, mountpoint);
3313 /* TestRun for set_e2uuid (3) */
3315 char device[] = "/dev/sda1";
3316 device[5] = devchar;
3317 char uuid[] = "time";
3320 r = guestfs_set_e2uuid (g, device, uuid);
3327 static int test_set_e2label_0_skip (void)
3331 str = getenv ("SKIP_TEST_SET_E2LABEL_0");
3332 if (str && strcmp (str, "1") == 0) return 1;
3333 str = getenv ("SKIP_TEST_SET_E2LABEL");
3334 if (str && strcmp (str, "1") == 0) return 1;
3338 static int test_set_e2label_0 (void)
3340 if (test_set_e2label_0_skip ()) {
3341 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_set_e2label_0");
3345 /* InitBasicFS for test_set_e2label_0: create ext2 on /dev/sda1 */
3347 char device[] = "/dev/sda";
3348 device[5] = devchar;
3351 r = guestfs_blockdev_setrw (g, device);
3358 r = guestfs_umount_all (g);
3365 r = guestfs_lvm_remove_all (g);
3370 char device[] = "/dev/sda";
3371 device[5] = devchar;
3372 char lines_0[] = ",";
3379 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3384 char fstype[] = "ext2";
3385 char device[] = "/dev/sda1";
3386 device[5] = devchar;
3389 r = guestfs_mkfs (g, fstype, device);
3394 char device[] = "/dev/sda1";
3395 device[5] = devchar;
3396 char mountpoint[] = "/";
3399 r = guestfs_mount (g, device, mountpoint);
3403 /* TestOutput for set_e2label (0) */
3404 char expected[] = "testlabel";
3406 char device[] = "/dev/sda1";
3407 device[5] = devchar;
3408 char label[] = "testlabel";
3411 r = guestfs_set_e2label (g, device, label);
3416 char device[] = "/dev/sda1";
3417 device[5] = devchar;
3420 r = guestfs_get_e2label (g, device);
3423 if (strcmp (r, expected) != 0) {
3424 fprintf (stderr, "test_set_e2label_0: expected \"%s\" but got \"%s\"\n", expected, r);
3432 static int test_pvremove_0_skip (void)
3436 str = getenv ("SKIP_TEST_PVREMOVE_0");
3437 if (str && strcmp (str, "1") == 0) return 1;
3438 str = getenv ("SKIP_TEST_PVREMOVE");
3439 if (str && strcmp (str, "1") == 0) return 1;
3443 static int test_pvremove_0 (void)
3445 if (test_pvremove_0_skip ()) {
3446 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_0");
3450 /* InitNone|InitEmpty for test_pvremove_0 */
3452 char device[] = "/dev/sda";
3453 device[5] = devchar;
3456 r = guestfs_blockdev_setrw (g, device);
3463 r = guestfs_umount_all (g);
3470 r = guestfs_lvm_remove_all (g);
3474 /* TestOutputList for pvremove (0) */
3476 char device[] = "/dev/sda";
3477 device[5] = devchar;
3478 char lines_0[] = ",";
3485 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3490 char device[] = "/dev/sda1";
3491 device[5] = devchar;
3494 r = guestfs_pvcreate (g, device);
3499 char volgroup[] = "VG";
3500 char physvols_0[] = "/dev/sda1";
3501 physvols_0[5] = devchar;
3502 char *physvols[] = {
3508 r = guestfs_vgcreate (g, volgroup, physvols);
3513 char logvol[] = "LV1";
3514 char volgroup[] = "VG";
3517 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3522 char logvol[] = "LV2";
3523 char volgroup[] = "VG";
3526 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3531 char vgname[] = "VG";
3534 r = guestfs_vgremove (g, vgname);
3539 char device[] = "/dev/sda1";
3540 device[5] = devchar;
3543 r = guestfs_pvremove (g, device);
3551 r = guestfs_lvs (g);
3555 fprintf (stderr, "test_pvremove_0: extra elements returned from command\n");
3559 for (i = 0; r[i] != NULL; ++i)
3566 static int test_pvremove_1_skip (void)
3570 str = getenv ("SKIP_TEST_PVREMOVE_1");
3571 if (str && strcmp (str, "1") == 0) return 1;
3572 str = getenv ("SKIP_TEST_PVREMOVE");
3573 if (str && strcmp (str, "1") == 0) return 1;
3577 static int test_pvremove_1 (void)
3579 if (test_pvremove_1_skip ()) {
3580 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_1");
3584 /* InitNone|InitEmpty for test_pvremove_1 */
3586 char device[] = "/dev/sda";
3587 device[5] = devchar;
3590 r = guestfs_blockdev_setrw (g, device);
3597 r = guestfs_umount_all (g);
3604 r = guestfs_lvm_remove_all (g);
3608 /* TestOutputList for pvremove (1) */
3610 char device[] = "/dev/sda";
3611 device[5] = devchar;
3612 char lines_0[] = ",";
3619 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3624 char device[] = "/dev/sda1";
3625 device[5] = devchar;
3628 r = guestfs_pvcreate (g, device);
3633 char volgroup[] = "VG";
3634 char physvols_0[] = "/dev/sda1";
3635 physvols_0[5] = devchar;
3636 char *physvols[] = {
3642 r = guestfs_vgcreate (g, volgroup, physvols);
3647 char logvol[] = "LV1";
3648 char volgroup[] = "VG";
3651 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3656 char logvol[] = "LV2";
3657 char volgroup[] = "VG";
3660 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3665 char vgname[] = "VG";
3668 r = guestfs_vgremove (g, vgname);
3673 char device[] = "/dev/sda1";
3674 device[5] = devchar;
3677 r = guestfs_pvremove (g, device);
3685 r = guestfs_vgs (g);
3689 fprintf (stderr, "test_pvremove_1: extra elements returned from command\n");
3693 for (i = 0; r[i] != NULL; ++i)
3700 static int test_pvremove_2_skip (void)
3704 str = getenv ("SKIP_TEST_PVREMOVE_2");
3705 if (str && strcmp (str, "1") == 0) return 1;
3706 str = getenv ("SKIP_TEST_PVREMOVE");
3707 if (str && strcmp (str, "1") == 0) return 1;
3711 static int test_pvremove_2 (void)
3713 if (test_pvremove_2_skip ()) {
3714 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvremove_2");
3718 /* InitNone|InitEmpty for test_pvremove_2 */
3720 char device[] = "/dev/sda";
3721 device[5] = devchar;
3724 r = guestfs_blockdev_setrw (g, device);
3731 r = guestfs_umount_all (g);
3738 r = guestfs_lvm_remove_all (g);
3742 /* TestOutputList for pvremove (2) */
3744 char device[] = "/dev/sda";
3745 device[5] = devchar;
3746 char lines_0[] = ",";
3753 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3758 char device[] = "/dev/sda1";
3759 device[5] = devchar;
3762 r = guestfs_pvcreate (g, device);
3767 char volgroup[] = "VG";
3768 char physvols_0[] = "/dev/sda1";
3769 physvols_0[5] = devchar;
3770 char *physvols[] = {
3776 r = guestfs_vgcreate (g, volgroup, physvols);
3781 char logvol[] = "LV1";
3782 char volgroup[] = "VG";
3785 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3790 char logvol[] = "LV2";
3791 char volgroup[] = "VG";
3794 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3799 char vgname[] = "VG";
3802 r = guestfs_vgremove (g, vgname);
3807 char device[] = "/dev/sda1";
3808 device[5] = devchar;
3811 r = guestfs_pvremove (g, device);
3819 r = guestfs_pvs (g);
3823 fprintf (stderr, "test_pvremove_2: extra elements returned from command\n");
3827 for (i = 0; r[i] != NULL; ++i)
3834 static int test_vgremove_0_skip (void)
3838 str = getenv ("SKIP_TEST_VGREMOVE_0");
3839 if (str && strcmp (str, "1") == 0) return 1;
3840 str = getenv ("SKIP_TEST_VGREMOVE");
3841 if (str && strcmp (str, "1") == 0) return 1;
3845 static int test_vgremove_0 (void)
3847 if (test_vgremove_0_skip ()) {
3848 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_0");
3852 /* InitNone|InitEmpty for test_vgremove_0 */
3854 char device[] = "/dev/sda";
3855 device[5] = devchar;
3858 r = guestfs_blockdev_setrw (g, device);
3865 r = guestfs_umount_all (g);
3872 r = guestfs_lvm_remove_all (g);
3876 /* TestOutputList for vgremove (0) */
3878 char device[] = "/dev/sda";
3879 device[5] = devchar;
3880 char lines_0[] = ",";
3887 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
3892 char device[] = "/dev/sda1";
3893 device[5] = devchar;
3896 r = guestfs_pvcreate (g, device);
3901 char volgroup[] = "VG";
3902 char physvols_0[] = "/dev/sda1";
3903 physvols_0[5] = devchar;
3904 char *physvols[] = {
3910 r = guestfs_vgcreate (g, volgroup, physvols);
3915 char logvol[] = "LV1";
3916 char volgroup[] = "VG";
3919 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3924 char logvol[] = "LV2";
3925 char volgroup[] = "VG";
3928 r = guestfs_lvcreate (g, logvol, volgroup, 50);
3933 char vgname[] = "VG";
3936 r = guestfs_vgremove (g, vgname);
3944 r = guestfs_lvs (g);
3948 fprintf (stderr, "test_vgremove_0: extra elements returned from command\n");
3952 for (i = 0; r[i] != NULL; ++i)
3959 static int test_vgremove_1_skip (void)
3963 str = getenv ("SKIP_TEST_VGREMOVE_1");
3964 if (str && strcmp (str, "1") == 0) return 1;
3965 str = getenv ("SKIP_TEST_VGREMOVE");
3966 if (str && strcmp (str, "1") == 0) return 1;
3970 static int test_vgremove_1 (void)
3972 if (test_vgremove_1_skip ()) {
3973 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgremove_1");
3977 /* InitNone|InitEmpty for test_vgremove_1 */
3979 char device[] = "/dev/sda";
3980 device[5] = devchar;
3983 r = guestfs_blockdev_setrw (g, device);
3990 r = guestfs_umount_all (g);
3997 r = guestfs_lvm_remove_all (g);
4001 /* TestOutputList for vgremove (1) */
4003 char device[] = "/dev/sda";
4004 device[5] = devchar;
4005 char lines_0[] = ",";
4012 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4017 char device[] = "/dev/sda1";
4018 device[5] = devchar;
4021 r = guestfs_pvcreate (g, device);
4026 char volgroup[] = "VG";
4027 char physvols_0[] = "/dev/sda1";
4028 physvols_0[5] = devchar;
4029 char *physvols[] = {
4035 r = guestfs_vgcreate (g, volgroup, physvols);
4040 char logvol[] = "LV1";
4041 char volgroup[] = "VG";
4044 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4049 char logvol[] = "LV2";
4050 char volgroup[] = "VG";
4053 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4058 char vgname[] = "VG";
4061 r = guestfs_vgremove (g, vgname);
4069 r = guestfs_vgs (g);
4073 fprintf (stderr, "test_vgremove_1: extra elements returned from command\n");
4077 for (i = 0; r[i] != NULL; ++i)
4084 static int test_lvremove_0_skip (void)
4088 str = getenv ("SKIP_TEST_LVREMOVE_0");
4089 if (str && strcmp (str, "1") == 0) return 1;
4090 str = getenv ("SKIP_TEST_LVREMOVE");
4091 if (str && strcmp (str, "1") == 0) return 1;
4095 static int test_lvremove_0 (void)
4097 if (test_lvremove_0_skip ()) {
4098 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_0");
4102 /* InitNone|InitEmpty for test_lvremove_0 */
4104 char device[] = "/dev/sda";
4105 device[5] = devchar;
4108 r = guestfs_blockdev_setrw (g, device);
4115 r = guestfs_umount_all (g);
4122 r = guestfs_lvm_remove_all (g);
4126 /* TestOutputList for lvremove (0) */
4128 char device[] = "/dev/sda";
4129 device[5] = devchar;
4130 char lines_0[] = ",";
4137 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4142 char device[] = "/dev/sda1";
4143 device[5] = devchar;
4146 r = guestfs_pvcreate (g, device);
4151 char volgroup[] = "VG";
4152 char physvols_0[] = "/dev/sda1";
4153 physvols_0[5] = devchar;
4154 char *physvols[] = {
4160 r = guestfs_vgcreate (g, volgroup, physvols);
4165 char logvol[] = "LV1";
4166 char volgroup[] = "VG";
4169 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4174 char logvol[] = "LV2";
4175 char volgroup[] = "VG";
4178 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4183 char device[] = "/dev/VG/LV1";
4186 r = guestfs_lvremove (g, device);
4194 r = guestfs_lvs (g);
4198 fprintf (stderr, "test_lvremove_0: short list returned from command\n");
4203 char expected[] = "/dev/VG/LV2";
4204 if (strcmp (r[0], expected) != 0) {
4205 fprintf (stderr, "test_lvremove_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4210 fprintf (stderr, "test_lvremove_0: extra elements returned from command\n");
4214 for (i = 0; r[i] != NULL; ++i)
4221 static int test_lvremove_1_skip (void)
4225 str = getenv ("SKIP_TEST_LVREMOVE_1");
4226 if (str && strcmp (str, "1") == 0) return 1;
4227 str = getenv ("SKIP_TEST_LVREMOVE");
4228 if (str && strcmp (str, "1") == 0) return 1;
4232 static int test_lvremove_1 (void)
4234 if (test_lvremove_1_skip ()) {
4235 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_1");
4239 /* InitNone|InitEmpty for test_lvremove_1 */
4241 char device[] = "/dev/sda";
4242 device[5] = devchar;
4245 r = guestfs_blockdev_setrw (g, device);
4252 r = guestfs_umount_all (g);
4259 r = guestfs_lvm_remove_all (g);
4263 /* TestOutputList for lvremove (1) */
4265 char device[] = "/dev/sda";
4266 device[5] = devchar;
4267 char lines_0[] = ",";
4274 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4279 char device[] = "/dev/sda1";
4280 device[5] = devchar;
4283 r = guestfs_pvcreate (g, device);
4288 char volgroup[] = "VG";
4289 char physvols_0[] = "/dev/sda1";
4290 physvols_0[5] = devchar;
4291 char *physvols[] = {
4297 r = guestfs_vgcreate (g, volgroup, physvols);
4302 char logvol[] = "LV1";
4303 char volgroup[] = "VG";
4306 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4311 char logvol[] = "LV2";
4312 char volgroup[] = "VG";
4315 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4320 char device[] = "/dev/VG";
4323 r = guestfs_lvremove (g, device);
4331 r = guestfs_lvs (g);
4335 fprintf (stderr, "test_lvremove_1: extra elements returned from command\n");
4339 for (i = 0; r[i] != NULL; ++i)
4346 static int test_lvremove_2_skip (void)
4350 str = getenv ("SKIP_TEST_LVREMOVE_2");
4351 if (str && strcmp (str, "1") == 0) return 1;
4352 str = getenv ("SKIP_TEST_LVREMOVE");
4353 if (str && strcmp (str, "1") == 0) return 1;
4357 static int test_lvremove_2 (void)
4359 if (test_lvremove_2_skip ()) {
4360 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvremove_2");
4364 /* InitNone|InitEmpty for test_lvremove_2 */
4366 char device[] = "/dev/sda";
4367 device[5] = devchar;
4370 r = guestfs_blockdev_setrw (g, device);
4377 r = guestfs_umount_all (g);
4384 r = guestfs_lvm_remove_all (g);
4388 /* TestOutputList for lvremove (2) */
4390 char device[] = "/dev/sda";
4391 device[5] = devchar;
4392 char lines_0[] = ",";
4399 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4404 char device[] = "/dev/sda1";
4405 device[5] = devchar;
4408 r = guestfs_pvcreate (g, device);
4413 char volgroup[] = "VG";
4414 char physvols_0[] = "/dev/sda1";
4415 physvols_0[5] = devchar;
4416 char *physvols[] = {
4422 r = guestfs_vgcreate (g, volgroup, physvols);
4427 char logvol[] = "LV1";
4428 char volgroup[] = "VG";
4431 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4436 char logvol[] = "LV2";
4437 char volgroup[] = "VG";
4440 r = guestfs_lvcreate (g, logvol, volgroup, 50);
4445 char device[] = "/dev/VG";
4448 r = guestfs_lvremove (g, device);
4456 r = guestfs_vgs (g);
4460 fprintf (stderr, "test_lvremove_2: short list returned from command\n");
4465 char expected[] = "VG";
4466 if (strcmp (r[0], expected) != 0) {
4467 fprintf (stderr, "test_lvremove_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
4472 fprintf (stderr, "test_lvremove_2: extra elements returned from command\n");
4476 for (i = 0; r[i] != NULL; ++i)
4483 static int test_mount_ro_0_skip (void)
4487 str = getenv ("SKIP_TEST_MOUNT_RO_0");
4488 if (str && strcmp (str, "1") == 0) return 1;
4489 str = getenv ("SKIP_TEST_MOUNT_RO");
4490 if (str && strcmp (str, "1") == 0) return 1;
4494 static int test_mount_ro_0 (void)
4496 if (test_mount_ro_0_skip ()) {
4497 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_0");
4501 /* InitBasicFS for test_mount_ro_0: create ext2 on /dev/sda1 */
4503 char device[] = "/dev/sda";
4504 device[5] = devchar;
4507 r = guestfs_blockdev_setrw (g, device);
4514 r = guestfs_umount_all (g);
4521 r = guestfs_lvm_remove_all (g);
4526 char device[] = "/dev/sda";
4527 device[5] = devchar;
4528 char lines_0[] = ",";
4535 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4540 char fstype[] = "ext2";
4541 char device[] = "/dev/sda1";
4542 device[5] = devchar;
4545 r = guestfs_mkfs (g, fstype, device);
4550 char device[] = "/dev/sda1";
4551 device[5] = devchar;
4552 char mountpoint[] = "/";
4555 r = guestfs_mount (g, device, mountpoint);
4559 /* TestLastFail for mount_ro (0) */
4561 char pathordevice[] = "/";
4564 r = guestfs_umount (g, pathordevice);
4569 char device[] = "/dev/sda1";
4570 device[5] = devchar;
4571 char mountpoint[] = "/";
4574 r = guestfs_mount_ro (g, device, mountpoint);
4579 char path[] = "/new";
4582 r = guestfs_touch (g, path);
4589 static int test_mount_ro_1_skip (void)
4593 str = getenv ("SKIP_TEST_MOUNT_RO_1");
4594 if (str && strcmp (str, "1") == 0) return 1;
4595 str = getenv ("SKIP_TEST_MOUNT_RO");
4596 if (str && strcmp (str, "1") == 0) return 1;
4600 static int test_mount_ro_1 (void)
4602 if (test_mount_ro_1_skip ()) {
4603 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_ro_1");
4607 /* InitBasicFS for test_mount_ro_1: create ext2 on /dev/sda1 */
4609 char device[] = "/dev/sda";
4610 device[5] = devchar;
4613 r = guestfs_blockdev_setrw (g, device);
4620 r = guestfs_umount_all (g);
4627 r = guestfs_lvm_remove_all (g);
4632 char device[] = "/dev/sda";
4633 device[5] = devchar;
4634 char lines_0[] = ",";
4641 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4646 char fstype[] = "ext2";
4647 char device[] = "/dev/sda1";
4648 device[5] = devchar;
4651 r = guestfs_mkfs (g, fstype, device);
4656 char device[] = "/dev/sda1";
4657 device[5] = devchar;
4658 char mountpoint[] = "/";
4661 r = guestfs_mount (g, device, mountpoint);
4665 /* TestOutput for mount_ro (1) */
4666 char expected[] = "data";
4668 char path[] = "/new";
4669 char content[] = "data";
4672 r = guestfs_write_file (g, path, content, 0);
4677 char pathordevice[] = "/";
4680 r = guestfs_umount (g, pathordevice);
4685 char device[] = "/dev/sda1";
4686 device[5] = devchar;
4687 char mountpoint[] = "/";
4690 r = guestfs_mount_ro (g, device, mountpoint);
4695 char path[] = "/new";
4698 r = guestfs_cat (g, path);
4701 if (strcmp (r, expected) != 0) {
4702 fprintf (stderr, "test_mount_ro_1: expected \"%s\" but got \"%s\"\n", expected, r);
4710 static int test_tgz_in_0_skip (void)
4714 str = getenv ("SKIP_TEST_TGZ_IN_0");
4715 if (str && strcmp (str, "1") == 0) return 1;
4716 str = getenv ("SKIP_TEST_TGZ_IN");
4717 if (str && strcmp (str, "1") == 0) return 1;
4721 static int test_tgz_in_0 (void)
4723 if (test_tgz_in_0_skip ()) {
4724 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tgz_in_0");
4728 /* InitBasicFS for test_tgz_in_0: create ext2 on /dev/sda1 */
4730 char device[] = "/dev/sda";
4731 device[5] = devchar;
4734 r = guestfs_blockdev_setrw (g, device);
4741 r = guestfs_umount_all (g);
4748 r = guestfs_lvm_remove_all (g);
4753 char device[] = "/dev/sda";
4754 device[5] = devchar;
4755 char lines_0[] = ",";
4762 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4767 char fstype[] = "ext2";
4768 char device[] = "/dev/sda1";
4769 device[5] = devchar;
4772 r = guestfs_mkfs (g, fstype, device);
4777 char device[] = "/dev/sda1";
4778 device[5] = devchar;
4779 char mountpoint[] = "/";
4782 r = guestfs_mount (g, device, mountpoint);
4786 /* TestOutput for tgz_in (0) */
4787 char expected[] = "hello\n";
4789 char directory[] = "/";
4792 r = guestfs_tgz_in (g, "../images/helloworld.tar.gz", directory);
4797 char path[] = "/hello";
4800 r = guestfs_cat (g, path);
4803 if (strcmp (r, expected) != 0) {
4804 fprintf (stderr, "test_tgz_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
4812 static int test_tar_in_0_skip (void)
4816 str = getenv ("SKIP_TEST_TAR_IN_0");
4817 if (str && strcmp (str, "1") == 0) return 1;
4818 str = getenv ("SKIP_TEST_TAR_IN");
4819 if (str && strcmp (str, "1") == 0) return 1;
4823 static int test_tar_in_0 (void)
4825 if (test_tar_in_0_skip ()) {
4826 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_tar_in_0");
4830 /* InitBasicFS for test_tar_in_0: create ext2 on /dev/sda1 */
4832 char device[] = "/dev/sda";
4833 device[5] = devchar;
4836 r = guestfs_blockdev_setrw (g, device);
4843 r = guestfs_umount_all (g);
4850 r = guestfs_lvm_remove_all (g);
4855 char device[] = "/dev/sda";
4856 device[5] = devchar;
4857 char lines_0[] = ",";
4864 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4869 char fstype[] = "ext2";
4870 char device[] = "/dev/sda1";
4871 device[5] = devchar;
4874 r = guestfs_mkfs (g, fstype, device);
4879 char device[] = "/dev/sda1";
4880 device[5] = devchar;
4881 char mountpoint[] = "/";
4884 r = guestfs_mount (g, device, mountpoint);
4888 /* TestOutput for tar_in (0) */
4889 char expected[] = "hello\n";
4891 char directory[] = "/";
4894 r = guestfs_tar_in (g, "../images/helloworld.tar", directory);
4899 char path[] = "/hello";
4902 r = guestfs_cat (g, path);
4905 if (strcmp (r, expected) != 0) {
4906 fprintf (stderr, "test_tar_in_0: expected \"%s\" but got \"%s\"\n", expected, r);
4914 static int test_checksum_0_skip (void)
4918 str = getenv ("SKIP_TEST_CHECKSUM_0");
4919 if (str && strcmp (str, "1") == 0) return 1;
4920 str = getenv ("SKIP_TEST_CHECKSUM");
4921 if (str && strcmp (str, "1") == 0) return 1;
4925 static int test_checksum_0 (void)
4927 if (test_checksum_0_skip ()) {
4928 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_0");
4932 /* InitBasicFS for test_checksum_0: create ext2 on /dev/sda1 */
4934 char device[] = "/dev/sda";
4935 device[5] = devchar;
4938 r = guestfs_blockdev_setrw (g, device);
4945 r = guestfs_umount_all (g);
4952 r = guestfs_lvm_remove_all (g);
4957 char device[] = "/dev/sda";
4958 device[5] = devchar;
4959 char lines_0[] = ",";
4966 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
4971 char fstype[] = "ext2";
4972 char device[] = "/dev/sda1";
4973 device[5] = devchar;
4976 r = guestfs_mkfs (g, fstype, device);
4981 char device[] = "/dev/sda1";
4982 device[5] = devchar;
4983 char mountpoint[] = "/";
4986 r = guestfs_mount (g, device, mountpoint);
4990 /* TestOutput for checksum (0) */
4991 char expected[] = "935282863";
4993 char path[] = "/new";
4994 char content[] = "test\n";
4997 r = guestfs_write_file (g, path, content, 0);
5002 char csumtype[] = "crc";
5003 char path[] = "/new";
5006 r = guestfs_checksum (g, csumtype, path);
5009 if (strcmp (r, expected) != 0) {
5010 fprintf (stderr, "test_checksum_0: expected \"%s\" but got \"%s\"\n", expected, r);
5018 static int test_checksum_1_skip (void)
5022 str = getenv ("SKIP_TEST_CHECKSUM_1");
5023 if (str && strcmp (str, "1") == 0) return 1;
5024 str = getenv ("SKIP_TEST_CHECKSUM");
5025 if (str && strcmp (str, "1") == 0) return 1;
5029 static int test_checksum_1 (void)
5031 if (test_checksum_1_skip ()) {
5032 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_1");
5036 /* InitBasicFS for test_checksum_1: create ext2 on /dev/sda1 */
5038 char device[] = "/dev/sda";
5039 device[5] = devchar;
5042 r = guestfs_blockdev_setrw (g, device);
5049 r = guestfs_umount_all (g);
5056 r = guestfs_lvm_remove_all (g);
5061 char device[] = "/dev/sda";
5062 device[5] = devchar;
5063 char lines_0[] = ",";
5070 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5075 char fstype[] = "ext2";
5076 char device[] = "/dev/sda1";
5077 device[5] = devchar;
5080 r = guestfs_mkfs (g, fstype, device);
5085 char device[] = "/dev/sda1";
5086 device[5] = devchar;
5087 char mountpoint[] = "/";
5090 r = guestfs_mount (g, device, mountpoint);
5094 /* TestLastFail for checksum (1) */
5096 char csumtype[] = "crc";
5097 char path[] = "/new";
5100 r = guestfs_checksum (g, csumtype, path);
5108 static int test_checksum_2_skip (void)
5112 str = getenv ("SKIP_TEST_CHECKSUM_2");
5113 if (str && strcmp (str, "1") == 0) return 1;
5114 str = getenv ("SKIP_TEST_CHECKSUM");
5115 if (str && strcmp (str, "1") == 0) return 1;
5119 static int test_checksum_2 (void)
5121 if (test_checksum_2_skip ()) {
5122 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_2");
5126 /* InitBasicFS for test_checksum_2: create ext2 on /dev/sda1 */
5128 char device[] = "/dev/sda";
5129 device[5] = devchar;
5132 r = guestfs_blockdev_setrw (g, device);
5139 r = guestfs_umount_all (g);
5146 r = guestfs_lvm_remove_all (g);
5151 char device[] = "/dev/sda";
5152 device[5] = devchar;
5153 char lines_0[] = ",";
5160 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5165 char fstype[] = "ext2";
5166 char device[] = "/dev/sda1";
5167 device[5] = devchar;
5170 r = guestfs_mkfs (g, fstype, device);
5175 char device[] = "/dev/sda1";
5176 device[5] = devchar;
5177 char mountpoint[] = "/";
5180 r = guestfs_mount (g, device, mountpoint);
5184 /* TestOutput for checksum (2) */
5185 char expected[] = "d8e8fca2dc0f896fd7cb4cb0031ba249";
5187 char path[] = "/new";
5188 char content[] = "test\n";
5191 r = guestfs_write_file (g, path, content, 0);
5196 char csumtype[] = "md5";
5197 char path[] = "/new";
5200 r = guestfs_checksum (g, csumtype, path);
5203 if (strcmp (r, expected) != 0) {
5204 fprintf (stderr, "test_checksum_2: expected \"%s\" but got \"%s\"\n", expected, r);
5212 static int test_checksum_3_skip (void)
5216 str = getenv ("SKIP_TEST_CHECKSUM_3");
5217 if (str && strcmp (str, "1") == 0) return 1;
5218 str = getenv ("SKIP_TEST_CHECKSUM");
5219 if (str && strcmp (str, "1") == 0) return 1;
5223 static int test_checksum_3 (void)
5225 if (test_checksum_3_skip ()) {
5226 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_3");
5230 /* InitBasicFS for test_checksum_3: create ext2 on /dev/sda1 */
5232 char device[] = "/dev/sda";
5233 device[5] = devchar;
5236 r = guestfs_blockdev_setrw (g, device);
5243 r = guestfs_umount_all (g);
5250 r = guestfs_lvm_remove_all (g);
5255 char device[] = "/dev/sda";
5256 device[5] = devchar;
5257 char lines_0[] = ",";
5264 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5269 char fstype[] = "ext2";
5270 char device[] = "/dev/sda1";
5271 device[5] = devchar;
5274 r = guestfs_mkfs (g, fstype, device);
5279 char device[] = "/dev/sda1";
5280 device[5] = devchar;
5281 char mountpoint[] = "/";
5284 r = guestfs_mount (g, device, mountpoint);
5288 /* TestOutput for checksum (3) */
5289 char expected[] = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83";
5291 char path[] = "/new";
5292 char content[] = "test\n";
5295 r = guestfs_write_file (g, path, content, 0);
5300 char csumtype[] = "sha1";
5301 char path[] = "/new";
5304 r = guestfs_checksum (g, csumtype, path);
5307 if (strcmp (r, expected) != 0) {
5308 fprintf (stderr, "test_checksum_3: expected \"%s\" but got \"%s\"\n", expected, r);
5316 static int test_checksum_4_skip (void)
5320 str = getenv ("SKIP_TEST_CHECKSUM_4");
5321 if (str && strcmp (str, "1") == 0) return 1;
5322 str = getenv ("SKIP_TEST_CHECKSUM");
5323 if (str && strcmp (str, "1") == 0) return 1;
5327 static int test_checksum_4 (void)
5329 if (test_checksum_4_skip ()) {
5330 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_4");
5334 /* InitBasicFS for test_checksum_4: create ext2 on /dev/sda1 */
5336 char device[] = "/dev/sda";
5337 device[5] = devchar;
5340 r = guestfs_blockdev_setrw (g, device);
5347 r = guestfs_umount_all (g);
5354 r = guestfs_lvm_remove_all (g);
5359 char device[] = "/dev/sda";
5360 device[5] = devchar;
5361 char lines_0[] = ",";
5368 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5373 char fstype[] = "ext2";
5374 char device[] = "/dev/sda1";
5375 device[5] = devchar;
5378 r = guestfs_mkfs (g, fstype, device);
5383 char device[] = "/dev/sda1";
5384 device[5] = devchar;
5385 char mountpoint[] = "/";
5388 r = guestfs_mount (g, device, mountpoint);
5392 /* TestOutput for checksum (4) */
5393 char expected[] = "52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec";
5395 char path[] = "/new";
5396 char content[] = "test\n";
5399 r = guestfs_write_file (g, path, content, 0);
5404 char csumtype[] = "sha224";
5405 char path[] = "/new";
5408 r = guestfs_checksum (g, csumtype, path);
5411 if (strcmp (r, expected) != 0) {
5412 fprintf (stderr, "test_checksum_4: expected \"%s\" but got \"%s\"\n", expected, r);
5420 static int test_checksum_5_skip (void)
5424 str = getenv ("SKIP_TEST_CHECKSUM_5");
5425 if (str && strcmp (str, "1") == 0) return 1;
5426 str = getenv ("SKIP_TEST_CHECKSUM");
5427 if (str && strcmp (str, "1") == 0) return 1;
5431 static int test_checksum_5 (void)
5433 if (test_checksum_5_skip ()) {
5434 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_5");
5438 /* InitBasicFS for test_checksum_5: create ext2 on /dev/sda1 */
5440 char device[] = "/dev/sda";
5441 device[5] = devchar;
5444 r = guestfs_blockdev_setrw (g, device);
5451 r = guestfs_umount_all (g);
5458 r = guestfs_lvm_remove_all (g);
5463 char device[] = "/dev/sda";
5464 device[5] = devchar;
5465 char lines_0[] = ",";
5472 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5477 char fstype[] = "ext2";
5478 char device[] = "/dev/sda1";
5479 device[5] = devchar;
5482 r = guestfs_mkfs (g, fstype, device);
5487 char device[] = "/dev/sda1";
5488 device[5] = devchar;
5489 char mountpoint[] = "/";
5492 r = guestfs_mount (g, device, mountpoint);
5496 /* TestOutput for checksum (5) */
5497 char expected[] = "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2";
5499 char path[] = "/new";
5500 char content[] = "test\n";
5503 r = guestfs_write_file (g, path, content, 0);
5508 char csumtype[] = "sha256";
5509 char path[] = "/new";
5512 r = guestfs_checksum (g, csumtype, path);
5515 if (strcmp (r, expected) != 0) {
5516 fprintf (stderr, "test_checksum_5: expected \"%s\" but got \"%s\"\n", expected, r);
5524 static int test_checksum_6_skip (void)
5528 str = getenv ("SKIP_TEST_CHECKSUM_6");
5529 if (str && strcmp (str, "1") == 0) return 1;
5530 str = getenv ("SKIP_TEST_CHECKSUM");
5531 if (str && strcmp (str, "1") == 0) return 1;
5535 static int test_checksum_6 (void)
5537 if (test_checksum_6_skip ()) {
5538 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_6");
5542 /* InitBasicFS for test_checksum_6: create ext2 on /dev/sda1 */
5544 char device[] = "/dev/sda";
5545 device[5] = devchar;
5548 r = guestfs_blockdev_setrw (g, device);
5555 r = guestfs_umount_all (g);
5562 r = guestfs_lvm_remove_all (g);
5567 char device[] = "/dev/sda";
5568 device[5] = devchar;
5569 char lines_0[] = ",";
5576 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5581 char fstype[] = "ext2";
5582 char device[] = "/dev/sda1";
5583 device[5] = devchar;
5586 r = guestfs_mkfs (g, fstype, device);
5591 char device[] = "/dev/sda1";
5592 device[5] = devchar;
5593 char mountpoint[] = "/";
5596 r = guestfs_mount (g, device, mountpoint);
5600 /* TestOutput for checksum (6) */
5601 char expected[] = "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d";
5603 char path[] = "/new";
5604 char content[] = "test\n";
5607 r = guestfs_write_file (g, path, content, 0);
5612 char csumtype[] = "sha384";
5613 char path[] = "/new";
5616 r = guestfs_checksum (g, csumtype, path);
5619 if (strcmp (r, expected) != 0) {
5620 fprintf (stderr, "test_checksum_6: expected \"%s\" but got \"%s\"\n", expected, r);
5628 static int test_checksum_7_skip (void)
5632 str = getenv ("SKIP_TEST_CHECKSUM_7");
5633 if (str && strcmp (str, "1") == 0) return 1;
5634 str = getenv ("SKIP_TEST_CHECKSUM");
5635 if (str && strcmp (str, "1") == 0) return 1;
5639 static int test_checksum_7 (void)
5641 if (test_checksum_7_skip ()) {
5642 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_7");
5646 /* InitBasicFS for test_checksum_7: create ext2 on /dev/sda1 */
5648 char device[] = "/dev/sda";
5649 device[5] = devchar;
5652 r = guestfs_blockdev_setrw (g, device);
5659 r = guestfs_umount_all (g);
5666 r = guestfs_lvm_remove_all (g);
5671 char device[] = "/dev/sda";
5672 device[5] = devchar;
5673 char lines_0[] = ",";
5680 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5685 char fstype[] = "ext2";
5686 char device[] = "/dev/sda1";
5687 device[5] = devchar;
5690 r = guestfs_mkfs (g, fstype, device);
5695 char device[] = "/dev/sda1";
5696 device[5] = devchar;
5697 char mountpoint[] = "/";
5700 r = guestfs_mount (g, device, mountpoint);
5704 /* TestOutput for checksum (7) */
5705 char expected[] = "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123";
5707 char path[] = "/new";
5708 char content[] = "test\n";
5711 r = guestfs_write_file (g, path, content, 0);
5716 char csumtype[] = "sha512";
5717 char path[] = "/new";
5720 r = guestfs_checksum (g, csumtype, path);
5723 if (strcmp (r, expected) != 0) {
5724 fprintf (stderr, "test_checksum_7: expected \"%s\" but got \"%s\"\n", expected, r);
5732 static int test_checksum_8_skip (void)
5736 str = getenv ("SKIP_TEST_CHECKSUM_8");
5737 if (str && strcmp (str, "1") == 0) return 1;
5738 str = getenv ("SKIP_TEST_CHECKSUM");
5739 if (str && strcmp (str, "1") == 0) return 1;
5743 static int test_checksum_8 (void)
5745 if (test_checksum_8_skip ()) {
5746 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_8");
5750 /* InitBasicFS for test_checksum_8: create ext2 on /dev/sda1 */
5752 char device[] = "/dev/sda";
5753 device[5] = devchar;
5756 r = guestfs_blockdev_setrw (g, device);
5763 r = guestfs_umount_all (g);
5770 r = guestfs_lvm_remove_all (g);
5775 char device[] = "/dev/sda";
5776 device[5] = devchar;
5777 char lines_0[] = ",";
5784 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5789 char fstype[] = "ext2";
5790 char device[] = "/dev/sda1";
5791 device[5] = devchar;
5794 r = guestfs_mkfs (g, fstype, device);
5799 char device[] = "/dev/sda1";
5800 device[5] = devchar;
5801 char mountpoint[] = "/";
5804 r = guestfs_mount (g, device, mountpoint);
5808 /* TestOutput for checksum (8) */
5809 char expected[] = "46d6ca27ee07cdc6fa99c2e138cc522c";
5811 char device[] = "/dev/sdd";
5812 device[5] = devchar;
5813 char mountpoint[] = "/";
5816 r = guestfs_mount (g, device, mountpoint);
5821 char csumtype[] = "md5";
5822 char path[] = "/known-3";
5825 r = guestfs_checksum (g, csumtype, path);
5828 if (strcmp (r, expected) != 0) {
5829 fprintf (stderr, "test_checksum_8: expected \"%s\" but got \"%s\"\n", expected, r);
5837 static int test_download_0_skip (void)
5841 str = getenv ("SKIP_TEST_DOWNLOAD_0");
5842 if (str && strcmp (str, "1") == 0) return 1;
5843 str = getenv ("SKIP_TEST_DOWNLOAD");
5844 if (str && strcmp (str, "1") == 0) return 1;
5848 static int test_download_0 (void)
5850 if (test_download_0_skip ()) {
5851 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_download_0");
5855 /* InitBasicFS for test_download_0: create ext2 on /dev/sda1 */
5857 char device[] = "/dev/sda";
5858 device[5] = devchar;
5861 r = guestfs_blockdev_setrw (g, device);
5868 r = guestfs_umount_all (g);
5875 r = guestfs_lvm_remove_all (g);
5880 char device[] = "/dev/sda";
5881 device[5] = devchar;
5882 char lines_0[] = ",";
5889 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
5894 char fstype[] = "ext2";
5895 char device[] = "/dev/sda1";
5896 device[5] = devchar;
5899 r = guestfs_mkfs (g, fstype, device);
5904 char device[] = "/dev/sda1";
5905 device[5] = devchar;
5906 char mountpoint[] = "/";
5909 r = guestfs_mount (g, device, mountpoint);
5913 /* TestOutput for download (0) */
5914 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
5916 char remotefilename[] = "/COPYING.LIB";
5919 r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
5924 char remotefilename[] = "/COPYING.LIB";
5927 r = guestfs_download (g, remotefilename, "testdownload.tmp");
5932 char remotefilename[] = "/upload";
5935 r = guestfs_upload (g, "testdownload.tmp", remotefilename);
5940 char csumtype[] = "md5";
5941 char path[] = "/upload";
5944 r = guestfs_checksum (g, csumtype, path);
5947 if (strcmp (r, expected) != 0) {
5948 fprintf (stderr, "test_download_0: expected \"%s\" but got \"%s\"\n", expected, r);
5956 static int test_upload_0_skip (void)
5960 str = getenv ("SKIP_TEST_UPLOAD_0");
5961 if (str && strcmp (str, "1") == 0) return 1;
5962 str = getenv ("SKIP_TEST_UPLOAD");
5963 if (str && strcmp (str, "1") == 0) return 1;
5967 static int test_upload_0 (void)
5969 if (test_upload_0_skip ()) {
5970 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_upload_0");
5974 /* InitBasicFS for test_upload_0: create ext2 on /dev/sda1 */
5976 char device[] = "/dev/sda";
5977 device[5] = devchar;
5980 r = guestfs_blockdev_setrw (g, device);
5987 r = guestfs_umount_all (g);
5994 r = guestfs_lvm_remove_all (g);
5999 char device[] = "/dev/sda";
6000 device[5] = devchar;
6001 char lines_0[] = ",";
6008 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6013 char fstype[] = "ext2";
6014 char device[] = "/dev/sda1";
6015 device[5] = devchar;
6018 r = guestfs_mkfs (g, fstype, device);
6023 char device[] = "/dev/sda1";
6024 device[5] = devchar;
6025 char mountpoint[] = "/";
6028 r = guestfs_mount (g, device, mountpoint);
6032 /* TestOutput for upload (0) */
6033 char expected[] = "e3eda01d9815f8d24aae2dbd89b68b06";
6035 char remotefilename[] = "/COPYING.LIB";
6038 r = guestfs_upload (g, "../COPYING.LIB", remotefilename);
6043 char csumtype[] = "md5";
6044 char path[] = "/COPYING.LIB";
6047 r = guestfs_checksum (g, csumtype, path);
6050 if (strcmp (r, expected) != 0) {
6051 fprintf (stderr, "test_upload_0: expected \"%s\" but got \"%s\"\n", expected, r);
6059 static int test_blockdev_rereadpt_0_skip (void)
6063 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT_0");
6064 if (str && strcmp (str, "1") == 0) return 1;
6065 str = getenv ("SKIP_TEST_BLOCKDEV_REREADPT");
6066 if (str && strcmp (str, "1") == 0) return 1;
6070 static int test_blockdev_rereadpt_0 (void)
6072 if (test_blockdev_rereadpt_0_skip ()) {
6073 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_rereadpt_0");
6077 /* InitNone|InitEmpty for test_blockdev_rereadpt_0 */
6079 char device[] = "/dev/sda";
6080 device[5] = devchar;
6083 r = guestfs_blockdev_setrw (g, device);
6090 r = guestfs_umount_all (g);
6097 r = guestfs_lvm_remove_all (g);
6101 /* TestRun for blockdev_rereadpt (0) */
6103 char device[] = "/dev/sda";
6104 device[5] = devchar;
6107 r = guestfs_blockdev_rereadpt (g, device);
6114 static int test_blockdev_flushbufs_0_skip (void)
6118 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS_0");
6119 if (str && strcmp (str, "1") == 0) return 1;
6120 str = getenv ("SKIP_TEST_BLOCKDEV_FLUSHBUFS");
6121 if (str && strcmp (str, "1") == 0) return 1;
6125 static int test_blockdev_flushbufs_0 (void)
6127 if (test_blockdev_flushbufs_0_skip ()) {
6128 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_flushbufs_0");
6132 /* InitNone|InitEmpty for test_blockdev_flushbufs_0 */
6134 char device[] = "/dev/sda";
6135 device[5] = devchar;
6138 r = guestfs_blockdev_setrw (g, device);
6145 r = guestfs_umount_all (g);
6152 r = guestfs_lvm_remove_all (g);
6156 /* TestRun for blockdev_flushbufs (0) */
6158 char device[] = "/dev/sda";
6159 device[5] = devchar;
6162 r = guestfs_blockdev_flushbufs (g, device);
6169 static int test_blockdev_getsize64_0_skip (void)
6173 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64_0");
6174 if (str && strcmp (str, "1") == 0) return 1;
6175 str = getenv ("SKIP_TEST_BLOCKDEV_GETSIZE64");
6176 if (str && strcmp (str, "1") == 0) return 1;
6180 static int test_blockdev_getsize64_0 (void)
6182 if (test_blockdev_getsize64_0_skip ()) {
6183 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsize64_0");
6187 /* InitNone|InitEmpty for test_blockdev_getsize64_0 */
6189 char device[] = "/dev/sda";
6190 device[5] = devchar;
6193 r = guestfs_blockdev_setrw (g, device);
6200 r = guestfs_umount_all (g);
6207 r = guestfs_lvm_remove_all (g);
6211 /* TestOutputInt for blockdev_getsize64 (0) */
6213 char device[] = "/dev/sda";
6214 device[5] = devchar;
6217 r = guestfs_blockdev_getsize64 (g, device);
6220 if (r != 524288000) {
6221 fprintf (stderr, "test_blockdev_getsize64_0: expected 524288000 but got %d\n", (int) r);
6228 static int test_blockdev_getsz_0_skip (void)
6232 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ_0");
6233 if (str && strcmp (str, "1") == 0) return 1;
6234 str = getenv ("SKIP_TEST_BLOCKDEV_GETSZ");
6235 if (str && strcmp (str, "1") == 0) return 1;
6239 static int test_blockdev_getsz_0 (void)
6241 if (test_blockdev_getsz_0_skip ()) {
6242 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getsz_0");
6246 /* InitNone|InitEmpty for test_blockdev_getsz_0 */
6248 char device[] = "/dev/sda";
6249 device[5] = devchar;
6252 r = guestfs_blockdev_setrw (g, device);
6259 r = guestfs_umount_all (g);
6266 r = guestfs_lvm_remove_all (g);
6270 /* TestOutputInt for blockdev_getsz (0) */
6272 char device[] = "/dev/sda";
6273 device[5] = devchar;
6276 r = guestfs_blockdev_getsz (g, device);
6280 fprintf (stderr, "test_blockdev_getsz_0: expected 1024000 but got %d\n", (int) r);
6287 static int test_blockdev_getbsz_0_skip (void)
6291 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ_0");
6292 if (str && strcmp (str, "1") == 0) return 1;
6293 str = getenv ("SKIP_TEST_BLOCKDEV_GETBSZ");
6294 if (str && strcmp (str, "1") == 0) return 1;
6298 static int test_blockdev_getbsz_0 (void)
6300 if (test_blockdev_getbsz_0_skip ()) {
6301 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getbsz_0");
6305 /* InitNone|InitEmpty for test_blockdev_getbsz_0 */
6307 char device[] = "/dev/sda";
6308 device[5] = devchar;
6311 r = guestfs_blockdev_setrw (g, device);
6318 r = guestfs_umount_all (g);
6325 r = guestfs_lvm_remove_all (g);
6329 /* TestOutputInt for blockdev_getbsz (0) */
6331 char device[] = "/dev/sda";
6332 device[5] = devchar;
6335 r = guestfs_blockdev_getbsz (g, device);
6339 fprintf (stderr, "test_blockdev_getbsz_0: expected 4096 but got %d\n", (int) r);
6346 static int test_blockdev_getss_0_skip (void)
6350 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS_0");
6351 if (str && strcmp (str, "1") == 0) return 1;
6352 str = getenv ("SKIP_TEST_BLOCKDEV_GETSS");
6353 if (str && strcmp (str, "1") == 0) return 1;
6357 static int test_blockdev_getss_0 (void)
6359 if (test_blockdev_getss_0_skip ()) {
6360 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getss_0");
6364 /* InitNone|InitEmpty for test_blockdev_getss_0 */
6366 char device[] = "/dev/sda";
6367 device[5] = devchar;
6370 r = guestfs_blockdev_setrw (g, device);
6377 r = guestfs_umount_all (g);
6384 r = guestfs_lvm_remove_all (g);
6388 /* TestOutputInt for blockdev_getss (0) */
6390 char device[] = "/dev/sda";
6391 device[5] = devchar;
6394 r = guestfs_blockdev_getss (g, device);
6398 fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r);
6405 static int test_blockdev_getro_0_skip (void)
6409 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO_0");
6410 if (str && strcmp (str, "1") == 0) return 1;
6411 str = getenv ("SKIP_TEST_BLOCKDEV_GETRO");
6412 if (str && strcmp (str, "1") == 0) return 1;
6416 static int test_blockdev_getro_0 (void)
6418 if (test_blockdev_getro_0_skip ()) {
6419 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_getro_0");
6423 /* InitNone|InitEmpty for test_blockdev_getro_0 */
6425 char device[] = "/dev/sda";
6426 device[5] = devchar;
6429 r = guestfs_blockdev_setrw (g, device);
6436 r = guestfs_umount_all (g);
6443 r = guestfs_lvm_remove_all (g);
6447 /* TestOutputTrue for blockdev_getro (0) */
6449 char device[] = "/dev/sda";
6450 device[5] = devchar;
6453 r = guestfs_blockdev_setro (g, device);
6458 char device[] = "/dev/sda";
6459 device[5] = devchar;
6462 r = guestfs_blockdev_getro (g, device);
6466 fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n");
6473 static int test_blockdev_setrw_0_skip (void)
6477 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW_0");
6478 if (str && strcmp (str, "1") == 0) return 1;
6479 str = getenv ("SKIP_TEST_BLOCKDEV_SETRW");
6480 if (str && strcmp (str, "1") == 0) return 1;
6484 static int test_blockdev_setrw_0 (void)
6486 if (test_blockdev_setrw_0_skip ()) {
6487 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setrw_0");
6491 /* InitNone|InitEmpty for test_blockdev_setrw_0 */
6493 char device[] = "/dev/sda";
6494 device[5] = devchar;
6497 r = guestfs_blockdev_setrw (g, device);
6504 r = guestfs_umount_all (g);
6511 r = guestfs_lvm_remove_all (g);
6515 /* TestOutputFalse for blockdev_setrw (0) */
6517 char device[] = "/dev/sda";
6518 device[5] = devchar;
6521 r = guestfs_blockdev_setrw (g, device);
6526 char device[] = "/dev/sda";
6527 device[5] = devchar;
6530 r = guestfs_blockdev_getro (g, device);
6534 fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n");
6541 static int test_blockdev_setro_0_skip (void)
6545 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO_0");
6546 if (str && strcmp (str, "1") == 0) return 1;
6547 str = getenv ("SKIP_TEST_BLOCKDEV_SETRO");
6548 if (str && strcmp (str, "1") == 0) return 1;
6552 static int test_blockdev_setro_0 (void)
6554 if (test_blockdev_setro_0_skip ()) {
6555 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_blockdev_setro_0");
6559 /* InitNone|InitEmpty for test_blockdev_setro_0 */
6561 char device[] = "/dev/sda";
6562 device[5] = devchar;
6565 r = guestfs_blockdev_setrw (g, device);
6572 r = guestfs_umount_all (g);
6579 r = guestfs_lvm_remove_all (g);
6583 /* TestOutputTrue for blockdev_setro (0) */
6585 char device[] = "/dev/sda";
6586 device[5] = devchar;
6589 r = guestfs_blockdev_setro (g, device);
6594 char device[] = "/dev/sda";
6595 device[5] = devchar;
6598 r = guestfs_blockdev_getro (g, device);
6602 fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n");
6609 static int test_statvfs_0_skip (void)
6613 str = getenv ("SKIP_TEST_STATVFS_0");
6614 if (str && strcmp (str, "1") == 0) return 1;
6615 str = getenv ("SKIP_TEST_STATVFS");
6616 if (str && strcmp (str, "1") == 0) return 1;
6620 static int test_statvfs_0 (void)
6622 if (test_statvfs_0_skip ()) {
6623 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_statvfs_0");
6627 /* InitBasicFS for test_statvfs_0: create ext2 on /dev/sda1 */
6629 char device[] = "/dev/sda";
6630 device[5] = devchar;
6633 r = guestfs_blockdev_setrw (g, device);
6640 r = guestfs_umount_all (g);
6647 r = guestfs_lvm_remove_all (g);
6652 char device[] = "/dev/sda";
6653 device[5] = devchar;
6654 char lines_0[] = ",";
6661 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6666 char fstype[] = "ext2";
6667 char device[] = "/dev/sda1";
6668 device[5] = devchar;
6671 r = guestfs_mkfs (g, fstype, device);
6676 char device[] = "/dev/sda1";
6677 device[5] = devchar;
6678 char mountpoint[] = "/";
6681 r = guestfs_mount (g, device, mountpoint);
6685 /* TestOutputStruct for statvfs (0) */
6688 struct guestfs_statvfs *r;
6690 r = guestfs_statvfs (g, path);
6693 if (r->bfree != 487702) {
6694 fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n",
6698 if (r->blocks != 490020) {
6699 fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n",
6703 if (r->bsize != 1024) {
6704 fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n",
6713 static int test_lstat_0_skip (void)
6717 str = getenv ("SKIP_TEST_LSTAT_0");
6718 if (str && strcmp (str, "1") == 0) return 1;
6719 str = getenv ("SKIP_TEST_LSTAT");
6720 if (str && strcmp (str, "1") == 0) return 1;
6724 static int test_lstat_0 (void)
6726 if (test_lstat_0_skip ()) {
6727 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lstat_0");
6731 /* InitBasicFS for test_lstat_0: create ext2 on /dev/sda1 */
6733 char device[] = "/dev/sda";
6734 device[5] = devchar;
6737 r = guestfs_blockdev_setrw (g, device);
6744 r = guestfs_umount_all (g);
6751 r = guestfs_lvm_remove_all (g);
6756 char device[] = "/dev/sda";
6757 device[5] = devchar;
6758 char lines_0[] = ",";
6765 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6770 char fstype[] = "ext2";
6771 char device[] = "/dev/sda1";
6772 device[5] = devchar;
6775 r = guestfs_mkfs (g, fstype, device);
6780 char device[] = "/dev/sda1";
6781 device[5] = devchar;
6782 char mountpoint[] = "/";
6785 r = guestfs_mount (g, device, mountpoint);
6789 /* TestOutputStruct for lstat (0) */
6791 char path[] = "/new";
6794 r = guestfs_touch (g, path);
6799 char path[] = "/new";
6800 struct guestfs_stat *r;
6802 r = guestfs_lstat (g, path);
6806 fprintf (stderr, "test_lstat_0: size was %d, expected 0\n",
6815 static int test_stat_0_skip (void)
6819 str = getenv ("SKIP_TEST_STAT_0");
6820 if (str && strcmp (str, "1") == 0) return 1;
6821 str = getenv ("SKIP_TEST_STAT");
6822 if (str && strcmp (str, "1") == 0) return 1;
6826 static int test_stat_0 (void)
6828 if (test_stat_0_skip ()) {
6829 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_stat_0");
6833 /* InitBasicFS for test_stat_0: create ext2 on /dev/sda1 */
6835 char device[] = "/dev/sda";
6836 device[5] = devchar;
6839 r = guestfs_blockdev_setrw (g, device);
6846 r = guestfs_umount_all (g);
6853 r = guestfs_lvm_remove_all (g);
6858 char device[] = "/dev/sda";
6859 device[5] = devchar;
6860 char lines_0[] = ",";
6867 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6872 char fstype[] = "ext2";
6873 char device[] = "/dev/sda1";
6874 device[5] = devchar;
6877 r = guestfs_mkfs (g, fstype, device);
6882 char device[] = "/dev/sda1";
6883 device[5] = devchar;
6884 char mountpoint[] = "/";
6887 r = guestfs_mount (g, device, mountpoint);
6891 /* TestOutputStruct for stat (0) */
6893 char path[] = "/new";
6896 r = guestfs_touch (g, path);
6901 char path[] = "/new";
6902 struct guestfs_stat *r;
6904 r = guestfs_stat (g, path);
6908 fprintf (stderr, "test_stat_0: size was %d, expected 0\n",
6917 static int test_command_lines_0_skip (void)
6921 str = getenv ("SKIP_TEST_COMMAND_LINES_0");
6922 if (str && strcmp (str, "1") == 0) return 1;
6923 str = getenv ("SKIP_TEST_COMMAND_LINES");
6924 if (str && strcmp (str, "1") == 0) return 1;
6928 static int test_command_lines_0 (void)
6930 if (test_command_lines_0_skip ()) {
6931 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_0");
6935 /* InitBasicFS for test_command_lines_0: create ext2 on /dev/sda1 */
6937 char device[] = "/dev/sda";
6938 device[5] = devchar;
6941 r = guestfs_blockdev_setrw (g, device);
6948 r = guestfs_umount_all (g);
6955 r = guestfs_lvm_remove_all (g);
6960 char device[] = "/dev/sda";
6961 device[5] = devchar;
6962 char lines_0[] = ",";
6969 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
6974 char fstype[] = "ext2";
6975 char device[] = "/dev/sda1";
6976 device[5] = devchar;
6979 r = guestfs_mkfs (g, fstype, device);
6984 char device[] = "/dev/sda1";
6985 device[5] = devchar;
6986 char mountpoint[] = "/";
6989 r = guestfs_mount (g, device, mountpoint);
6993 /* TestOutputList for command_lines (0) */
6995 char remotefilename[] = "/test-command";
6998 r = guestfs_upload (g, "test-command", remotefilename);
7003 char path[] = "/test-command";
7006 r = guestfs_chmod (g, 493, path);
7011 char arguments_0[] = "/test-command";
7012 char arguments_1[] = "1";
7013 char *arguments[] = {
7021 r = guestfs_command_lines (g, arguments);
7025 fprintf (stderr, "test_command_lines_0: short list returned from command\n");
7030 char expected[] = "Result1";
7031 if (strcmp (r[0], expected) != 0) {
7032 fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7037 fprintf (stderr, "test_command_lines_0: extra elements returned from command\n");
7041 for (i = 0; r[i] != NULL; ++i)
7048 static int test_command_lines_1_skip (void)
7052 str = getenv ("SKIP_TEST_COMMAND_LINES_1");
7053 if (str && strcmp (str, "1") == 0) return 1;
7054 str = getenv ("SKIP_TEST_COMMAND_LINES");
7055 if (str && strcmp (str, "1") == 0) return 1;
7059 static int test_command_lines_1 (void)
7061 if (test_command_lines_1_skip ()) {
7062 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_1");
7066 /* InitBasicFS for test_command_lines_1: create ext2 on /dev/sda1 */
7068 char device[] = "/dev/sda";
7069 device[5] = devchar;
7072 r = guestfs_blockdev_setrw (g, device);
7079 r = guestfs_umount_all (g);
7086 r = guestfs_lvm_remove_all (g);
7091 char device[] = "/dev/sda";
7092 device[5] = devchar;
7093 char lines_0[] = ",";
7100 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7105 char fstype[] = "ext2";
7106 char device[] = "/dev/sda1";
7107 device[5] = devchar;
7110 r = guestfs_mkfs (g, fstype, device);
7115 char device[] = "/dev/sda1";
7116 device[5] = devchar;
7117 char mountpoint[] = "/";
7120 r = guestfs_mount (g, device, mountpoint);
7124 /* TestOutputList for command_lines (1) */
7126 char remotefilename[] = "/test-command";
7129 r = guestfs_upload (g, "test-command", remotefilename);
7134 char path[] = "/test-command";
7137 r = guestfs_chmod (g, 493, path);
7142 char arguments_0[] = "/test-command";
7143 char arguments_1[] = "2";
7144 char *arguments[] = {
7152 r = guestfs_command_lines (g, arguments);
7156 fprintf (stderr, "test_command_lines_1: short list returned from command\n");
7161 char expected[] = "Result2";
7162 if (strcmp (r[0], expected) != 0) {
7163 fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7168 fprintf (stderr, "test_command_lines_1: extra elements returned from command\n");
7172 for (i = 0; r[i] != NULL; ++i)
7179 static int test_command_lines_2_skip (void)
7183 str = getenv ("SKIP_TEST_COMMAND_LINES_2");
7184 if (str && strcmp (str, "1") == 0) return 1;
7185 str = getenv ("SKIP_TEST_COMMAND_LINES");
7186 if (str && strcmp (str, "1") == 0) return 1;
7190 static int test_command_lines_2 (void)
7192 if (test_command_lines_2_skip ()) {
7193 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_2");
7197 /* InitBasicFS for test_command_lines_2: create ext2 on /dev/sda1 */
7199 char device[] = "/dev/sda";
7200 device[5] = devchar;
7203 r = guestfs_blockdev_setrw (g, device);
7210 r = guestfs_umount_all (g);
7217 r = guestfs_lvm_remove_all (g);
7222 char device[] = "/dev/sda";
7223 device[5] = devchar;
7224 char lines_0[] = ",";
7231 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7236 char fstype[] = "ext2";
7237 char device[] = "/dev/sda1";
7238 device[5] = devchar;
7241 r = guestfs_mkfs (g, fstype, device);
7246 char device[] = "/dev/sda1";
7247 device[5] = devchar;
7248 char mountpoint[] = "/";
7251 r = guestfs_mount (g, device, mountpoint);
7255 /* TestOutputList for command_lines (2) */
7257 char remotefilename[] = "/test-command";
7260 r = guestfs_upload (g, "test-command", remotefilename);
7265 char path[] = "/test-command";
7268 r = guestfs_chmod (g, 493, path);
7273 char arguments_0[] = "/test-command";
7274 char arguments_1[] = "3";
7275 char *arguments[] = {
7283 r = guestfs_command_lines (g, arguments);
7287 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7292 char expected[] = "";
7293 if (strcmp (r[0], expected) != 0) {
7294 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7299 fprintf (stderr, "test_command_lines_2: short list returned from command\n");
7304 char expected[] = "Result3";
7305 if (strcmp (r[1], expected) != 0) {
7306 fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7311 fprintf (stderr, "test_command_lines_2: extra elements returned from command\n");
7315 for (i = 0; r[i] != NULL; ++i)
7322 static int test_command_lines_3_skip (void)
7326 str = getenv ("SKIP_TEST_COMMAND_LINES_3");
7327 if (str && strcmp (str, "1") == 0) return 1;
7328 str = getenv ("SKIP_TEST_COMMAND_LINES");
7329 if (str && strcmp (str, "1") == 0) return 1;
7333 static int test_command_lines_3 (void)
7335 if (test_command_lines_3_skip ()) {
7336 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_3");
7340 /* InitBasicFS for test_command_lines_3: create ext2 on /dev/sda1 */
7342 char device[] = "/dev/sda";
7343 device[5] = devchar;
7346 r = guestfs_blockdev_setrw (g, device);
7353 r = guestfs_umount_all (g);
7360 r = guestfs_lvm_remove_all (g);
7365 char device[] = "/dev/sda";
7366 device[5] = devchar;
7367 char lines_0[] = ",";
7374 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7379 char fstype[] = "ext2";
7380 char device[] = "/dev/sda1";
7381 device[5] = devchar;
7384 r = guestfs_mkfs (g, fstype, device);
7389 char device[] = "/dev/sda1";
7390 device[5] = devchar;
7391 char mountpoint[] = "/";
7394 r = guestfs_mount (g, device, mountpoint);
7398 /* TestOutputList for command_lines (3) */
7400 char remotefilename[] = "/test-command";
7403 r = guestfs_upload (g, "test-command", remotefilename);
7408 char path[] = "/test-command";
7411 r = guestfs_chmod (g, 493, path);
7416 char arguments_0[] = "/test-command";
7417 char arguments_1[] = "4";
7418 char *arguments[] = {
7426 r = guestfs_command_lines (g, arguments);
7430 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
7435 char expected[] = "";
7436 if (strcmp (r[0], expected) != 0) {
7437 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7442 fprintf (stderr, "test_command_lines_3: short list returned from command\n");
7447 char expected[] = "Result4";
7448 if (strcmp (r[1], expected) != 0) {
7449 fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7454 fprintf (stderr, "test_command_lines_3: extra elements returned from command\n");
7458 for (i = 0; r[i] != NULL; ++i)
7465 static int test_command_lines_4_skip (void)
7469 str = getenv ("SKIP_TEST_COMMAND_LINES_4");
7470 if (str && strcmp (str, "1") == 0) return 1;
7471 str = getenv ("SKIP_TEST_COMMAND_LINES");
7472 if (str && strcmp (str, "1") == 0) return 1;
7476 static int test_command_lines_4 (void)
7478 if (test_command_lines_4_skip ()) {
7479 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_4");
7483 /* InitBasicFS for test_command_lines_4: create ext2 on /dev/sda1 */
7485 char device[] = "/dev/sda";
7486 device[5] = devchar;
7489 r = guestfs_blockdev_setrw (g, device);
7496 r = guestfs_umount_all (g);
7503 r = guestfs_lvm_remove_all (g);
7508 char device[] = "/dev/sda";
7509 device[5] = devchar;
7510 char lines_0[] = ",";
7517 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7522 char fstype[] = "ext2";
7523 char device[] = "/dev/sda1";
7524 device[5] = devchar;
7527 r = guestfs_mkfs (g, fstype, device);
7532 char device[] = "/dev/sda1";
7533 device[5] = devchar;
7534 char mountpoint[] = "/";
7537 r = guestfs_mount (g, device, mountpoint);
7541 /* TestOutputList for command_lines (4) */
7543 char remotefilename[] = "/test-command";
7546 r = guestfs_upload (g, "test-command", remotefilename);
7551 char path[] = "/test-command";
7554 r = guestfs_chmod (g, 493, path);
7559 char arguments_0[] = "/test-command";
7560 char arguments_1[] = "5";
7561 char *arguments[] = {
7569 r = guestfs_command_lines (g, arguments);
7573 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7578 char expected[] = "";
7579 if (strcmp (r[0], expected) != 0) {
7580 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7585 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7590 char expected[] = "Result5";
7591 if (strcmp (r[1], expected) != 0) {
7592 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7597 fprintf (stderr, "test_command_lines_4: short list returned from command\n");
7602 char expected[] = "";
7603 if (strcmp (r[2], expected) != 0) {
7604 fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]);
7609 fprintf (stderr, "test_command_lines_4: extra elements returned from command\n");
7613 for (i = 0; r[i] != NULL; ++i)
7620 static int test_command_lines_5_skip (void)
7624 str = getenv ("SKIP_TEST_COMMAND_LINES_5");
7625 if (str && strcmp (str, "1") == 0) return 1;
7626 str = getenv ("SKIP_TEST_COMMAND_LINES");
7627 if (str && strcmp (str, "1") == 0) return 1;
7631 static int test_command_lines_5 (void)
7633 if (test_command_lines_5_skip ()) {
7634 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_5");
7638 /* InitBasicFS for test_command_lines_5: create ext2 on /dev/sda1 */
7640 char device[] = "/dev/sda";
7641 device[5] = devchar;
7644 r = guestfs_blockdev_setrw (g, device);
7651 r = guestfs_umount_all (g);
7658 r = guestfs_lvm_remove_all (g);
7663 char device[] = "/dev/sda";
7664 device[5] = devchar;
7665 char lines_0[] = ",";
7672 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7677 char fstype[] = "ext2";
7678 char device[] = "/dev/sda1";
7679 device[5] = devchar;
7682 r = guestfs_mkfs (g, fstype, device);
7687 char device[] = "/dev/sda1";
7688 device[5] = devchar;
7689 char mountpoint[] = "/";
7692 r = guestfs_mount (g, device, mountpoint);
7696 /* TestOutputList for command_lines (5) */
7698 char remotefilename[] = "/test-command";
7701 r = guestfs_upload (g, "test-command", remotefilename);
7706 char path[] = "/test-command";
7709 r = guestfs_chmod (g, 493, path);
7714 char arguments_0[] = "/test-command";
7715 char arguments_1[] = "6";
7716 char *arguments[] = {
7724 r = guestfs_command_lines (g, arguments);
7728 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7733 char expected[] = "";
7734 if (strcmp (r[0], expected) != 0) {
7735 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]);
7740 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7745 char expected[] = "";
7746 if (strcmp (r[1], expected) != 0) {
7747 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]);
7752 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7757 char expected[] = "Result6";
7758 if (strcmp (r[2], expected) != 0) {
7759 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]);
7764 fprintf (stderr, "test_command_lines_5: short list returned from command\n");
7769 char expected[] = "";
7770 if (strcmp (r[3], expected) != 0) {
7771 fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]);
7776 fprintf (stderr, "test_command_lines_5: extra elements returned from command\n");
7780 for (i = 0; r[i] != NULL; ++i)
7787 static int test_command_lines_6_skip (void)
7791 str = getenv ("SKIP_TEST_COMMAND_LINES_6");
7792 if (str && strcmp (str, "1") == 0) return 1;
7793 str = getenv ("SKIP_TEST_COMMAND_LINES");
7794 if (str && strcmp (str, "1") == 0) return 1;
7798 static int test_command_lines_6 (void)
7800 if (test_command_lines_6_skip ()) {
7801 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_6");
7805 /* InitBasicFS for test_command_lines_6: create ext2 on /dev/sda1 */
7807 char device[] = "/dev/sda";
7808 device[5] = devchar;
7811 r = guestfs_blockdev_setrw (g, device);
7818 r = guestfs_umount_all (g);
7825 r = guestfs_lvm_remove_all (g);
7830 char device[] = "/dev/sda";
7831 device[5] = devchar;
7832 char lines_0[] = ",";
7839 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7844 char fstype[] = "ext2";
7845 char device[] = "/dev/sda1";
7846 device[5] = devchar;
7849 r = guestfs_mkfs (g, fstype, device);
7854 char device[] = "/dev/sda1";
7855 device[5] = devchar;
7856 char mountpoint[] = "/";
7859 r = guestfs_mount (g, device, mountpoint);
7863 /* TestOutputList for command_lines (6) */
7865 char remotefilename[] = "/test-command";
7868 r = guestfs_upload (g, "test-command", remotefilename);
7873 char path[] = "/test-command";
7876 r = guestfs_chmod (g, 493, path);
7881 char arguments_0[] = "/test-command";
7882 char arguments_1[] = "7";
7883 char *arguments[] = {
7891 r = guestfs_command_lines (g, arguments);
7895 fprintf (stderr, "test_command_lines_6: extra elements returned from command\n");
7899 for (i = 0; r[i] != NULL; ++i)
7906 static int test_command_lines_7_skip (void)
7910 str = getenv ("SKIP_TEST_COMMAND_LINES_7");
7911 if (str && strcmp (str, "1") == 0) return 1;
7912 str = getenv ("SKIP_TEST_COMMAND_LINES");
7913 if (str && strcmp (str, "1") == 0) return 1;
7917 static int test_command_lines_7 (void)
7919 if (test_command_lines_7_skip ()) {
7920 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_7");
7924 /* InitBasicFS for test_command_lines_7: create ext2 on /dev/sda1 */
7926 char device[] = "/dev/sda";
7927 device[5] = devchar;
7930 r = guestfs_blockdev_setrw (g, device);
7937 r = guestfs_umount_all (g);
7944 r = guestfs_lvm_remove_all (g);
7949 char device[] = "/dev/sda";
7950 device[5] = devchar;
7951 char lines_0[] = ",";
7958 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
7963 char fstype[] = "ext2";
7964 char device[] = "/dev/sda1";
7965 device[5] = devchar;
7968 r = guestfs_mkfs (g, fstype, device);
7973 char device[] = "/dev/sda1";
7974 device[5] = devchar;
7975 char mountpoint[] = "/";
7978 r = guestfs_mount (g, device, mountpoint);
7982 /* TestOutputList for command_lines (7) */
7984 char remotefilename[] = "/test-command";
7987 r = guestfs_upload (g, "test-command", remotefilename);
7992 char path[] = "/test-command";
7995 r = guestfs_chmod (g, 493, path);
8000 char arguments_0[] = "/test-command";
8001 char arguments_1[] = "8";
8002 char *arguments[] = {
8010 r = guestfs_command_lines (g, arguments);
8014 fprintf (stderr, "test_command_lines_7: short list returned from command\n");
8019 char expected[] = "";
8020 if (strcmp (r[0], expected) != 0) {
8021 fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8026 fprintf (stderr, "test_command_lines_7: extra elements returned from command\n");
8030 for (i = 0; r[i] != NULL; ++i)
8037 static int test_command_lines_8_skip (void)
8041 str = getenv ("SKIP_TEST_COMMAND_LINES_8");
8042 if (str && strcmp (str, "1") == 0) return 1;
8043 str = getenv ("SKIP_TEST_COMMAND_LINES");
8044 if (str && strcmp (str, "1") == 0) return 1;
8048 static int test_command_lines_8 (void)
8050 if (test_command_lines_8_skip ()) {
8051 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_8");
8055 /* InitBasicFS for test_command_lines_8: create ext2 on /dev/sda1 */
8057 char device[] = "/dev/sda";
8058 device[5] = devchar;
8061 r = guestfs_blockdev_setrw (g, device);
8068 r = guestfs_umount_all (g);
8075 r = guestfs_lvm_remove_all (g);
8080 char device[] = "/dev/sda";
8081 device[5] = devchar;
8082 char lines_0[] = ",";
8089 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8094 char fstype[] = "ext2";
8095 char device[] = "/dev/sda1";
8096 device[5] = devchar;
8099 r = guestfs_mkfs (g, fstype, device);
8104 char device[] = "/dev/sda1";
8105 device[5] = devchar;
8106 char mountpoint[] = "/";
8109 r = guestfs_mount (g, device, mountpoint);
8113 /* TestOutputList for command_lines (8) */
8115 char remotefilename[] = "/test-command";
8118 r = guestfs_upload (g, "test-command", remotefilename);
8123 char path[] = "/test-command";
8126 r = guestfs_chmod (g, 493, path);
8131 char arguments_0[] = "/test-command";
8132 char arguments_1[] = "9";
8133 char *arguments[] = {
8141 r = guestfs_command_lines (g, arguments);
8145 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8150 char expected[] = "";
8151 if (strcmp (r[0], expected) != 0) {
8152 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8157 fprintf (stderr, "test_command_lines_8: short list returned from command\n");
8162 char expected[] = "";
8163 if (strcmp (r[1], expected) != 0) {
8164 fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8169 fprintf (stderr, "test_command_lines_8: extra elements returned from command\n");
8173 for (i = 0; r[i] != NULL; ++i)
8180 static int test_command_lines_9_skip (void)
8184 str = getenv ("SKIP_TEST_COMMAND_LINES_9");
8185 if (str && strcmp (str, "1") == 0) return 1;
8186 str = getenv ("SKIP_TEST_COMMAND_LINES");
8187 if (str && strcmp (str, "1") == 0) return 1;
8191 static int test_command_lines_9 (void)
8193 if (test_command_lines_9_skip ()) {
8194 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_9");
8198 /* InitBasicFS for test_command_lines_9: create ext2 on /dev/sda1 */
8200 char device[] = "/dev/sda";
8201 device[5] = devchar;
8204 r = guestfs_blockdev_setrw (g, device);
8211 r = guestfs_umount_all (g);
8218 r = guestfs_lvm_remove_all (g);
8223 char device[] = "/dev/sda";
8224 device[5] = devchar;
8225 char lines_0[] = ",";
8232 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8237 char fstype[] = "ext2";
8238 char device[] = "/dev/sda1";
8239 device[5] = devchar;
8242 r = guestfs_mkfs (g, fstype, device);
8247 char device[] = "/dev/sda1";
8248 device[5] = devchar;
8249 char mountpoint[] = "/";
8252 r = guestfs_mount (g, device, mountpoint);
8256 /* TestOutputList for command_lines (9) */
8258 char remotefilename[] = "/test-command";
8261 r = guestfs_upload (g, "test-command", remotefilename);
8266 char path[] = "/test-command";
8269 r = guestfs_chmod (g, 493, path);
8274 char arguments_0[] = "/test-command";
8275 char arguments_1[] = "10";
8276 char *arguments[] = {
8284 r = guestfs_command_lines (g, arguments);
8288 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8293 char expected[] = "Result10-1";
8294 if (strcmp (r[0], expected) != 0) {
8295 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8300 fprintf (stderr, "test_command_lines_9: short list returned from command\n");
8305 char expected[] = "Result10-2";
8306 if (strcmp (r[1], expected) != 0) {
8307 fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8312 fprintf (stderr, "test_command_lines_9: extra elements returned from command\n");
8316 for (i = 0; r[i] != NULL; ++i)
8323 static int test_command_lines_10_skip (void)
8327 str = getenv ("SKIP_TEST_COMMAND_LINES_10");
8328 if (str && strcmp (str, "1") == 0) return 1;
8329 str = getenv ("SKIP_TEST_COMMAND_LINES");
8330 if (str && strcmp (str, "1") == 0) return 1;
8334 static int test_command_lines_10 (void)
8336 if (test_command_lines_10_skip ()) {
8337 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_lines_10");
8341 /* InitBasicFS for test_command_lines_10: create ext2 on /dev/sda1 */
8343 char device[] = "/dev/sda";
8344 device[5] = devchar;
8347 r = guestfs_blockdev_setrw (g, device);
8354 r = guestfs_umount_all (g);
8361 r = guestfs_lvm_remove_all (g);
8366 char device[] = "/dev/sda";
8367 device[5] = devchar;
8368 char lines_0[] = ",";
8375 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8380 char fstype[] = "ext2";
8381 char device[] = "/dev/sda1";
8382 device[5] = devchar;
8385 r = guestfs_mkfs (g, fstype, device);
8390 char device[] = "/dev/sda1";
8391 device[5] = devchar;
8392 char mountpoint[] = "/";
8395 r = guestfs_mount (g, device, mountpoint);
8399 /* TestOutputList for command_lines (10) */
8401 char remotefilename[] = "/test-command";
8404 r = guestfs_upload (g, "test-command", remotefilename);
8409 char path[] = "/test-command";
8412 r = guestfs_chmod (g, 493, path);
8417 char arguments_0[] = "/test-command";
8418 char arguments_1[] = "11";
8419 char *arguments[] = {
8427 r = guestfs_command_lines (g, arguments);
8431 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
8436 char expected[] = "Result11-1";
8437 if (strcmp (r[0], expected) != 0) {
8438 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]);
8443 fprintf (stderr, "test_command_lines_10: short list returned from command\n");
8448 char expected[] = "Result11-2";
8449 if (strcmp (r[1], expected) != 0) {
8450 fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]);
8455 fprintf (stderr, "test_command_lines_10: extra elements returned from command\n");
8459 for (i = 0; r[i] != NULL; ++i)
8466 static int test_command_0_skip (void)
8470 str = getenv ("SKIP_TEST_COMMAND_0");
8471 if (str && strcmp (str, "1") == 0) return 1;
8472 str = getenv ("SKIP_TEST_COMMAND");
8473 if (str && strcmp (str, "1") == 0) return 1;
8477 static int test_command_0 (void)
8479 if (test_command_0_skip ()) {
8480 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_0");
8484 /* InitBasicFS for test_command_0: create ext2 on /dev/sda1 */
8486 char device[] = "/dev/sda";
8487 device[5] = devchar;
8490 r = guestfs_blockdev_setrw (g, device);
8497 r = guestfs_umount_all (g);
8504 r = guestfs_lvm_remove_all (g);
8509 char device[] = "/dev/sda";
8510 device[5] = devchar;
8511 char lines_0[] = ",";
8518 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8523 char fstype[] = "ext2";
8524 char device[] = "/dev/sda1";
8525 device[5] = devchar;
8528 r = guestfs_mkfs (g, fstype, device);
8533 char device[] = "/dev/sda1";
8534 device[5] = devchar;
8535 char mountpoint[] = "/";
8538 r = guestfs_mount (g, device, mountpoint);
8542 /* TestOutput for command (0) */
8543 char expected[] = "Result1";
8545 char remotefilename[] = "/test-command";
8548 r = guestfs_upload (g, "test-command", remotefilename);
8553 char path[] = "/test-command";
8556 r = guestfs_chmod (g, 493, path);
8561 char arguments_0[] = "/test-command";
8562 char arguments_1[] = "1";
8563 char *arguments[] = {
8570 r = guestfs_command (g, arguments);
8573 if (strcmp (r, expected) != 0) {
8574 fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r);
8582 static int test_command_1_skip (void)
8586 str = getenv ("SKIP_TEST_COMMAND_1");
8587 if (str && strcmp (str, "1") == 0) return 1;
8588 str = getenv ("SKIP_TEST_COMMAND");
8589 if (str && strcmp (str, "1") == 0) return 1;
8593 static int test_command_1 (void)
8595 if (test_command_1_skip ()) {
8596 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_1");
8600 /* InitBasicFS for test_command_1: create ext2 on /dev/sda1 */
8602 char device[] = "/dev/sda";
8603 device[5] = devchar;
8606 r = guestfs_blockdev_setrw (g, device);
8613 r = guestfs_umount_all (g);
8620 r = guestfs_lvm_remove_all (g);
8625 char device[] = "/dev/sda";
8626 device[5] = devchar;
8627 char lines_0[] = ",";
8634 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8639 char fstype[] = "ext2";
8640 char device[] = "/dev/sda1";
8641 device[5] = devchar;
8644 r = guestfs_mkfs (g, fstype, device);
8649 char device[] = "/dev/sda1";
8650 device[5] = devchar;
8651 char mountpoint[] = "/";
8654 r = guestfs_mount (g, device, mountpoint);
8658 /* TestOutput for command (1) */
8659 char expected[] = "Result2\n";
8661 char remotefilename[] = "/test-command";
8664 r = guestfs_upload (g, "test-command", remotefilename);
8669 char path[] = "/test-command";
8672 r = guestfs_chmod (g, 493, path);
8677 char arguments_0[] = "/test-command";
8678 char arguments_1[] = "2";
8679 char *arguments[] = {
8686 r = guestfs_command (g, arguments);
8689 if (strcmp (r, expected) != 0) {
8690 fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r);
8698 static int test_command_2_skip (void)
8702 str = getenv ("SKIP_TEST_COMMAND_2");
8703 if (str && strcmp (str, "1") == 0) return 1;
8704 str = getenv ("SKIP_TEST_COMMAND");
8705 if (str && strcmp (str, "1") == 0) return 1;
8709 static int test_command_2 (void)
8711 if (test_command_2_skip ()) {
8712 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_2");
8716 /* InitBasicFS for test_command_2: create ext2 on /dev/sda1 */
8718 char device[] = "/dev/sda";
8719 device[5] = devchar;
8722 r = guestfs_blockdev_setrw (g, device);
8729 r = guestfs_umount_all (g);
8736 r = guestfs_lvm_remove_all (g);
8741 char device[] = "/dev/sda";
8742 device[5] = devchar;
8743 char lines_0[] = ",";
8750 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8755 char fstype[] = "ext2";
8756 char device[] = "/dev/sda1";
8757 device[5] = devchar;
8760 r = guestfs_mkfs (g, fstype, device);
8765 char device[] = "/dev/sda1";
8766 device[5] = devchar;
8767 char mountpoint[] = "/";
8770 r = guestfs_mount (g, device, mountpoint);
8774 /* TestOutput for command (2) */
8775 char expected[] = "\nResult3";
8777 char remotefilename[] = "/test-command";
8780 r = guestfs_upload (g, "test-command", remotefilename);
8785 char path[] = "/test-command";
8788 r = guestfs_chmod (g, 493, path);
8793 char arguments_0[] = "/test-command";
8794 char arguments_1[] = "3";
8795 char *arguments[] = {
8802 r = guestfs_command (g, arguments);
8805 if (strcmp (r, expected) != 0) {
8806 fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r);
8814 static int test_command_3_skip (void)
8818 str = getenv ("SKIP_TEST_COMMAND_3");
8819 if (str && strcmp (str, "1") == 0) return 1;
8820 str = getenv ("SKIP_TEST_COMMAND");
8821 if (str && strcmp (str, "1") == 0) return 1;
8825 static int test_command_3 (void)
8827 if (test_command_3_skip ()) {
8828 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_3");
8832 /* InitBasicFS for test_command_3: create ext2 on /dev/sda1 */
8834 char device[] = "/dev/sda";
8835 device[5] = devchar;
8838 r = guestfs_blockdev_setrw (g, device);
8845 r = guestfs_umount_all (g);
8852 r = guestfs_lvm_remove_all (g);
8857 char device[] = "/dev/sda";
8858 device[5] = devchar;
8859 char lines_0[] = ",";
8866 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8871 char fstype[] = "ext2";
8872 char device[] = "/dev/sda1";
8873 device[5] = devchar;
8876 r = guestfs_mkfs (g, fstype, device);
8881 char device[] = "/dev/sda1";
8882 device[5] = devchar;
8883 char mountpoint[] = "/";
8886 r = guestfs_mount (g, device, mountpoint);
8890 /* TestOutput for command (3) */
8891 char expected[] = "\nResult4\n";
8893 char remotefilename[] = "/test-command";
8896 r = guestfs_upload (g, "test-command", remotefilename);
8901 char path[] = "/test-command";
8904 r = guestfs_chmod (g, 493, path);
8909 char arguments_0[] = "/test-command";
8910 char arguments_1[] = "4";
8911 char *arguments[] = {
8918 r = guestfs_command (g, arguments);
8921 if (strcmp (r, expected) != 0) {
8922 fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r);
8930 static int test_command_4_skip (void)
8934 str = getenv ("SKIP_TEST_COMMAND_4");
8935 if (str && strcmp (str, "1") == 0) return 1;
8936 str = getenv ("SKIP_TEST_COMMAND");
8937 if (str && strcmp (str, "1") == 0) return 1;
8941 static int test_command_4 (void)
8943 if (test_command_4_skip ()) {
8944 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_4");
8948 /* InitBasicFS for test_command_4: create ext2 on /dev/sda1 */
8950 char device[] = "/dev/sda";
8951 device[5] = devchar;
8954 r = guestfs_blockdev_setrw (g, device);
8961 r = guestfs_umount_all (g);
8968 r = guestfs_lvm_remove_all (g);
8973 char device[] = "/dev/sda";
8974 device[5] = devchar;
8975 char lines_0[] = ",";
8982 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
8987 char fstype[] = "ext2";
8988 char device[] = "/dev/sda1";
8989 device[5] = devchar;
8992 r = guestfs_mkfs (g, fstype, device);
8997 char device[] = "/dev/sda1";
8998 device[5] = devchar;
8999 char mountpoint[] = "/";
9002 r = guestfs_mount (g, device, mountpoint);
9006 /* TestOutput for command (4) */
9007 char expected[] = "\nResult5\n\n";
9009 char remotefilename[] = "/test-command";
9012 r = guestfs_upload (g, "test-command", remotefilename);
9017 char path[] = "/test-command";
9020 r = guestfs_chmod (g, 493, path);
9025 char arguments_0[] = "/test-command";
9026 char arguments_1[] = "5";
9027 char *arguments[] = {
9034 r = guestfs_command (g, arguments);
9037 if (strcmp (r, expected) != 0) {
9038 fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r);
9046 static int test_command_5_skip (void)
9050 str = getenv ("SKIP_TEST_COMMAND_5");
9051 if (str && strcmp (str, "1") == 0) return 1;
9052 str = getenv ("SKIP_TEST_COMMAND");
9053 if (str && strcmp (str, "1") == 0) return 1;
9057 static int test_command_5 (void)
9059 if (test_command_5_skip ()) {
9060 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_5");
9064 /* InitBasicFS for test_command_5: create ext2 on /dev/sda1 */
9066 char device[] = "/dev/sda";
9067 device[5] = devchar;
9070 r = guestfs_blockdev_setrw (g, device);
9077 r = guestfs_umount_all (g);
9084 r = guestfs_lvm_remove_all (g);
9089 char device[] = "/dev/sda";
9090 device[5] = devchar;
9091 char lines_0[] = ",";
9098 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9103 char fstype[] = "ext2";
9104 char device[] = "/dev/sda1";
9105 device[5] = devchar;
9108 r = guestfs_mkfs (g, fstype, device);
9113 char device[] = "/dev/sda1";
9114 device[5] = devchar;
9115 char mountpoint[] = "/";
9118 r = guestfs_mount (g, device, mountpoint);
9122 /* TestOutput for command (5) */
9123 char expected[] = "\n\nResult6\n\n";
9125 char remotefilename[] = "/test-command";
9128 r = guestfs_upload (g, "test-command", remotefilename);
9133 char path[] = "/test-command";
9136 r = guestfs_chmod (g, 493, path);
9141 char arguments_0[] = "/test-command";
9142 char arguments_1[] = "6";
9143 char *arguments[] = {
9150 r = guestfs_command (g, arguments);
9153 if (strcmp (r, expected) != 0) {
9154 fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r);
9162 static int test_command_6_skip (void)
9166 str = getenv ("SKIP_TEST_COMMAND_6");
9167 if (str && strcmp (str, "1") == 0) return 1;
9168 str = getenv ("SKIP_TEST_COMMAND");
9169 if (str && strcmp (str, "1") == 0) return 1;
9173 static int test_command_6 (void)
9175 if (test_command_6_skip ()) {
9176 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_6");
9180 /* InitBasicFS for test_command_6: create ext2 on /dev/sda1 */
9182 char device[] = "/dev/sda";
9183 device[5] = devchar;
9186 r = guestfs_blockdev_setrw (g, device);
9193 r = guestfs_umount_all (g);
9200 r = guestfs_lvm_remove_all (g);
9205 char device[] = "/dev/sda";
9206 device[5] = devchar;
9207 char lines_0[] = ",";
9214 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9219 char fstype[] = "ext2";
9220 char device[] = "/dev/sda1";
9221 device[5] = devchar;
9224 r = guestfs_mkfs (g, fstype, device);
9229 char device[] = "/dev/sda1";
9230 device[5] = devchar;
9231 char mountpoint[] = "/";
9234 r = guestfs_mount (g, device, mountpoint);
9238 /* TestOutput for command (6) */
9239 char expected[] = "";
9241 char remotefilename[] = "/test-command";
9244 r = guestfs_upload (g, "test-command", remotefilename);
9249 char path[] = "/test-command";
9252 r = guestfs_chmod (g, 493, path);
9257 char arguments_0[] = "/test-command";
9258 char arguments_1[] = "7";
9259 char *arguments[] = {
9266 r = guestfs_command (g, arguments);
9269 if (strcmp (r, expected) != 0) {
9270 fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r);
9278 static int test_command_7_skip (void)
9282 str = getenv ("SKIP_TEST_COMMAND_7");
9283 if (str && strcmp (str, "1") == 0) return 1;
9284 str = getenv ("SKIP_TEST_COMMAND");
9285 if (str && strcmp (str, "1") == 0) return 1;
9289 static int test_command_7 (void)
9291 if (test_command_7_skip ()) {
9292 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_7");
9296 /* InitBasicFS for test_command_7: create ext2 on /dev/sda1 */
9298 char device[] = "/dev/sda";
9299 device[5] = devchar;
9302 r = guestfs_blockdev_setrw (g, device);
9309 r = guestfs_umount_all (g);
9316 r = guestfs_lvm_remove_all (g);
9321 char device[] = "/dev/sda";
9322 device[5] = devchar;
9323 char lines_0[] = ",";
9330 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9335 char fstype[] = "ext2";
9336 char device[] = "/dev/sda1";
9337 device[5] = devchar;
9340 r = guestfs_mkfs (g, fstype, device);
9345 char device[] = "/dev/sda1";
9346 device[5] = devchar;
9347 char mountpoint[] = "/";
9350 r = guestfs_mount (g, device, mountpoint);
9354 /* TestOutput for command (7) */
9355 char expected[] = "\n";
9357 char remotefilename[] = "/test-command";
9360 r = guestfs_upload (g, "test-command", remotefilename);
9365 char path[] = "/test-command";
9368 r = guestfs_chmod (g, 493, path);
9373 char arguments_0[] = "/test-command";
9374 char arguments_1[] = "8";
9375 char *arguments[] = {
9382 r = guestfs_command (g, arguments);
9385 if (strcmp (r, expected) != 0) {
9386 fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r);
9394 static int test_command_8_skip (void)
9398 str = getenv ("SKIP_TEST_COMMAND_8");
9399 if (str && strcmp (str, "1") == 0) return 1;
9400 str = getenv ("SKIP_TEST_COMMAND");
9401 if (str && strcmp (str, "1") == 0) return 1;
9405 static int test_command_8 (void)
9407 if (test_command_8_skip ()) {
9408 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_8");
9412 /* InitBasicFS for test_command_8: create ext2 on /dev/sda1 */
9414 char device[] = "/dev/sda";
9415 device[5] = devchar;
9418 r = guestfs_blockdev_setrw (g, device);
9425 r = guestfs_umount_all (g);
9432 r = guestfs_lvm_remove_all (g);
9437 char device[] = "/dev/sda";
9438 device[5] = devchar;
9439 char lines_0[] = ",";
9446 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9451 char fstype[] = "ext2";
9452 char device[] = "/dev/sda1";
9453 device[5] = devchar;
9456 r = guestfs_mkfs (g, fstype, device);
9461 char device[] = "/dev/sda1";
9462 device[5] = devchar;
9463 char mountpoint[] = "/";
9466 r = guestfs_mount (g, device, mountpoint);
9470 /* TestOutput for command (8) */
9471 char expected[] = "\n\n";
9473 char remotefilename[] = "/test-command";
9476 r = guestfs_upload (g, "test-command", remotefilename);
9481 char path[] = "/test-command";
9484 r = guestfs_chmod (g, 493, path);
9489 char arguments_0[] = "/test-command";
9490 char arguments_1[] = "9";
9491 char *arguments[] = {
9498 r = guestfs_command (g, arguments);
9501 if (strcmp (r, expected) != 0) {
9502 fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r);
9510 static int test_command_9_skip (void)
9514 str = getenv ("SKIP_TEST_COMMAND_9");
9515 if (str && strcmp (str, "1") == 0) return 1;
9516 str = getenv ("SKIP_TEST_COMMAND");
9517 if (str && strcmp (str, "1") == 0) return 1;
9521 static int test_command_9 (void)
9523 if (test_command_9_skip ()) {
9524 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_9");
9528 /* InitBasicFS for test_command_9: create ext2 on /dev/sda1 */
9530 char device[] = "/dev/sda";
9531 device[5] = devchar;
9534 r = guestfs_blockdev_setrw (g, device);
9541 r = guestfs_umount_all (g);
9548 r = guestfs_lvm_remove_all (g);
9553 char device[] = "/dev/sda";
9554 device[5] = devchar;
9555 char lines_0[] = ",";
9562 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9567 char fstype[] = "ext2";
9568 char device[] = "/dev/sda1";
9569 device[5] = devchar;
9572 r = guestfs_mkfs (g, fstype, device);
9577 char device[] = "/dev/sda1";
9578 device[5] = devchar;
9579 char mountpoint[] = "/";
9582 r = guestfs_mount (g, device, mountpoint);
9586 /* TestOutput for command (9) */
9587 char expected[] = "Result10-1\nResult10-2\n";
9589 char remotefilename[] = "/test-command";
9592 r = guestfs_upload (g, "test-command", remotefilename);
9597 char path[] = "/test-command";
9600 r = guestfs_chmod (g, 493, path);
9605 char arguments_0[] = "/test-command";
9606 char arguments_1[] = "10";
9607 char *arguments[] = {
9614 r = guestfs_command (g, arguments);
9617 if (strcmp (r, expected) != 0) {
9618 fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r);
9626 static int test_command_10_skip (void)
9630 str = getenv ("SKIP_TEST_COMMAND_10");
9631 if (str && strcmp (str, "1") == 0) return 1;
9632 str = getenv ("SKIP_TEST_COMMAND");
9633 if (str && strcmp (str, "1") == 0) return 1;
9637 static int test_command_10 (void)
9639 if (test_command_10_skip ()) {
9640 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_10");
9644 /* InitBasicFS for test_command_10: create ext2 on /dev/sda1 */
9646 char device[] = "/dev/sda";
9647 device[5] = devchar;
9650 r = guestfs_blockdev_setrw (g, device);
9657 r = guestfs_umount_all (g);
9664 r = guestfs_lvm_remove_all (g);
9669 char device[] = "/dev/sda";
9670 device[5] = devchar;
9671 char lines_0[] = ",";
9678 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9683 char fstype[] = "ext2";
9684 char device[] = "/dev/sda1";
9685 device[5] = devchar;
9688 r = guestfs_mkfs (g, fstype, device);
9693 char device[] = "/dev/sda1";
9694 device[5] = devchar;
9695 char mountpoint[] = "/";
9698 r = guestfs_mount (g, device, mountpoint);
9702 /* TestOutput for command (10) */
9703 char expected[] = "Result11-1\nResult11-2";
9705 char remotefilename[] = "/test-command";
9708 r = guestfs_upload (g, "test-command", remotefilename);
9713 char path[] = "/test-command";
9716 r = guestfs_chmod (g, 493, path);
9721 char arguments_0[] = "/test-command";
9722 char arguments_1[] = "11";
9723 char *arguments[] = {
9730 r = guestfs_command (g, arguments);
9733 if (strcmp (r, expected) != 0) {
9734 fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r);
9742 static int test_command_11_skip (void)
9746 str = getenv ("SKIP_TEST_COMMAND_11");
9747 if (str && strcmp (str, "1") == 0) return 1;
9748 str = getenv ("SKIP_TEST_COMMAND");
9749 if (str && strcmp (str, "1") == 0) return 1;
9753 static int test_command_11 (void)
9755 if (test_command_11_skip ()) {
9756 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_command_11");
9760 /* InitBasicFS for test_command_11: create ext2 on /dev/sda1 */
9762 char device[] = "/dev/sda";
9763 device[5] = devchar;
9766 r = guestfs_blockdev_setrw (g, device);
9773 r = guestfs_umount_all (g);
9780 r = guestfs_lvm_remove_all (g);
9785 char device[] = "/dev/sda";
9786 device[5] = devchar;
9787 char lines_0[] = ",";
9794 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9799 char fstype[] = "ext2";
9800 char device[] = "/dev/sda1";
9801 device[5] = devchar;
9804 r = guestfs_mkfs (g, fstype, device);
9809 char device[] = "/dev/sda1";
9810 device[5] = devchar;
9811 char mountpoint[] = "/";
9814 r = guestfs_mount (g, device, mountpoint);
9818 /* TestLastFail for command (11) */
9820 char remotefilename[] = "/test-command";
9823 r = guestfs_upload (g, "test-command", remotefilename);
9828 char path[] = "/test-command";
9831 r = guestfs_chmod (g, 493, path);
9836 char arguments_0[] = "/test-command";
9837 char *arguments[] = {
9843 r = guestfs_command (g, arguments);
9851 static int test_file_0_skip (void)
9855 str = getenv ("SKIP_TEST_FILE_0");
9856 if (str && strcmp (str, "1") == 0) return 1;
9857 str = getenv ("SKIP_TEST_FILE");
9858 if (str && strcmp (str, "1") == 0) return 1;
9862 static int test_file_0 (void)
9864 if (test_file_0_skip ()) {
9865 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_0");
9869 /* InitBasicFS for test_file_0: create ext2 on /dev/sda1 */
9871 char device[] = "/dev/sda";
9872 device[5] = devchar;
9875 r = guestfs_blockdev_setrw (g, device);
9882 r = guestfs_umount_all (g);
9889 r = guestfs_lvm_remove_all (g);
9894 char device[] = "/dev/sda";
9895 device[5] = devchar;
9896 char lines_0[] = ",";
9903 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
9908 char fstype[] = "ext2";
9909 char device[] = "/dev/sda1";
9910 device[5] = devchar;
9913 r = guestfs_mkfs (g, fstype, device);
9918 char device[] = "/dev/sda1";
9919 device[5] = devchar;
9920 char mountpoint[] = "/";
9923 r = guestfs_mount (g, device, mountpoint);
9927 /* TestOutput for file (0) */
9928 char expected[] = "empty";
9930 char path[] = "/new";
9933 r = guestfs_touch (g, path);
9938 char path[] = "/new";
9941 r = guestfs_file (g, path);
9944 if (strcmp (r, expected) != 0) {
9945 fprintf (stderr, "test_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
9953 static int test_file_1_skip (void)
9957 str = getenv ("SKIP_TEST_FILE_1");
9958 if (str && strcmp (str, "1") == 0) return 1;
9959 str = getenv ("SKIP_TEST_FILE");
9960 if (str && strcmp (str, "1") == 0) return 1;
9964 static int test_file_1 (void)
9966 if (test_file_1_skip ()) {
9967 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_1");
9971 /* InitBasicFS for test_file_1: create ext2 on /dev/sda1 */
9973 char device[] = "/dev/sda";
9974 device[5] = devchar;
9977 r = guestfs_blockdev_setrw (g, device);
9984 r = guestfs_umount_all (g);
9991 r = guestfs_lvm_remove_all (g);
9996 char device[] = "/dev/sda";
9997 device[5] = devchar;
9998 char lines_0[] = ",";
10004 suppress_error = 0;
10005 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10010 char fstype[] = "ext2";
10011 char device[] = "/dev/sda1";
10012 device[5] = devchar;
10014 suppress_error = 0;
10015 r = guestfs_mkfs (g, fstype, device);
10020 char device[] = "/dev/sda1";
10021 device[5] = devchar;
10022 char mountpoint[] = "/";
10024 suppress_error = 0;
10025 r = guestfs_mount (g, device, mountpoint);
10029 /* TestOutput for file (1) */
10030 char expected[] = "ASCII text";
10032 char path[] = "/new";
10033 char content[] = "some content\n";
10035 suppress_error = 0;
10036 r = guestfs_write_file (g, path, content, 0);
10041 char path[] = "/new";
10043 suppress_error = 0;
10044 r = guestfs_file (g, path);
10047 if (strcmp (r, expected) != 0) {
10048 fprintf (stderr, "test_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
10056 static int test_file_2_skip (void)
10060 str = getenv ("SKIP_TEST_FILE_2");
10061 if (str && strcmp (str, "1") == 0) return 1;
10062 str = getenv ("SKIP_TEST_FILE");
10063 if (str && strcmp (str, "1") == 0) return 1;
10067 static int test_file_2 (void)
10069 if (test_file_2_skip ()) {
10070 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_file_2");
10074 /* InitBasicFS for test_file_2: create ext2 on /dev/sda1 */
10076 char device[] = "/dev/sda";
10077 device[5] = devchar;
10079 suppress_error = 0;
10080 r = guestfs_blockdev_setrw (g, device);
10086 suppress_error = 0;
10087 r = guestfs_umount_all (g);
10093 suppress_error = 0;
10094 r = guestfs_lvm_remove_all (g);
10099 char device[] = "/dev/sda";
10100 device[5] = devchar;
10101 char lines_0[] = ",";
10107 suppress_error = 0;
10108 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10113 char fstype[] = "ext2";
10114 char device[] = "/dev/sda1";
10115 device[5] = devchar;
10117 suppress_error = 0;
10118 r = guestfs_mkfs (g, fstype, device);
10123 char device[] = "/dev/sda1";
10124 device[5] = devchar;
10125 char mountpoint[] = "/";
10127 suppress_error = 0;
10128 r = guestfs_mount (g, device, mountpoint);
10132 /* TestLastFail for file (2) */
10134 char path[] = "/nofile";
10136 suppress_error = 1;
10137 r = guestfs_file (g, path);
10145 static int test_umount_all_0_skip (void)
10149 str = getenv ("SKIP_TEST_UMOUNT_ALL_0");
10150 if (str && strcmp (str, "1") == 0) return 1;
10151 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10152 if (str && strcmp (str, "1") == 0) return 1;
10156 static int test_umount_all_0 (void)
10158 if (test_umount_all_0_skip ()) {
10159 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_0");
10163 /* InitBasicFS for test_umount_all_0: create ext2 on /dev/sda1 */
10165 char device[] = "/dev/sda";
10166 device[5] = devchar;
10168 suppress_error = 0;
10169 r = guestfs_blockdev_setrw (g, device);
10175 suppress_error = 0;
10176 r = guestfs_umount_all (g);
10182 suppress_error = 0;
10183 r = guestfs_lvm_remove_all (g);
10188 char device[] = "/dev/sda";
10189 device[5] = devchar;
10190 char lines_0[] = ",";
10196 suppress_error = 0;
10197 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10202 char fstype[] = "ext2";
10203 char device[] = "/dev/sda1";
10204 device[5] = devchar;
10206 suppress_error = 0;
10207 r = guestfs_mkfs (g, fstype, device);
10212 char device[] = "/dev/sda1";
10213 device[5] = devchar;
10214 char mountpoint[] = "/";
10216 suppress_error = 0;
10217 r = guestfs_mount (g, device, mountpoint);
10221 /* TestOutputList for umount_all (0) */
10224 suppress_error = 0;
10225 r = guestfs_umount_all (g);
10232 suppress_error = 0;
10233 r = guestfs_mounts (g);
10236 if (r[0] != NULL) {
10237 fprintf (stderr, "test_umount_all_0: extra elements returned from command\n");
10241 for (i = 0; r[i] != NULL; ++i)
10248 static int test_umount_all_1_skip (void)
10252 str = getenv ("SKIP_TEST_UMOUNT_ALL_1");
10253 if (str && strcmp (str, "1") == 0) return 1;
10254 str = getenv ("SKIP_TEST_UMOUNT_ALL");
10255 if (str && strcmp (str, "1") == 0) return 1;
10259 static int test_umount_all_1 (void)
10261 if (test_umount_all_1_skip ()) {
10262 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_all_1");
10266 /* InitNone|InitEmpty for test_umount_all_1 */
10268 char device[] = "/dev/sda";
10269 device[5] = devchar;
10271 suppress_error = 0;
10272 r = guestfs_blockdev_setrw (g, device);
10278 suppress_error = 0;
10279 r = guestfs_umount_all (g);
10285 suppress_error = 0;
10286 r = guestfs_lvm_remove_all (g);
10290 /* TestOutputList for umount_all (1) */
10292 char device[] = "/dev/sda";
10293 device[5] = devchar;
10294 char lines_0[] = ",10";
10295 char lines_1[] = ",20";
10296 char lines_2[] = ",";
10304 suppress_error = 0;
10305 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10310 char fstype[] = "ext2";
10311 char device[] = "/dev/sda1";
10312 device[5] = devchar;
10314 suppress_error = 0;
10315 r = guestfs_mkfs (g, fstype, device);
10320 char fstype[] = "ext2";
10321 char device[] = "/dev/sda2";
10322 device[5] = devchar;
10324 suppress_error = 0;
10325 r = guestfs_mkfs (g, fstype, device);
10330 char fstype[] = "ext2";
10331 char device[] = "/dev/sda3";
10332 device[5] = devchar;
10334 suppress_error = 0;
10335 r = guestfs_mkfs (g, fstype, device);
10340 char device[] = "/dev/sda1";
10341 device[5] = devchar;
10342 char mountpoint[] = "/";
10344 suppress_error = 0;
10345 r = guestfs_mount (g, device, mountpoint);
10350 char path[] = "/mp1";
10352 suppress_error = 0;
10353 r = guestfs_mkdir (g, path);
10358 char device[] = "/dev/sda2";
10359 device[5] = devchar;
10360 char mountpoint[] = "/mp1";
10362 suppress_error = 0;
10363 r = guestfs_mount (g, device, mountpoint);
10368 char path[] = "/mp1/mp2";
10370 suppress_error = 0;
10371 r = guestfs_mkdir (g, path);
10376 char device[] = "/dev/sda3";
10377 device[5] = devchar;
10378 char mountpoint[] = "/mp1/mp2";
10380 suppress_error = 0;
10381 r = guestfs_mount (g, device, mountpoint);
10386 char path[] = "/mp1/mp2/mp3";
10388 suppress_error = 0;
10389 r = guestfs_mkdir (g, path);
10395 suppress_error = 0;
10396 r = guestfs_umount_all (g);
10403 suppress_error = 0;
10404 r = guestfs_mounts (g);
10407 if (r[0] != NULL) {
10408 fprintf (stderr, "test_umount_all_1: extra elements returned from command\n");
10412 for (i = 0; r[i] != NULL; ++i)
10419 static int test_mounts_0_skip (void)
10423 str = getenv ("SKIP_TEST_MOUNTS_0");
10424 if (str && strcmp (str, "1") == 0) return 1;
10425 str = getenv ("SKIP_TEST_MOUNTS");
10426 if (str && strcmp (str, "1") == 0) return 1;
10430 static int test_mounts_0 (void)
10432 if (test_mounts_0_skip ()) {
10433 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mounts_0");
10437 /* InitBasicFS for test_mounts_0: create ext2 on /dev/sda1 */
10439 char device[] = "/dev/sda";
10440 device[5] = devchar;
10442 suppress_error = 0;
10443 r = guestfs_blockdev_setrw (g, device);
10449 suppress_error = 0;
10450 r = guestfs_umount_all (g);
10456 suppress_error = 0;
10457 r = guestfs_lvm_remove_all (g);
10462 char device[] = "/dev/sda";
10463 device[5] = devchar;
10464 char lines_0[] = ",";
10470 suppress_error = 0;
10471 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10476 char fstype[] = "ext2";
10477 char device[] = "/dev/sda1";
10478 device[5] = devchar;
10480 suppress_error = 0;
10481 r = guestfs_mkfs (g, fstype, device);
10486 char device[] = "/dev/sda1";
10487 device[5] = devchar;
10488 char mountpoint[] = "/";
10490 suppress_error = 0;
10491 r = guestfs_mount (g, device, mountpoint);
10495 /* TestOutputList for mounts (0) */
10499 suppress_error = 0;
10500 r = guestfs_mounts (g);
10504 fprintf (stderr, "test_mounts_0: short list returned from command\n");
10509 char expected[] = "/dev/sda1";
10510 expected[5] = devchar;
10511 if (strcmp (r[0], expected) != 0) {
10512 fprintf (stderr, "test_mounts_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
10516 if (r[1] != NULL) {
10517 fprintf (stderr, "test_mounts_0: extra elements returned from command\n");
10521 for (i = 0; r[i] != NULL; ++i)
10528 static int test_umount_0_skip (void)
10532 str = getenv ("SKIP_TEST_UMOUNT_0");
10533 if (str && strcmp (str, "1") == 0) return 1;
10534 str = getenv ("SKIP_TEST_UMOUNT");
10535 if (str && strcmp (str, "1") == 0) return 1;
10539 static int test_umount_0 (void)
10541 if (test_umount_0_skip ()) {
10542 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_0");
10546 /* InitNone|InitEmpty for test_umount_0 */
10548 char device[] = "/dev/sda";
10549 device[5] = devchar;
10551 suppress_error = 0;
10552 r = guestfs_blockdev_setrw (g, device);
10558 suppress_error = 0;
10559 r = guestfs_umount_all (g);
10565 suppress_error = 0;
10566 r = guestfs_lvm_remove_all (g);
10570 /* TestOutputList for umount (0) */
10572 char device[] = "/dev/sda";
10573 device[5] = devchar;
10574 char lines_0[] = ",";
10580 suppress_error = 0;
10581 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10586 char fstype[] = "ext2";
10587 char device[] = "/dev/sda1";
10588 device[5] = devchar;
10590 suppress_error = 0;
10591 r = guestfs_mkfs (g, fstype, device);
10596 char device[] = "/dev/sda1";
10597 device[5] = devchar;
10598 char mountpoint[] = "/";
10600 suppress_error = 0;
10601 r = guestfs_mount (g, device, mountpoint);
10608 suppress_error = 0;
10609 r = guestfs_mounts (g);
10613 fprintf (stderr, "test_umount_0: short list returned from command\n");
10618 char expected[] = "/dev/sda1";
10619 expected[5] = devchar;
10620 if (strcmp (r[0], expected) != 0) {
10621 fprintf (stderr, "test_umount_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
10625 if (r[1] != NULL) {
10626 fprintf (stderr, "test_umount_0: extra elements returned from command\n");
10630 for (i = 0; r[i] != NULL; ++i)
10637 static int test_umount_1_skip (void)
10641 str = getenv ("SKIP_TEST_UMOUNT_1");
10642 if (str && strcmp (str, "1") == 0) return 1;
10643 str = getenv ("SKIP_TEST_UMOUNT");
10644 if (str && strcmp (str, "1") == 0) return 1;
10648 static int test_umount_1 (void)
10650 if (test_umount_1_skip ()) {
10651 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_umount_1");
10655 /* InitNone|InitEmpty for test_umount_1 */
10657 char device[] = "/dev/sda";
10658 device[5] = devchar;
10660 suppress_error = 0;
10661 r = guestfs_blockdev_setrw (g, device);
10667 suppress_error = 0;
10668 r = guestfs_umount_all (g);
10674 suppress_error = 0;
10675 r = guestfs_lvm_remove_all (g);
10679 /* TestOutputList for umount (1) */
10681 char device[] = "/dev/sda";
10682 device[5] = devchar;
10683 char lines_0[] = ",";
10689 suppress_error = 0;
10690 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10695 char fstype[] = "ext2";
10696 char device[] = "/dev/sda1";
10697 device[5] = devchar;
10699 suppress_error = 0;
10700 r = guestfs_mkfs (g, fstype, device);
10705 char device[] = "/dev/sda1";
10706 device[5] = devchar;
10707 char mountpoint[] = "/";
10709 suppress_error = 0;
10710 r = guestfs_mount (g, device, mountpoint);
10715 char pathordevice[] = "/";
10717 suppress_error = 0;
10718 r = guestfs_umount (g, pathordevice);
10725 suppress_error = 0;
10726 r = guestfs_mounts (g);
10729 if (r[0] != NULL) {
10730 fprintf (stderr, "test_umount_1: extra elements returned from command\n");
10734 for (i = 0; r[i] != NULL; ++i)
10741 static int test_write_file_0_skip (void)
10745 str = getenv ("SKIP_TEST_WRITE_FILE_0");
10746 if (str && strcmp (str, "1") == 0) return 1;
10747 str = getenv ("SKIP_TEST_WRITE_FILE");
10748 if (str && strcmp (str, "1") == 0) return 1;
10752 static int test_write_file_0 (void)
10754 if (test_write_file_0_skip ()) {
10755 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_0");
10759 /* InitBasicFS for test_write_file_0: create ext2 on /dev/sda1 */
10761 char device[] = "/dev/sda";
10762 device[5] = devchar;
10764 suppress_error = 0;
10765 r = guestfs_blockdev_setrw (g, device);
10771 suppress_error = 0;
10772 r = guestfs_umount_all (g);
10778 suppress_error = 0;
10779 r = guestfs_lvm_remove_all (g);
10784 char device[] = "/dev/sda";
10785 device[5] = devchar;
10786 char lines_0[] = ",";
10792 suppress_error = 0;
10793 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10798 char fstype[] = "ext2";
10799 char device[] = "/dev/sda1";
10800 device[5] = devchar;
10802 suppress_error = 0;
10803 r = guestfs_mkfs (g, fstype, device);
10808 char device[] = "/dev/sda1";
10809 device[5] = devchar;
10810 char mountpoint[] = "/";
10812 suppress_error = 0;
10813 r = guestfs_mount (g, device, mountpoint);
10817 /* TestOutput for write_file (0) */
10818 char expected[] = "new file contents";
10820 char path[] = "/new";
10821 char content[] = "new file contents";
10823 suppress_error = 0;
10824 r = guestfs_write_file (g, path, content, 0);
10829 char path[] = "/new";
10831 suppress_error = 0;
10832 r = guestfs_cat (g, path);
10835 if (strcmp (r, expected) != 0) {
10836 fprintf (stderr, "test_write_file_0: expected \"%s\" but got \"%s\"\n", expected, r);
10844 static int test_write_file_1_skip (void)
10848 str = getenv ("SKIP_TEST_WRITE_FILE_1");
10849 if (str && strcmp (str, "1") == 0) return 1;
10850 str = getenv ("SKIP_TEST_WRITE_FILE");
10851 if (str && strcmp (str, "1") == 0) return 1;
10855 static int test_write_file_1 (void)
10857 if (test_write_file_1_skip ()) {
10858 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_1");
10862 /* InitBasicFS for test_write_file_1: create ext2 on /dev/sda1 */
10864 char device[] = "/dev/sda";
10865 device[5] = devchar;
10867 suppress_error = 0;
10868 r = guestfs_blockdev_setrw (g, device);
10874 suppress_error = 0;
10875 r = guestfs_umount_all (g);
10881 suppress_error = 0;
10882 r = guestfs_lvm_remove_all (g);
10887 char device[] = "/dev/sda";
10888 device[5] = devchar;
10889 char lines_0[] = ",";
10895 suppress_error = 0;
10896 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
10901 char fstype[] = "ext2";
10902 char device[] = "/dev/sda1";
10903 device[5] = devchar;
10905 suppress_error = 0;
10906 r = guestfs_mkfs (g, fstype, device);
10911 char device[] = "/dev/sda1";
10912 device[5] = devchar;
10913 char mountpoint[] = "/";
10915 suppress_error = 0;
10916 r = guestfs_mount (g, device, mountpoint);
10920 /* TestOutput for write_file (1) */
10921 char expected[] = "\nnew file contents\n";
10923 char path[] = "/new";
10924 char content[] = "\nnew file contents\n";
10926 suppress_error = 0;
10927 r = guestfs_write_file (g, path, content, 0);
10932 char path[] = "/new";
10934 suppress_error = 0;
10935 r = guestfs_cat (g, path);
10938 if (strcmp (r, expected) != 0) {
10939 fprintf (stderr, "test_write_file_1: expected \"%s\" but got \"%s\"\n", expected, r);
10947 static int test_write_file_2_skip (void)
10951 str = getenv ("SKIP_TEST_WRITE_FILE_2");
10952 if (str && strcmp (str, "1") == 0) return 1;
10953 str = getenv ("SKIP_TEST_WRITE_FILE");
10954 if (str && strcmp (str, "1") == 0) return 1;
10958 static int test_write_file_2 (void)
10960 if (test_write_file_2_skip ()) {
10961 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_2");
10965 /* InitBasicFS for test_write_file_2: create ext2 on /dev/sda1 */
10967 char device[] = "/dev/sda";
10968 device[5] = devchar;
10970 suppress_error = 0;
10971 r = guestfs_blockdev_setrw (g, device);
10977 suppress_error = 0;
10978 r = guestfs_umount_all (g);
10984 suppress_error = 0;
10985 r = guestfs_lvm_remove_all (g);
10990 char device[] = "/dev/sda";
10991 device[5] = devchar;
10992 char lines_0[] = ",";
10998 suppress_error = 0;
10999 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11004 char fstype[] = "ext2";
11005 char device[] = "/dev/sda1";
11006 device[5] = devchar;
11008 suppress_error = 0;
11009 r = guestfs_mkfs (g, fstype, device);
11014 char device[] = "/dev/sda1";
11015 device[5] = devchar;
11016 char mountpoint[] = "/";
11018 suppress_error = 0;
11019 r = guestfs_mount (g, device, mountpoint);
11023 /* TestOutput for write_file (2) */
11024 char expected[] = "\n\n";
11026 char path[] = "/new";
11027 char content[] = "\n\n";
11029 suppress_error = 0;
11030 r = guestfs_write_file (g, path, content, 0);
11035 char path[] = "/new";
11037 suppress_error = 0;
11038 r = guestfs_cat (g, path);
11041 if (strcmp (r, expected) != 0) {
11042 fprintf (stderr, "test_write_file_2: expected \"%s\" but got \"%s\"\n", expected, r);
11050 static int test_write_file_3_skip (void)
11054 str = getenv ("SKIP_TEST_WRITE_FILE_3");
11055 if (str && strcmp (str, "1") == 0) return 1;
11056 str = getenv ("SKIP_TEST_WRITE_FILE");
11057 if (str && strcmp (str, "1") == 0) return 1;
11061 static int test_write_file_3 (void)
11063 if (test_write_file_3_skip ()) {
11064 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_3");
11068 /* InitBasicFS for test_write_file_3: create ext2 on /dev/sda1 */
11070 char device[] = "/dev/sda";
11071 device[5] = devchar;
11073 suppress_error = 0;
11074 r = guestfs_blockdev_setrw (g, device);
11080 suppress_error = 0;
11081 r = guestfs_umount_all (g);
11087 suppress_error = 0;
11088 r = guestfs_lvm_remove_all (g);
11093 char device[] = "/dev/sda";
11094 device[5] = devchar;
11095 char lines_0[] = ",";
11101 suppress_error = 0;
11102 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11107 char fstype[] = "ext2";
11108 char device[] = "/dev/sda1";
11109 device[5] = devchar;
11111 suppress_error = 0;
11112 r = guestfs_mkfs (g, fstype, device);
11117 char device[] = "/dev/sda1";
11118 device[5] = devchar;
11119 char mountpoint[] = "/";
11121 suppress_error = 0;
11122 r = guestfs_mount (g, device, mountpoint);
11126 /* TestOutput for write_file (3) */
11127 char expected[] = "";
11129 char path[] = "/new";
11130 char content[] = "";
11132 suppress_error = 0;
11133 r = guestfs_write_file (g, path, content, 0);
11138 char path[] = "/new";
11140 suppress_error = 0;
11141 r = guestfs_cat (g, path);
11144 if (strcmp (r, expected) != 0) {
11145 fprintf (stderr, "test_write_file_3: expected \"%s\" but got \"%s\"\n", expected, r);
11153 static int test_write_file_4_skip (void)
11157 str = getenv ("SKIP_TEST_WRITE_FILE_4");
11158 if (str && strcmp (str, "1") == 0) return 1;
11159 str = getenv ("SKIP_TEST_WRITE_FILE");
11160 if (str && strcmp (str, "1") == 0) return 1;
11164 static int test_write_file_4 (void)
11166 if (test_write_file_4_skip ()) {
11167 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_4");
11171 /* InitBasicFS for test_write_file_4: create ext2 on /dev/sda1 */
11173 char device[] = "/dev/sda";
11174 device[5] = devchar;
11176 suppress_error = 0;
11177 r = guestfs_blockdev_setrw (g, device);
11183 suppress_error = 0;
11184 r = guestfs_umount_all (g);
11190 suppress_error = 0;
11191 r = guestfs_lvm_remove_all (g);
11196 char device[] = "/dev/sda";
11197 device[5] = devchar;
11198 char lines_0[] = ",";
11204 suppress_error = 0;
11205 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11210 char fstype[] = "ext2";
11211 char device[] = "/dev/sda1";
11212 device[5] = devchar;
11214 suppress_error = 0;
11215 r = guestfs_mkfs (g, fstype, device);
11220 char device[] = "/dev/sda1";
11221 device[5] = devchar;
11222 char mountpoint[] = "/";
11224 suppress_error = 0;
11225 r = guestfs_mount (g, device, mountpoint);
11229 /* TestOutput for write_file (4) */
11230 char expected[] = "\n\n\n";
11232 char path[] = "/new";
11233 char content[] = "\n\n\n";
11235 suppress_error = 0;
11236 r = guestfs_write_file (g, path, content, 0);
11241 char path[] = "/new";
11243 suppress_error = 0;
11244 r = guestfs_cat (g, path);
11247 if (strcmp (r, expected) != 0) {
11248 fprintf (stderr, "test_write_file_4: expected \"%s\" but got \"%s\"\n", expected, r);
11256 static int test_write_file_5_skip (void)
11260 str = getenv ("SKIP_TEST_WRITE_FILE_5");
11261 if (str && strcmp (str, "1") == 0) return 1;
11262 str = getenv ("SKIP_TEST_WRITE_FILE");
11263 if (str && strcmp (str, "1") == 0) return 1;
11267 static int test_write_file_5 (void)
11269 if (test_write_file_5_skip ()) {
11270 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_write_file_5");
11274 /* InitBasicFS for test_write_file_5: create ext2 on /dev/sda1 */
11276 char device[] = "/dev/sda";
11277 device[5] = devchar;
11279 suppress_error = 0;
11280 r = guestfs_blockdev_setrw (g, device);
11286 suppress_error = 0;
11287 r = guestfs_umount_all (g);
11293 suppress_error = 0;
11294 r = guestfs_lvm_remove_all (g);
11299 char device[] = "/dev/sda";
11300 device[5] = devchar;
11301 char lines_0[] = ",";
11307 suppress_error = 0;
11308 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11313 char fstype[] = "ext2";
11314 char device[] = "/dev/sda1";
11315 device[5] = devchar;
11317 suppress_error = 0;
11318 r = guestfs_mkfs (g, fstype, device);
11323 char device[] = "/dev/sda1";
11324 device[5] = devchar;
11325 char mountpoint[] = "/";
11327 suppress_error = 0;
11328 r = guestfs_mount (g, device, mountpoint);
11332 /* TestOutput for write_file (5) */
11333 char expected[] = "\n";
11335 char path[] = "/new";
11336 char content[] = "\n";
11338 suppress_error = 0;
11339 r = guestfs_write_file (g, path, content, 0);
11344 char path[] = "/new";
11346 suppress_error = 0;
11347 r = guestfs_cat (g, path);
11350 if (strcmp (r, expected) != 0) {
11351 fprintf (stderr, "test_write_file_5: expected \"%s\" but got \"%s\"\n", expected, r);
11359 static int test_mkfs_0_skip (void)
11363 str = getenv ("SKIP_TEST_MKFS_0");
11364 if (str && strcmp (str, "1") == 0) return 1;
11365 str = getenv ("SKIP_TEST_MKFS");
11366 if (str && strcmp (str, "1") == 0) return 1;
11370 static int test_mkfs_0 (void)
11372 if (test_mkfs_0_skip ()) {
11373 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkfs_0");
11377 /* InitNone|InitEmpty for test_mkfs_0 */
11379 char device[] = "/dev/sda";
11380 device[5] = devchar;
11382 suppress_error = 0;
11383 r = guestfs_blockdev_setrw (g, device);
11389 suppress_error = 0;
11390 r = guestfs_umount_all (g);
11396 suppress_error = 0;
11397 r = guestfs_lvm_remove_all (g);
11401 /* TestOutput for mkfs (0) */
11402 char expected[] = "new file contents";
11404 char device[] = "/dev/sda";
11405 device[5] = devchar;
11406 char lines_0[] = ",";
11412 suppress_error = 0;
11413 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11418 char fstype[] = "ext2";
11419 char device[] = "/dev/sda1";
11420 device[5] = devchar;
11422 suppress_error = 0;
11423 r = guestfs_mkfs (g, fstype, device);
11428 char device[] = "/dev/sda1";
11429 device[5] = devchar;
11430 char mountpoint[] = "/";
11432 suppress_error = 0;
11433 r = guestfs_mount (g, device, mountpoint);
11438 char path[] = "/new";
11439 char content[] = "new file contents";
11441 suppress_error = 0;
11442 r = guestfs_write_file (g, path, content, 0);
11447 char path[] = "/new";
11449 suppress_error = 0;
11450 r = guestfs_cat (g, path);
11453 if (strcmp (r, expected) != 0) {
11454 fprintf (stderr, "test_mkfs_0: expected \"%s\" but got \"%s\"\n", expected, r);
11462 static int test_lvcreate_0_skip (void)
11466 str = getenv ("SKIP_TEST_LVCREATE_0");
11467 if (str && strcmp (str, "1") == 0) return 1;
11468 str = getenv ("SKIP_TEST_LVCREATE");
11469 if (str && strcmp (str, "1") == 0) return 1;
11473 static int test_lvcreate_0 (void)
11475 if (test_lvcreate_0_skip ()) {
11476 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvcreate_0");
11480 /* InitNone|InitEmpty for test_lvcreate_0 */
11482 char device[] = "/dev/sda";
11483 device[5] = devchar;
11485 suppress_error = 0;
11486 r = guestfs_blockdev_setrw (g, device);
11492 suppress_error = 0;
11493 r = guestfs_umount_all (g);
11499 suppress_error = 0;
11500 r = guestfs_lvm_remove_all (g);
11504 /* TestOutputList for lvcreate (0) */
11506 char device[] = "/dev/sda";
11507 device[5] = devchar;
11508 char lines_0[] = ",10";
11509 char lines_1[] = ",20";
11510 char lines_2[] = ",";
11518 suppress_error = 0;
11519 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11524 char device[] = "/dev/sda1";
11525 device[5] = devchar;
11527 suppress_error = 0;
11528 r = guestfs_pvcreate (g, device);
11533 char device[] = "/dev/sda2";
11534 device[5] = devchar;
11536 suppress_error = 0;
11537 r = guestfs_pvcreate (g, device);
11542 char device[] = "/dev/sda3";
11543 device[5] = devchar;
11545 suppress_error = 0;
11546 r = guestfs_pvcreate (g, device);
11551 char volgroup[] = "VG1";
11552 char physvols_0[] = "/dev/sda1";
11553 physvols_0[5] = devchar;
11554 char physvols_1[] = "/dev/sda2";
11555 physvols_1[5] = devchar;
11556 char *physvols[] = {
11562 suppress_error = 0;
11563 r = guestfs_vgcreate (g, volgroup, physvols);
11568 char volgroup[] = "VG2";
11569 char physvols_0[] = "/dev/sda3";
11570 physvols_0[5] = devchar;
11571 char *physvols[] = {
11576 suppress_error = 0;
11577 r = guestfs_vgcreate (g, volgroup, physvols);
11582 char logvol[] = "LV1";
11583 char volgroup[] = "VG1";
11585 suppress_error = 0;
11586 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11591 char logvol[] = "LV2";
11592 char volgroup[] = "VG1";
11594 suppress_error = 0;
11595 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11600 char logvol[] = "LV3";
11601 char volgroup[] = "VG2";
11603 suppress_error = 0;
11604 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11609 char logvol[] = "LV4";
11610 char volgroup[] = "VG2";
11612 suppress_error = 0;
11613 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11618 char logvol[] = "LV5";
11619 char volgroup[] = "VG2";
11621 suppress_error = 0;
11622 r = guestfs_lvcreate (g, logvol, volgroup, 50);
11629 suppress_error = 0;
11630 r = guestfs_lvs (g);
11634 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11639 char expected[] = "/dev/VG1/LV1";
11640 if (strcmp (r[0], expected) != 0) {
11641 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11646 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11651 char expected[] = "/dev/VG1/LV2";
11652 if (strcmp (r[1], expected) != 0) {
11653 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11658 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11663 char expected[] = "/dev/VG2/LV3";
11664 if (strcmp (r[2], expected) != 0) {
11665 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
11670 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11675 char expected[] = "/dev/VG2/LV4";
11676 if (strcmp (r[3], expected) != 0) {
11677 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
11682 fprintf (stderr, "test_lvcreate_0: short list returned from command\n");
11687 char expected[] = "/dev/VG2/LV5";
11688 if (strcmp (r[4], expected) != 0) {
11689 fprintf (stderr, "test_lvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[4]);
11693 if (r[5] != NULL) {
11694 fprintf (stderr, "test_lvcreate_0: extra elements returned from command\n");
11698 for (i = 0; r[i] != NULL; ++i)
11705 static int test_vgcreate_0_skip (void)
11709 str = getenv ("SKIP_TEST_VGCREATE_0");
11710 if (str && strcmp (str, "1") == 0) return 1;
11711 str = getenv ("SKIP_TEST_VGCREATE");
11712 if (str && strcmp (str, "1") == 0) return 1;
11716 static int test_vgcreate_0 (void)
11718 if (test_vgcreate_0_skip ()) {
11719 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgcreate_0");
11723 /* InitNone|InitEmpty for test_vgcreate_0 */
11725 char device[] = "/dev/sda";
11726 device[5] = devchar;
11728 suppress_error = 0;
11729 r = guestfs_blockdev_setrw (g, device);
11735 suppress_error = 0;
11736 r = guestfs_umount_all (g);
11742 suppress_error = 0;
11743 r = guestfs_lvm_remove_all (g);
11747 /* TestOutputList for vgcreate (0) */
11749 char device[] = "/dev/sda";
11750 device[5] = devchar;
11751 char lines_0[] = ",10";
11752 char lines_1[] = ",20";
11753 char lines_2[] = ",";
11761 suppress_error = 0;
11762 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11767 char device[] = "/dev/sda1";
11768 device[5] = devchar;
11770 suppress_error = 0;
11771 r = guestfs_pvcreate (g, device);
11776 char device[] = "/dev/sda2";
11777 device[5] = devchar;
11779 suppress_error = 0;
11780 r = guestfs_pvcreate (g, device);
11785 char device[] = "/dev/sda3";
11786 device[5] = devchar;
11788 suppress_error = 0;
11789 r = guestfs_pvcreate (g, device);
11794 char volgroup[] = "VG1";
11795 char physvols_0[] = "/dev/sda1";
11796 physvols_0[5] = devchar;
11797 char physvols_1[] = "/dev/sda2";
11798 physvols_1[5] = devchar;
11799 char *physvols[] = {
11805 suppress_error = 0;
11806 r = guestfs_vgcreate (g, volgroup, physvols);
11811 char volgroup[] = "VG2";
11812 char physvols_0[] = "/dev/sda3";
11813 physvols_0[5] = devchar;
11814 char *physvols[] = {
11819 suppress_error = 0;
11820 r = guestfs_vgcreate (g, volgroup, physvols);
11827 suppress_error = 0;
11828 r = guestfs_vgs (g);
11832 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
11837 char expected[] = "VG1";
11838 if (strcmp (r[0], expected) != 0) {
11839 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11844 fprintf (stderr, "test_vgcreate_0: short list returned from command\n");
11849 char expected[] = "VG2";
11850 if (strcmp (r[1], expected) != 0) {
11851 fprintf (stderr, "test_vgcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11855 if (r[2] != NULL) {
11856 fprintf (stderr, "test_vgcreate_0: extra elements returned from command\n");
11860 for (i = 0; r[i] != NULL; ++i)
11867 static int test_pvcreate_0_skip (void)
11871 str = getenv ("SKIP_TEST_PVCREATE_0");
11872 if (str && strcmp (str, "1") == 0) return 1;
11873 str = getenv ("SKIP_TEST_PVCREATE");
11874 if (str && strcmp (str, "1") == 0) return 1;
11878 static int test_pvcreate_0 (void)
11880 if (test_pvcreate_0_skip ()) {
11881 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvcreate_0");
11885 /* InitNone|InitEmpty for test_pvcreate_0 */
11887 char device[] = "/dev/sda";
11888 device[5] = devchar;
11890 suppress_error = 0;
11891 r = guestfs_blockdev_setrw (g, device);
11897 suppress_error = 0;
11898 r = guestfs_umount_all (g);
11904 suppress_error = 0;
11905 r = guestfs_lvm_remove_all (g);
11909 /* TestOutputList for pvcreate (0) */
11911 char device[] = "/dev/sda";
11912 device[5] = devchar;
11913 char lines_0[] = ",10";
11914 char lines_1[] = ",20";
11915 char lines_2[] = ",";
11923 suppress_error = 0;
11924 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
11929 char device[] = "/dev/sda1";
11930 device[5] = devchar;
11932 suppress_error = 0;
11933 r = guestfs_pvcreate (g, device);
11938 char device[] = "/dev/sda2";
11939 device[5] = devchar;
11941 suppress_error = 0;
11942 r = guestfs_pvcreate (g, device);
11947 char device[] = "/dev/sda3";
11948 device[5] = devchar;
11950 suppress_error = 0;
11951 r = guestfs_pvcreate (g, device);
11958 suppress_error = 0;
11959 r = guestfs_pvs (g);
11963 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
11968 char expected[] = "/dev/sda1";
11969 expected[5] = devchar;
11970 if (strcmp (r[0], expected) != 0) {
11971 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
11976 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
11981 char expected[] = "/dev/sda2";
11982 expected[5] = devchar;
11983 if (strcmp (r[1], expected) != 0) {
11984 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
11989 fprintf (stderr, "test_pvcreate_0: short list returned from command\n");
11994 char expected[] = "/dev/sda3";
11995 expected[5] = devchar;
11996 if (strcmp (r[2], expected) != 0) {
11997 fprintf (stderr, "test_pvcreate_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
12001 if (r[3] != NULL) {
12002 fprintf (stderr, "test_pvcreate_0: extra elements returned from command\n");
12006 for (i = 0; r[i] != NULL; ++i)
12013 static int test_is_dir_0_skip (void)
12017 str = getenv ("SKIP_TEST_IS_DIR_0");
12018 if (str && strcmp (str, "1") == 0) return 1;
12019 str = getenv ("SKIP_TEST_IS_DIR");
12020 if (str && strcmp (str, "1") == 0) return 1;
12024 static int test_is_dir_0 (void)
12026 if (test_is_dir_0_skip ()) {
12027 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_0");
12031 /* InitBasicFS for test_is_dir_0: create ext2 on /dev/sda1 */
12033 char device[] = "/dev/sda";
12034 device[5] = devchar;
12036 suppress_error = 0;
12037 r = guestfs_blockdev_setrw (g, device);
12043 suppress_error = 0;
12044 r = guestfs_umount_all (g);
12050 suppress_error = 0;
12051 r = guestfs_lvm_remove_all (g);
12056 char device[] = "/dev/sda";
12057 device[5] = devchar;
12058 char lines_0[] = ",";
12064 suppress_error = 0;
12065 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12070 char fstype[] = "ext2";
12071 char device[] = "/dev/sda1";
12072 device[5] = devchar;
12074 suppress_error = 0;
12075 r = guestfs_mkfs (g, fstype, device);
12080 char device[] = "/dev/sda1";
12081 device[5] = devchar;
12082 char mountpoint[] = "/";
12084 suppress_error = 0;
12085 r = guestfs_mount (g, device, mountpoint);
12089 /* TestOutputFalse for is_dir (0) */
12091 char path[] = "/new";
12093 suppress_error = 0;
12094 r = guestfs_touch (g, path);
12099 char path[] = "/new";
12101 suppress_error = 0;
12102 r = guestfs_is_dir (g, path);
12106 fprintf (stderr, "test_is_dir_0: expected false, got true\n");
12113 static int test_is_dir_1_skip (void)
12117 str = getenv ("SKIP_TEST_IS_DIR_1");
12118 if (str && strcmp (str, "1") == 0) return 1;
12119 str = getenv ("SKIP_TEST_IS_DIR");
12120 if (str && strcmp (str, "1") == 0) return 1;
12124 static int test_is_dir_1 (void)
12126 if (test_is_dir_1_skip ()) {
12127 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_dir_1");
12131 /* InitBasicFS for test_is_dir_1: create ext2 on /dev/sda1 */
12133 char device[] = "/dev/sda";
12134 device[5] = devchar;
12136 suppress_error = 0;
12137 r = guestfs_blockdev_setrw (g, device);
12143 suppress_error = 0;
12144 r = guestfs_umount_all (g);
12150 suppress_error = 0;
12151 r = guestfs_lvm_remove_all (g);
12156 char device[] = "/dev/sda";
12157 device[5] = devchar;
12158 char lines_0[] = ",";
12164 suppress_error = 0;
12165 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12170 char fstype[] = "ext2";
12171 char device[] = "/dev/sda1";
12172 device[5] = devchar;
12174 suppress_error = 0;
12175 r = guestfs_mkfs (g, fstype, device);
12180 char device[] = "/dev/sda1";
12181 device[5] = devchar;
12182 char mountpoint[] = "/";
12184 suppress_error = 0;
12185 r = guestfs_mount (g, device, mountpoint);
12189 /* TestOutputTrue for is_dir (1) */
12191 char path[] = "/new";
12193 suppress_error = 0;
12194 r = guestfs_mkdir (g, path);
12199 char path[] = "/new";
12201 suppress_error = 0;
12202 r = guestfs_is_dir (g, path);
12206 fprintf (stderr, "test_is_dir_1: expected true, got false\n");
12213 static int test_is_file_0_skip (void)
12217 str = getenv ("SKIP_TEST_IS_FILE_0");
12218 if (str && strcmp (str, "1") == 0) return 1;
12219 str = getenv ("SKIP_TEST_IS_FILE");
12220 if (str && strcmp (str, "1") == 0) return 1;
12224 static int test_is_file_0 (void)
12226 if (test_is_file_0_skip ()) {
12227 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_0");
12231 /* InitBasicFS for test_is_file_0: create ext2 on /dev/sda1 */
12233 char device[] = "/dev/sda";
12234 device[5] = devchar;
12236 suppress_error = 0;
12237 r = guestfs_blockdev_setrw (g, device);
12243 suppress_error = 0;
12244 r = guestfs_umount_all (g);
12250 suppress_error = 0;
12251 r = guestfs_lvm_remove_all (g);
12256 char device[] = "/dev/sda";
12257 device[5] = devchar;
12258 char lines_0[] = ",";
12264 suppress_error = 0;
12265 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12270 char fstype[] = "ext2";
12271 char device[] = "/dev/sda1";
12272 device[5] = devchar;
12274 suppress_error = 0;
12275 r = guestfs_mkfs (g, fstype, device);
12280 char device[] = "/dev/sda1";
12281 device[5] = devchar;
12282 char mountpoint[] = "/";
12284 suppress_error = 0;
12285 r = guestfs_mount (g, device, mountpoint);
12289 /* TestOutputTrue for is_file (0) */
12291 char path[] = "/new";
12293 suppress_error = 0;
12294 r = guestfs_touch (g, path);
12299 char path[] = "/new";
12301 suppress_error = 0;
12302 r = guestfs_is_file (g, path);
12306 fprintf (stderr, "test_is_file_0: expected true, got false\n");
12313 static int test_is_file_1_skip (void)
12317 str = getenv ("SKIP_TEST_IS_FILE_1");
12318 if (str && strcmp (str, "1") == 0) return 1;
12319 str = getenv ("SKIP_TEST_IS_FILE");
12320 if (str && strcmp (str, "1") == 0) return 1;
12324 static int test_is_file_1 (void)
12326 if (test_is_file_1_skip ()) {
12327 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_is_file_1");
12331 /* InitBasicFS for test_is_file_1: create ext2 on /dev/sda1 */
12333 char device[] = "/dev/sda";
12334 device[5] = devchar;
12336 suppress_error = 0;
12337 r = guestfs_blockdev_setrw (g, device);
12343 suppress_error = 0;
12344 r = guestfs_umount_all (g);
12350 suppress_error = 0;
12351 r = guestfs_lvm_remove_all (g);
12356 char device[] = "/dev/sda";
12357 device[5] = devchar;
12358 char lines_0[] = ",";
12364 suppress_error = 0;
12365 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12370 char fstype[] = "ext2";
12371 char device[] = "/dev/sda1";
12372 device[5] = devchar;
12374 suppress_error = 0;
12375 r = guestfs_mkfs (g, fstype, device);
12380 char device[] = "/dev/sda1";
12381 device[5] = devchar;
12382 char mountpoint[] = "/";
12384 suppress_error = 0;
12385 r = guestfs_mount (g, device, mountpoint);
12389 /* TestOutputFalse for is_file (1) */
12391 char path[] = "/new";
12393 suppress_error = 0;
12394 r = guestfs_mkdir (g, path);
12399 char path[] = "/new";
12401 suppress_error = 0;
12402 r = guestfs_is_file (g, path);
12406 fprintf (stderr, "test_is_file_1: expected false, got true\n");
12413 static int test_exists_0_skip (void)
12417 str = getenv ("SKIP_TEST_EXISTS_0");
12418 if (str && strcmp (str, "1") == 0) return 1;
12419 str = getenv ("SKIP_TEST_EXISTS");
12420 if (str && strcmp (str, "1") == 0) return 1;
12424 static int test_exists_0 (void)
12426 if (test_exists_0_skip ()) {
12427 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_0");
12431 /* InitBasicFS for test_exists_0: create ext2 on /dev/sda1 */
12433 char device[] = "/dev/sda";
12434 device[5] = devchar;
12436 suppress_error = 0;
12437 r = guestfs_blockdev_setrw (g, device);
12443 suppress_error = 0;
12444 r = guestfs_umount_all (g);
12450 suppress_error = 0;
12451 r = guestfs_lvm_remove_all (g);
12456 char device[] = "/dev/sda";
12457 device[5] = devchar;
12458 char lines_0[] = ",";
12464 suppress_error = 0;
12465 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12470 char fstype[] = "ext2";
12471 char device[] = "/dev/sda1";
12472 device[5] = devchar;
12474 suppress_error = 0;
12475 r = guestfs_mkfs (g, fstype, device);
12480 char device[] = "/dev/sda1";
12481 device[5] = devchar;
12482 char mountpoint[] = "/";
12484 suppress_error = 0;
12485 r = guestfs_mount (g, device, mountpoint);
12489 /* TestOutputTrue for exists (0) */
12491 char path[] = "/new";
12493 suppress_error = 0;
12494 r = guestfs_touch (g, path);
12499 char path[] = "/new";
12501 suppress_error = 0;
12502 r = guestfs_exists (g, path);
12506 fprintf (stderr, "test_exists_0: expected true, got false\n");
12513 static int test_exists_1_skip (void)
12517 str = getenv ("SKIP_TEST_EXISTS_1");
12518 if (str && strcmp (str, "1") == 0) return 1;
12519 str = getenv ("SKIP_TEST_EXISTS");
12520 if (str && strcmp (str, "1") == 0) return 1;
12524 static int test_exists_1 (void)
12526 if (test_exists_1_skip ()) {
12527 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_exists_1");
12531 /* InitBasicFS for test_exists_1: create ext2 on /dev/sda1 */
12533 char device[] = "/dev/sda";
12534 device[5] = devchar;
12536 suppress_error = 0;
12537 r = guestfs_blockdev_setrw (g, device);
12543 suppress_error = 0;
12544 r = guestfs_umount_all (g);
12550 suppress_error = 0;
12551 r = guestfs_lvm_remove_all (g);
12556 char device[] = "/dev/sda";
12557 device[5] = devchar;
12558 char lines_0[] = ",";
12564 suppress_error = 0;
12565 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12570 char fstype[] = "ext2";
12571 char device[] = "/dev/sda1";
12572 device[5] = devchar;
12574 suppress_error = 0;
12575 r = guestfs_mkfs (g, fstype, device);
12580 char device[] = "/dev/sda1";
12581 device[5] = devchar;
12582 char mountpoint[] = "/";
12584 suppress_error = 0;
12585 r = guestfs_mount (g, device, mountpoint);
12589 /* TestOutputTrue for exists (1) */
12591 char path[] = "/new";
12593 suppress_error = 0;
12594 r = guestfs_mkdir (g, path);
12599 char path[] = "/new";
12601 suppress_error = 0;
12602 r = guestfs_exists (g, path);
12606 fprintf (stderr, "test_exists_1: expected true, got false\n");
12613 static int test_mkdir_p_0_skip (void)
12617 str = getenv ("SKIP_TEST_MKDIR_P_0");
12618 if (str && strcmp (str, "1") == 0) return 1;
12619 str = getenv ("SKIP_TEST_MKDIR_P");
12620 if (str && strcmp (str, "1") == 0) return 1;
12624 static int test_mkdir_p_0 (void)
12626 if (test_mkdir_p_0_skip ()) {
12627 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_0");
12631 /* InitBasicFS for test_mkdir_p_0: create ext2 on /dev/sda1 */
12633 char device[] = "/dev/sda";
12634 device[5] = devchar;
12636 suppress_error = 0;
12637 r = guestfs_blockdev_setrw (g, device);
12643 suppress_error = 0;
12644 r = guestfs_umount_all (g);
12650 suppress_error = 0;
12651 r = guestfs_lvm_remove_all (g);
12656 char device[] = "/dev/sda";
12657 device[5] = devchar;
12658 char lines_0[] = ",";
12664 suppress_error = 0;
12665 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12670 char fstype[] = "ext2";
12671 char device[] = "/dev/sda1";
12672 device[5] = devchar;
12674 suppress_error = 0;
12675 r = guestfs_mkfs (g, fstype, device);
12680 char device[] = "/dev/sda1";
12681 device[5] = devchar;
12682 char mountpoint[] = "/";
12684 suppress_error = 0;
12685 r = guestfs_mount (g, device, mountpoint);
12689 /* TestOutputTrue for mkdir_p (0) */
12691 char path[] = "/new/foo/bar";
12693 suppress_error = 0;
12694 r = guestfs_mkdir_p (g, path);
12699 char path[] = "/new/foo/bar";
12701 suppress_error = 0;
12702 r = guestfs_is_dir (g, path);
12706 fprintf (stderr, "test_mkdir_p_0: expected true, got false\n");
12713 static int test_mkdir_p_1_skip (void)
12717 str = getenv ("SKIP_TEST_MKDIR_P_1");
12718 if (str && strcmp (str, "1") == 0) return 1;
12719 str = getenv ("SKIP_TEST_MKDIR_P");
12720 if (str && strcmp (str, "1") == 0) return 1;
12724 static int test_mkdir_p_1 (void)
12726 if (test_mkdir_p_1_skip ()) {
12727 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_1");
12731 /* InitBasicFS for test_mkdir_p_1: create ext2 on /dev/sda1 */
12733 char device[] = "/dev/sda";
12734 device[5] = devchar;
12736 suppress_error = 0;
12737 r = guestfs_blockdev_setrw (g, device);
12743 suppress_error = 0;
12744 r = guestfs_umount_all (g);
12750 suppress_error = 0;
12751 r = guestfs_lvm_remove_all (g);
12756 char device[] = "/dev/sda";
12757 device[5] = devchar;
12758 char lines_0[] = ",";
12764 suppress_error = 0;
12765 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12770 char fstype[] = "ext2";
12771 char device[] = "/dev/sda1";
12772 device[5] = devchar;
12774 suppress_error = 0;
12775 r = guestfs_mkfs (g, fstype, device);
12780 char device[] = "/dev/sda1";
12781 device[5] = devchar;
12782 char mountpoint[] = "/";
12784 suppress_error = 0;
12785 r = guestfs_mount (g, device, mountpoint);
12789 /* TestOutputTrue for mkdir_p (1) */
12791 char path[] = "/new/foo/bar";
12793 suppress_error = 0;
12794 r = guestfs_mkdir_p (g, path);
12799 char path[] = "/new/foo";
12801 suppress_error = 0;
12802 r = guestfs_is_dir (g, path);
12806 fprintf (stderr, "test_mkdir_p_1: expected true, got false\n");
12813 static int test_mkdir_p_2_skip (void)
12817 str = getenv ("SKIP_TEST_MKDIR_P_2");
12818 if (str && strcmp (str, "1") == 0) return 1;
12819 str = getenv ("SKIP_TEST_MKDIR_P");
12820 if (str && strcmp (str, "1") == 0) return 1;
12824 static int test_mkdir_p_2 (void)
12826 if (test_mkdir_p_2_skip ()) {
12827 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_2");
12831 /* InitBasicFS for test_mkdir_p_2: create ext2 on /dev/sda1 */
12833 char device[] = "/dev/sda";
12834 device[5] = devchar;
12836 suppress_error = 0;
12837 r = guestfs_blockdev_setrw (g, device);
12843 suppress_error = 0;
12844 r = guestfs_umount_all (g);
12850 suppress_error = 0;
12851 r = guestfs_lvm_remove_all (g);
12856 char device[] = "/dev/sda";
12857 device[5] = devchar;
12858 char lines_0[] = ",";
12864 suppress_error = 0;
12865 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12870 char fstype[] = "ext2";
12871 char device[] = "/dev/sda1";
12872 device[5] = devchar;
12874 suppress_error = 0;
12875 r = guestfs_mkfs (g, fstype, device);
12880 char device[] = "/dev/sda1";
12881 device[5] = devchar;
12882 char mountpoint[] = "/";
12884 suppress_error = 0;
12885 r = guestfs_mount (g, device, mountpoint);
12889 /* TestOutputTrue for mkdir_p (2) */
12891 char path[] = "/new/foo/bar";
12893 suppress_error = 0;
12894 r = guestfs_mkdir_p (g, path);
12899 char path[] = "/new";
12901 suppress_error = 0;
12902 r = guestfs_is_dir (g, path);
12906 fprintf (stderr, "test_mkdir_p_2: expected true, got false\n");
12913 static int test_mkdir_p_3_skip (void)
12917 str = getenv ("SKIP_TEST_MKDIR_P_3");
12918 if (str && strcmp (str, "1") == 0) return 1;
12919 str = getenv ("SKIP_TEST_MKDIR_P");
12920 if (str && strcmp (str, "1") == 0) return 1;
12924 static int test_mkdir_p_3 (void)
12926 if (test_mkdir_p_3_skip ()) {
12927 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_3");
12931 /* InitBasicFS for test_mkdir_p_3: create ext2 on /dev/sda1 */
12933 char device[] = "/dev/sda";
12934 device[5] = devchar;
12936 suppress_error = 0;
12937 r = guestfs_blockdev_setrw (g, device);
12943 suppress_error = 0;
12944 r = guestfs_umount_all (g);
12950 suppress_error = 0;
12951 r = guestfs_lvm_remove_all (g);
12956 char device[] = "/dev/sda";
12957 device[5] = devchar;
12958 char lines_0[] = ",";
12964 suppress_error = 0;
12965 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
12970 char fstype[] = "ext2";
12971 char device[] = "/dev/sda1";
12972 device[5] = devchar;
12974 suppress_error = 0;
12975 r = guestfs_mkfs (g, fstype, device);
12980 char device[] = "/dev/sda1";
12981 device[5] = devchar;
12982 char mountpoint[] = "/";
12984 suppress_error = 0;
12985 r = guestfs_mount (g, device, mountpoint);
12989 /* TestRun for mkdir_p (3) */
12991 char path[] = "/new";
12993 suppress_error = 0;
12994 r = guestfs_mkdir (g, path);
12999 char path[] = "/new";
13001 suppress_error = 0;
13002 r = guestfs_mkdir_p (g, path);
13009 static int test_mkdir_p_4_skip (void)
13013 str = getenv ("SKIP_TEST_MKDIR_P_4");
13014 if (str && strcmp (str, "1") == 0) return 1;
13015 str = getenv ("SKIP_TEST_MKDIR_P");
13016 if (str && strcmp (str, "1") == 0) return 1;
13020 static int test_mkdir_p_4 (void)
13022 if (test_mkdir_p_4_skip ()) {
13023 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_p_4");
13027 /* InitBasicFS for test_mkdir_p_4: create ext2 on /dev/sda1 */
13029 char device[] = "/dev/sda";
13030 device[5] = devchar;
13032 suppress_error = 0;
13033 r = guestfs_blockdev_setrw (g, device);
13039 suppress_error = 0;
13040 r = guestfs_umount_all (g);
13046 suppress_error = 0;
13047 r = guestfs_lvm_remove_all (g);
13052 char device[] = "/dev/sda";
13053 device[5] = devchar;
13054 char lines_0[] = ",";
13060 suppress_error = 0;
13061 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13066 char fstype[] = "ext2";
13067 char device[] = "/dev/sda1";
13068 device[5] = devchar;
13070 suppress_error = 0;
13071 r = guestfs_mkfs (g, fstype, device);
13076 char device[] = "/dev/sda1";
13077 device[5] = devchar;
13078 char mountpoint[] = "/";
13080 suppress_error = 0;
13081 r = guestfs_mount (g, device, mountpoint);
13085 /* TestLastFail for mkdir_p (4) */
13087 char path[] = "/new";
13089 suppress_error = 0;
13090 r = guestfs_touch (g, path);
13095 char path[] = "/new";
13097 suppress_error = 1;
13098 r = guestfs_mkdir_p (g, path);
13105 static int test_mkdir_0_skip (void)
13109 str = getenv ("SKIP_TEST_MKDIR_0");
13110 if (str && strcmp (str, "1") == 0) return 1;
13111 str = getenv ("SKIP_TEST_MKDIR");
13112 if (str && strcmp (str, "1") == 0) return 1;
13116 static int test_mkdir_0 (void)
13118 if (test_mkdir_0_skip ()) {
13119 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_0");
13123 /* InitBasicFS for test_mkdir_0: create ext2 on /dev/sda1 */
13125 char device[] = "/dev/sda";
13126 device[5] = devchar;
13128 suppress_error = 0;
13129 r = guestfs_blockdev_setrw (g, device);
13135 suppress_error = 0;
13136 r = guestfs_umount_all (g);
13142 suppress_error = 0;
13143 r = guestfs_lvm_remove_all (g);
13148 char device[] = "/dev/sda";
13149 device[5] = devchar;
13150 char lines_0[] = ",";
13156 suppress_error = 0;
13157 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13162 char fstype[] = "ext2";
13163 char device[] = "/dev/sda1";
13164 device[5] = devchar;
13166 suppress_error = 0;
13167 r = guestfs_mkfs (g, fstype, device);
13172 char device[] = "/dev/sda1";
13173 device[5] = devchar;
13174 char mountpoint[] = "/";
13176 suppress_error = 0;
13177 r = guestfs_mount (g, device, mountpoint);
13181 /* TestOutputTrue for mkdir (0) */
13183 char path[] = "/new";
13185 suppress_error = 0;
13186 r = guestfs_mkdir (g, path);
13191 char path[] = "/new";
13193 suppress_error = 0;
13194 r = guestfs_is_dir (g, path);
13198 fprintf (stderr, "test_mkdir_0: expected true, got false\n");
13205 static int test_mkdir_1_skip (void)
13209 str = getenv ("SKIP_TEST_MKDIR_1");
13210 if (str && strcmp (str, "1") == 0) return 1;
13211 str = getenv ("SKIP_TEST_MKDIR");
13212 if (str && strcmp (str, "1") == 0) return 1;
13216 static int test_mkdir_1 (void)
13218 if (test_mkdir_1_skip ()) {
13219 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mkdir_1");
13223 /* InitBasicFS for test_mkdir_1: create ext2 on /dev/sda1 */
13225 char device[] = "/dev/sda";
13226 device[5] = devchar;
13228 suppress_error = 0;
13229 r = guestfs_blockdev_setrw (g, device);
13235 suppress_error = 0;
13236 r = guestfs_umount_all (g);
13242 suppress_error = 0;
13243 r = guestfs_lvm_remove_all (g);
13248 char device[] = "/dev/sda";
13249 device[5] = devchar;
13250 char lines_0[] = ",";
13256 suppress_error = 0;
13257 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13262 char fstype[] = "ext2";
13263 char device[] = "/dev/sda1";
13264 device[5] = devchar;
13266 suppress_error = 0;
13267 r = guestfs_mkfs (g, fstype, device);
13272 char device[] = "/dev/sda1";
13273 device[5] = devchar;
13274 char mountpoint[] = "/";
13276 suppress_error = 0;
13277 r = guestfs_mount (g, device, mountpoint);
13281 /* TestLastFail for mkdir (1) */
13283 char path[] = "/new/foo/bar";
13285 suppress_error = 1;
13286 r = guestfs_mkdir (g, path);
13293 static int test_rm_rf_0_skip (void)
13297 str = getenv ("SKIP_TEST_RM_RF_0");
13298 if (str && strcmp (str, "1") == 0) return 1;
13299 str = getenv ("SKIP_TEST_RM_RF");
13300 if (str && strcmp (str, "1") == 0) return 1;
13304 static int test_rm_rf_0 (void)
13306 if (test_rm_rf_0_skip ()) {
13307 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_rf_0");
13311 /* InitBasicFS for test_rm_rf_0: create ext2 on /dev/sda1 */
13313 char device[] = "/dev/sda";
13314 device[5] = devchar;
13316 suppress_error = 0;
13317 r = guestfs_blockdev_setrw (g, device);
13323 suppress_error = 0;
13324 r = guestfs_umount_all (g);
13330 suppress_error = 0;
13331 r = guestfs_lvm_remove_all (g);
13336 char device[] = "/dev/sda";
13337 device[5] = devchar;
13338 char lines_0[] = ",";
13344 suppress_error = 0;
13345 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13350 char fstype[] = "ext2";
13351 char device[] = "/dev/sda1";
13352 device[5] = devchar;
13354 suppress_error = 0;
13355 r = guestfs_mkfs (g, fstype, device);
13360 char device[] = "/dev/sda1";
13361 device[5] = devchar;
13362 char mountpoint[] = "/";
13364 suppress_error = 0;
13365 r = guestfs_mount (g, device, mountpoint);
13369 /* TestOutputFalse for rm_rf (0) */
13371 char path[] = "/new";
13373 suppress_error = 0;
13374 r = guestfs_mkdir (g, path);
13379 char path[] = "/new/foo";
13381 suppress_error = 0;
13382 r = guestfs_mkdir (g, path);
13387 char path[] = "/new/foo/bar";
13389 suppress_error = 0;
13390 r = guestfs_touch (g, path);
13395 char path[] = "/new";
13397 suppress_error = 0;
13398 r = guestfs_rm_rf (g, path);
13403 char path[] = "/new";
13405 suppress_error = 0;
13406 r = guestfs_exists (g, path);
13410 fprintf (stderr, "test_rm_rf_0: expected false, got true\n");
13417 static int test_rmdir_0_skip (void)
13421 str = getenv ("SKIP_TEST_RMDIR_0");
13422 if (str && strcmp (str, "1") == 0) return 1;
13423 str = getenv ("SKIP_TEST_RMDIR");
13424 if (str && strcmp (str, "1") == 0) return 1;
13428 static int test_rmdir_0 (void)
13430 if (test_rmdir_0_skip ()) {
13431 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_0");
13435 /* InitBasicFS for test_rmdir_0: create ext2 on /dev/sda1 */
13437 char device[] = "/dev/sda";
13438 device[5] = devchar;
13440 suppress_error = 0;
13441 r = guestfs_blockdev_setrw (g, device);
13447 suppress_error = 0;
13448 r = guestfs_umount_all (g);
13454 suppress_error = 0;
13455 r = guestfs_lvm_remove_all (g);
13460 char device[] = "/dev/sda";
13461 device[5] = devchar;
13462 char lines_0[] = ",";
13468 suppress_error = 0;
13469 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13474 char fstype[] = "ext2";
13475 char device[] = "/dev/sda1";
13476 device[5] = devchar;
13478 suppress_error = 0;
13479 r = guestfs_mkfs (g, fstype, device);
13484 char device[] = "/dev/sda1";
13485 device[5] = devchar;
13486 char mountpoint[] = "/";
13488 suppress_error = 0;
13489 r = guestfs_mount (g, device, mountpoint);
13493 /* TestRun for rmdir (0) */
13495 char path[] = "/new";
13497 suppress_error = 0;
13498 r = guestfs_mkdir (g, path);
13503 char path[] = "/new";
13505 suppress_error = 0;
13506 r = guestfs_rmdir (g, path);
13513 static int test_rmdir_1_skip (void)
13517 str = getenv ("SKIP_TEST_RMDIR_1");
13518 if (str && strcmp (str, "1") == 0) return 1;
13519 str = getenv ("SKIP_TEST_RMDIR");
13520 if (str && strcmp (str, "1") == 0) return 1;
13524 static int test_rmdir_1 (void)
13526 if (test_rmdir_1_skip ()) {
13527 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_1");
13531 /* InitBasicFS for test_rmdir_1: create ext2 on /dev/sda1 */
13533 char device[] = "/dev/sda";
13534 device[5] = devchar;
13536 suppress_error = 0;
13537 r = guestfs_blockdev_setrw (g, device);
13543 suppress_error = 0;
13544 r = guestfs_umount_all (g);
13550 suppress_error = 0;
13551 r = guestfs_lvm_remove_all (g);
13556 char device[] = "/dev/sda";
13557 device[5] = devchar;
13558 char lines_0[] = ",";
13564 suppress_error = 0;
13565 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13570 char fstype[] = "ext2";
13571 char device[] = "/dev/sda1";
13572 device[5] = devchar;
13574 suppress_error = 0;
13575 r = guestfs_mkfs (g, fstype, device);
13580 char device[] = "/dev/sda1";
13581 device[5] = devchar;
13582 char mountpoint[] = "/";
13584 suppress_error = 0;
13585 r = guestfs_mount (g, device, mountpoint);
13589 /* TestLastFail for rmdir (1) */
13591 char path[] = "/new";
13593 suppress_error = 1;
13594 r = guestfs_rmdir (g, path);
13601 static int test_rmdir_2_skip (void)
13605 str = getenv ("SKIP_TEST_RMDIR_2");
13606 if (str && strcmp (str, "1") == 0) return 1;
13607 str = getenv ("SKIP_TEST_RMDIR");
13608 if (str && strcmp (str, "1") == 0) return 1;
13612 static int test_rmdir_2 (void)
13614 if (test_rmdir_2_skip ()) {
13615 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rmdir_2");
13619 /* InitBasicFS for test_rmdir_2: create ext2 on /dev/sda1 */
13621 char device[] = "/dev/sda";
13622 device[5] = devchar;
13624 suppress_error = 0;
13625 r = guestfs_blockdev_setrw (g, device);
13631 suppress_error = 0;
13632 r = guestfs_umount_all (g);
13638 suppress_error = 0;
13639 r = guestfs_lvm_remove_all (g);
13644 char device[] = "/dev/sda";
13645 device[5] = devchar;
13646 char lines_0[] = ",";
13652 suppress_error = 0;
13653 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13658 char fstype[] = "ext2";
13659 char device[] = "/dev/sda1";
13660 device[5] = devchar;
13662 suppress_error = 0;
13663 r = guestfs_mkfs (g, fstype, device);
13668 char device[] = "/dev/sda1";
13669 device[5] = devchar;
13670 char mountpoint[] = "/";
13672 suppress_error = 0;
13673 r = guestfs_mount (g, device, mountpoint);
13677 /* TestLastFail for rmdir (2) */
13679 char path[] = "/new";
13681 suppress_error = 0;
13682 r = guestfs_touch (g, path);
13687 char path[] = "/new";
13689 suppress_error = 1;
13690 r = guestfs_rmdir (g, path);
13697 static int test_rm_0_skip (void)
13701 str = getenv ("SKIP_TEST_RM_0");
13702 if (str && strcmp (str, "1") == 0) return 1;
13703 str = getenv ("SKIP_TEST_RM");
13704 if (str && strcmp (str, "1") == 0) return 1;
13708 static int test_rm_0 (void)
13710 if (test_rm_0_skip ()) {
13711 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_0");
13715 /* InitBasicFS for test_rm_0: create ext2 on /dev/sda1 */
13717 char device[] = "/dev/sda";
13718 device[5] = devchar;
13720 suppress_error = 0;
13721 r = guestfs_blockdev_setrw (g, device);
13727 suppress_error = 0;
13728 r = guestfs_umount_all (g);
13734 suppress_error = 0;
13735 r = guestfs_lvm_remove_all (g);
13740 char device[] = "/dev/sda";
13741 device[5] = devchar;
13742 char lines_0[] = ",";
13748 suppress_error = 0;
13749 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13754 char fstype[] = "ext2";
13755 char device[] = "/dev/sda1";
13756 device[5] = devchar;
13758 suppress_error = 0;
13759 r = guestfs_mkfs (g, fstype, device);
13764 char device[] = "/dev/sda1";
13765 device[5] = devchar;
13766 char mountpoint[] = "/";
13768 suppress_error = 0;
13769 r = guestfs_mount (g, device, mountpoint);
13773 /* TestRun for rm (0) */
13775 char path[] = "/new";
13777 suppress_error = 0;
13778 r = guestfs_touch (g, path);
13783 char path[] = "/new";
13785 suppress_error = 0;
13786 r = guestfs_rm (g, path);
13793 static int test_rm_1_skip (void)
13797 str = getenv ("SKIP_TEST_RM_1");
13798 if (str && strcmp (str, "1") == 0) return 1;
13799 str = getenv ("SKIP_TEST_RM");
13800 if (str && strcmp (str, "1") == 0) return 1;
13804 static int test_rm_1 (void)
13806 if (test_rm_1_skip ()) {
13807 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_1");
13811 /* InitBasicFS for test_rm_1: create ext2 on /dev/sda1 */
13813 char device[] = "/dev/sda";
13814 device[5] = devchar;
13816 suppress_error = 0;
13817 r = guestfs_blockdev_setrw (g, device);
13823 suppress_error = 0;
13824 r = guestfs_umount_all (g);
13830 suppress_error = 0;
13831 r = guestfs_lvm_remove_all (g);
13836 char device[] = "/dev/sda";
13837 device[5] = devchar;
13838 char lines_0[] = ",";
13844 suppress_error = 0;
13845 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13850 char fstype[] = "ext2";
13851 char device[] = "/dev/sda1";
13852 device[5] = devchar;
13854 suppress_error = 0;
13855 r = guestfs_mkfs (g, fstype, device);
13860 char device[] = "/dev/sda1";
13861 device[5] = devchar;
13862 char mountpoint[] = "/";
13864 suppress_error = 0;
13865 r = guestfs_mount (g, device, mountpoint);
13869 /* TestLastFail for rm (1) */
13871 char path[] = "/new";
13873 suppress_error = 1;
13874 r = guestfs_rm (g, path);
13881 static int test_rm_2_skip (void)
13885 str = getenv ("SKIP_TEST_RM_2");
13886 if (str && strcmp (str, "1") == 0) return 1;
13887 str = getenv ("SKIP_TEST_RM");
13888 if (str && strcmp (str, "1") == 0) return 1;
13892 static int test_rm_2 (void)
13894 if (test_rm_2_skip ()) {
13895 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_rm_2");
13899 /* InitBasicFS for test_rm_2: create ext2 on /dev/sda1 */
13901 char device[] = "/dev/sda";
13902 device[5] = devchar;
13904 suppress_error = 0;
13905 r = guestfs_blockdev_setrw (g, device);
13911 suppress_error = 0;
13912 r = guestfs_umount_all (g);
13918 suppress_error = 0;
13919 r = guestfs_lvm_remove_all (g);
13924 char device[] = "/dev/sda";
13925 device[5] = devchar;
13926 char lines_0[] = ",";
13932 suppress_error = 0;
13933 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
13938 char fstype[] = "ext2";
13939 char device[] = "/dev/sda1";
13940 device[5] = devchar;
13942 suppress_error = 0;
13943 r = guestfs_mkfs (g, fstype, device);
13948 char device[] = "/dev/sda1";
13949 device[5] = devchar;
13950 char mountpoint[] = "/";
13952 suppress_error = 0;
13953 r = guestfs_mount (g, device, mountpoint);
13957 /* TestLastFail for rm (2) */
13959 char path[] = "/new";
13961 suppress_error = 0;
13962 r = guestfs_mkdir (g, path);
13967 char path[] = "/new";
13969 suppress_error = 1;
13970 r = guestfs_rm (g, path);
13977 static int test_read_lines_0_skip (void)
13981 str = getenv ("SKIP_TEST_READ_LINES_0");
13982 if (str && strcmp (str, "1") == 0) return 1;
13983 str = getenv ("SKIP_TEST_READ_LINES");
13984 if (str && strcmp (str, "1") == 0) return 1;
13988 static int test_read_lines_0 (void)
13990 if (test_read_lines_0_skip ()) {
13991 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_0");
13995 /* InitBasicFS for test_read_lines_0: create ext2 on /dev/sda1 */
13997 char device[] = "/dev/sda";
13998 device[5] = devchar;
14000 suppress_error = 0;
14001 r = guestfs_blockdev_setrw (g, device);
14007 suppress_error = 0;
14008 r = guestfs_umount_all (g);
14014 suppress_error = 0;
14015 r = guestfs_lvm_remove_all (g);
14020 char device[] = "/dev/sda";
14021 device[5] = devchar;
14022 char lines_0[] = ",";
14028 suppress_error = 0;
14029 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14034 char fstype[] = "ext2";
14035 char device[] = "/dev/sda1";
14036 device[5] = devchar;
14038 suppress_error = 0;
14039 r = guestfs_mkfs (g, fstype, device);
14044 char device[] = "/dev/sda1";
14045 device[5] = devchar;
14046 char mountpoint[] = "/";
14048 suppress_error = 0;
14049 r = guestfs_mount (g, device, mountpoint);
14053 /* TestOutputList for read_lines (0) */
14055 char path[] = "/new";
14056 char content[] = "line1\r\nline2\nline3";
14058 suppress_error = 0;
14059 r = guestfs_write_file (g, path, content, 0);
14064 char path[] = "/new";
14067 suppress_error = 0;
14068 r = guestfs_read_lines (g, path);
14072 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14077 char expected[] = "line1";
14078 if (strcmp (r[0], expected) != 0) {
14079 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14084 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14089 char expected[] = "line2";
14090 if (strcmp (r[1], expected) != 0) {
14091 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14096 fprintf (stderr, "test_read_lines_0: short list returned from command\n");
14101 char expected[] = "line3";
14102 if (strcmp (r[2], expected) != 0) {
14103 fprintf (stderr, "test_read_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14107 if (r[3] != NULL) {
14108 fprintf (stderr, "test_read_lines_0: extra elements returned from command\n");
14112 for (i = 0; r[i] != NULL; ++i)
14119 static int test_read_lines_1_skip (void)
14123 str = getenv ("SKIP_TEST_READ_LINES_1");
14124 if (str && strcmp (str, "1") == 0) return 1;
14125 str = getenv ("SKIP_TEST_READ_LINES");
14126 if (str && strcmp (str, "1") == 0) return 1;
14130 static int test_read_lines_1 (void)
14132 if (test_read_lines_1_skip ()) {
14133 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_read_lines_1");
14137 /* InitBasicFS for test_read_lines_1: create ext2 on /dev/sda1 */
14139 char device[] = "/dev/sda";
14140 device[5] = devchar;
14142 suppress_error = 0;
14143 r = guestfs_blockdev_setrw (g, device);
14149 suppress_error = 0;
14150 r = guestfs_umount_all (g);
14156 suppress_error = 0;
14157 r = guestfs_lvm_remove_all (g);
14162 char device[] = "/dev/sda";
14163 device[5] = devchar;
14164 char lines_0[] = ",";
14170 suppress_error = 0;
14171 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14176 char fstype[] = "ext2";
14177 char device[] = "/dev/sda1";
14178 device[5] = devchar;
14180 suppress_error = 0;
14181 r = guestfs_mkfs (g, fstype, device);
14186 char device[] = "/dev/sda1";
14187 device[5] = devchar;
14188 char mountpoint[] = "/";
14190 suppress_error = 0;
14191 r = guestfs_mount (g, device, mountpoint);
14195 /* TestOutputList for read_lines (1) */
14197 char path[] = "/new";
14198 char content[] = "";
14200 suppress_error = 0;
14201 r = guestfs_write_file (g, path, content, 0);
14206 char path[] = "/new";
14209 suppress_error = 0;
14210 r = guestfs_read_lines (g, path);
14213 if (r[0] != NULL) {
14214 fprintf (stderr, "test_read_lines_1: extra elements returned from command\n");
14218 for (i = 0; r[i] != NULL; ++i)
14225 static int test_lvs_0_skip (void)
14229 str = getenv ("SKIP_TEST_LVS_0");
14230 if (str && strcmp (str, "1") == 0) return 1;
14231 str = getenv ("SKIP_TEST_LVS");
14232 if (str && strcmp (str, "1") == 0) return 1;
14236 static int test_lvs_0 (void)
14238 if (test_lvs_0_skip ()) {
14239 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_0");
14243 /* InitBasicFSonLVM for test_lvs_0: create ext2 on /dev/VG/LV */
14245 char device[] = "/dev/sda";
14246 device[5] = devchar;
14248 suppress_error = 0;
14249 r = guestfs_blockdev_setrw (g, device);
14255 suppress_error = 0;
14256 r = guestfs_umount_all (g);
14262 suppress_error = 0;
14263 r = guestfs_lvm_remove_all (g);
14268 char device[] = "/dev/sda";
14269 device[5] = devchar;
14270 char lines_0[] = ",";
14276 suppress_error = 0;
14277 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14282 char device[] = "/dev/sda1";
14283 device[5] = devchar;
14285 suppress_error = 0;
14286 r = guestfs_pvcreate (g, device);
14291 char volgroup[] = "VG";
14292 char physvols_0[] = "/dev/sda1";
14293 physvols_0[5] = devchar;
14294 char *physvols[] = {
14299 suppress_error = 0;
14300 r = guestfs_vgcreate (g, volgroup, physvols);
14305 char logvol[] = "LV";
14306 char volgroup[] = "VG";
14308 suppress_error = 0;
14309 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14314 char fstype[] = "ext2";
14315 char device[] = "/dev/VG/LV";
14317 suppress_error = 0;
14318 r = guestfs_mkfs (g, fstype, device);
14323 char device[] = "/dev/VG/LV";
14324 char mountpoint[] = "/";
14326 suppress_error = 0;
14327 r = guestfs_mount (g, device, mountpoint);
14331 /* TestOutputList for lvs (0) */
14335 suppress_error = 0;
14336 r = guestfs_lvs (g);
14340 fprintf (stderr, "test_lvs_0: short list returned from command\n");
14345 char expected[] = "/dev/VG/LV";
14346 if (strcmp (r[0], expected) != 0) {
14347 fprintf (stderr, "test_lvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14351 if (r[1] != NULL) {
14352 fprintf (stderr, "test_lvs_0: extra elements returned from command\n");
14356 for (i = 0; r[i] != NULL; ++i)
14363 static int test_lvs_1_skip (void)
14367 str = getenv ("SKIP_TEST_LVS_1");
14368 if (str && strcmp (str, "1") == 0) return 1;
14369 str = getenv ("SKIP_TEST_LVS");
14370 if (str && strcmp (str, "1") == 0) return 1;
14374 static int test_lvs_1 (void)
14376 if (test_lvs_1_skip ()) {
14377 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_lvs_1");
14381 /* InitNone|InitEmpty for test_lvs_1 */
14383 char device[] = "/dev/sda";
14384 device[5] = devchar;
14386 suppress_error = 0;
14387 r = guestfs_blockdev_setrw (g, device);
14393 suppress_error = 0;
14394 r = guestfs_umount_all (g);
14400 suppress_error = 0;
14401 r = guestfs_lvm_remove_all (g);
14405 /* TestOutputList for lvs (1) */
14407 char device[] = "/dev/sda";
14408 device[5] = devchar;
14409 char lines_0[] = ",10";
14410 char lines_1[] = ",20";
14411 char lines_2[] = ",";
14419 suppress_error = 0;
14420 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14425 char device[] = "/dev/sda1";
14426 device[5] = devchar;
14428 suppress_error = 0;
14429 r = guestfs_pvcreate (g, device);
14434 char device[] = "/dev/sda2";
14435 device[5] = devchar;
14437 suppress_error = 0;
14438 r = guestfs_pvcreate (g, device);
14443 char device[] = "/dev/sda3";
14444 device[5] = devchar;
14446 suppress_error = 0;
14447 r = guestfs_pvcreate (g, device);
14452 char volgroup[] = "VG1";
14453 char physvols_0[] = "/dev/sda1";
14454 physvols_0[5] = devchar;
14455 char physvols_1[] = "/dev/sda2";
14456 physvols_1[5] = devchar;
14457 char *physvols[] = {
14463 suppress_error = 0;
14464 r = guestfs_vgcreate (g, volgroup, physvols);
14469 char volgroup[] = "VG2";
14470 char physvols_0[] = "/dev/sda3";
14471 physvols_0[5] = devchar;
14472 char *physvols[] = {
14477 suppress_error = 0;
14478 r = guestfs_vgcreate (g, volgroup, physvols);
14483 char logvol[] = "LV1";
14484 char volgroup[] = "VG1";
14486 suppress_error = 0;
14487 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14492 char logvol[] = "LV2";
14493 char volgroup[] = "VG1";
14495 suppress_error = 0;
14496 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14501 char logvol[] = "LV3";
14502 char volgroup[] = "VG2";
14504 suppress_error = 0;
14505 r = guestfs_lvcreate (g, logvol, volgroup, 50);
14512 suppress_error = 0;
14513 r = guestfs_lvs (g);
14517 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14522 char expected[] = "/dev/VG1/LV1";
14523 if (strcmp (r[0], expected) != 0) {
14524 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14529 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14534 char expected[] = "/dev/VG1/LV2";
14535 if (strcmp (r[1], expected) != 0) {
14536 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14541 fprintf (stderr, "test_lvs_1: short list returned from command\n");
14546 char expected[] = "/dev/VG2/LV3";
14547 if (strcmp (r[2], expected) != 0) {
14548 fprintf (stderr, "test_lvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
14552 if (r[3] != NULL) {
14553 fprintf (stderr, "test_lvs_1: extra elements returned from command\n");
14557 for (i = 0; r[i] != NULL; ++i)
14564 static int test_vgs_0_skip (void)
14568 str = getenv ("SKIP_TEST_VGS_0");
14569 if (str && strcmp (str, "1") == 0) return 1;
14570 str = getenv ("SKIP_TEST_VGS");
14571 if (str && strcmp (str, "1") == 0) return 1;
14575 static int test_vgs_0 (void)
14577 if (test_vgs_0_skip ()) {
14578 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_0");
14582 /* InitBasicFSonLVM for test_vgs_0: create ext2 on /dev/VG/LV */
14584 char device[] = "/dev/sda";
14585 device[5] = devchar;
14587 suppress_error = 0;
14588 r = guestfs_blockdev_setrw (g, device);
14594 suppress_error = 0;
14595 r = guestfs_umount_all (g);
14601 suppress_error = 0;
14602 r = guestfs_lvm_remove_all (g);
14607 char device[] = "/dev/sda";
14608 device[5] = devchar;
14609 char lines_0[] = ",";
14615 suppress_error = 0;
14616 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14621 char device[] = "/dev/sda1";
14622 device[5] = devchar;
14624 suppress_error = 0;
14625 r = guestfs_pvcreate (g, device);
14630 char volgroup[] = "VG";
14631 char physvols_0[] = "/dev/sda1";
14632 physvols_0[5] = devchar;
14633 char *physvols[] = {
14638 suppress_error = 0;
14639 r = guestfs_vgcreate (g, volgroup, physvols);
14644 char logvol[] = "LV";
14645 char volgroup[] = "VG";
14647 suppress_error = 0;
14648 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14653 char fstype[] = "ext2";
14654 char device[] = "/dev/VG/LV";
14656 suppress_error = 0;
14657 r = guestfs_mkfs (g, fstype, device);
14662 char device[] = "/dev/VG/LV";
14663 char mountpoint[] = "/";
14665 suppress_error = 0;
14666 r = guestfs_mount (g, device, mountpoint);
14670 /* TestOutputList for vgs (0) */
14674 suppress_error = 0;
14675 r = guestfs_vgs (g);
14679 fprintf (stderr, "test_vgs_0: short list returned from command\n");
14684 char expected[] = "VG";
14685 if (strcmp (r[0], expected) != 0) {
14686 fprintf (stderr, "test_vgs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14690 if (r[1] != NULL) {
14691 fprintf (stderr, "test_vgs_0: extra elements returned from command\n");
14695 for (i = 0; r[i] != NULL; ++i)
14702 static int test_vgs_1_skip (void)
14706 str = getenv ("SKIP_TEST_VGS_1");
14707 if (str && strcmp (str, "1") == 0) return 1;
14708 str = getenv ("SKIP_TEST_VGS");
14709 if (str && strcmp (str, "1") == 0) return 1;
14713 static int test_vgs_1 (void)
14715 if (test_vgs_1_skip ()) {
14716 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_vgs_1");
14720 /* InitNone|InitEmpty for test_vgs_1 */
14722 char device[] = "/dev/sda";
14723 device[5] = devchar;
14725 suppress_error = 0;
14726 r = guestfs_blockdev_setrw (g, device);
14732 suppress_error = 0;
14733 r = guestfs_umount_all (g);
14739 suppress_error = 0;
14740 r = guestfs_lvm_remove_all (g);
14744 /* TestOutputList for vgs (1) */
14746 char device[] = "/dev/sda";
14747 device[5] = devchar;
14748 char lines_0[] = ",10";
14749 char lines_1[] = ",20";
14750 char lines_2[] = ",";
14758 suppress_error = 0;
14759 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14764 char device[] = "/dev/sda1";
14765 device[5] = devchar;
14767 suppress_error = 0;
14768 r = guestfs_pvcreate (g, device);
14773 char device[] = "/dev/sda2";
14774 device[5] = devchar;
14776 suppress_error = 0;
14777 r = guestfs_pvcreate (g, device);
14782 char device[] = "/dev/sda3";
14783 device[5] = devchar;
14785 suppress_error = 0;
14786 r = guestfs_pvcreate (g, device);
14791 char volgroup[] = "VG1";
14792 char physvols_0[] = "/dev/sda1";
14793 physvols_0[5] = devchar;
14794 char physvols_1[] = "/dev/sda2";
14795 physvols_1[5] = devchar;
14796 char *physvols[] = {
14802 suppress_error = 0;
14803 r = guestfs_vgcreate (g, volgroup, physvols);
14808 char volgroup[] = "VG2";
14809 char physvols_0[] = "/dev/sda3";
14810 physvols_0[5] = devchar;
14811 char *physvols[] = {
14816 suppress_error = 0;
14817 r = guestfs_vgcreate (g, volgroup, physvols);
14824 suppress_error = 0;
14825 r = guestfs_vgs (g);
14829 fprintf (stderr, "test_vgs_1: short list returned from command\n");
14834 char expected[] = "VG1";
14835 if (strcmp (r[0], expected) != 0) {
14836 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14841 fprintf (stderr, "test_vgs_1: short list returned from command\n");
14846 char expected[] = "VG2";
14847 if (strcmp (r[1], expected) != 0) {
14848 fprintf (stderr, "test_vgs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
14852 if (r[2] != NULL) {
14853 fprintf (stderr, "test_vgs_1: extra elements returned from command\n");
14857 for (i = 0; r[i] != NULL; ++i)
14864 static int test_pvs_0_skip (void)
14868 str = getenv ("SKIP_TEST_PVS_0");
14869 if (str && strcmp (str, "1") == 0) return 1;
14870 str = getenv ("SKIP_TEST_PVS");
14871 if (str && strcmp (str, "1") == 0) return 1;
14875 static int test_pvs_0 (void)
14877 if (test_pvs_0_skip ()) {
14878 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_0");
14882 /* InitBasicFSonLVM for test_pvs_0: create ext2 on /dev/VG/LV */
14884 char device[] = "/dev/sda";
14885 device[5] = devchar;
14887 suppress_error = 0;
14888 r = guestfs_blockdev_setrw (g, device);
14894 suppress_error = 0;
14895 r = guestfs_umount_all (g);
14901 suppress_error = 0;
14902 r = guestfs_lvm_remove_all (g);
14907 char device[] = "/dev/sda";
14908 device[5] = devchar;
14909 char lines_0[] = ",";
14915 suppress_error = 0;
14916 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
14921 char device[] = "/dev/sda1";
14922 device[5] = devchar;
14924 suppress_error = 0;
14925 r = guestfs_pvcreate (g, device);
14930 char volgroup[] = "VG";
14931 char physvols_0[] = "/dev/sda1";
14932 physvols_0[5] = devchar;
14933 char *physvols[] = {
14938 suppress_error = 0;
14939 r = guestfs_vgcreate (g, volgroup, physvols);
14944 char logvol[] = "LV";
14945 char volgroup[] = "VG";
14947 suppress_error = 0;
14948 r = guestfs_lvcreate (g, logvol, volgroup, 8);
14953 char fstype[] = "ext2";
14954 char device[] = "/dev/VG/LV";
14956 suppress_error = 0;
14957 r = guestfs_mkfs (g, fstype, device);
14962 char device[] = "/dev/VG/LV";
14963 char mountpoint[] = "/";
14965 suppress_error = 0;
14966 r = guestfs_mount (g, device, mountpoint);
14970 /* TestOutputList for pvs (0) */
14974 suppress_error = 0;
14975 r = guestfs_pvs (g);
14979 fprintf (stderr, "test_pvs_0: short list returned from command\n");
14984 char expected[] = "/dev/sda1";
14985 expected[5] = devchar;
14986 if (strcmp (r[0], expected) != 0) {
14987 fprintf (stderr, "test_pvs_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
14991 if (r[1] != NULL) {
14992 fprintf (stderr, "test_pvs_0: extra elements returned from command\n");
14996 for (i = 0; r[i] != NULL; ++i)
15003 static int test_pvs_1_skip (void)
15007 str = getenv ("SKIP_TEST_PVS_1");
15008 if (str && strcmp (str, "1") == 0) return 1;
15009 str = getenv ("SKIP_TEST_PVS");
15010 if (str && strcmp (str, "1") == 0) return 1;
15014 static int test_pvs_1 (void)
15016 if (test_pvs_1_skip ()) {
15017 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_pvs_1");
15021 /* InitNone|InitEmpty for test_pvs_1 */
15023 char device[] = "/dev/sda";
15024 device[5] = devchar;
15026 suppress_error = 0;
15027 r = guestfs_blockdev_setrw (g, device);
15033 suppress_error = 0;
15034 r = guestfs_umount_all (g);
15040 suppress_error = 0;
15041 r = guestfs_lvm_remove_all (g);
15045 /* TestOutputList for pvs (1) */
15047 char device[] = "/dev/sda";
15048 device[5] = devchar;
15049 char lines_0[] = ",10";
15050 char lines_1[] = ",20";
15051 char lines_2[] = ",";
15059 suppress_error = 0;
15060 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15065 char device[] = "/dev/sda1";
15066 device[5] = devchar;
15068 suppress_error = 0;
15069 r = guestfs_pvcreate (g, device);
15074 char device[] = "/dev/sda2";
15075 device[5] = devchar;
15077 suppress_error = 0;
15078 r = guestfs_pvcreate (g, device);
15083 char device[] = "/dev/sda3";
15084 device[5] = devchar;
15086 suppress_error = 0;
15087 r = guestfs_pvcreate (g, device);
15094 suppress_error = 0;
15095 r = guestfs_pvs (g);
15099 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15104 char expected[] = "/dev/sda1";
15105 expected[5] = devchar;
15106 if (strcmp (r[0], expected) != 0) {
15107 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15112 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15117 char expected[] = "/dev/sda2";
15118 expected[5] = devchar;
15119 if (strcmp (r[1], expected) != 0) {
15120 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15125 fprintf (stderr, "test_pvs_1: short list returned from command\n");
15130 char expected[] = "/dev/sda3";
15131 expected[5] = devchar;
15132 if (strcmp (r[2], expected) != 0) {
15133 fprintf (stderr, "test_pvs_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15137 if (r[3] != NULL) {
15138 fprintf (stderr, "test_pvs_1: extra elements returned from command\n");
15142 for (i = 0; r[i] != NULL; ++i)
15149 static int test_list_partitions_0_skip (void)
15153 str = getenv ("SKIP_TEST_LIST_PARTITIONS_0");
15154 if (str && strcmp (str, "1") == 0) return 1;
15155 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
15156 if (str && strcmp (str, "1") == 0) return 1;
15160 static int test_list_partitions_0 (void)
15162 if (test_list_partitions_0_skip ()) {
15163 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_0");
15167 /* InitBasicFS for test_list_partitions_0: create ext2 on /dev/sda1 */
15169 char device[] = "/dev/sda";
15170 device[5] = devchar;
15172 suppress_error = 0;
15173 r = guestfs_blockdev_setrw (g, device);
15179 suppress_error = 0;
15180 r = guestfs_umount_all (g);
15186 suppress_error = 0;
15187 r = guestfs_lvm_remove_all (g);
15192 char device[] = "/dev/sda";
15193 device[5] = devchar;
15194 char lines_0[] = ",";
15200 suppress_error = 0;
15201 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15206 char fstype[] = "ext2";
15207 char device[] = "/dev/sda1";
15208 device[5] = devchar;
15210 suppress_error = 0;
15211 r = guestfs_mkfs (g, fstype, device);
15216 char device[] = "/dev/sda1";
15217 device[5] = devchar;
15218 char mountpoint[] = "/";
15220 suppress_error = 0;
15221 r = guestfs_mount (g, device, mountpoint);
15225 /* TestOutputList for list_partitions (0) */
15229 suppress_error = 0;
15230 r = guestfs_list_partitions (g);
15234 fprintf (stderr, "test_list_partitions_0: short list returned from command\n");
15239 char expected[] = "/dev/sda1";
15240 expected[5] = devchar;
15241 if (strcmp (r[0], expected) != 0) {
15242 fprintf (stderr, "test_list_partitions_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15246 if (r[1] != NULL) {
15247 fprintf (stderr, "test_list_partitions_0: extra elements returned from command\n");
15251 for (i = 0; r[i] != NULL; ++i)
15258 static int test_list_partitions_1_skip (void)
15262 str = getenv ("SKIP_TEST_LIST_PARTITIONS_1");
15263 if (str && strcmp (str, "1") == 0) return 1;
15264 str = getenv ("SKIP_TEST_LIST_PARTITIONS");
15265 if (str && strcmp (str, "1") == 0) return 1;
15269 static int test_list_partitions_1 (void)
15271 if (test_list_partitions_1_skip ()) {
15272 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_partitions_1");
15276 /* InitNone|InitEmpty for test_list_partitions_1 */
15278 char device[] = "/dev/sda";
15279 device[5] = devchar;
15281 suppress_error = 0;
15282 r = guestfs_blockdev_setrw (g, device);
15288 suppress_error = 0;
15289 r = guestfs_umount_all (g);
15295 suppress_error = 0;
15296 r = guestfs_lvm_remove_all (g);
15300 /* TestOutputList for list_partitions (1) */
15302 char device[] = "/dev/sda";
15303 device[5] = devchar;
15304 char lines_0[] = ",10";
15305 char lines_1[] = ",20";
15306 char lines_2[] = ",";
15314 suppress_error = 0;
15315 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15322 suppress_error = 0;
15323 r = guestfs_list_partitions (g);
15327 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15332 char expected[] = "/dev/sda1";
15333 expected[5] = devchar;
15334 if (strcmp (r[0], expected) != 0) {
15335 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15340 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15345 char expected[] = "/dev/sda2";
15346 expected[5] = devchar;
15347 if (strcmp (r[1], expected) != 0) {
15348 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15353 fprintf (stderr, "test_list_partitions_1: short list returned from command\n");
15358 char expected[] = "/dev/sda3";
15359 expected[5] = devchar;
15360 if (strcmp (r[2], expected) != 0) {
15361 fprintf (stderr, "test_list_partitions_1: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15365 if (r[3] != NULL) {
15366 fprintf (stderr, "test_list_partitions_1: extra elements returned from command\n");
15370 for (i = 0; r[i] != NULL; ++i)
15377 static int test_list_devices_0_skip (void)
15381 str = getenv ("SKIP_TEST_LIST_DEVICES_0");
15382 if (str && strcmp (str, "1") == 0) return 1;
15383 str = getenv ("SKIP_TEST_LIST_DEVICES");
15384 if (str && strcmp (str, "1") == 0) return 1;
15388 static int test_list_devices_0 (void)
15390 if (test_list_devices_0_skip ()) {
15391 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_list_devices_0");
15395 /* InitNone|InitEmpty for test_list_devices_0 */
15397 char device[] = "/dev/sda";
15398 device[5] = devchar;
15400 suppress_error = 0;
15401 r = guestfs_blockdev_setrw (g, device);
15407 suppress_error = 0;
15408 r = guestfs_umount_all (g);
15414 suppress_error = 0;
15415 r = guestfs_lvm_remove_all (g);
15419 /* TestOutputList for list_devices (0) */
15423 suppress_error = 0;
15424 r = guestfs_list_devices (g);
15428 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15433 char expected[] = "/dev/sda";
15434 expected[5] = devchar;
15435 if (strcmp (r[0], expected) != 0) {
15436 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15441 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15446 char expected[] = "/dev/sdb";
15447 expected[5] = devchar;
15448 if (strcmp (r[1], expected) != 0) {
15449 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15454 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15459 char expected[] = "/dev/sdc";
15460 expected[5] = devchar;
15461 if (strcmp (r[2], expected) != 0) {
15462 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15467 fprintf (stderr, "test_list_devices_0: short list returned from command\n");
15472 char expected[] = "/dev/sdd";
15473 expected[5] = devchar;
15474 if (strcmp (r[3], expected) != 0) {
15475 fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
15479 if (r[4] != NULL) {
15480 fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
15484 for (i = 0; r[i] != NULL; ++i)
15491 static int test_ls_0_skip (void)
15495 str = getenv ("SKIP_TEST_LS_0");
15496 if (str && strcmp (str, "1") == 0) return 1;
15497 str = getenv ("SKIP_TEST_LS");
15498 if (str && strcmp (str, "1") == 0) return 1;
15502 static int test_ls_0 (void)
15504 if (test_ls_0_skip ()) {
15505 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ls_0");
15509 /* InitBasicFS for test_ls_0: create ext2 on /dev/sda1 */
15511 char device[] = "/dev/sda";
15512 device[5] = devchar;
15514 suppress_error = 0;
15515 r = guestfs_blockdev_setrw (g, device);
15521 suppress_error = 0;
15522 r = guestfs_umount_all (g);
15528 suppress_error = 0;
15529 r = guestfs_lvm_remove_all (g);
15534 char device[] = "/dev/sda";
15535 device[5] = devchar;
15536 char lines_0[] = ",";
15542 suppress_error = 0;
15543 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15548 char fstype[] = "ext2";
15549 char device[] = "/dev/sda1";
15550 device[5] = devchar;
15552 suppress_error = 0;
15553 r = guestfs_mkfs (g, fstype, device);
15558 char device[] = "/dev/sda1";
15559 device[5] = devchar;
15560 char mountpoint[] = "/";
15562 suppress_error = 0;
15563 r = guestfs_mount (g, device, mountpoint);
15567 /* TestOutputList for ls (0) */
15569 char path[] = "/new";
15571 suppress_error = 0;
15572 r = guestfs_touch (g, path);
15577 char path[] = "/newer";
15579 suppress_error = 0;
15580 r = guestfs_touch (g, path);
15585 char path[] = "/newest";
15587 suppress_error = 0;
15588 r = guestfs_touch (g, path);
15593 char directory[] = "/";
15596 suppress_error = 0;
15597 r = guestfs_ls (g, directory);
15601 fprintf (stderr, "test_ls_0: short list returned from command\n");
15606 char expected[] = "lost+found";
15607 if (strcmp (r[0], expected) != 0) {
15608 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[0]);
15613 fprintf (stderr, "test_ls_0: short list returned from command\n");
15618 char expected[] = "new";
15619 if (strcmp (r[1], expected) != 0) {
15620 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[1]);
15625 fprintf (stderr, "test_ls_0: short list returned from command\n");
15630 char expected[] = "newer";
15631 if (strcmp (r[2], expected) != 0) {
15632 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[2]);
15637 fprintf (stderr, "test_ls_0: short list returned from command\n");
15642 char expected[] = "newest";
15643 if (strcmp (r[3], expected) != 0) {
15644 fprintf (stderr, "test_ls_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
15648 if (r[4] != NULL) {
15649 fprintf (stderr, "test_ls_0: extra elements returned from command\n");
15653 for (i = 0; r[i] != NULL; ++i)
15660 static int test_cat_0_skip (void)
15664 str = getenv ("SKIP_TEST_CAT_0");
15665 if (str && strcmp (str, "1") == 0) return 1;
15666 str = getenv ("SKIP_TEST_CAT");
15667 if (str && strcmp (str, "1") == 0) return 1;
15671 static int test_cat_0 (void)
15673 if (test_cat_0_skip ()) {
15674 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_cat_0");
15678 /* InitBasicFS for test_cat_0: create ext2 on /dev/sda1 */
15680 char device[] = "/dev/sda";
15681 device[5] = devchar;
15683 suppress_error = 0;
15684 r = guestfs_blockdev_setrw (g, device);
15690 suppress_error = 0;
15691 r = guestfs_umount_all (g);
15697 suppress_error = 0;
15698 r = guestfs_lvm_remove_all (g);
15703 char device[] = "/dev/sda";
15704 device[5] = devchar;
15705 char lines_0[] = ",";
15711 suppress_error = 0;
15712 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15717 char fstype[] = "ext2";
15718 char device[] = "/dev/sda1";
15719 device[5] = devchar;
15721 suppress_error = 0;
15722 r = guestfs_mkfs (g, fstype, device);
15727 char device[] = "/dev/sda1";
15728 device[5] = devchar;
15729 char mountpoint[] = "/";
15731 suppress_error = 0;
15732 r = guestfs_mount (g, device, mountpoint);
15736 /* TestOutput for cat (0) */
15737 char expected[] = "new file contents";
15739 char path[] = "/new";
15740 char content[] = "new file contents";
15742 suppress_error = 0;
15743 r = guestfs_write_file (g, path, content, 0);
15748 char path[] = "/new";
15750 suppress_error = 0;
15751 r = guestfs_cat (g, path);
15754 if (strcmp (r, expected) != 0) {
15755 fprintf (stderr, "test_cat_0: expected \"%s\" but got \"%s\"\n", expected, r);
15763 static int test_touch_0_skip (void)
15767 str = getenv ("SKIP_TEST_TOUCH_0");
15768 if (str && strcmp (str, "1") == 0) return 1;
15769 str = getenv ("SKIP_TEST_TOUCH");
15770 if (str && strcmp (str, "1") == 0) return 1;
15774 static int test_touch_0 (void)
15776 if (test_touch_0_skip ()) {
15777 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_touch_0");
15781 /* InitBasicFS for test_touch_0: create ext2 on /dev/sda1 */
15783 char device[] = "/dev/sda";
15784 device[5] = devchar;
15786 suppress_error = 0;
15787 r = guestfs_blockdev_setrw (g, device);
15793 suppress_error = 0;
15794 r = guestfs_umount_all (g);
15800 suppress_error = 0;
15801 r = guestfs_lvm_remove_all (g);
15806 char device[] = "/dev/sda";
15807 device[5] = devchar;
15808 char lines_0[] = ",";
15814 suppress_error = 0;
15815 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15820 char fstype[] = "ext2";
15821 char device[] = "/dev/sda1";
15822 device[5] = devchar;
15824 suppress_error = 0;
15825 r = guestfs_mkfs (g, fstype, device);
15830 char device[] = "/dev/sda1";
15831 device[5] = devchar;
15832 char mountpoint[] = "/";
15834 suppress_error = 0;
15835 r = guestfs_mount (g, device, mountpoint);
15839 /* TestOutputTrue for touch (0) */
15841 char path[] = "/new";
15843 suppress_error = 0;
15844 r = guestfs_touch (g, path);
15849 char path[] = "/new";
15851 suppress_error = 0;
15852 r = guestfs_exists (g, path);
15856 fprintf (stderr, "test_touch_0: expected true, got false\n");
15863 static int test_sync_0_skip (void)
15867 str = getenv ("SKIP_TEST_SYNC_0");
15868 if (str && strcmp (str, "1") == 0) return 1;
15869 str = getenv ("SKIP_TEST_SYNC");
15870 if (str && strcmp (str, "1") == 0) return 1;
15874 static int test_sync_0 (void)
15876 if (test_sync_0_skip ()) {
15877 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_sync_0");
15881 /* InitNone|InitEmpty for test_sync_0 */
15883 char device[] = "/dev/sda";
15884 device[5] = devchar;
15886 suppress_error = 0;
15887 r = guestfs_blockdev_setrw (g, device);
15893 suppress_error = 0;
15894 r = guestfs_umount_all (g);
15900 suppress_error = 0;
15901 r = guestfs_lvm_remove_all (g);
15905 /* TestRun for sync (0) */
15908 suppress_error = 0;
15909 r = guestfs_sync (g);
15916 static int test_mount_0_skip (void)
15920 str = getenv ("SKIP_TEST_MOUNT_0");
15921 if (str && strcmp (str, "1") == 0) return 1;
15922 str = getenv ("SKIP_TEST_MOUNT");
15923 if (str && strcmp (str, "1") == 0) return 1;
15927 static int test_mount_0 (void)
15929 if (test_mount_0_skip ()) {
15930 printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_mount_0");
15934 /* InitNone|InitEmpty for test_mount_0 */
15936 char device[] = "/dev/sda";
15937 device[5] = devchar;
15939 suppress_error = 0;
15940 r = guestfs_blockdev_setrw (g, device);
15946 suppress_error = 0;
15947 r = guestfs_umount_all (g);
15953 suppress_error = 0;
15954 r = guestfs_lvm_remove_all (g);
15958 /* TestOutput for mount (0) */
15959 char expected[] = "new file contents";
15961 char device[] = "/dev/sda";
15962 device[5] = devchar;
15963 char lines_0[] = ",";
15969 suppress_error = 0;
15970 r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
15975 char fstype[] = "ext2";
15976 char device[] = "/dev/sda1";
15977 device[5] = devchar;
15979 suppress_error = 0;
15980 r = guestfs_mkfs (g, fstype, device);
15985 char device[] = "/dev/sda1";
15986 device[5] = devchar;
15987 char mountpoint[] = "/";
15989 suppress_error = 0;
15990 r = guestfs_mount (g, device, mountpoint);
15995 char path[] = "/new";
15996 char content[] = "new file contents";
15998 suppress_error = 0;
15999 r = guestfs_write_file (g, path, content, 0);
16004 char path[] = "/new";
16006 suppress_error = 0;
16007 r = guestfs_cat (g, path);
16010 if (strcmp (r, expected) != 0) {
16011 fprintf (stderr, "test_mount_0: expected \"%s\" but got \"%s\"\n", expected, r);
16019 int main (int argc, char *argv[])
16023 const char *srcdir;
16024 const char *filename;
16026 int nr_tests, test_num = 0;
16029 no_test_warnings ();
16031 g = guestfs_create ();
16033 printf ("guestfs_create FAILED\n");
16037 guestfs_set_error_handler (g, print_error, NULL);
16039 guestfs_set_path (g, "../appliance");
16041 filename = "test1.img";
16042 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16047 if (lseek (fd, 524288000, SEEK_SET) == -1) {
16053 if (write (fd, &c, 1) == -1) {
16059 if (close (fd) == -1) {
16064 if (guestfs_add_drive (g, filename) == -1) {
16065 printf ("guestfs_add_drive %s FAILED\n", filename);
16069 filename = "test2.img";
16070 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16075 if (lseek (fd, 52428800, SEEK_SET) == -1) {
16081 if (write (fd, &c, 1) == -1) {
16087 if (close (fd) == -1) {
16092 if (guestfs_add_drive (g, filename) == -1) {
16093 printf ("guestfs_add_drive %s FAILED\n", filename);
16097 filename = "test3.img";
16098 fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666);
16103 if (lseek (fd, 10485760, SEEK_SET) == -1) {
16109 if (write (fd, &c, 1) == -1) {
16115 if (close (fd) == -1) {
16120 if (guestfs_add_drive (g, filename) == -1) {
16121 printf ("guestfs_add_drive %s FAILED\n", filename);
16125 if (guestfs_add_drive (g, "../images/test.sqsh") == -1) {
16126 printf ("guestfs_add_drive %s FAILED\n", filename);
16130 if (guestfs_launch (g) == -1) {
16131 printf ("guestfs_launch FAILED\n");
16134 if (guestfs_wait_ready (g) == -1) {
16135 printf ("guestfs_wait_ready FAILED\n");
16139 /* Detect if the appliance uses /dev/sd* or /dev/hd* in device
16140 * names. This changed between RHEL 5 and RHEL 6 so we have to
16143 devs = guestfs_list_devices (g);
16144 if (devs == NULL || devs[0] == NULL) {
16145 printf ("guestfs_list_devices FAILED\n");
16148 if (strncmp (devs[0], "/dev/sd", 7) == 0)
16150 else if (strncmp (devs[0], "/dev/hd", 7) == 0)
16153 printf ("guestfs_list_devices returned unexpected string '%s'\n",
16157 for (i = 0; devs[i] != NULL; ++i)
16164 printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
16165 if (test_find_0 () == -1) {
16166 printf ("test_find_0 FAILED\n");
16170 printf ("%3d/%3d test_find_1\n", test_num, nr_tests);
16171 if (test_find_1 () == -1) {
16172 printf ("test_find_1 FAILED\n");
16176 printf ("%3d/%3d test_find_2\n", test_num, nr_tests);
16177 if (test_find_2 () == -1) {
16178 printf ("test_find_2 FAILED\n");
16182 printf ("%3d/%3d test_lvresize_0\n", test_num, nr_tests);
16183 if (test_lvresize_0 () == -1) {
16184 printf ("test_lvresize_0 FAILED\n");
16188 printf ("%3d/%3d test_zerofree_0\n", test_num, nr_tests);
16189 if (test_zerofree_0 () == -1) {
16190 printf ("test_zerofree_0 FAILED\n");
16194 printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests);
16195 if (test_hexdump_0 () == -1) {
16196 printf ("test_hexdump_0 FAILED\n");
16200 printf ("%3d/%3d test_strings_e_0\n", test_num, nr_tests);
16201 if (test_strings_e_0 () == -1) {
16202 printf ("test_strings_e_0 FAILED\n");
16206 printf ("%3d/%3d test_strings_e_1\n", test_num, nr_tests);
16207 if (test_strings_e_1 () == -1) {
16208 printf ("test_strings_e_1 FAILED\n");
16212 printf ("%3d/%3d test_strings_0\n", test_num, nr_tests);
16213 if (test_strings_0 () == -1) {
16214 printf ("test_strings_0 FAILED\n");
16218 printf ("%3d/%3d test_strings_1\n", test_num, nr_tests);
16219 if (test_strings_1 () == -1) {
16220 printf ("test_strings_1 FAILED\n");
16224 printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
16225 if (test_equal_0 () == -1) {
16226 printf ("test_equal_0 FAILED\n");
16230 printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
16231 if (test_equal_1 () == -1) {
16232 printf ("test_equal_1 FAILED\n");
16236 printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
16237 if (test_equal_2 () == -1) {
16238 printf ("test_equal_2 FAILED\n");
16242 printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
16243 if (test_ping_daemon_0 () == -1) {
16244 printf ("test_ping_daemon_0 FAILED\n");
16248 printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
16249 if (test_dmesg_0 () == -1) {
16250 printf ("test_dmesg_0 FAILED\n");
16254 printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
16255 if (test_drop_caches_0 () == -1) {
16256 printf ("test_drop_caches_0 FAILED\n");
16260 printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
16261 if (test_mv_0 () == -1) {
16262 printf ("test_mv_0 FAILED\n");
16266 printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
16267 if (test_mv_1 () == -1) {
16268 printf ("test_mv_1 FAILED\n");
16272 printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
16273 if (test_cp_a_0 () == -1) {
16274 printf ("test_cp_a_0 FAILED\n");
16278 printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
16279 if (test_cp_0 () == -1) {
16280 printf ("test_cp_0 FAILED\n");
16284 printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
16285 if (test_cp_1 () == -1) {
16286 printf ("test_cp_1 FAILED\n");
16290 printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
16291 if (test_cp_2 () == -1) {
16292 printf ("test_cp_2 FAILED\n");
16296 printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
16297 if (test_grub_install_0 () == -1) {
16298 printf ("test_grub_install_0 FAILED\n");
16302 printf ("%3d/%3d test_zero_0\n", test_num, nr_tests);
16303 if (test_zero_0 () == -1) {
16304 printf ("test_zero_0 FAILED\n");
16308 printf ("%3d/%3d test_fsck_0\n", test_num, nr_tests);
16309 if (test_fsck_0 () == -1) {
16310 printf ("test_fsck_0 FAILED\n");
16314 printf ("%3d/%3d test_fsck_1\n", test_num, nr_tests);
16315 if (test_fsck_1 () == -1) {
16316 printf ("test_fsck_1 FAILED\n");
16320 printf ("%3d/%3d test_set_e2uuid_0\n", test_num, nr_tests);
16321 if (test_set_e2uuid_0 () == -1) {
16322 printf ("test_set_e2uuid_0 FAILED\n");
16326 printf ("%3d/%3d test_set_e2uuid_1\n", test_num, nr_tests);
16327 if (test_set_e2uuid_1 () == -1) {
16328 printf ("test_set_e2uuid_1 FAILED\n");
16332 printf ("%3d/%3d test_set_e2uuid_2\n", test_num, nr_tests);
16333 if (test_set_e2uuid_2 () == -1) {
16334 printf ("test_set_e2uuid_2 FAILED\n");
16338 printf ("%3d/%3d test_set_e2uuid_3\n", test_num, nr_tests);
16339 if (test_set_e2uuid_3 () == -1) {
16340 printf ("test_set_e2uuid_3 FAILED\n");
16344 printf ("%3d/%3d test_set_e2label_0\n", test_num, nr_tests);
16345 if (test_set_e2label_0 () == -1) {
16346 printf ("test_set_e2label_0 FAILED\n");
16350 printf ("%3d/%3d test_pvremove_0\n", test_num, nr_tests);
16351 if (test_pvremove_0 () == -1) {
16352 printf ("test_pvremove_0 FAILED\n");
16356 printf ("%3d/%3d test_pvremove_1\n", test_num, nr_tests);
16357 if (test_pvremove_1 () == -1) {
16358 printf ("test_pvremove_1 FAILED\n");
16362 printf ("%3d/%3d test_pvremove_2\n", test_num, nr_tests);
16363 if (test_pvremove_2 () == -1) {
16364 printf ("test_pvremove_2 FAILED\n");
16368 printf ("%3d/%3d test_vgremove_0\n", test_num, nr_tests);
16369 if (test_vgremove_0 () == -1) {
16370 printf ("test_vgremove_0 FAILED\n");
16374 printf ("%3d/%3d test_vgremove_1\n", test_num, nr_tests);
16375 if (test_vgremove_1 () == -1) {
16376 printf ("test_vgremove_1 FAILED\n");
16380 printf ("%3d/%3d test_lvremove_0\n", test_num, nr_tests);
16381 if (test_lvremove_0 () == -1) {
16382 printf ("test_lvremove_0 FAILED\n");
16386 printf ("%3d/%3d test_lvremove_1\n", test_num, nr_tests);
16387 if (test_lvremove_1 () == -1) {
16388 printf ("test_lvremove_1 FAILED\n");
16392 printf ("%3d/%3d test_lvremove_2\n", test_num, nr_tests);
16393 if (test_lvremove_2 () == -1) {
16394 printf ("test_lvremove_2 FAILED\n");
16398 printf ("%3d/%3d test_mount_ro_0\n", test_num, nr_tests);
16399 if (test_mount_ro_0 () == -1) {
16400 printf ("test_mount_ro_0 FAILED\n");
16404 printf ("%3d/%3d test_mount_ro_1\n", test_num, nr_tests);
16405 if (test_mount_ro_1 () == -1) {
16406 printf ("test_mount_ro_1 FAILED\n");
16410 printf ("%3d/%3d test_tgz_in_0\n", test_num, nr_tests);
16411 if (test_tgz_in_0 () == -1) {
16412 printf ("test_tgz_in_0 FAILED\n");
16416 printf ("%3d/%3d test_tar_in_0\n", test_num, nr_tests);
16417 if (test_tar_in_0 () == -1) {
16418 printf ("test_tar_in_0 FAILED\n");
16422 printf ("%3d/%3d test_checksum_0\n", test_num, nr_tests);
16423 if (test_checksum_0 () == -1) {
16424 printf ("test_checksum_0 FAILED\n");
16428 printf ("%3d/%3d test_checksum_1\n", test_num, nr_tests);
16429 if (test_checksum_1 () == -1) {
16430 printf ("test_checksum_1 FAILED\n");
16434 printf ("%3d/%3d test_checksum_2\n", test_num, nr_tests);
16435 if (test_checksum_2 () == -1) {
16436 printf ("test_checksum_2 FAILED\n");
16440 printf ("%3d/%3d test_checksum_3\n", test_num, nr_tests);
16441 if (test_checksum_3 () == -1) {
16442 printf ("test_checksum_3 FAILED\n");
16446 printf ("%3d/%3d test_checksum_4\n", test_num, nr_tests);
16447 if (test_checksum_4 () == -1) {
16448 printf ("test_checksum_4 FAILED\n");
16452 printf ("%3d/%3d test_checksum_5\n", test_num, nr_tests);
16453 if (test_checksum_5 () == -1) {
16454 printf ("test_checksum_5 FAILED\n");
16458 printf ("%3d/%3d test_checksum_6\n", test_num, nr_tests);
16459 if (test_checksum_6 () == -1) {
16460 printf ("test_checksum_6 FAILED\n");
16464 printf ("%3d/%3d test_checksum_7\n", test_num, nr_tests);
16465 if (test_checksum_7 () == -1) {
16466 printf ("test_checksum_7 FAILED\n");
16470 printf ("%3d/%3d test_checksum_8\n", test_num, nr_tests);
16471 if (test_checksum_8 () == -1) {
16472 printf ("test_checksum_8 FAILED\n");
16476 printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
16477 if (test_download_0 () == -1) {
16478 printf ("test_download_0 FAILED\n");
16482 printf ("%3d/%3d test_upload_0\n", test_num, nr_tests);
16483 if (test_upload_0 () == -1) {
16484 printf ("test_upload_0 FAILED\n");
16488 printf ("%3d/%3d test_blockdev_rereadpt_0\n", test_num, nr_tests);
16489 if (test_blockdev_rereadpt_0 () == -1) {
16490 printf ("test_blockdev_rereadpt_0 FAILED\n");
16494 printf ("%3d/%3d test_blockdev_flushbufs_0\n", test_num, nr_tests);
16495 if (test_blockdev_flushbufs_0 () == -1) {
16496 printf ("test_blockdev_flushbufs_0 FAILED\n");
16500 printf ("%3d/%3d test_blockdev_getsize64_0\n", test_num, nr_tests);
16501 if (test_blockdev_getsize64_0 () == -1) {
16502 printf ("test_blockdev_getsize64_0 FAILED\n");
16506 printf ("%3d/%3d test_blockdev_getsz_0\n", test_num, nr_tests);
16507 if (test_blockdev_getsz_0 () == -1) {
16508 printf ("test_blockdev_getsz_0 FAILED\n");
16512 printf ("%3d/%3d test_blockdev_getbsz_0\n", test_num, nr_tests);
16513 if (test_blockdev_getbsz_0 () == -1) {
16514 printf ("test_blockdev_getbsz_0 FAILED\n");
16518 printf ("%3d/%3d test_blockdev_getss_0\n", test_num, nr_tests);
16519 if (test_blockdev_getss_0 () == -1) {
16520 printf ("test_blockdev_getss_0 FAILED\n");
16524 printf ("%3d/%3d test_blockdev_getro_0\n", test_num, nr_tests);
16525 if (test_blockdev_getro_0 () == -1) {
16526 printf ("test_blockdev_getro_0 FAILED\n");
16530 printf ("%3d/%3d test_blockdev_setrw_0\n", test_num, nr_tests);
16531 if (test_blockdev_setrw_0 () == -1) {
16532 printf ("test_blockdev_setrw_0 FAILED\n");
16536 printf ("%3d/%3d test_blockdev_setro_0\n", test_num, nr_tests);
16537 if (test_blockdev_setro_0 () == -1) {
16538 printf ("test_blockdev_setro_0 FAILED\n");
16542 printf ("%3d/%3d test_statvfs_0\n", test_num, nr_tests);
16543 if (test_statvfs_0 () == -1) {
16544 printf ("test_statvfs_0 FAILED\n");
16548 printf ("%3d/%3d test_lstat_0\n", test_num, nr_tests);
16549 if (test_lstat_0 () == -1) {
16550 printf ("test_lstat_0 FAILED\n");
16554 printf ("%3d/%3d test_stat_0\n", test_num, nr_tests);
16555 if (test_stat_0 () == -1) {
16556 printf ("test_stat_0 FAILED\n");
16560 printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests);
16561 if (test_command_lines_0 () == -1) {
16562 printf ("test_command_lines_0 FAILED\n");
16566 printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests);
16567 if (test_command_lines_1 () == -1) {
16568 printf ("test_command_lines_1 FAILED\n");
16572 printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests);
16573 if (test_command_lines_2 () == -1) {
16574 printf ("test_command_lines_2 FAILED\n");
16578 printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests);
16579 if (test_command_lines_3 () == -1) {
16580 printf ("test_command_lines_3 FAILED\n");
16584 printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests);
16585 if (test_command_lines_4 () == -1) {
16586 printf ("test_command_lines_4 FAILED\n");
16590 printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests);
16591 if (test_command_lines_5 () == -1) {
16592 printf ("test_command_lines_5 FAILED\n");
16596 printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests);
16597 if (test_command_lines_6 () == -1) {
16598 printf ("test_command_lines_6 FAILED\n");
16602 printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests);
16603 if (test_command_lines_7 () == -1) {
16604 printf ("test_command_lines_7 FAILED\n");
16608 printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests);
16609 if (test_command_lines_8 () == -1) {
16610 printf ("test_command_lines_8 FAILED\n");
16614 printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests);
16615 if (test_command_lines_9 () == -1) {
16616 printf ("test_command_lines_9 FAILED\n");
16620 printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests);
16621 if (test_command_lines_10 () == -1) {
16622 printf ("test_command_lines_10 FAILED\n");
16626 printf ("%3d/%3d test_command_0\n", test_num, nr_tests);
16627 if (test_command_0 () == -1) {
16628 printf ("test_command_0 FAILED\n");
16632 printf ("%3d/%3d test_command_1\n", test_num, nr_tests);
16633 if (test_command_1 () == -1) {
16634 printf ("test_command_1 FAILED\n");
16638 printf ("%3d/%3d test_command_2\n", test_num, nr_tests);
16639 if (test_command_2 () == -1) {
16640 printf ("test_command_2 FAILED\n");
16644 printf ("%3d/%3d test_command_3\n", test_num, nr_tests);
16645 if (test_command_3 () == -1) {
16646 printf ("test_command_3 FAILED\n");
16650 printf ("%3d/%3d test_command_4\n", test_num, nr_tests);
16651 if (test_command_4 () == -1) {
16652 printf ("test_command_4 FAILED\n");
16656 printf ("%3d/%3d test_command_5\n", test_num, nr_tests);
16657 if (test_command_5 () == -1) {
16658 printf ("test_command_5 FAILED\n");
16662 printf ("%3d/%3d test_command_6\n", test_num, nr_tests);
16663 if (test_command_6 () == -1) {
16664 printf ("test_command_6 FAILED\n");
16668 printf ("%3d/%3d test_command_7\n", test_num, nr_tests);
16669 if (test_command_7 () == -1) {
16670 printf ("test_command_7 FAILED\n");
16674 printf ("%3d/%3d test_command_8\n", test_num, nr_tests);
16675 if (test_command_8 () == -1) {
16676 printf ("test_command_8 FAILED\n");
16680 printf ("%3d/%3d test_command_9\n", test_num, nr_tests);
16681 if (test_command_9 () == -1) {
16682 printf ("test_command_9 FAILED\n");
16686 printf ("%3d/%3d test_command_10\n", test_num, nr_tests);
16687 if (test_command_10 () == -1) {
16688 printf ("test_command_10 FAILED\n");
16692 printf ("%3d/%3d test_command_11\n", test_num, nr_tests);
16693 if (test_command_11 () == -1) {
16694 printf ("test_command_11 FAILED\n");
16698 printf ("%3d/%3d test_file_0\n", test_num, nr_tests);
16699 if (test_file_0 () == -1) {
16700 printf ("test_file_0 FAILED\n");
16704 printf ("%3d/%3d test_file_1\n", test_num, nr_tests);
16705 if (test_file_1 () == -1) {
16706 printf ("test_file_1 FAILED\n");
16710 printf ("%3d/%3d test_file_2\n", test_num, nr_tests);
16711 if (test_file_2 () == -1) {
16712 printf ("test_file_2 FAILED\n");
16716 printf ("%3d/%3d test_umount_all_0\n", test_num, nr_tests);
16717 if (test_umount_all_0 () == -1) {
16718 printf ("test_umount_all_0 FAILED\n");
16722 printf ("%3d/%3d test_umount_all_1\n", test_num, nr_tests);
16723 if (test_umount_all_1 () == -1) {
16724 printf ("test_umount_all_1 FAILED\n");
16728 printf ("%3d/%3d test_mounts_0\n", test_num, nr_tests);
16729 if (test_mounts_0 () == -1) {
16730 printf ("test_mounts_0 FAILED\n");
16734 printf ("%3d/%3d test_umount_0\n", test_num, nr_tests);
16735 if (test_umount_0 () == -1) {
16736 printf ("test_umount_0 FAILED\n");
16740 printf ("%3d/%3d test_umount_1\n", test_num, nr_tests);
16741 if (test_umount_1 () == -1) {
16742 printf ("test_umount_1 FAILED\n");
16746 printf ("%3d/%3d test_write_file_0\n", test_num, nr_tests);
16747 if (test_write_file_0 () == -1) {
16748 printf ("test_write_file_0 FAILED\n");
16752 printf ("%3d/%3d test_write_file_1\n", test_num, nr_tests);
16753 if (test_write_file_1 () == -1) {
16754 printf ("test_write_file_1 FAILED\n");
16758 printf ("%3d/%3d test_write_file_2\n", test_num, nr_tests);
16759 if (test_write_file_2 () == -1) {
16760 printf ("test_write_file_2 FAILED\n");
16764 printf ("%3d/%3d test_write_file_3\n", test_num, nr_tests);
16765 if (test_write_file_3 () == -1) {
16766 printf ("test_write_file_3 FAILED\n");
16770 printf ("%3d/%3d test_write_file_4\n", test_num, nr_tests);
16771 if (test_write_file_4 () == -1) {
16772 printf ("test_write_file_4 FAILED\n");
16776 printf ("%3d/%3d test_write_file_5\n", test_num, nr_tests);
16777 if (test_write_file_5 () == -1) {
16778 printf ("test_write_file_5 FAILED\n");
16782 printf ("%3d/%3d test_mkfs_0\n", test_num, nr_tests);
16783 if (test_mkfs_0 () == -1) {
16784 printf ("test_mkfs_0 FAILED\n");
16788 printf ("%3d/%3d test_lvcreate_0\n", test_num, nr_tests);
16789 if (test_lvcreate_0 () == -1) {
16790 printf ("test_lvcreate_0 FAILED\n");
16794 printf ("%3d/%3d test_vgcreate_0\n", test_num, nr_tests);
16795 if (test_vgcreate_0 () == -1) {
16796 printf ("test_vgcreate_0 FAILED\n");
16800 printf ("%3d/%3d test_pvcreate_0\n", test_num, nr_tests);
16801 if (test_pvcreate_0 () == -1) {
16802 printf ("test_pvcreate_0 FAILED\n");
16806 printf ("%3d/%3d test_is_dir_0\n", test_num, nr_tests);
16807 if (test_is_dir_0 () == -1) {
16808 printf ("test_is_dir_0 FAILED\n");
16812 printf ("%3d/%3d test_is_dir_1\n", test_num, nr_tests);
16813 if (test_is_dir_1 () == -1) {
16814 printf ("test_is_dir_1 FAILED\n");
16818 printf ("%3d/%3d test_is_file_0\n", test_num, nr_tests);
16819 if (test_is_file_0 () == -1) {
16820 printf ("test_is_file_0 FAILED\n");
16824 printf ("%3d/%3d test_is_file_1\n", test_num, nr_tests);
16825 if (test_is_file_1 () == -1) {
16826 printf ("test_is_file_1 FAILED\n");
16830 printf ("%3d/%3d test_exists_0\n", test_num, nr_tests);
16831 if (test_exists_0 () == -1) {
16832 printf ("test_exists_0 FAILED\n");
16836 printf ("%3d/%3d test_exists_1\n", test_num, nr_tests);
16837 if (test_exists_1 () == -1) {
16838 printf ("test_exists_1 FAILED\n");
16842 printf ("%3d/%3d test_mkdir_p_0\n", test_num, nr_tests);
16843 if (test_mkdir_p_0 () == -1) {
16844 printf ("test_mkdir_p_0 FAILED\n");
16848 printf ("%3d/%3d test_mkdir_p_1\n", test_num, nr_tests);
16849 if (test_mkdir_p_1 () == -1) {
16850 printf ("test_mkdir_p_1 FAILED\n");
16854 printf ("%3d/%3d test_mkdir_p_2\n", test_num, nr_tests);
16855 if (test_mkdir_p_2 () == -1) {
16856 printf ("test_mkdir_p_2 FAILED\n");
16860 printf ("%3d/%3d test_mkdir_p_3\n", test_num, nr_tests);
16861 if (test_mkdir_p_3 () == -1) {
16862 printf ("test_mkdir_p_3 FAILED\n");
16866 printf ("%3d/%3d test_mkdir_p_4\n", test_num, nr_tests);
16867 if (test_mkdir_p_4 () == -1) {
16868 printf ("test_mkdir_p_4 FAILED\n");
16872 printf ("%3d/%3d test_mkdir_0\n", test_num, nr_tests);
16873 if (test_mkdir_0 () == -1) {
16874 printf ("test_mkdir_0 FAILED\n");
16878 printf ("%3d/%3d test_mkdir_1\n", test_num, nr_tests);
16879 if (test_mkdir_1 () == -1) {
16880 printf ("test_mkdir_1 FAILED\n");
16884 printf ("%3d/%3d test_rm_rf_0\n", test_num, nr_tests);
16885 if (test_rm_rf_0 () == -1) {
16886 printf ("test_rm_rf_0 FAILED\n");
16890 printf ("%3d/%3d test_rmdir_0\n", test_num, nr_tests);
16891 if (test_rmdir_0 () == -1) {
16892 printf ("test_rmdir_0 FAILED\n");
16896 printf ("%3d/%3d test_rmdir_1\n", test_num, nr_tests);
16897 if (test_rmdir_1 () == -1) {
16898 printf ("test_rmdir_1 FAILED\n");
16902 printf ("%3d/%3d test_rmdir_2\n", test_num, nr_tests);
16903 if (test_rmdir_2 () == -1) {
16904 printf ("test_rmdir_2 FAILED\n");
16908 printf ("%3d/%3d test_rm_0\n", test_num, nr_tests);
16909 if (test_rm_0 () == -1) {
16910 printf ("test_rm_0 FAILED\n");
16914 printf ("%3d/%3d test_rm_1\n", test_num, nr_tests);
16915 if (test_rm_1 () == -1) {
16916 printf ("test_rm_1 FAILED\n");
16920 printf ("%3d/%3d test_rm_2\n", test_num, nr_tests);
16921 if (test_rm_2 () == -1) {
16922 printf ("test_rm_2 FAILED\n");
16926 printf ("%3d/%3d test_read_lines_0\n", test_num, nr_tests);
16927 if (test_read_lines_0 () == -1) {
16928 printf ("test_read_lines_0 FAILED\n");
16932 printf ("%3d/%3d test_read_lines_1\n", test_num, nr_tests);
16933 if (test_read_lines_1 () == -1) {
16934 printf ("test_read_lines_1 FAILED\n");
16938 printf ("%3d/%3d test_lvs_0\n", test_num, nr_tests);
16939 if (test_lvs_0 () == -1) {
16940 printf ("test_lvs_0 FAILED\n");
16944 printf ("%3d/%3d test_lvs_1\n", test_num, nr_tests);
16945 if (test_lvs_1 () == -1) {
16946 printf ("test_lvs_1 FAILED\n");
16950 printf ("%3d/%3d test_vgs_0\n", test_num, nr_tests);
16951 if (test_vgs_0 () == -1) {
16952 printf ("test_vgs_0 FAILED\n");
16956 printf ("%3d/%3d test_vgs_1\n", test_num, nr_tests);
16957 if (test_vgs_1 () == -1) {
16958 printf ("test_vgs_1 FAILED\n");
16962 printf ("%3d/%3d test_pvs_0\n", test_num, nr_tests);
16963 if (test_pvs_0 () == -1) {
16964 printf ("test_pvs_0 FAILED\n");
16968 printf ("%3d/%3d test_pvs_1\n", test_num, nr_tests);
16969 if (test_pvs_1 () == -1) {
16970 printf ("test_pvs_1 FAILED\n");
16974 printf ("%3d/%3d test_list_partitions_0\n", test_num, nr_tests);
16975 if (test_list_partitions_0 () == -1) {
16976 printf ("test_list_partitions_0 FAILED\n");
16980 printf ("%3d/%3d test_list_partitions_1\n", test_num, nr_tests);
16981 if (test_list_partitions_1 () == -1) {
16982 printf ("test_list_partitions_1 FAILED\n");
16986 printf ("%3d/%3d test_list_devices_0\n", test_num, nr_tests);
16987 if (test_list_devices_0 () == -1) {
16988 printf ("test_list_devices_0 FAILED\n");
16992 printf ("%3d/%3d test_ls_0\n", test_num, nr_tests);
16993 if (test_ls_0 () == -1) {
16994 printf ("test_ls_0 FAILED\n");
16998 printf ("%3d/%3d test_cat_0\n", test_num, nr_tests);
16999 if (test_cat_0 () == -1) {
17000 printf ("test_cat_0 FAILED\n");
17004 printf ("%3d/%3d test_touch_0\n", test_num, nr_tests);
17005 if (test_touch_0 () == -1) {
17006 printf ("test_touch_0 FAILED\n");
17010 printf ("%3d/%3d test_sync_0\n", test_num, nr_tests);
17011 if (test_sync_0 () == -1) {
17012 printf ("test_sync_0 FAILED\n");
17016 printf ("%3d/%3d test_mount_0\n", test_num, nr_tests);
17017 if (test_mount_0 () == -1) {
17018 printf ("test_mount_0 FAILED\n");
17023 unlink ("test1.img");
17024 unlink ("test2.img");
17025 unlink ("test3.img");
17028 printf ("***** %d / %d tests FAILED *****\n", failed, nr_tests);